libxml++
3.2.3
|
XML parser. More...
#include <libxml++/parsers/parser.h>
Public Types | |
using | size_type = unsigned int |
Public Member Functions | |
LIBXMLPP_API | Parser () |
LIBXMLPP_API | ~Parser () override |
LIBXMLPP_API bool | get_include_default_attributes () noexcept |
See set_include_default_attributes(). More... | |
LIBXMLPP_API void | get_parser_options (int& set_options, int& clear_options) noexcept |
See set_parser_options(). More... | |
LIBXMLPP_API bool | get_substitute_entities () const noexcept |
See set_substitute_entities(). More... | |
LIBXMLPP_API bool | get_throw_messages () const noexcept |
See set_throw_messages(). More... | |
LIBXMLPP_API bool | get_validate () const noexcept |
See set_validate(). More... | |
virtual LIBXMLPP_API void | parse_file (const std::string& filename)=0 |
Parse an XML document from a file. More... | |
virtual LIBXMLPP_API void | parse_memory (const Glib::ustring& contents)=0 |
Parse an XML document from a string. More... | |
virtual LIBXMLPP_API void | parse_memory_raw (const unsigned char* contents, size_type bytes_count)=0 |
Parse an XML document from raw memory. More... | |
virtual LIBXMLPP_API void | parse_stream (std::istream& in)=0 |
Parse an XML document from a stream. More... | |
LIBXMLPP_API void | set_include_default_attributes (bool val=true) noexcept |
Set whether default attribute values from the DTD shall be included in the node tree. More... | |
LIBXMLPP_API void | set_parser_options (int set_options=0, int clear_options=0) noexcept |
Set and/or clear parser option flags. More... | |
LIBXMLPP_API void | set_substitute_entities (bool val=true) noexcept |
Set whether the parser will automatically substitute entity references with the text of the entities' definitions. More... | |
LIBXMLPP_API void | set_throw_messages (bool val=true) noexcept |
Set whether the parser will collect and throw error and warning messages. More... | |
LIBXMLPP_API void | set_validate (bool val=true) noexcept |
By default, the parser will not validate the XML file. More... | |
Protected Types | |
enum class | MsgType { ParserError , ParserWarning , ValidityError , ValidityWarning } |
Protected Member Functions | |
virtual LIBXMLPP_API void | check_for_error_and_warning_messages () |
virtual LIBXMLPP_API void | check_for_exception () |
int | get_xinclude_options_internal () const noexcept |
virtual LIBXMLPP_API void | handle_exception () |
To be called in an exception handler. More... | |
virtual LIBXMLPP_API void | initialize_context () |
virtual LIBXMLPP_API void | on_parser_error (const Glib::ustring& message) |
virtual LIBXMLPP_API void | on_parser_warning (const Glib::ustring& message) |
virtual LIBXMLPP_API void | on_validity_error (const Glib::ustring& message) |
virtual LIBXMLPP_API void | on_validity_warning (const Glib::ustring& message) |
virtual LIBXMLPP_API void | release_underlying () |
void | set_xinclude_options_internal (int xinclude_options) noexcept |
![]() | |
NonCopyable () noexcept | |
NonCopyable (const NonCopyable&)=delete | |
NonCopyable (NonCopyable&&)=delete | |
virtual | ~NonCopyable () |
NonCopyable& | operator= (const NonCopyable&)=delete |
NonCopyable& | operator= (NonCopyable&&)=delete |
Static Protected Member Functions | |
static LIBXMLPP_API void | callback_error_or_warning (MsgType msg_type, void* ctx, const char* msg, va_list var_args) |
static LIBXMLPP_API void | callback_parser_error (void* ctx, const char* msg,...) |
static LIBXMLPP_API void | callback_parser_warning (void* ctx, const char* msg,...) |
static LIBXMLPP_API void | callback_validity_error (void* ctx, const char* msg,...) |
static LIBXMLPP_API void | callback_validity_warning (void* ctx, const char* msg,...) |
Protected Attributes | |
_xmlParserCtxt* | context_ |
std::unique_ptr< exception > | exception_ |
XML parser.
Abstract base class for DOM parser and SAX parser.
using xmlpp::Parser::size_type = unsigned int |
|
strongprotected |
LIBXMLPP_API xmlpp::Parser::Parser | ( | ) |
|
override |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
protectedvirtual |
|
protectedvirtual |
|
noexcept |
See set_include_default_attributes().
|
noexcept |
See set_parser_options().
[out] | set_options | Set bits correspond to flags that shall be set during parsing. |
[out] | clear_options | Set bits correspond to flags that shall be cleared during parsing. Bits that are set in neither set_options nor clear_options are not affected. |
|
noexcept |
See set_substitute_entities().
|
noexcept |
See set_throw_messages().
|
noexcept |
See set_validate().
|
protectednoexcept |
|
protectedvirtual |
To be called in an exception handler.
|
protectedvirtual |
Reimplemented in xmlpp::SaxParser.
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
pure virtual |
Parse an XML document from a file.
exception |
filename | The path to the file. |
Implemented in xmlpp::SaxParser, and xmlpp::DomParser.
|
pure virtual |
Parse an XML document from a string.
exception |
contents | The XML document as a string. |
Implemented in xmlpp::SaxParser, and xmlpp::DomParser.
|
pure virtual |
Parse an XML document from raw memory.
exception |
contents | The XML document as an array of bytes. |
bytes_count | The number of bytes in the contents array. |
Implemented in xmlpp::SaxParser, and xmlpp::DomParser.
|
pure virtual |
Parse an XML document from a stream.
exception |
in | The stream. |
Implemented in xmlpp::SaxParser, and xmlpp::DomParser.
|
protectedvirtual |
Reimplemented in xmlpp::SaxParser, and xmlpp::DomParser.
|
noexcept |
Set whether default attribute values from the DTD shall be included in the node tree.
If set, attributes not assigned a value in the XML file, but with a default value in the DTD file, will be included in the node tree that the parser creates. These attributes will be represented by AttributeNode instances (not AttributeDeclaration instances), just like attributes which are assigned a value in the XML file.
val | Whether attributes with default values will be included in the node tree. |
|
noexcept |
Set and/or clear parser option flags.
See the libxml2 documentation, enum xmlParserOption, for a list of parser options. This method overrides other methods that set parser options, such as set_validate(), set_substitute_entities() and set_include_default_attributes(). Use set_parser_options() only if no other method can set the parser options you want.
set_options | Set bits correspond to flags that shall be set during parsing. |
clear_options | Set bits correspond to flags that shall be cleared during parsing. Bits that are set in neither set_options nor clear_options are not affected. |
|
noexcept |
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.
val | Whether entities will be substitued. |
|
noexcept |
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.
DOM parser
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 messages.
SAX parser
If the messages are not collected, the error handling on_*() methods in the user's SAX parser subclass are called. This is the default, if set_throw_messages() is not called.
val | Whether messages will be collected and thrown in an exception. |
|
noexcept |
By default, the parser will not validate the XML file.
val | Whether the document should be validated. |
|
protectednoexcept |
|
protected |
|
protected |