GDAL

gdal_multidomainmetadata.h
1/******************************************************************************
2 *
3 * Name: gdal_multidomainmetadata.h
4 * Project: GDAL Core
5 * Purpose: Declaration of GDALMultiDomainMetadata class
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 ******************************************************************************
9 * Copyright (c) 1998, Frank Warmerdam
10 * Copyright (c) 2007-2014, Even Rouault <even dot rouault at spatialys.com>
11 *
12 * SPDX-License-Identifier: MIT
13 ****************************************************************************/
14
15#ifndef GDALMULTIDOMAINMETADATA_H_INCLUDED
16#define GDALMULTIDOMAINMETADATA_H_INCLUDED
17
18#include "cpl_port.h"
19#include "cpl_string.h"
20
21#include <map>
22
24 typedef struct CPLXMLNode CPLXMLNode;
25
28/************************************************************************/
29/* GDALMultiDomainMetadata */
30/************************************************************************/
31
33 class CPL_DLL GDALMultiDomainMetadata
34{
35 private:
36 CPLStringList aosDomainList{};
37
38 struct Comparator
39 {
40 bool operator()(const char *a, const char *b) const
41 {
42 return STRCASECMP(a, b) < 0;
43 }
44 };
45
46 std::map<const char *, CPLStringList, Comparator> oMetadata{};
47
48 public:
49 GDALMultiDomainMetadata();
50
52 GDALMultiDomainMetadata(const GDALMultiDomainMetadata &) = default;
53
55 GDALMultiDomainMetadata &
56 operator=(const GDALMultiDomainMetadata &) = default;
57
59 GDALMultiDomainMetadata(GDALMultiDomainMetadata &&) = default;
60
62 GDALMultiDomainMetadata &operator=(GDALMultiDomainMetadata &&) = default;
63
64 ~GDALMultiDomainMetadata();
65
66 int XMLInit(const CPLXMLNode *psMetadata, int bMerge);
67 CPLXMLNode *Serialize() const;
68
69 CSLConstList GetDomainList() const
70 {
71 return aosDomainList.List();
72 }
73
74 char **GetMetadata(const char *pszDomain = "");
75 CPLErr SetMetadata(CSLConstList papszMetadata, const char *pszDomain = "");
76 const char *GetMetadataItem(const char *pszName,
77 const char *pszDomain = "");
78 CPLErr SetMetadataItem(const char *pszName, const char *pszValue,
79 const char *pszDomain = "");
80
81 void Clear();
82
83 inline void clear()
84 {
85 Clear();
86 }
87};
88
90
91#endif
CPLStringList
String list class designed around our use of C "char**" string lists.
Definition cpl_string.h:458
CPLErr
CPLErr
Error category.
Definition cpl_error.h:37
cpl_port.h
Core portability definitions for CPL.
STRCASECMP
#define STRCASECMP(a, b)
Alias for strcasecmp()
Definition cpl_port.h:534
CSLConstList
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1087
cpl_string.h
Various convenience functions for working with strings and string lists.
CPLXMLNode
Document node structure.
Definition cpl_minixml.h:54