root/trunk/gdal/port/cpl_minixml.h

Revision 15686, 6.4 kB (checked in by rouault, 2 weeks ago)

Fix typo in documentation of psChild field of CPLXMLNode struct

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 /**********************************************************************
2  * $Id$
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
35 /**
36  * \file cpl_minixml.h
37  *
38  * Definitions for CPL mini XML Parser/Serializer.
39  */
40
41 CPL_C_START
42
43 typedef enum
44 {
45     /*! Node is an element */           CXT_Element = 0,
46     /*! Node is a raw text value */     CXT_Text = 1,
47     /*! Node is attribute */            CXT_Attribute = 2, 
48     /*! Node is an XML comment. */      CXT_Comment = 3,   
49     /*! Node is a special literal */    CXT_Literal = 4     
50 } CPLXMLNodeType;
51
52 /**
53  * Document node structure.
54  *
55  * This C structure is used to hold a single text fragment representing a
56  * component of the document when parsed.   It should be allocated with the
57  * appropriate CPL function, and freed with CPLDestroyXMLNode().  The structure
58  * contents should not normally be altered by application code, but may be
59  * freely examined by application code.
60  *
61  * Using the psChild and psNext pointers, a heirarchical tree structure
62  * for a document can be represented as a tree of CPLXMLNode structures.
63  */
64
65 typedef struct CPLXMLNode
66 {
67     /**
68      * \brief Node type
69      *
70      * One of CXT_Element, CXT_Text, CXT_Attribute, CXT_Comment,
71      * or CXT_Literal.
72      */
73     CPLXMLNodeType      eType;       
74    
75     /**
76      * \brief Node value
77      *
78      * For CXT_Element this is the name of the element, without the angle
79      * brackets.  Note there is a single CXT_Element even when the document
80      * contains a start and end element tag.  The node represents the pair.
81      * All text or other elements between the start and end tag will appear
82      * as children nodes of this CXT_Element node.
83      *
84      * For CXT_Attribute the pszValue is the attribute name.  The value of
85      * the attribute will be a CXT_Text child.
86      *
87      * For CXT_Text this is the text itself (value of an attribute, or a
88      * text fragment between an element start and end tags.
89      *
90      * For CXT_Literal it is all the literal text.  Currently this is just
91      * used for !DOCTYPE lines, and the value would be the entire line.
92      *
93      * For CXT_Comment the value is all the literal text within the comment,
94      * but not including the comment start/end indicators ("<--" and "-->").
95      */
96     char                *pszValue;   
97
98     /**
99      * \brief Next sibling.
100      *
101      * Pointer to next sibling, that is the next node appearing after this
102      * one that has the same parent as this node.  NULL if this node is the
103      * last child of the parent element.
104      */
105     struct CPLXMLNode  *psNext;     
106
107     /**
108      * \brief Child node.
109      *
110      * Pointer to first child node, if any.  Only CXT_Element and CXT_Attribute
111      * nodes should have children.  For CXT_Attribute it should be a single
112      * CXT_Text value node, while CXT_Element can have any kind of child.
113      * The full list of children for a node are identified by walking the
114      * psNext's starting with the psChild node.
115      */
116
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( 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 CPLXMLNode CPL_DLL *CPLCloneXMLTree( CPLXMLNode *psTree );
144 int        CPL_DLL CPLSetXMLValue( CPLXMLNode *psRoot,  const char *pszPath,
145                                    const char *pszValue );
146 void       CPL_DLL CPLStripXMLNamespace( CPLXMLNode *psRoot,
147                                          const char *pszNameSpace,
148                                          int bRecurse );
149 void       CPL_DLL CPLCleanXMLElementName( char * );
150
151 CPLXMLNode CPL_DLL *CPLParseXMLFile( const char *pszFilename );
152 int        CPL_DLL CPLSerializeXMLTreeToFile( CPLXMLNode *psTree,
153                                               const char *pszFilename );
154
155 CPL_C_END
156
157 #endif /* _CPL_MINIXML_H_INCLUDED */
Note: See TracBrowser for help on using the browser.