d73998e133bcea41d081862c68670085a6a6d131
1 #ifndef __LSIMPL_H__
2 #define __LSIMPL_H__
3 /**
4 * Phoebe DOM Implementation.
5 *
6 * This is a C++ approximation of the W3C DOM model, which follows
7 * fairly closely the specifications in the various .idl files, copies of
8 * which are provided for reference. Most important is this one:
9 *
10 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
11 *
12 * Authors:
13 * Bob Jamison
14 *
15 * Copyright (C) 2005 Bob Jamison
16 *
17 * This library is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU Lesser General Public
19 * License as published by the Free Software Foundation; either
20 * version 2.1 of the License, or (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25 * Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public
28 * License along with this library; if not, write to the Free Software
29 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
32 #include <glib.h>
34 #include "domimpl.h"
35 #include "events.h"
36 #include "traversal.h"
37 #include "ls.h"
40 #include "xmlreader.h"
42 namespace org
43 {
44 namespace w3c
45 {
46 namespace dom
47 {
48 namespace ls
49 {
52 /*#########################################################################
53 ## LSParserImpl
54 #########################################################################*/
56 /**
57 *
58 */
59 class LSParserImpl : virtual public LSParser
60 {
61 public:
63 typedef enum
64 {
65 PARSE_AS_DATA = 0,
66 PARSE_AS_DOCUMENT = 1
67 } ParsingModes;
69 /**
70 *
71 */
72 virtual bool getBusy();
74 /**
75 *
76 */
77 virtual DocumentPtr parse(const LSInput &input)
78 throw(dom::DOMException, LSException);
81 /**
82 *
83 */
84 virtual DocumentPtr parseURI(const DOMString &uri)
85 throw(dom::DOMException, LSException);
87 /**
88 *
89 */
90 virtual NodePtr parseWithContext(const LSInput &input,
91 const NodePtr contextArg,
92 unsigned short action)
93 throw(dom::DOMException, LSException);
96 //##################
97 //# Non-API methods
98 //##################
100 /**
101 *
102 */
103 LSParserImpl()
104 {}
106 /**
107 *
108 */
109 LSParserImpl(const LSParserImpl &other) : LSParser(other)
110 {}
112 /**
113 *
114 */
115 virtual ~LSParserImpl()
116 {}
120 //##################
121 //# Internals
122 //##################
125 protected:
127 XmlReader reader;
128 LSParserFilter *filter;
130 };
135 /*#########################################################################
136 ## LSParserFilterImpl
137 #########################################################################*/
139 /**
140 *
141 */
142 class LSParserFilterImpl : virtual public LSParserFilter
143 {
144 public:
146 /**
147 *
148 */
149 virtual unsigned short startElement(const ElementPtr elementArg)
150 { return 0; }
152 /**
153 *
154 */
155 virtual unsigned short acceptNode(const NodePtr nodeArg)
156 { return 0; }
158 /**
159 *
160 */
161 virtual unsigned long getWhatToShow()
162 { return 0; }
164 //##################
165 //# Non-API methods
166 //##################
168 /**
169 *
170 */
171 virtual ~LSParserFilterImpl()
172 {}
176 };
178 /*#########################################################################
179 ## LSSerializerImpl
180 #########################################################################*/
182 /**
183 *
184 */
185 class LSSerializerImpl : virtual public LSSerializer
186 {
187 public:
190 /**
191 *
192 */
193 virtual bool write(const NodePtr nodeArg,
194 const LSOutput &destination)
195 throw (LSException);
197 /**
198 *
199 */
200 virtual bool writeToURI(const NodePtr nodeArg,
201 const DOMString &uri)
202 throw(LSException);
204 /**
205 *
206 */
207 virtual DOMString writeToString(const NodePtr nodeArg)
208 throw(dom::DOMException, LSException);
210 //##################
211 //# Non-API methods
212 //##################
214 /**
215 *
216 */
217 LSSerializerImpl()
218 {
219 indent = 0;
220 }
222 /**
223 *
224 */
225 virtual ~LSSerializerImpl()
226 {}
230 protected:
232 /**
233 *
234 */
235 void writeNode(const NodePtr nodeArg);
237 private:
239 void spaces();
241 void po(char *fmt, ...) G_GNUC_PRINTF(2,3);
243 void pos(const DOMString &str);
245 void poxml(const DOMString &str);
247 DOMString outbuf;
249 int indent;
251 DOMConfiguration *domConfig;
253 LSSerializerFilter *filter;
257 };
262 /*#########################################################################
263 ## LSSerializerFilterImpl
264 #########################################################################*/
266 /**
267 *
268 */
269 class LSSerializerFilterImpl : virtual public LSSerializerFilter
270 {
271 public:
273 /**
274 *
275 */
276 virtual unsigned long getWhatToShow()
277 { return 0; }
279 //##################
280 //# Non-API methods
281 //##################
283 /**
284 *
285 */
286 virtual ~LSSerializerFilterImpl()
287 {}
288 };
292 /*#########################################################################
293 ## DOMImplementationLSImpl
294 #########################################################################*/
296 /**
297 *
298 */
299 class DOMImplementationLSImpl : virtual public DOMImplementationLS
300 {
301 public:
303 /**
304 *
305 */
306 virtual LSParser &createLSParser(unsigned short mode,
307 const DOMString &schemaType)
308 throw (dom::DOMException)
309 {
310 LSParserImpl newParser;
311 parser = newParser;
312 return parser;
313 }
316 /**
317 *
318 */
319 virtual LSSerializer &createLSSerializer()
320 {
321 LSSerializerImpl newSerializer;
322 serializer = newSerializer;
323 return serializer;
324 }
327 /**
328 *
329 */
330 virtual LSInput createLSInput()
331 {
332 LSInput input;
333 return input;
334 }
336 /**
337 *
338 */
339 virtual LSOutput createLSOutput()
340 {
341 LSOutput output;
342 return output;
343 }
345 //##################
346 //# Non-API methods
347 //##################
349 /**
350 *
351 */
352 virtual ~DOMImplementationLSImpl() {}
354 protected:
356 LSParserImpl parser;
357 LSSerializerImpl serializer;
358 };
365 } //namespace ls
366 } //namespace dom
367 } //namespace w3c
368 } //namespace org
373 #endif /* __LSIMPL_H__ */
375 /*#########################################################################
376 ## E N D O F F I L E
377 #########################################################################*/