33 #include "dcmtk/config/osconfig.h"
34 #include "dcmtk/ofstd/oftypes.h"
35 #include "dcmtk/ofstd/oflist.h"
36 #include "dcmtk/ofstd/ofstring.h"
37 #include "dcmtk/ofstd/ofconsol.h"
39 #define INCLUDE_CSTDIO
40 #include "dcmtk/ofstd/ofstdinc.h"
48 typedef signed long OFCmdSignedInt;
50 typedef unsigned long OFCmdUnsignedInt;
52 typedef double OFCmdFloat;
57 typedef OFListIterator(
OFString) OFListIterator_OFString;
102 ParamDescription(descr),
117 OFCmdParam& operator=(
const OFCmdParam& arg);
238 const int shortCols);
259 const char *shortOpt,
260 const int valueCount,
261 const char *valueDescr,
262 const char *optDescr,
263 const int flags = 0);
276 const char *shortOpt,
277 const char *optDescr,
278 const int flags = 0);
292 const int valueCount,
293 const char *valueDescr,
294 const char *optDescr,
295 const int flags = 0);
307 const char *optDescr,
308 const int flags = 0);
318 const int longCols = 0,
319 const int shortCols = 0);
329 const int longCols = 0,
330 const int shortCols = 0);
469 OFCmdSignedInt &value);
481 OFCmdSignedInt &value,
482 const OFCmdSignedInt low,
483 const OFBool incl = OFTrue);
495 OFCmdSignedInt &value,
496 const OFCmdSignedInt low,
497 const OFCmdSignedInt high);
509 OFCmdUnsignedInt &value);
523 OFCmdUnsignedInt &value,
524 const OFCmdUnsignedInt low,
525 const OFBool incl = OFTrue);
539 OFCmdUnsignedInt &value,
540 const OFCmdUnsignedInt low,
541 const OFCmdUnsignedInt high);
564 const OFCmdFloat low,
565 const OFBool incl = OFTrue);
578 const OFCmdFloat low,
579 const OFCmdFloat high);
621 const signed int pos = 0,
686 const OFCmdSignedInt low,
687 const OFBool incl = OFTrue);
698 const OFCmdSignedInt low,
699 const OFCmdSignedInt high);
718 const OFCmdUnsignedInt low,
719 const OFBool incl = OFTrue);
730 const OFCmdUnsignedInt low,
731 const OFCmdUnsignedInt high);
750 const OFCmdFloat low,
751 const OFBool incl = OFTrue);
762 const OFCmdFloat low,
763 const OFCmdFloat high);
799 const int startPos = 1);
873 const OFBool mode = OFTrue)
const;
887 const int directOption = 0);
897 int shortCols)
const;
902 unsigned int &longCols,
903 unsigned int &shortCols)
const;
905 #ifdef HAVE_WINDOWS_H
909 void expandWildcards(
const OFString ¶m,
910 int directOption = 0);
void getSyntaxString(OFString &syntaxStr) const
returns command line syntax as a C++ string (single text line).
parameter is required, more than one value is allowed (# = 1..n), "option..."
static const int AF_Exclusive
exclusive option that overrides any other option (e.g. "--help")
void getStatusString(const E_ParseStatus status, OFString &statusStr)
returns status of parseLine as a C++ string
E_ParseStatus parseCommandFile(const char *argValue, OFList< OFString > &argList)
check whether 'argValue' points to command file and parse content if so
int ParamColumn
width of column for parameter names
E_ParamMode
mode specifying parameter's cardinality
int ShortColumn
width of column for short option names
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)
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 ...
OFBool gotoNextArg()
sets next command line argument as the current one.
void setParamColumn(const int column)
sets default width of parameter column
OFListIterator(OFString) ArgumentIterator
current position in argument list
void addGroup(const char *name, const int longCols=0, const int shortCols=0)
adds a new group (top-level).
OFCmdParam::E_ParamMode LastParamMode
mode of last added parameter (used for debug checking)
OFBool getCurrentArg(const char *&arg)
gets current command line argument as a C string This is the argument which is currently parsed or ha...
void getOptionString(OFString &optionStr) const
returns description of all options as a C++ string (multiple text lines).
static const int PF_NoCommandFiles
disable support for command files ("@filename") containing additional arguments
int MinParamCount
minimum number of parameters which should be accepted
no more arguments to be converted
converted value falls below minimum
argument contains invalid char(s)
const OFString ParamName
parameter name
OFBool getCurrentOption(const char *&opt)
returns current option as a C string.
OFList< OFListIterator_OFString > OptionPosList
list of option positions within argument list
E_ValueStatus getValue(OFCmdSignedInt &value)
returns next argument as a signed integer value
OFBool ExclusiveOption
OFTrue if an "exclusive" option is used in the command line, OFFalse otherwise.
void setOptionChars(const char *chars)
sets characters used to detect options
int getArgCount() const
gets number of command line arguments.
Internal structure to store valid command line parameters.
int getMaxParamCount() const
gets maximum number of parameters which should be accepted.
const E_ParamMode ParamMode
parameter's cardinality mode
OFString OptionChars
C++ string conisting of all valid characters introducing an option.
no arguments to be parsed
E_FindOptionMode
mode for findOption method
find next option (from left to right)
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_ParseStatus
status of command line parsing
OFCmdParam(const char *param, const char *descr, const E_ParamMode mode)
constructor
OFBool gotoFirstArg()
sets first command line argument as the current one.
static const int PF_ExpandWildcards
parsing flag to expand wildcard under Windows (very similar to Unix)
OFList< OFCmdParam * > ValidParamList
list of valid/defined command line parameters
converted value exceeds maximum
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) ...
argument contains invalid char(s)
OFBool getLastArg(OFString &arg)
returns last command line argument as a C++ string
void beginOptionBlock()
starts an option block which can be used to support mutually exclusive options.
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.
const OFString & getProgramName() const
get the name of the program (i.e.
OFBool findParam(const int pos)
checks whether specified parameter exists in the command line.
specified parameter doesn't exist
parameter is required (# = 1), "option"
OFBool gotoNextOption()
sets next command line option as the current one.
static const int AF_NoWarning
do not output a warning message if option has never been checked.
missing value(s) for an option
void setOptionColumns(const int longCols, const int shortCols)
sets default width of option columns
int getParamCount() const
gets number of parameters in the parsed command line.
void storeParameter(const OFString ¶m, const int directOption=0)
stores the specified parameter in the argument/parameter list
OFBool getMissingParam(OFString ¶m)
returns name of parameter which is missed in the parsed command line (used for error output) ...
OFList< OFCmdOption * > ValidOptionList
list of valid/defined command line options
OFString ProgramName
program name, i.e. the value of argv[0]
E_ValueStatus
status of converting string option value to value field
static const int AF_Internal
internal option that is not shown in the syntax usage output
virtual ~OFCommandLine()
destructor
E_ParamValueStatus getParam(const int pos, OFCmdSignedInt &value)
gets value of specified parameter as signed integer.
E_ParseStatus parseLine(int argCount, char *argValue[], const int flags=0, const int startPos=1)
parses specified command line arguments (argc, argv).
OFBool hasExclusiveOption() const
checks whether the parsed command line contains any "exclusive" option which does not require any man...
int getMinParamCount() const
gets minimum number of parameters which should be accepted.
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
OFCommandLine()
constructor
OFBool addOption(const char *longOpt, const char *shortOpt, const int valueCount, const char *valueDescr, const char *optDescr, const int flags=0)
adds an item to the list of valid options (full version)
OFList< OFCmdParamPos * > ParamPosList
list of parameter positions within argument list
int packColumnValues(int longCols, int shortCols) const
packs the two 16 bit values into one 32 bit value
void addSubGroup(const char *name, const int longCols=0, const int shortCols=0)
adds a new subgroup (beyond group-level).
a simple string class that implements a subset of std::string.
OFList< OFString > ArgumentList
list of command line arguments (after parsing)
E_ParamValueStatus
status of converting string parameter to value field
size_t size() const
returns number of elements in the list.
E_ParseStatus checkParamCount()
checks whether number of parameters in parsed command line is within the range of min/max (see below)...
void getParamString(OFString ¶mStr) const
returns description of all parameters as a C++ string (multiple text lines).
find first option (from left to right)
const OFCmdOption * findCmdOption(const OFString &option) const
finds specified option and returns reference to its describing structure
handles command line arguments.
converted value exceeds maximum
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
OFBool gotoFirstOption()
sets first command line option as the current one.
void endOptionBlock()
ends an option block which can be used to support mutually exclusive options.
void unpackColumnValues(const int value, unsigned int &longCols, unsigned int &shortCols) const
unpacks two 16 bit values from one 32 bit value
int MaxParamCount
maximum number of parameter which should be accepted
converted value falls below minimum
parameter is optional (# = 0..1), "[option]"
OFBool OptionBlockMode
OFTrue if option block is active, OFFalse otherwise.
int LongColumn
width of column for long option names
const OFString ParamDescription
parameter description