18INLINE ConfigVariable::
19ConfigVariable(
const std::string &name, ConfigVariable::ValueType value_type) :
28INLINE ConfigVariable::
29ConfigVariable(
const std::string &name, ConfigVariable::ValueType value_type,
30 const std::string &description,
int flags) :
40INLINE ConfigVariable::
41ConfigVariable(
const std::string &name) :
50INLINE ConfigVariable::
59get_default_value()
const {
60 nassertr(is_constructed(),
nullptr);
61 return _core->get_default_value();
69 nassertr(is_constructed(), *
new std::string());
81 nassertv(is_constructed());
82 _core->make_local_value()->set_string_value(string_value);
91 nassertv(is_constructed());
92 _core->clear_local_value();
101 nassertr(is_constructed(), 0);
111INLINE
bool ConfigVariable::
112has_string_word(
size_t n)
const {
113 nassertr(is_constructed(),
false);
122INLINE
bool ConfigVariable::
123has_bool_word(
size_t n)
const {
124 nassertr(is_constructed(),
false);
133INLINE
bool ConfigVariable::
134has_int_word(
size_t n)
const {
135 nassertr(is_constructed(),
false);
144INLINE
bool ConfigVariable::
145has_int64_word(
size_t n)
const {
146 nassertr(is_constructed(),
false);
155INLINE
bool ConfigVariable::
156has_double_word(
size_t n)
const {
157 nassertr(is_constructed(),
false);
166INLINE std::string ConfigVariable::
167get_string_word(
size_t n)
const {
168 nassertr(is_constructed(), std::string());
177INLINE
bool ConfigVariable::
178get_bool_word(
size_t n)
const {
179 nassertr(is_constructed(),
false);
188INLINE
int ConfigVariable::
189get_int_word(
size_t n)
const {
190 nassertr(is_constructed(), 0);
199INLINE int64_t ConfigVariable::
200get_int64_word(
size_t n)
const {
201 nassertr(is_constructed(), 0);
210INLINE
double ConfigVariable::
211get_double_word(
size_t n)
const {
212 nassertr(is_constructed(), 0.0);
221INLINE
void ConfigVariable::
222set_string_word(
size_t n,
const std::string &value) {
223 nassertv(is_constructed());
224 _core->make_local_value()->set_string_word(n, value);
231INLINE
void ConfigVariable::
232set_bool_word(
size_t n,
bool value) {
233 nassertv(is_constructed());
234 _core->make_local_value()->set_bool_word(n, value);
241INLINE
void ConfigVariable::
242set_int_word(
size_t n,
int value) {
243 nassertv(is_constructed());
244 _core->make_local_value()->set_int_word(n, value);
251INLINE
void ConfigVariable::
252set_int64_word(
size_t n, int64_t value) {
253 nassertv(is_constructed());
254 _core->make_local_value()->set_int64_word(n, value);
261INLINE
void ConfigVariable::
262set_double_word(
size_t n,
double value) {
263 nassertv(is_constructed());
264 _core->make_local_value()->set_double_word(n, value);
273INLINE
bool ConfigVariable::
274is_constructed()
const {
276 if (_core ==
nullptr) {
277 report_unconstructed();
A single declaration of a config variable, typically defined as one line in a .prc file,...
int64_t get_int64_word(size_t n) const
Returns the int64 value of the nth word of the declaration's value, or 0 if there is no nth value.
bool has_bool_word(size_t n) const
Returns true if the declaration's value has a valid boolean value for the nth word.
bool get_bool_word(size_t n) const
Returns the boolean value of the nth word of the declaration's value, or false if there is no nth val...
double get_double_word(size_t n) const
Returns the integer value of the nth word of the declaration's value, or 0 if there is no nth value.
bool has_int_word(size_t n) const
Returns true if the declaration's value has a valid integer value for the nth word.
size_t get_num_words() const
Returns the number of words in the declaration's value.
int get_int_word(size_t n) const
Returns the integer value of the nth word of the declaration's value, or 0 if there is no nth value.
bool has_double_word(size_t n) const
Returns true if the declaration's value has a valid integer value for the nth word.
const std::string & get_string_value() const
Returns the value assigned to this variable.
std::string get_string_word(size_t n) const
Returns the string value of the nth word of the declaration's value, or empty string if there is no n...
bool has_int64_word(size_t n) const
Returns true if the declaration's value has a valid int64 value for the nth word.
bool has_string_word(size_t n) const
Returns true if the declaration's value has a valid string value for the nth word.
This class is the base class for both ConfigVariableList and ConfigVariable (and hence for all of the...
void clear_value()
Removes the value assigned to this variable, and lets its original value (as read from the prc files)...
size_t get_num_words() const
Returns the number of words in the variable's value.
const std::string & get_string_value() const
Returns the toplevel value of the variable, formatted as a string.
void set_string_value(const std::string &value)
Changes the value assigned to this variable.