OTB  9.0.0
Orfeo Toolbox
otbWrapperParameterKey.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 otbWrapperParameterKey_h
22 #define otbWrapperParameterKey_h
23 
24 #include <string>
25 #include <vector>
26 #include <ostream>
27 #include <itksys/RegularExpression.hxx>
28 #include "itkMacro.h"
29 #include "OTBApplicationEngineExport.h"
30 
31 namespace otb
32 {
33 namespace Wrapper
34 {
35 
44 class OTBApplicationEngine_EXPORT ParameterKey
45 {
46 public:
47  typedef ParameterKey Self;
48 
49  ParameterKey();
50  ParameterKey(const char* val);
51  ParameterKey(const std::string& val);
52  virtual ~ParameterKey();
53 
54 
56  /*
57 last() : return "tata"
58  ** parent() : return "toto.titi"
59  ** root() : return "toto"
60  ** split() : return vector<string> ("toto", "titi", "tata")
61  ** append(std::string)
62  ** append(const Key&)
63  */
64 
66  std::string GetLastElement();
67 
69  std::string GetFirstElement();
70 
72  std::string GetRoot();
73 
75  std::vector<std::string> Split();
76 
78  void Append(const std::string& val);
79 
81  void Append(const ParameterKey& pKey);
82 
84  std::string GetKey()
85  {
86  return m_Key;
87  }
88 
90  std::string GetKey() const
91  {
92  return m_Key;
93  }
94 
96  void SetKey(const std::string& val)
97  {
98  // Check chain : lowercase, alphanumerical or "."
99  itksys::RegularExpression reg;
100  reg.compile("([^0-9a-z\\.])");
102 
103  if (!reg.find(val))
104  {
105  m_Key = val;
106  }
107  else
108  {
109  itkGenericExceptionMacro("Invalid key '" << val << "'. Must be in lowercase, containing alphanumerical characters or \".\"");
110  }
111  }
112 
113 private:
114  ParameterKey(const Self&) = delete;
115  void operator=(const Self&) = delete;
116 
117  std::string m_Key;
118 };
119 
120 } // end namespace Wrapper
121 } // end namespace otb
122 
123 #endif // otbWrapperParameterKey_h_
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Wrapper::ParameterKey::m_Key
std::string m_Key
Definition: otbWrapperParameterKey.h:117
otb::Wrapper::ParameterKey::GetKey
std::string GetKey() const
Definition: otbWrapperParameterKey.h:90
otb::Wrapper::ParameterKey::Self
ParameterKey Self
Definition: otbWrapperParameterKey.h:47
otb::Wrapper::ParameterKey::GetKey
std::string GetKey()
Definition: otbWrapperParameterKey.h:84
otb::Wrapper::ParameterKey
Definition: otbWrapperParameterKey.h:44
otb::Wrapper::ParameterKey::SetKey
void SetKey(const std::string &val)
Definition: otbWrapperParameterKey.h:96