libxml++ 5.0.1

- Main Page
- Related Pages
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | List of all members
xmlpp::TextReader Class Reference

A TextReader-style XML parser. More...

`#include <libxml++/parsers/textreader.h>`

Inheritance diagram for xmlpp::TextReader:
[legend]

## Public Types
enum | NodeType { NodeType::InternalError = -1, NodeType::None = 0, NodeType::Element = 1, NodeType::Attribute = 2, NodeType::Text = 3, NodeType::CDATA = 4, NodeType::EntityReference = 5, NodeType::Entity = 6, NodeType::ProcessingInstruction = 7, NodeType::Comment = 8, NodeType::Document = 9, NodeType::DocumentType = 10, NodeType::DocumentFragment = 11, NodeType::Notation = 12, NodeType::Whitespace = 13, NodeType::SignificantWhitespace = 14, NodeType::EndElement = 15, NodeType::EndEntity = 16, NodeType::XmlDeclaration = 17 }
| Node type of the current node. More...
enum | ParserProperties { ParserProperties::LoadDtd = 1, ParserProperties::DefaultAttrs = 2, ParserProperties::Validate = 3, ParserProperties::SubstEntities = 4 }
enum | ReadState { ReadState::InternalError = -1, ReadState::Initial = 0, ReadState::Interactive = 1, ReadState::Error = 2, ReadState::EndOfFile = 3, ReadState::Closed = 4, ReadState::Reading = 5 }
using | size_type = unsigned int

## Public Member Functions
LIBXMLPP_API | TextReader (struct _xmlTextReader* cobj)
| Wraps a TextReader object from an underlying libxml object. More...
LIBXMLPP_API | TextReader (const ustring& URI)
| Creates a new TextReader object to parse a file or URI. More...
LIBXMLPP_API | TextReader (const unsigned char* data, size_type size, const ustring& uri=ustring())
| Creates a new TextReader object which parses in memory data. More...
LIBXMLPP_API | ~TextReader () override
LIBXMLPP_API void | close ()
LIBXMLPP_API Node* | expand ()
| Expand the current node. More...
LIBXMLPP_API ustring | get_attribute (int number) const
LIBXMLPP_API ustring | get_attribute (const ustring& name) const
LIBXMLPP_API ustring | get_attribute (const ustring& local_name, const ustring& ns_uri) const
LIBXMLPP_API int | get_attribute_count () const
| Gets the number of attributes on the current node. More...
LIBXMLPP_API ustring | get_base_uri () const
| Gets the base Uniform Resource Identifier (URI) of the current node. More...
LIBXMLPP_API Node* | get_current_node ()
| Get a pointer to the current node. More...
LIBXMLPP_API const Node* | get_current_node () const
| Get a pointer to the current node. More...
LIBXMLPP_API int | get_depth () const
| Gets the depth of the current node in the XML document. More...
LIBXMLPP_API ustring | get_local_name () const
LIBXMLPP_API ustring | get_name () const
LIBXMLPP_API ustring | get_namespace_uri () const
LIBXMLPP_API NodeType | get_node_type () const
| Get the node type of the current node. More...
LIBXMLPP_API bool | get_normalization () const
LIBXMLPP_API bool | get_parser_property (ParserProperties property) const
LIBXMLPP_API ustring | get_prefix () const
| Get the namespace prefix associated with the current node. More...
LIBXMLPP_API char | get_quote_char () const
| Get the quotation mark character used to enclose the value of an attribute. More...
LIBXMLPP_API ReadState | get_read_state () const
LIBXMLPP_API ustring | get_value () const
LIBXMLPP_API ustring | get_xml_lang () const
LIBXMLPP_API bool | has_attributes () const
| Gets a value indicating whether the current node has any attributes. More...
LIBXMLPP_API bool | has_value () const
| Whether the node can have a text value. More...
LIBXMLPP_API bool | is_default () const
| Whether an Attribute node was generated from the default value defined in the DTD or schema. More...
LIBXMLPP_API bool | is_empty_element () const
| Check if the current node is empty. More...
LIBXMLPP_API bool | is_valid () const
LIBXMLPP_API ustring | lookup_namespace (const ustring& prefix) const
LIBXMLPP_API bool | move_to_attribute (int number)
LIBXMLPP_API bool | move_to_attribute (const ustring& name)
LIBXMLPP_API bool | move_to_attribute (const ustring& local_name, const ustring& ns_uri)
LIBXMLPP_API bool | move_to_element ()
LIBXMLPP_API bool | move_to_first_attribute ()
LIBXMLPP_API bool | move_to_next_attribute ()
LIBXMLPP_API bool | next ()
LIBXMLPP_API bool | read ()
| Moves the position of the current instance to the next node in the stream, exposing its properties. More...
LIBXMLPP_API bool | read_attribute_value ()
| Parses an attribute value into one or more Text and EntityReference nodes. More...
LIBXMLPP_API ustring | read_inner_xml ()
| Reads the contents of the current node, including child nodes and markup. More...
LIBXMLPP_API ustring | read_outer_xml ()
| Reads the current node and its contents, including child nodes and markup. More...
LIBXMLPP_API ustring | read_string ()
| Reads the contents of an element or a text node as a string. More...
LIBXMLPP_API void | set_normalization (bool value)
LIBXMLPP_API void | set_parser_property (ParserProperties property, bool value)

