libzypp  17.25.0
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 
20 namespace zypp
21 {
22  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) ),
73  XmlString::FREE ); }
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 
118  XmlString name() const
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 
143  XmlString value() const
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
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::XmlString::FREE
Definition: XmlString.h:52
zypp::xml::Node::baseUri
XmlString baseUri() const
The base URI of the node.
Definition: Node.h:54
zypp::xml::Node::readState
ReadState readState() const
Gets the read state of the reader.
Definition: Node.h:139
zypp::xml::ReadState
xmlTextReaderMode ReadState
Definition: libxmlfwd.h:27
zypp::xml::Node::prefix
XmlString prefix() const
A shorthand reference to the namespace associated with the node.
Definition: Node.h:130
zypp::xml::Node::xmlVersion
XmlString xmlVersion() const
Determine the XML version of the document being read.
Definition: Node.h:155
zypp::xml::NodeType
xmlReaderTypes NodeType
Definition: libxmlfwd.h:31
zypp::xml::operator<<
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
Definition: libxmlfwd.cc:28
zypp::xml::Node::quoteChar
int quoteChar() const
The quotation mark character used to enclose the value of an attribute.
Definition: Node.h:135
XmlString.h
zypp::xml::Node::_reader
const xmlTextReaderPtr & _reader
Reference to the Reader.
Definition: Node.h:162
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::namespaceUri
XmlString namespaceUri() const
The URI defining the namespace associated with the node.
Definition: Node.h:122
zypp::xml::Node::Node
Node()
Default ctor.
Definition: Node.cc:39
zypp::xml::Node::attributeCount
int attributeCount() const
Provides the number of attributes of the current node.
Definition: Node.h:50
zypp::xml::Node::hasValue
int hasValue() const
Whether the node can have a text value.
Definition: Node.h:88
bool
zypp::xml::Node::isAttribute
bool isAttribute() const
Whether this is an Attribute node.
Definition: Node.h:92
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::nodeType
NodeType nodeType() const
Get the node type of the current node.
Definition: Node.h:126
zypp::xml::Node::localName
XmlString localName() const
The local name of the node.
Definition: Node.h:114
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::xmlLang
XmlString xmlLang() const
The xml:lang scope within which the node resides.
Definition: Node.h:151
zypp::xml::Node::name
XmlString name() const
The qualified name of the node, equal to Prefix :LocalName.
Definition: Node.h:118
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
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::_no_reader
static const xmlTextReaderPtr _no_reader
NULL Reader referenced by default ctor.
Definition: Node.h:160
zypp::xml::Node::hasAttributes
int hasAttributes() const
Whether the node has attributes.
Definition: Node.h:84
zypp::xml::Node::columnNumber
int columnNumber() const
Provide the column number of the current parsing point.
Definition: Node.h:58
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::depth
int depth() const
The depth of the node in the tree.
Definition: Node.h:62
zypp::xml::Node::lineNumber
int lineNumber() const
Provide the line number of the current parsing point.
Definition: Node.h:110
zypp::xml::XmlString
xmlChar * wrapper.
Definition: XmlString.h:40
xml
zypp::xml::Node::encoding
XmlString encoding() const
Determine the encoding of the document being read.
Definition: Node.h:66
zypp::xml::Node::value
XmlString value() const
Provides the text value of the node if present.
Definition: Node.h:143
zypp::xml::Node
xmlTextReader based interface to Reader's current node.
Definition: Node.h:35
str
String related utilities and Regular expression matching.
zypp::xml::Node::isEmptyElement
int isEmptyElement() const
Check if the current node is empty.
Definition: Node.h:101