libzypp 17.31.6
Node.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_PARSER_XML_NODE_H
13#define ZYPP_PARSER_XML_NODE_H
14
15#include <iosfwd>
16
18
20namespace zypp
21{
23 namespace xml
24 {
25
27 //
28 // CLASS NAME : Node
29 //
35 class Node
36 {
37 public:
39 Node();
40
42 Node( xmlTextReaderPtr const & reader_r );
43
45 explicit operator bool() const
46 { return _reader; }
47
48 public:
50 int attributeCount() const
51 { return xmlTextReaderAttributeCount( _reader ); }
52
55 { return xmlTextReaderConstBaseUri( _reader ); }
56
58 int columnNumber() const
59 { return xmlTextReaderGetParserColumnNumber( _reader ); }
60
62 int depth() const
63 { return xmlTextReaderDepth( _reader ); }
64
67 { return xmlTextReaderConstEncoding( _reader ); }
68
71 XmlString getAttribute( const char * name_r ) const
72 { return XmlString( xmlTextReaderGetAttribute( _reader, reinterpret_cast<const xmlChar *>(name_r) ),
75 XmlString getAttribute( const std::string & name_r ) const
76 { return getAttribute( name_r.c_str() ); }
77
80 XmlString getAttributeNo( int no_r ) const
81 { return XmlString( xmlTextReaderGetAttributeNo( _reader, no_r ), XmlString::FREE ); }
82
84 int hasAttributes() const
85 { return xmlTextReaderHasAttributes( _reader ); }
86
88 int hasValue() const
89 { return xmlTextReaderHasValue( _reader ); }
90
92 bool isAttribute() const
93 { return( nodeType() == XML_READER_TYPE_ATTRIBUTE ); }
94
97 int isDefault() const
98 { return xmlTextReaderIsDefault( _reader ); }
99
101 int isEmptyElement() const
102 { return xmlTextReaderIsEmptyElement( _reader ); }
103
106 int isNamespaceDecl() const
107 { return xmlTextReaderIsNamespaceDecl( _reader ); }
108
110 int lineNumber() const
111 { return xmlTextReaderGetParserLineNumber( _reader ); }
112
115 { return xmlTextReaderConstLocalName( _reader ); }
116
119 { return xmlTextReaderConstName( _reader ); }
120
123 { return xmlTextReaderConstNamespaceUri( _reader ); }
124
127 { return (NodeType)xmlTextReaderNodeType( _reader ); }
128
131 { return xmlTextReaderConstPrefix( _reader ); }
132
135 int quoteChar() const
136 { return xmlTextReaderQuoteChar( _reader ); }
137
140 { return (ReadState)xmlTextReaderReadState( _reader ); }
141
144 { return xmlTextReaderConstValue( _reader ); }
145
148 { return XmlString( xmlTextReaderValue( _reader ), XmlString::FREE ); }
149
152 { return xmlTextReaderConstXmlLang( _reader ); }
153
156 { return xmlTextReaderConstXmlVersion( _reader ); }
157
158 private:
160 static xmlTextReaderPtr const _no_reader;
162 xmlTextReaderPtr const & _reader;
163 };
165
167 std::ostream & operator<<( std::ostream & str, const Node & obj );
168
170 } // namespace xml
173} // namespace zypp
175#endif // ZYPP_PARSER_XML_NODE_H
xmlTextReader based interface to Reader's current node.
Definition: Node.h:36
XmlString getValue() const
Provides a copy of the text value of the node if present.
Definition: Node.h:147
XmlString localName() const
The local name of the node.
Definition: Node.h:114
XmlString prefix() const
A shorthand reference to the namespace associated with the node.
Definition: Node.h:130
int depth() const
The depth of the node in the tree.
Definition: Node.h:62
XmlString namespaceUri() const
The URI defining the namespace associated with the node.
Definition: Node.h:122
int isNamespaceDecl() const
Determine whether the current node is a namespace declaration rather than a regular attribute.
Definition: Node.h:106
int hasAttributes() const
Whether the node has attributes.
Definition: Node.h:84
int attributeCount() const
Provides the number of attributes of the current node.
Definition: Node.h:50
XmlString xmlVersion() const
Determine the XML version of the document being read.
Definition: Node.h:155
int isDefault() const
Whether an Attribute node was generated from the default value defined in the DTD or schema.
Definition: Node.h:97
int hasValue() const
Whether the node can have a text value.
Definition: Node.h:88
NodeType nodeType() const
Get the node type of the current node.
Definition: Node.h:126
bool isAttribute() const
Whether this is an Attribute node.
Definition: Node.h:92
static xmlTextReaderPtr const _no_reader
NULL Reader referenced by default ctor.
Definition: Node.h:160
int lineNumber() const
Provide the line number of the current parsing point.
Definition: Node.h:110
ReadState readState() const
Gets the read state of the reader.
Definition: Node.h:139
int isEmptyElement() const
Check if the current node is empty.
Definition: Node.h:101
XmlString getAttributeNo(int no_r) const
Provides a copy of the attribute value with the specified index relative to the containing element.
Definition: Node.h:80
XmlString baseUri() const
The base URI of the node.
Definition: Node.h:54
Node()
Default ctor.
Definition: Node.cc:39
XmlString encoding() const
Determine the encoding of the document being read.
Definition: Node.h:66
int quoteChar() const
The quotation mark character used to enclose the value of an attribute.
Definition: Node.h:135
XmlString value() const
Provides the text value of the node if present.
Definition: Node.h:143
XmlString getAttribute(const char *name_r) const
Provides a copy of the attribute value with the specified qualified name.
Definition: Node.h:71
XmlString getAttribute(const std::string &name_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: Node.h:75
XmlString xmlLang() const
The xml:lang scope within which the node resides.
Definition: Node.h:151
xmlTextReaderPtr const & _reader
Reference to the Reader.
Definition: Node.h:162
int columnNumber() const
Provide the column number of the current parsing point.
Definition: Node.h:58
XmlString name() const
The qualified name of the node, equal to Prefix :LocalName.
Definition: Node.h:118
xmlChar * wrapper.
Definition: XmlString.h:41
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
Definition: libxmlfwd.cc:29
xmlTextReaderMode ReadState
Definition: libxmlfwd.h:27
xmlReaderTypes NodeType
Definition: libxmlfwd.h:31
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2