## Additional Inherited Members
Protected Member Functions inherited from xmlpp::NonCopyable
| NonCopyable () noexcept
| NonCopyable (const NonCopyable&)=delete
| NonCopyable (NonCopyable&&)=delete
virtual | ~NonCopyable ()
NonCopyable& | operator= (const NonCopyable&)=delete
NonCopyable& | operator= (NonCopyable&&)=delete

## Detailed Description

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.

## Member Typedef Documentation

using xmlpp::TextReader::size_type = unsigned int

## Member Enumeration Documentation

enum xmlpp::TextReader::NodeType
| strong

Node type of the current node.

See DotGNU's XmlNodeType enum.

Enumerator
InternalError |
None |
Element |
Attribute |
Text |
CDATA |
EntityReference |
Entity |
ProcessingInstruction |
Comment |
Document |
DocumentType |
DocumentFragment |
Notation |
Whitespace |
SignificantWhitespace |
EndElement |
EndEntity |
XmlDeclaration |

enum xmlpp::TextReader::ParserProperties
| strong

Enumerator
LoadDtd |
DefaultAttrs |
Validate |
SubstEntities |

enum xmlpp::TextReader::ReadState
| strong

Enumerator
InternalError |
Initial |
Interactive |
Error |
EndOfFile |
Closed |
Reading |

## Constructor & Destructor Documentation

LIBXMLPP_API xmlpp::TextReader::TextReader | ( | struct _xmlTextReader * | cobj | ) |

Wraps a TextReader object from an underlying libxml object.

The TextReader takes ownership of cobj.

Parameters

  cobj | The underlying libxml xmlTextReader object.

LIBXMLPP_API xmlpp::TextReader::TextReader | ( | const ustring& | URI | ) |

Creates a new TextReader object to parse a file or URI.

Parameters

  URI | The URI to read.

Exceptions

  xmlpp::internal_error | If an xmlTextReader object cannot be created.

LIBXMLPP_API xmlpp::TextReader::TextReader | ( | const unsigned char * | data,
|  | size_type | size,
|  | const ustring& | uri = `ustring()`
| ) |  |

Creates a new TextReader object which parses in memory data.

Parameters

  data | The data to parse.
  size | The number of bytes in data.
  uri | The base URI to use for the document.

Exceptions

  xmlpp::internal_error | If an xmlTextReader object cannot be created.

LIBXMLPP_API xmlpp::TextReader::~TextReader | ( |  | ) |
| override

## Member Function Documentation

LIBXMLPP_API void xmlpp::TextReader::close | ( |  | ) |

LIBXMLPP_API 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().

Warning
  The C++ wrappers are not deleted. Using this method causes memory leaks, unless you call xmlpp::Node::free_wrappers(), which is not intended to be called by the application.

Returns
  A pointer to the current node, or `nullptr` in case of error.

Exceptions

  xmlpp::parse_error |
  xmlpp::validity_error |

LIBXMLPP_API ustring xmlpp::TextReader::get_attribute | ( | int | number | ) | const

LIBXMLPP_API ustring xmlpp::TextReader::get_attribute | ( | const ustring& | name | ) | const

LIBXMLPP_API ustring xmlpp::TextReader::get_attribute | ( | const ustring& | local_name,
|  | const ustring& | ns_uri
| ) |  | const

LIBXMLPP_API int xmlpp::TextReader::get_attribute_count | ( |  | ) | const

Gets the number of attributes on the current node.

Returns
  The number of attributes on the current node, or zero if the current node does not support attributes, or -1 in case of error.

Exceptions

  xmlpp::parse_error |
  xmlpp::validity_error |

LIBXMLPP_API ustring xmlpp::TextReader::get_base_uri | ( |  | ) | const

Gets the base Uniform Resource Identifier (URI) of the current node.

Returns
  The base URI of the current node or an empty ustring if not available.

LIBXMLPP_API Node* xmlpp::TextReader::get_current_node | ( |  | ) |

Get a pointer to the current node.

Warning
  This is dangerous because the underlying node may be destroyed on the next read. The C++ wrapper is not deleted. Using this method causes memory leaks, unless you call xmlpp::Node::free_wrappers(), which is not intended to be called by the application.

Returns
  A pointer to the current node, or `nullptr` in case of error.

LIBXMLPP_API const Node* xmlpp::TextReader::get_current_node | ( |  | ) | const

Get a pointer to the current node.

Warning
  See the non-const get_current_node().

Returns
  A pointer to the current node, or `nullptr` in case of error.

LIBXMLPP_API int xmlpp::TextReader::get_depth | ( |  | ) | const

Gets the depth of the current node in the XML document.

Returns
  The depth of the current node in the XML document, or -1 in case of error.

LIBXMLPP_API ustring xmlpp::TextReader::get_local_name | ( |  | ) | const

LIBXMLPP_API ustring xmlpp::TextReader::get_name | ( |  | ) | const

