Panda3D
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
ConfigDeclaration Class Reference

A single declaration of a config variable, typically defined as one line in a .prc file, e.g. More...

#include "configDeclaration.h"

Inheritance diagram for ConfigDeclaration:
ConfigFlags

Public Member Functions

bool get_bool_word (int n) const
 Returns the boolean value of the nth word of the declaration's value, or false if there is no nth value. More...
 
int get_decl_seq () const
 Returns the sequence number of the declaration within the page. More...
 
double get_double_word (int n) const
 Returns the integer value of the nth word of the declaration's value, or 0 if there is no nth value. More...
 
PN_int64 get_int64_word (int n) const
 Returns the int64 value of the nth word of the declaration's value, or 0 if there is no nth value. More...
 
int get_int_word (int n) const
 Returns the integer value of the nth word of the declaration's value, or 0 if there is no nth value. More...
 
int get_num_words () const
 Returns the number of words in the declaration's value. More...
 
ConfigPageget_page () const
 Returns the page on which this declaration can be found. More...
 
const string & get_string_value () const
 Returns the value assigned to this variable. More...
 
string get_string_word (int n) const
 Returns the string value of the nth word of the declaration's value, or empty string if there is no nth value. More...
 
ConfigVariableCoreget_variable () const
 Returns the variable that this declaration names. More...
 
bool has_bool_word (int n) const
 Returns true if the declaration's value has a valid boolean value for the nth word. More...
 
bool has_double_word (int n) const
 Returns true if the declaration's value has a valid integer value for the nth word. More...
 
bool has_int64_word (int n) const
 Returns true if the declaration's value has a valid int64 value for the nth word. More...
 
bool has_int_word (int n) const
 Returns true if the declaration's value has a valid integer value for the nth word. More...
 
bool has_string_word (int n) const
 Returns true if the declaration's value has a valid string value for the nth word. More...
 
bool operator< (const ConfigDeclaration &other) const
 Sorts two declarations in order based on the order in which their respective pages were loaded, and the order in which they appear within the same page. More...
 
void output (ostream &out) const
 
void set_bool_word (int n, bool value)
 Changes the nth word to the indicated value without affecting the other words. More...
 
void set_double_word (int n, double value)
 Changes the nth word to the indicated value without affecting the other words. More...
 
void set_int64_word (int n, PN_int64 value)
 Changes the nth word to the indicated value without affecting the other words. More...
 
void set_int_word (int n, int value)
 Changes the nth word to the indicated value without affecting the other words. More...
 
void set_string_value (const string &value)
 Changes the value assigned to this variable. More...
 
void set_string_word (int n, const string &value)
 Changes the nth word to the indicated value without affecting the other words. More...
 
void write (ostream &out) const
 

Static Public Member Functions

static string downcase (const string &s)
 Returns the input string with all uppercase letters converted to lowercase. More...
 
static int extract_words (const string &str, vector_string &words)
 Divides the string into a number of words according to whitespace. More...
 

Friends

class ConfigPage
 

Additional Inherited Members

- Public Types inherited from ConfigFlags
enum  ValueType {
  VT_undefined, VT_list, VT_string, VT_filename,
  VT_bool, VT_int, VT_double, VT_enum,
  VT_search_path, VT_int64, VT_color
}
 
enum  VariableFlags {
  F_trust_level_mask = 0x00000fff, F_open = 0x00001000, F_closed = 0x00002000, F_dynamic = 0x00004000,
  F_dconfig = 0x00008000
}
 

Detailed Description

A single declaration of a config variable, typically defined as one line in a .prc file, e.g.

"show-frame-rate-meter 1". This is really just a pairing of a string name (actually, a ConfigVariableCore pointer) to a string value.

Definition at line 36 of file configDeclaration.h.

Member Function Documentation

◆ downcase()

string ConfigDeclaration::downcase ( const string &  s)
static

Returns the input string with all uppercase letters converted to lowercase.

Definition at line 437 of file configDeclaration.cxx.

