vtkCLIOptions.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkCLIOptions.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
41 #ifndef vtkCLIOptions_h
42 #define vtkCLIOptions_h
43 
44 #include "vtkObject.h"
45 #include "vtkPVVTKExtensionsCoreModule.h" // needed for export macro
46 
47 #include <memory> // for std::unique_ptr
48 #include <string> // for std::string
49 #include <vector> // for std::vector
50 #include <vtk_cli11_forward.h> // for CLI::App
51 
52 // forward declare CLI::App
53 namespace CLI
54 {
55 class App;
56 }
57 
59 {
60 public:
61  static vtkCLIOptions* New();
62  vtkTypeMacro(vtkCLIOptions, vtkObject);
63  void PrintSelf(ostream& os, vtkIndent indent) override;
64 
70  static vtkCLIOptions* New(const std::shared_ptr<CLI::App>& app);
71 
76  CLI::App* GetCLI11App() const;
77 
81  const char* GetHelp() const;
82 
84 
88  void SetName(const char* name);
89  const char* GetName() const;
91 
93 
96  void SetDescription(const char* desc);
97  const char* GetDescription() const;
99 
101 
109  void SetAllowExtras(bool val);
110  bool GetAllowExtras() const;
112 
114 
122  void SetStopOnUnrecognizedArgument(bool val);
123  bool GetStopOnUnrecognizedArgument() const;
125 
127 
133  vtkSetMacro(GenerateWarnings, bool);
134  vtkGetMacro(GenerateWarnings, bool);
135  vtkBooleanMacro(GenerateWarnings, bool);
137 
139 
153  vtkSetMacro(HandleLegacyArgumentFormats, bool);
154  vtkGetMacro(HandleLegacyArgumentFormats, bool);
155  vtkBooleanMacro(HandleLegacyArgumentFormats, bool);
157 
168  bool Parse(int& argc, char**& argv);
169 
171 
175  const std::vector<std::string>& GetExtraArguments() const { return this->ExtraArguments; }
177 
181  const std::string& GetLastErrorMessage() const { return this->LastErrorMessage; }
182 
186  vtkGetMacro(HelpRequested, bool);
187 
191  std::string GetUsage() const;
192 
193 protected:
194  vtkCLIOptions();
195  ~vtkCLIOptions() override;
196 
197 private:
198  vtkCLIOptions(const vtkCLIOptions&) = delete;
199  void operator=(const vtkCLIOptions&) = delete;
200 
201  class vtkInternals;
202  std::unique_ptr<vtkInternals> Internals;
203  bool HandleLegacyArgumentFormats = true;
204  bool GenerateWarnings = true;
205  std::vector<std::string> ExtraArguments;
206  std::string LastErrorMessage;
207  bool HelpRequested = false;
208  mutable std::string Help;
209  mutable std::string Description;
210 };
211 
212 #endif
#define VTKPVVTKEXTENSIONSCORE_EXPORT
command line options manager
Definition: vtkCLIOptions.h:58
const std::vector< std::string > & GetExtraArguments() const
Returns unparsed / extra arguments left over from the most reset Parse call.
const std::string & GetLastErrorMessage() const
Returns error message from the most recent call to Parse, if any.