35 #if defined(__APPLE__) && defined(__DYNAMIC__)
36 #include <crt_externs.h>
37 #define environ (*_NSGetEnviron())
40 #include <boost/algorithm/string.hpp>
41 #include <boost/program_options.hpp>
42 #include <boost/program_options/environment_iterator.hpp>
48 using namespace boost;
49 using namespace boost::filesystem;
51 using namespace rsc::logging;
66 char* rawHome = getenv(
"HOME");
68 throw runtime_error(
"Home directory not defined in HOME variable.");
70 string home = string(rawHome) + string(
"/");
72 char* rawHomeDrive = getenv(
"HOMEDRIVE");
74 throw runtime_error(
"HOMEDRIVE variable not set.");
76 char* rawHomePath = getenv(
"HOMEPATH");
78 throw runtime_error(
"HOMEPATH variable not set.");
80 string home = string(rawHomeDrive) + string(rawHomePath) + string(
"\\");
90 if (starts_with(name, prefix)) {
92 transform(name.begin() + prefix.size(), name.end(), back_inserter(
100 EnvironmentVariableSource::EnvironmentVariableSource(
const string& prefix) :
101 logger(
Logger::getLogger(
"rsc.config.EnvironmentVariableSource")), prefix(
106 for (environment_iterator it = environment_iterator(environ); it
107 != environment_iterator(); ++it) {
114 split(key, name, is_any_of(
"_"));
115 string value = it->second;
void provideOptions(OptionHandler &handler)
Implementations should pass all configuration options to handler.
virtual void handleOption(const std::vector< std::string > &key, const std::string &value)=0
This method is called once for each individual option available from a given ConfigSource.
path userConfigDirectory()
Return the canonical directory for configuration files of the user associated with the current proces...
string transformName(const string &name, const string &prefix)
Implementations of this interface receive options from ConfigSource objects.
path systemConfigDirectory()
Return the directory in which system-wide configuration files are located.
#define RSCTRACE(logger, msg)
rsc::logging::LoggerPtr logger
path userHomeDirectory()
Return the home directory of the user associated with the current process.
Interface for logging adapters that can be used with RSC.