Elements
6.2
A C++ base framework for the Euclid Software.
|
Python dictionary-like Environment interface. More...
#include <Environment.h>
Classes | |
class | Variable |
proxy class to overload the assignment More... | |
Public Types | |
enum | ShellType { sh, csh } |
Public Member Functions | |
Environment (bool keep_same=true) | |
default constructor More... | |
virtual | ~Environment () |
Variable | operator[] (const std::string &) |
const Variable | operator[] (const std::string &index) const |
Environment & | restore () |
Environment & | set (const std::string &, const std::string &) |
Environment & | unSet (const std::string &) |
Environment & | append (const std::string &, const std::string &) |
Environment & | prepend (const std::string &, const std::string &) |
std::string | get (const std::string &index, const std::string &default_value="") const |
void | commit () |
std::string | generateScript (ShellType) const |
Static Public Member Functions | |
static bool | hasKey (const std::string &) |
Static Private Member Functions | |
static void | checkOutOfRange (const std::string &) |
check that the variable is in the environment More... | |
Private Attributes | |
std::map< std::string, std::string > | m_old_values |
old value for changed variables More... | |
bool | m_keep_same |
std::vector< std::string > | m_added_variables |
variable added to the environment More... | |
Python dictionary-like Environment interface.
Definition at line 44 of file Environment.h.
Enumerator | |
---|---|
sh | |
csh |
Definition at line 64 of file Environment.h.
|
explicit |
default constructor
Definition at line 159 of file Environment.cpp.
|
virtual |
Definition at line 175 of file Environment.cpp.
References restore().
Environment & Elements::Environment::append | ( | const std::string & | index, |
const std::string & | value | ||
) |
Definition at line 222 of file Environment.cpp.
Referenced by Elements::Environment::Variable::operator+=().
void Elements::Environment::commit | ( | ) |
Definition at line 255 of file Environment.cpp.
References m_added_variables, and m_old_values.
string Elements::Environment::generateScript | ( | Environment::ShellType | type | ) | const |
Definition at line 261 of file Environment.cpp.
References get(), hasKey(), m_added_variables, and m_old_values.
string Elements::Environment::get | ( | const std::string & | index, |
const std::string & | default_value = "" |
||
) | const |
Definition at line 240 of file Environment.cpp.
References Elements::System::getEnv(), and hasKey().
Referenced by append(), Elements::Services::DataSync::environmentVariable(), generateScript(), and prepend().
|
static |
Definition at line 250 of file Environment.cpp.
References Elements::System::isEnvSet().
Referenced by checkOutOfRange(), generateScript(), get(), Elements::Kernel::pathSearchInEnvVariable(), set(), and Elements::TempPath::~TempPath().
Environment::Variable Elements::Environment::operator[] | ( | const std::string & | index | ) |
Definition at line 179 of file Environment.cpp.
const Environment::Variable Elements::Environment::operator[] | ( | const std::string & | index | ) | const |
Definition at line 183 of file Environment.cpp.
Environment & Elements::Environment::prepend | ( | const std::string & | index, |
const std::string & | value | ||
) |
Environment & Elements::Environment::restore | ( | ) |
Definition at line 161 of file Environment.cpp.
References m_added_variables, m_old_values, Elements::System::setEnv(), and Elements::System::unSetEnv().
Referenced by ~Environment().
Environment & Elements::Environment::set | ( | const std::string & | index, |
const std::string & | value | ||
) |
Definition at line 187 of file Environment.cpp.
References std::vector< T >::emplace_back(), std::map< K, T >::end(), std::map< K, T >::find(), Elements::System::getEnv(), hasKey(), m_added_variables, m_keep_same, m_old_values, and Elements::System::setEnv().
Referenced by append(), Elements::Environment::Variable::operator=(), and prepend().
Environment & Elements::Environment::unSet | ( | const std::string & | index | ) |
Definition at line 204 of file Environment.cpp.
References std::vector< T >::begin(), checkOutOfRange(), std::map< K, T >::end(), std::vector< T >::end(), std::vector< T >::erase(), std::find(), std::map< K, T >::find(), Elements::System::getEnv(), m_added_variables, m_old_values, and Elements::System::unSetEnv().
|
private |
variable added to the environment
Definition at line 81 of file Environment.h.
Referenced by commit(), generateScript(), restore(), set(), and unSet().
|
private |
Definition at line 78 of file Environment.h.
Referenced by set().
|
private |
old value for changed variables
Definition at line 76 of file Environment.h.
Referenced by commit(), generateScript(), restore(), set(), and unSet().