Class Environment allows easy access to path informations, system environment variables and command line arguments. More...
![]() |
Class Environment allows easy access to path informations, system environment variables and command line arguments.
This class allows to manage/access/change the informations as described in the following section. It is the task of the application itself to make use of this information in a suitable way corresponding to the application's purpose. The class Environment itself simply provides the information and makes no use of it.
The following features are supported.
Examples of Usage:
#include "TestToolBox\EnvironmentImpl.h" namespace TTB = TestToolBox; // define input path somewhere within source directories // Remark: at startup the source directory is the directory // where file environmentImpl.h is stored TTB::TheEnvironment()->CutSourceDirAfter("\\SW-Root\\"); std::string myInputFilePath = TTB::TheEnvironment()->GetSourceDir() + "MyInputFiles\\TestCaseA.input" // accessing command line if (TTB::TheEnvironment()->IsExistingCommandLineOption("-trace")) { ... } long numOfExecutions = TTB::TheEnvironment()->GetCommandLineOptionVal<long>("-numExecutions") // accessing environment variable bool produceDetailedOutput = TTB::TheEnvironment()->GetSystemEnvVariableVal<bool>("DetailedOutput"); // Display a textual description of a system error code as received via // return value or via GetLastError() if (!SomeSystemFunctionCall()) { DWORD errCode = ::GetLastError(); cout << "Function failed, reason: " << TTB::Environment::GetErrorDescription(errCode).c_str() << std::endl; // Start notepad to display some test results TTB::Environment::StartExeFile("notepad.exe","c:\tmp\MyTestResults.txt");