PUMA Library Reference Manual
|
#include <Puma/Config.h>
Load and hold PUMA configuration options in the correct order from the command line or a configuration file.
Public Types | |
enum | OPTIONS { SET_OPTION , SET_OPTION_ARG } |
Configuration option types. More... | |
Public Member Functions | |
Config (ErrorStream &err) | |
Constructor. | |
Config (ErrorStream &err, const char *path) | |
Constructor. | |
Config (ErrorStream &err, int &argc, char **&argv) | |
Constructor. | |
Config (ErrorStream &err, const char *path, int &argc, char **&argv) | |
Constructor. | |
Config (const Config ©) | |
Copy-constructor. | |
~Config () | |
Destroy this configuration object. | |
void | Join (const Config &other) |
Join this configuration with another. | |
void | Read (const char *path=(const char *) 0) |
Read the given configuration file, or the file given in PUMA_CONFIG environment variable if path is NULL, or /etc/puma.config otherwise. | |
void | Read (int &argc, char **&argv) |
Read configuration options from the command line and remove all recognized options from the command line. | |
void | Add (const ConfOption *option) |
Add a configuration option to the configuration. | |
void | Add (const char *option, bool system=false) |
Add a configuration option to the configuration. | |
void | Add (const char *option, const char *arg, bool system=false) |
Add a configuration option to the configuration. | |
void | Add (const char *option, const char *arg1, const char *arg2, bool system=false) |
Add a configuration option to the configuration. | |
void | Remove (const ConfOption *option) |
Remove an option from the configuration. | |
unsigned | Options () const |
Get the number options collected. | |
const ConfOption * | Option (unsigned n) const |
Get the n-th option in this configuration. | |
const ConfOption * | Option (const char *option) const |
Get a specific option in this configuration. | |
bool | CustomConfigFile (int argc, char **argv) |
Check if a configuration file is given on the command line. | |
bool | CustomSystemConfigFile (int argc, char **argv) |
Check if a system configuration file (lower priority options) is given on the command line. | |
void | PrintOption (OptsParser::Option &option, std::ostream &os) const |
Print the given option on an output stream. | |
void | PrintOptions (std::ostream &os) const |
Print the collected options on the given output stream. | |
|
inline |
Constructor.
err | The error stream to use. |
|
inline |
Constructor.
Read the given configuration file. See Read() for details.
err | The error stream to use. |
path | Path to the configuration file, or NULL. |
|
inline |
Constructor.
Read configuration options from the command line. See Read() for details.
err | The error stream to use. |
argc | The number of command line arguments. |
argv | The command line arguments. |
|
inline |
Constructor.
Read the configuration from a configuration file and the command line. See Read() for details.
err | The error stream to use. |
path | Path to the configuration file, or NULL. |
argc | The number of command line arguments. |
argv | The command line arguments. |
|
inline |
Copy-constructor.
copy | The configuration to copy. |
Puma::Config::~Config | ( | ) |
Destroy this configuration object.
|
inline |
Add a configuration option to the configuration.
option | The option to add. |
system | True if this option shall be added as a system priority option. |
|
inline |
Add a configuration option to the configuration.
option | The option to add. |
arg | The argument or the option. |
system | True if this option shall be added as a system priority option. |
|
inline |
Add a configuration option to the configuration.
option | The option to add. |
arg1 | The first argument or the option. |
arg2 | The second argument or the option. |
system | True if this option shall be added as a system priority option. |
void Puma::Config::Add | ( | const ConfOption * | option | ) |
Add a configuration option to the configuration.
option | The option to add. |
bool Puma::Config::CustomConfigFile | ( | int | argc, |
char ** | argv ) |
Check if a configuration file is given on the command line.
argc | The number of command line arguments. |
argv | The command line arguments. |
bool Puma::Config::CustomSystemConfigFile | ( | int | argc, |
char ** | argv ) |
Check if a system configuration file (lower priority options) is given on the command line.
argc | The number of command line arguments. |
argv | The command line arguments. |
void Puma::Config::Join | ( | const Config & | other | ) |
Join this configuration with another.
other | The configuration to join with. |
const ConfOption * Puma::Config::Option | ( | const char * | option | ) | const |
Get a specific option in this configuration.
option | The name of the option to get. |
const ConfOption * Puma::Config::Option | ( | unsigned | n | ) | const |
Get the n-th option in this configuration.
n | The index of the option to get. |
unsigned Puma::Config::Options | ( | ) | const |
Get the number options collected.
void Puma::Config::PrintOption | ( | OptsParser::Option & | option, |
std::ostream & | os ) const |
Print the given option on an output stream.
option | The option to print. |
os | The output stream. |
void Puma::Config::PrintOptions | ( | std::ostream & | os | ) | const |
Print the collected options on the given output stream.
os | The output stream. |
void Puma::Config::Read | ( | const char * | path = (const char *) 0 | ) |
Read the given configuration file, or the file given in PUMA_CONFIG environment variable if path is NULL, or /etc/puma.config otherwise.
path | The path to the configuration file, or NULL. |
void Puma::Config::Read | ( | int & | argc, |
char **& | argv ) |
Read configuration options from the command line and remove all recognized options from the command line.
argc | The number of command line arguments. |
argv | The command line arguments. |
void Puma::Config::Remove | ( | const ConfOption * | option | ) |
Remove an option from the configuration.
option | The option to remove. |