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 StringMap::iterator it;
95 it = pStringMap.find( key );
96 if( it == pStringMap.end() )
100 if( it->second.second )
103 "Env: trying to delete a shell-imported string entry: %s",
107 log->
Debug(
UtilityMsg,
"Env: deleting string entry: %s", key.c_str() );
108 pStringMap.erase( it );
117 std::string key = UnifyKey( k );
120 it = pIntMap.find( key );
121 if( it == pIntMap.end() )
125 "Env: trying to get a non-existent integer entry: %s",
129 value = it->second.first;
138 std::string key = UnifyKey( k );
145 it = pIntMap.find( key );
146 if( it == pIntMap.end() )
148 pIntMap[key] = std::make_pair( value,
false );
156 if( it->second.second )
159 "Env: trying to override a shell-imported integer entry: %s",
164 "Env: overriding entry: %s=%d with %d",
165 key.c_str(), it->second.first, value );
167 pIntMap[key] = std::make_pair( value,
false );
176 std::string key = UnifyKey( k );
180 it = pIntMap.find( key );
181 if( it == pIntMap.end() )
185 if( it->second.second )
188 "Env: trying to delete a shell-imported integer entry: %s",
192 log->
Debug(
UtilityMsg,
"Env: deleting integer entry: %s", key.c_str() );
202 std::string key = UnifyKey( k );
205 it = pPtrMap.find( key );
206 if( it == pPtrMap.end() )
210 "Env: trying to get a non-existent pointer entry: %s",
223 std::string key = UnifyKey( k );
227 bool ret = pPtrMap.find(key) == pPtrMap.end();
229 pPtrMap[key] = value;
239 std::string key = UnifyKey( k );
241 std::string strValue = GetEnv( shellKey );
247 int value = (int)strtol( strValue.c_str(), &endPtr, 0 );
251 "Env: Unable to import %s as %s: %s is not a proper integer",
252 shellKey.c_str(), key.c_str(), strValue.c_str() );
257 shellKey.c_str(), value, key.c_str() );
259 pIntMap[key] = std::make_pair( value,
true );
268 std::string key = UnifyKey( k );
270 std::string value = GetEnv( shellKey );
276 shellKey.c_str(), value.c_str(), key.c_str() );
277 pStringMap[key] = std::make_pair( value,
true );
286 std::string key = UnifyKey( k );
298 std::string key = UnifyKey( k );
308 std::string Env::GetEnv(
const std::string &key )
310 char *var = getenv( key.c_str() );
static Log * GetLog()
Get default log.
bool DelInt(const std::string &key)
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 PutPtr(const std::string &key, void *value)
bool ImportInt(const std::string &key, const std::string &shellKey)
bool GetPtr(const std::string &key, void *&value)
bool DelString(const std::string &key)
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