delphyne_gui
GlobalAttributes Class Reference

Detailed Description

Holds methods to parse and query CLI arguments.

Developers should not instantiate an object of this type but use the API that this class provides.

#include <visualizer/global_attributes.hh>

Static Public Member Functions

static void ParseArguments (int argc, const char *const *argv)
 Parses a list of CLI arguments and holds them as pairs key-value. More...
 
static bool HasArgument (const std::string &key)
 Query the key existence. More...
 
static std::string GetArgument (const std::string &key)
 Gets a CLI argument previously set using SetArgument. More...
 

Member Function Documentation

◆ GetArgument()

std::string GetArgument ( const std::string &  key)
static

Gets a CLI argument previously set using SetArgument.

Parameters
[in]keyA string to index the value.
Returns
A std::string with the argument.
Exceptions
std::runtime_errorWhen there is no value for key.

◆ HasArgument()

bool HasArgument ( const std::string &  key)
static

Query the key existence.

Parameters
[in]keyA string to index the value.
Returns
true When key exists, false otherwise.

◆ ParseArguments()

void ParseArguments ( int  argc,
const char *const *  argv 
)
static

Parses a list of CLI arguments and holds them as pairs key-value.

Each element of argv must be "--{KEY}={VALUE}". The key will be KEY, and the value will be VALUE. Note that "--" and "=" are necessary. Each element of argv should not have: white spaces, '\n', '\r', '\t' characters and must be at least 5 characters long including "--" and "=".

Parameters
[in]argcThe number of elements in argv.
[in]argvA vector of string constants that hold the arguments.
Exceptions
std::runtime_errorWhen any item of argv contains: white spaces, '\n', '\r' or '\t' characters.
std::runtime_errorWhen any item of argv does not start with "--".
std::runtime_errorWhen any item of argv does not have "=" from the third position on.
std::runtime_errorWhen key or value any item of argv are empty strings.

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