Handles commandline parameters. More...
#include <GetoptParser.h>
Classes | |
struct | KeyValue |
Public Types | |
enum | CommandLineCleaning { eCLC_None, eCLC_Cleanup } |
typedef ICL_CORE_VC_DEPRECATE ParameterRegistrationCheck tParameterRegistrationCheck | ICL_CORE_GCC_DEPRECATE |
typedef ICL_CORE_VC_DEPRECATE CommandLineCleaning tCommandLineCleaning | ICL_CORE_GCC_DEPRECATE |
typedef icl_core::List< KeyValue > | KeyValueList |
enum | ParameterRegistrationCheck { ePRC_Strict, ePRC_Relaxed } |
Static Public Member Functions | |
static Getopt & | instance () |
Private Types | |
typedef icl_core::Map< icl_core::String, GetoptParameter > | ParameterMap |
Private Member Functions | |
Getopt () | |
Handles commandline parameters.
Getopt reads all commandline parameters and extracts commandline options (both key/value and simple ones). All parameters, which which were not identified as option parameters can be accessed as non-option parameters.
Commandline options have to be registered with calls to AddParameter(). Then parsing the commandline is initialized by a call to Initialize() with the commandline as arguments.
Getopt is implemented as a singleton so that it can be used from everywhere after it has been initialized once.
Definition at line 54 of file GetoptParser.h.
typedef ICL_CORE_VC_DEPRECATE ParameterRegistrationCheck tParameterRegistrationCheck icl_core::config::Getopt::ICL_CORE_GCC_DEPRECATE |
Definition at line 62 of file GetoptParser.h.
typedef ICL_CORE_VC_DEPRECATE CommandLineCleaning tCommandLineCleaning icl_core::config::Getopt::ICL_CORE_GCC_DEPRECATE |
Definition at line 69 of file GetoptParser.h.
Definition at line 81 of file GetoptParser.h.
|
private |
Definition at line 310 of file GetoptParser.h.
Enumerator | |
---|---|
eCLC_None |
command line options are left untouched |
eCLC_Cleanup |
known command line options are removed |
Definition at line 64 of file GetoptParser.h.
Enumerator | |
---|---|
ePRC_Strict |
all options have to be registered |
ePRC_Relaxed |
options not registered are ignored |
Definition at line 57 of file GetoptParser.h.
|
private |
Definition at line 704 of file GetoptParser.cpp.
void icl_core::config::Getopt::activateExtraCmdParams | ( | const icl_core::String & | delimiter = "--" | ) |
Active extra command parameters. They are delimited from regular commandline parameters using the delimiter and run from there to the end of the commandline.
Definition at line 39 of file GetoptParser.cpp.
void icl_core::config::Getopt::addParameter | ( | const GetoptParameter & | parameter | ) |
Adds a parameter to the list of commandline options.
Definition at line 45 of file GetoptParser.cpp.
void icl_core::config::Getopt::addParameter | ( | const GetoptParameterList & | parameters | ) |
Adds a list of parameters to the list of commandline options.
Definition at line 65 of file GetoptParser.cpp.
void icl_core::config::Getopt::addParameter | ( | const GetoptPositionalParameter & | parameter | ) |
Adds a positional parameter to the list of commandline options.
Definition at line 74 of file GetoptParser.cpp.
void icl_core::config::Getopt::addParameter | ( | const GetoptPositionalParameterList & | parameters | ) |
Adds a list of positional parameters to the list of commandline options.
Definition at line 86 of file GetoptParser.cpp.
int & icl_core::config::Getopt::argc | ( | ) |
Get the original argc.
Definition at line 375 of file GetoptParser.cpp.
char ** icl_core::config::Getopt::argv | ( | ) | const |
Get the original argv.
Definition at line 380 of file GetoptParser.cpp.
icl_core::String icl_core::config::Getopt::extraCmdParam | ( | size_t | index | ) | const |
Get the extra command parameter at index.
Definition at line 385 of file GetoptParser.cpp.
size_t icl_core::config::Getopt::extraCmdParamCount | ( | ) | const |
Get the number of extra command parameters.
Definition at line 390 of file GetoptParser.cpp.
bool icl_core::config::Getopt::initialize | ( | int & | argc, |
char * | argv[], | ||
bool | remove_read_arguments | ||
) |
Initializes Getopt with a commandline.
Definition at line 95 of file GetoptParser.cpp.
bool icl_core::config::Getopt::initialize | ( | int & | argc, |
char * | argv[], | ||
CommandLineCleaning | cleanup = eCLC_None , |
||
ParameterRegistrationCheck | registration_check = ePRC_Strict |
||
) |
Initializes Getopt with a commandline.
argc | Number of command line options in argv |
argv | Command line options |
cleanup | Can be eCLC_None to leave argc and argv untouched or eCLC_Cleanup to remove known options from argv and decrease argc appropriately |
registration_check | When encountering a not registered command line option, the value ePRC_Strict causes the initialization to fail, while ePRC_Relaxed accepts it anyway |
Definition at line 100 of file GetoptParser.cpp.
|
static |
Get the singleton instance.
Definition at line 33 of file GetoptParser.cpp.
|
inline |
Returns true
if Getopt has already been initialized.
Definition at line 135 of file GetoptParser.h.
icl_core::String icl_core::config::Getopt::paramNonOpt | ( | size_t | index | ) | const |
Get the non-option parameter at the specified index.
Definition at line 431 of file GetoptParser.cpp.
size_t icl_core::config::Getopt::paramNonOptCount | ( | ) | const |
Get the number of non-option parameters.
Definition at line 443 of file GetoptParser.cpp.
icl_core::String icl_core::config::Getopt::paramOpt | ( | const icl_core::String & | name | ) | const |
Get the value of the commandline option name.
Definition at line 395 of file GetoptParser.cpp.
bool icl_core::config::Getopt::paramOptPresent | ( | const icl_core::String & | name | ) | const |
Checks if the option name is present.
Definition at line 408 of file GetoptParser.cpp.
Getopt::KeyValueList icl_core::config::Getopt::paramPrefixOpt | ( | const icl_core::String & | prefix | ) | const |
Get the list of defined suffixes for the specified prefix.
Definition at line 413 of file GetoptParser.cpp.
bool icl_core::config::Getopt::paramPrefixOptPresent | ( | const icl_core::String & | prefix | ) | const |
Check in a prefix option is present.
Definition at line 426 of file GetoptParser.cpp.
void icl_core::config::Getopt::printHelp | ( | ) | const |
Prints the help text.
Definition at line 473 of file GetoptParser.cpp.
icl_core::String icl_core::config::Getopt::programDescription | ( | ) | const |
Get the program description.
Definition at line 463 of file GetoptParser.cpp.
icl_core::String icl_core::config::Getopt::programName | ( | ) | const |
Get the program name.
Definition at line 448 of file GetoptParser.cpp.
icl_core::String icl_core::config::Getopt::programVersion | ( | ) | const |
Get the program version.
Definition at line 453 of file GetoptParser.cpp.
void icl_core::config::Getopt::setProgramDescription | ( | icl_core::String const & | description | ) |
Set the program description, a short string describing the program's purpose.
Definition at line 468 of file GetoptParser.cpp.
void icl_core::config::Getopt::setProgramVersion | ( | icl_core::String const & | version | ) |
Set the program version.
Definition at line 458 of file GetoptParser.cpp.
|
private |
Definition at line 322 of file GetoptParser.h.
|
private |
Definition at line 323 of file GetoptParser.h.
|
private |
Definition at line 330 of file GetoptParser.h.
|
private |
Definition at line 317 of file GetoptParser.h.
|
private |
Definition at line 318 of file GetoptParser.h.
|
private |
Definition at line 320 of file GetoptParser.h.
|
private |
Definition at line 316 of file GetoptParser.h.
|
private |
Definition at line 327 of file GetoptParser.h.
|
private |
Definition at line 328 of file GetoptParser.h.
|
private |
Definition at line 311 of file GetoptParser.h.
|
private |
Definition at line 329 of file GetoptParser.h.
|
private |
Definition at line 312 of file GetoptParser.h.
|
private |
Definition at line 326 of file GetoptParser.h.
|
private |
Definition at line 324 of file GetoptParser.h.
|
private |
Definition at line 325 of file GetoptParser.h.
|
private |
Definition at line 315 of file GetoptParser.h.
|
private |
Definition at line 313 of file GetoptParser.h.
|
private |
Definition at line 314 of file GetoptParser.h.