nis-util
1.0.D108
|
#include <configuration.h>
Public Types | |
typedef boost::shared_ptr < configuration > | pointer |
typedef configuration_section::level_t | level_t |
Public Member Functions | |
rcstring | get_string (const rcstring §ion_name, const rcstring &item_name) const |
long | get_long (const rcstring §ion_name, const rcstring &item_name) const |
bool | get_bool (const rcstring §ion_name, const rcstring &item_name) const |
void | load_command_line_file (const rcstring &filename) |
void | set_command_line_string (const source_location &locn, const rcstring §ion_name, const rcstring &item_name, const rcstring &value) |
void | set_command_line_long (const source_location &locn, const rcstring §ion_name, const rcstring &item_name, long value) |
void | set_command_line_bool (const source_location &locn, const rcstring §ion_name, const rcstring &item_name, bool value) |
void | set_command_line_bool (const source_location &locn, const rcstring &item_name, bool value) |
void | set_builtin_string (const rcstring §ion_name, const rcstring &item_name, const rcstring &value) |
void | set_builtin_long (const rcstring §ion_name, const rcstring &item_name, long value) |
void | set_builtin_bool (const rcstring §ion_name, const rcstring &item_name, bool value) |
void | print (void) const |
Static Public Member Functions | |
static configuration & | get_singleton (void) |
Private Types | |
typedef std::map< rcstring, configuration_section::pointer > | sections_t |
Private Member Functions | |
virtual | ~configuration () |
configuration () | |
void | load (void) |
void | parse (level_t level, const input::pointer &src) |
void | set (const rcstring §ion_name, const configuration_item::pointer &item) |
configuration (const configuration &rhs) | |
configuration & | operator= (const configuration &rhs) |
Static Private Member Functions | |
static rcstring | canonical_name (const rcstring &name) |
Private Attributes | |
sections_t | sections |
Static Private Attributes | |
static configuration * | singleton |
The configuration class is used to represent the storage and access of configuration data.
There are several sources of configuration data: 1. the built-in default 2. the /etc/nis-util.conf file 3. the ~/.nis-utilrc file 4. the NIS_UTIL evironment variable 5. the util-specific environment variable 6. cfg file given on the command line 7. command line options
Definition at line 40 of file configuration.h.
Definition at line 45 of file configuration.h.
typedef boost::shared_ptr<configuration> configuration::pointer |
Definition at line 43 of file configuration.h.
typedef std::map<rcstring, configuration_section::pointer> configuration::sections_t [private] |
Definition at line 296 of file configuration.h.
configuration::~configuration | ( | ) | [private, virtual] |
The destructor.
Definition at line 38 of file configuration.cc.
configuration::configuration | ( | ) | [private] |
The default constructor. It is private on purpose, use the get_singleton class method instead.
Definition at line 43 of file configuration.cc.
configuration::configuration | ( | const configuration & | rhs | ) | [private] |
The copy constructor. Do not use.
rhs | The right hand side of the initialization. |
rcstring configuration::canonical_name | ( | const rcstring & | name | ) | [static, private] |
bool configuration::get_bool | ( | const rcstring & | section_name, |
const rcstring & | item_name | ||
) | const |
The get_bool method is used to obtain a boolean configuration value.
section_name | The name of the section the configuration item appears within, or the empty string for global configuration values. |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
Definition at line 73 of file configuration.cc.
long configuration::get_long | ( | const rcstring & | section_name, |
const rcstring & | item_name | ||
) | const |
The get_long method is used to obtain an integer configuration value.
section_name | The name of the section the configuration item appears within, or the empty string for global configuration values. |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
Definition at line 85 of file configuration.cc.
configuration & configuration::get_singleton | ( | void | ) | [static] |
The get_singleton class method is used to obtain a reference to the configuration data, possibly reading the configuration sources if required.
Definition at line 49 of file configuration.cc.
rcstring configuration::get_string | ( | const rcstring & | section_name, |
const rcstring & | item_name | ||
) | const |
The get_string method is used to obtain a string configuration value.
section_name | The name of the section the configuration item appears within, or the empty string for global configuration values. |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
Definition at line 61 of file configuration.cc.
void configuration::load | ( | void | ) | [private] |
The load method is used to load all of the various configuration sources (environment variables, sys cfg files, user cfg files, etc).
Definition at line 142 of file configuration.cc.
void configuration::load_command_line_file | ( | const rcstring & | filename | ) |
The load_command_line_file method is used to load a configuration file given on the command line using the --ConFiGuration=filename option.
Configuration file specified on the command line take precedence over everything except specific command line options, e.g. via the set_command_line_string, set_command_line_long and set_command_line_bool methods.
filename | The name of the file to be read, or "-" to indocate the standard input. |
Definition at line 212 of file configuration.cc.
configuration& configuration::operator= | ( | const configuration & | rhs | ) | [private] |
The assignment operator. Do not use.
rhs | The right hand side of the assignment. |
void configuration::parse | ( | level_t | level, |
const input::pointer & | src | ||
) | [private] |
The parse method is used to read the given input (usually a file, but not always and squirrel away each of the configuration settings, provided they are of higher precedence than any extant setting.
level | The configuration level (or precedence) of the settings within the file being parsed. |
src | The source of input being parsed. |
void configuration::print | ( | void | ) | const |
The print method is used to print the configuration data to the standard output. Mostly useful for debugging.
Definition at line 305 of file configuration.cc.
void configuration::set | ( | const rcstring & | section_name, |
const configuration_item::pointer & | item | ||
) | [private] |
The set method is used to insert a configuration item into the known settings, provoded it is a high enough precedence level.
This is intentionally private, to re-inforce the idea that settings must not be able to be given arbitrary precedence levels.
section_name | The section the setting blongs in, or "" for the global section. |
item | The item to be inserted in the named section. |
Definition at line 97 of file configuration.cc.
void configuration::set_builtin_bool | ( | const rcstring & | section_name, |
const rcstring & | item_name, | ||
bool | value | ||
) |
The set_builtin_bool method is used to set a boolean configuration item with builtin precedence (the lowest precedence).
section_name | The name of the section the configuration item appears within, or the empty string for global configuration values. |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
value | The new value of the item. |
Definition at line 293 of file configuration.cc.
void configuration::set_builtin_long | ( | const rcstring & | section_name, |
const rcstring & | item_name, | ||
long | value | ||
) |
The set_builtin_long method is used to set an integer configuration item with builtin precedence (the lowest precedence).
section_name | The name of the section the configuration item appears within, or the empty string for global configuration values. |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
value | The new value of the item. |
Definition at line 281 of file configuration.cc.
void configuration::set_builtin_string | ( | const rcstring & | section_name, |
const rcstring & | item_name, | ||
const rcstring & | value | ||
) |
The set_builtin_string method is used to set a string configuration item with builtin precedence (the lowest precedence).
section_name | The name of the section the configuration item appears within, or the empty string for global configuration values. |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
value | The new value of the item. |
Definition at line 269 of file configuration.cc.
void configuration::set_command_line_bool | ( | const source_location & | locn, |
const rcstring & | section_name, | ||
const rcstring & | item_name, | ||
bool | value | ||
) |
The set_command_line_bool method is used to set a boolean configuration item from the command line.
The command line options take precendence over all other configuration settings.
locn | The source code location of the setting |
section_name | The name of the section the configuration item appears within, or the empty string for global configuration values. |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
value | The new value of the item. |
Definition at line 244 of file configuration.cc.
void configuration::set_command_line_bool | ( | const source_location & | locn, |
const rcstring & | item_name, | ||
bool | value | ||
) |
The set_command_line_bool method is used to set a boolean configuration item from the command line. It will be placed in the global section.
The command line options take precendence over all other configuration settings.
locn | The source code location of the setting |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
value | The new value of the item. |
Definition at line 255 of file configuration.cc.
void configuration::set_command_line_long | ( | const source_location & | locn, |
const rcstring & | section_name, | ||
const rcstring & | item_name, | ||
long | value | ||
) |
The set_command_line_long method is used to set an integer configuration item from the command line.
The command line options take precendence over all other configuration settings.
locn | The source code location of the setting |
section_name | The name of the section the configuration item appears within, or the empty string for global configuration values. |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
value | The new value of the item. |
Definition at line 233 of file configuration.cc.
void configuration::set_command_line_string | ( | const source_location & | locn, |
const rcstring & | section_name, | ||
const rcstring & | item_name, | ||
const rcstring & | value | ||
) |
The set_command_line_string method is used to set a string configuration item from the command line.
The command line options take precendence over all other configuration settings.
locn | The source code location of the setting |
section_name | The name of the section the configuration item appears within, or the empty string for global configuration values. |
item_name | The name of the item, within the section. Names within sections are unique to each section. |
value | The new value of the item. |
Definition at line 221 of file configuration.cc.
sections_t configuration::sections [private] |
The sections instance variable is used to remember all of the sections specified in the various configuration sources. This is added to by the set method, and read by the various "get" methods.
Definition at line 304 of file configuration.h.
configuration * configuration::singleton [static, private] |
The singleton class variable is used to remember the one instance of this class for the whole program. It is instantiated by the get_singleton class method.
Definition at line 311 of file configuration.h.