1 /* Converted to D from C:/devLibs/gdal21/include/cpl_minixml.h by htod */
2 module gdal.cpl.minixml;
3 /**********************************************************************
4  * $Id: cpl_minixml.h 33666 2016-03-07 05:21:07Z goatbar $
5  *
6  * Project:  CPL - Common Portability Library
7  * Purpose:  Declarations for MiniXML Handler.
8  * Author:   Frank Warmerdam, warmerdam@pobox.com
9  *
10  **********************************************************************
11  * Copyright (c) 2001, Frank Warmerdam
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included
21  * in all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
26  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29  * DEALINGS IN THE SOFTWARE.
30  ****************************************************************************/
31 
32 import gdal.cpl.port;
33 
34 /**
35  * \file cpl_minixml.h
36  *
37  * Definitions for CPL mini XML Parser/Serializer.
38  */
39 enum
40 {
41     CXT_Element   = 0, /*! Node is an element        */
42     CXT_Text      = 1, /*! Node is a raw text value  */
43     CXT_Attribute = 2, /*! Node is attribute         */
44     CXT_Comment   = 3, /*! Node is an XML comment.   */
45     CXT_Literal   = 4, /*! Node is a special literal */
46 }
47 extern (C):
48 alias int CPLXMLNodeType;
49 
50 /**
51  * Document node structure.
52  *
53  * This C structure is used to hold a single text fragment representing a
54  * component of the document when parsed.   It should be allocated with the
55  * appropriate CPL function, and freed with CPLDestroyXMLNode().  The structure
56  * contents should not normally be altered by application code, but may be
57  * freely examined by application code.
58  *
59  * Using the psChild and psNext pointers, a hierarchical tree structure
60  * for a document can be represented as a tree of CPLXMLNode structures.
61  */
62 struct CPLXMLNode
63 {
64     /**
65      * \brief Node type
66      *
67      * One of CXT_Element, CXT_Text, CXT_Attribute, CXT_Comment,
68      * or CXT_Literal.
69      */
70     CPLXMLNodeType eType;
71 
72     /**
73      * \brief Node value
74      *
75      * For CXT_Element this is the name of the element, without the angle
76      * brackets.  Note there is a single CXT_Element even when the document
77      * contains a start and end element tag.  The node represents the pair.
78      * All text or other elements between the start and end tag will appear
79      * as children nodes of this CXT_Element node.
80      *
81      * For CXT_Attribute the pszValue is the attribute name.  The value of
82      * the attribute will be a CXT_Text child.
83      *
84      * For CXT_Text this is the text itself (value of an attribute, or a
85      * text fragment between an element start and end tags.
86      *
87      * For CXT_Literal it is all the literal text.  Currently this is just
88      * used for !DOCTYPE lines, and the value would be the entire line.
89      *
90      * For CXT_Comment the value is all the literal text within the comment,
91      * but not including the comment start/end indicators ("<--" and "-->").
92      */
93     char *pszValue;
94 
95     /**
96      * \brief Next sibling.
97      *
98      * Pointer to next sibling, that is the next node appearing after this
99      * one that has the same parent as this node.  NULL if this node is the
100      * last child of the parent element.
101      */
102     CPLXMLNode *psNext;
103 
104     /**
105      * \brief Child node.
106      *
107      * Pointer to first child node, if any.  Only CXT_Element and CXT_Attribute
108      * nodes should have children.  For CXT_Attribute it should be a single
109      * CXT_Text value node, while CXT_Element can have any kind of child.
110      * The full list of children for a node are identified by walking the
111      * psNext's starting with the psChild node.
112      */
113     CPLXMLNode *psChild;
114 }
115 
116 
117 CPLXMLNode * CPLParseXMLString(const(char) *) nothrow @nogc;
118 void  CPLDestroyXMLNode(CPLXMLNode *) nothrow @nogc;
119 CPLXMLNode * CPLGetXMLNode(CPLXMLNode *poRoot, const(char) *pszPath) nothrow @nogc;
120 CPLXMLNode * CPLSearchXMLNode(CPLXMLNode *poRoot, const(char) *pszTarget) nothrow @nogc;
121 const(char) * CPLGetXMLValue(CPLXMLNode *poRoot, const(char) *pszPath, const(char) *pszDefault) nothrow @nogc;
122 CPLXMLNode * CPLCreateXMLNode(CPLXMLNode *poParent, CPLXMLNodeType eType, const(char) *pszText) nothrow @nogc;
123 char * CPLSerializeXMLTree(CPLXMLNode *psNode) nothrow @nogc;
124 void  CPLAddXMLChild(CPLXMLNode *psParent, CPLXMLNode *psChild) nothrow @nogc;
125 int  CPLRemoveXMLChild(CPLXMLNode *psParent, CPLXMLNode *psChild) nothrow @nogc;
126 void  CPLAddXMLSibling(CPLXMLNode *psOlderSibling, CPLXMLNode *psNewSibling) nothrow @nogc;
127 CPLXMLNode * CPLCreateXMLElementAndValue(CPLXMLNode *psParent, const(char) *pszName, const(char) *pszValue) nothrow @nogc;
128 void  CPLAddXMLAttributeAndValue(CPLXMLNode *psParent, const(char) *pszName, const(char) *pszValue) nothrow @nogc;
129 CPLXMLNode * CPLCloneXMLTree(CPLXMLNode *psTree) nothrow @nogc;
130 int  CPLSetXMLValue(CPLXMLNode *psRoot, const(char) *pszPath, const(char) *pszValue) nothrow @nogc;
131 void  CPLStripXMLNamespace(CPLXMLNode *psRoot, const(char) *pszNameSpace, int bRecurse) nothrow @nogc;
132 void  CPLCleanXMLElementName(char *) nothrow @nogc;
133 
134 CPLXMLNode * CPLParseXMLFile(const(char) *pszFilename) nothrow @nogc;
135 int  CPLSerializeXMLTreeToFile(CPLXMLNode *psTree, const(char) *pszFilename) nothrow @nogc;