add more string-like functionality to ConfigVariableString
This commit is contained in:
parent
a483e0d497
commit
9a3c2e76a1
|
|
@ -84,7 +84,7 @@ get_default_value() const {
|
|||
// Description: Returns the toplevel value of the variable, formatted
|
||||
// as a string.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE string ConfigVariable::
|
||||
INLINE const string &ConfigVariable::
|
||||
get_string_value() const {
|
||||
const ConfigDeclaration *decl = _core->get_declaration(0);
|
||||
return decl->get_string_value();
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ PUBLISHED:
|
|||
|
||||
INLINE const ConfigDeclaration *get_default_value() const;
|
||||
|
||||
INLINE string get_string_value() const;
|
||||
INLINE const string &get_string_value() const;
|
||||
INLINE void set_string_value(const string &value);
|
||||
|
||||
INLINE int get_num_words() const;
|
||||
|
|
|
|||
|
|
@ -59,20 +59,51 @@ operator = (const string &value) {
|
|||
// Description: Returns the variable's value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE ConfigVariableString::
|
||||
operator string () const {
|
||||
operator const string & () const {
|
||||
return get_value();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ConfigVariableString::c_str
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE const char *ConfigVariableString::
|
||||
c_str() const {
|
||||
return get_value().c_str();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ConfigVariableString::empty
|
||||
// Access: Published
|
||||
// Description: Returns true if the string is empty, false otherwise.
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool ConfigVariableString::
|
||||
empty() const {
|
||||
return get_value().empty();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ConfigVariableString::length
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE size_t ConfigVariableString::
|
||||
length() const {
|
||||
return get_value().length();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ConfigVariableString::Indexing operator
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE char ConfigVariableString::
|
||||
operator [] (int n) const {
|
||||
assert(n >= 0 && n < (int)length());
|
||||
return get_value()[n];
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: ConfigVariableString::Equality operator
|
||||
// Access: Public
|
||||
|
|
@ -118,7 +149,7 @@ set_value(const string &value) {
|
|||
// Access: Published
|
||||
// Description: Returns the variable's value.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE string ConfigVariableString::
|
||||
INLINE const string &ConfigVariableString::
|
||||
get_value() const {
|
||||
return get_string_value();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,8 +34,14 @@ PUBLISHED:
|
|||
const string &description = string(), int flags = 0);
|
||||
|
||||
INLINE void operator = (const string &value);
|
||||
INLINE operator string () const;
|
||||
INLINE operator const string & () const;
|
||||
|
||||
// These methods help the ConfigVariableString act like a C++ string
|
||||
// object.
|
||||
INLINE const char *c_str() const;
|
||||
INLINE bool empty() const;
|
||||
INLINE size_t length() const;
|
||||
INLINE char operator [] (int n) const;
|
||||
|
||||
// Comparison operators are handy.
|
||||
INLINE bool operator == (const string &other) const;
|
||||
|
|
@ -43,7 +49,7 @@ PUBLISHED:
|
|||
INLINE bool operator < (const string &other) const;
|
||||
|
||||
INLINE void set_value(const string &value);
|
||||
INLINE string get_value() const;
|
||||
INLINE const string &get_value() const;
|
||||
INLINE string get_default_value() const;
|
||||
|
||||
INLINE string get_word(int n) const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue