libzypp: zypp/parser/xml/Node.h Source File

libzypp 17.38.10

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
17#include <zypp/parser/xml/XmlString.h>
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
54 XmlString baseUri() const
55 { return xmlTextReaderConstBaseUri( _reader ); }
56
58 int columnNumber() const
59 { return xmlTextReaderGetParserColumnNumber( _reader ); }
60
62 int depth() const
63 { return xmlTextReaderDepth( _reader ); }
64
66 XmlString encoding() const
67 { return xmlTextReaderConstEncoding( _reader ); }
68
71 XmlString getAttribute( const char * name_r ) const
72 { return XmlString( xmlTextReaderGetAttribute( _reader, reinterpret_cast<const xmlChar *>(name_r) ),
73 XmlString::FREE ); }
74
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
114 XmlString localName() const
115 { return xmlTextReaderConstLocalName( _reader ); }
116
118 XmlString name() const
119 { return xmlTextReaderConstName( _reader ); }
120
122 XmlString namespaceUri() const
123 { return xmlTextReaderConstNamespaceUri( _reader ); }
124
126 NodeType nodeType() const
127 { return (NodeType)xmlTextReaderNodeType( _reader ); }
128
130 XmlString prefix() const
131 { return xmlTextReaderConstPrefix( _reader ); }
132
135 int quoteChar() const
136 { return xmlTextReaderQuoteChar( _reader ); }
137
139 ReadState readState() const
140 { return (ReadState)xmlTextReaderReadState( _reader ); }
141
143 XmlString value() const
144 { return xmlTextReaderConstValue( _reader ); }
145
147 XmlString getValue() const
148 { return XmlString( xmlTextReaderValue( _reader ), XmlString::FREE ); }
149
151 XmlString xmlLang() const
152 { return xmlTextReaderConstXmlLang( _reader ); }
153
155 XmlString xmlVersion() const
156 { return xmlTextReaderConstXmlVersion( _reader ); }
157
158 private:
160 static xmlTextReaderPtr const _no_reader;
162 xmlTextReaderPtr const & _reader;
163 };
164
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
XmlString.h
bool
zypp::xml::Node
xmlTextReader based interface to Reader's current node.
Definition Node.h:36
zypp::xml::Node::getValue
XmlString getValue() const
Provides a copy of the text value of the node if present.
Definition Node.h:147
zypp::xml::Node::localName
XmlString localName() const
The local name of the node.
Definition Node.h:114
zypp::xml::Node::prefix
XmlString prefix() const
A shorthand reference to the namespace associated with the node.
Definition Node.h:130
zypp::xml::Node::depth
int depth() const
The depth of the node in the tree.
Definition Node.h:62
zypp::xml::Node::namespaceUri
XmlString namespaceUri() const
The URI defining the namespace associated with the node.
Definition Node.h:122
zypp::xml::Node::isNamespaceDecl
int isNamespaceDecl() const
Determine whether the current node is a namespace declaration rather than a regular attribute.
Definition Node.h:106
zypp::xml::Node::hasAttributes
int hasAttributes() const
Whether the node has attributes.
Definition Node.h:84
zypp::xml::Node::attributeCount
int attributeCount() const
Provides the number of attributes of the current node.
Definition Node.h:50
zypp::xml::Node::xmlVersion
XmlString xmlVersion() const
Determine the XML version of the document being read.
Definition Node.h:155
zypp::xml::Node::isDefault
int isDefault() const
Whether an Attribute node was generated from the default value defined in the DTD or schema.
Definition Node.h:97
zypp::xml::Node::hasValue
int hasValue() const
Whether the node can have a text value.
Definition Node.h:88
zypp::xml::Node::nodeType
NodeType nodeType() const
Get the node type of the current node.
Definition Node.h:126
zypp::xml::Node::isAttribute
bool isAttribute() const
Whether this is an Attribute node.
Definition Node.h:92
zypp::xml::Node::_no_reader
static xmlTextReaderPtr const _no_reader
NULL Reader referenced by default ctor.
Definition Node.h:160
zypp::xml::Node::lineNumber
int lineNumber() const
Provide the line number of the current parsing point.
Definition Node.h:110
zypp::xml::Node::readState
ReadState readState() const
Gets the read state of the reader.
Definition Node.h:139
zypp::xml::Node::isEmptyElement
int isEmptyElement() const
Check if the current node is empty.
Definition Node.h:101
zypp::xml::Node::getAttributeNo
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
zypp::xml::Node::baseUri
XmlString baseUri() const
The base URI of the node.
Definition Node.h:54
zypp::xml::Node::Node
Node()
Default ctor.
Definition Node.cc:39
zypp::xml::Node::encoding
XmlString encoding() const
Determine the encoding of the document being read.
Definition Node.h:66
zypp::xml::Node::quoteChar
int quoteChar() const
The quotation mark character used to enclose the value of an attribute.
Definition Node.h:135
zypp::xml::Node::value
XmlString value() const
Provides the text value of the node if present.
Definition Node.h:143
zypp::xml::Node::getAttribute
XmlString getAttribute(const char *name_r) const
Provides a copy of the attribute value with the specified qualified name.
Definition Node.h:71
zypp::xml::Node::getAttribute
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
zypp::xml::Node::xmlLang
XmlString xmlLang() const
The xml:lang scope within which the node resides.
Definition Node.h:151
zypp::xml::Node::_reader
xmlTextReaderPtr const & _reader
Reference to the Reader.
Definition Node.h:162
zypp::xml::Node::columnNumber
int columnNumber() const
Provide the column number of the current parsing point.
Definition Node.h:58
zypp::xml::Node::name
XmlString name() const
The qualified name of the node, equal to Prefix :LocalName.
Definition Node.h:118
zypp::xml::XmlString
xmlChar * wrapper.
Definition XmlString.h:41
zypp::xml::XmlString::FREE
@ FREE
Definition XmlString.h:52
str
String related utilities and Regular expression matching.
zypp::xml
Definition libxmlfwd.cc:22
zypp::xml::operator<<
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
relates: ReadState Stream output.
Definition libxmlfwd.cc:29
zypp::xml::NodeType
xmlReaderTypes NodeType
Definition libxmlfwd.h:31
zypp::xml::ReadState
xmlTextReaderMode ReadState
Definition libxmlfwd.h:27
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2