Public Types | |
| enum | E_ParseStatus { PS_Normal, PS_NoArguments, PS_UnknownOption, PS_MissingValue, PS_MissingParameter, PS_TooManyParameters, PS_CannotOpenCommandFile } |
| status of command line parsing More... | |
| enum | E_ValueStatus { VS_Normal, VS_Invalid, VS_NoMore, VS_Empty, VS_Underflow, VS_Overflow } |
| status of converting string option value to value field More... | |
| enum | E_ParamValueStatus { PVS_Normal, PVS_Invalid, PVS_CantFind, PVS_Empty, PVS_Underflow, PVS_Overflow } |
| status of converting string parameter to value field More... | |
| enum | E_FindOptionMode { FOM_Normal, FOM_First, FOM_Next } |
| mode for findOption method More... | |
Public Member Functions | |
| OFCommandLine () | |
| constructor | |
| virtual | ~OFCommandLine () |
| destructor | |
| void | setOptionChars (const char *chars) |
| sets characters used to detect options | |
| void | setOptionColumns (const int longCols, const int shortCols) |
| sets default width of option columns | |
| void | setParamColumn (const int column) |
| sets default width of parameter column | |
| OFBool | addOption (const char *longOpt, const char *shortOpt, const int valueCount, const char *valueDescr, const char *optDescr, const OFBool exclusive=OFFalse) |
| adds an item to the list of valid options (full version) | |
| OFBool | addOption (const char *longOpt, const char *shortOpt, const char *optDescr, const OFBool exclusive=OFFalse) |
| adds an item to the list of valid options (without additional values) | |
| OFBool | addOption (const char *longOpt, const int valueCount, const char *valueDescr, const char *optDescr, const OFBool exclusive=OFFalse) |
| adds an item to the list of valid options (without short name) | |
| OFBool | addOption (const char *longOpt, const char *optDescr, const OFBool exclusive=OFFalse) |
| adds an item to the list of valid options (without short name and additional values) | |
| void | addGroup (const char *name, const int longCols=0, const int shortCols=0) |
| adds a new group (top-level). | |
| void | addSubGroup (const char *name, const int longCols=0, const int shortCols=0) |
| adds a new subgroup (beyond group-level). | |
| OFBool | addParam (const char *param, const char *descr, const OFCmdParam::E_ParamMode mode=OFCmdParam::PM_Mandatory) |
| adds an item to the list of valid parameters (full version) | |
| OFBool | addParam (const char *param, const OFCmdParam::E_ParamMode mode=OFCmdParam::PM_Mandatory) |
| adds an item to the list of valid parameters (without description) | |
| int | getArgCount () const |
| gets number of command line arguments. | |
| OFBool | gotoFirstArg () |
| sets first command line argument as the current one. | |
| OFBool | gotoNextArg () |
| sets next command line argument as the current one. | |
| OFBool | getCurrentArg (const char *&arg) |
| gets current command line argument as a C string This is the argument which is currently parsed or has been selected as the current one by gotoXXXArg(). | |
| OFBool | getCurrentArg (OFCmdString &arg) |
| gets current command line argument as a C++ string. | |
| int | getParamCount () const |
| gets number of parameters in the parsed command line. | |
| int | getMinParamCount () const |
| gets minimum number of parameters which should be accepted. | |
| int | getMaxParamCount () const |
| gets maximum number of parameters which should be accepted. | |
| OFBool | hasExclusiveOption () const |
| checks whether the parsed command line contains any "exclusive" option which does not require any mandatory parameter. | |
| OFBool | findParam (const int pos) |
| checks whether specified parameter exists in the command line. | |
| E_ParamValueStatus | getParam (const int pos, OFCmdSignedInt &value) |
| gets value of specified parameter as signed integer. | |
| E_ParamValueStatus | getParamAndCheckMin (const int pos, OFCmdSignedInt &value, const OFCmdSignedInt low, const OFBool incl=OFTrue) |
| get value of specified parameter as signed integer and checks for given boundary | |
| E_ParamValueStatus | getParamAndCheckMinMax (const int pos, OFCmdSignedInt &value, const OFCmdSignedInt low, const OFCmdSignedInt high) |
| gets value of specified parameter as signed integer and checks for given boundaries | |
| E_ParamValueStatus | getParam (const int pos, OFCmdUnsignedInt &value) |
| gets value of specified parameter as unsigned integer. | |
| E_ParamValueStatus | getParamAndCheckMin (const int pos, OFCmdUnsignedInt &value, const OFCmdUnsignedInt low, const OFBool incl=OFTrue) |
| gets value of specified parameter as unsigned integer and checks for given boundary. | |
| E_ParamValueStatus | getParamAndCheckMinMax (const int pos, OFCmdUnsignedInt &value, const OFCmdUnsignedInt low, const OFCmdUnsignedInt high) |
| gets value of specified parameter as unsigned integer and checks for given boundaries. | |
| E_ParamValueStatus | getParam (const int pos, OFCmdFloat &value) |
| gets value of specified parameter as floating point. | |
| E_ParamValueStatus | getParamAndCheckMin (const int pos, OFCmdFloat &value, const OFCmdFloat low, const OFBool incl=OFTrue) |
| gets value of specified parameter as floating point and checks for given boundary | |
| E_ParamValueStatus | getParamAndCheckMinMax (const int pos, OFCmdFloat &value, const OFCmdFloat low, const OFCmdFloat high) |
| gets value of specified parameter as floating point and checks for given boundaries | |
| E_ParamValueStatus | getParam (const int pos, const char *¶m) |
| gets value of specified parameter as C string. | |
| E_ParamValueStatus | getParam (const int pos, OFCmdString ¶m) |
| gets value of specified parameter as C++ string. | |
| OFBool | findOption (const char *longOpt, const signed int pos=0, const E_FindOptionMode mode=FOM_Normal) |
| checks whether specified option exists in the command line. | |
| OFBool | gotoFirstOption () |
| sets first command line option as the current one. | |
| OFBool | gotoNextOption () |
| sets next command line option as the current one. | |
| OFBool | getCurrentOption (const char *&opt) |
| returns current option as a C string. | |
| OFBool | getCurrentOption (OFCmdString &opt) |
| returns current option as a C++ string. | |
| void | beginOptionBlock () |
| starts an option block which can be used to support mutually exclusive options. | |
| void | endOptionBlock () |
| ends an option block which can be used to support mutually exclusive options. | |
| E_ValueStatus | getValue (OFCmdSignedInt &value) |
| returns next argument as a signed integer value | |
| E_ValueStatus | getValueAndCheckMin (OFCmdSignedInt &value, const OFCmdSignedInt low, const OFBool incl=OFTrue) |
| returns next argument as a signed integer value and checks for given boundary | |
| E_ValueStatus | getValueAndCheckMinMax (OFCmdSignedInt &value, const OFCmdSignedInt low, const OFCmdSignedInt high) |
| returns next argument as a signed integer value and checks for given boundaries | |
| E_ValueStatus | getValue (OFCmdUnsignedInt &value) |
| returns next argument as an unsigned integer value | |
| E_ValueStatus | getValueAndCheckMin (OFCmdUnsignedInt &value, const OFCmdUnsignedInt low, const OFBool incl=OFTrue) |
| returns next argument as an unsigned integer value and checks for given boundary | |
| E_ValueStatus | getValueAndCheckMinMax (OFCmdUnsignedInt &value, const OFCmdUnsignedInt low, const OFCmdUnsignedInt high) |
| returns next argument as an unsigned integer value and checks for given boundaries | |
| E_ValueStatus | getValue (OFCmdFloat &value) |
| returns next argument as a floating point value | |
| E_ValueStatus | getValueAndCheckMin (OFCmdFloat &value, const OFCmdFloat low, const OFBool incl=OFTrue) |
| returns next argument as a floating point value and checks for given boundary | |
| E_ValueStatus | getValueAndCheckMinMax (OFCmdFloat &value, const OFCmdFloat low, const OFCmdFloat high) |
| returns next argument as a floating point value and checks for given boundaries | |
| E_ValueStatus | getValue (const char *&value) |
| returns next argument as a C string | |
| E_ValueStatus | getValue (OFCmdString &value) |
| returns next argument as a C++ string | |
| E_ParseStatus | parseLine (int argCount, char *argValue[], const int flags=0, const int startPos=1) |
| parses specified command line arguments (argc, argv). | |
| void | getSyntaxString (OFString &syntaxStr) const |
| returns command line syntax as a C++ string (single text line). | |
| void | getOptionString (OFString &optionStr) const |
| returns description of all options as a C++ string (multiple text lines). | |
| void | getParamString (OFString ¶mStr) const |
| returns description of all parameters as a C++ string (multiple text lines). | |
| void | getStatusString (const E_ParseStatus status, OFString &statusStr) |
| returns status of parseLine as a C++ string | |
| void | getStatusString (const E_ParamValueStatus status, OFString &statusStr) |
| returns status of getParam as a C++ string | |
| void | getStatusString (const E_ValueStatus status, OFString &statusStr) |
| returns status of getValue as a C++ string | |
Static Public Attributes | |
| static const int | ExpandWildcards |
| parsing flag to expand wildcard under Windows (very similar to Unix) | |
| static const int | NoCommandFiles |
| disable support for command files ("@filename") containing additional arguments | |
Protected Member Functions | |
| OFBool | checkOption (const OFString &option, const OFBool mode=OFTrue) const |
| checks whether given option is valid (starting with an option char and not followed by a number) | |
| OFBool | findParam (int pos, OFListIterator(OFCmdParamPos *)&pos_iter) |
| finds specified parameter and sets given iterator to this position | |
| const OFCmdOption * | findCmdOption (const OFString &option) const |
| finds specified option and returns reference to its describing structure | |
| void | storeParameter (const OFString ¶m, const int directOption=0) |
| stores the specified parameter in the argument/parameter list | |
| E_ParseStatus | parseCommandFile (const char *argValue, OFList< OFString > &argList) |
| check whether 'argValue' points to command file and parse content if so | |
| int | packColumnValues (int longCols, int shortCols) const |
| packs the two 16 bit values into one 32 bit value | |
| void | unpackColumnValues (const int value, unsigned int &longCols, unsigned int &shortCols) const |
| unpacks two 16 bit values from one 32 bit value | |
| E_ParseStatus | checkParamCount () |
| checks whether number of parameters in parsed command line is within the range of min/max (see below) | |
| OFBool | getLastArg (OFString &arg) |
| returns last command line argument as a C++ string | |
| OFBool | getMissingParam (OFString ¶m) |
| returns name of parameter which is missed in the parsed command line (used for error output) | |
Private Member Functions | |
| OFListIterator (OFString) ArgumentIterator | |
| current position in argument list | |
| OFListIterator (OFListIterator_OFString) OptionPosIterator | |
| current position in option position list | |
| OFListIterator (OFListIterator_OFString) OptionBlockIterator | |
| current position in option position list (used for option blocks) | |
| OFCommandLine & | operator= (const OFCommandLine &obj) |
| private undefined assignment operator | |
Private Attributes | |
| OFList< OFCmdOption * > | ValidOptionList |
| list of valid/defined command line options | |
| OFList< OFCmdParam * > | ValidParamList |
| list of valid/defined command line parameters | |
| OFList< OFString > | ArgumentList |
| list of command line arguments (after parsing) | |
| OFList< OFCmdParamPos * > | ParamPosList |
| list of parameter positions within argument list | |
| OFList< OFListIterator_OFString > | OptionPosList |
| list of option positions within argument list | |
| OFBool | OptionBlockMode |
| OFTrue if option block is active, OFFalse otherwise. | |
| OFString | OptionChars |
| C++ string conisting of all valid characters introducing an option. | |
| OFBool | ExclusiveOption |
| OFTrue if an "exclusive" option is used in the command line, OFFalse otherwise. | |
| int | LongColumn |
| width of column for long option names | |
| int | ShortColumn |
| width of column for short option names | |
| int | ParamColumn |
| width of column for parameter names | |
| int | MinParamCount |
| minimum number of parameters which should be accepted | |
| int | MaxParamCount |
| maximum number of parameter which should be accepted | |
| OFCmdParam::E_ParamMode | LastParamMode |
| mode of last added parameter (used for debug checking) | |
This class is the interface to this module. All methods which can be used from outside are defined here.
Definition at line 133 of file ofcmdln.h.
|
|
mode for findOption method
|
|
|
status of converting string parameter to value field
|
|
|
status of command line parsing
|
|
|
status of converting string option value to value field
|
|
||||||||||||||||
|
adds a new group (top-level). all following options belong to this group
|
|
||||||||||||||||
|
adds an item to the list of valid options (without short name and additional values)
|
|
||||||||||||||||||||||||
|
adds an item to the list of valid options (without short name)
|
|
||||||||||||||||||||
|
adds an item to the list of valid options (without additional values)
|
|
||||||||||||||||||||||||||||
|
adds an item to the list of valid options (full version)
|
|
||||||||||||
|
adds an item to the list of valid parameters (without description)
|
|
||||||||||||||||
|
adds an item to the list of valid parameters (full version)
|
|
||||||||||||||||
|
adds a new subgroup (beyond group-level). all following options belong to this subgroup
|
|
||||||||||||||||
|
checks whether specified option exists in the command line. The search process starts from the last command line argument (which is a direct predecessor of the optional defined reference parameter 'pos') and goes to the first one.
|
|
|
checks whether specified parameter exists in the command line.
|
|
|
gets number of command line arguments. (options and parameters)
Definition at line 370 of file ofcmdln.h. References ArgumentList, and OFList< T >::size(). |
|
|
gets current command line argument as a C++ string. This is the argument which is currently parsed or has been selected as the current one by gotoXXXArg().
|
|
|
gets current command line argument as a C string This is the argument which is currently parsed or has been selected as the current one by gotoXXXArg().
|
|
|
returns current option as a C++ string. This is the option which has currently been parsed (e.g. used for error output) or which has been selected as the current one by gotoXXXOption().
|
|
|
returns current option as a C string. This is the option which has currently been parsed (e.g. used for error output) or which has been selected as the current one by gotoXXXOption().
|
|
|
gets maximum number of parameters which should be accepted.
Definition at line 431 of file ofcmdln.h. References MaxParamCount. |
|
|
gets minimum number of parameters which should be accepted.
Definition at line 422 of file ofcmdln.h. References MinParamCount. |
|
|
returns description of all options as a C++ string (multiple text lines). Text consists of group headings, short and long option names, option descriptions and additional option values.
|
|
||||||||||||
|
gets value of specified parameter as C++ string.
|
|
||||||||||||
|
gets value of specified parameter as C string.
|
|
||||||||||||
|
gets value of specified parameter as floating point.
|
|
||||||||||||
|
gets value of specified parameter as unsigned integer. NB: If command line argument specifies a negative value the result depends on the signed->unsigned conversion implemented in sscanf() !!
|
|
||||||||||||
|
gets value of specified parameter as signed integer.
|
|
||||||||||||||||||||
|
gets value of specified parameter as floating point and checks for given boundary
|
|
||||||||||||||||||||
|
gets value of specified parameter as unsigned integer and checks for given boundary. NB: If command line argument specifies a negative value the result depends on the signed->unsigned conversion implemented in sscanf() !!
|
|
||||||||||||||||||||
|
get value of specified parameter as signed integer and checks for given boundary
|
|
||||||||||||||||||||
|
gets value of specified parameter as floating point and checks for given boundaries
|
|
||||||||||||||||||||
|
gets value of specified parameter as unsigned integer and checks for given boundaries. NB: If command line argument specifies a negative value the result depends on the signed->unsigned conversion implemented in sscanf() !!
|
|
||||||||||||||||||||
|
gets value of specified parameter as signed integer and checks for given boundaries
|
|
|
gets number of parameters in the parsed command line. A parameter is an argument which is no option (e.g. a filename).
Definition at line 413 of file ofcmdln.h. References ParamPosList, and OFList< T >::size(). |
|
|
returns description of all parameters as a C++ string (multiple text lines). Text consists of heading "parameters:" and parameter names and descriptions.
|
|
||||||||||||
|
returns status of getValue as a C++ string
|
|
||||||||||||
|
returns status of getParam as a C++ string
|
|
||||||||||||
|
returns status of parseLine as a C++ string
|
|
|
returns command line syntax as a C++ string (single text line). Text consists of "[options]" (if defined by addOption) and all parameters defined by addParam.
|
|
|
returns next argument as a C++ string
|
|
|
returns next argument as a C string
|
|
|
returns next argument as a floating point value
|
|
|
returns next argument as an unsigned integer value
|
|
|
returns next argument as a signed integer value
|
|
||||||||||||||||
|
returns next argument as a floating point value and checks for given boundary
|
|
||||||||||||||||
|
returns next argument as an unsigned integer value and checks for given boundary
|
|
||||||||||||||||
|
returns next argument as a signed integer value and checks for given boundary
|
|
||||||||||||||||
|
returns next argument as a floating point value and checks for given boundaries
|
|
||||||||||||||||
|
returns next argument as an unsigned integer value and checks for given boundaries
|
|
||||||||||||||||
|
returns next argument as a signed integer value and checks for given boundaries
|
|
|
sets first command line argument as the current one. Useful for iterating over all arguments.
|
|
|
sets first command line option as the current one. Useful for iterating over all options.
|
|
|
sets next command line argument as the current one. Useful for iterating over all arguments.
|
|
|
sets next command line option as the current one. Useful for iterating over all options.
|
|
|
checks whether the parsed command line contains any "exclusive" option which does not require any mandatory parameter. Examples for typical exclusive options are "--help" and "--version".
Definition at line 442 of file ofcmdln.h. References ExclusiveOption. |
|
||||||||||||||||||||
|
parses specified command line arguments (argc, argv). Additionally create internal structures for evaluation and return status indicating any errors occuring during the parse process. If "--help" or the specified shortcut is the only command line argument, the status code PS_NoArguments is returned.
|
|
|
sets characters used to detect options
|
|
||||||||||||
|
sets default width of option columns
|
|
|
sets default width of parameter column
|