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 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 */
34 #include "dom.h"
36 namespace org
37 {
38 namespace w3c
39 {
40 namespace dom
41 {
45 class XmlReader
46 {
47 public:
49 /**
50 *
51 */
52 XmlReader();
54 /**
55 *
56 */
57 XmlReader(bool parseAsData);
59 /**
60 *
61 */
62 virtual ~XmlReader();
64 /**
65 *
66 */
67 org::w3c::dom::Document *parse(const DOMString &buf,
68 int offset, int length);
70 /**
71 *
72 */
73 org::w3c::dom::Document *parse(const DOMString &buf);
75 /**
76 *
77 */
78 org::w3c::dom::Document *parseFile(char *fileName);
81 protected:
83 void error(char *format, ...);
85 int get(int ch);
86 int peek(int ch);
87 bool match(int pos, char *str);
89 int skipwhite(int ch);
90 int getWord(int pos, DOMString &result);
91 int getPrefixedWord(int pos,
92 DOMString &prefix,
93 DOMString &shortWord,
94 DOMString &fullWord);
95 int getQuoted(int p, DOMString &result);
97 int parseVersion(int pos);
98 int parseDoctype(int pos);
100 int parseCDATA (int pos, CDATASection *cdata);
101 int parseComment(int pos, Comment *comment);
102 int parseText(int pos, Text *test);
104 int parseEntity(int pos, DOMString &buf);
106 int parseAttributes(int p0, Node *node, bool *quickClose);
108 int parseNode(int p0, Node *node, int depth);
110 bool keepGoing;
111 bool parseAsData;
112 int pos; //current parse position
113 int len; //length of parsed region
114 DOMString parsebuf;
116 DOMString loadFile(char *fileName);
118 int lineNr;
119 int colNr;
121 Document *document;
123 };
125 } //namespace dom
126 } //namespace w3c
127 } //namespace org
129 #endif /*_XMLREADER_H_*/