Referenced by extract_words().

◆ extract_words()

int ConfigDeclaration::extract_words ( const string &  str,
vector_string &  words 
)
static

Divides the string into a number of words according to whitespace.

The words vector should be cleared by the user before calling; otherwise, the list of words in the string will be appended to the end of whatever was there before.

The return value is the number of words extracted.

Definition at line 407 of file configDeclaration.cxx.

References downcase().

Referenced by ConfigPageManager::reload_implicit_pages(), and set_double_word().

◆ get_bool_word()

bool ConfigDeclaration::get_bool_word ( int  n) const
inline

Returns the boolean value of the nth word of the declaration's value, or false if there is no nth value.

See also has_bool_word().

Definition at line 196 of file configDeclaration.I.

References get_int_word(), and has_string_word().

Referenced by ConfigVariable::get_bool_word(), ConfigVariableBool::get_default_value(), and get_string_word().

◆ get_decl_seq()

int ConfigDeclaration::get_decl_seq ( ) const
inline

Returns the sequence number of the declaration within the page.

Sequence numbers are assigned as each declaration is created; each declaration is given a higher sequence number than all the declarations created in the page before it.

Definition at line 271 of file configDeclaration.I.

Referenced by get_double_word(), and operator<().

◆ get_double_word()

double ConfigDeclaration::get_double_word ( int  n) const
inline

Returns the integer value of the nth word of the declaration's value, or 0 if there is no nth value.

See also has_double_word().

Definition at line 250 of file configDeclaration.I.

References get_decl_seq(), and has_string_word().

Referenced by ConfigVariableDouble::get_default_value(), ConfigVariableColor::get_default_value(), ConfigVariable::get_double_word(), and get_int64_word().

◆ get_int64_word()

PN_int64 ConfigDeclaration::get_int64_word ( int  n) const
inline

Returns the int64 value of the nth word of the declaration's value, or 0 if there is no nth value.

See also has_int64_word().

Definition at line 232 of file configDeclaration.I.

References get_double_word(), and has_string_word().

Referenced by ConfigVariableInt64::get_default_value(), ConfigVariable::get_int64_word(), and get_int_word().

◆ get_int_word()

int ConfigDeclaration::get_int_word ( int  n) const
inline

Returns the integer value of the nth word of the declaration's value, or 0 if there is no nth value.

See also has_int_word().

Definition at line 214 of file configDeclaration.I.

References get_int64_word(), and has_string_word().

Referenced by get_bool_word(), ConfigVariableInt::get_default_value(), and ConfigVariable::get_int_word().

◆ get_num_words()

int ConfigDeclaration::get_num_words ( ) const
inline

Returns the number of words in the declaration's value.

A word is defined as a sequence of non-whitespace characters delimited by whitespace.

Definition at line 90 of file configDeclaration.I.

References has_string_word().

Referenced by ConfigVariableColor::get_default_value(), ConfigVariable::get_num_words(), and set_string_value().

◆ get_page()

ConfigPage * ConfigDeclaration::get_page ( ) const
inline

Returns the page on which this declaration can be found.

Definition at line 41 of file configDeclaration.I.

References get_variable().

Referenced by ConfigVariableManager::list_dynamic_variables(), ConfigVariableManager::list_unused_variables(), and operator<().

◆ get_string_value()

const string & ConfigDeclaration::get_string_value ( ) const
inline

◆ get_string_word()

string ConfigDeclaration::get_string_word ( int  n) const
inline

Returns the string value of the nth word of the declaration's value, or empty string if there is no nth value.

See also has_string_word().

Definition at line 181 of file configDeclaration.I.

References get_bool_word(), and has_string_word().

Referenced by ConfigVariable::get_string_word(), and has_double_word().

◆ get_variable()

ConfigVariableCore * ConfigDeclaration::get_variable ( ) const
inline

Returns the variable that this declaration names.

This variable may or may not have been defined by the time the declaration is read.

Definition at line 53 of file configDeclaration.I.

