Medical Imaging Interaction Toolkit  2021.10.00
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 
14  Library: CTK
15 
16  Copyright (c) Kitware Inc.
17 
18  Licensed under the Apache License, Version 2.0 (the "License");
19  you may not use this file except in compliance with the License.
20  You may obtain a copy of the License at
21 
22  http://www.apache.org/licenses/LICENSE-2.0.txt
23 
24  Unless required by applicable law or agreed to in writing, software
25  distributed under the License is distributed on an "AS IS" BASIS,
26  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27  See the License for the specific language governing permissions and
28  limitations under the License.
29 
30 =========================================================================*/
31 
32 #ifndef __mitkCommandLineParser_h
33 #define __mitkCommandLineParser_h
34 
35 #include <map>
36 #include <usAny.h>
37 
38 #include <MitkCommandLineExports.h>
39 #include <mitkVersion.h>
40 
70 {
71 public:
72  enum Type
73  {
74  String = 0,
75  Bool = 1,
77  Int = 3,
78  Float = 4,
79  Directory = 5,
80  File = 6,
81  Image = 7
82  };
83 
84  enum Channel
85  {
86  None = 0,
87  Input = 1,
88  Output = 2
89  };
90 
91  typedef std::vector<std::string> StringContainerType;
92 
94 
96 
117  std::map<std::string, us::Any> parseArguments(const StringContainerType &arguments, bool *ok = nullptr);
118 
123  std::map<std::string, us::Any> parseArguments(int argc, char **argv, bool *ok = nullptr);
124 
132  std::string errorString() const;
133 
143  const StringContainerType &unparsedArguments() const;
144 
155  bool argumentAdded(const std::string &argument) const;
156 
165  bool argumentParsed(const std::string &argument) const;
166 
214  void addArgument(const std::string &longarg,
215  const std::string &shortarg,
216  Type type,
217  const std::string &argLabel,
218  const std::string &argHelp = std::string(),
219  const us::Any &defaultValue = us::Any(),
220  bool optional = true,
221  bool ignoreRest = false,
222  bool deprecated = false,
223  mitkCommandLineParser::Channel channel = mitkCommandLineParser::Channel::None);
224 
238  void addDeprecatedArgument(const std::string &longarg,
239  const std::string &shortarg,
240  const std::string &argLabel,
241  const std::string &argHelp);
242 
243 
248  std::vector < std::map<std::string, us::Any> > getArgumentList();
249 
264  bool setExactMatchRegularExpression(const std::string &argument,
265  const std::string &expression,
266  const std::string &exactMatchFailedMessage);
267 
273  std::string::size_type fieldWidth() const;
274 
282  std::string helpText() const;
283 
308  void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix);
309 
320  void beginGroup(const std::string &description);
321 
327  void endGroup();
328 
335  void setStrictModeEnabled(bool strictMode);
336 
340  void generateXmlOutput();
341 
347  void setTitle(std::string title);
353  void setContributor(std::string contributor);
359  void setCategory(std::string category);
365  void setDescription(std::string description);
375  void changeParameterGroup(std::string name, std::string tooltip);
376 
377 protected:
378  class ctkInternal;
379  ctkInternal *Internal;
380 
381  std::string Title;
382  std::string Contributor;
383  std::string Category;
384  std::string Description;
385  std::string ParameterGroupName;
387 };
388 
389 
390 
391 #endif
#define MITKCOMMANDLINE_EXPORT
class ITK_EXPORT Image
Definition: usAny.h:163
std::vector< std::string > StringList
std::vector< std::string > StringContainerType