libxml++
5.4.0
|
A TextReader-style XML parser. More...
#include <libxml++/parsers/textreader.h>
Public Types | |
enum class | NodeType { InternalError = -1 , None = 0 , Element = 1 , Attribute = 2 , Text = 3 , CDATA = 4 , EntityReference = 5 , Entity = 6 , ProcessingInstruction = 7 , Comment = 8 , Document = 9 , DocumentType = 10 , DocumentFragment = 11 , Notation = 12 , Whitespace = 13 , SignificantWhitespace = 14 , EndElement = 15 , EndEntity = 16 , XmlDeclaration = 17 } |
Node type of the current node. More... | |
enum class | ParserProperties { LoadDtd = 1 , DefaultAttrs = 2 , Validate = 3 , SubstEntities = 4 } |
enum class | ReadState { InternalError = -1 , Initial = 0 , Interactive = 1 , Error = 2 , EndOfFile = 3 , Closed = 4 , Reading = 5 } |
using | size_type = unsigned int |
Public Member Functions | |
TextReader (const unsigned char *data, size_type size, const ustring & uri=ustring()) | |
Creates a new TextReader object which parses in memory data. More... | |
TextReader (const ustring & URI) | |
Creates a new TextReader object to parse a file or URI. More... | |
TextReader (struct _xmlTextReader * cobj) | |
Wraps a TextReader object from an underlying libxml object. More... | |
~TextReader () override | |
void | close () |
Node * | expand () |
Expand the current node. More... | |
ustring | get_attribute (const ustring & local_name, const ustring & ns_uri) const |
Gets the value of the specified attribute. More... | |
ustring | get_attribute (const ustring & name) const |
Gets the value of the attribute with the specified qualified name. More... | |
ustring | get_attribute (int number) const |
Gets the value of the attribute with the specified index relative to the containing element. More... | |
std::optional< ustring > | get_attribute2 (const ustring & local_name, const ustring & ns_uri) const |
Gets the value of the specified attribute. More... | |
std::optional< ustring > | get_attribute2 (const ustring & name) const |
Gets the value of the attribute with the specified qualified name. More... | |
std::optional< ustring > | get_attribute2 (int number) const |
Gets the value of the attribute with the specified index relative to the containing element. More... | |
int | get_attribute_count () const |
Gets the number of attributes on the current node. More... | |
ustring | get_base_uri () const |
Gets the base Uniform Resource Identifier (URI) of the current node. More... | |
std::optional< ustring > | get_base_uri2 () const |
Gets the base Uniform Resource Identifier (URI) of the current node. More... | |
Node * | get_current_node () |
Get a pointer to the current node. More... | |
const Node * | get_current_node () const |
Get a pointer to the current node. More... | |
int | get_depth () const |
Gets the depth of the current node in the XML document. More... | |
ustring | get_local_name () const |
Gets the local name of the node. More... | |
std::optional< ustring > | get_local_name2 () const |
Gets the local name of the node. More... | |
ustring | get_name () const |
Gets the qualified name of the node, equal to Prefix:LocalName. More... | |
std::optional< ustring > | get_name2 () const |
Gets the qualified name of the node, equal to Prefix:LocalName. More... | |
ustring | get_namespace_uri () const |
Gets the URI defining the namespace associated with the node. More... | |
std::optional< ustring > | get_namespace_uri2 () const |
Gets the URI defining the namespace associated with the node. More... | |
NodeType | get_node_type () const |
Get the node type of the current node. More... | |
bool | get_normalization () const |
bool | get_parser_property (ParserProperties property) const |
ustring | get_prefix () const |
Get the namespace prefix associated with the current node. More... | |
std::optional< ustring > | get_prefix2 () const |
Get the namespace prefix associated with the current node. More... | |
char | get_quote_char () const |
Get the quotation mark character used to enclose the value of an attribute. More... | |
ReadState | get_read_state () const |
Gets the read state of the reader. More... | |
ustring | get_value () const |
Gets the text value of the node. More... | |
std::optional< ustring > | get_value2 () const |
Gets the text value of the node. More... | |
ustring | get_xml_lang () const |
Gets the xml:lang scope within which the node resides. More... | |
std::optional< ustring > | get_xml_lang2 () const |
Gets the xml:lang scope within which the node resides. More... | |
bool | has_attributes () const |
Gets a value indicating whether the current node has any attributes. More... | |
bool | has_value () const |
Whether the node can have a text value. More... | |
bool | is_default () const |
Whether an Attribute node was generated from the default value defined in the DTD or schema. More... | |
bool | is_empty_element () const |
Check if the current node is empty. More... | |
bool | is_valid () const |
ustring | lookup_namespace (const ustring & prefix) const |
Resolves a namespace prefix in the scope of the current element. More... | |
std::optional< ustring > | lookup_namespace2 (const ustring & prefix) const |
Resolves a namespace prefix in the scope of the current element. More... | |
bool | move_to_attribute (const ustring & local_name, const ustring & ns_uri) |
bool | move_to_attribute (const ustring & name) |
bool | move_to_attribute (int number) |
bool | move_to_element () |
bool | move_to_first_attribute () |
bool | move_to_next_attribute () |
bool | next () |
bool | read () |
Moves the position of the current instance to the next node in the stream, exposing its properties. More... | |
bool | read_attribute_value () |
Parses an attribute value into one or more Text and EntityReference nodes. More... | |
ustring | read_inner_xml () |
Reads the contents of the current node, including child nodes and markup. More... | |
std::optional< ustring > | read_inner_xml2 () |
Reads the contents of the current node, including child nodes and markup. More... | |
ustring | read_outer_xml () |
Reads the current node and its contents, including child nodes and markup. More... | |
std::optional< ustring > | read_outer_xml2 () |
Reads the current node and its contents, including child nodes and markup. More... | |
ustring | read_string () |
Reads the contents of an element or a text node as a string. More... | |
std::optional< ustring > | read_string2 () |
Reads the contents of an element or a text node as a string. More... | |
void | set_normalization (bool value) |
void | set_parser_property (ParserProperties property, bool value) |
Public Member Functions inherited from xmlpp::NonCopyable | |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable (NonCopyable &&)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable & | operator= (NonCopyable &&)=delete |
Additional Inherited Members | |
Protected Member Functions inherited from xmlpp::NonCopyable | |
NonCopyable () noexcept | |
virtual | ~NonCopyable () |
A TextReader-style XML parser.
A reader that provides fast, non-cached, forward-only access to XML data, in the style of .Net's XmlTextReader class.
using xmlpp::TextReader::size_type = unsigned int |
|
strong |
Node type of the current node.
See DotGNU's XmlNodeType enum.
|
strong |
|
strong |
xmlpp::TextReader::TextReader | ( | struct _xmlTextReader * | cobj | ) |
Wraps a TextReader object from an underlying libxml object.
The TextReader takes ownership of cobj.
cobj | The underlying libxml xmlTextReader object. |
xmlpp::TextReader::TextReader | ( | const ustring & | URI | ) |
Creates a new TextReader object to parse a file or URI.
URI | The URI to read. |
xmlpp::internal_error | If an xmlTextReader object cannot be created. |
xmlpp::TextReader::TextReader | ( | const unsigned char * | data, |
size_type | size, | ||
const ustring & | uri = ustring() |
||
) |
Creates a new TextReader object which parses in memory data.
data | The data to parse. |
size | The number of bytes in data. |
uri | The base URI to use for the document. |
xmlpp::internal_error | If an xmlTextReader object cannot be created. |
|
override |
void xmlpp::TextReader::close | ( | ) |
Node* xmlpp::TextReader::expand | ( | ) |
Expand the current node.
Reads the contents of the current node and the full subtree. It then makes the subtree available until the next call to read() or next().
nullptr
in case of error. xmlpp::parse_error | |
xmlpp::validity_error |
ustring xmlpp::TextReader::get_attribute | ( | const ustring & | local_name, |
const ustring & | ns_uri | ||
) | const |
Gets the value of the specified attribute.
local_name | The local name of the attribute. |
ns_uri | The namespace URI of the attribute. |
xmlpp::parse_error | |
xmlpp::validity_error |
Gets the value of the attribute with the specified qualified name.
name | The qualified name of the attribute. |
xmlpp::parse_error | |
xmlpp::validity_error |
ustring xmlpp::TextReader::get_attribute | ( | int | number | ) | const |
Gets the value of the attribute with the specified index relative to the containing element.
number | The zero-based index of the attribute relative to the containing element. |
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::get_attribute2 | ( | const ustring & | local_name, |
const ustring & | ns_uri | ||
) | const |
Gets the value of the specified attribute.
local_name | The local name of the attribute. |
ns_uri | The namespace URI of the attribute. |
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::get_attribute2 | ( | const ustring & | name | ) | const |
Gets the value of the attribute with the specified qualified name.
name | The qualified name of the attribute. |
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::get_attribute2 | ( | int | number | ) | const |
Gets the value of the attribute with the specified index relative to the containing element.
number | The zero-based index of the attribute relative to the containing element. |
xmlpp::parse_error | |
xmlpp::validity_error |
int xmlpp::TextReader::get_attribute_count | ( | ) | const |
Gets the number of attributes on the current node.
xmlpp::parse_error | |
xmlpp::validity_error |
ustring xmlpp::TextReader::get_base_uri | ( | ) | const |
Gets the base Uniform Resource Identifier (URI) of the current node.
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::get_base_uri2 | ( | ) | const |
Gets the base Uniform Resource Identifier (URI) of the current node.
xmlpp::parse_error | |
xmlpp::validity_error |
Node* xmlpp::TextReader::get_current_node | ( | ) |
Get a pointer to the current node.
nullptr
in case of error. const Node* xmlpp::TextReader::get_current_node | ( | ) | const |
Get a pointer to the current node.
nullptr
in case of error. int xmlpp::TextReader::get_depth | ( | ) | const |
Gets the depth of the current node in the XML document.
ustring xmlpp::TextReader::get_local_name | ( | ) | const |
Gets the local name of the node.
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::get_local_name2 | ( | ) | const |
Gets the local name of the node.
xmlpp::parse_error | |
xmlpp::validity_error |
ustring xmlpp::TextReader::get_name | ( | ) | const |
Gets the qualified name of the node, equal to Prefix:LocalName.
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::get_name2 | ( | ) | const |
Gets the qualified name of the node, equal to Prefix:LocalName.
xmlpp::parse_error | |
xmlpp::validity_error |
ustring xmlpp::TextReader::get_namespace_uri | ( | ) | const |
Gets the URI defining the namespace associated with the node.
std::optional<ustring> xmlpp::TextReader::get_namespace_uri2 | ( | ) | const |
Gets the URI defining the namespace associated with the node.
NodeType xmlpp::TextReader::get_node_type | ( | ) | const |
Get the node type of the current node.
xmlpp::parse_error | |
xmlpp::validity_error |
bool xmlpp::TextReader::get_normalization | ( | ) | const |
bool xmlpp::TextReader::get_parser_property | ( | ParserProperties | property | ) | const |
ustring xmlpp::TextReader::get_prefix | ( | ) | const |
Get the namespace prefix associated with the current node.
std::optional<ustring> xmlpp::TextReader::get_prefix2 | ( | ) | const |
Get the namespace prefix associated with the current node.
char xmlpp::TextReader::get_quote_char | ( | ) | const |
Get the quotation mark character used to enclose the value of an attribute.
ReadState xmlpp::TextReader::get_read_state | ( | ) | const |
Gets the read state of the reader.
ustring xmlpp::TextReader::get_value | ( | ) | const |
Gets the text value of the node.
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::get_value2 | ( | ) | const |
Gets the text value of the node.
xmlpp::parse_error | |
xmlpp::validity_error |
ustring xmlpp::TextReader::get_xml_lang | ( | ) | const |
Gets the xml:lang scope within which the node resides.
std::optional<ustring> xmlpp::TextReader::get_xml_lang2 | ( | ) | const |
Gets the xml:lang scope within which the node resides.
bool xmlpp::TextReader::has_attributes | ( | ) | const |
Gets a value indicating whether the current node has any attributes.
bool xmlpp::TextReader::has_value | ( | ) | const |
Whether the node can have a text value.
bool xmlpp::TextReader::is_default | ( | ) | const |
Whether an Attribute node was generated from the default value defined in the DTD or schema.
bool xmlpp::TextReader::is_empty_element | ( | ) | const |
Check if the current node is empty.
bool xmlpp::TextReader::is_valid | ( | ) | const |
Resolves a namespace prefix in the scope of the current element.
prefix | The prefix whose namespace URI is to be resolved. To return the default namespace, specify an empty string. |
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::lookup_namespace2 | ( | const ustring & | prefix | ) | const |
Resolves a namespace prefix in the scope of the current element.
prefix | The prefix whose namespace URI is to be resolved. To return the default namespace, specify an empty string. |
xmlpp::parse_error | |
xmlpp::validity_error |
bool xmlpp::TextReader::move_to_attribute | ( | const ustring & | name | ) |
bool xmlpp::TextReader::move_to_attribute | ( | int | number | ) |
bool xmlpp::TextReader::move_to_element | ( | ) |
bool xmlpp::TextReader::move_to_first_attribute | ( | ) |
bool xmlpp::TextReader::move_to_next_attribute | ( | ) |
bool xmlpp::TextReader::next | ( | ) |
bool xmlpp::TextReader::read | ( | ) |
Moves the position of the current instance to the next node in the stream, exposing its properties.
xmlpp::parse_error | |
xmlpp::validity_error |
bool xmlpp::TextReader::read_attribute_value | ( | ) |
Parses an attribute value into one or more Text and EntityReference nodes.
xmlpp::parse_error | |
xmlpp::validity_error |
ustring xmlpp::TextReader::read_inner_xml | ( | ) |
Reads the contents of the current node, including child nodes and markup.
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::read_inner_xml2 | ( | ) |
Reads the contents of the current node, including child nodes and markup.
xmlpp::parse_error | |
xmlpp::validity_error |
ustring xmlpp::TextReader::read_outer_xml | ( | ) |
Reads the current node and its contents, including child nodes and markup.
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::read_outer_xml2 | ( | ) |
Reads the current node and its contents, including child nodes and markup.
xmlpp::parse_error | |
xmlpp::validity_error |
ustring xmlpp::TextReader::read_string | ( | ) |
Reads the contents of an element or a text node as a string.
xmlpp::parse_error | |
xmlpp::validity_error |
std::optional<ustring> xmlpp::TextReader::read_string2 | ( | ) |
Reads the contents of an element or a text node as a string.
xmlpp::parse_error | |
xmlpp::validity_error |
void xmlpp::TextReader::set_normalization | ( | bool | value | ) |
void xmlpp::TextReader::set_parser_property | ( | ParserProperties | property, |
bool | value | ||
) |