Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::G::MarkupParser Class Reference

A GMarkupParser C++ wrapper interface. More...

`#include <inti/glib/markup.h>`

List of all members.

## Public Member Functions

Constructors

- virtual ~MarkupParser ()
    Destructor.

## Protected Member Functions

Constructors

- MarkupParser ()
    Constructor a new markup parser.

Callback Handlers

- virtual void on_start_element (MarkupParseContext &context, const String &element_name, const std::map< const char *, const char * > &attributes, G::Error &error)
    Called when the opening tag of an element is seen.
- virtual void on_end_element (MarkupParseContext &context, const String &element_name, G::Error &error)
    Called when the closing tag of an element is seen.
- virtual void on_text (MarkupParseContext &context, const String text, G::Error &error)
    Called when some text is seen (text is always inside an element).
- virtual void on_passthrough (MarkupParseContext &context, const String &passthrough_text, G::Error &error)
    Called for comments, processing instructions and doctype declarations; if you're re-writing the parsed document, write the passthrough text back out in the same position.
- virtual void on_error (MarkupParseContext &context, G::Error &error)
    Called when an error occurs.

## Detailed Description

A GMarkupParser C++ wrapper interface.

MarkupParser is an abstract interface class that be can be derived from, or multiplely inherited. It declares five virtual methods that can be overridden. Except for the on_error() method, any of these methods can set an error by calling G::Error::set(); in particular the G_MARKUP_ERROR_UNKNOWN_ELEMENT, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, and G_MARKUP_ERROR_INVALID_CONTENT errors are intended to be set from these methods. If you set an error from a virtual method, G::MarkupParseContext::parse() will report that error back to its caller.

## Member Function Documentation

virtual void Inti::G::MarkupParser::on_end_element | ( | MarkupParseContext & | context,
|  | const String & | element_name,
|  | G::Error & | error
| ) | `[protected, virtual]`

  | Called when the closing tag of an element is seen. Parameters:
  context | The MarkupParseContext.
  element_name | The element name.
  error | A reference to a G::Error to set if an error occurs.
Called for close tags .

virtual void Inti::G::MarkupParser::on_error | ( | MarkupParseContext & | context,
|  | G::Error & | error
| ) | `[protected, virtual]`

  | Called when an error occurs. Parameters:
  context | The MarkupParseContext.
  error | A reference to a G::Error to set if an error occurs.
Called on error, including ones set by the other virtual methods.

virtual void Inti::G::MarkupParser::on_passthrough | ( | MarkupParseContext & | context,
|  | const String & | passthrough_text,
|  | G::Error & | error
| ) | `[protected, virtual]`

  | Called for comments, processing instructions and doctype declarations; if you're re-writing the parsed document, write the passthrough text back out in the same position. Parameters:
  context | The MarkupParseContext.
  passthrough_text | The passthrough text.
  error | A reference to a G::Error to set if an error occurs.
Called for strings that should be re-saved verbatim in the same position, but are not otherwise interpretable. At the moment this includes comments and processing instructions.

virtual void Inti::G::MarkupParser::on_start_element | ( | MarkupParseContext & | context,
|  | const String & | element_name,
|  | const std::map< const char *, const char * > & | attributes,
|  | G::Error & | error
| ) | `[protected, virtual]`

  | Called when the opening tag of an element is seen. Parameters:
  context | The MarkupParseContext.
  element_name | The element name.
  attributes | A map of attribute/value pairs.
  error | A reference to a G::Error to set if an error occurs.
The first value in the attribute map is the attribute name and the second value is the attribute value. You can retrieve the name and value of an attribute by doing something like this:
                 std::map<const char*, const char*>::const_iterator i = attributes.begin();
                 while (i != attributes.end())
                 {
                    g_print("The name is %s and the value is %s\n", (*i).first, (*i).second);
                    ++i;
                 }
Called for open tags .

virtual void Inti::G::MarkupParser::on_text | ( | MarkupParseContext & | context,
|  | const String | text,
|  | G::Error & | error
| ) | `[protected, virtual]`

  | Called when some text is seen (text is always inside an element). Parameters:
  context | The MarkupParseContext.
  text | The parsed text.
  error | A reference to a G::Error to set if an error occurs.
Called for character data.

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

- markup.h

Main Page - Footer