OFFIS DCMTK  Version 3.6.0
ofcmdln.h
1 /*
2  *
3  * Copyright (C) 1998-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: ofstd
15  *
16  * Author: Joerg Riesmeier
17  *
18  * Purpose: Handle command line arguments (Header)
19  *
20  * Last Update: $Author: joergr $
21  * Update Date: $Date: 2010-10-14 13:15:50 $
22  * CVS/RCS Revision: $Revision: 1.43 $
23  * Status: $State: Exp $
24  *
25  * CVS/RCS Log at end of file
26  *
27  */
28 
29 
30 #ifndef OFCMDLN_H
31 #define OFCMDLN_H
32 
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"
38 
39 #define INCLUDE_CSTDIO
40 #include "dcmtk/ofstd/ofstdinc.h"
41 
42 
43 /*--------------------*
44  * type declaration *
45  *--------------------*/
46 
48 typedef signed long OFCmdSignedInt;
50 typedef unsigned long OFCmdUnsignedInt;
52 typedef double OFCmdFloat;
54 typedef OFString OFCmdString;
55 
56 // necessary for MSVC5 :-/
57 typedef OFListIterator(OFString) OFListIterator_OFString;
58 
59 
60 /*------------------------*
61  * forward declarations *
62  *------------------------*/
63 
64 struct OFCmdOption;
65 struct OFCmdParamPos;
66 
67 
68 /*----------------------*
69  * struct declaration *
70  *----------------------*/
71 
75 struct OFCmdParam
76 {
77 
81  {
89  PM_MultiOptional
90  };
91 
98  OFCmdParam(const char *param,
99  const char *descr,
100  const E_ParamMode mode)
101  : ParamName(param),
102  ParamDescription(descr),
103  ParamMode(mode)
104  {
105  }
106 
113 
114 private:
115 
117  OFCmdParam& operator=(const OFCmdParam& arg);
118 };
119 
120 
121 /*---------------------*
122  * class declaration *
123  *---------------------*/
124 
130 {
131 
132  public:
133 
134  // --- enumerations
135 
139  {
156  };
157 
158 
162  {
175  };
176 
177 
181  {
194  };
195 
199  {
210  };
211 
212 
213  // --- constructor and destructor
214 
217  OFCommandLine();
218 
221  virtual ~OFCommandLine();
222 
223 
224  // --- initialization
225 
230  void setOptionChars(const char *chars);
231 
237  void setOptionColumns(const int longCols,
238  const int shortCols);
239 
244  void setParamColumn(const int column);
245 
258  OFBool addOption(const char *longOpt,
259  const char *shortOpt,
260  const int valueCount,
261  const char *valueDescr,
262  const char *optDescr,
263  const int flags = 0);
264 
275  OFBool addOption(const char *longOpt,
276  const char *shortOpt,
277  const char *optDescr,
278  const int flags = 0);
279 
291  OFBool addOption(const char *longOpt,
292  const int valueCount,
293  const char *valueDescr,
294  const char *optDescr,
295  const int flags = 0);
296 
306  OFBool addOption(const char *longOpt,
307  const char *optDescr,
308  const int flags = 0);
309 
317  void addGroup(const char *name,
318  const int longCols = 0,
319  const int shortCols = 0);
320 
328  void addSubGroup(const char *name,
329  const int longCols = 0,
330  const int shortCols = 0);
331 
341  OFBool addParam(const char *param,
342  const char *descr,
344 
353  OFBool addParam(const char *param,
355 
356 
357  // --- get information
358 
363  const OFString &getProgramName() const
364  {
365  return ProgramName;
366  }
367 
373  int getArgCount() const
374  {
375  return OFstatic_cast(int, ArgumentList.size());
376  }
377 
383  OFBool gotoFirstArg();
384 
390  OFBool gotoNextArg();
391 
399  OFBool getCurrentArg(const char *&arg);
400 
409  OFBool getCurrentArg(OFCmdString &arg);
410 
416  int getParamCount() const
417  {
418  return OFstatic_cast(int, ParamPosList.size());
419  }
420 
425  int getMinParamCount() const
426  {
427  return MinParamCount;
428  }
429 
434  int getMaxParamCount() const
435  {
436  return MaxParamCount;
437  }
438 
445  OFBool hasExclusiveOption() const
446  {
447  return ExclusiveOption;
448  }
449 
450 
451  // --- find/get parameter (parameter is an argument which is no option)
452 
459  OFBool findParam(const int pos);
460 
468  E_ParamValueStatus getParam(const int pos,
469  OFCmdSignedInt &value);
470 
481  OFCmdSignedInt &value,
482  const OFCmdSignedInt low,
483  const OFBool incl = OFTrue);
484 
495  OFCmdSignedInt &value,
496  const OFCmdSignedInt low,
497  const OFCmdSignedInt high);
498 
508  E_ParamValueStatus getParam(const int pos,
509  OFCmdUnsignedInt &value);
510 
523  OFCmdUnsignedInt &value,
524  const OFCmdUnsignedInt low,
525  const OFBool incl = OFTrue);
526 
539  OFCmdUnsignedInt &value,
540  const OFCmdUnsignedInt low,
541  const OFCmdUnsignedInt high);
542 
550  E_ParamValueStatus getParam(const int pos,
551  OFCmdFloat &value);
552 
563  OFCmdFloat &value,
564  const OFCmdFloat low,
565  const OFBool incl = OFTrue);
566 
577  OFCmdFloat &value,
578  const OFCmdFloat low,
579  const OFCmdFloat high);
580 
588  E_ParamValueStatus getParam(const int pos,
589  const char *&param);
590 
598  E_ParamValueStatus getParam(const int pos,
599  OFCmdString &param);
600 
601 
602  // --- find/get option (option is an argument which starts with an option character, see above)
603 
620  OFBool findOption(const char *longOpt,
621  const signed int pos = 0,
622  const E_FindOptionMode mode = FOM_Normal);
623 
629  OFBool gotoFirstOption();
630 
636  OFBool gotoNextOption();
637 
646  OFBool getCurrentOption(const char *&opt);
647 
656  OFBool getCurrentOption(OFCmdString &opt);
657 
660  void beginOptionBlock();
661 
664  void endOptionBlock();
665 
666 
667  // --- get value (used for option values)
668 
675  E_ValueStatus getValue(OFCmdSignedInt &value);
676 
685  E_ValueStatus getValueAndCheckMin(OFCmdSignedInt &value,
686  const OFCmdSignedInt low,
687  const OFBool incl = OFTrue);
688 
697  E_ValueStatus getValueAndCheckMinMax(OFCmdSignedInt &value,
698  const OFCmdSignedInt low,
699  const OFCmdSignedInt high);
700 
707  E_ValueStatus getValue(OFCmdUnsignedInt &value);
708 
717  E_ValueStatus getValueAndCheckMin(OFCmdUnsignedInt &value,
718  const OFCmdUnsignedInt low,
719  const OFBool incl = OFTrue);
720 
729  E_ValueStatus getValueAndCheckMinMax(OFCmdUnsignedInt &value,
730  const OFCmdUnsignedInt low,
731  const OFCmdUnsignedInt high);
732 
739  E_ValueStatus getValue(OFCmdFloat &value);
740 
749  E_ValueStatus getValueAndCheckMin(OFCmdFloat &value,
750  const OFCmdFloat low,
751  const OFBool incl = OFTrue);
752 
761  E_ValueStatus getValueAndCheckMinMax(OFCmdFloat &value,
762  const OFCmdFloat low,
763  const OFCmdFloat high);
764 
771  E_ValueStatus getValue(const char *&value);
772 
780 
781 
782  // --- parsing command line
783 
796  E_ParseStatus parseLine(int argCount,
797  char *argValue[],
798  const int flags = 0,
799  const int startPos = 1);
800 
801 
802  // --- get usage/status strings
803 
809  void getSyntaxString(OFString &syntaxStr) const;
810 
817  void getOptionString(OFString &optionStr) const;
818 
824  void getParamString(OFString &paramStr) const;
825 
831  void getStatusString(const E_ParseStatus status,
832  OFString &statusStr);
833 
839  void getStatusString(const E_ParamValueStatus status,
840  OFString &statusStr);
841 
847  void getStatusString(const E_ValueStatus status,
848  OFString &statusStr);
849 
850 
851  // --- flags (used for method parseLine)
852 
854  static const int PF_ExpandWildcards;
856  static const int PF_NoCommandFiles;
857 
858  // --- flags (used for method addOption)
859 
861  static const int AF_Exclusive;
863  static const int AF_Internal;
866  static const int AF_NoWarning;
867 
868  protected:
869 
872  OFBool checkOption(const OFString &option,
873  const OFBool mode = OFTrue) const;
874 
877  OFBool findParam(int pos,
878  OFListIterator(OFCmdParamPos *) &pos_iter);
879 
882  const OFCmdOption *findCmdOption(const OFString &option) const;
883 
886  void storeParameter(const OFString &param,
887  const int directOption = 0);
888 
891  E_ParseStatus parseCommandFile(const char *argValue,
892  OFList<OFString> &argList);
893 
896  int packColumnValues(int longCols,
897  int shortCols) const;
898 
901  void unpackColumnValues(const int value,
902  unsigned int &longCols,
903  unsigned int &shortCols) const;
904 
905 #ifdef HAVE_WINDOWS_H
906 
909  void expandWildcards(const OFString &param,
910  int directOption = 0);
911 #endif
912 
916 
919  OFBool getLastArg(OFString &arg);
920 
923  OFBool getMissingParam(OFString &param);
924 
925 
926  private:
927 
930 
935 
939  OFListIterator(OFString) ArgumentIterator;
940 
942  OFList<OFCmdParamPos *> ParamPosList;
944  OFList<OFListIterator_OFString> OptionPosList;
946  OFListIterator(OFListIterator_OFString) OptionPosIterator;
948  OFListIterator(OFListIterator_OFString) OptionBlockIterator;
949 
954 
957 
964 
969 
971  OFCmdParam::E_ParamMode LastParamMode;
972 
973 
974  private:
975 
977  OFCommandLine &operator=(const OFCommandLine &obj);
978 };
979 
980 
981 #endif
982 
983 
984 /*
985  *
986  * CVS/RCS Log:
987  * $Log: ofcmdln.h,v $
988  * Revision 1.43 2010-10-14 13:15:50 joergr
989  * Updated copyright header. Added reference to COPYRIGHT file.
990  *
991  * Revision 1.42 2010-04-28 13:23:18 joergr
992  * Added type cast to integer variable in order to avoid compiler warnings
993  * reported by VisualStudio 2005.
994  *
995  * Revision 1.41 2009-12-23 12:15:51 joergr
996  * Added support for getting the name of the program, i.e. the value of argv[0].
997  *
998  * Revision 1.40 2009-06-04 09:53:00 joergr
999  * Added new flag that can be used to avoid wrong warning messages (in debug
1000  * mode) that an option has possibly never been checked.
1001  *
1002  * Revision 1.39 2008-04-16 12:39:35 joergr
1003  * Added support for reverse search direction (left to right) to findOption().
1004  *
1005  * Revision 1.38 2006/07/27 13:16:11 joergr
1006  * Changed parameter "exclusive" of method addOption() from type OFBool into an
1007  * integer parameter "flags".
1008  * Added addOption() flag for internal options that are not shown in the syntax
1009  * usage output. Prepended prefix "PF_" to parseLine() flags.
1010  * Option "--help" is no longer an exclusive option by default.
1011  *
1012  * Revision 1.37 2005/12/08 16:05:48 meichel
1013  * Changed include path schema for all DCMTK header files
1014  *
1015  * Revision 1.36 2003/12/05 13:59:33 joergr
1016  * Fixed problem with retrieving option values using the new iteration feature.
1017  *
1018  * Revision 1.35 2003/12/05 10:36:03 joergr
1019  * Added support for iterating over command line arguments and options.
1020  * Removed leading underscore characters from preprocessor symbols (reserved
1021  * symbols). Updated copyright date where appropriate.
1022  *
1023  * Revision 1.34 2003/06/12 13:19:58 joergr
1024  * Added support for so-called command files ("@filename") which can be used to
1025  * summarize command line options and parameter
1026  *
1027  * Revision 1.33 2003/05/20 08:42:39 joergr
1028  * Renamed parameters/variables "string" to avoid name clash with STL class.
1029  *
1030  * Revision 1.32 2002/12/09 13:04:41 joergr
1031  * Replaced tab characters by spaces.
1032  *
1033  * Revision 1.31 2002/12/05 13:48:21 joergr
1034  * Make sure that no warning on "unchecked command line options" is reported in
1035  * debug mode when an exclusive option is used.
1036  *
1037  * Revision 1.30 2002/11/27 11:23:04 meichel
1038  * Adapted module ofstd to use of new header file ofstdinc.h
1039  *
1040  * Revision 1.29 2002/09/19 08:30:20 joergr
1041  * Added general support for "exclusive" command line options besides "--help",
1042  * e.g. "--version".
1043  *
1044  * Revision 1.28 2001/11/09 15:46:42 joergr
1045  * Renamed some of the getValue/getParam methods to avoid ambiguities reported
1046  * by certain compilers.
1047  *
1048  * Revision 1.27 2001/08/23 16:05:52 meichel
1049  * Added private undefined copy assignment operators to avoid gcc warnings
1050  *
1051  * Revision 1.26 2001/06/01 15:51:32 meichel
1052  * Updated copyright header
1053  *
1054  * Revision 1.25 2000/10/10 12:01:20 meichel
1055  * Created/updated doc++ comments
1056  *
1057  * Revision 1.24 2000/04/14 15:17:11 meichel
1058  * Adapted all ofstd library classes to consistently use ofConsole for output.
1059  *
1060  * Revision 1.23 2000/03/08 16:36:01 meichel
1061  * Updated copyright header.
1062  *
1063  * Revision 1.22 2000/03/07 15:38:49 joergr
1064  * Changed behaviour of class OFConsoleApplication to support automatic
1065  * evaluation of "--help" option for command line application with no
1066  * mandatory parameter.
1067  *
1068  * Revision 1.21 2000/03/03 14:02:46 meichel
1069  * Implemented library support for redirecting error messages into memory
1070  * instead of printing them to stdout/stderr for GUI applications.
1071  *
1072  * Revision 1.20 2000/03/02 12:39:11 joergr
1073  * Fixed inconsistency: console applications with no or only optional
1074  * parameters could not be started without any command line argument
1075  * because this was always regarded identical with "--help" (print usage).
1076  *
1077  * Revision 1.19 1999/10/04 10:02:31 joergr
1078  * Fixed bug in wildcard expansion (concerning "direct option" feature).
1079  *
1080  * Revision 1.18 1999/09/13 16:36:54 joergr
1081  * Corrected bug in OFCommandLine::findOption() regarding the optional
1082  * parameter 'pos' specifying a reference command line parameter.
1083  *
1084  * Revision 1.17 1999/09/06 16:48:25 joergr
1085  * Added support to method 'findOption()' to detect options which are
1086  * 'direct' predecessors of an optionally specified reference parameter.
1087  *
1088  * Revision 1.16 1999/05/04 08:38:26 joergr
1089  * Added DOC++ comments to header file.
1090  *
1091  * Revision 1.15 1999/04/29 15:21:45 joergr
1092  * Removed debug code.
1093  *
1094  * Revision 1.13 1999/04/28 13:13:16 joergr
1095  * Removed some '#ifdef DEBUG' statements from header files to avoid
1096  * problems with inconsistent compilations.
1097  *
1098  * Revision 1.12 1999/04/27 17:46:05 joergr
1099  * Added some comments (DOC++ style).
1100  *
1101  * Revision 1.10 1999/04/26 16:32:47 joergr
1102  * Added support to define minimum width of short and long option columns.
1103  * Removed bug: empty parameters have always been interpreted as options.
1104  * Enhanced support of wildcard expansion under Windows (now very similar
1105  * to Unix shells).
1106  *
1107  * Revision 1.9 1999/03/24 16:59:38 joergr
1108  * Added optional parameters to define minimum width of columns for short and
1109  * long options in syntax output.
1110  * Changed optional integer parameter in method findOption to enum type.
1111  *
1112  * Revision 1.8 1999/02/08 11:51:38 joergr
1113  * Removed '#include <iostream.h>' from ofcmdln.h.
1114  *
1115  * Revision 1.7 1999/02/05 14:07:07 joergr
1116  * Added automatic wildcard expansion for Windows compilers.
1117  *
1118  * Revision 1.6 1998/12/02 18:44:25 joergr
1119  * Introduced test whether added options are correct (starting with defined
1120  * option character followed by a character which is no number). Changed
1121  * parse routine to distinguish between options (normally starting mit - or
1122  * +) and signed numbers which can be valid parameters.
1123  *
1124  * Revision 1.5 1998/12/02 17:38:53 joergr
1125  * Introduced new enum type used to indicate the status when converting
1126  * parameter values (similar to option values). Changed return value of
1127  * getParam() methods to this type. Added corresponding getStatusString()
1128  * method to convert status code to strings.
1129  *
1130  * Revision 1.4 1998/12/02 15:19:49 joergr
1131  * Added methods to convert parameters to signed/unsigned integers and
1132  * floats. Changed return value of existing getParam() methods.
1133  *
1134  * Revision 1.3 1998/11/30 12:30:18 joergr
1135  * Use lists of pointers (!) to internal data structures to avoid errors with
1136  * MSVC5 (operator '==' was not defined to compare structures).
1137  *
1138  * Revision 1.2 1998/11/30 12:27:02 joergr
1139  * Introduced additional type definition to avoid errors with MSVC5 when
1140  * using ListIterators of ListIterators (syntax problems?).
1141  *
1142  * Revision 1.1 1998/11/27 12:34:47 joergr
1143  * Added class to handle command line arguments.
1144  *
1145  *
1146  */
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..."
Definition: ofcmdln.h:87
static const int AF_Exclusive
exclusive option that overrides any other option (e.g. "--help")
Definition: ofcmdln.h:861
normal, no errors
Definition: ofcmdln.h:164
unknown option detected
Definition: ofcmdln.h:147
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
Definition: ofcmdln.h:963
E_ParamMode
mode specifying parameter's cardinality
Definition: ofcmdln.h:80
int ShortColumn
width of column for short option names
Definition: ofcmdln.h:961
exclusive option used
Definition: ofcmdln.h:145
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
normal, no errors
Definition: ofcmdln.h:183
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)
Definition: ofcmdln.h:971
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
Definition: ofcmdln.h:856
int MinParamCount
minimum number of parameters which should be accepted
Definition: ofcmdln.h:966
no more arguments to be converted
Definition: ofcmdln.h:168
converted value falls below minimum
Definition: ofcmdln.h:191
argument contains invalid char(s)
Definition: ofcmdln.h:166
const OFString ParamName
parameter name
Definition: ofcmdln.h:108
OFBool getCurrentOption(const char *&opt)
returns current option as a C string.
OFList< OFListIterator_OFString > OptionPosList
list of option positions within argument list
Definition: ofcmdln.h:944
normal, no errors
Definition: ofcmdln.h:141
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.
Definition: ofcmdln.h:956
void setOptionChars(const char *chars)
sets characters used to detect options
int getArgCount() const
gets number of command line arguments.
Definition: ofcmdln.h:373
Internal structure to store valid command line parameters.
Definition: ofcmdln.h:75
int getMaxParamCount() const
gets maximum number of parameters which should be accepted.
Definition: ofcmdln.h:434
const E_ParamMode ParamMode
parameter's cardinality mode
Definition: ofcmdln.h:112
find next option
Definition: ofcmdln.h:205
OFString OptionChars
C++ string conisting of all valid characters introducing an option.
Definition: ofcmdln.h:953
find first option
Definition: ofcmdln.h:203
no arguments to be parsed
Definition: ofcmdln.h:143
E_FindOptionMode
mode for findOption method
Definition: ofcmdln.h:198
find next option (from left to right)
Definition: ofcmdln.h:209
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
Definition: ofcmdln.h:138
OFCmdParam(const char *param, const char *descr, const E_ParamMode mode)
constructor
Definition: ofcmdln.h:98
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)
Definition: ofcmdln.h:854
OFList< OFCmdParam * > ValidParamList
list of valid/defined command line parameters
Definition: ofcmdln.h:934
converted value exceeds maximum
Definition: ofcmdln.h:174
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)
Definition: ofcmdln.h:185
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.
Definition: ofcmdln.h:363
OFBool findParam(const int pos)
checks whether specified parameter exists in the command line.
empty string argument
Definition: ofcmdln.h:170
too many parameters
Definition: ofcmdln.h:153
specified parameter doesn't exist
Definition: ofcmdln.h:187
parameter is required (# = 1), "option"
Definition: ofcmdln.h:83
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.
Definition: ofcmdln.h:866
cannot open command file
Definition: ofcmdln.h:155
missing value(s) for an option
Definition: ofcmdln.h:149
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.
Definition: ofcmdln.h:416
void storeParameter(const OFString &param, const int directOption=0)
stores the specified parameter in the argument/parameter list
OFBool getMissingParam(OFString &param)
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
Definition: ofcmdln.h:932
OFString ProgramName
program name, i.e. the value of argv[0]
Definition: ofcmdln.h:929
E_ValueStatus
status of converting string option value to value field
Definition: ofcmdln.h:161
static const int AF_Internal
internal option that is not shown in the syntax usage output
Definition: ofcmdln.h:863
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...
Definition: ofcmdln.h:445
int getMinParamCount() const
gets minimum number of parameters which should be accepted.
Definition: ofcmdln.h:425
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
Definition: ofcmdln.h:942
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.
Definition: ofstring.h:86
OFList< OFString > ArgumentList
list of command line arguments (after parsing)
Definition: ofcmdln.h:937
E_ParamValueStatus
status of converting string parameter to value field
Definition: ofcmdln.h:180
size_t size() const
returns number of elements in the list.
Definition: oflist.h:358
E_ParseStatus checkParamCount()
checks whether number of parameters in parsed command line is within the range of min/max (see below)...
void getParamString(OFString &paramStr) const
returns description of all parameters as a C++ string (multiple text lines).
find first option (from left to right)
Definition: ofcmdln.h:207
const OFCmdOption * findCmdOption(const OFString &option) const
finds specified option and returns reference to its describing structure
handles command line arguments.
Definition: ofcmdln.h:129
converted value exceeds maximum
Definition: ofcmdln.h:193
empty string argument
Definition: ofcmdln.h:189
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
Definition: ofcmdln.h:968
converted value falls below minimum
Definition: ofcmdln.h:172
parameter is optional (# = 0..1), "[option]"
Definition: ofcmdln.h:85
OFBool OptionBlockMode
OFTrue if option block is active, OFFalse otherwise.
Definition: ofcmdln.h:951
int LongColumn
width of column for long option names
Definition: ofcmdln.h:959
const OFString ParamDescription
parameter description
Definition: ofcmdln.h:110


Generated on Thu Aug 27 2015 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.9.1