configVariableString.I 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // Filename: configVariableString.I
  2. // Created by: drose (20Oct04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: ConfigVariableString::Constructor
  20. // Access: Published
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. INLINE ConfigVariableString::
  24. ConfigVariableString(const string &name) :
  25. ConfigVariable(name, VT_string)
  26. {
  27. _core->set_used();
  28. }
  29. ////////////////////////////////////////////////////////////////////
  30. // Function: ConfigVariableString::Constructor
  31. // Access: Published
  32. // Description:
  33. ////////////////////////////////////////////////////////////////////
  34. INLINE ConfigVariableString::
  35. ConfigVariableString(const string &name, const string &default_value,
  36. const string &description, int flags) :
  37. ConfigVariable(name, VT_string, description, flags)
  38. {
  39. _core->set_default_value(default_value);
  40. _core->set_used();
  41. }
  42. ////////////////////////////////////////////////////////////////////
  43. // Function: ConfigVariableString::operator =
  44. // Access: Published
  45. // Description: Reassigns the variable's local value.
  46. ////////////////////////////////////////////////////////////////////
  47. INLINE void ConfigVariableString::
  48. operator = (const string &value) {
  49. set_value(value);
  50. }
  51. ////////////////////////////////////////////////////////////////////
  52. // Function: ConfigVariableString::string typecast operator
  53. // Access: Published
  54. // Description: Returns the variable's value.
  55. ////////////////////////////////////////////////////////////////////
  56. INLINE ConfigVariableString::
  57. operator string () const {
  58. return get_value();
  59. }
  60. ////////////////////////////////////////////////////////////////////
  61. // Function: ConfigVariableString::empty
  62. // Access: Published
  63. // Description: Returns true if the string is empty, false otherwise.
  64. ////////////////////////////////////////////////////////////////////
  65. INLINE bool ConfigVariableString::
  66. empty() const {
  67. return get_value().empty();
  68. }
  69. ////////////////////////////////////////////////////////////////////
  70. // Function: ConfigVariableString::Equality operator
  71. // Access: Public
  72. // Description:
  73. ////////////////////////////////////////////////////////////////////
  74. INLINE bool ConfigVariableString::
  75. operator == (const string &other) const {
  76. return get_value() == other;
  77. }
  78. ////////////////////////////////////////////////////////////////////
  79. // Function: ConfigVariableString::Inequality operator
  80. // Access: Public
  81. // Description:
  82. ////////////////////////////////////////////////////////////////////
  83. INLINE bool ConfigVariableString::
  84. operator != (const string &other) const {
  85. return get_value() != other;
  86. }
  87. ////////////////////////////////////////////////////////////////////
  88. // Function: ConfigVariableString::Ordering operator
  89. // Access: Public
  90. // Description:
  91. ////////////////////////////////////////////////////////////////////
  92. INLINE bool ConfigVariableString::
  93. operator < (const string &other) const {
  94. return get_value() < other;
  95. }
  96. ////////////////////////////////////////////////////////////////////
  97. // Function: ConfigVariableString::set_value
  98. // Access: Published
  99. // Description: Reassigns the variable's local value.
  100. ////////////////////////////////////////////////////////////////////
  101. INLINE void ConfigVariableString::
  102. set_value(const string &value) {
  103. set_string_value(value);
  104. }
  105. ////////////////////////////////////////////////////////////////////
  106. // Function: ConfigVariableString::get_value
  107. // Access: Published
  108. // Description: Returns the variable's value.
  109. ////////////////////////////////////////////////////////////////////
  110. INLINE string ConfigVariableString::
  111. get_value() const {
  112. return get_string_value();
  113. }
  114. ////////////////////////////////////////////////////////////////////
  115. // Function: ConfigVariableString::get_default_value
  116. // Access: Published
  117. // Description: Returns the variable's default value.
  118. ////////////////////////////////////////////////////////////////////
  119. INLINE string ConfigVariableString::
  120. get_default_value() const {
  121. const ConfigDeclaration *decl = ConfigVariable::get_default_value();
  122. if (decl != (ConfigDeclaration *)NULL) {
  123. return decl->get_string_word(0);
  124. }
  125. return string();
  126. }
  127. ////////////////////////////////////////////////////////////////////
  128. // Function: ConfigVariableString::get_word
  129. // Access: Published
  130. // Description: Returns the variable's nth value.
  131. ////////////////////////////////////////////////////////////////////
  132. INLINE string ConfigVariableString::
  133. get_word(int n) const {
  134. return get_string_word(n);
  135. }
  136. ////////////////////////////////////////////////////////////////////
  137. // Function: ConfigVariableString::set_word
  138. // Access: Published
  139. // Description: Reassigns the variable's nth value. This makes a
  140. // local copy of the variable's overall value.
  141. ////////////////////////////////////////////////////////////////////
  142. INLINE void ConfigVariableString::
  143. set_word(int n, const string &value) {
  144. set_string_word(n, value);
  145. }