GDAL

- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

cpl_minixml.h
Go to the documentation of this file.
1 /**********************************************************************
2 * $Id: cpl_minixml.h 33666 2016-03-07 05:21:07Z goatbar $
3 *
4 * Project: CPL - Common Portability Library
5 * Purpose: Declarations for MiniXML Handler.
6 * Author: Frank Warmerdam, warmerdam@pobox.com
7 *
8 **********************************************************************
9 * Copyright (c) 2001, Frank Warmerdam
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
28 ****************************************************************************/
29
30 #ifndef CPL_MINIXML_H_INCLUDED
31 #define CPL_MINIXML_H_INCLUDED
32
33 #include "cpl_port.h"
34
41 CPL_C_START
42
43 typedef enum
44 { CXT_Element = 0, CXT_Text = 1, CXT_Attribute = 2, CXT_Comment = 3, CXT_Literal = 4
50 } CPLXMLNodeType;
51
65 typedef struct CPLXMLNode
66 {
73 CPLXMLNodeType eType;
74
96 char *pszValue;
97
105 struct CPLXMLNode *psNext;
106
117 struct CPLXMLNode *psChild;
118 } CPLXMLNode;
119
120
121 CPLXMLNode CPL_DLL *CPLParseXMLString( const char * );
122 void CPL_DLL CPLDestroyXMLNode( CPLXMLNode * );
123 CPLXMLNode CPL_DLL *CPLGetXMLNode( CPLXMLNode *poRoot,
124 const char *pszPath );
125 CPLXMLNode CPL_DLL *CPLSearchXMLNode( CPLXMLNode *poRoot,
126 const char *pszTarget );
127 const char CPL_DLL *CPLGetXMLValue( CPLXMLNode *poRoot,
128 const char *pszPath,
129 const char *pszDefault );
130 CPLXMLNode CPL_DLL *CPLCreateXMLNode( CPLXMLNode *poParent,
131 CPLXMLNodeType eType,
132 const char *pszText );
133 char CPL_DLL *CPLSerializeXMLTree( const CPLXMLNode *psNode );
134 void CPL_DLL CPLAddXMLChild( CPLXMLNode *psParent,
135 CPLXMLNode *psChild );
136 int CPL_DLL CPLRemoveXMLChild( CPLXMLNode *psParent,
137 CPLXMLNode *psChild );
138 void CPL_DLL CPLAddXMLSibling( CPLXMLNode *psOlderSibling,
139 CPLXMLNode *psNewSibling );
140 CPLXMLNode CPL_DLL *CPLCreateXMLElementAndValue( CPLXMLNode *psParent,
141 const char *pszName,
142 const char *pszValue );
143 void CPL_DLL CPLAddXMLAttributeAndValue( CPLXMLNode *psParent,
144 const char *pszName,
145 const char *pszValue );
146 CPLXMLNode CPL_DLL *CPLCloneXMLTree( CPLXMLNode *psTree );
147 int CPL_DLL CPLSetXMLValue( CPLXMLNode *psRoot, const char *pszPath,
148 const char *pszValue );
149 void CPL_DLL CPLStripXMLNamespace( CPLXMLNode *psRoot,
150 const char *pszNameSpace,
151 int bRecurse );
152 void CPL_DLL CPLCleanXMLElementName( char * );
153
154 CPLXMLNode CPL_DLL *CPLParseXMLFile( const char *pszFilename );
155 int CPL_DLL CPLSerializeXMLTreeToFile( const CPLXMLNode *psTree,
156 const char *pszFilename );
157
158 CPL_C_END
159
160 #ifdef __cplusplus
161 // Manage a tree of XML nodes so that all nodes are freed when the instance goes
162 // out of scope. Only the top level node should be in a CPLXMLTreeCloser.
163 class CPLXMLTreeCloser {
164 public:
165 explicit CPLXMLTreeCloser(CPLXMLNode* data) { the_data_ = data; }
166
167 ~CPLXMLTreeCloser() {
168 if (the_data_) CPLDestroyXMLNode(the_data_);
169 }
170
171 // Modifying the contents pointed to by the return is allowed.
172 CPLXMLNode* get() const { return the_data_; }
173
174 CPLXMLNode* operator->() const { return get(); }
175
176 private:
177 CPLXMLNode* the_data_;
178 };
179 #endif /* __cplusplus */
180
181 #endif /* CPL_MINIXML_H_INCLUDED */
CPLCreateXMLNode
CPLXMLNode * CPLCreateXMLNode(CPLXMLNode *poParent, CPLXMLNodeType eType, const char *pszText)
Create an document tree item.
Definition: cpl_minixml.cpp:1191
CPLAddXMLAttributeAndValue
void CPLAddXMLAttributeAndValue(CPLXMLNode *psParent, const char *pszName, const char *pszValue)
Create an attribute and text value.
Definition: cpl_minixml.cpp:1783
CXT_Text
Definition: cpl_minixml.h:46
CPLParseXMLFile
CPLXMLNode * CPLParseXMLFile(const char *pszFilename)
Parse XML file into tree.
Definition: cpl_minixml.cpp:2021
CPLXMLNode
Document node structure.
Definition: cpl_minixml.h:65
CPLRemoveXMLChild
int CPLRemoveXMLChild(CPLXMLNode *psParent, CPLXMLNode *psChild)
Remove child node from parent.
Definition: cpl_minixml.cpp:1657
cpl_port.h
Core portability definitions for CPL.
CXT_Element
Definition: cpl_minixml.h:45
CPLAddXMLSibling
void CPLAddXMLSibling(CPLXMLNode *psOlderSibling, CPLXMLNode *psNewSibling)
Add new sibling.
Definition: cpl_minixml.cpp:1701
CPLSetXMLValue
int CPLSetXMLValue(CPLXMLNode *psRoot, const char *pszPath, const char *pszValue)
Set element value by path.
Definition: cpl_minixml.cpp:1862
CPLSearchXMLNode
CPLXMLNode * CPLSearchXMLNode(CPLXMLNode *poRoot, const char *pszTarget)
Search for a node in document.
Definition: cpl_minixml.cpp:1358
CPLStripXMLNamespace
void CPLStripXMLNamespace(CPLXMLNode *psRoot, const char *pszNameSpace, int bRecurse)
Strip indicated namespaces.
Definition: cpl_minixml.cpp:1954
CPLSerializeXMLTree
char * CPLSerializeXMLTree(const CPLXMLNode *psNode)
Convert tree into string document.
Definition: cpl_minixml.cpp:1145
CPLAddXMLChild
void CPLAddXMLChild(CPLXMLNode *psParent, CPLXMLNode *psChild)
Add child node to parent.
Definition: cpl_minixml.cpp:1601
CPLXMLNode::eType
CPLXMLNodeType eType
Node type.
Definition: cpl_minixml.h:73
CPLXMLNode
struct CPLXMLNode CPLXMLNode
Document node structure.
CPLParseXMLString
CPLXMLNode * CPLParseXMLString(const char *)
Parse an XML string into tree form.
Definition: cpl_minixml.cpp:587
CXT_Literal
Definition: cpl_minixml.h:49
CPLSerializeXMLTreeToFile
int CPLSerializeXMLTreeToFile(const CPLXMLNode *psTree, const char *pszFilename)
Write document tree to a file.
Definition: cpl_minixml.cpp:2059
CXT_Attribute
Definition: cpl_minixml.h:47
CPLXMLTreeCloser
Definition: cpl_minixml.h:163
CPLDestroyXMLNode
void CPLDestroyXMLNode(CPLXMLNode *)
Destroy a tree.
Definition: cpl_minixml.cpp:1302
CPLCloneXMLTree
CPLXMLNode * CPLCloneXMLTree(CPLXMLNode *psTree)
Copy tree.
Definition: cpl_minixml.cpp:1807
CPLXMLNode::psNext
struct CPLXMLNode * psNext
Next sibling.
Definition: cpl_minixml.h:105
CPLXMLNodeType
CPLXMLNodeType
Definition: cpl_minixml.h:43
CPLGetXMLValue
const char * CPLGetXMLValue(CPLXMLNode *poRoot, const char *pszPath, const char *pszDefault)
Fetch element/attribute value.
Definition: cpl_minixml.cpp:1539
CXT_Comment
Definition: cpl_minixml.h:48
CPLCleanXMLElementName
void CPLCleanXMLElementName(char *)
Make string into safe XML token.
Definition: cpl_minixml.cpp:2129
CPLGetXMLNode
CPLXMLNode * CPLGetXMLNode(CPLXMLNode *poRoot, const char *pszPath)
Find node by path.
Definition: cpl_minixml.cpp:1447
CPLXMLNode::pszValue
char * pszValue
Node value.
Definition: cpl_minixml.h:96
CPLXMLNode::psChild
struct CPLXMLNode * psChild
Child node.
Definition: cpl_minixml.h:117
CPLCreateXMLElementAndValue
CPLXMLNode * CPLCreateXMLElementAndValue(CPLXMLNode *psParent, const char *pszName, const char *pszValue)
Create an element and text value.
Definition: cpl_minixml.cpp:1744

Generated for GDAL by 1.8.8.