libzypp  16.22.5
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 {
28  namespace xml
30  {
31 
32  xmlTextReaderPtr const Node::_no_reader = 0;
33 
35  //
36  // METHOD NAME : Node::Node
37  // METHOD TYPE : Constructor
38  //
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 
xmlTextReader based interface to Reader's current node.
Definition: Node.h:35
Node()
Default ctor.
Definition: Node.cc:39
std::ostream & operator<<(std::ostream &str, const ReadState &obj)
Definition: libxmlfwd.cc:29
#define X(m)
XmlString prefix() const
A shorthand reference to the namespace associated with the node.
Definition: Node.h:130
static xmlTextReaderPtr const _no_reader
NULL Reader referenced by default ctor.
Definition: Node.h:160