OTB  9.0.0
Orfeo Toolbox
otbWrapperCommandLineParser.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbWrapperCommandLineParser_h
22 #define otbWrapperCommandLineParser_h
23 
24 #include "itkObjectFactory.h"
25 #include <string>
26 
27 
28 namespace otb
29 {
30 namespace Wrapper
31 {
32 
43 class ITK_ABI_EXPORT CommandLineParser : public itk::Object
44 {
45 public:
48  typedef itk::Object Superclass;
49  typedef itk::SmartPointer<Self> Pointer;
50  typedef itk::SmartPointer<const Self> ConstPointer;
51 
53  itkNewMacro(Self);
54 
56  itkTypeMacro(CommandLineParser, itk::Object);
57 
59  typedef enum { OK, NOMODULENAME, MULTIPLEMODULENAME, INVALIDMODULENAME, NOMODULEPATH, INVALIDMODULEPATH, DEFAULT } ParseResultType;
60 
62  std::vector<std::string> GetAttribut(const std::string& key, const std::string& exp);
63  std::vector<std::string> GetAttribut(const std::string& key, const std::vector<std::string>& exp);
64 
66  std::string GetAttributAsString(const std::string& key, const std::string& exp);
67  std::string GetAttributAsString(const std::string& key, const std::vector<std::string>& exp);
68 
70  bool IsAttributExists(const std::string &key, const std::string& exp);
71  bool IsAttributExists(const std::string &key, const std::vector<std::string>& exp);
73 
75  CommandLineParser::ParseResultType GetPaths(std::vector<std::string>& paths, const std::string& exp);
76  CommandLineParser::ParseResultType GetPaths(std::vector<std::string>& paths, const std::vector<std::string>& exp);
78 
80  std::string GetPathsAsString(const std::string& exp);
81  std::string GetPathsAsString(const std::vector<std::string>& vexp);
83 
84 
87  CommandLineParser::ParseResultType GetModuleName(std::string& modName, const std::string& exp);
88  CommandLineParser::ParseResultType GetModuleName(std::string& modName, const std::vector<std::string>& exp);
90 
92  std::vector<std::string> GetKeyList(const std::string& exp);
93  std::vector<std::string> GetKeyList(const std::vector<std::string>& exp);
95 
96 protected:
99 
101  ~CommandLineParser() override;
102 
103 private:
104  CommandLineParser(const CommandLineParser&) = delete;
105  void operator=(const CommandLineParser&) = delete;
106 
107 
109  bool IsAValidKey(const std::string& foundKey);
110 
111 
112 }; // end class
113 
114 } // end namespace Wrapper
115 } // end namespace otb
116 
117 #endif // otbWrapperCommandLineParser_h_
otb::Wrapper::CommandLineParser
This class check the validity of a command line application.
Definition: otbWrapperCommandLineParser.h:43
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Wrapper::CommandLineParser::ParseResultType
ParseResultType
Definition: otbWrapperCommandLineParser.h:59
otb::Wrapper::CommandLineParser::Self
CommandLineParser Self
Definition: otbWrapperCommandLineParser.h:47
otb::Wrapper::CommandLineParser::Superclass
itk::Object Superclass
Definition: otbWrapperCommandLineParser.h:48
otb::vexp
Definition: otbParserXPlugins.h:699
otb::Wrapper::CommandLineParser::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbWrapperCommandLineParser.h:50
otb::Wrapper::CommandLineParser::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbWrapperCommandLineParser.h:49