KitParser Class Reference

SaxParser implementation for reading the KitModel from an XML document. More...

#include <kitparser.hpp>

List of all members.

Public Member Functions

 KitParser (KitModel &model)
 Constructor taking the rich data model to save the XML document within.
virtual ~KitParser ()

Protected Member Functions

virtual void on_start_document ()
 Does nothing. Called at the start of a document.
virtual void on_end_document ()
 Does nothing. Called at the end of a document.
virtual void on_start_element (const Glib::ustring &name, const AttributeList &attributes)
 Called for each element.
virtual void on_end_element (const Glib::ustring &name)
 Called at the end of each element.
virtual void on_characters (const Glib::ustring &text)
 Called for each piece of CDATA belonging to an element.
virtual void on_comment (const Glib::ustring &text)
 Does nothing. Called for each comment.
virtual void on_warning (const Glib::ustring &text)
 Outputs any warnings to STDOUT.
virtual void on_error (const Glib::ustring &text)
 Outputs any errors to STDOUT.
virtual void on_fatal_error (const Glib::ustring &text)
 Outputs any fatal errors to STDOUT.

Protected Attributes

KitModelm_model

Private Member Functions

void process_item (const AttributeList &attributes)
 <The most recently processed CDATA
void process_category (const AttributeList &attributes)
 Reads a category's attributes from a 'category' element.
void process_category_item (const AttributeList &attributes)
 Reads details of an item association with a category from a 'category-item' element.

Private Attributes

ModelCategorym_category
 The most recently processed category element.
ModelItemm_item
 The most recently processed item element.
Glib::ustring m_cdata


Detailed Description

SaxParser implementation for reading the KitModel from an XML document.

Definition at line 35 of file kitparser.hpp.


Constructor & Destructor Documentation

KitParser::KitParser ( KitModel model  )  [inline]

Constructor taking the rich data model to save the XML document within.

Definition at line 45 of file kitparser.hpp.

virtual KitParser::~KitParser (  )  [inline, virtual]

Definition at line 46 of file kitparser.hpp.


Member Function Documentation

void KitParser::process_item ( const AttributeList &  attributes  )  [private]

<The most recently processed CDATA

Reads an item's attributes from an 'item' element.

Parameters:
attributes The list of attributes for the element.

Definition at line 45 of file kitparser.cpp.

References KitModel::add_item(), m_item, m_model, ModelItem::set_checked(), and Item::set_id().

Referenced by on_start_element().

void KitParser::process_category ( const AttributeList &  attributes  )  [private]

Reads a category's attributes from a 'category' element.

Parameters:
attributes The list of attributes for the element.

Definition at line 68 of file kitparser.cpp.

References KitModel::add_category(), m_category, m_model, and Category::set_id().

Referenced by on_start_element().

void KitParser::process_category_item ( const AttributeList &  attributes  )  [private]

Reads details of an item association with a category from a 'category-item' element.

Parameters:
attributes The list of attributes for the element.

Definition at line 87 of file kitparser.cpp.

References ModelCategory::add_item(), KitModel::find_item(), Category::get_id(), m_category, and m_model.

Referenced by on_start_element().

void KitParser::on_start_document (  )  [protected, virtual]

Does nothing. Called at the start of a document.

Definition at line 29 of file kitparser.cpp.

void KitParser::on_end_document (  )  [protected, virtual]

Does nothing. Called at the end of a document.

Definition at line 35 of file kitparser.cpp.

void KitParser::on_start_element ( const Glib::ustring &  name,
const AttributeList &  attributes 
) [protected, virtual]

Called for each element.

Determines which element is being processed and calls appropriate method to process the corresponding attributes.

Definition at line 115 of file kitparser.cpp.

References m_cdata, process_category(), process_category_item(), and process_item().

void KitParser::on_end_element ( const Glib::ustring &  name  )  [protected, virtual]

Called at the end of each element.

If any CDATA existed in the element body, sets the text belonging to the appropriate element object with the previously captured CDATA.

Definition at line 141 of file kitparser.cpp.

References m_category, m_cdata, m_item, Item::set_description(), and Category::set_name().

void KitParser::on_characters ( const Glib::ustring &  text  )  [protected, virtual]

Called for each piece of CDATA belonging to an element.

This may be called a number of times, each time passing a bit more of the parsed CDATA. The processing of the CDATA is split up by any embedded entities.

The CDATA is held in a private member variable. The CDATA variable is cleared at the start of each new element and appended to at each call to this method. The captured text is then set on the appropriate object during KitParser::on_end_element().

Definition at line 164 of file kitparser.cpp.

References m_cdata.

void KitParser::on_comment ( const Glib::ustring &  text  )  [protected, virtual]

Does nothing. Called for each comment.

Definition at line 171 of file kitparser.cpp.

void KitParser::on_warning ( const Glib::ustring &  text  )  [protected, virtual]

Outputs any warnings to STDOUT.

Definition at line 177 of file kitparser.cpp.

void KitParser::on_error ( const Glib::ustring &  text  )  [protected, virtual]

Outputs any errors to STDOUT.

Definition at line 183 of file kitparser.cpp.

void KitParser::on_fatal_error ( const Glib::ustring &  text  )  [protected, virtual]

Outputs any fatal errors to STDOUT.

Definition at line 189 of file kitparser.cpp.


Member Data Documentation

The most recently processed category element.

Definition at line 37 of file kitparser.hpp.

Referenced by on_end_element(), process_category(), and process_category_item().

The most recently processed item element.

Definition at line 38 of file kitparser.hpp.

Referenced by on_end_element(), and process_item().

Glib::ustring KitParser::m_cdata [private]

Definition at line 39 of file kitparser.hpp.

Referenced by on_characters(), on_end_element(), and on_start_element().

Definition at line 48 of file kitparser.hpp.

Referenced by process_category(), process_category_item(), and process_item().


The documentation for this class was generated from the following files:

Copyright 2008-2010 Frank Dean