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-2007 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 "domimpl.h"
33 #include "events.h"
34 #include "traversal.h"
35 #include "ls.h"
38 #include "xmlreader.h"
40 namespace org
41 {
42 namespace w3c
43 {
44 namespace dom
45 {
46 namespace ls
47 {
50 /*#########################################################################
51 ## LSParserImpl
52 #########################################################################*/
54 /**
55 *
56 */
57 class LSParserImpl : virtual public LSParser
58 {
59 public:
61 typedef enum
62 {
63 PARSE_AS_DATA = 0,
64 PARSE_AS_DOCUMENT = 1
65 } ParsingModes;
67 /**
68 *
69 */
70 virtual bool getBusy();
72 /**
73 *
74 */
75 virtual DocumentPtr parse(const LSInput &input)
76 throw(dom::DOMException, LSException);
79 /**
80 *
81 */
82 virtual DocumentPtr parseURI(const DOMString &uri)
83 throw(dom::DOMException, LSException);
85 /**
86 *
87 */
88 virtual NodePtr parseWithContext(const LSInput &input,
89 const NodePtr contextArg,
90 unsigned short action)
91 throw(dom::DOMException, LSException);
94 //##################
95 //# Non-API methods
96 //##################
98 /**
99 *
100 */
101 LSParserImpl()
102 {}
104 /**
105 *
106 */
107 LSParserImpl(const LSParserImpl &other) : LSParser(other)
108 {}
110 /**
111 *
112 */
113 virtual ~LSParserImpl()
114 {}
118 //##################
119 //# Internals
120 //##################
123 protected:
125 XmlReader reader;
126 LSParserFilter *filter;
128 };
133 /*#########################################################################
134 ## LSParserFilterImpl
135 #########################################################################*/
137 /**
138 *
139 */
140 class LSParserFilterImpl : virtual public LSParserFilter
141 {
142 public:
144 /**
145 *
146 */
147 virtual unsigned short startElement(const ElementPtr /*elementArg*/)
148 { return 0; }
150 /**
151 *
152 */
153 virtual unsigned short acceptNode(const NodePtr /*nodeArg*/)
154 { return 0; }
156 /**
157 *
158 */
159 virtual unsigned long getWhatToShow()
160 { return 0; }
162 //##################
163 //# Non-API methods
164 //##################
166 /**
167 *
168 */
169 virtual ~LSParserFilterImpl()
170 {}
174 };
176 /*#########################################################################
177 ## LSSerializerImpl
178 #########################################################################*/
180 /**
181 *
182 */
183 class LSSerializerImpl : virtual public LSSerializer
184 {
185 public:
188 /**
189 *
190 */
191 virtual bool write(const NodePtr nodeArg,
192 const LSOutput &destination)
193 throw (LSException);
195 /**
196 *
197 */
198 virtual bool writeToURI(const NodePtr nodeArg,
199 const DOMString &uri)
200 throw(LSException);
202 /**
203 *
204 */
205 virtual DOMString writeToString(const NodePtr nodeArg)
206 throw(dom::DOMException, LSException);
208 //##################
209 //# Non-API methods
210 //##################
212 /**
213 *
214 */
215 LSSerializerImpl()
216 {
217 indent = 0;
218 }
220 /**
221 *
222 */
223 virtual ~LSSerializerImpl()
224 {}
228 protected:
230 /**
231 *
232 */
233 void writeNode(const NodePtr nodeArg);
235 private:
237 void spaces();
239 void po(char const *fmt, ...)
240 #ifdef G_GNUC_PRINTF
241 G_GNUC_PRINTF(2, 3)
242 #endif
243 ;
245 void pos(const DOMString &str);
247 void poxml(const DOMString &str);
249 DOMString outbuf;
251 int indent;
253 DOMConfiguration *domConfig;
255 LSSerializerFilter *filter;
259 };
264 /*#########################################################################
265 ## LSSerializerFilterImpl
266 #########################################################################*/
268 /**
269 *
270 */
271 class LSSerializerFilterImpl : virtual public LSSerializerFilter
272 {
273 public:
275 /**
276 *
277 */
278 virtual unsigned long getWhatToShow()
279 { return 0; }
281 //##################
282 //# Non-API methods
283 //##################
285 /**
286 *
287 */
288 virtual ~LSSerializerFilterImpl()
289 {}
290 };
294 /*#########################################################################
295 ## DOMImplementationLSImpl
296 #########################################################################*/
298 /**
299 *
300 */
301 class DOMImplementationLSImpl : virtual public DOMImplementationLS
302 {
303 public:
305 /**
306 *
307 */
308 virtual LSParser &createLSParser(unsigned short /*mode*/,
309 const DOMString &/*schemaType*/)
310 throw (dom::DOMException)
311 {
312 LSParserImpl newParser;
313 parser = newParser;
314 return parser;
315 }
318 /**
319 *
320 */
321 virtual LSSerializer &createLSSerializer()
322 {
323 LSSerializerImpl newSerializer;
324 serializer = newSerializer;
325 return serializer;
326 }
329 /**
330 *
331 */
332 virtual LSInput createLSInput()
333 {
334 LSInput input;
335 return input;
336 }
338 /**
339 *
340 */
341 virtual LSOutput createLSOutput()
342 {
343 LSOutput output;
344 return output;
345 }
347 //##################
348 //# Non-API methods
349 //##################
351 /**
352 *
353 */
354 virtual ~DOMImplementationLSImpl() {}
356 protected:
358 LSParserImpl parser;
359 LSSerializerImpl serializer;
360 };
367 } //namespace ls
368 } //namespace dom
369 } //namespace w3c
370 } //namespace org
375 #endif /* __LSIMPL_H__ */
377 /*#########################################################################
378 ## E N D O F F I L E
379 #########################################################################*/