| Elements
    6.2
    A C++ base framework for the Euclid Software. | 
 
 
 
Go to the documentation of this file.
   31 #include <boost/format.hpp>   
   50   checkCompatibility(other);
 
   54   checkCompatibility(other);
 
   58   checkCompatibility(other);
 
   66   checkCompatibility(other);
 
   68   m_env = move(other.m_env);
 
   82   m_env.get().
set(m_index, arg_value);
 
   89   m_env.get().
unSet(m_index);
 
   96   m_env.get().
append(m_index, arg_value);
 
  108   m_env.get().
prepend(m_index, arg_value);
 
  132   return m_env.get().get(m_index, 
"");
 
  140   return value().empty();
 
  144   return m_env.get().hasKey(m_index);
 
  149   if (m_index != other.
m_index) {
 
  151     error_buffer << 
"The \"" << other.
m_index << 
"\" environment variable" 
  152                  << 
" cannot be copied to the \"" << m_index << 
"\" environment variable." << endl;
 
  167     setEnv(v.first, v.second);
 
  224   const string new_value = 
get(index) + value;
 
  226   set(index, new_value);
 
  233   const string new_value = value + 
get(index);
 
  235   set(index, new_value);
 
  241   string value{default_value};
 
  268   map<ShellType, string> set_cmd{{ShellType::sh, 
"export %s=%s"}, {ShellType::csh, 
"setenv %s %s"}};
 
  269   map<ShellType, string> unset_cmd{{ShellType::sh, 
"unset %s"}, {ShellType::csh, 
"unsetenv %s"}};
 
  273       script_text << format(set_cmd[type]) % v.first % 
get(v.first) << endl;
 
  275       script_text << format(unset_cmd[type]) % v.first << endl;
 
  280     script_text << format(set_cmd[type]) % v % 
get(v) << endl;
 
  283   return script_text.str();
 
  290     error_buffer << 
"The environment doesn't contain the " << index << 
" variable." << endl;
 
  
std::reference_wrapper< Environment > m_env
a copiable and movable reference
Variable & set(const std::string &)
Environment & unSet(const std::string &)
This file is intended to iron out all the differences between systems (currently Linux and MacOSX)
ELEMENTS_API std::string getEnv(const std::string &var)
get a particular environment variable
Environment & prepend(const std::string &, const std::string &)
std::string generateScript(ShellType) const
Variable & append(const std::string &)
const std::string & index() const
static bool hasKey(const std::string &)
Variable & operator+=(const std::string &)
proxy class to overload the assignment
Environment & append(const std::string &, const std::string &)
ELEMENTS_API Environment::Variable operator+(const std::string &, const Environment::Variable &)
ELEMENTS_API int unSetEnv(const std::string &name)
Simple wrap around unsetenv for strings.
ELEMENTS_API std::ostream & operator<<(std::ostream &, const Environment::Variable &)
Variable operator[](const std::string &)
Environment(bool keep_same=true)
default constructor
std::vector< std::string > m_added_variables
variable added to the environment
std::string m_index
The Name of the variable.
ELEMENTS_API bool isEnvSet(const std::string &var)
Check if an environment variable is set or not.
std::string get(const std::string &index, const std::string &default_value="") const
std::map< std::string, std::string > m_old_values
old value for changed variables
std::string value() const
T emplace_back(T... args)
Variable & prepend(const std::string &)
Defines a class to handle the Environment.
Python dictionary-like Environment interface.
Variable operator+(const std::string &)
Environment & env() const
Variable & operator=(const Variable &other)
static void checkOutOfRange(const std::string &)
check that the variable is in the environment
ELEMENTS_API int setEnv(const std::string &name, const std::string &value, bool overwrite=true)
set an environment variables.
Environment & set(const std::string &, const std::string &)
void checkCompatibility(const Variable &)