GDAL
cpl_minixml.h
Go to the documentation of this file.
1/**********************************************************************
2 *
3 * Project: CPL - Common Portability Library
4 * Purpose: Declarations for MiniXML Handler.
5 * Author: Frank Warmerdam, warmerdam@pobox.com
6 *
7 **********************************************************************
8 * Copyright (c) 2001, Frank Warmerdam
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef CPL_MINIXML_H_INCLUDED
14#define CPL_MINIXML_H_INCLUDED
15
16#include "cpl_port.h"
17
23
25
27typedef enum
35
37typedef struct CPLXMLNode CPLXMLNode;
38
40
54{
62
84 char *pszValue;
85
94
104
106};
107
108CPLXMLNode CPL_DLL *CPLParseXMLString(const char *);
109void CPL_DLL CPLDestroyXMLNode(CPLXMLNode *);
110CPLXMLNode CPL_DLL *CPLGetXMLNode(CPLXMLNode *poRoot, const char *pszPath);
111#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
113extern "C++"
114{
115 inline const CPLXMLNode *CPLGetXMLNode(const CPLXMLNode *poRoot,
116 const char *pszPath)
117 {
118 return const_cast<const CPLXMLNode *>(
119 CPLGetXMLNode(const_cast<CPLXMLNode *>(poRoot), pszPath));
120 }
121}
123#endif
124CPLXMLNode CPL_DLL *CPLSearchXMLNode(CPLXMLNode *poRoot, const char *pszTarget);
125#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
127extern "C++"
128{
129 inline const CPLXMLNode *CPLSearchXMLNode(const CPLXMLNode *poRoot,
130 const char *pszTarget)
131 {
132 return const_cast<const CPLXMLNode *>(
133 CPLSearchXMLNode(const_cast<CPLXMLNode *>(poRoot), pszTarget));
134 }
135}
137#endif
138const char CPL_DLL *CPLGetXMLValue(const CPLXMLNode *poRoot,
139 const char *pszPath, const char *pszDefault);
140CPLXMLNode CPL_DLL *CPLCreateXMLNode(CPLXMLNode *poParent, CPLXMLNodeType eType,
141 const char *pszText);
142char CPL_DLL *CPLSerializeXMLTree(const CPLXMLNode *psNode);
143void CPL_DLL CPLAddXMLChild(CPLXMLNode *psParent, CPLXMLNode *psChild);
144int CPL_DLL CPLRemoveXMLChild(CPLXMLNode *psParent, CPLXMLNode *psChild);
145void CPL_DLL CPLAddXMLSibling(CPLXMLNode *psOlderSibling,
146 CPLXMLNode *psNewSibling);
147CPLXMLNode CPL_DLL *CPLCreateXMLElementAndValue(CPLXMLNode *psParent,
148 const char *pszName,
149 const char *pszValue);
150void CPL_DLL CPLAddXMLAttributeAndValue(CPLXMLNode *psParent,
151 const char *pszName,
152 const char *pszValue);
153CPLXMLNode CPL_DLL *CPLCloneXMLTree(const CPLXMLNode *psTree);
154int CPL_DLL CPLSetXMLValue(CPLXMLNode *psRoot, const char *pszPath,
155 const char *pszValue);
156void CPL_DLL CPLStripXMLNamespace(CPLXMLNode *psRoot, const char *pszNameSpace,
157 int bRecurse);
158void CPL_DLL CPLCleanXMLElementName(char *);
159
160CPLXMLNode CPL_DLL *CPLParseXMLFile(const char *pszFilename);
161int CPL_DLL CPLSerializeXMLTreeToFile(const CPLXMLNode *psTree,
162 const char *pszFilename);
163
164size_t CPL_DLL CPLXMLNodeGetRAMUsageEstimate(const CPLXMLNode *psNode);
165
167
168#if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
169
170extern "C++"
171{
172#ifndef DOXYGEN_SKIP
173#include <memory>
174#endif
175
177 struct CPL_DLL CPLXMLTreeCloserDeleter
178 {
179 void operator()(CPLXMLNode *psNode) const
180 {
181 CPLDestroyXMLNode(psNode);
182 }
183 };
184
186
191 class CPL_DLL CPLXMLTreeCloser
192 : public std::unique_ptr<CPLXMLNode, CPLXMLTreeCloserDeleter>
193 {
194 public:
197 : std::unique_ptr<CPLXMLNode, CPLXMLTreeCloserDeleter>(data)
198 {
199 }
200
203 CPLXMLNode *getDocumentElement();
204 };
205
206} // extern "C++"
207
208#endif /* __cplusplus */
209
210#endif /* CPL_MINIXML_H_INCLUDED */
CPLXMLTreeCloser(CPLXMLNode *data)
Constructor.
Definition cpl_minixml.h:196
CPLXMLNodeType
XML node type.
Definition cpl_minixml.h:28
@ CXT_Literal
Definition cpl_minixml.h:33
@ CXT_Element
Definition cpl_minixml.h:29
@ CXT_Comment
Definition cpl_minixml.h:32
@ CXT_Text
Definition cpl_minixml.h:30
@ CXT_Attribute
Definition cpl_minixml.h:31
Core portability definitions for CPL.
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:279
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:275
Document node structure.
Definition cpl_minixml.h:54
struct CPLXMLNode * psChild
Child node.
Definition cpl_minixml.h:105
CPLXMLNodeType eType
Node type.
Definition cpl_minixml.h:61
struct CPLXMLNode * psNext
Next sibling.
Definition cpl_minixml.h:93
char * pszValue
Node value.
Definition cpl_minixml.h:84