LIBXMLPP_API ustring xmlpp::TextReader::get_namespace_uri | ( |  | ) | const

LIBXMLPP_API NodeType xmlpp::TextReader::get_node_type | ( |  | ) | const

Get the node type of the current node.

Returns
  The xmlpp::TextReader::NodeType of the current node. In case of error, either returns xmlpp::TextReader::NodeType::InternalError or throws an exception.

Exceptions

  xmlpp::parse_error |
  xmlpp::validity_error |

LIBXMLPP_API bool xmlpp::TextReader::get_normalization | ( |  | ) | const

LIBXMLPP_API bool xmlpp::TextReader::get_parser_property | ( | ParserProperties | property | ) | const

LIBXMLPP_API ustring xmlpp::TextReader::get_prefix | ( |  | ) | const

Get the namespace prefix associated with the current node.

Returns
  The namespace prefix, or an empty string if not available.

LIBXMLPP_API char xmlpp::TextReader::get_quote_char | ( |  | ) | const

Get the quotation mark character used to enclose the value of an attribute.

Returns
  Returns " or ' and -1 in case of error.

LIBXMLPP_API ReadState xmlpp::TextReader::get_read_state | ( |  | ) | const

LIBXMLPP_API ustring xmlpp::TextReader::get_value | ( |  | ) | const

LIBXMLPP_API ustring xmlpp::TextReader::get_xml_lang | ( |  | ) | const

LIBXMLPP_API bool xmlpp::TextReader::has_attributes | ( |  | ) | const

Gets a value indicating whether the current node has any attributes.

Returns
  true if the current has attributes, false otherwise.

LIBXMLPP_API bool xmlpp::TextReader::has_value | ( |  | ) | const

Whether the node can have a text value.

Returns
  true if the current node can have an associated text value, false otherwise.

LIBXMLPP_API bool xmlpp::TextReader::is_default | ( |  | ) | const

Whether an Attribute node was generated from the default value defined in the DTD or schema.

Returns
  true if defaulted, false otherwise.

LIBXMLPP_API bool xmlpp::TextReader::is_empty_element | ( |  | ) | const

Check if the current node is empty.

Returns
  true if empty, false otherwise.

LIBXMLPP_API bool xmlpp::TextReader::is_valid | ( |  | ) | const

LIBXMLPP_API ustring xmlpp::TextReader::lookup_namespace | ( | const ustring& | prefix | ) | const

LIBXMLPP_API bool xmlpp::TextReader::move_to_attribute | ( | int | number | ) |

LIBXMLPP_API bool xmlpp::TextReader::move_to_attribute | ( | const ustring& | name | ) |

LIBXMLPP_API bool xmlpp::TextReader::move_to_attribute | ( | const ustring& | local_name,
|  | const ustring& | ns_uri
| ) |  |

LIBXMLPP_API bool xmlpp::TextReader::move_to_element | ( |  | ) |

LIBXMLPP_API bool xmlpp::TextReader::move_to_first_attribute | ( |  | ) |

LIBXMLPP_API bool xmlpp::TextReader::move_to_next_attribute | ( |  | ) |

LIBXMLPP_API bool xmlpp::TextReader::next | ( |  | ) |

LIBXMLPP_API bool xmlpp::TextReader::read | ( |  | ) |

Moves the position of the current instance to the next node in the stream, exposing its properties.

Returns
  true if the node was read successfully, false if there are no more nodes to read.

Exceptions

  xmlpp::parse_error |
  xmlpp::validity_error |

LIBXMLPP_API bool xmlpp::TextReader::read_attribute_value | ( |  | ) |

Parses an attribute value into one or more Text and EntityReference nodes.

Returns
  A bool where true indicates the attribute value was parsed, and false indicates the reader was not positioned on an attribute node or all the attribute values have been read.

Exceptions

  xmlpp::parse_error |
  xmlpp::validity_error |

LIBXMLPP_API ustring xmlpp::TextReader::read_inner_xml | ( |  | ) |

Reads the contents of the current node, including child nodes and markup.

Returns
  A ustring containing the XML content, or an empty ustring if the current node is neither an element nor attribute, or has no child nodes.

Exceptions

  xmlpp::parse_error |
  xmlpp::validity_error |

LIBXMLPP_API ustring xmlpp::TextReader::read_outer_xml | ( |  | ) |

Reads the current node and its contents, including child nodes and markup.

Returns
  A ustring containing the XML content, or an empty ustring if the current node is neither an element nor attribute.

Exceptions

  xmlpp::parse_error |
  xmlpp::validity_error |

LIBXMLPP_API ustring xmlpp::TextReader::read_string | ( |  | ) |

Reads the contents of an element or a text node as a string.

Returns
  A ustring containing the contents of the Element or Text node, or an empty ustring if the reader is positioned on any other type of node.

Exceptions

  xmlpp::parse_error |
  xmlpp::validity_error |

LIBXMLPP_API void xmlpp::TextReader::set_normalization | ( | bool | value | ) |

LIBXMLPP_API void xmlpp::TextReader::set_parser_property | ( | ParserProperties | property,
|  | bool | value
| ) |  |