Panda3D
 All Classes Functions Variables Enumerations
configVariableString.I
00001 // Filename: configVariableString.I
00002 // Created by:  drose (20Oct04)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: ConfigVariableString::Constructor
00018 //       Access: Published
00019 //  Description: 
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE ConfigVariableString::
00022 ConfigVariableString(const string &name) :
00023   ConfigVariable(name, VT_string),
00024   _local_modified(initial_invalid_cache())
00025 {
00026   _core->set_used();
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: ConfigVariableString::Constructor
00031 //       Access: Published
00032 //  Description: 
00033 ////////////////////////////////////////////////////////////////////
00034 INLINE ConfigVariableString::
00035 ConfigVariableString(const string &name, const string &default_value, 
00036                      const string &description, int flags) :
00037 #ifdef PRC_SAVE_DESCRIPTIONS
00038   ConfigVariable(name, VT_string, description, flags),
00039 #else
00040   ConfigVariable(name, VT_string, string(), flags),
00041 #endif
00042   _local_modified(initial_invalid_cache())
00043 {
00044   _core->set_default_value(default_value);
00045   _core->set_used();
00046 }
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //     Function: ConfigVariableString::operator =
00050 //       Access: Published
00051 //  Description: Reassigns the variable's local value.
00052 ////////////////////////////////////////////////////////////////////
00053 INLINE void ConfigVariableString::
00054 operator = (const string &value) {
00055   set_value(value);
00056 }
00057 
00058 ////////////////////////////////////////////////////////////////////
00059 //     Function: ConfigVariableString::string typecast operator
00060 //       Access: Published
00061 //  Description: Returns the variable's value.
00062 ////////////////////////////////////////////////////////////////////
00063 INLINE ConfigVariableString::
00064 operator const string & () const {
00065   return get_value();
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: ConfigVariableString::c_str
00070 //       Access: Public
00071 //  Description:
00072 ////////////////////////////////////////////////////////////////////
00073 INLINE const char *ConfigVariableString::
00074 c_str() const {
00075   return get_value().c_str();
00076 }
00077 
00078 ////////////////////////////////////////////////////////////////////
00079 //     Function: ConfigVariableString::empty
00080 //       Access: Public
00081 //  Description:
00082 ////////////////////////////////////////////////////////////////////
00083 INLINE bool ConfigVariableString::
00084 empty() const {
00085   return get_value().empty();
00086 }
00087 
00088 ////////////////////////////////////////////////////////////////////
00089 //     Function: ConfigVariableString::length
00090 //       Access: Public
00091 //  Description:
00092 ////////////////////////////////////////////////////////////////////
00093 INLINE size_t ConfigVariableString::
00094 length() const {
00095   return get_value().length();
00096 }
00097 
00098 ////////////////////////////////////////////////////////////////////
00099 //     Function: ConfigVariableString::Indexing operator
00100 //       Access: Public
00101 //  Description:
00102 ////////////////////////////////////////////////////////////////////
00103 INLINE char ConfigVariableString::
00104 operator [] (int n) const {
00105   assert(n >= 0 && n < (int)length());
00106   return get_value()[n];
00107 }
00108 
00109 ////////////////////////////////////////////////////////////////////
00110 //     Function: ConfigVariableString::Equality operator
00111 //       Access: Public
00112 //  Description:
00113 ////////////////////////////////////////////////////////////////////
00114 INLINE bool ConfigVariableString::
00115 operator == (const string &other) const {
00116   return get_value() == other;
00117 }
00118 
00119 ////////////////////////////////////////////////////////////////////
00120 //     Function: ConfigVariableString::Inequality operator
00121 //       Access: Public
00122 //  Description:
00123 ////////////////////////////////////////////////////////////////////
00124 INLINE bool ConfigVariableString::
00125 operator != (const string &other) const {
00126   return get_value() != other;
00127 }
00128 
00129 ////////////////////////////////////////////////////////////////////
00130 //     Function: ConfigVariableString::Ordering operator
00131 //       Access: Public
00132 //  Description:
00133 ////////////////////////////////////////////////////////////////////
00134 INLINE bool ConfigVariableString::
00135 operator < (const string &other) const {
00136   return get_value() < other;
00137 }
00138 
00139 ////////////////////////////////////////////////////////////////////
00140 //     Function: ConfigVariableString::set_value
00141 //       Access: Published
00142 //  Description: Reassigns the variable's local value.
00143 ////////////////////////////////////////////////////////////////////
00144 INLINE void ConfigVariableString::
00145 set_value(const string &value) {
00146   set_string_value(value);
00147 }
00148 
00149 ////////////////////////////////////////////////////////////////////
00150 //     Function: ConfigVariableString::get_value
00151 //       Access: Published
00152 //  Description: Returns the variable's value.
00153 ////////////////////////////////////////////////////////////////////
00154 INLINE const string &ConfigVariableString::
00155 get_value() const {
00156   TAU_PROFILE("const string &ConfigVariableString::get_value() const", " ", TAU_USER);
00157   if (!is_cache_valid(_local_modified)) {
00158     mark_cache_valid(((ConfigVariableString *)this)->_local_modified);
00159     ((ConfigVariableString *)this)->_cache = get_string_value();
00160   }
00161   return _cache;
00162 }
00163 
00164 ////////////////////////////////////////////////////////////////////
00165 //     Function: ConfigVariableString::get_default_value
00166 //       Access: Published
00167 //  Description: Returns the variable's default value.
00168 ////////////////////////////////////////////////////////////////////
00169 INLINE string ConfigVariableString::
00170 get_default_value() const {
00171   const ConfigDeclaration *decl = ConfigVariable::get_default_value();
00172   if (decl != (ConfigDeclaration *)NULL) {
00173     return decl->get_string_value();
00174   }
00175   return string();
00176 }
00177 
00178 ////////////////////////////////////////////////////////////////////
00179 //     Function: ConfigVariableString::get_word
00180 //       Access: Published
00181 //  Description: Returns the variable's nth value.
00182 ////////////////////////////////////////////////////////////////////
00183 INLINE string ConfigVariableString::
00184 get_word(int n) const {
00185   return get_string_word(n);
00186 }
00187 
00188 ////////////////////////////////////////////////////////////////////
00189 //     Function: ConfigVariableString::set_word
00190 //       Access: Published
00191 //  Description: Reassigns the variable's nth value.  This makes a
00192 //               local copy of the variable's overall value.
00193 ////////////////////////////////////////////////////////////////////
00194 INLINE void ConfigVariableString::
00195 set_word(int n, const string &value) {
00196   set_string_word(n, value);
00197 }
 All Classes Functions Variables Enumerations