References get_string_value().

Referenced by get_page().

◆ has_bool_word()

bool ConfigDeclaration::has_bool_word ( int  n) const
inline

Returns true if the declaration's value has a valid boolean value for the nth word.

Definition at line 120 of file configDeclaration.I.

References has_int_word(), and has_string_word().

Referenced by ConfigVariable::has_bool_word(), and has_string_word().

◆ has_double_word()

bool ConfigDeclaration::has_double_word ( int  n) const
inline

Returns true if the declaration's value has a valid integer value for the nth word.

Definition at line 165 of file configDeclaration.I.

References get_string_word(), and has_string_word().

Referenced by ConfigVariable::has_double_word(), and has_int64_word().

◆ has_int64_word()

bool ConfigDeclaration::has_int64_word ( int  n) const
inline

Returns true if the declaration's value has a valid int64 value for the nth word.

Definition at line 150 of file configDeclaration.I.

References has_double_word(), and has_string_word().

Referenced by ConfigVariable::has_int64_word(), and has_int_word().

◆ has_int_word()

bool ConfigDeclaration::has_int_word ( int  n) const
inline

Returns true if the declaration's value has a valid integer value for the nth word.

Definition at line 135 of file configDeclaration.I.

References has_int64_word(), and has_string_word().

Referenced by has_bool_word(), and ConfigVariable::has_int_word().

◆ has_string_word()

bool ConfigDeclaration::has_string_word ( int  n) const
inline

Returns true if the declaration's value has a valid string value for the nth word.

This is really the same thing as asking if there are at least n words in the value.

Definition at line 106 of file configDeclaration.I.

References has_bool_word().

Referenced by get_bool_word(), get_double_word(), get_int64_word(), get_int_word(), get_num_words(), get_string_word(), has_bool_word(), has_double_word(), has_int64_word(), has_int_word(), and ConfigVariable::has_string_word().

◆ operator<()

bool ConfigDeclaration::operator< ( const ConfigDeclaration other) const
inline

Sorts two declarations in order based on the order in which their respective pages were loaded, and the order in which they appear within the same page.

Definition at line 24 of file configDeclaration.I.

References get_decl_seq(), and get_page().

◆ set_bool_word()

void ConfigDeclaration::set_bool_word ( int  n,
bool  value 
)

Changes the nth word to the indicated value without affecting the other words.

Definition at line 95 of file configDeclaration.cxx.

References set_int_word(), and ConfigVariable::set_string_word().

Referenced by set_string_word().

◆ set_double_word()

void ConfigDeclaration::set_double_word ( int  n,
double  value 
)

Changes the nth word to the indicated value without affecting the other words.

Definition at line 140 of file configDeclaration.cxx.

References extract_words(), ConfigVariable::get_string_value(), and ConfigVariable::set_string_word().

Referenced by set_int64_word().

◆ set_int64_word()

void ConfigDeclaration::set_int64_word ( int  n,
PN_int64  value 
)

Changes the nth word to the indicated value without affecting the other words.

Definition at line 125 of file configDeclaration.cxx.

References set_double_word(), and ConfigVariable::set_string_word().

Referenced by set_int_word().

◆ set_int_word()

void ConfigDeclaration::set_int_word ( int  n,
int  value 
)

Changes the nth word to the indicated value without affecting the other words.

Definition at line 110 of file configDeclaration.cxx.

References set_int64_word(), and ConfigVariable::set_string_word().

Referenced by set_bool_word().

◆ set_string_value()

void ConfigDeclaration::set_string_value ( const string &  value)
inline

Changes the value assigned to this variable.

Definition at line 76 of file configDeclaration.I.

References get_num_words().

Referenced by get_string_value().

◆ set_string_word()

void ConfigDeclaration::set_string_word ( int  n,
const string &  value 
)

Changes the nth word to the indicated value without affecting the other words.

Definition at line 61 of file configDeclaration.cxx.

References set_bool_word().


The documentation for this class was generated from the following files: