Kitlist  1.1.0
kitparser.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of Kitlist, a program to maintain a simple list
4  of items and assign items to one or more categories.
5 
6  Copyright (C) 2008,2009 Frank Dean
7 
8  Kitlist is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Kitlist is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Kitlist. If not, see <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifndef KIT_PARSER_H
24 #define KIT_PARSER_H 1
25 
26 #include <libxml++/libxml++.h>
27 
28 #include "kitmodel.hpp"
29 
30 
35 class KitParser : public xmlpp::SaxParser {
36  private:
39  Glib::ustring m_cdata;
40  void process_item(const AttributeList& attributes);
41  void process_category(const AttributeList& attributes);
42  void process_category_item(const AttributeList& attributes);
43  public:
45  KitParser(KitModel& model) : xmlpp::SaxParser(), m_model(model), m_category(NULL), m_item(NULL) {}
46  virtual ~KitParser() {}
47  protected:
49  virtual void on_start_document();
50  virtual void on_end_document();
51  virtual void on_start_element(const Glib::ustring& name,
52  const AttributeList& attributes);
53  virtual void on_end_element(const Glib::ustring& name);
54  virtual void on_characters(const Glib::ustring& text);
55  virtual void on_comment(const Glib::ustring& text);
56  virtual void on_warning(const Glib::ustring& text);
57  virtual void on_error(const Glib::ustring& text);
58  virtual void on_fatal_error(const Glib::ustring& text);
59 
60 };
61 
62 #endif // KIT_PARSER_H
virtual void on_error(const Glib::ustring &text)
Outputs any errors to STDOUT.
Definition: kitparser.cpp:183
virtual void on_start_element(const Glib::ustring &name, const AttributeList &attributes)
Called for each element.
Definition: kitparser.cpp:115
virtual void on_end_document()
Does nothing. Called at the end of a document.
Definition: kitparser.cpp:35
ModelItem * m_item
The most recently processed item element.
Definition: kitparser.hpp:38
void process_item(const AttributeList &attributes)
<The most recently processed CDATA
Definition: kitparser.cpp:45
Represents a Category combined with GuiState attributes.
Definition: kitmodel.hpp:94
SaxParser implementation for reading the KitModel from an XML document.
Definition: kitparser.hpp:35
virtual void on_comment(const Glib::ustring &text)
Does nothing. Called for each comment.
Definition: kitparser.cpp:171
virtual void on_warning(const Glib::ustring &text)
Outputs any warnings to STDOUT.
Definition: kitparser.cpp:177
Glib::ustring m_cdata
Definition: kitparser.hpp:39
void process_category(const AttributeList &attributes)
Reads a category&#39;s attributes from a &#39;category&#39; element.
Definition: kitparser.cpp:68
virtual void on_characters(const Glib::ustring &text)
Called for each piece of CDATA belonging to an element.
Definition: kitparser.cpp:164
virtual void on_end_element(const Glib::ustring &name)
Called at the end of each element.
Definition: kitparser.cpp:141
Represents an Item combined with GuiState attributes.
Definition: kitmodel.hpp:60
Holds a rich graph of objects representing the application&#39;s data model.
Definition: kitmodel.hpp:135
virtual void on_fatal_error(const Glib::ustring &text)
Outputs any fatal errors to STDOUT.
Definition: kitparser.cpp:189
virtual void on_start_document()
Does nothing. Called at the start of a document.
Definition: kitparser.cpp:29
ModelCategory * m_category
The most recently processed category element.
Definition: kitparser.hpp:37
void process_category_item(const AttributeList &attributes)
Reads details of an item association with a category from a &#39;category-item&#39; element.
Definition: kitparser.cpp:87
KitParser(KitModel &model)
Constructor taking the rich data model to save the XML document within.
Definition: kitparser.hpp:45
virtual ~KitParser()
Definition: kitparser.hpp:46
KitModel & m_model
Definition: kitparser.hpp:48

Copyright 2008-2021 Frank Dean