libzypp  13.10.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 
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 ); }
74 
77  XmlString getAttributeNo( int no_r ) const
78  { return XmlString( xmlTextReaderGetAttributeNo( _reader, no_r ), XmlString::FREE ); }
79 
81  int hasAttributes() const
82  { return xmlTextReaderHasAttributes( _reader ); }
83 
85  int hasValue() const
86  { return xmlTextReaderHasValue( _reader ); }
87 
89  bool isAttribute() const
90  { return( nodeType() == XML_READER_TYPE_ATTRIBUTE ); }
91 
94  int isDefault() const
95  { return xmlTextReaderIsDefault( _reader ); }
96 
98  int isEmptyElement() const
99  { return xmlTextReaderIsEmptyElement( _reader ); }
100 
103  int isNamespaceDecl() const
104  { return xmlTextReaderIsNamespaceDecl( _reader ); }
105 
107  int lineNumber() const
108  { return xmlTextReaderGetParserLineNumber( _reader ); }
109 
112  { return xmlTextReaderConstLocalName( _reader ); }
113 
115  XmlString name() const
116  { return xmlTextReaderConstName( _reader ); }
117 
120  { return xmlTextReaderConstNamespaceUri( _reader ); }
121 
124  { return (NodeType)xmlTextReaderNodeType( _reader ); }
125 
128  { return xmlTextReaderConstPrefix( _reader ); }
129 
132  int quoteChar() const
133  { return xmlTextReaderQuoteChar( _reader ); }
134 
137  { return (ReadState)xmlTextReaderReadState( _reader ); }
138 
140  XmlString value() const
141  { return xmlTextReaderConstValue( _reader ); }
142 
145  { return XmlString( xmlTextReaderValue( _reader ), XmlString::FREE ); }
146 
149  { return xmlTextReaderConstXmlLang( _reader ); }
150 
153  { return xmlTextReaderConstXmlVersion( _reader ); }
154 
155  private:
157  static xmlTextReaderPtr const _no_reader;
159  xmlTextReaderPtr const & _reader;
160  };
162 
164  std::ostream & operator<<( std::ostream & str, const Node & obj );
165 
167  } // namespace xml
170 } // namespace zypp
172 #endif // ZYPP_PARSER_XML_NODE_H
ReadState readState() const
Gets the read state of the reader.
Definition: Node.h:136
bool isAttribute() const
Whether this is an Attribute node.
Definition: Node.h:89
XmlString baseUri() const
The base URI of the node.
Definition: Node.h:54
int isDefault() const
Whether an Attribute node was generated from the default value defined in the DTD or schema...
Definition: Node.h:94
XmlString localName() const
The local name of the node.
Definition: Node.h:111
xmlTextReaderPtr const & _reader
Reference to the Reader.
Definition: Node.h:159
xmlChar * wrapper.
Definition: XmlString.h:40
int isEmptyElement() const
Check if the current node is empty.
Definition: Node.h:98
int depth() const
The depth of the node in the tree.
Definition: Node.h:62
XmlString xmlVersion() const
Determine the XML version of the document being read.
Definition: Node.h:152
XmlString value() const
Provides the text value of the node if present.
Definition: Node.h:140
xmlTextReader based interface to Reader&#39;s current node.
Definition: Node.h:35
int hasValue() const
Whether the node can have a text value.
Definition: Node.h:85
XmlString encoding() const
Determine the encoding of the document being read.
Definition: Node.h:66
XmlString name() const
The qualified name of the node, equal to Prefix :LocalName.
Definition: Node.h:115
int columnNumber() const
Provide the column number of the current parsing point.
Definition: Node.h:58
XmlString getValue() const
Provides a copy of the text value of the node if present.
Definition: Node.h:144
Node()
Default ctor.
Definition: Node.cc:39
XmlString getAttribute(const char *name_r) const
Provides a copy of the attribute value with the specified qualified name.
Definition: Node.h:71
int lineNumber() const
Provide the line number of the current parsing point.
Definition: Node.h:107
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:77
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
Definition: libxmlfwd.cc:29
xmlReaderTypes NodeType
Definition: libxmlfwd.h:34
XmlString namespaceUri() const
The URI defining the namespace associated with the node.
Definition: Node.h:119
int attributeCount() const
Provides the number of attributes of the current node.
Definition: Node.h:50
XmlString prefix() const
A shorthand reference to the namespace associated with the node.
Definition: Node.h:127
static xmlTextReaderPtr const _no_reader
NULL Reader referenced by default ctor.
Definition: Node.h:157
int hasAttributes() const
Whether the node has attributes.
Definition: Node.h:81
xmlTextReaderMode ReadState
Definition: libxmlfwd.h:30
NodeType nodeType() const
Get the node type of the current node.
Definition: Node.h:123
int isNamespaceDecl() const
Determine whether the current node is a namespace declaration rather than a regular attribute...
Definition: Node.h:103
XmlString xmlLang() const
The xml:lang scope within which the node resides.
Definition: Node.h:148
int quoteChar() const
The quotation mark character used to enclose the value of an attribute.
Definition: Node.h:132