OTB  9.0.0
Orfeo Toolbox
Public Member Functions | List of all members
otb::XMLMetadataSupplier Class Reference

#include <otbXMLMetadataSupplier.h>

+ Inheritance diagram for otb::XMLMetadataSupplier:
+ Collaboration diagram for otb::XMLMetadataSupplier:

Public Member Functions

std::string GetFirstMetadataValue (std::string const &paths, bool &hasValue) const
 
std::string GetMetadataValue (std::string const &path, bool &hasValue, int band=1) const override
 
XMLMetadataSupplieroperator= (const XMLMetadataSupplier &)=delete
 
 XMLMetadataSupplier (const std::string &)
 
 XMLMetadataSupplier (const XMLMetadataSupplier &)=delete
 
- Public Member Functions inherited from otb::MetadataSupplierInterface
template<>
bool GetAs (bool const &defaultValue, std::string const &path, int band) const
 
template<typename T >
GetAs (std::string const &path, int band=-1) const
 
template<typename T >
GetAs (T const &defaultValue, std::string const &path, int band=-1) const
 
template<typename T >
std::vector< T > GetAsVector (std::string const &path, char sep=' ', int size=-1, int band=-1) const
 
virtual std::vector< std::string > GetResourceFiles () const
 
bool HasValue (std::string const &path, int band=-1) const
 
virtual ~MetadataSupplierInterface ()=default
 
std::string m_FileName
 
char ** m_MetadataDic = nullptr
 
template<typename T >
GetFirstAs (std::string const &path) const
 
std::string GetResourceFile (std::string const &s="") const override
 
int GetNbBands () const override
 
unsigned int GetNumberOf (std::string const &path) const override
 
unsigned int GetAttributId (std::string const &path, std::string const &value) const override
 
std::string PrintSelf () const
 
 ~XMLMetadataSupplier ()=default
 
virtual char ** ReadXMLToList (CPLXMLNode *psNode, char **papszList, const char *pszName="")
 
std::vector< std::string > FetchPartialNameValueMultiple (char **papszStrList, const char *pszName) const
 
std::vector< std::string > FetchPartialNameValueMultiple (const std::vector< std::string > &StringVector, const std::string &Name) const
 
std::vector< std::string > GetAllStartWith (char **papszStrList, const char *pszName) const
 

Additional Inherited Members

- Public Attributes inherited from otb::MetadataSupplierInterface
const std::array< std::string, 3 > FALSES = {"0", "false", "False"}
 
const std::array< std::string, 3 > TRUES = {"1", "true", "True"}
 

Detailed Description

Class to access metadata information in a XML file.

Definition at line 41 of file otbXMLMetadataSupplier.h.

Constructor & Destructor Documentation

◆ XMLMetadataSupplier() [1/2]

otb::XMLMetadataSupplier::XMLMetadataSupplier ( const std::string &  )

◆ XMLMetadataSupplier() [2/2]

otb::XMLMetadataSupplier::XMLMetadataSupplier ( const XMLMetadataSupplier )
delete

◆ ~XMLMetadataSupplier()

otb::XMLMetadataSupplier::~XMLMetadataSupplier ( )
default

List of resource files

Member Function Documentation

◆ FetchPartialNameValueMultiple() [1/2]

std::vector<std::string> otb::XMLMetadataSupplier::FetchPartialNameValueMultiple ( char **  papszStrList,
const char *  pszName 
) const
protected

In a StringList of “Name=Value” pairs, look for the values associated with a name containing the specified string.

Parameters
papszStrListA StringList that will be searched
pszNameA string that will be looked for in the keys
Returns
A StringList containing only the pairs from papszStrList whose key contain pszName

◆ FetchPartialNameValueMultiple() [2/2]

std::vector<std::string> otb::XMLMetadataSupplier::FetchPartialNameValueMultiple ( const std::vector< std::string > &  StringVector,
const std::string &  Name 
) const
protected

In a StringList of “Name=Value” pairs, look for the values associated with a name containing the specified string.

Parameters
StringVectorA std::vector of std::string that will be searched
NameA std::string that will be looked for in the keys
Returns
A std::vector of std::string containing only the pairs from StringVector whose key contain Name

