Panda3D
configVariableString.h
1 // Filename: configVariableString.h
2 // Created by: drose (20Oct04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CONFIGVARIABLESTRING_H
16 #define CONFIGVARIABLESTRING_H
17 
18 #include "dtoolbase.h"
19 #include "configVariable.h"
20 
21 ////////////////////////////////////////////////////////////////////
22 // Class : ConfigVariableString
23 // Description : This is a convenience class to specialize
24 // ConfigVariable as a string type.
25 ////////////////////////////////////////////////////////////////////
26 class EXPCL_DTOOLCONFIG ConfigVariableString : public ConfigVariable {
27 PUBLISHED:
28  INLINE ConfigVariableString(const string &name);
29  INLINE ConfigVariableString(const string &name, const string &default_value,
30  const string &description = string(), int flags = 0);
31 
32  INLINE void operator = (const string &value);
33  INLINE operator const string & () const;
34 
35  // These methods help the ConfigVariableString act like a C++ string
36  // object.
37  INLINE const char *c_str() const;
38  INLINE bool empty() const;
39  INLINE size_t length() const;
40  INLINE char operator [] (int n) const;
41 
42  // Comparison operators are handy.
43  INLINE bool operator == (const string &other) const;
44  INLINE bool operator != (const string &other) const;
45  INLINE bool operator < (const string &other) const;
46 
47  INLINE void set_value(const string &value);
48  INLINE const string &get_value() const;
49  INLINE string get_default_value() const;
50 
51  INLINE string get_word(int n) const;
52  INLINE void set_word(int n, const string &value);
53 
54 private:
55  void reload_cache();
56 
57 private:
58  AtomicAdjust::Integer _local_modified;
59  string _cache;
60 };
61 
62 #include "configVariableString.I"
63 
64 #endif
const ConfigDeclaration * get_default_value() const
Returns the default variable specified for this variable.
This is a generic, untyped ConfigVariable.
This is a convenience class to specialize ConfigVariable as a string type.