]> git.llucax.com Git - software/bife/bife++.git/blob - parser.h
- Normalized Fallback constructor to be the same of Widget (or Container).
[software/bife/bife++.git] / parser.h
1 // vim: set expandtab tabstop=4 shiftwidth=4:
2
3 #ifndef BIFE_PARSER_H
4 #define BIFE_PARSER_H
5
6 #include "libbife/hit.h"
7 #include "libbife/hash.h"
8 #include "libbife/widget.h"
9 #include "libbife/fallback.h"
10 #include <libxml++/libxml++.h>
11 #include <string>
12 #include <stack>
13
14 namespace bife {
15
16     using std::string;
17
18     /**
19      * Base Widget Class.
20      *
21      * @todo Better plug-in support. Cleanning (a lot).
22      * @todo Try to free some memeory :)
23      */
24     class Parser: public xmlpp::SaxParser {
25         // Typedefs.
26         protected:
27             /// Stack of widget pointers.
28             typedef std::stack<Widget*> WidgetStack;
29
30         // Attributes.
31         protected:
32             /**
33              * Widget stack.
34              * This is the stack of widgets to know what widget is the parser
35              * proccesing.
36              */
37             WidgetStack stack;
38
39             /// Fallback constructor function pointer.
40             Fallback::Constructor* fbNew;
41
42             /// Fallback destructor function pointer.
43             Widget::Destructor* fbDel;
44
45             /// Fallback class name.
46             string fbClass;
47
48         public:
49             /// Widget attributes (FIXME - this must be protected?).
50             Widget* root;
51
52         // Methods.
53         protected:
54             /**
55              * Start document handler.
56              */
57             virtual void on_start_document(void);
58
59             /**
60              * End document handler.
61              */
62             virtual void on_end_document(void);
63
64             /**
65              * Start element handler.
66              *
67              * @param  name  Element name.
68              * @param  attrs Element attributes.
69              */
70             virtual void on_start_element(const string&, const AttributeMap&);
71
72             /**
73              * End element handler.
74              *
75              * @param name Element name.
76              */
77             virtual void on_end_element(const string&);
78
79             /**
80              * Character handler.
81              *
82              * @param chars Characters.
83              */
84             virtual void on_characters(const string&);
85
86             /**
87              * Comment handler.
88              *
89              * @param text Comment text.
90              */
91             virtual void on_comment(const string&);
92
93             /**
94              * Warning handler.
95              *
96              * @param warn Warning description.
97              */
98             virtual void on_warning(const string&);
99
100             /**
101              * Error handler.
102              *
103              * @param error Error description.
104              */
105             virtual void on_error(const string&);
106
107             /**
108              * Fatal error handler.
109              *
110              * @param error Fatal error description.
111              */
112             virtual void on_fatal_error(const string&);
113
114             /**
115              * Validity error handler.
116              *
117              * @param error Validity error description.
118              */
119             virtual void on_validity_error(const string&);
120
121             /**
122              * Validity warning handler.
123              *
124              * @param warn Validity warning description.
125              */
126             virtual void on_validity_warning(const string&);
127
128         public:
129             /**
130              * Constructor.
131              */
132             //Parser(void);
133
134             /**
135              * Constructor.
136              *
137              * @param fallback Fallback class name.
138              */
139             Parser(const string& = "");
140
141             /**
142              * Destructor.
143              */
144             virtual ~Parser(void);
145
146             /**
147              * Renders the widget using a HIT template.
148              *
149              * @param  hit HIT template to use to render de widget.
150              * @return Rendered widget.
151              */
152             //virtual operator string(void) const;
153     };
154
155 }
156
157 #endif