1 #ifndef _XMLREADER_H_
2 #define _XMLREADER_H_
4 /**
5 * Phoebe DOM Implementation.
6 *
7 * This is a C++ approximation of the W3C DOM model, which follows
8 * fairly closely the specifications in the various .idl files, copies of
9 * which are provided for reference. Most important is this one:
10 *
11 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
12 *
13 * Authors:
14 * Bob Jamison
15 *
16 * Copyright (C) 2005-2008 Bob Jamison
17 *
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Lesser General Public
20 * License as published by the Free Software Foundation; either
21 * version 2.1 of the License, or (at your option) any later version.
22 *
23 * This library is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * Lesser General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public
29 * License along with this library; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 */
33 #include "dom.h"
35 namespace org
36 {
37 namespace w3c
38 {
39 namespace dom
40 {
44 class XmlReader
45 {
46 public:
48 /**
49 *
50 */
51 XmlReader();
53 /**
54 *
55 */
56 XmlReader(bool parseAsData);
58 /**
59 *
60 */
61 virtual ~XmlReader();
63 /**
64 *
65 */
66 org::w3c::dom::DocumentPtr parse(const DOMString &buf,
67 int offset, int length);
69 /**
70 *
71 */
72 org::w3c::dom::DocumentPtr parse(const DOMString &buf);
74 /**
75 *
76 */
77 org::w3c::dom::DocumentPtr parseFile(const DOMString &fileName);
80 private:
82 void error(const char *format, ...)
83 #ifdef G_GNUC_PRINTF
84 G_GNUC_PRINTF(2, 3)
85 #endif
86 ;
88 int get(int ch);
89 int peek(int ch);
90 bool match(int pos, char const *str);
92 int skipwhite(int ch);
93 int getWord(int pos, DOMString &result);
94 int getPrefixedWord(int pos,
95 DOMString &prefix,
96 DOMString &shortWord,
97 DOMString &fullWord);
98 int getQuoted(int p, DOMString &result);
100 int parseVersion(int pos);
101 int parseDoctype(int pos);
103 int parseCDATA (int pos, CDATASectionPtr cdata);
104 int parseComment(int pos, CommentPtr comment);
105 int parseText(int pos, TextPtr text);
107 int parseEntity(int pos, DOMString &buf);
109 int parseAttributes(int p0, NodePtr node, bool *quickClose);
111 int parseNode(int p0, NodePtr node, int depth);
113 bool keepGoing;
114 bool parseAsData;
115 int pos; //current parse position
116 int len; //length of parsed region
117 DOMString parsebuf;
119 DOMString loadFile(const DOMString &fileName);
121 int lineNr;
122 int colNr;
124 DocumentPtr document;
126 };
128 } //namespace dom
129 } //namespace w3c
130 } //namespace org
132 #endif /*_XMLREADER_H_*/