libzypp 17.37.10

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
17#include <zypp/base/LogControl.h>
18#include <zypp/base/LogTools.h>
19#include <zypp/base/Exception.h>
20
21#include <zypp/parser/xml/Node.h>
22
23 using std::endl;
24
26 namespace 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 //
39 Node::Node()
40 : _reader( _no_reader )
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
Node.h
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::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::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::_no_reader
static xmlTextReaderPtr const _no_reader
NULL Reader referenced by default ctor.
Definition Node.h:160
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::Node
Node()
Default ctor.
Definition Node.cc:39
zypp::xml::Node::value
XmlString value() const
Provides the text value of the node if present.
Definition Node.h:143
zypp::xml::Node::_reader
xmlTextReaderPtr const & _reader
Reference to the Reader.
Definition Node.h:162
X
#define X(T)
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)
Definition libxmlfwd.cc:29
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition Application.cc:20
Exception.h
LogControl.h
LogTools.h