Code

Extensions. Add option to choose dxf output units
[inkscape.git] / src / io / simple-sax.h
1 #ifndef SEEN_SIMPLE_SAX_H
2 #define SEEN_SIMPLE_SAX_H
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  */
15 #include <libxml/parser.h>
16 #include <glibmm/ustring.h>
18 namespace Inkscape {
19 namespace IO
20 {
22 class SaxHandler
23 {
24 public:
25     SaxHandler();
26     virtual ~SaxHandler();
28     int parseMemory( const char* buffer, int size );
29     int parseFile( const char* filename );
31     static const char* errToStr( int errVal );
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*/) {}
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);
52     // Disable:
53     SaxHandler(SaxHandler const &);
54     SaxHandler &operator=(SaxHandler const &);
56     xmlSAXHandler sax;
57 };
61 class FlatSaxHandler : public SaxHandler
62 {
63 public:
64     FlatSaxHandler();
65     virtual ~FlatSaxHandler();
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);
72     Glib::ustring data;
74 private:
75     // Disable:
76     FlatSaxHandler(FlatSaxHandler const &);
77     FlatSaxHandler &operator=(FlatSaxHandler const &);
78 };
82 } // namespace IO
83 } // namespace Inkscape
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 :
97 #endif // SEEN_SIMPLE_SAX_H