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

libzypp 17.38.13

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-core/base/LogControl.h>
18#include <zypp-core/base/LogTools.h>
19#include <zypp-core/base/Exception.h>
20
21#include <zypp/parser/xml/Node.h>
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 //
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
Exception.h
LogControl.h
LogTools.h
Node.h
zypp::xml::Node
xmlTextReader based interface to Reader's current node.
Definition Node.h:36
zypp::xml::Node::prefix
XmlString prefix() const
A shorthand reference to the namespace associated with the node.
Definition Node.h:130
zypp::xml::Node::_no_reader
static xmlTextReaderPtr const _no_reader
NULL Reader referenced by default ctor.
Definition Node.h:160
zypp::xml::Node::Node
Node()
Default ctor.
Definition Node.cc:39
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)
relates: ReadState Stream output.
Definition libxmlfwd.cc:29
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2