Medical Imaging Interaction Toolkit  2018.4.99-a3d2e8fb
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 
212  void addArgument(const std::string &longarg,
213  const std::string &shortarg,
214  Type type,
215  const std::string &argLabel,
216  const std::string &argHelp = std::string(),
217  const us::Any &defaultValue = us::Any(),
218  bool optional = true,
219  bool ignoreRest = false,
220  bool deprecated = false,
221  mitkCommandLineParser::Channel channel = mitkCommandLineParser::Channel::None);
222 
235  void addDeprecatedArgument(const std::string &longarg,
236  const std::string &shortarg,
237  const std::string &argLabel,
238  const std::string &argHelp);
239 
240 
245  std::vector < std::map<std::string, us::Any> > getArgumentList();
246 
261  bool setExactMatchRegularExpression(const std::string &argument,
262  const std::string &expression,
263  const std::string &exactMatchFailedMessage);
264 
270  std::string::size_type fieldWidth() const;
271 
280  std::string helpText() const;
281 
306  void setArgumentPrefix(const std::string &longPrefix, const std::string &shortPrefix);
307 
318  void beginGroup(const std::string &description);
319 
325  void endGroup();
326 
333  void setStrictModeEnabled(bool strictMode);
334 
338  void generateXmlOutput();
339 
345  void setTitle(std::string title);
351  void setContributor(std::string contributor);
357  void setCategory(std::string category);
363  void setDescription(std::string description);
373  void changeParameterGroup(std::string name, std::string tooltip);
374 
375 protected:
376  class ctkInternal;
377  ctkInternal *Internal;
378 
379  std::string Title;
380  std::string Contributor;
381  std::string Category;
382  std::string Description;
383  std::string ParameterGroupName;
385 };
386 
387 
388 
389 #endif
#define MITKCOMMANDLINE_EXPORT
class ITK_EXPORT Image
Definition: usAny.h:163
int Int
Definition: jsoncpp.h:158
std::vector< std::string > StringList
std::vector< std::string > StringContainerType