libzypp 17.37.17
Node.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <libxml/xmlreader.h>
13#include <libxml/xmlerror.h>
14
15#include <iostream>
16
18#include <zypp/base/LogTools.h>
19#include <zypp/base/Exception.h>
20
22
23using std::endl;
24
26namespace zypp
27{
29 namespace xml
30 {
31
32 xmlTextReaderPtr const Node::_no_reader = 0;
33
35 //
36 // METHOD NAME : Node::Node
37 // METHOD TYPE : Constructor
38 //
41 {}
42
44 //
45 // METHOD NAME : Node::Node
46 // METHOD TYPE : Constructor
47 //
48 Node::Node( xmlTextReaderPtr const & reader_r )
49 : _reader( reader_r )
50 {}
51
52 /******************************************************************
53 **
54 ** FUNCTION NAME : operator<<
55 ** FUNCTION TYPE : std::ostream &
56 */
57 std::ostream & operator<<( std::ostream & str, const Node & obj )
58 {
59 if ( ! obj )
60 return str << "NoNode" << endl;
61#define X(m) obj.m()
62 str << X(depth) << ":" << std::string( X(depth), ' ') << X(nodeType) << " <";
63 if ( X(nodeType) == XML_READER_TYPE_NONE )
64 {
65 return str << '[' << X(readState) << "]>";
66 }
67 if ( obj.prefix() )
68 str << X(prefix) << ':';
69 str << X(localName) << "> ";
70 if ( X(hasAttributes) )
71 str << " [attr " << X(attributeCount);
72 else
73 str << " [noattr";
74 if ( X(isEmptyElement) )
75 str << "|empty";
76 str << ']';
77 if ( X(hasValue) )
78 str << " {" << X(value) << '}';
79#undef X
80 return str;
81 }
82
84 } // namespace xml
87} // namespace zypp
89
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
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
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
static xmlTextReaderPtr const _no_reader
NULL Reader referenced by default ctor.
Definition Node.h:160
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
Node()
Default ctor.
Definition Node.cc:39
XmlString value() const
Provides the text value of the node if present.
Definition Node.h:143
xmlTextReaderPtr const & _reader
Reference to the Reader.
Definition Node.h:162
#define X(T)
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
Definition libxmlfwd.cc:29
Easy-to use interface to the ZYPP dependency resolver.