xml_text_reader Class Reference

#include <xmltextread.h>

Inheritance diagram for xml_text_reader:

xml_text_reader_by_node

Public Member Functions

virtual ~xml_text_reader ()
 xml_text_reader (input &deeper, bool validate=false)
void parse ()

Protected Member Functions

virtual void process_node ()=0
virtual void process_node_end (bool empty)
int depth ()
xmlReaderTypes node_type ()
const xmlChar * name ()
int is_empty_element ()
int has_value ()
const xmlChar * value ()
void move_back_to_element ()

Static Protected Member Functions

static const char * xmlReaderType_ename (xmlReaderTypes)

Private Member Functions

int read_deeper (char *buffer, int len)
void close ()
void error (const char *msg, xmlParserSeverities severity, xmlTextReaderLocatorPtr locator)
bool read ()
 xml_text_reader ()
 xml_text_reader (const xml_text_reader &)
xml_text_readeroperator= (const xml_text_reader &)

Static Private Member Functions

static int read_callback (void *context, char *buffer, int len)
static int close_callback (void *context)
static void error_callback (void *context, const char *msg, xmlParserSeverities severity, xmlTextReaderLocatorPtr locator)

Private Attributes

input deeper
xmlTextReaderPtr reader
int number_of_errors
bool validate

Static Private Attributes

static int number_of_parsers

Detailed Description

The xml_text_reader class is used to represent an XML stream reader. It uses the xmlTextReader* functions from the GNOME libxml2 library.

Definition at line 56 of file xmltextread.h.


Constructor & Destructor Documentation

virtual xml_text_reader::~xml_text_reader (  )  [virtual]

The destructor.

xml_text_reader::xml_text_reader ( input deeper,
bool  validate = false 
)

The constructor.

xml_text_reader::xml_text_reader (  )  [private]

The default constructor. Do not use.

xml_text_reader::xml_text_reader ( const xml_text_reader  )  [private]

The copy constructor. Do not use.


Member Function Documentation

void xml_text_reader::parse (  ) 

The parse method is used to parse the given file. Each element will cause the process_node() method to be called.

virtual void xml_text_reader::process_node (  )  [protected, pure virtual]

The process_node method is used to process each node as it is read from the input. Each derived class must supply its own process_node method.

Implemented in xml_text_reader_by_node.

virtual void xml_text_reader::process_node_end ( bool  empty  )  [protected, virtual]

The process_node_end method is only ever called for ELEMENT nodes, and only after all of the attributes have been given to the process_node method.

The default implimentation does nothing.

Parameters:
empty Whether or not the original ELEMENT node was empty.

Reimplemented in xml_text_reader_by_node.

int xml_text_reader::depth (  )  [inline, protected]

The depth method is used to obtain the depth of the current node in the tree.

Returns:
the depth or -1 in case of error

Definition at line 102 of file xmltextread.h.

xmlReaderTypes xml_text_reader::node_type (  )  [inline, protected]

The node_type method is used to get the node type of the current node.

Returns:
the xmlNodeType of the current node or -1 in case of error
See also:
http://dotgnu.org/pnetlib-doc/System/Xml/XmlNodeType.html

Definition at line 115 of file xmltextread.h.

static const char* xml_text_reader::xmlReaderType_ename ( xmlReaderTypes   )  [static, protected]

The xmlReaderType_ename class method is used to obtain the text equivalent of a node type.

const xmlChar* xml_text_reader::name (  )  [inline, protected]

The name method is used to determine the qualified name of the current node, equal to Prefix:LocalName.

Returns:
the node name or NULL if not available

Definition at line 133 of file xmltextread.h.

int xml_text_reader::is_empty_element (  )  [inline, protected]

The is_empty_element method is used to check if the current node is empty.

Returns:
1 if empty, 0 if not and -1 in case of error

Definition at line 142 of file xmltextread.h.

int xml_text_reader::has_value (  )  [inline, protected]

The has_value method is used to determine whether or not the current node has a text value.

Returns:
1 if true, 0 if false, and -1 in case or error

Definition at line 151 of file xmltextread.h.

const xmlChar* xml_text_reader::value (  )  [inline, protected]

The value method is used to provide the text value of the current node if present.

Returns:
the string or NULL if not available. The result must be deallocated with xmlFree()

Definition at line 161 of file xmltextread.h.

void xml_text_reader::move_back_to_element (  )  [inline, protected]

The move_back_to_element method is used after parsing the element attributes to move the reader pointer back to the element node once again so that the name is again available.

Definition at line 168 of file xmltextread.h.

static int xml_text_reader::read_callback ( void *  context,
char *  buffer,
int  len 
) [static, private]

The read_callback class method is used to handle callbacks by the parser. It calls the read_deeper method.

int xml_text_reader::read_deeper ( char *  buffer,
int  len 
) [private]

The read_deeper method is used by the read_callback class method is used to obtain the next block of input.

static int xml_text_reader::close_callback ( void *  context  )  [static, private]

The close_callback class method is used to handle callbacks by the parser when end of inpout is reached.

void xml_text_reader::close (  )  [private]

The close method is called by the parser when it gets to the end of the input.

static void xml_text_reader::error_callback ( void *  context,
const char *  msg,
xmlParserSeverities  severity,
xmlTextReaderLocatorPtr  locator 
) [static, private]

The error_callback class method is used to handle callbacks by the parser when an error is seen.

void xml_text_reader::error ( const char *  msg,
xmlParserSeverities  severity,
xmlTextReaderLocatorPtr  locator 
) [private]

the error method is used to report errors and warnings detected during the parse.

bool xml_text_reader::read (  )  [private]

The read method is used to read one node from the input, and process it via the veirtual process_node method. If there is an error, it is reported in a fatal error message, and this function does not return.

Returns:
If end of file is reached, false is returned. If there is not error, true is returned.

xml_text_reader& xml_text_reader::operator= ( const xml_text_reader  )  [private]

The assignment operator. Do not use.


Field Documentation

The deeper instance variable is used to remember the deeper input stream which the XML parser will use to obtain its input.

Definition at line 175 of file xmltextread.h.

xmlTextReaderPtr xml_text_reader::reader [private]

The reader instance variable is used to remember the location of the opaque xml_text_reader data store.

Definition at line 181 of file xmltextread.h.

The number_of_errors instance variable is used to remember how many errors have been detected to date in the parsing of the input stream.

Definition at line 188 of file xmltextread.h.

int xml_text_reader::number_of_parsers [static, private]

The number_of_parsers class variable is used to remember how many instances are currently active. This lets us initialise and clean up after the xml2 library.

Definition at line 195 of file xmltextread.h.

bool xml_text_reader::validate [private]

The validate instance variable is used to remember whether or not we are validating the data against the DTD.

Definition at line 201 of file xmltextread.h.


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

Generated on Wed Mar 12 23:37:45 2008 for Aegis by  doxygen 1.5.5