/usr/include/libxml++-2.6/libxml++/parsers/textreader.h is in libxml++2.6-dev 2.40.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | /* textreader.h
* libxml++ and this file are copyright (C) 2000 by Ari Johnson, and
* are covered by the GNU Lesser General Public License, which should be
* included with libxml++ as the file COPYING.
*/
#ifndef __LIBXMLPP_XMLREADER_H
#define __LIBXMLPP_XMLREADER_H
#include <libxml++/noncopyable.h>
#include <libxml++/nodes/node.h>
#include <glibmm/ustring.h>
#include <memory>
extern "C"
{
struct _xmlTextReader;
}
namespace xmlpp
{
/** A TextReader-style XML parser.
* A reader that provides fast, non-cached, forward-only access to XML data,
* in the style of .Net's <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmltextreader.aspx">XmlTextReader</a> class.
*/
class TextReader: NonCopyable
{
public:
enum xmlNodeType {
Attribute = 2,
CDATA = 4,
Comment = 8,
Document = 9,
DocumentFragment = 11,
DocumentType = 10,
Element = 1,
EndElement = 15,
EndEntity = 16,
Entity = 6,
EntityReference = 5,
None = 0,
Notation = 12,
ProcessingInstruction = 7,
SignificantWhitespace = 14,
Text = 3,
Whitespace = 13,
XmlDeclaration = 17
};
enum xmlReadState
{
Closed = 4,
EndOfFile = 3,
Error = 2,
Initial = 0,
Interactive = 1,
Reading = 5
};
enum ParserProperties
{
LoadDtd = 1,
DefaultAttrs = 2,
Validate = 3,
SubstEntities = 4
};
typedef unsigned int size_type;
public:
/**
* Wraps a TextReader object from an underlying libxml object. The TextReader
* takes ownership of cobj.
* @param cobj The underlying libxml xmlTextReader object.
*/
TextReader(struct _xmlTextReader* cobj);
/**
* Creates a new TextReader object to parse a file or URI.
* @param URI The URI to read.
* @throws xmlpp::internal_error If an xmlTextReader object cannot be created.
*/
TextReader(const Glib::ustring& URI);
/**
* Creates a new TextReader object which parses in memory data.
* @param data The data to parse.
* @param size The number of bytes in data.
* @param uri The base URI to use for the document.
* @throws xmlpp::internal_error If an xmlTextReader object cannot be created.
*/
TextReader(const unsigned char* data, size_type size, const Glib::ustring& uri = Glib::ustring());
~TextReader() override;
/** Moves the position of the current instance to the next node in the stream, exposing its properties.
* @return true if the node was read successfully, false if there are no more nodes to read.
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
bool read();
/** Reads the contents of the current node, including child nodes and markup.
* @return A Glib::ustring containing the XML content, or an empty Glib::ustring if the current node is neither an element nor attribute, or has no child nodes.
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
Glib::ustring read_inner_xml();
/** Reads the current node and its contents, including child nodes and markup.
* @return A Glib::ustring containing the XML content, or an empty Glib::ustring if the current node is neither an element nor attribute.
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
Glib::ustring read_outer_xml();
/** Reads the contents of an element or a text node as a string.
* @return A Glib::ustring containing the contents of the Element or Text node, or an empty Glib::ustring if the reader is positioned on any other type of node.
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
Glib::ustring read_string();
/** Parses an attribute value into one or more Text and EntityReference nodes.
* @return 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.
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
bool read_attribute_value();
/** Gets the number of attributes on the current node.
* @return The number of attributes on the current node, or zero if the current node
* does not support attributes, or -1 in case of error.
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
int get_attribute_count() const;
/** Gets the base Uniform Resource Identifier (URI) of the current node.
* @return The base URI of the current node or an empty Glib::ustring if not available.
*/
Glib::ustring get_base_uri() const;
/** Gets the depth of the current node in the XML document.
* @return The depth of the current node in the XML document, or -1 in case of error.
*/
int get_depth() const;
/** Gets a value indicating whether the current node has any attributes.
* @return true if the current has attributes, false otherwise.
*/
bool has_attributes() const;
/** Whether the node can have a text value.
* @return true if the current node can have an associated text value, false otherwise.
*/
bool has_value() const;
/** Whether an Attribute node was generated from the default value defined in the DTD or schema.
* @return true if defaulted, false otherwise.
*/
bool is_default() const;
/** Check if the current node is empty
* @return true if empty, false otherwise.
*/
bool is_empty_element() const;
Glib::ustring get_local_name() const;
Glib::ustring get_name() const;
Glib::ustring get_namespace_uri() const;
/** Get the node type of the current node.
* @returns The xmlpp::xmlNodeType of the current node, or -1 in case of error.
*/
xmlNodeType get_node_type() const;
/** Get the namespace prefix associated with the current node.
* @returns The namespace prefix, or an empty string if not available.
*/
Glib::ustring get_prefix() const;
/** Get the quotation mark character used to enclose the value of an attribute.
* @returns Returns " or ' and -1 in case of error.
*/
char get_quote_char() const;
Glib::ustring get_value() const;
Glib::ustring get_xml_lang() const;
xmlReadState get_read_state() const;
void close();
Glib::ustring get_attribute(int number) const;
Glib::ustring get_attribute(const Glib::ustring& name) const;
Glib::ustring get_attribute(const Glib::ustring& local_name, const Glib::ustring& ns_uri) const;
// TODO InputBuffer GetRemainder;
Glib::ustring lookup_namespace(const Glib::ustring& prefix) const;
bool move_to_attribute(int number);
bool move_to_attribute(const Glib::ustring& name);
bool move_to_attribute(const Glib::ustring& local_name, const Glib::ustring& ns_uri);
bool move_to_first_attribute();
bool move_to_next_attribute();
bool move_to_element();
bool get_normalization() const;
void set_normalization(bool value);
bool get_parser_property(ParserProperties property) const;
void set_parser_property(ParserProperties property, bool value);
/** 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 <tt>nullptr</tt> in case of error.
*/
Node* get_current_node();
/** Get a pointer to the current node.
* @warning See the non-const get_current_node().
* @returns A pointer to the current node, or <tt>nullptr</tt> in case of error.
*/
const Node* get_current_node() const;
// Document* CurrentDocument();
/** 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 <tt>nullptr</tt> in case of error.
* @throws xmlpp::parse_error
* @throws xmlpp::validity_error
*/
Node* expand();
bool next();
bool is_valid() const;
private:
class PropertyReader;
friend class PropertyReader;
void setup_exceptions();
static void on_libxml_error(void * arg, const char *msg, int severity,
void * locator);
void check_for_exceptions() const;
std::auto_ptr<PropertyReader> propertyreader;
_xmlTextReader* impl_;
int severity_;
Glib::ustring error_;
};
}
#endif
|