Panda3D
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | 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 (size_t n) const
 Returns the boolean value of the nth word of the declaration's value, or false if there is no nth value.
 
int get_decl_seq () const
 Returns the sequence number of the declaration within the page.
 
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.
 
Filename get_filename_value () const
 Interprets the string value as a filename and returns it, with any variables expanded.
 
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.
 
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.
 
size_t get_num_words () const
 Returns the number of words in the declaration's value.
 
ConfigPageget_page () const
 
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 nth value.
 
ConfigVariableCoreget_variable () const
 
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 has_double_word (size_t n) const
 Returns true if the declaration's value has a valid integer value for the nth word.
 
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_int_word (size_t n) const
 Returns true if the declaration's value has a valid integer 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.
 
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.
 
void output (std::ostream &out) const
 
void set_bool_word (size_t n, bool value)
 Changes the nth word to the indicated value without affecting the other words.
 
void set_double_word (size_t n, double value)
 Changes the nth word to the indicated value without affecting the other words.
 
void set_int64_word (size_t n, int64_t value)
 Changes the nth word to the indicated value without affecting the other words.
 
void set_int_word (size_t n, int value)
 Changes the nth word to the indicated value without affecting the other words.
 
void set_string_value (const std::string &value)
 Changes the value assigned to this variable.
 
void set_string_word (size_t n, const std::string &value)
 Changes the nth word to the indicated value without affecting the other words.
 
void write (std::ostream &out) const
 

Static Public Member Functions

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

Public Attributes

 get_page
 Returns the page on which this declaration can be found.
 
 get_variable
 Returns the variable that this declaration names.
 

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 34 of file configDeclaration.h.

Member Function Documentation

◆ downcase()

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

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

Definition at line 433 of file configDeclaration.cxx.

◆ extract_words()

size_t ConfigDeclaration::extract_words ( const std::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 406 of file configDeclaration.cxx.

Referenced by ConfigPageManager::reload_implicit_pages().

◆ get_bool_word()

bool ConfigDeclaration::get_bool_word ( size_t 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 160 of file configDeclaration.I.

References has_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 223 of file configDeclaration.I.

Referenced by operator<().

◆ get_double_word()

double ConfigDeclaration::get_double_word ( size_t 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 205 of file configDeclaration.I.

References has_string_word().

Referenced by ConfigVariableColor::get_default_value().

◆ get_filename_value()

Filename ConfigDeclaration::get_filename_value ( ) const

◆ get_int64_word()

int64_t ConfigDeclaration::get_int64_word ( size_t 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 190 of file configDeclaration.I.

References has_string_word().

◆ get_int_word()

int ConfigDeclaration::get_int_word ( size_t 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 175 of file configDeclaration.I.

References has_string_word().

◆ get_num_words()

size_t 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 71 of file configDeclaration.I.

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

◆ get_string_value()

const std::string & ConfigDeclaration::get_string_value ( ) const
inline

Returns the value assigned to this variable.

This is the original one-line text defined for the variable in the .prc file (or passed to ConfigPage::make_declaration()).

Definition at line 52 of file configDeclaration.I.

Referenced by ConfigVariableColor::get_default_value(), ConfigVariable::get_string_value(), ConfigVariableList::get_string_value(), and ConfigVariableList::get_unique_value().

◆ get_string_word()

std::string ConfigDeclaration::get_string_word ( size_t 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 148 of file configDeclaration.I.

References has_string_word().

◆ has_bool_word()

bool ConfigDeclaration::has_bool_word ( size_t n) const
inline

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

Definition at line 96 of file configDeclaration.I.

References has_string_word().

◆ has_double_word()

bool ConfigDeclaration::has_double_word ( size_t 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_string_word().

◆ has_int64_word()

bool ConfigDeclaration::has_int64_word ( size_t n) const
inline

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

Definition at line 122 of file configDeclaration.I.

References has_string_word().

◆ has_int_word()

bool ConfigDeclaration::has_int_word ( size_t n) const
inline

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

Definition at line 109 of file configDeclaration.I.

References has_string_word().

◆ has_string_word()

bool ConfigDeclaration::has_string_word ( size_t 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 84 of file configDeclaration.I.

Referenced by get_bool_word(), get_double_word(), get_int64_word(), get_int_word(), get_string_word(), has_bool_word(), has_double_word(), has_int64_word(), and has_int_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 19 of file configDeclaration.I.

References get_decl_seq(), and get_page.

◆ output()

void ConfigDeclaration::output ( std::ostream & out) const

Definition at line 174 of file configDeclaration.cxx.

◆ set_bool_word()

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

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

Definition at line 88 of file configDeclaration.cxx.

References set_string_word().

◆ set_double_word()

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

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

Definition at line 127 of file configDeclaration.cxx.

References set_string_word().

◆ set_int64_word()

void ConfigDeclaration::set_int64_word ( size_t n,
int64_t value )

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

Definition at line 114 of file configDeclaration.cxx.

References set_string_word().

◆ set_int_word()

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

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

Definition at line 101 of file configDeclaration.cxx.

References set_string_word().

◆ set_string_value()

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

Changes the value assigned to this variable.

Definition at line 60 of file configDeclaration.I.

◆ set_string_word()

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

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

Definition at line 56 of file configDeclaration.cxx.

Referenced by set_bool_word(), set_double_word(), set_int64_word(), and set_int_word().

◆ write()

void ConfigDeclaration::write ( std::ostream & out) const

Definition at line 182 of file configDeclaration.cxx.

Friends And Related Symbol Documentation

◆ ConfigPage

friend class ConfigPage
friend

Definition at line 121 of file configDeclaration.h.

Member Data Documentation

◆ get_page

ConfigPage * ConfigDeclaration::get_page
inline

Returns the page on which this declaration can be found.

Definition at line 46 of file configDeclaration.h.

Referenced by operator<().

◆ get_variable

ConfigVariableCore * ConfigDeclaration::get_variable
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 47 of file configDeclaration.h.


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