Edinburgh Speech Tools  2.4-release
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
XML_Parser_Class Class Reference

#include <include/rxp/XML_Parser.h>

Inheritance diagram for XML_Parser_Class:

Public Member Functions

 XML_Parser_Class ()
 
void register_id (EST_Regex id_pattern, EST_String directory)
 
void registered_ids (EST_TList< EST_String > &list)
 
InputSource try_and_open (Entity ent)
 
Creating a parser

Each of these methods creates a one-shot parser which will run over the indicated text.

XML_Parsermake_parser (InputSource source, void *data)
 Create a parser for the RXP InputSource.
 
XML_Parsermake_parser (InputSource source, Entity initial_entity, void *data)
 Create a parser for the RXP InputSource.
 
XML_Parsermake_parser (FILE *input, void *data)
 Create a parser for a stdio input stream.
 
XML_Parsermake_parser (FILE *input, const EST_String desc, void *data)
 
XML_Parsermake_parser (const EST_String filename, void *data)
 

Protected Member Functions

void error (XML_Parser_Class &c, XML_Parser &p, void *data, EST_String message)
 
const char * get_error (XML_Parser &p)
 Get the error message for the last error.
 
The callbacks.

These methods can be overridden in a subclass to create a class of parsers to do whatever you want.

virtual void document_open (XML_Parser_Class &c, XML_Parser &p, void *data)
 
virtual void document_close (XML_Parser_Class &c, XML_Parser &p, void *data)
 
virtual void element_open (XML_Parser_Class &c, XML_Parser &p, void *data, const char *name, XML_Attribute_List &attributes)
 
virtual void element_close (XML_Parser_Class &c, XML_Parser &p, void *data, const char *name)
 
virtual void element (XML_Parser_Class &c, XML_Parser &p, void *data, const char *name, XML_Attribute_List &attributes)
 
virtual void pcdata (XML_Parser_Class &c, XML_Parser &p, void *data, const char *chars)
 
virtual void cdata (XML_Parser_Class &c, XML_Parser &p, void *data, const char *chars)
 
virtual void processing (XML_Parser_Class &c, XML_Parser &p, void *data, const char *instruction)
 
virtual void error (XML_Parser_Class &c, XML_Parser &p, void *data)
 

Static Protected Member Functions

static InputSource open_entity (Entity ent, void *arg)
 

Friends

class XML_Parser
 

Detailed Description

A Class of parsers, All parsers share callbacks and a list of known public IDs.

Definition at line 78 of file XML_Parser.h.

Constructor & Destructor Documentation

XML_Parser_Class::XML_Parser_Class ( )

Create an object representing the class of parsers.

Definition at line 44 of file XML_Parser.cc.

Member Function Documentation

InputSource XML_Parser_Class::open_entity ( Entity  ent,
void *  arg 
)
staticprotected

Do any necessary remappings and open a stream which reads the given entity.

Definition at line 160 of file XML_Parser.cc.

void XML_Parser_Class::document_open ( XML_Parser_Class c,
XML_Parser p,
void *  data 
)
protectedvirtual

Called when starting a document.

Definition at line 169 of file XML_Parser.cc.

void XML_Parser_Class::document_close ( XML_Parser_Class c,
XML_Parser p,
void *  data 
)
protectedvirtual

Called at the end of a document.

Definition at line 174 of file XML_Parser.cc.

void XML_Parser_Class::element_open ( XML_Parser_Class c,
XML_Parser p,
void *  data,
const char *  name,
XML_Attribute_List attributes 
)
protectedvirtual

Called when an element starts.

Definition at line 179 of file XML_Parser.cc.

void XML_Parser_Class::element_close ( XML_Parser_Class c,
XML_Parser p,
void *  data,
const char *  name 
)
protectedvirtual

Called when an element ends.

Definition at line 196 of file XML_Parser.cc.

void XML_Parser_Class::element ( XML_Parser_Class c,
XML_Parser p,
void *  data,
const char *  name,
XML_Attribute_List attributes 
)
protectedvirtual

Called for empty elements.

Defaults to element_open(...) followed by element_closed(...).

Definition at line 186 of file XML_Parser.cc.

void XML_Parser_Class::pcdata ( XML_Parser_Class c,
XML_Parser p,
void *  data,
const char *  chars 
)
protectedvirtual

Called for parsed character data sequences.

Definition at line 202 of file XML_Parser.cc.

void XML_Parser_Class::cdata ( XML_Parser_Class c,
XML_Parser p,
void *  data,
const char *  chars 
)
protectedvirtual

Called for unparsed character data sequences.

Definition at line 208 of file XML_Parser.cc.

void XML_Parser_Class::processing ( XML_Parser_Class c,
XML_Parser p,
void *  data,
const char *  instruction 
)
protectedvirtual

Called for processing directives.

Definition at line 214 of file XML_Parser.cc.

void XML_Parser_Class::error ( XML_Parser_Class c,
XML_Parser p,
void *  data 
)
protectedvirtual

Called when there is an error in parsing.

Definition at line 220 of file XML_Parser.cc.

void XML_Parser_Class::error ( XML_Parser_Class c,
XML_Parser p,
void *  data,
EST_String  message 
)
protected

This can be called from any of the callbacks to present "message" as an error through the error callback, thus getting filename and line information into the message.

Definition at line 230 of file XML_Parser.cc.

void XML_Parser_Class::register_id ( EST_Regex  id_pattern,
EST_String  directory 
)

Add a mapping from entity ID (SYSTEM or PUBLIC) to filename.

The string can contain escapes like \2 which are replaced by the text matching the Nth bracketed part of the regular expression.

Definition at line 48 of file XML_Parser.cc.

void XML_Parser_Class::registered_ids ( EST_TList< EST_String > &  list)

Fill in the list with the known entity ID mappings.

Definition at line 53 of file XML_Parser.cc.

XML_Parser * XML_Parser_Class::make_parser ( FILE *  input,
const EST_String  desc,
void *  data 
)

Create a parser for a stdio input stream, giving a description for use in errors.

Definition at line 78 of file XML_Parser.cc.

InputSource XML_Parser_Class::try_and_open ( Entity  ent)

Utility which tries to open an entity called ID at places specified in the mapping of this parser class.

Definition at line 125 of file XML_Parser.cc.

Friends And Related Function Documentation

friend class XML_Parser
friend

XML_Parser defines the behaviour of an individual one-shot parser.

Definition at line 231 of file XML_Parser.h.


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