]> git.llucax.com Git - software/bife/bife++.git/blob - parser.h
4eb8e79eba12d0b7132c5bc5c105dcbd0f9839ff
[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 "hit.h"
7 #include "hash.h"
8 #include "widget.h"
9 #include <libxml++/libxml++.h>
10 #include <string>
11 #include <stack>
12
13 namespace bife {
14
15     using std::string;
16
17     /**
18      * Base Widget Class.
19      *
20      * @todo 
21      */
22     class Parser: public xmlpp::SaxParser {
23         // Typedefs.
24         protected:
25             typedef std::stack<Widget*> WidgetStack;
26
27         // Attributes.
28         public:
29             /// Widget attributes.
30             Widget* root;
31
32             /// Stack TODO.
33             WidgetStack stack;
34
35             // TODO Fallback.
36
37         // Methods.
38         protected:
39             /**
40              * Start document handler.
41              */
42             virtual void on_start_document(void);
43
44             /**
45              * End document handler.
46              */
47             virtual void on_end_document(void);
48
49             /**
50              * Start element handler.
51              *
52              * @param  name  Element name.
53              * @param  attrs Element attributes.
54              */
55             virtual void on_start_element(const string&, const AttributeMap&);
56
57             /**
58              * End element handler.
59              *
60              * @param name Element name.
61              */
62             virtual void on_end_element(const string&);
63
64             /**
65              * Character handler.
66              *
67              * @param chars Characters.
68              */
69             virtual void on_characters(const string&);
70
71             /**
72              * Comment handler.
73              *
74              * @param text Comment text.
75              */
76             virtual void on_comment(const string&);
77
78             /**
79              * Warning handler.
80              *
81              * @param warn Warning description.
82              */
83             virtual void on_warning(const string&);
84
85             /**
86              * Error handler.
87              *
88              * @param error Error description.
89              */
90             virtual void on_error(const string&);
91
92             /**
93              * Fatal error handler.
94              *
95              * @param error Fatal error description.
96              */
97             virtual void on_fatal_error(const string&);
98
99             /**
100              * Validity error handler.
101              *
102              * @param error Validity error description.
103              */
104             virtual void on_validity_error(const string&);
105
106             /**
107              * Validity warning handler.
108              *
109              * @param warn Validity warning description.
110              */
111             virtual void on_validity_warning(const string&);
112
113         public:
114             /**
115              * Constructor.
116              */
117             Parser(void);
118
119             /**
120              * Constructor.
121              *
122              * @param fallback Fallback.
123              */
124             //Parser(const Fallback&); TODO
125
126             /**
127              * Destructor.
128              */
129             virtual ~Parser(void);
130
131             /**
132              * Renders the widget using a HIT template.
133              *
134              * @param  hit HIT template to use to render de widget.
135              * @return Rendered widget.
136              */
137             //virtual operator string(void) const;
138     };
139
140 }
141
142 #endif