◆ GetAllStartWith()

std::vector<std::string> otb::XMLMetadataSupplier::GetAllStartWith ( char **  papszStrList,
const char *  pszName 
) const
protected

In a StringList of “Name=Value” pairs, look for the keys equal to the specified string.

Parameters
papszStrListA StringList that will be searched
pszNameA string that will be looked for at the beginning of the keys
Returns
A StringList containing only the pairs from papszStrList whose key start with pszName

◆ GetAttributId()

unsigned int otb::XMLMetadataSupplier::GetAttributId ( std::string const &  path,
std::string const &  value 
) const
overridevirtual

If multiple keys have the same path, gives the position of the one with value value

Implements otb::MetadataSupplierInterface.

◆ GetFirstAs()

template<typename T >
T otb::XMLMetadataSupplier::GetFirstAs ( std::string const &  path) const
inline

Get the metadata value corresponding to a given path converted to the given type.

This method can look for a value in a list, using the _# jocker. For example, looking for "value" in a dictionary like this : foo_1.bar=42 foo_1.doo=99 foo_2.value=8 One can specify this path : foo_#.value, the method will then return 8.

Parameters
pathThe path to look for.
Returns
The value corresponding to path. @raises otb::Error if path not found

Definition at line 83 of file otbXMLMetadataSupplier.h.

References otbGenericExceptionMacro.

◆ GetFirstMetadataValue()

std::string otb::XMLMetadataSupplier::GetFirstMetadataValue ( std::string const &  paths,
bool &  hasValue 
) const

Get the first metadata value corresponding to a given path.

Parameters
pathThe path to look for
hasValueTrue if path is found
Returns
The value corresponding to path. Empty string if not found.

◆ GetMetadataValue()

std::string otb::XMLMetadataSupplier::GetMetadataValue ( std::string const &  path,
bool &  hasValue,
int  band = 1 
) const
overridevirtual

Get the metadata value corresponding to a given path.

Parameters
pathThe path to look for
hasValueTrue if path is found
bandnot used
Returns
The value corresponding to path. Empty string if not found.

Implements otb::MetadataSupplierInterface.

◆ GetNbBands()

int otb::XMLMetadataSupplier::GetNbBands ( ) const
overridevirtual

List of resource files

Implements otb::MetadataSupplierInterface.

◆ GetNumberOf()

unsigned int otb::XMLMetadataSupplier::GetNumberOf ( std::string const &  path) const
overridevirtual

Get the number of keys starting with path

Implements otb::MetadataSupplierInterface.

◆ GetResourceFile()

std::string otb::XMLMetadataSupplier::GetResourceFile ( std::string const &  s = "") const
overridevirtual

List of resource files

Implements otb::MetadataSupplierInterface.

◆ operator=()

XMLMetadataSupplier& otb::XMLMetadataSupplier::operator= ( const XMLMetadataSupplier )
delete

◆ PrintSelf()

std::string otb::XMLMetadataSupplier::PrintSelf ( ) const

Writes the content of the XML file into a string.

Returns
A std::string

◆ ReadXMLToList()

virtual char** otb::XMLMetadataSupplier::ReadXMLToList ( CPLXMLNode *  psNode,
char **  papszList,
const char *  pszName = "" 
)
protectedvirtual

ReadXMLToList Transform xml to list of NULL terminated name=value strings.

Parameters
psNodeA xml node to process
papszListA list to fill with name=value strings
pszNameA name of parent node. For root xml node should be empty. If name is not empty, the sibling nodes will not proceed
Returns
An input list filled with values

This method originates from a work by GDAL in the class GDALMDReaderBase.

Member Data Documentation

◆ m_FileName

std::string otb::XMLMetadataSupplier::m_FileName
private

List of resource files

Definition at line 169 of file otbXMLMetadataSupplier.h.

◆ m_MetadataDic

char** otb::XMLMetadataSupplier::m_MetadataDic = nullptr
private

Dictionary containing the metadata

Definition at line 172 of file otbXMLMetadataSupplier.h.


The documentation for this class was generated from the following file: