Medical Imaging Interaction Toolkit  2025.12.02
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 
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 
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
#define MITKCOMMANDLINE_EXPORT
bool argumentParsed(const std::string &argument) const
void addArgument(const std::string &longarg, const std::string &shortarg, Type type, const std::string &argLabel, const std::string &argHelp=std::string(), const us::Any &defaultValue=us::Any(), bool optional=true, bool ignoreRest=false, bool deprecated=false, mitkCommandLineParser::Channel channel=mitkCommandLineParser::Channel::None)
std::string helpText() const
std::vector< std::map< std::string, us::Any > > getArgumentList()
void setDescription(std::string description)
void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix)
const StringContainerType & unparsedArguments() const
void setContributor(std::string contributor)
std::string errorString() const
bool setExactMatchRegularExpression(const std::string &argument, const std::string &expression, const std::string &exactMatchFailedMessage)
void setCategory(std::string category)
std::string::size_type fieldWidth() const
void changeParameterGroup(std::string name, std::string tooltip)
void setTitle(std::string title)
bool argumentAdded(const std::string &argument) const
void addDeprecatedArgument(const std::string &longarg, const std::string &shortarg, const std::string &argLabel, const std::string &argHelp)
void beginGroup(const std::string &description)
std::vector< std::string > StringContainerType
std::map< std::string, us::Any > parseArguments(int argc, char **argv, bool *ok=nullptr)
void setStrictModeEnabled(bool strictMode)
std::map< std::string, us::Any > parseArguments(const StringContainerType &arguments, bool *ok=nullptr)
Definition: usAny.h:164
class ITK_EXPORT Image
std::vector< std::string > StringList