libzypp  10.5.0
Node.cc
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 extern "C"
00013 {
00014 #include <libxml/xmlreader.h>
00015 #include <libxml/xmlerror.h>
00016 }
00017 
00018 #include <iostream>
00019 
00020 #include "zypp/base/LogControl.h"
00021 #include "zypp/base/LogTools.h"
00022 #include "zypp/base/Exception.h"
00023 
00024 #include "zypp/parser/xml/Node.h"
00025 
00026 using std::endl;
00027 
00029 namespace zypp
00030 { 
00031 
00032   namespace xml
00033   { 
00034 
00035     xmlTextReaderPtr const Node::_no_reader = 0;
00036 
00038     //
00039     //  METHOD NAME : Node::Node
00040     //  METHOD TYPE : Constructor
00041     //
00042     Node::Node()
00043     : _reader( _no_reader )
00044     {}
00045 
00047     //
00048     //  METHOD NAME : Node::Node
00049     //  METHOD TYPE : Constructor
00050     //
00051     Node::Node( xmlTextReaderPtr const & reader_r )
00052     : _reader( reader_r )
00053     {}
00054 
00055     /******************************************************************
00056      **
00057      ** FUNCTION NAME : operator<<
00058      ** FUNCTION TYPE : std::ostream &
00059     */
00060     std::ostream & operator<<( std::ostream & str, const Node & obj )
00061     {
00062       if ( ! obj )
00063         return str << "NoNode" << endl;
00064 #define X(m) obj.m()
00065       str << X(depth) << ":" <<  std::string( X(depth), ' ') << X(nodeType) << " <";
00066       if ( X(nodeType) == XML_READER_TYPE_NONE )
00067         {
00068           return str << '[' << X(readState) << "]>";
00069         }
00070       if ( obj.prefix() )
00071         str << X(prefix) << ':';
00072       str << X(localName) << "> ";
00073       if ( X(hasAttributes) )
00074         str << " [attr " << X(attributeCount);
00075       else
00076         str << " [noattr";
00077       if ( X(isEmptyElement) )
00078         str << "|empty";
00079       str << ']';
00080       if ( X(hasValue) )
00081         str << " {" << X(value) << '}';
00082 #undef X
00083       return str;
00084     }
00085 
00087   } // namespace xml
00090 } // namespace zypp
00092