~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/dom/traversal.h

  • Committer: ishmal
  • Date: 2006-04-12 13:25:21 UTC
  • Revision ID: ishmal@users.sourceforge.net-20060412132521-5ynoezpwbzq4d1c3
Add new rearranged /dom directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __TRAVERSAL_H__
 
2
#define __TRAVERSAL_H__
 
3
 
 
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
 */
 
32
 
 
33
 
 
34
#include "dom.h"
 
35
 
 
36
 
 
37
namespace org
 
38
{
 
39
namespace w3c
 
40
{
 
41
namespace dom
 
42
{
 
43
namespace traversal
 
44
{
 
45
 
 
46
 
 
47
//Local aliases
 
48
typedef dom::Node Node;
 
49
 
 
50
 
 
51
 
 
52
 
 
53
 
 
54
/*#########################################################################
 
55
## NodeFilter
 
56
#########################################################################*/
 
57
/**
 
58
 *
 
59
 */
 
60
class NodeFilter
 
61
{
 
62
public:
 
63
 
 
64
    // Constants returned by acceptNode
 
65
    typedef enum
 
66
        {
 
67
        FILTER_ACCEPT                  = 1,
 
68
        FILTER_REJECT                  = 2,
 
69
        FILTER_SKIP                    = 3
 
70
        } AcceptNodeReturn;
 
71
 
 
72
 
 
73
 
 
74
    // Constants for whatToShow
 
75
    typedef enum
 
76
        {
 
77
        SHOW_ALL                       = 0xFFFFFFFF,
 
78
        SHOW_ELEMENT                   = 0x00000001,
 
79
        SHOW_ATTRIBUTE                 = 0x00000002,
 
80
        SHOW_TEXT                      = 0x00000004,
 
81
        SHOW_CDATA_SECTION             = 0x00000008,
 
82
        SHOW_ENTITY_REFERENCE          = 0x00000010,
 
83
        SHOW_ENTITY                    = 0x00000020,
 
84
        SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
 
85
        SHOW_COMMENT                   = 0x00000080,
 
86
        SHOW_DOCUMENT                  = 0x00000100,
 
87
        SHOW_DOCUMENT_TYPE             = 0x00000200,
 
88
        SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
 
89
        SHOW_NOTATION                  = 0x00000800
 
90
        } WhatToShowReturn;
 
91
 
 
92
    /**
 
93
     *
 
94
     */
 
95
    virtual short acceptNode(const Node *n)
 
96
        {
 
97
        return 0;
 
98
        }
 
99
 
 
100
 
 
101
 
 
102
    //##################
 
103
    //# Non-API methods
 
104
    //##################
 
105
 
 
106
    /**
 
107
     *
 
108
     */
 
109
    NodeFilter()
 
110
        {}
 
111
 
 
112
    /**
 
113
     *
 
114
     */
 
115
    NodeFilter(const NodeFilter &other)
 
116
        {
 
117
        }
 
118
 
 
119
    /**
 
120
     *
 
121
     */
 
122
    virtual ~NodeFilter() {}
 
123
 
 
124
 
 
125
};
 
126
 
 
127
/*#########################################################################
 
128
## NodeIterator
 
129
#########################################################################*/
 
130
/**
 
131
 *
 
132
 */
 
133
class NodeIterator
 
134
{
 
135
public:
 
136
 
 
137
    /**
 
138
     *
 
139
     */
 
140
    virtual Node *getRoot()
 
141
        {
 
142
        return NULL;
 
143
        }
 
144
 
 
145
    /**
 
146
     *
 
147
     */
 
148
    virtual unsigned long getWhatToShow()
 
149
        { return whatToShow; }
 
150
 
 
151
    /**
 
152
     *
 
153
     */
 
154
    virtual NodeFilter getFilter()
 
155
        { return filter; }
 
156
 
 
157
    /**
 
158
     *
 
159
     */
 
160
    virtual bool getExpandEntityReferences()
 
161
        { return expandEntityReferences; }
 
162
 
 
163
    /**
 
164
     *
 
165
     */
 
166
    virtual Node *nextNode() throw(dom::DOMException)
 
167
        {
 
168
        return NULL;
 
169
        }
 
170
 
 
171
    /**
 
172
     *
 
173
     */
 
174
    virtual Node *previousNode() throw(dom::DOMException)
 
175
        {
 
176
        return NULL;
 
177
        }
 
178
 
 
179
    /**
 
180
     *
 
181
     */
 
182
    virtual void detach()
 
183
        {
 
184
        }
 
185
 
 
186
 
 
187
    //##################
 
188
    //# Non-API methods
 
189
    //##################
 
190
 
 
191
    /**
 
192
     *
 
193
     */
 
194
    NodeIterator() {}
 
195
 
 
196
    /**
 
197
     *
 
198
     */
 
199
    NodeIterator(const NodeIterator &other)
 
200
        {
 
201
        whatToShow             = other.whatToShow;
 
202
        filter                 = other.filter;
 
203
        expandEntityReferences = other.expandEntityReferences;
 
204
        }
 
205
 
 
206
    /**
 
207
     *
 
208
     */
 
209
    virtual ~NodeIterator() {}
 
210
 
 
211
protected:
 
212
 
 
213
    unsigned long whatToShow;
 
214
    NodeFilter filter;
 
215
    bool expandEntityReferences;
 
216
 
 
217
 
 
218
};
 
219
 
 
220
 
 
221
 
 
222
/*#########################################################################
 
223
## TreeWalker
 
224
#########################################################################*/
 
225
 
 
226
/**
 
227
 *
 
228
 */
 
229
class TreeWalker
 
230
{
 
231
public:
 
232
 
 
233
 
 
234
    /**
 
235
     *
 
236
     */
 
237
    virtual Node *getRoot()
 
238
        {
 
239
        return NULL;
 
240
        }
 
241
 
 
242
    /**
 
243
     *
 
244
     */
 
245
    virtual unsigned long getWhatToShow()
 
246
        { return whatToShow; }
 
247
 
 
248
    /**
 
249
     *
 
250
     */
 
251
    virtual NodeFilter getFilter()
 
252
        { return filter; }
 
253
 
 
254
    /**
 
255
     *
 
256
     */
 
257
    virtual bool getExpandEntityReferences()
 
258
        { return expandEntityReferences; }
 
259
 
 
260
    /**
 
261
     *
 
262
     */
 
263
    virtual Node *getCurrentNode()
 
264
        { return currentNode; }
 
265
 
 
266
    /**
 
267
     *
 
268
     */
 
269
    virtual void setCurrentNode(const Node *val) throw(dom::DOMException)
 
270
        { currentNode = (Node *)val; }
 
271
 
 
272
    /**
 
273
     *
 
274
     */
 
275
    virtual Node *parentNode()
 
276
        {
 
277
        return NULL;
 
278
        }
 
279
 
 
280
    /**
 
281
     *
 
282
     */
 
283
    virtual Node *firstChild()
 
284
        {
 
285
        return NULL;
 
286
        }
 
287
 
 
288
    /**
 
289
     *
 
290
     */
 
291
    virtual Node *lastChild()
 
292
        {
 
293
        return NULL;
 
294
        }
 
295
 
 
296
    /**
 
297
     *
 
298
     */
 
299
    virtual Node *previousSibling()
 
300
        {
 
301
        return NULL;
 
302
        }
 
303
 
 
304
    /**
 
305
     *
 
306
     */
 
307
    virtual Node *nextSibling()
 
308
        {
 
309
        return NULL;
 
310
        }
 
311
 
 
312
    /**
 
313
     *
 
314
     */
 
315
    virtual Node *previousNode()
 
316
        {
 
317
        return NULL;
 
318
        }
 
319
 
 
320
    /**
 
321
     *
 
322
     */
 
323
    virtual Node *nextNode()
 
324
        {
 
325
        return NULL;
 
326
        }
 
327
 
 
328
 
 
329
 
 
330
    //##################
 
331
    //# Non-API methods
 
332
    //##################
 
333
 
 
334
    /**
 
335
     *
 
336
     */
 
337
    TreeWalker() {}
 
338
 
 
339
    /**
 
340
     *
 
341
     */
 
342
    TreeWalker(const TreeWalker &other)
 
343
        {
 
344
        whatToShow             = other.whatToShow;
 
345
        filter                 = other.filter;
 
346
        expandEntityReferences = other.expandEntityReferences;
 
347
        currentNode            = other.currentNode;
 
348
        }
 
349
 
 
350
    /**
 
351
     *
 
352
     */
 
353
    virtual ~TreeWalker() {}
 
354
 
 
355
 
 
356
protected:
 
357
 
 
358
    unsigned long whatToShow;
 
359
    NodeFilter filter;
 
360
    bool expandEntityReferences;
 
361
    Node *currentNode;
 
362
 
 
363
};
 
364
 
 
365
 
 
366
 
 
367
 
 
368
/*#########################################################################
 
369
## DocumentTraversal
 
370
#########################################################################*/
 
371
 
 
372
/**
 
373
 *
 
374
 */
 
375
class DocumentTraversal
 
376
{
 
377
public:
 
378
 
 
379
    /**
 
380
     *
 
381
     */
 
382
    virtual NodeIterator createNodeIterator(const Node *root,
 
383
                                          unsigned long whatToShow,
 
384
                                          const NodeFilter *filter,
 
385
                                          bool entityReferenceExpansion)
 
386
                                          throw (dom::DOMException)
 
387
        {
 
388
        NodeIterator ret;
 
389
        return ret;
 
390
        }
 
391
 
 
392
    /**
 
393
     *
 
394
     */
 
395
    virtual TreeWalker createTreeWalker(const Node *root,
 
396
                                        unsigned long whatToShow,
 
397
                                        const NodeFilter *filter,
 
398
                                        bool entityReferenceExpansion)
 
399
                                        throw (dom::DOMException)
 
400
        {
 
401
        TreeWalker ret;
 
402
        return ret;
 
403
        }
 
404
 
 
405
 
 
406
    //##################
 
407
    //# Non-API methods
 
408
    //##################
 
409
 
 
410
    /**
 
411
     *
 
412
     */
 
413
    DocumentTraversal() {}
 
414
 
 
415
    /**
 
416
     *
 
417
     */
 
418
    DocumentTraversal(const DocumentTraversal &other)
 
419
        {}
 
420
 
 
421
    /**
 
422
     *
 
423
     */
 
424
    virtual ~DocumentTraversal() {}
 
425
 
 
426
};
 
427
 
 
428
 
 
429
 
 
430
 
 
431
 
 
432
 
 
433
}  //namespace traversal
 
434
}  //namespace dom
 
435
}  //namespace w3c
 
436
}  //namespace org
 
437
 
 
438
#endif   /* __TRAVERSAL_H__ */
 
439
 
 
440
 
 
441
/*#########################################################################
 
442
## E N D    O F    F I L E
 
443
#########################################################################*/
 
444