RSC
0.12.1
|
Classes | |
class | CollectingOptionHandler |
An OptionHandler which collects the options in an instance of Properties. More... | |
class | CommandLinePropertySource |
A source for options from the command line using a -D java properties-like syntax. More... | |
class | ConfigFileSource |
Objects of this class parse streams that contain configuration information in "ini-file" syntax. More... | |
class | ConfigSource |
Implementations of this interface obtain configuration information somewhere and pass individual configuration options to an OptionHandler instance. More... | |
class | EnvironmentVariableSource |
Objects of this class analyze the environment of the current process, finding environment variables whose name starts with a specified string. More... | |
class | OptionHandler |
Implementations of this interface receive options from ConfigSource objects. More... | |
class | PropertyHandler |
This implementation of the OptionHandler interface stores all options it receives into a runtime::Properties object. More... | |
Functions | |
string | trim (const string &s) |
LoggerPtr | getLogger () |
void | configure (OptionHandler &handler, const std::string &configFileName, const std::string &environmentVariablePrefix, int argc=0, const char **argv=0, bool stripEnvironmentVariablePrefix=true, const boost::filesystem::path &prefix="/") |
Pass configuration options in from configuration files derived from configFileName and environment variables with prefix environmentVariablePrefix to handler. More... | |
path | systemConfigDirectory () |
Return the directory in which system-wide configuration files are located. More... | |
path | prefixConfigDirectory (const path &prefix) |
path | userHomeDirectory () |
Return the home directory of the user associated with the current process. More... | |
path | userConfigDirectory () |
Return the canonical directory for configuration files of the user associated with the current process. More... | |
string | transformName (const string &name, const string &prefix, const bool &stripPrefix) |
RSC_EXPORT boost::filesystem::path | prefixConfigDirectory (const boost::filesystem::path &prefix=RSC_INSTALL_PREFIX) |
Return the directory in which prefix-wide configuration files are located. More... | |
void RSC_EXPORT rsc::config::configure | ( | OptionHandler & | handler, |
const std::string & | configFileName, | ||
const std::string & | environmentVariablePrefix, | ||
int | argc = 0 , |
||
const char ** | argv = 0 , |
||
bool | stripEnvironmentVariablePrefix = true , |
||
const boost::filesystem::path & | prefix = "/" |
||
) |
Pass configuration options in from configuration files derived from configFileName and environment variables with prefix environmentVariablePrefix to handler.
The following configuration configuration sources are considered based on configFileName:
/usr/local/etc/
) to configFileName $HOME/
.config) to configFileName
) to configFileName See #ConfigFileSource for the configuration file format.
handler | Receiver of the configuration options. |
configFileName | A filename (without directory) from which three configuration file names are derived. |
environmentVariablePrefix | A prefix string with which all processed environment variables have to start. |
argc | number of arguments passed to the main program. If 0, no command line argument parsing will be performed. If something else is specified, ensure that |
argv | matches the argc. Defaults to 0, so no argument parsing. |
argv | argument vector for command line parsing. Must match the length given in argc. Might be an arbitrary pointer of argc i 0. |
stripEnvironmentVariablePrefix | if true, the prefix for environment variable will be stripped before passing options to the handler. If e.g. RSC_ is set as prefix and this is true, RSC_TEST will be passed to the handlers as just TEST. Default is true. |
prefix | the (installation) prefix under which to search for a prefix-wide configuration file |
Definition at line 54 of file Configuration.cpp.
References getLogger(), prefixConfigDirectory(), rsc::config::ConfigFileSource::provideOptions(), rsc::config::CommandLinePropertySource::provideOptions(), rsc::config::EnvironmentVariableSource::provideOptions(), RSCWARN, and userConfigDirectory().
LoggerPtr rsc::config::getLogger | ( | ) |
Definition at line 48 of file Configuration.cpp.
Referenced by configure().
path rsc::config::prefixConfigDirectory | ( | const path & | prefix | ) |
Definition at line 64 of file Environment.cpp.
References systemConfigDirectory().
Referenced by configure().
RSC_EXPORT boost::filesystem::path rsc::config::prefixConfigDirectory | ( | const boost::filesystem::path & | prefix = RSC_INSTALL_PREFIX | ) |
Return the directory in which prefix-wide configuration files are located.
prefix | the prefix for which the path shall be located. |
RSC_EXPORT boost::filesystem::path rsc::config::systemConfigDirectory | ( | ) |
Return the directory in which system-wide configuration files are located.
Definition at line 56 of file Environment.cpp.
Referenced by prefixConfigDirectory().
string rsc::config::transformName | ( | const string & | name, |
const string & | prefix, | ||
const bool & | stripPrefix | ||
) |
Definition at line 104 of file Environment.cpp.
Referenced by rsc::config::EnvironmentVariableSource::provideOptions().
string rsc::config::trim | ( | const string & | s | ) |
Definition at line 46 of file ConfigFileSource.cpp.
Referenced by rsc::config::ConfigFileSource::getOption().
RSC_EXPORT boost::filesystem::path rsc::config::userConfigDirectory | ( | ) |
Return the canonical directory for configuration files of the user associated with the current process.
std::runtime_error | if no config directory for the user is available |
Definition at line 100 of file Environment.cpp.
References userHomeDirectory().
Referenced by configure().
RSC_EXPORT boost::filesystem::path rsc::config::userHomeDirectory | ( | ) |
Return the home directory of the user associated with the current process.
std::runtime_error | if no home directory for the user is available |
Definition at line 79 of file Environment.cpp.
Referenced by userConfigDirectory().