libxml++ 2.35.1
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes
xmlpp::Parser Class Reference

XML parser. More...

#include <libxml++/parsers/parser.h>

Inheritance diagram for xmlpp::Parser:
Inheritance graph
[legend]
Collaboration diagram for xmlpp::Parser:
Collaboration graph
[legend]

List of all members.

Public Types

typedef unsigned int size_type

Public Member Functions

 Parser ()
virtual ~Parser ()
virtual void set_validate (bool val=true)
 By default, the parser will not validate the XML file.
virtual bool get_validate () const
 See set_validate()
virtual void set_substitute_entities (bool val=true)
 Set whether the parser will automatically substitute entity references with the text of the entities' definitions.
virtual bool get_substitute_entities () const
 See set_substitute_entities().
void set_throw_messages (bool val=true)
 Set whether the parser will collect and throw error and warning messages.
bool get_throw_messages () const
 See set_throw_messages().
virtual void parse_file (const Glib::ustring& filename)=0
 Parse an XML document from a file.
virtual void parse_memory (const Glib::ustring& contents)=0
 Parse an XML document from a string.
virtual void parse_stream (std::istream& in)=0
 Parse an XML document from a stream.

Protected Types

enum  MsgType {
  MsgParserError,
  MsgParserWarning,
  MsgValidityError,
  MsgValidityWarning
}

Protected Member Functions

virtual void initialize_context ()
virtual void release_underlying ()
virtual void on_validity_error (const Glib::ustring& message)
virtual void on_validity_warning (const Glib::ustring& message)
virtual void handleException (const exception& e)
virtual void check_for_exception ()
virtual void check_for_validity_messages ()

Static Protected Member Functions

static void callback_parser_error (void* ctx, const char* msg,...)
static void callback_parser_warning (void* ctx, const char* msg,...)
static void callback_validity_error (void* ctx, const char* msg,...)
static void callback_validity_warning (void* ctx, const char* msg,...)
static void callback_error_or_warning (MsgType msg_type, void* ctx, const char* msg, va_list var_args)

Protected Attributes

_xmlParserCtxt* context_
exceptionexception_
Glib::ustring validate_error_
Glib::ustring validate_warning_
bool validate_
bool substitute_entities_

Detailed Description

XML parser.


Member Typedef Documentation

typedef unsigned int xmlpp::Parser::size_type

Member Enumeration Documentation

enum xmlpp::Parser::MsgType [protected]
Enumerator:
MsgParserError 
MsgParserWarning 
MsgValidityError 
MsgValidityWarning 

Constructor & Destructor Documentation

xmlpp::Parser::Parser ( )
virtual xmlpp::Parser::~Parser ( ) [virtual]

Member Function Documentation

static void xmlpp::Parser::callback_error_or_warning ( MsgType  msg_type,
void *  ctx,
const char *  msg,
va_list  var_args 
) [static, protected]
static void xmlpp::Parser::callback_parser_error ( void *  ctx,
const char *  msg,
  ... 
) [static, protected]
static void xmlpp::Parser::callback_parser_warning ( void *  ctx,
const char *  msg,
  ... 
) [static, protected]
static void xmlpp::Parser::callback_validity_error ( void *  ctx,
const char *  msg,
  ... 
) [static, protected]
static void xmlpp::Parser::callback_validity_warning ( void *  ctx,
const char *  msg,
  ... 
) [static, protected]
virtual void xmlpp::Parser::check_for_exception ( ) [protected, virtual]
virtual void xmlpp::Parser::check_for_validity_messages ( ) [protected, virtual]
virtual bool xmlpp::Parser::get_substitute_entities ( ) const [virtual]

See set_substitute_entities().

Returns:
Whether entities will be substituted during parsing.
bool xmlpp::Parser::get_throw_messages ( ) const

See set_throw_messages().

Since libxml++ 2.36:
Returns:
Whether messages will be collected and thrown in an exception. The default with only validation messages thrown is returned as false.
virtual bool xmlpp::Parser::get_validate ( ) const [virtual]

See set_validate()

Returns:
Whether the parser will validate the XML file.
virtual void xmlpp::Parser::handleException ( const exception e) [protected, virtual]
virtual void xmlpp::Parser::initialize_context ( ) [protected, virtual]
virtual void xmlpp::Parser::on_validity_error ( const Glib::ustring message) [protected, virtual]
virtual void xmlpp::Parser::on_validity_warning ( const Glib::ustring message) [protected, virtual]
virtual void xmlpp::Parser::parse_file ( const Glib::ustring filename) [pure virtual]

Parse an XML document from a file.

Exceptions:
exception
Parameters:
filenameThe path to the file.

Implemented in xmlpp::SaxParser, and xmlpp::DomParser.

virtual void xmlpp::Parser::parse_memory ( const Glib::ustring contents) [pure virtual]

Parse an XML document from a string.

Exceptions:
exception
Parameters:
contentsThe XML document as a string.

Implemented in xmlpp::SaxParser, and xmlpp::DomParser.

virtual void xmlpp::Parser::parse_stream ( std::istream &  in) [pure virtual]

Parse an XML document from a stream.

Exceptions:
exception
Parameters:
inThe stream.

Implemented in xmlpp::SaxParser, and xmlpp::DomParser.

virtual void xmlpp::Parser::release_underlying ( ) [protected, virtual]

Reimplemented in xmlpp::SaxParser, and xmlpp::DomParser.

virtual void xmlpp::Parser::set_substitute_entities ( bool  val = true) [virtual]

Set whether the parser will automatically substitute entity references with the text of the entities' definitions.

For instance, this affects the text returned by ContentNode::get_content(). By default, the parser will not substitute entities, so that you do not lose the entity reference information.

Parameters:
valWhether entities will be substitued.
void xmlpp::Parser::set_throw_messages ( bool  val = true)

Set whether the parser will collect and throw error and warning messages.

If messages are collected, they are included in an exception thrown at the end of parsing. If the messages are not collected, they are written on stderr. The messages written on stderr are slightly different, and may be preferred in a program started from the command-line.

The default, if set_throw_messages() is not called, is to collect and throw only messages from validation. Other messages are written to stderr. This is for backward compatibility, and may change in the future.

Since libxml++ 2.36:
Parameters:
valWhether messages will be collected and thrown in an exception.
virtual void xmlpp::Parser::set_validate ( bool  val = true) [virtual]

By default, the parser will not validate the XML file.

Parameters:
valWhether the document should be validated.

Member Data Documentation

_xmlParserCtxt* xmlpp::Parser::context_ [protected]
bool xmlpp::Parser::validate_ [protected]

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