1 // vim: set expandtab tabstop=4 shiftwidth=4:
3 // FIXME - ver tema de fallback.
10 using std::stringstream;
19 void Parser::on_start_document(void) {
21 cerr << "In Parser::on_start_document();" << endl;
25 void Parser::on_end_document(void) {
27 cerr << "In Parser::on_end_document();" << endl;
31 void Parser::on_start_element(const string& name, const AttributeMap& attrs) {
33 cerr << "In Parser::on_start_element(name = '" << name << "', attrs = [";
35 Hash::const_iterator last = attrs.end();
37 for (Hash::const_iterator i = attrs.begin(); i != last; i++) { //last; i++) {
38 cerr << i->first << ": '" << i->second << "', ";
40 cerr << last->first << ": '" << last->second << "'";
42 cerr << "]);" << endl;
44 stack.push(new Translate(name, attrs));
47 void Parser::on_end_element(const string& name) {
49 cerr << "In Parser::on_end_element('" << name << "');" << endl;
51 Widget* cur = stack.top();
53 // If is the last widget, it's the root widget.
56 // If is not the last widget, we add it as content of his parent.
58 Container* par = dynamic_cast<Container*>(stack.top());
59 // If the parent is a Container, we add curent widget as content.
62 // If not, we raise an exception TODO
64 throw "Trying to add content to a non-container widget.";
69 void Parser::on_characters(const string& chars) {
71 cerr << "In Parser::on_characters('" << chars << "');" << endl;
74 Container* cur = dynamic_cast<Container*>(stack.top());
75 // If we are in a Container, we add curent string widget as content.
77 cur->append(new String(chars));
78 // If not, we raise an exception TODO
80 throw "Trying to add content to a non-container widget.";
83 // FIXME - investigar si tiene sentido.
84 throw "Characters with no tags!!!?!?!?!";
88 void Parser::on_comment(const string& text) {
90 cerr << "In Parser::on_comment('" << text << "');" << endl;
94 void Parser::on_warning(const string& warn) {
96 cerr << "In Parser::on_warning('" << warn << "');" << endl;
100 void Parser::on_error(const string& error) {
102 cerr << "In Parser::on_error('" << error << "');" << endl;
106 void Parser::on_fatal_error(const string& error) {
108 cerr << "In Parser::on_fatal_error('" << error << "');" << endl;
112 void Parser::on_validity_error(const string& error) {
114 cerr << "In Parser::on_validity_error('" << error << "');" << endl;
118 void Parser::on_validity_warning(const string& warn) {
120 cerr << "In Parser::on_validity_warning('" << warn << "');" << endl;
124 Parser::Parser(void): root(NULL) {
126 cerr << "In Parser::Parser();" << endl;
130 //Parser::Parser(const Hash& attrs): attrs(attrs) {
132 // cerr << "In Parser::Parser(attrs = {" /* TODO << attrs */ << "});" << endl;
136 Parser::~Parser(void) {
138 cerr << "In Parser destructor." << endl;
142 Parser::operator string(void) const {