📄 ofcmdln.h
字号:
int getArgCount() const { return ArgumentList.size(); } /** sets first command line argument as the current one. * Useful for iterating over all arguments. * ** @return OFTrue if successful, OFFalse otherwise */ OFBool gotoFirstArg(); /** sets next command line argument as the current one. * Useful for iterating over all arguments. * ** @return OFTrue if successful, OFFalse otherwise */ OFBool gotoNextArg(); /** 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(). ** @param arg reference to C string where argument should be stored * ** @return OFTrue if successful, OFFalse otherwise */ 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(). * ** @param arg reference to C++ string where argument should be stored * ** @return OFTrue if successful, OFFalse otherwise */ OFBool getCurrentArg(OFCmdString &arg); /** gets number of parameters in the parsed command line. * A parameter is an argument which is no option (e.g. a filename). * ** @return number of parameters */ int getParamCount() const { return ParamPosList.size(); } /** gets minimum number of parameters which should be accepted. * ** @return number of parameters */ int getMinParamCount() const { return MinParamCount; } /** gets maximum number of parameters which should be accepted. * ** @return number of parameters */ int getMaxParamCount() const { return MaxParamCount; } /** 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". * ** @return OFTrue if an exclusive option is used */ OFBool hasExclusiveOption() const { return ExclusiveOption; } // --- find/get parameter (parameter is an argument which is no option) /** checks whether specified parameter exists in the command line. * ** @param pos position of parameter to be checked (1..n) * ** @return OFTrue if parameter exists, false otherwise */ OFBool findParam(const int pos); /** gets value of specified parameter as signed integer. * ** @param pos position of parameter (1..n) * @param value reference to variable where the value should be stored * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ E_ParamValueStatus getParam(const int pos, OFCmdSignedInt &value); /** get value of specified parameter as signed integer and checks for given boundary * ** @param pos position of parameter (1..n) * @param value reference to variable where the value should be stored * @param low minimum boundary for value (used for range check) * @param incl if OFTrue 'low' value is valid (included), otherwise invalid * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ E_ParamValueStatus getParamAndCheckMin(const int pos, OFCmdSignedInt &value, const OFCmdSignedInt low, const OFBool incl = OFTrue); /** gets value of specified parameter as signed integer and checks for given boundaries * ** @param pos position of parameter (1..n) * @param value reference to variable where the value should be stored * @param low minimum boundary for value (used for range check, boundary included) * @param high maximum boundary for value (dito) * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ E_ParamValueStatus getParamAndCheckMinMax(const int pos, OFCmdSignedInt &value, const OFCmdSignedInt low, const OFCmdSignedInt high); /** 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() !! * ** @param pos position of parameter (1..n) * @param value reference to variable where the value should be stored * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ E_ParamValueStatus getParam(const int pos, OFCmdUnsignedInt &value); /** 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() !! * ** @param pos position of parameter (1..n) * @param value reference to variable where the value should be stored * @param low minimum boundary for value (used for range check) * @param incl if OFTrue 'low' value is valid (included), otherwise invalid * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ 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 boundaries. * NB: If command line argument specifies a negative value the result depends on the * signed->unsigned conversion implemented in sscanf() !! * ** @param pos position of parameter (1..n) * @param value reference to variable where the value should be stored * @param low minimum boundary for value (used for range check, boundary included) * @param high maximum boundary for value (dito) * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ E_ParamValueStatus getParamAndCheckMinMax(const int pos, OFCmdUnsignedInt &value, const OFCmdUnsignedInt low, const OFCmdUnsignedInt high); /** gets value of specified parameter as floating point. * ** @param pos position of parameter (1..n) * @param value reference to variable where the value should be stored * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ E_ParamValueStatus getParam(const int pos, OFCmdFloat &value); /** gets value of specified parameter as floating point and checks for given boundary * ** @param pos position of parameter (1..n) * @param value reference to variable where the value should be stored * @param low minimum boundary for value (used for range check) * @param incl if OFTrue 'low' value is valid (included), otherwise invalid * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ 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 boundaries * ** @param pos position of parameter (1..n) * @param value reference to variable where the value should be stored * @param low minimum boundary for value (used for range check, boundary included) * @param high maximum boundary for value (dito) * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ E_ParamValueStatus getParamAndCheckMinMax(const int pos, OFCmdFloat &value, const OFCmdFloat low, const OFCmdFloat high); /** gets value of specified parameter as C string. * ** @param pos position of parameter (1..n) * @param param reference to variable where the value should be stored * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ E_ParamValueStatus getParam(const int pos, const char *¶m); /** gets value of specified parameter as C++ string. * ** @param pos position of parameter (1..n) * @param param reference to variable where the value should be stored * ** @return status of get/conversion, PVS_Normal if successful (use getStatusString for error string) */ E_ParamValueStatus getParam(const int pos, OFCmdString ¶m); // --- find/get option (option is an argument which starts with an option character, see above) /** 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. * ** @param longOpt name of option (in long format) to be checked * @param pos position of reference parameter * (default: all parameters; if value is negative option must be a direct * predecessor of the specified reference parameter '-pos', no further * search processes will be performed) * @param mode find option mode (used to support option blocks) * ** @return OFTrue if option exists, OFFalse otherwise */ OFBool findOption(const char *longOpt, const signed int pos = 0, const E_FindOptionMode mode = FOM_Normal); /** sets first command line option as the current one. * Useful for iterating over all options. * ** @return OFTrue if successful, OFFalse otherwise */ OFBool gotoFirstOption(); /** sets next command line option as the current one. * Useful for iterating over all options. * ** @return OFTrue if successful, OFFalse otherwise */ OFBool gotoNextOption(); /** 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(). * ** @param opt reference to C string where option should be stored * ** @return OFTrue if there is a current option, OFFalse otherwise */ OFBool getCurrentOption(const char *&opt); /** 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(). * ** @param opt reference to C++ string where option should be stored * ** @return OFTrue if there is a current option, OFFalse otherwise */ OFBool getCurrentOption(OFCmdString &opt); /** starts an option block which can be used to support mutually exclusive options. */ void beginOptionBlock(); /** ends an option block which can be used to support mutually exclusive options. */ void endOptionBlock(); // --- get value (used for option values) /** returns next argument as a signed integer value * ** @param value reference to signed integer variable where the value should be stored * ** @return status of get/conversion, VS_Normal if successful (use getStatusString for error string) */ E_ValueStatus getValue(OFCmdSignedInt &value); /** returns next argument as a signed integer value and checks for given boundary * ** @param value reference to signed integer variable where the value should be stored * @param low minimum boundary for value (used for range check) * @param incl if OFTrue 'low' value is valid (included), otherwise invalid * ** @return status of get/conversion, VS_Normal if successful (use getStatusString for error string) */ E_ValueStatus getValueAndCheckMin(OFCmdSignedInt &value, const OFCmdSignedInt low, const OFBool incl = OFTrue); /** returns next argument as a signed integer value and checks for given boundaries * ** @param value reference to signed integer variable where the value should be stored * @param low minimum boundary for value (used for range check, boundary included) * @param high maximum boundary for value (dito) * ** @return status of get/conversion, VS_Normal if successful (use getStatusString for error string) */ E_ValueStatus getValueAndCheckMinMax(OFCmdSignedInt &value, const OFCmdSignedInt low, const OFCmdSignedInt high); /** returns next argument as an unsigned integer value * ** @param value reference to unsigned integer variable where the value should be stored * ** @return status of get/conversion, VS_Normal if successful (use getStatusString for error string) */ E_ValueStatus getValue(OFCmdUnsignedInt &value); /** returns next argument as an unsigned integer value and checks for given boundary * ** @param value reference to unsigned integer variable where the value should be stored * @param low minimum boundary for value (used for range check) * @param incl if OFTrue 'low' value is valid (included), otherwise invalid * ** @return status of get/conversion, VS_Normal if successful (use getStatusString for error string) */ E_ValueStatus getValueAndCheckMin(OFCmdUnsignedInt &value, const OFCmdUnsignedInt low, const OFBool incl = OFTrue); /** returns next argument as an unsigned integer value and checks for given boundaries * ** @param value reference to unsigned integer variable where the value should be stored * @param low minimum boundary for value (used for range check, boundary included) * @param high maximum boundary for value (dito) * ** @return status of get/conversion, VS_Normal if successful (use getStatusString for error string) */ E_ValueStatus getValueAndCheckMinMax(OFCmdUnsignedInt &value, const OFCmdUnsignedInt low, const OFCmdUnsignedInt high); /** returns next argument as a floating point value * ** @param value reference to floating point variable where the value should be stored * ** @return status of get/conversion, VS_Normal if successful (use getStatusString for error string) */ E_ValueStatus getValue(OFCmdFloat &value); /** returns next argument as a floating point value and checks for given boundary *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -