RSC  0.13.4
rsc::config Namespace Reference

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...
 
vector< string > splitSequenceValue (const string &value)
 
vector< string > mergeSequenceValue (const string &description, const vector< string > &key, const string &raw, const vector< string > &previous)
 

Function Documentation

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:

  1. Prepending a prefix-wide configuration directory (e.g. /usr/local/etc/) to configFileName
  2. Prepending a user-specific configuration directory (e.g. $HOME/.config) to configFileName
  3. Prepending the current working directory () to configFileName
  4. Environment Variables

See #ConfigFileSource for the configuration file format.

Parameters
handlerReceiver of the configuration options.
configFileNameA filename (without directory) from which three configuration file names are derived.
environmentVariablePrefixA prefix string with which all processed environment variables have to start.
argcnumber of arguments passed to the main program. If 0, no command line argument parsing will be performed. If something else is specified, ensure that
argvmatches the argc. Defaults to 0, so no argument parsing.
argvargument vector for command line parsing. Must match the length given in argc. Might be an arbitrary pointer of argc i 0.
stripEnvironmentVariablePrefixif 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.
prefixthe (installation) prefix under which to search for a prefix-wide configuration file
Author
jmoringe

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().

Here is the call graph for this function:

LoggerPtr rsc::config::getLogger ( )

Definition at line 48 of file Configuration.cpp.

Referenced by configure().

Here is the caller graph for this function:

std::vector< std::string > rsc::config::mergeSequenceValue ( const string &  description,
const vector< string > &  key,
const string &  raw,
const vector< string > &  previous 
)

Definition at line 47 of file Utility.cpp.

References std::container_none, std::element_sequence(), and splitSequenceValue().

Referenced by rsc::plugins::Configurator::handleOption().

Here is the call graph for this function:

Here is the caller graph for this function:

path rsc::config::prefixConfigDirectory ( const path &  prefix)

Definition at line 64 of file Environment.cpp.

References systemConfigDirectory().

Referenced by configure().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters
prefixthe prefix for which the path shall be located.
Returns
A boost::filesystem::path object representing the prefix configuration directory.
Author
jwienke
std::vector< std::string > rsc::config::splitSequenceValue ( const string &  value)

Definition at line 39 of file Utility.cpp.

Referenced by mergeSequenceValue().

Here is the caller graph for this function:

RSC_EXPORT boost::filesystem::path rsc::config::systemConfigDirectory ( )

Return the directory in which system-wide configuration files are located.

Returns
A boost::filesystem::path object representing the system configuration directory.
Author
jmoringe

Definition at line 56 of file Environment.cpp.

Referenced by prefixConfigDirectory().

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

string rsc::config::trim ( const string &  s)

Definition at line 46 of file ConfigFileSource.cpp.

Referenced by rsc::config::ConfigFileSource::getOption().

Here is the caller graph for this function:

RSC_EXPORT boost::filesystem::path rsc::config::userConfigDirectory ( )

Return the canonical directory for configuration files of the user associated with the current process.

Returns
A boost::filesystem::path object representing the configuration directory of the user.
Exceptions
std::runtime_errorif no config directory for the user is available
Author
jmoringe

Definition at line 100 of file Environment.cpp.

References userHomeDirectory().

Referenced by configure().

Here is the call graph for this function:

Here is the caller graph for this function:

RSC_EXPORT boost::filesystem::path rsc::config::userHomeDirectory ( )

Return the home directory of the user associated with the current process.

Returns
A boost::filesystem::path object representing the home directory of the user.
Exceptions
std::runtime_errorif no home directory for the user is available
Author
jmoringe

Definition at line 79 of file Environment.cpp.

Referenced by userConfigDirectory().

Here is the caller graph for this function: