| 286 | } |
| 287 | |
| 288 | void Context::setStringVar(const char * name, const char * value) noexcept |
| 289 | { |
| 290 | if (!name || !*name) |
| 291 | { |
| 292 | return; |
| 293 | } |
| 294 | |
| 295 | AutoMutex lock(getImpl()->m_resultsCacheMutex); |
| 296 | |
| 297 | // Set the value if specified. |
| 298 | if (value) |
| 299 | { |
| 300 | EnvMap::iterator iter = getImpl()->m_envMap.find(name); |
| 301 | if (iter != getImpl()->m_envMap.end()) |
| 302 | { |
| 303 | if (0 != strcmp(iter->second.c_str(), value)) |
| 304 | { |
| 305 | iter->second = value; |
| 306 | } |
| 307 | else |
| 308 | { |
| 309 | // Do not flush the cache because nothing changed. |
| 310 | return; |
| 311 | } |
| 312 | } |
| 313 | else |
| 314 | { |
| 315 | getImpl()->m_envMap[name] = value; |
| 316 | } |
| 317 | } |
| 318 | // If a null value is specified, erase it. |
| 319 | else |
| 320 | { |
| 321 | EnvMap::const_iterator iter = getImpl()->m_envMap.find(name); |
| 322 | if (iter != getImpl()->m_envMap.end()) |
| 323 | { |
| 324 | getImpl()->m_envMap.erase(iter); |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | getImpl()->clearCaches(); |
| 329 | } |
| 330 | |
| 331 | const char * Context::getStringVar(const char * name) const noexcept |
| 332 | { |