Medical Imaging Interaction Toolkit  2023.12.99-1652ac8d
Medical Imaging Interaction Toolkit
mitkCommandLineParser.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkCommandLineParser_h
14 #define mitkCommandLineParser_h
15 
16 #include <map>
17 #include <usAny.h>
18 
19 #include <MitkCommandLineExports.h>
20 #include <mitkVersion.h>
21 
51 {
52 public:
53  enum Type
54  {
55  String = 0,
56  Bool = 1,
58  Int = 3,
59  Float = 4,
60  Directory = 5,
61  File = 6,
62  Image = 7
63  };
64 
65  enum Channel
66  {
67  None = 0,
68  Input = 1,
69  Output = 2
70  };
71 
72  typedef std::vector<std::string> StringContainerType;
73 
75 
77 
98  std::map<std::string, us::Any> parseArguments(const StringContainerType &arguments, bool *ok = nullptr);
99 
104  std::map<std::string, us::Any> parseArguments(int argc, char **argv, bool *ok = nullptr);
105 
113  std::string errorString() const;
114 
124  const StringContainerType &unparsedArguments() const;
125 
136  bool argumentAdded(const std::string &argument) const;
137 
146  bool argumentParsed(const std::string &argument) const;
147 
195  void addArgument(const std::string &longarg,
196  const std::string &shortarg,
197  Type type,
198  const std::string &argLabel,
199  const std::string &argHelp = std::string(),
200  const us::Any &defaultValue = us::Any(),
201  bool optional = true,
202  bool ignoreRest = false,
203  bool deprecated = false,
204  mitkCommandLineParser::Channel channel = mitkCommandLineParser::Channel::None);
205 
219  void addDeprecatedArgument(const std::string &longarg,
220  const std::string &shortarg,
221  const std::string &argLabel,
222  const std::string &argHelp);
223 
224 
229  std::vector < std::map<std::string, us::Any> > getArgumentList();
230 
245  bool setExactMatchRegularExpression(const std::string &argument,
246  const std::string &expression,
247  const std::string &exactMatchFailedMessage);
248 
254  std::string::size_type fieldWidth() const;
255 
263  std::string helpText() const;
264 
289  void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix);
290 
301  void beginGroup(const std::string &description);
302 
308  void endGroup();
309 
316  void setStrictModeEnabled(bool strictMode);
317 
321  void generateXmlOutput();
322 
328  void setTitle(std::string title);
334  void setContributor(std::string contributor);
340  void setCategory(std::string category);
346  void setDescription(std::string description);
356  void changeParameterGroup(std::string name, std::string tooltip);
357 
358 protected:
359  class ctkInternal;
360  ctkInternal *Internal;
361 
362  std::string Title;
363  std::string Contributor;
364  std::string Category;
365  std::string Description;
366  std::string ParameterGroupName;
368 };
369 
370 
371 
372 #endif
mitkCommandLineParser::Contributor
std::string Contributor
Definition: mitkCommandLineParser.h:363
usAny.h
mitkCommandLineParser::Type
Type
Definition: mitkCommandLineParser.h:53
mitkVersion.h
mitkCommandLineParser::Internal
ctkInternal * Internal
Definition: mitkCommandLineParser.h:359
mitkCommandLineParser::StringContainerType
std::vector< std::string > StringContainerType
Definition: mitkCommandLineParser.h:72
us::Any
Definition: usAny.h:163
mitkCommandLineParser::Title
std::string Title
Definition: mitkCommandLineParser.h:362
mitkCommandLineParser::Category
std::string Category
Definition: mitkCommandLineParser.h:364
MitkCommandLineExports.h
mitkCommandLineParser::Description
std::string Description
Definition: mitkCommandLineParser.h:365
mitkCommandLineParser::ParameterGroupDescription
std::string ParameterGroupDescription
Definition: mitkCommandLineParser.h:367
mitkCommandLineParser::ParameterGroupName
std::string ParameterGroupName
Definition: mitkCommandLineParser.h:366
mitkCommandLineParser
Definition: mitkCommandLineParser.h:50
MITKCOMMANDLINE_EXPORT
#define MITKCOMMANDLINE_EXPORT
Definition: MitkCommandLineExports.h:15
itk::Image
class ITK_EXPORT Image
Definition: mitkGeometryClipImageFilter.h:25
mitkCommandLineParser::Channel
Channel
Definition: mitkCommandLineParser.h:65
mitk::StringList
std::vector< std::string > StringList
Definition: mitkDICOMEnums.h:22