OTB  7.1.0
Orfeo Toolbox
otbExtendedFilenameHelper.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 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;
109  OptionMapType m_OptionMap;
110 };
111 } // end namespace otb
112 
113 #endif // otbExtendedFilenameHelper_h
itk::SmartPointer< const Self > ConstPointer
itk::SmartPointer< Self > Pointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
OTBApplicationEngine_EXPORT void SetString(itk::MetaDataDictionary &dict, const std::string &key, const std::string &val)
std::map< std::string, std::string > OptionMapType
Helper to handle extended filenames.