Elements  5.8
A C++ base framework for the Euclid Software.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Elements::Environment Class Reference

#include <Environment.h>

Collaboration diagram for Elements::Environment:
[legend]

Classes

class  Variable
 proxy class to overload the assignment More...
 

Public Types

enum  ShellType { sh, csh }
 

Public Member Functions

 Environment (bool keep_same=true)
 
virtual ~Environment ()
 
Variable operator[] (const std::string &)
 
const Variable operator[] (const std::string &index) const
 
Environmentrestore ()
 
Environmentset (const std::string &, const std::string &)
 
EnvironmentunSet (const std::string &)
 
Environmentappend (const std::string &, const std::string &)
 
Environmentprepend (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::stringm_added_variables
 variable added to the environment More...
 

Detailed Description

Definition at line 43 of file Environment.h.

Member Enumeration Documentation

Enumerator
sh 
csh 

Definition at line 97 of file Environment.h.

Constructor & Destructor Documentation

Elements::Environment::Environment ( bool  keep_same = true)
explicit

Definition at line 174 of file Environment.cpp.

Elements::Environment::~Environment ( )
virtual

Definition at line 195 of file Environment.cpp.

References restore().

Here is the call graph for this function:

Member Function Documentation

Environment & Elements::Environment::append ( const std::string index,
const std::string value 
)

Definition at line 248 of file Environment.cpp.

References set().

Referenced by Elements::Environment::Variable::operator+=().

Here is the call graph for this function:

void Elements::Environment::checkOutOfRange ( const std::string index)
staticprivate

check that the variable is in the environment

Definition at line 318 of file Environment.cpp.

References hasKey(), and std::stringstream::str().

Referenced by unSet().

Here is the call graph for this function:

void Elements::Environment::commit ( )

Definition at line 282 of file Environment.cpp.

References m_added_variables, and m_old_values.

string Elements::Environment::generateScript ( Environment::ShellType  type) const

Definition at line 289 of file Environment.cpp.

References hasKey(), m_added_variables, and m_old_values.

Here is the call graph for this function:

string Elements::Environment::get ( const std::string index,
const std::string default_value = "" 
) const

Definition at line 266 of file Environment.cpp.

References Elements::System::getEnv(), and hasKey().

Here is the call graph for this function:

bool Elements::Environment::hasKey ( const std::string index)
static

Definition at line 276 of file Environment.cpp.

References Elements::System::isEnvSet().

Referenced by checkOutOfRange(), generateScript(), get(), set(), and Elements::TempPath::~TempPath().

Here is the call graph for this function:

Environment::Variable Elements::Environment::operator[] ( const std::string index)

Definition at line 199 of file Environment.cpp.

const Environment::Variable Elements::Environment::operator[] ( const std::string index) const

Definition at line 205 of file Environment.cpp.

Environment & Elements::Environment::prepend ( const std::string index,
const std::string value 
)

Definition at line 257 of file Environment.cpp.

References set().

Here is the call graph for this function:

Environment & Elements::Environment::restore ( )

Definition at line 179 of file Environment.cpp.

References m_added_variables, m_old_values, Elements::System::setEnv(), and Elements::System::unSetEnv().

Referenced by ~Environment().

Here is the call graph for this function:

Environment & Elements::Environment::set ( const std::string index,
const std::string value 
)

Definition at line 211 of file Environment.cpp.

References std::map< K, T >::end(), std::map< K, T >::find(), Elements::System::getEnv(), hasKey(), m_added_variables, m_keep_same, m_old_values, std::vector< T >::push_back(), and Elements::System::setEnv().

Referenced by append(), Elements::Environment::Variable::operator=(), and prepend().

Here is the call graph for this function:

Environment & Elements::Environment::unSet ( const std::string index)

Definition at line 229 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().

Here is the call graph for this function:

Member Data Documentation

std::vector<std::string> Elements::Environment::m_added_variables
private

variable added to the environment

Definition at line 114 of file Environment.h.

Referenced by commit(), generateScript(), restore(), set(), and unSet().

bool Elements::Environment::m_keep_same
private

Definition at line 111 of file Environment.h.

Referenced by set().

std::map<std::string, std::string> Elements::Environment::m_old_values
private

old value for changed variables

Definition at line 109 of file Environment.h.

Referenced by commit(), generateScript(), restore(), set(), and unSet().


The documentation for this class was generated from the following files: