Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
environment.cc
Go to the documentation of this file.
1 
18 #include "ion/port/environment.h"
19 
20 #include <cstdlib>
21 
22 namespace ion {
23 namespace port {
24 
25 #if defined(ION_PLATFORM_WINDOWS)
26 #undef GetEnvironmentVariable
27 #endif
28 
29 const std::string GetEnvironmentVariableValue(const std::string& name) {
30  char* var = getenv(name.c_str());
31  return var ? var : std::string();
32 }
33 
34 void SetEnvironmentVariableValue(const std::string& name,
35  const std::string& value) {
36 #if defined(ION_PLATFORM_WINDOWS)
37  const std::string env = name + "=" + value;
38  _putenv(env.c_str());
39 #else
40  setenv(name.c_str(), value.c_str(), 1);
41 #endif
42 }
43 
44 } // namespace port
45 } // namespace ion
const std::string GetEnvironmentVariableValue(const std::string &name)
Returns the value of the named environment variable.
Definition: environment.cc:29
double value
std::string name
Definition: printer.cc:324
void SetEnvironmentVariableValue(const std::string &name, const std::string &value)
Sets the named environment variable to the passed value.
Definition: environment.cc:34