RSC  0.17.1
rsc::config::EnvironmentVariableSource Class Reference

Objects of this class analyze the environment of the current process, finding environment variables whose name starts with a specified string. More...

#include <Environment.h>

Inheritance diagram for rsc::config::EnvironmentVariableSource:
Inheritance graph
Collaboration diagram for rsc::config::EnvironmentVariableSource:
Collaboration graph

Classes

class  Match
 

Public Types

typedef std::vector< MatchMatches
 

Public Member Functions

 EnvironmentVariableSource (const std::string &prefix="", const bool &stripPrefix=true)
 Construct a source that collect environment variables whose name starts with prefix. More...
 
void provideOptions (OptionHandler &handler)
 Implementations should pass all configuration options to handler. More...
 
Matches getMatches ()
 Return matching environment variables. More...
 
- Public Member Functions inherited from rsc::config::ConfigSource
virtual ~ConfigSource ()
 

Private Attributes

rsc::logging::LoggerPtr logger
 
const std::string prefix
 
bool stripPrefix
 
boost::shared_ptr< Matchesmatches
 

Additional Inherited Members

- Protected Member Functions inherited from rsc::config::ConfigSource
void splitKeyAtDots (const std::string &input, std::vector< std::string > &output)
 Creates a key vector structure used in the options backend from a dot-separated string. More...
 

Detailed Description

Objects of this class analyze the environment of the current process, finding environment variables whose name starts with a specified string.

The prefix is stripped from matching names and the variables are converted to options and passed to the OptionHandler.

Author
jmoringe

Definition at line 115 of file Environment.h.

Member Typedef Documentation

Definition at line 131 of file Environment.h.

Constructor & Destructor Documentation

rsc::config::EnvironmentVariableSource::EnvironmentVariableSource ( const std::string &  prefix = "",
const bool &  stripPrefix = true 
)

Construct a source that collect environment variables whose name starts with prefix.

Parameters
prefixA prefix string against which all environment variables are matched.
stripPrefixDetermines whether the specified prefix will be stripped from the options when passing them to the handlers or not. 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.

Definition at line 147 of file Environment.cpp.

Member Function Documentation

EnvironmentVariableSource::Matches rsc::config::EnvironmentVariableSource::getMatches ( )

Return matching environment variables.

Returns
A collection of Match instances each containing the raw and transformed name of an environment variable along with its value.

Definition at line 153 of file Environment.cpp.

References matches, and rsc::config::transformName().

Referenced by rsc::config::configure(), and provideOptions().

Here is the call graph for this function:

Here is the caller graph for this function:

void rsc::config::EnvironmentVariableSource::provideOptions ( OptionHandler handler)
virtual

Implementations should pass all configuration options to handler.

Parameters
handlerThe handler to which all option should be passed.
Exceptions
std::invalid_argumentmay be thrown when the options this source uses in the background are not well-formated

Implements rsc::config::ConfigSource.

Definition at line 168 of file Environment.cpp.

References getMatches(), rsc::config::OptionHandler::handleOption(), logger, matches, and RSCTRACE.

Referenced by rsc::config::configure().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

rsc::logging::LoggerPtr rsc::config::EnvironmentVariableSource::logger
private

Definition at line 159 of file Environment.h.

Referenced by provideOptions().

boost::shared_ptr<Matches> rsc::config::EnvironmentVariableSource::matches
private

Definition at line 164 of file Environment.h.

Referenced by getMatches(), and provideOptions().

const std::string rsc::config::EnvironmentVariableSource::prefix
private

Definition at line 161 of file Environment.h.

bool rsc::config::EnvironmentVariableSource::stripPrefix
private

Definition at line 162 of file Environment.h.


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