00001 /* 00002 00003 This file is part of Kitlist, a program to maintain a simple list 00004 of items and assign items to one or more categories. 00005 00006 Copyright (C) 2008,2009 Frank Dean 00007 00008 Kitlist is free software: you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation, either version 3 of the License, or 00011 (at your option) any later version. 00012 00013 Kitlist is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with Kitlist. If not, see <http://www.gnu.org/licenses/>. 00020 00021 */ 00022 00023 #ifndef KIT_PARSER_H 00024 #define KIT_PARSER_H 1 00025 00026 #include <libxml++/libxml++.h> 00027 00028 #include "kitmodel.hpp" 00029 00030 00035 class KitParser : public xmlpp::SaxParser { 00036 private: 00037 ModelCategory* m_category; 00038 ModelItem* m_item; 00039 Glib::ustring m_cdata; 00040 void process_item(const AttributeList& attributes); 00041 void process_category(const AttributeList& attributes); 00042 void process_category_item(const AttributeList& attributes); 00043 public: 00045 KitParser(KitModel& model) : xmlpp::SaxParser(), m_model(model), m_category(NULL), m_item(NULL) {} 00046 virtual ~KitParser() {} 00047 protected: 00048 KitModel& m_model; 00049 virtual void on_start_document(); 00050 virtual void on_end_document(); 00051 virtual void on_start_element(const Glib::ustring& name, 00052 const AttributeList& attributes); 00053 virtual void on_end_element(const Glib::ustring& name); 00054 virtual void on_characters(const Glib::ustring& text); 00055 virtual void on_comment(const Glib::ustring& text); 00056 virtual void on_warning(const Glib::ustring& text); 00057 virtual void on_error(const Glib::ustring& text); 00058 virtual void on_fatal_error(const Glib::ustring& text); 00059 00060 }; 00061 00062 #endif // KIT_PARSER_H