TestToolBox::Environment Class Reference

Class allows easy access to path informations, system environment variables and command line arguments. For more info about usage see Using Environment. More...

#include <Environment.h>

Collaboration diagram for TestToolBox::Environment:
Collaboration graph
[legend]

List of all members.

Public Types

enum  CallMode { CM_DEFAULT, CM_THROW }
 

Mode describing the behaviour of a called function in case of error.

More...

Protected Types

typedef std::map< std::string,
std::string > 
CmdLineOptions
 Set of command options as read from command line
each command option has the format -optionName [paramValue].

Protected Attributes

CmdLineOptions m_cmdLineOptions
 Stored command line options.

Exe path



std::string GetExeFileFullPath (void)
 Get complete path for exe file (e.g. "C:\MyTargetBin\MyAppname.exe").
std::string GetExeDir (void)
 Get directory path (e.g. "C:\MyTargetBin").
std::string GetExeDrive (void)
 Get drive letter (e.g. "C:").
std::string GetAppName (void)
 Get application name, i.e. name of executable without extension (e.g. "MyAppname").

Source path



std::string GetSourceDir ()
 Get the directory where the sources are stored. The initial value is generated from the preprocessor expression __FILE__ and relates to the directory where the sources have been compiled (usually within a version management system) An arbitrary string can be set using SetSourceDir(). To limit the path use function CutSourceDirAfter(). //.
std::string GetSourceDrive (void)
 Get drive letter (e.g. "C:").
void CutSourceDirAfter (std::string const &in_findStr)
 Find first occurance of the given string within source dir and cut off the rest of the source dir string.
void SetSourceDir (std::string const &in_sourceDir)
 Explicitly replace the value of SourceDir with the given string.

Out/Ref directories

Get and set file paths used for unit testing. When starting up both path directories are initialized with the executable directory as available through GetExeDir().



std::string GetOutputDir ()
void SetOutputDir (std::string in_outputDir)
std::string GetReferenceDir ()
void SetReferenceDir (std::string in_referenceDir)

Access to command line

When starting up all command line params of format "-option [value]" are read into an internal string map upon which all functions except GetCommandLineStr()/GetArgsStr() are working.



bool IsExistingCommandLineOption (std::string const &in_nameOption) const
 Check whether the given option is given within the command line.
std::string GetCommandLineOption (std::string const &in_nameOption)
 Get the given option in string format.
void SetCommandLineOption (std::string const &in_nameOption, std::string const &in_optionValue)
 Change/create the given option in string format.
template<class T >
GetCommandLineOptionVal (const std::string &in_nameOption, CallMode in_callMode=CM_DEFAULT)
 Get the given option in numeric/any streamable format.
template<class T >
void SetCommandLineOptionVal (const std::string &in_nameOption, T in_val)
 Set the given option in numeric/any streamable format.
static std::string GetCommandLineStr (void)
 Get the complete command line as a single string.
static std::string GetArgsStr (void)

Access to system environment variables



bool IsExistingSystemEnvVariable (std::string const &in_envVarName)
 Check whether the given environment variable is existing.
bool GetSystemEnvVariable (std::string const &in_envVarName, std::string &out_envVarValue)
 Get the given environment variable in string format A return value of false signals that the environment variable is not set.
std::string GetSystemEnvVariable (std::string const &in_envVarName)
 Get the given environment variable as string. If variable is not existing an empty string is returned.
void SetSystemEnvVariable (std::string const &in_envVarName, std::string const &in_envVarValue)
 Set the given environment variable in string format.
template<class T >
GetSystemEnvVariableVal (const std::string &in_envVarName, CallMode in_callMode=CM_DEFAULT)
 Get the given environment variable in numeric/any streamable format.
template<class T >
void SetSystemEnvVariableVal (const std::string &in_envVarName, T in_val)
 Set the given environment variable in numeric/any streamable format.

Name of user and computer



static std::string GetNameOfComputer (void)
 Get name of computer.
static std::string GetNameOfUser (void)
 Get name of user which has logged in.

General Helper Functions



static std::string GetErrorDescription (int in_systemError)
 Get a textual description for a system error code.
static bool StartExeFile (std::string const &in_executableToStart, std::string const &in_startArguments="")
 Start an arbitrary executable file.

Detailed Description

Class allows easy access to path informations, system environment variables and command line arguments. For more info about usage see Using Environment.

See also:
Environment.h (File documentation)
TestEnvironment (unit test for class Environment)
Using Environment (Usage documentation)

Member Enumeration Documentation

Mode describing the behaviour of a called function in case of error.

Enumerator:
CM_DEFAULT 

return default value in case of error

CM_THROW 

throw std::exception in case of error


Member Function Documentation

static std::string TestToolBox::Environment::GetArgsStr ( void   )  [static]

Get the complete command line args as a single string. The name of the executable (usually arg0) is not contained.


The documentation for this class was generated from the following file:
Generated on Fri May 27 22:55:54 2011 for TestToolBox by  doxygen 1.6.3