UPnPsdk 0.1
Universal Plug and Play +, Software Development Kit
 
Loading...
Searching...
No Matches
ixmlparser.hpp
Go to the documentation of this file.
1#ifndef UPNPLIB_IXMLPARSER_HPP
2#define UPNPLIB_IXMLPARSER_HPP
3/**************************************************************************
4 *
5 * Copyright (c) 2000-2003 Intel Corporation
6 * All rights reserved.
7 * Copyright (C) 2022+ GPL 3 and higher by Ingo Höft, <Ingo@Hoeft-online.de>
8 * Redistribution only with this Copyright remark. Last modified: 2025-05-29
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * - Neither name of Intel Corporation nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
26 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
29 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
30 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
31 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 **************************************************************************/
39#include <ixml/ixml.hpp>
40#include <ixml/ixmlmembuf.hpp>
41
43/* Parser definitions */
44#define QUOT "&quot;"
45#define LT "&lt;"
46#define GT "&gt;"
47#define APOS "&apos;"
48#define AMP "&amp;"
49#define ESC_HEX "&#x"
50#define ESC_DEC "&#"
52
54typedef struct _IXML_NamespaceURI {
55 char* nsURI;
56 char* prefix;
57 struct _IXML_NamespaceURI* nextNsURI;
59
61typedef struct _IXML_ElementStack {
62 char* element;
63 char* prefix;
64 char* namespaceUri;
65 IXML_NamespaceURI* pNsURI;
66 struct _IXML_ElementStack* nextElement;
68
70typedef enum { eELEMENT, eATTRIBUTE, eCONTENT } PARSER_STATE;
71
73typedef struct _Parser {
77 char* curPtr;
79 char* savePtr;
80 ixml_membuf lastElem;
81 ixml_membuf tokenBuf;
82 IXML_Node* pNeedPrefixNode;
83 IXML_ElementStack* pCurElement;
84 IXML_Node* currentNodePtr;
85 PARSER_STATE state;
86 int bHasTopLevel;
88
94 const DOMString name);
95
109 char c);
110
111#ifdef IXML_HAVE_SCRIPTSUPPORT
120void Parser_setBeforeFree(
122 IXML_BeforeFreeNode_t hndlr);
123
127IXML_BeforeFreeNode_t Parser_getBeforeFree();
128#endif
129
135 IXML_Node* IXML_Nodeptr);
136
137int Parser_LoadDocument(IXML_Document** retDoc, const char* xmlFile, int file);
138
139int Parser_setNodePrefixAndLocalName(IXML_Node* newIXML_NodeIXML_Attr);
140
142void ixmlAttr_init(IXML_Attr* attrNode);
143
155 IXML_Element* element,
157 const char* tagName);
158
164 IXML_NamedNodeMap* nnMap);
165
172 /* [in] The named node map. */
173 IXML_NamedNodeMap** nnMap,
174 /* [in] The node to add. */
175 IXML_Node* add);
176
182 IXML_NodeList** nList,
184 IXML_Node* add);
185
189void ixmlNode_init(
191 IXML_Node* nodeptr);
192
203 IXML_Node* srcNode,
205 IXML_Node* destNode);
206
214 IXML_Node* n,
216 const char* tagname,
218 IXML_NodeList** list);
219
227 IXML_Node* n,
229 const char* namespaceURI,
231 const char* localName,
233 IXML_NodeList** list);
234
242 IXML_Node* node,
244 const DOMString qualifiedName);
245
253 IXML_Node* destNode,
255 IXML_Node* src);
256
262 IXML_NodeList* nList);
263
264#endif /* UPNPLIB_IXMLPARSER_HPP */
Data structure common to all types of nodes.
Definition ixml.hpp:132
Data structure representing an Attribute node.
Definition ixml.hpp:177
Data structure representing a list of nodes.
Definition ixml.hpp:193
Data structure representing a list of named nodes.
Definition ixml.hpp:201
Data structure representing an Element node.
Definition ixml.hpp:169
Data structure representing the DOM Document.
Definition ixml.hpp:155
#define DOMString
The type of DOM strings.
Definition ixml.hpp:47
The ixml_membuf type.
int ixmlNodeList_addToNodeList(IXML_NodeList **nList, IXML_Node *add)
Add a node to nodelist.
Definition nodeList.cpp:74
struct _IXML_ElementStack IXML_ElementStack
IXML_ElementStack.
void ixmlNamedNodeMap_init(IXML_NamedNodeMap *nnMap)
Initializes a NamedNodeMap object.
struct _Parser Parser
Parser.
char * curPtr
int ixmlNode_setNodeProperties(IXML_Node *destNode, IXML_Node *src)
Definition node.cpp:1310
char * dataBuffer
int ixmlNode_compare(IXML_Node *srcNode, IXML_Node *destNode)
Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignore...
Definition node.cpp:490
void ixmlNode_getElementsByTagName(IXML_Node *n, const char *tagname, IXML_NodeList **list)
Returns a nodeList of all descendant Elements with a given tagName, in the order in which they are en...
Definition node.cpp:1211
void ixmlNode_init(IXML_Node *nodeptr)
Intializes a node.
Definition node.cpp:43
int ixmlNode_setNodeName(IXML_Node *node, const DOMString qualifiedName)
Definition node.cpp:1284
char * savePtr
void ixmlNodeList_init(IXML_NodeList *nList)
Initializes a nodelist.
Definition nodeList.cpp:43
void Parser_freeNodeContent(IXML_Node *IXML_Nodeptr)
Fees a node contents.
struct _IXML_NamespaceURI IXML_NamespaceURI
IXML_NamespaceURI.
int ixmlElement_setTagName(IXML_Element *element, const char *tagName)
Set the given element's tagName.
Definition element.cpp:57
void ixmlAttr_init(IXML_Attr *attrNode)
ixmlAttr_init
Definition attr.cpp:39
int Parser_setNodePrefixAndLocalName(IXML_Node *newIXML_NodeIXML_Attr)
Set the node prefix and localName as defined by the nodeName in the form of ns:name.
PARSER_STATE
PARSER_STATE.
int Parser_LoadDocument(IXML_Document **retDoc, const char *xmlFile, int file)
Parses a xml file and return the DOM tree.
void Parser_setErrorChar(char c)
Sets the error character.
int ixmlNamedNodeMap_addToNamedNodeMap(IXML_NamedNodeMap **nnMap, IXML_Node *add)
Add a node to a NamedNodeMap.
int Parser_isValidXmlName(const DOMString name)
Check to see whether name is a valid xml name.
void ixmlNode_getElementsByTagNameNS(IXML_Node *n, const char *namespaceURI, const char *localName, IXML_NodeList **list)
Returns a nodeList of all the descendant Elements with a given local name and namespace URI in the or...
Definition node.cpp:1261
IXML_ElementStack.
Parser.
IXML_NamespaceURI.