libxml++
4.9.1
About: libxml++ is a C++ wrapper for the libxml XML parser library.
![]() ![]() |
DOM XML parser. More...
#include <domparser.h>
Public Member Functions | |
DomParser () | |
Create a parser with an empty document. More... | |
DomParser (const std::string &filename, bool validate=false) | |
Instantiate the parser and parse a document immediately. More... | |
~DomParser () override | |
void | set_xinclude_options (bool process_xinclude=true, bool generate_xinclude_nodes=true, bool fixup_base_uris=true) noexcept |
Set whether and how the parser will perform XInclude substitution. More... | |
void | get_xinclude_options (bool &process_xinclude, bool &generate_xinclude_nodes, bool &fixup_base_uris) const noexcept |
Get whether and how the parser will perform XInclude substitution. More... | |
void | parse_file (const std::string &filename) override |
Parse an XML document from a file. More... | |
void | parse_memory (const ustring &contents) override |
Parse an XML document from a string. More... | |
void | parse_memory_raw (const unsigned char *contents, size_type bytes_count) override |
Parse an XML document from raw memory. More... | |
void | parse_stream (std::istream &in) override |
Parse an XML document from a stream. More... | |
operator bool () const noexcept | |
Test whether a document has been parsed. More... | |
Document * | get_document () noexcept |
Get the parsed document. More... | |
const Document * | get_document () const noexcept |
Get the parsed document. More... | |
![]() | |
Parser () | |
~Parser () override | |
void | set_validate (bool val=true) noexcept |
By default, the parser will not validate the XML file. More... | |
bool | get_validate () const noexcept |
See set_validate(). More... | |
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... | |
bool | get_substitute_entities () const noexcept |
See set_substitute_entities(). More... | |
void | set_throw_messages (bool val=true) noexcept |
Set whether the parser will collect and throw error and warning messages. More... | |
bool | get_throw_messages () const noexcept |
See set_throw_messages(). More... | |
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... | |
bool | get_include_default_attributes () const noexcept |
See set_include_default_attributes(). More... | |
void | set_parser_options (int set_options=0, int clear_options=0) noexcept |
Set and/or clear parser option flags. More... | |
void | get_parser_options (int &set_options, int &clear_options) const noexcept |
See set_parser_options(). More... | |
Protected Member Functions | |
void | parse_context () |
void | check_xinclude_and_finish_parsing () |
void | release_underlying () override |
![]() | |
virtual void | initialize_context () |
virtual void | on_parser_error (const ustring &message) |
virtual void | on_parser_warning (const ustring &message) |
virtual void | on_validity_error (const ustring &message) |
virtual void | on_validity_warning (const ustring &message) |
virtual void | handle_exception () |
To be called in an exception handler. More... | |
virtual void | check_for_exception () |
virtual void | check_for_error_and_warning_messages () |
![]() | |
NonCopyable () noexcept | |
virtual | ~NonCopyable () |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable (NonCopyable &&)=delete | |
NonCopyable & | operator= (NonCopyable &&)=delete |
Protected Attributes | |
int | xinclude_options_ = 0 |
Document * | doc_ |
![]() | |
_xmlParserCtxt * | context_ |
std::unique_ptr< exception > | exception_ |
Additional Inherited Members | |
![]() | |
using | size_type = unsigned int |
![]() | |
enum | MsgType { MsgType::ParserError, MsgType::ParserWarning, MsgType::ValidityError, MsgType::ValidityWarning } |
![]() | |
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) |
xmlpp::DomParser::DomParser | ( | ) |
Create a parser with an empty document.
xmlpp::internal_error | If an empty document can't be created. |
Definition at line 23 of file domparser.cc.
References doc_.
|
explicit |
Instantiate the parser and parse a document immediately.
filename | The path to the file. |
validate | Whether the parser should validate the XML. |
Definition at line 30 of file domparser.cc.
References parse_file(), and xmlpp::Parser::set_validate().
|
override |
Definition at line 37 of file domparser.cc.
References release_underlying().
|
protected |
Definition at line 147 of file domparser.cc.
References xmlpp::Parser::context_, doc_, xmlpp::format_xml_error(), xmlpp::Parser::get_parser_options(), xmlpp::Parser::release_underlying(), and xinclude_options_.
Referenced by parse_context(), and parse_stream().
|
noexcept |
Get the parsed document.
nullptr
. Definition at line 268 of file domparser.cc.
References doc_.
|
noexcept |
Get the parsed document.
nullptr
. Definition at line 263 of file domparser.cc.
References doc_.
Referenced by xmlpp::RelaxNGValidator::validate().
|
noexcept |
Get whether and how the parser will perform XInclude substitution.
[out] | process_xinclude | Do XInclude substitution on the XML document. |
[out] | generate_xinclude_nodes | Generate XIncludeStart and XIncludeEnd nodes. |
[out] | fixup_base_uris | Add or replace xml:base attributes in included element nodes, if necessary to preserve the target of relative URIs. |
Definition at line 54 of file domparser.cc.
|
explicitnoexcept |
Test whether a document has been parsed.
Definition at line 258 of file domparser.cc.
|
protected |
Definition at line 108 of file domparser.cc.
References xmlpp::Parser::check_for_exception(), check_xinclude_and_finish_parsing(), xmlpp::Parser::context_, xmlpp::KeepBlanks::Default, xmlpp::format_xml_error(), xmlpp::format_xml_parser_error(), xmlpp::Parser::initialize_context(), and release_underlying().
Referenced by parse_file(), and parse_memory_raw().
|
overridevirtual |
Parse an XML document from a file.
If the parser already contains a document, that document and all its nodes are deleted.
filename | The path to the file. |
Implements xmlpp::Parser.
Definition at line 62 of file domparser.cc.
References xmlpp::Parser::context_, xmlpp::KeepBlanks::Default, xmlpp::format_xml_error(), parse_context(), and release_underlying().
Referenced by DomParser().
|
overridevirtual |
Parse an XML document from a string.
If the parser already contains a document, that document and all its nodes are deleted.
contents | The XML document as a string. |
Implements xmlpp::Parser.
Definition at line 103 of file domparser.cc.
References parse_memory_raw().
|
overridevirtual |
Parse an XML document from raw memory.
If the parser already contains a document, that document and all its nodes are deleted.
contents | The XML document as an array of bytes. |
bytes_count | The number of bytes in the contents array. |
Implements xmlpp::Parser.
Definition at line 85 of file domparser.cc.
References xmlpp::Parser::context_, xmlpp::KeepBlanks::Default, xmlpp::format_xml_error(), parse_context(), and release_underlying().
Referenced by parse_memory().
|
overridevirtual |
Parse an XML document from a stream.
If the parser already contains a document, that document and all its nodes are deleted.
in | The stream. |
Implements xmlpp::Parser.
Definition at line 177 of file domparser.cc.
References xmlpp::Parser::check_for_exception(), check_xinclude_and_finish_parsing(), xmlpp::Parser::context_, xmlpp::KeepBlanks::Default, xmlpp::format_xml_error(), xmlpp::format_xml_parser_error(), xmlpp::Parser::initialize_context(), and release_underlying().
|
overrideprotectedvirtual |
Reimplemented from xmlpp::Parser.
Definition at line 247 of file domparser.cc.
References doc_, and xmlpp::Parser::release_underlying().
Referenced by parse_context(), parse_file(), parse_memory_raw(), parse_stream(), and ~DomParser().
|
noexcept |
Set whether and how the parser will perform XInclude substitution.
process_xinclude | Do XInclude substitution on the XML document. If false , the other parameters have no effect. |
generate_xinclude_nodes | Generate XIncludeStart and XIncludeEnd nodes. |
fixup_base_uris | Add or replace xml:base attributes in included element nodes, if necessary to preserve the target of relative URIs. |
Definition at line 42 of file domparser.cc.
|
protected |
Definition at line 123 of file domparser.h.
Referenced by check_xinclude_and_finish_parsing(), DomParser(), get_document(), and release_underlying().
|
protected |
Definition at line 122 of file domparser.h.
Referenced by check_xinclude_and_finish_parsing().