Code

add proper unix socket includes
[inkscape.git] / src / dom / lsimpl.h
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 "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 Document *parse(const LSInput &input)
76                             throw(dom::DOMException, LSException);
79     /**
80      *
81      */
82     virtual Document *parseURI(const DOMString &uri)
83                                throw(dom::DOMException, LSException);
85    /**
86      *
87      */
88     virtual Node *parseWithContext(const LSInput &input,
89                                    const Node *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
142 public:
144     /**
145      *
146      */
147     virtual unsigned short startElement(const Element *elementArg)
148         { return 0; }
150     /**
151      *
152      */
153     virtual unsigned short acceptNode(const Node *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
185 public:
188     /**
189      *
190      */
191     virtual bool write(const Node *nodeArg,
192                        const LSOutput &destination)
193                        throw (LSException);
195     /**
196      *
197      */
198     virtual bool writeToURI(const Node *nodeArg,
199                             const DOMString &uri)
200                             throw(LSException);
202     /**
203      *
204      */
205     virtual DOMString writeToString(const Node *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 Node *nodeArg);
235 private:
237     void spaces();
239     void po(char *fmt, ...);
241     void pos(const DOMString &str);
243     void poxml(const DOMString &str);
245     DOMString          outbuf;
247     int                indent;
249     DOMConfiguration   *domConfig;
251     LSSerializerFilter *filter;
255 };
260 /*#########################################################################
261 ## LSSerializerFilterImpl
262 #########################################################################*/
264 /**
265  *
266  */
267 class LSSerializerFilterImpl : virtual public LSSerializerFilter
269 public:
271     /**
272      *
273      */
274     virtual unsigned long  getWhatToShow()
275         { return 0; }
277     //##################
278     //# Non-API methods
279     //##################
281     /**
282      *
283      */
284     virtual ~LSSerializerFilterImpl()
285         {}
286 };
290 /*#########################################################################
291 ## DOMImplementationLSImpl
292 #########################################################################*/
294 /**
295  *
296  */
297 class DOMImplementationLSImpl : virtual public DOMImplementationLS
299 public:
301     /**
302      *
303      */
304     virtual LSParser &createLSParser(unsigned short mode,
305                                      const DOMString &schemaType)
306                                      throw (dom::DOMException)
307         {
308         LSParserImpl newParser;
309         parser = newParser;
310         return parser;
311         }
314     /**
315      *
316      */
317     virtual LSSerializer &createLSSerializer()
318         {
319         LSSerializerImpl newSerializer;
320         serializer = newSerializer;
321         return serializer;
322         }
325     /**
326      *
327      */
328     virtual LSInput createLSInput()
329         {
330         LSInput input;
331         return input;
332         }
334     /**
335      *
336      */
337     virtual LSOutput createLSOutput()
338         {
339         LSOutput output;
340         return output;
341         }
343     //##################
344     //# Non-API methods
345     //##################
347     /**
348      *
349      */
350     virtual ~DOMImplementationLSImpl() {}
352 protected:
354     LSParserImpl     parser;
355     LSSerializerImpl serializer;
356 };
363 }  //namespace ls
364 }  //namespace dom
365 }  //namespace w3c
366 }  //namespace org
371 #endif   /* __LSIMPL_H__ */
373 /*#########################################################################
374 ## E N D    O F    F I L E
375 #########################################################################*/