2
0

string_setting.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2012-2014 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. #include "string_setting.h"
  6. #include "string_utils.h"
  7. namespace crown
  8. {
  9. static StringSetting* g_string_settings_head = NULL;
  10. StringSetting::StringSetting(const char* name, const char* synopsis, const char* value) :
  11. m_name(name),
  12. m_synopsis(synopsis),
  13. m_value(value),
  14. m_next(NULL)
  15. {
  16. *this = value;
  17. if (g_string_settings_head != NULL)
  18. {
  19. m_next = g_string_settings_head;
  20. }
  21. g_string_settings_head = this;
  22. }
  23. const char* StringSetting::name() const
  24. {
  25. return m_name;
  26. }
  27. const char* StringSetting::synopsis() const
  28. {
  29. return m_synopsis;
  30. }
  31. const char* StringSetting::value() const
  32. {
  33. return m_value;
  34. }
  35. StringSetting& StringSetting::operator=(const char* value)
  36. {
  37. m_value = value;
  38. return *this;
  39. }
  40. StringSetting* StringSetting::find_setting(const char* name)
  41. {
  42. StringSetting* head = g_string_settings_head;
  43. while (head != NULL)
  44. {
  45. if (strcmp(name, head->name()) == 0)
  46. {
  47. return head;
  48. }
  49. head = head->m_next;
  50. }
  51. return NULL;
  52. }
  53. } // namespace crown