OTB  6.7.0
Orfeo Toolbox
otbWrapperParameterKey.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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 
48  typedef ParameterKey Self;
49 
50  ParameterKey();
51  ParameterKey( const char * val );
52  ParameterKey( const std::string & val );
53  virtual ~ParameterKey();
54 
55 
57  /*
58 last() : return "tata"
59  ** parent() : return "toto.titi"
60  ** root() : return "toto"
61  ** split() : return vector<string> ("toto", "titi", "tata")
62  ** append(std::string)
63  ** append(const Key&)
64  */
65 
67  std::string GetLastElement();
68 
70  std::string GetFirstElement();
71 
73  std::string GetRoot();
74 
76  std::vector<std::string> Split();
77 
79  void Append( const std::string & val );
80 
82  void Append( const ParameterKey & pKey );
83 
85  std::string GetKey()
86  {
87  return m_Key;
88  }
89 
91  std::string GetKey() const
92  {
93  return m_Key;
94  }
95 
97  void SetKey( const std::string & val )
98  {
99  // Check chain : lowercase, alphanumerical or "."
100  itksys::RegularExpression reg;
101  reg.compile("([^0-9a-z\\.])");
103 
104  if(!reg.find(val))
105  {
106  m_Key = val;
107  }
108  else
109  {
110  itkGenericExceptionMacro( "Invalid key '"
111  << val <<
112  "'. Must be in lowercase, containing alphanumerical characters or \".\"");
113  }
114  }
115 
116 private:
117  ParameterKey(const Self&) = delete;
118  void operator=(const Self&) = delete;
119 
120  std::string m_Key;
121 
122 };
123 
124 } // end namespace Wrapper
125 } //end namespace otb
126 
127 #endif // otbWrapperParameterKey_h_
void SetKey(const std::string &val)