libzypp  11.13.5
Node.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 extern "C"
13 {
14 #include <libxml/xmlreader.h>
15 #include <libxml/xmlerror.h>
16 }
17 
18 #include <iostream>
19 
20 #include "zypp/base/LogControl.h"
21 #include "zypp/base/LogTools.h"
22 #include "zypp/base/Exception.h"
23 
24 #include "zypp/parser/xml/Node.h"
25 
26 using std::endl;
27 
29 namespace zypp
30 {
31 
32  namespace xml
33  {
34 
35  xmlTextReaderPtr const Node::_no_reader = 0;
36 
38  //
39  // METHOD NAME : Node::Node
40  // METHOD TYPE : Constructor
41  //
43  : _reader( _no_reader )
44  {}
45 
47  //
48  // METHOD NAME : Node::Node
49  // METHOD TYPE : Constructor
50  //
51  Node::Node( xmlTextReaderPtr const & reader_r )
52  : _reader( reader_r )
53  {}
54 
55  /******************************************************************
56  **
57  ** FUNCTION NAME : operator<<
58  ** FUNCTION TYPE : std::ostream &
59  */
60  std::ostream & operator<<( std::ostream & str, const Node & obj )
61  {
62  if ( ! obj )
63  return str << "NoNode" << endl;
64 #define X(m) obj.m()
65  str << X(depth) << ":" << std::string( X(depth), ' ') << X(nodeType) << " <";
66  if ( X(nodeType) == XML_READER_TYPE_NONE )
67  {
68  return str << '[' << X(readState) << "]>";
69  }
70  if ( obj.prefix() )
71  str << X(prefix) << ':';
72  str << X(localName) << "> ";
73  if ( X(hasAttributes) )
74  str << " [attr " << X(attributeCount);
75  else
76  str << " [noattr";
77  if ( X(isEmptyElement) )
78  str << "|empty";
79  str << ']';
80  if ( X(hasValue) )
81  str << " {" << X(value) << '}';
82 #undef X
83  return str;
84  }
85 
87  } // namespace xml
90 } // namespace zypp
92