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: 2026-04-01
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 **************************************************************************/
35// Last compare with ./Pupnp source file, based on 2026-03-16, ver 1.14.30
36
41#include <ixml/ixml.hpp>
42#include <ixml/ixmlmembuf.hpp>
43
45/* Parser definitions */
46#define QUOT "&quot;"
47#define LT "&lt;"
48#define GT "&gt;"
49#define APOS "&apos;"
50#define AMP "&amp;"
51#define ESC_HEX "&#x"
52#define ESC_DEC "&#"
54
56typedef struct _IXML_NamespaceURI {
57 char* nsURI;
58 char* prefix;
59 struct _IXML_NamespaceURI* nextNsURI;
61
63typedef struct _IXML_ElementStack {
64 char* element;
65 char* prefix;
66 char* namespaceUri;
67 IXML_NamespaceURI* pNsURI;
68 struct _IXML_ElementStack* nextElement;
70
72typedef enum { eELEMENT, eATTRIBUTE, eCONTENT } PARSER_STATE;
73
75typedef struct _Parser {
79 char* curPtr;
81 char* savePtr;
82 ixml_membuf lastElem;
83 ixml_membuf tokenBuf;
84 IXML_Node* pNeedPrefixNode;
85 IXML_ElementStack* pCurElement;
86 IXML_Node* currentNodePtr;
87 PARSER_STATE state;
88 int bHasTopLevel;
90
96 const DOMString name);
97
111 char c);
112
113#ifdef IXML_HAVE_SCRIPTSUPPORT
122void Parser_setBeforeFree(
124 IXML_BeforeFreeNode_t hndlr);
125
129IXML_BeforeFreeNode_t Parser_getBeforeFree(void);
130#endif
131
137 IXML_Node* IXML_Nodeptr);
138
139int Parser_LoadDocument(IXML_Document** retDoc, const char* xmlFile, int file);
140
141int Parser_setNodePrefixAndLocalName(IXML_Node* newIXML_NodeIXML_Attr);
142
144void ixmlAttr_init(IXML_Attr* attrNode);
145
157 IXML_Element* element,
159 const char* tagName);
160
166 IXML_NamedNodeMap* nnMap);
167
174 /* [in] The named node map. */
175 IXML_NamedNodeMap** nnMap,
176 /* [in] The node to add. */
177 IXML_Node* add);
178
184 IXML_NodeList** nList,
186 IXML_Node* add);
187
191void ixmlNode_init(
193 IXML_Node* nodeptr);
194
205 const IXML_Node* srcNode,
207 const IXML_Node* destNode);
208
216 IXML_Node* n,
218 const char* tagname,
220 IXML_NodeList** list);
221
229 IXML_Node* n,
231 const char* namespaceURI,
233 const char* localName,
235 IXML_NodeList** list);
236
244 IXML_Node* node,
246 const DOMString qualifiedName);
247
255 IXML_Node* destNode,
257 IXML_Node* src);
258
264 IXML_NodeList* nList);
265
266#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:1281
char * dataBuffer
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:1184
void ixmlNode_init(IXML_Node *nodeptr)
Intializes a node.
Definition node.cpp:47
int ixmlNode_setNodeName(IXML_Node *node, const DOMString qualifiedName)
Definition node.cpp:1257
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:60
void ixmlAttr_init(IXML_Attr *attrNode)
ixmlAttr_init
Definition attr.cpp:40
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 ixmlNode_compare(const IXML_Node *srcNode, const IXML_Node *destNode)
Compare two nodes to see whether they are the same node. Parent, sibling and children node are ignore...
Definition node.cpp:485
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:1234
IXML_ElementStack.
Parser.
IXML_NamespaceURI.