Main Page | Class Hierarchy | Class List | File List | Class Members

xml::tree_parser Class Reference

The xml::tree_parser class is used to parse an XML document and generate a tree like structure of xml::node objects. More...

#include <tree_parser.h>

List of all members.

Public Member Functions

 tree_parser (const char *filename, bool allow_exceptions=true)
 xml::tree_parser class constructor.

 tree_parser (const char *data, size_type size, bool allow_exceptions=true)
 xml::tree_parser class constructor.

 ~tree_parser (void)
 xml::tree_parser class destructor.

bool operator! (void) const
 Check to see if a xml::tree_parser class is vaild.

const std::string & get_error_message (void) const
 If operator! indicates that there was an error parsing your XML data, you can use this member function to get the error message that was generated durring parsing.

bool had_warnings (void) const
 Check to see if there were any warnings from the parser while processing the given XML data.

xml::documentget_document (void)
 Get a reference to the xml::document that was generated during the XML parsing.

const xml::documentget_document (void) const
 Get a const reference to the xml::document that was generate during the XML parsing.


Detailed Description

The xml::tree_parser class is used to parse an XML document and generate a tree like structure of xml::node objects.

After constructing a tree_parser, with either a file to parse or some in memory data to parse, you can walk the tree using the xml::node interface.


Constructor & Destructor Documentation

xml::tree_parser::tree_parser const char *  filename,
bool  allow_exceptions = true
 

xml::tree_parser class constructor.

Given the name of a file, this constructor will parse that file.

There are two options for dealing with XML parsing errors. The default it to throw an exception (std::runtime_error). The other option is to pass false for the allow_exceptions flag. This will prevent an exception from being thrown, instead, a flag will be set that you can test with the operator! member function.

No matter what option you choose, this constructor may still throw exceptions for memory failure or other non-parsing related failures.

Parameters:
filename The name of the file to parse.
allow_exceptions Whether or not you want an exception for parsing errors.
Author:
Peter Jones

xml::tree_parser::tree_parser const char *  data,
size_type  size,
bool  allow_exceptions = true
 

xml::tree_parser class constructor.

Given some data and the size of that data, parse that data as XML. To see if the data was parsed successfully use operator!.

Parameters:
data The XML data to parse.
size The size of the XML data to parse.
allow_exceptions Whether or not you want an exception for parsing errors.
Author:
Peter Jones

xml::tree_parser::~tree_parser void   ) 
 

xml::tree_parser class destructor.

Author:
Peter Jones


Member Function Documentation

const xml::document& xml::tree_parser::get_document void   )  const
 

Get a const reference to the xml::document that was generate during the XML parsing.

You should make sure to only use a reference to the document to avoid a deep copy.

Returns:
A const reference to the xml::document.
Author:
Peter Jones

xml::document& xml::tree_parser::get_document void   ) 
 

Get a reference to the xml::document that was generated during the XML parsing.

You should make sure to only use a reference to the document to avoid a deep copy.

Returns:
A reference to the xml::document.
Author:
Peter Jones

const std::string& xml::tree_parser::get_error_message void   )  const
 

If operator! indicates that there was an error parsing your XML data, you can use this member function to get the error message that was generated durring parsing.

Returns:
The error message generated durring XML parsing.
Author:
Peter Jones

bool xml::tree_parser::had_warnings void   )  const
 

Check to see if there were any warnings from the parser while processing the given XML data.

If there were, you may want to send the same document through xmllint or the event_parser to catch and review the warning messages.

Returns:
True if there were any warnings.

False if there were no warnings.

Author:
Peter Jones

bool xml::tree_parser::operator! void   )  const
 

Check to see if a xml::tree_parser class is vaild.

That is, check to see if parsing XML data was successful and the tree_parser holds a good XML node tree.

Returns:
True if the tree_parser is NOT VAILD; false if it is vaild.
Author:
Peter Jones


The documentation for this class was generated from the following file:
Generated on Tue Oct 19 12:26:03 2004 for xmlwrapp by doxygen 1.3.6