Code

Warning cleanup
[inkscape.git] / src / xml / simple-document.h
1 /*
2  * Inkscape::XML::SimpleDocument - generic XML document implementation
3  *
4  * Copyright 2004-2005 MenTaLguY <mental@rydia.net>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * See the file COPYING for details.
12  *
13  */
15 #ifndef SEEN_INKSCAPE_XML_SIMPLE_DOCUMENT_H
16 #define SEEN_INKSCAPE_XML_SIMPLE_DOCUMENT_H
18 #include "xml/document.h"
19 #include "xml/simple-node.h"
20 #include "xml/node-observer.h"
21 #include "xml/log-builder.h"
23 namespace Inkscape {
25 namespace XML {
27 class SimpleDocument : public SimpleNode,
28                        public Document,
29                        public NodeObserver
30 {
31 public:
32     explicit SimpleDocument()
33     : SimpleNode(g_quark_from_static_string("xml")), _in_transaction(false)
34     {
35         _initBindings();
36     }
38     NodeType type() const { return Inkscape::XML::DOCUMENT_NODE; }
40     NodeObserver *logger() { return this; }
42     bool inTransaction() { return _in_transaction; }
44     void beginTransaction();
45     void rollback();
46     void commit();
47     Inkscape::XML::Event *commitUndoable();
49     Node *createElement(char const *name);
50     Node *createTextNode(char const *content);
51     Node *createComment(char const *content);
53     void notifyChildAdded(Node &parent, Node &child, Node *prev);
55     void notifyChildRemoved(Node &parent, Node &child, Node *prev);
57     void notifyChildOrderChanged(Node &parent, Node &child,
58                                  Node *old_prev, Node *new_prev);
60     void notifyContentChanged(Node &node,
61                               Util::ptr_shared<char> old_content,
62                               Util::ptr_shared<char> new_content);
64     void notifyAttributeChanged(Node &node, GQuark name,
65                                 Util::ptr_shared<char> old_value,
66                                 Util::ptr_shared<char> new_value);
68 protected:
69     SimpleDocument(SimpleDocument const &doc)
70     : Node(), SimpleNode(doc), Document(), NodeObserver(),
71       _in_transaction(false)
72     {
73         _initBindings();
74     }
76     SimpleNode *_duplicate(Document* /*doc*/) const
77     {
78         return new SimpleDocument(*this);
79     }
81 private:
82     void _initBindings();
84     bool _in_transaction;
85     LogBuilder _log_builder;
86 };
88 }
90 }
92 #endif
93 /*
94   Local Variables:
95   mode:c++
96   c-file-style:"stroustrup"
97   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
98   indent-tabs-mode:nil
99   fill-column:99
100   End:
101 */
102 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :