OTB  9.0.0
Orfeo Toolbox
otbMetadataStorageInterface.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 otbMetadataStorageInterface_h
22 #define otbMetadataStorageInterface_h
23 
24 #include "OTBMetadataExport.h"
25 #include "itkMacro.h"
26 #include <vector>
27 #include <string>
28 #include <sstream>
29 #include "otbStringUtils.h"
30 #include "otbMacro.h"
31 #include "otbStringUtilities.h"
32 #include "otbJoinContainer.h"
33 
34 namespace otb
35 {
36 
43 class OTBMetadata_EXPORT MetadataStorageInterface
44 {
45 public:
46 
49  virtual void SetMetadataValue(const char * path, const char * value, int band=-1) = 0;
50 
51  // TODO : check precision settings
52  void SetAs(const std::string & path, double value, int band=-1);
53 
54  void SetAs(const std::string & path, const std::string & value, int band=-1);
55 
57  template < typename T> void SetAsVector(const char *path, std::vector<T> value, const char sep=' ', int band=-1)
58  {
59  std::ostringstream oss;
60  oss << "[";
61  otb::Join(oss, value, std::string(&sep));
62  oss << "]";
63  SetMetadataValue(path, oss.str().c_str(), band);
64  }
65  template < typename T> void SetAsVector(const std::string& path, std::vector<T> value, const char sep=' ', int band=-1)
66  {
67  SetAsVector(path.c_str(), value, sep, band);
68  }
69 };
71 
72 
73 } // end namespace otb
74 
75 #endif
otbJoinContainer.h
otb::MetadataStorageInterface
Base class to store metadata information in files/images.
Definition: otbMetadataStorageInterface.h:43
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otbMacro.h
otbStringUtilities.h
otb::MetadataStorageInterface::SetAsVector
void SetAsVector(const std::string &path, std::vector< T > value, const char sep=' ', int band=-1)
Definition: otbMetadataStorageInterface.h:65
otbStringUtils.h
otb::MetadataStorageInterface::SetAsVector
void SetAsVector(const char *path, std::vector< T > value, const char sep=' ', int band=-1)
Definition: otbMetadataStorageInterface.h:57
otb::Join
std::ostream & Join(std::ostream &os, TRange const &range, std::string const &separator)
Definition: otbJoinContainer.h:47