Elements 6.3.3
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches

Python dictionary-like Environment interface. More...

#include <Environment.h>

Collaboration diagram for Elements::Environment:

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
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

Private Attributes

std::map< std::string, std::stringm_old_values
 old value for changed variables
bool m_keep_same
std::vector< std::stringm_added_variables
 variable added to the environment

Detailed Description

Python dictionary-like Environment interface.

Definition at line 44 of file Environment.h.

Member Enumeration Documentation

◆ ShellType

Enumerator
sh 
csh 

Definition at line 64 of file Environment.h.

Constructor & Destructor Documentation

◆ Environment()

◆ ~Environment()

Elements::Environment::~Environment ( )
virtual

Definition at line 175 of file Environment.cpp.

References restore().

Here is the call graph for this function:

Member Function Documentation

◆ append()

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

Definition at line 222 of file Environment.cpp.

References Environment(), get(), and set().

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

Here is the call graph for this function:

◆ commit()

void Elements::Environment::commit ( )

Definition at line 255 of file Environment.cpp.

References m_added_variables, and m_old_values.

◆ generateScript()

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

Definition at line 261 of file Environment.cpp.

References csh, endl(), get(), hasKey(), m_added_variables, m_old_values, sh, and std::stringstream::str().

Here is the call graph for this function:

◆ get()

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

Definition at line 240 of file Environment.cpp.

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

Referenced by append(), Elements::Services::DataSync::environmentVariable(), generateScript(), and prepend().

Here is the call graph for this function:

◆ hasKey()

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

Definition at line 250 of file Environment.cpp.

References Elements::isEnvSet().

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

Here is the call graph for this function:

◆ operator[]() [1/2]

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

Definition at line 179 of file Environment.cpp.

◆ operator[]() [2/2]

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

Definition at line 183 of file Environment.cpp.

References Environment().

Here is the call graph for this function:

◆ prepend()

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

Definition at line 231 of file Environment.cpp.

References Environment(), get(), and set().

Here is the call graph for this function:

◆ restore()

Environment & Elements::Environment::restore ( )

Definition at line 161 of file Environment.cpp.

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

Referenced by ~Environment().

Here is the call graph for this function:

◆ set()

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

Definition at line 187 of file Environment.cpp.

References Environment(), Elements::getEnv(), hasKey(), m_added_variables, m_keep_same, m_old_values, and Elements::setEnv().

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

Here is the call graph for this function:

◆ unSet()

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

Definition at line 204 of file Environment.cpp.

References checkOutOfRange(), Environment(), std::find(), Elements::getEnv(), m_added_variables, m_old_values, and Elements::unSetEnv().

Here is the call graph for this function:

Member Data Documentation

◆ m_added_variables

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

variable added to the environment

Definition at line 81 of file Environment.h.

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

◆ m_keep_same

bool Elements::Environment::m_keep_same
private

Definition at line 78 of file Environment.h.

Referenced by Environment(), and set().

◆ m_old_values

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

old value for changed variables

Definition at line 76 of file Environment.h.

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


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