| 2164 | } |
| 2165 | |
| 2166 | void Config::addEnvironmentVar(const char * name, const char * defaultValue) |
| 2167 | { |
| 2168 | if (!name || !*name) |
| 2169 | { |
| 2170 | return; |
| 2171 | } |
| 2172 | |
| 2173 | // Note: Only a null default value removes the entry. |
| 2174 | |
| 2175 | if (defaultValue) |
| 2176 | { |
| 2177 | getImpl()->m_env[std::string(name)] = std::string(defaultValue); |
| 2178 | getImpl()->m_context->setStringVar(name, defaultValue); |
| 2179 | } |
| 2180 | else |
| 2181 | { |
| 2182 | StringMap::const_iterator iter = getImpl()->m_env.find(std::string(name)); |
| 2183 | if(iter != getImpl()->m_env.end()) getImpl()->m_env.erase(iter); |
| 2184 | getImpl()->m_context->setStringVar(name, nullptr); |
| 2185 | } |
| 2186 | |
| 2187 | AutoMutex lock(getImpl()->m_cacheidMutex); |
| 2188 | getImpl()->resetCacheIDs(); |
| 2189 | } |
| 2190 | |
| 2191 | int Config::getNumEnvironmentVars() const |
| 2192 | { |