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