|
blocxx
|
The EnvVars class is an abstraction for a set of environment variables. More...
#include <EnvVars.hpp>
Public Types | |
| enum | EEnvVarFlag { E_CURRENT_ENVIRONMENT , E_EMPTY_ENVIRONMENT } |
| typedef Map< String, String > | EnvMap |
| typedef EnvMap::const_iterator | const_iterator |
Public Member Functions | |
| EnvVars (EEnvVarFlag flag=E_EMPTY_ENVIRONMENT) | |
| Create an EnvVars object that is either empty or contains all of the environment variable from the current environment. | |
| template<class InputIterator > | |
| EnvVars (EEnvVarFlag flag, InputIterator first, InputIterator last) | |
| Create an EnvVars object that is either empty or contains all of the environment variable from the current environment and override it with additional environment variables from a map range specified with InputIterators. | |
| EnvVars (const char *const envp[]) | |
| Create an EnvVars object that contains the evironment variables specifed in a string array. | |
| EnvVars (const EnvVars &arg) | |
| Copy constructor. | |
| ~EnvVars () | |
| Destructor. | |
| EnvVars & | operator= (const EnvVars &arg) |
| Assignment operator. | |
| const char *const * | getenvp () const |
| size_t | size () const |
| String | getValue (const String &key, const String ¬FoundRetVal=String()) const |
| Get the value associated with a given key. | |
| bool | removeVar (const String &key) |
| Remove an environment variable from this EnvVars object. | |
| bool | setVar (const String &keyValue) |
| Set the value for a given environemt variable. | |
| bool | setVar (const String &key, const String &value) |
| Set the value for a given environemt variable. | |
| bool | addVar (const String &name, const String &value) |
| Adds the variable name if its not already part of the set. | |
| bool | updateVar (const String &name, const String &value) |
| Updates an existing variable. | |
| const_iterator | begin () const |
| const_iterator | end () const |
Private Member Functions | |
| void | deleteEnvp () const |
Static Private Member Functions | |
| static void | fillEnvMap (EnvMap &envMap) |
| static void | fillEnvMap (const char *const envp[], EnvMap &envMap) |
Private Attributes | |
| EnvMap | m_envMap |
| char ** | m_envp |
The EnvVars class is an abstraction for a set of environment variables.
Definition at line 49 of file EnvVars.hpp.
Definition at line 53 of file EnvVars.hpp.
Definition at line 52 of file EnvVars.hpp.
| Enumerator | |
|---|---|
| E_CURRENT_ENVIRONMENT | |
| E_EMPTY_ENVIRONMENT | |
Definition at line 55 of file EnvVars.hpp.
| BLOCXX_NAMESPACE::EnvVars::EnvVars | ( | EEnvVarFlag | flag = E_EMPTY_ENVIRONMENT | ) |
Create an EnvVars object that is either empty or contains all of the environment variable from the current environment.
Definition at line 77 of file EnvVars.cpp.
References E_CURRENT_ENVIRONMENT, environ, fillEnvMap(), m_envMap, and BLOCXX_NAMESPACE::operator==().
|
inline |
Create an EnvVars object that is either empty or contains all of the environment variable from the current environment and override it with additional environment variables from a map range specified with InputIterators.
The map with the additional variables can contain either blocxx::String or std::string elements (has to provide the c_str() method returning pointer to the string). Variables with empty name or a name containing the '=' character (like for setenv in SUSv3) are discarded.
| flag | Whether to construct using empty or current environment. |
| first | InputIterator pointing to the first variable. |
| last | InputIterator pointing to one past the last variable. |
Definition at line 83 of file EnvVars.hpp.
References BLOCXX_NAMESPACE::operator==().
Create an EnvVars object that contains the evironment variables specifed in a string array.
| envp | A NULL terminated char* array that contains the environment variables for the EnvVars object. Each element of the array must be in the form of "ENV_VAR_NAME=VALUE". |
Definition at line 88 of file EnvVars.cpp.
References fillEnvMap(), m_envMap, and BLOCXX_NAMESPACE::operator==().
Copy constructor.
| arg | The EnvVars object this object will be a copy of. |
| BLOCXX_NAMESPACE::EnvVars::~EnvVars | ( | ) |
Adds the variable name if its not already part of the set.
Definition at line 208 of file EnvVars.cpp.
References deleteEnvp(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::end(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::find(), m_envMap, name, and BLOCXX_NAMESPACE::operator==().
|
inline |
Definition at line 190 of file EnvVars.hpp.
|
private |
Definition at line 128 of file EnvVars.cpp.
Referenced by addVar(), getenvp(), removeVar(), setVar(), updateVar(), and ~EnvVars().
|
inline |
Definition at line 199 of file EnvVars.hpp.
|
staticprivate |
Definition at line 112 of file EnvVars.cpp.
References i, and BLOCXX_NAMESPACE::operator==().
Definition at line 104 of file EnvVars.cpp.
References environ, fillEnvMap(), and BLOCXX_NAMESPACE::operator==().
Referenced by EnvVars(), EnvVars(), and fillEnvMap().
Definition at line 159 of file EnvVars.cpp.
References BLOCXX_NAMESPACE::Map< Key, T, Compare >::begin(), deleteEnvp(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::end(), i, m_envMap, m_envp, BLOCXX_NAMESPACE::operator==(), and BLOCXX_NAMESPACE::Map< Key, T, Compare >::size().
| String BLOCXX_NAMESPACE::EnvVars::getValue | ( | const String & | key, |
| const String & | notFoundRetVal = String() ) const |
Get the value associated with a given key.
| key | The name for the value to retrieve. |
| notFoundRetVal | If the environment variable by the name of 'key' is not found, then return the value specified by this parameter. |
Definition at line 150 of file EnvVars.cpp.
References BLOCXX_NAMESPACE::Map< Key, T, Compare >::end(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::find(), m_envMap, and BLOCXX_NAMESPACE::operator==().
Remove an environment variable from this EnvVars object.
| key | The name of the environment variable to be removed. |
Definition at line 192 of file EnvVars.cpp.
References deleteEnvp(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::end(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::erase(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::find(), m_envMap, and BLOCXX_NAMESPACE::operator==().
Set the value for a given environemt variable.
If the environment variable does not exist in the EnvVars object, it will be added.
| key | The name of the environment variable |
| value | The value to set the environment variable to. |
Definition at line 222 of file EnvVars.cpp.
References deleteEnvp(), m_envMap, and BLOCXX_NAMESPACE::operator==().
Set the value for a given environemt variable.
If the environment variable does not exist in the EnvVars object, it will be added.
| keyValue | A key=value string that represent the key/value of the environemt variable to be set/added. |
Definition at line 236 of file EnvVars.cpp.
References BLOCXX_NAMESPACE::operator==(), and setVar().
Referenced by setVar().
|
inline |
Definition at line 132 of file EnvVars.hpp.
Updates an existing variable.
Definition at line 245 of file EnvVars.cpp.
References deleteEnvp(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::end(), BLOCXX_NAMESPACE::Map< Key, T, Compare >::find(), m_envMap, name, and BLOCXX_NAMESPACE::operator==().
|
private |
Definition at line 209 of file EnvVars.hpp.
Referenced by addVar(), EnvVars(), EnvVars(), getenvp(), getValue(), removeVar(), setVar(), and updateVar().
|
mutableprivate |
Definition at line 210 of file EnvVars.hpp.
Referenced by deleteEnvp(), and getenvp().