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