33 std::string key = UnifyKey( k );
35 StringMap::iterator it;
36 it = pStringMap.find( key );
37 if( it == pStringMap.end() )
41 "Env: trying to get a non-existent string entry: %s",
45 value = it->second.first;
54 std::string key = UnifyKey( k );
60 StringMap::iterator it;
61 it = pStringMap.find( key );
62 if( it == pStringMap.end() )
64 pStringMap[key] = std::make_pair( value,
false );
72 if( it->second.second )
75 "Env: trying to override a shell-imported string entry: %s",
80 "Env: overriding entry: %s=\"%s\" with \"%s\"",
81 key.c_str(), it->second.first.c_str(), value.c_str() );
82 pStringMap[key] = std::make_pair( value,
false );
91 std::string key = UnifyKey( k );
94 it = pIntMap.find( key );
95 if( it == pIntMap.end() )
99 "Env: trying to get a non-existent integer entry: %s",
103 value = it->second.first;
112 std::string key = UnifyKey( k );
119 it = pIntMap.find( key );
120 if( it == pIntMap.end() )
122 pIntMap[key] = std::make_pair( value,
false );
130 if( it->second.second )
133 "Env: trying to override a shell-imported integer entry: %s",
138 "Env: overriding entry: %s=%d with %d",
139 key.c_str(), it->second.first, value );
141 pIntMap[key] = std::make_pair( value,
false );
150 std::string key = UnifyKey( k );
152 std::string strValue = GetEnv( shellKey );
158 int value = (int)strtol( strValue.c_str(), &endPtr, 0 );
162 "Env: Unable to import %s as %s: %s is not a proper integer",
163 shellKey.c_str(), key.c_str(), strValue.c_str() );
168 shellKey.c_str(), value, key.c_str() );
170 pIntMap[key] = std::make_pair( value,
true );
179 std::string key = UnifyKey( k );
181 std::string value = GetEnv( shellKey );
187 shellKey.c_str(), value.c_str(), key.c_str() );
188 pStringMap[key] = std::make_pair( value,
true );
197 std::string key = UnifyKey( k );
209 std::string key = UnifyKey( k );
219 std::string Env::GetEnv(
const std::string &key )
221 char *var = getenv( key.c_str() );
static Log * GetLog()
Get default log.
bool PutInt(const std::string &key, int value)
bool PutString(const std::string &key, const std::string &value)
bool GetDefaultIntValue(const std::string &key, int &value)
bool ImportString(const std::string &key, const std::string &shellKey)
bool ImportInt(const std::string &key, const std::string &shellKey)
bool GetString(const std::string &key, std::string &value)
bool GetInt(const std::string &key, int &value)
bool GetDefaultStringValue(const std::string &key, std::string &value)
void Error(uint64_t topic, const char *format,...)
Report an error.
void Info(uint64_t topic, const char *format,...)
Print an info.
void Debug(uint64_t topic, const char *format,...)
Print a debug message.
const uint64_t UtilityMsg
static std::unordered_map< std::string, std::string > theDefaultStrs
static std::unordered_map< std::string, int > theDefaultInts