OTB  9.0.0
Orfeo Toolbox
otbExtendedFilenameHelper.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 otbExtendedFilenameHelper_h
22 #define otbExtendedFilenameHelper_h
23 
24 #include <map>
25 #include <vector>
26 
27 #include "itkObject.h"
28 #include "itkObjectFactory.h"
29 #include "OTBCommonExport.h"
30 #include <string>
31 
32 namespace otb
33 {
34 
44 class OTBCommon_EXPORT ExtendedFilenameHelper : public itk::Object
45 {
46 public:
49  typedef itk::SmartPointer<Self> Pointer;
50  typedef itk::SmartPointer<const Self> ConstPointer;
51  typedef itk::Object Superclass;
52 
53  itkTypeMacro(ExtendedFilenameHelper, itk::Object);
54  itkNewMacro(Self);
55 
56  typedef std::map<std::string, std::string> OptionMapType;
57 
59  virtual void SetExtendedFileName(const char* extFname);
60 
61  virtual void SetExtendedFileName(const std::string& extFname);
62 
63  const OptionMapType& GetOptionMap(void) const;
64 
65  itkGetStringMacro(ExtendedFileName);
66  itkGetStringMacro(SimpleFileName);
67 
68  struct OTBCommon_EXPORT GenericBandRange : std::pair<int, int>
69  {
71  {
72  }
73 
74  GenericBandRange(int a);
75 
76  GenericBandRange(const std::pair<int, int>& a);
77 
78  GenericBandRange(int a, int b);
79 
80  bool SetString(const std::string& str, size_t start = 0, size_t size = std::string::npos);
81 
82  void Print(std::ostream& os);
83  };
84 
87  std::vector<ExtendedFilenameHelper::GenericBandRange> GetGenericBandRange(const std::string& bandRange) const;
88 
92  bool ResolveBandRange(const std::string& bandRange, const unsigned int& nbBands, std::vector<unsigned int>& output) const;
93 
94 protected:
96  {
97  }
99  {
100  }
101 
102 private:
103  ExtendedFilenameHelper(const Self&) = delete;
104  void operator=(const Self&) = delete;
105  itkSetStringMacro(SimpleFileName);
106 
107  std::string m_ExtendedFileName;
108  std::string m_SimpleFileName;
110 };
111 } // end namespace otb
112 
113 #endif // otbExtendedFilenameHelper_h
otb::ExtendedFilenameHelper::GenericBandRange
Definition: otbExtendedFilenameHelper.h:68
otb::ExtendedFilenameHelper::m_OptionMap
OptionMapType m_OptionMap
Definition: otbExtendedFilenameHelper.h:109
otb::ExtendedFilenameHelper::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbExtendedFilenameHelper.h:50
otb::ExtendedFilenameHelper::GenericBandRange::GenericBandRange
GenericBandRange()
Definition: otbExtendedFilenameHelper.h:70
otb::ExtendedFilenameHelper::Self
ExtendedFilenameHelper Self
Definition: otbExtendedFilenameHelper.h:48
otb::ExtendedFilenameHelper::~ExtendedFilenameHelper
~ExtendedFilenameHelper() override
Definition: otbExtendedFilenameHelper.h:98
otb::ExtendedFilenameHelper::m_SimpleFileName
std::string m_SimpleFileName
Definition: otbExtendedFilenameHelper.h:108
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ExtendedFilenameHelper::ExtendedFilenameHelper
ExtendedFilenameHelper()
Definition: otbExtendedFilenameHelper.h:95
otb::ExtendedFilenameHelper::Superclass
itk::Object Superclass
Definition: otbExtendedFilenameHelper.h:51
otb::ExtendedFilenameHelper
Helper to handle extended filenames.
Definition: otbExtendedFilenameHelper.h:44
otb::ExtendedFilenameHelper::OptionMapType
std::map< std::string, std::string > OptionMapType
Definition: otbExtendedFilenameHelper.h:54
otb::ExtendedFilenameHelper::m_ExtendedFileName
std::string m_ExtendedFileName
Definition: otbExtendedFilenameHelper.h:105
otb::ExtendedFilenameHelper::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbExtendedFilenameHelper.h:49
otb::Wrapper::MetaDataHelper::SetString
OTBApplicationEngine_EXPORT void SetString(itk::MetaDataDictionary &dict, const std::string &key, const std::string &val)