CLRX
1
An unofficial OpenCL extensions designed for Radeon GPUs
|
The Command Line Parser (parses options and their arguments) More...
#include <CLIParser.h>
Classes | |
struct | OptTypeTrait< bool * > |
Option type trait for bool* type. More... | |
struct | OptTypeTrait< bool > |
Option type trait for boolean type. More... | |
struct | OptTypeTrait< const char * > |
Option type trait for const char* type. More... | |
struct | OptTypeTrait< const char ** > |
Option type trait for const char** type. More... | |
struct | OptTypeTrait< cxint * > |
Option type trait for cxint* type. More... | |
struct | OptTypeTrait< cxint > |
Option type trait for cxint type. More... | |
struct | OptTypeTrait< cxllong * > |
Option type trait for cxllong* type. More... | |
struct | OptTypeTrait< cxllong > |
Option type trait for cxllong type. More... | |
struct | OptTypeTrait< cxlong * > |
Option type trait for cxlong* type. More... | |
struct | OptTypeTrait< cxlong > |
Option type trait for cxlong type. More... | |
struct | OptTypeTrait< cxuint * > |
Option type trait for cxuint* type. More... | |
struct | OptTypeTrait< cxuint > |
Option type trait for cxuint type. More... | |
struct | OptTypeTrait< cxullong * > |
Option type trait for cxullong* type. More... | |
struct | OptTypeTrait< cxullong > |
Option type trait for cxullong type. More... | |
struct | OptTypeTrait< cxulong * > |
Option type trait for cxulong* type. More... | |
struct | OptTypeTrait< cxulong > |
Option type trait for cxulong type. More... | |
struct | OptTypeTrait< double * > |
Option type trait for double* type. More... | |
struct | OptTypeTrait< double > |
Option type trait for double type. More... | |
struct | OptTypeTrait< float * > |
Option type trait for float* type. More... | |
struct | OptTypeTrait< float > |
Option type trait for float type. More... | |
Public Member Functions | |
CLIParser (const char *programName, const CLIOption *options, cxuint argc, const char **argv) | |
constructor More... | |
void | setPackageName (const char *pkgName) |
set package name | |
void | parse () |
parse options from arguments | |
bool | handleHelpOrUsage (std::ostream &os=std::cout) const |
handle printing of help or usage. returns false when help or usage not enabled | |
cxuint | findOption (char shortName) const |
find option by shortName, returns optionId | |
cxuint | findOption (const char *longName) const |
find option by longName, returns optionId | |
template<typename T > | |
T | getOptArg (cxuint optionId) const |
get option argument if it provided | |
template<typename T > | |
T | getShortOptArg (char shortName) const |
get option argument if it provided | |
template<typename T > | |
T | getLongOptArg (const char *longName) const |
get option argument if it provided | |
template<typename T > | |
const T * | getOptArgArray (cxuint optionId, size_t &length) const |
get option argument array if it provided More... | |
template<typename T > | |
const T * | getShortOptArgArray (char shortName, size_t &length) const |
get option argument array if it provided More... | |
template<typename T > | |
const T * | getLongOptArgArray (const char *longName, size_t &length) const |
get option argument array if it provided More... | |
bool | hasOptArg (cxuint optionId) const |
returns true when argument provided for specified option | |
bool | hasShortOptArg (char shortName) const |
returns true when argument provided for specified option | |
bool | hasLongOptArg (const char *longName) const |
returns true when argument provided for specified option | |
bool | hasOption (cxuint optionId) const |
returns true if option included in command line | |
bool | hasShortOption (char shortName) const |
returns true if option included in command line | |
bool | hasLongOption (const char *longName) const |
returns true if option included in command line | |
cxuint | getArgsNum () const |
get left over arguments number | |
const char *const * | getArgs () const |
get left over arguments (null-terminated) | |
void | printHelp (std::ostream &os=std::cout) const |
print help for program (lists options) | |
void | printUsage (std::ostream &os=std::cout) const |
print usage | |
void | printVersion (std::ostream &os=std::cout) const |
print version | |
![]() | |
NonCopyableAndNonMovable () | |
constructor | |
NonCopyableAndNonMovable (const NonCopyableAndNonMovable &)=delete | |
copy-constructor | |
NonCopyableAndNonMovable (NonCopyableAndNonMovable &&)=delete | |
move-constructor | |
NonCopyableAndNonMovable & | operator= (const NonCopyableAndNonMovable &)=delete |
copy-assignment | |
NonCopyableAndNonMovable & | operator= (NonCopyableAndNonMovable &&)=delete |
move-asignment | |
The Command Line Parser (parses options and their arguments)
This class implements a command-line parser which provides short options and long options with/without arguments. Argument can be a string, number, boolean, and list of previous. Conventions of the option's (and their arguments) syntax was adapted from popt library.
Option argument can be attached in the next argument or in the rest of the argument (after '=' or not for short options). If argument option is optional then can be attached in a next argument only when argument does not have option (otherwise argument will be treated likes next option).
Elements of option argument array are separated by comma. Commas and backslashes can be entered by using backslash escapes in a string array element. An element of string array can also be empty.
Option identified by optionId which is order number. First optionId is 0. Option can have short name, long name or both. Option without argument must have argType set likes CLIArgType::NONE (no type, no argument). Argument name (argName) is optional (can be null).
IMPORTANT NOTICE: Option's list and argument's list must be available and unmodified while whole lifecycle of this CLIParser. For whole lifecycle of any option argument or left over argument, a CLIParser must be alive. (because it keeps values of these arguments).
CLRX::CLIParser::CLIParser | ( | const char * | programName, |
const CLIOption * | options, | ||
cxuint | argc, | ||
const char ** | argv | ||
) |
constructor
programName | name of program |
options | null-terminated (shortName==0, longName==NULL) options list |
argc | argc |
argv | argv |
|
inline |
get option argument array if it provided
optionId | id of option |
length | length of array |
|
inline |
get option argument array if it provided
shortName | short name of option |
length | length of array |
|
inline |
get option argument array if it provided
longName | long name of option |
length | length of array |