Kitlist  1.1.0
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
KitParser Class Reference

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

#include <kitparser.hpp>

Inheritance diagram for KitParser:

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

KitModelm_model
 

Private Member Functions

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

Private Attributes

ModelCategorym_category
 The most recently processed category element. More...
 
ModelItemm_item
 The most recently processed item element. More...
 
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::KitParser ( KitModel model)
inline

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

Definition at line 45 of file kitparser.hpp.

◆ ~KitParser()

virtual KitParser::~KitParser ( )
inlinevirtual

Definition at line 46 of file kitparser.hpp.

Member Function Documentation

◆ on_characters()

void KitParser::on_characters ( const Glib::ustring &  text)
protectedvirtual

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.

◆ on_comment()

void KitParser::on_comment ( const Glib::ustring &  text)
protectedvirtual

Does nothing. Called for each comment.

Definition at line 171 of file kitparser.cpp.

◆ on_end_document()

void KitParser::on_end_document ( )
protectedvirtual

Does nothing. Called at the end of a document.

Definition at line 35 of file kitparser.cpp.

◆ on_end_element()

void KitParser::on_end_element ( const Glib::ustring &  name)
protectedvirtual

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().

◆ on_error()

void KitParser::on_error ( const Glib::ustring &  text)
protectedvirtual

Outputs any errors to STDOUT.

Definition at line 183 of file kitparser.cpp.

◆ on_fatal_error()

void KitParser::on_fatal_error ( const Glib::ustring &  text)
protectedvirtual

Outputs any fatal errors to STDOUT.

Definition at line 189 of file kitparser.cpp.

◆ on_start_document()

void KitParser::on_start_document ( )
protectedvirtual

Does nothing. Called at the start of a document.

Definition at line 29 of file kitparser.cpp.

◆ on_start_element()

void KitParser::on_start_element ( const Glib::ustring &  name,
const AttributeList &  attributes 
)
protectedvirtual

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().

◆ on_warning()

void KitParser::on_warning ( const Glib::ustring &  text)
protectedvirtual

Outputs any warnings to STDOUT.

Definition at line 177 of file kitparser.cpp.

◆ process_category()

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

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

Parameters
attributesThe 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().

◆ process_category_item()

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

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

Parameters
attributesThe 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().

◆ process_item()

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

<The most recently processed CDATA

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

Parameters
attributesThe 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().

Member Data Documentation

◆ m_category

ModelCategory* KitParser::m_category
private

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().

◆ m_cdata

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().

◆ m_item

ModelItem* KitParser::m_item
private

The most recently processed item element.

Definition at line 38 of file kitparser.hpp.

Referenced by on_end_element(), and process_item().

◆ m_model

KitModel& KitParser::m_model
protected

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-2021 Frank Dean