~mc.../inkscape/inkscape

« back to all changes in this revision

Viewing changes to src/io/simple-sax.h

  • Committer: mental
  • Date: 2006-01-16 02:36:01 UTC
  • Revision ID: mental@users.sourceforge.net-20060116023601-wkr0h7edl5veyudq
moving trunk for module inkscape

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SEEN_SIMPLE_SAX_H
 
2
#define SEEN_SIMPLE_SAX_H
 
3
 
 
4
/*
 
5
 * SimpleSAX
 
6
 *
 
7
 * Authors:
 
8
 *   Jon A. Cruz <jon@joncruz.org>
 
9
 *
 
10
 * Copyright (C) 2004 AUTHORS
 
11
 *
 
12
 * Released under GNU GPL, read the file 'COPYING' for more information
 
13
 */
 
14
 
 
15
#include <libxml/parser.h>
 
16
#include <glibmm/ustring.h>
 
17
 
 
18
namespace Inkscape {
 
19
namespace IO
 
20
{
 
21
 
 
22
class SaxHandler
 
23
{
 
24
public:
 
25
    SaxHandler();
 
26
    virtual ~SaxHandler();
 
27
 
 
28
    int parseMemory( const char* buffer, int size );
 
29
    int parseFile( const char* filename );
 
30
 
 
31
    static const char* errToStr( int errVal );
 
32
 
 
33
protected:
 
34
    virtual void _startDocument() {}
 
35
    virtual void _endDocument() {}
 
36
    virtual void _startElement(const xmlChar *name, const xmlChar **attrs) {}
 
37
    virtual void _endElement(const xmlChar *name) {}
 
38
    virtual void _characters(const xmlChar *ch, int len) {}
 
39
 
 
40
private:
 
41
    static void startDocument(void *user_data);
 
42
    static void endDocument(void *user_data);
 
43
    static void startElement(void *user_data,
 
44
                             const xmlChar *name,
 
45
                             const xmlChar **attrs);
 
46
    static void endElement(void *user_data,
 
47
                           const xmlChar *name);
 
48
    static void characters(void *  user_data,
 
49
                           const xmlChar *ch,
 
50
                           int len);
 
51
 
 
52
    // Disable:
 
53
    SaxHandler(SaxHandler const &);
 
54
    SaxHandler &operator=(SaxHandler const &);
 
55
 
 
56
    xmlSAXHandler sax;
 
57
};
 
58
 
 
59
 
 
60
 
 
61
class FlatSaxHandler : public SaxHandler
 
62
{
 
63
public:
 
64
    FlatSaxHandler();
 
65
    virtual ~FlatSaxHandler();
 
66
 
 
67
protected:
 
68
    virtual void _startElement(const xmlChar *name, const xmlChar **attrs);
 
69
    virtual void _endElement(const xmlChar *name);
 
70
    virtual void _characters(const xmlChar *ch, int len);
 
71
 
 
72
    Glib::ustring data;
 
73
 
 
74
private:
 
75
    // Disable:
 
76
    FlatSaxHandler(FlatSaxHandler const &);
 
77
    FlatSaxHandler &operator=(FlatSaxHandler const &);
 
78
};
 
79
 
 
80
 
 
81
 
 
82
} // namespace IO
 
83
} // namespace Inkscape
 
84
 
 
85
 
 
86
/*
 
87
  Local Variables:
 
88
  mode:c++
 
89
  c-file-style:"stroustrup"
 
90
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
91
  indent-tabs-mode:nil
 
92
  fill-column:99
 
93
  End:
 
94
*/
 
95
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
 
96
 
 
97
#endif // SEEN_SIMPLE_SAX_H