ANNA Suite  2020b
Multipurpose development suite for Telco applications
Public Member Functions | Friends | List of all members
anna::Environment Class Reference

#include <Environment.hpp>

Inheritance diagram for anna::Environment:
Inheritance graph
[legend]
Collaboration diagram for anna::Environment:
Collaboration graph
[legend]

Public Member Functions

 ~Environment ()
 
void initialize (char **envp=NULL)
 
std::string getValue (const char *variableName, bool exceptionIfMissing=false) noexcept(false)
 
std::string getValue (const std::string &variableName, bool exceptionIfMissing=false) noexcept(false)
 
void setVariable (const std::string &name, const std::string &value, bool overwrite=true) noexcept(false)
 
void unsetVariable (const std::string &name) noexcept(false)
 

Friends

class Singleton< Environment >
 

Additional Inherited Members

- Static Public Member Functions inherited from anna::Singleton< Environment >
static Environmentinstantiate ()
 
static void release ()
 

Detailed Description

Environment variables reader

Constructor & Destructor Documentation

◆ ~Environment()

anna::Environment::~Environment ( )
inline

Destructor.

30 {;}
Here is the call graph for this function:

Member Function Documentation

◆ getValue() [1/2]

std::string anna::Environment::getValue ( const char *  variableName,
bool  exceptionIfMissing = false 
)
noexcept

Return associated value (could be empty). This value could be cached at initialization (envp array from main function), if not, would be cached here.

Parameters
variableNameEnvironment variable name.
exceptionIfMissingWhen enabled, an exception is launched for missing variables. Empty string in other case (default behaviour).
Returns
Environment value.

◆ getValue() [2/2]

std::string anna::Environment::getValue ( const std::string &  variableName,
bool  exceptionIfMissing = false 
)
noexcept

◆ initialize()

void anna::Environment::initialize ( char **  envp = NULL)

Parses the environment data (all variables available) when process was started.

Parameters
envpEnvironment array passed on main function as third argument. Cache data is cleared if NULL passed, allowing to get current environment values for variables.

◆ setVariable()

void anna::Environment::setVariable ( const std::string &  name,
const std::string &  value,
bool  overwrite = true 
)
noexcept

Sets an environment variable. If an empty variable name is provided, or environment set operation fails, an exception will be launched.

Parameters
nameVariable name.
valueVariable value
overwriteOverwrite an existing variable name/value or keep old value if exists

◆ unsetVariable()

void anna::Environment::unsetVariable ( const std::string &  name)
noexcept

Unsets an environment variable (different than set empty string). If an empty variable name is provided, or environment set operation fails, an exception will be launched.

Parameters
nameVariable name. If empty, nothing is done.

Friends And Related Function Documentation

◆ Singleton< Environment >

friend class Singleton< Environment >
friend

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