libzypp  13.10.6
zypp::xml::Reader Class Reference

xmlTextReader based interface to iterate xml streams. More...

#include <Reader.h>

Inheritance diagram for zypp::xml::Reader:

Public Types

typedef function< bool(Reader &)> ProcessNode
 

Public Member Functions

 Reader (const InputStream &stream_r, const Validate &validate_r=Validate::none())
 Ctor. More...
 
 ~Reader ()
 Dtor. More...
 
XmlString nodeText ()
 If the curent node is not empty, advances the reader to the next node, and returns the value. More...
 
bool nextNode ()
 
bool nextNodeAttribute ()
 
bool nextNodeOrAttribute ()
 
bool atEnd () const
 
const Nodeoperator* () const
 
const Nodeoperator-> () const
 
bool foreachNode (ProcessNode fnc_r)
 
bool foreachNodeAttribute (ProcessNode fnc_r)
 
bool foreachNodeOrAttribute (ProcessNode fnc_r)
 
bool seekToNode (int depth_r, const std::string &name_r)
 
bool seekToEndNode (int depth_r, const std::string &name_r)
 

Private Member Functions

void close ()
 

Private Attributes

InputStream _stream
 
xmlTextReaderPtr _reader
 
Node _node
 

Detailed Description

xmlTextReader based interface to iterate xml streams.

* // Consume a node.
* bool consumeNode( XML::Reader & reader_r )
* {
* DBG << *reader_r << endl;
* return true;
* }
*
* // Consume all nodes (omitting attributes)
* void example()
* {
* try
* {
* XML::Reader reader( "/Local/repodata/repomd.xml" );
* reader.foreachNode( consumeNode );
* }
* catch ( const Exception & )
* { ; } // parse error
* }
*
* // Consume a node.
* bool consumeNodeAndAttribute( XML::Reader & reader_r )
* {
* consumeNode( reader_r );
* return reader_r.foreachNodeAttribute( consumeNode );
* }
*
* // Consume all nodes and thair attributes.
* void example()
* {
* Pathname repodata( "/Local/repodata/repomd.xml" );
* try
* {
* XML::Reader reader( "/Local/repodata/repomd.xml" );
* reader.foreachNode( consumeNodeAndAttribute );
* // or:
* // reader.foreachNodeOrAttribute( consumeNode )
* }
* catch ( const Exception & )
* { ; } // parse error
* }
*

Definition at line 95 of file Reader.h.

Member Typedef Documentation

typedef function<bool( Reader & )> zypp::xml::Reader::ProcessNode

Definition at line 141 of file Reader.h.

Constructor & Destructor Documentation

zypp::xml::Reader::Reader ( const InputStream stream_r,
const Validate validate_r = Validate::none() 
)

Ctor.

Setup xmlTextReader and advance to the 1st Node.

Definition at line 106 of file Reader.cc.

zypp::xml::Reader::~Reader ( )

Dtor.

Definition at line 131 of file Reader.cc.

Member Function Documentation

XmlString zypp::xml::Reader::nodeText ( )

If the curent node is not empty, advances the reader to the next node, and returns the value.

Note
if the node has a xml subtree you will probably jump to that node and get a empty text value back. Use it only if you are sure the node has no XML subtree.

Definition at line 140 of file Reader.cc.

bool zypp::xml::Reader::nextNode ( )

Definition at line 160 of file Reader.cc.

bool zypp::xml::Reader::nextNodeAttribute ( )

Definition at line 180 of file Reader.cc.

bool zypp::xml::Reader::nextNodeOrAttribute ( )
inline

Definition at line 124 of file Reader.h.

bool zypp::xml::Reader::atEnd ( ) const
inline

Definition at line 128 of file Reader.h.

const Node& zypp::xml::Reader::operator* ( ) const
inline

Definition at line 132 of file Reader.h.

const Node* zypp::xml::Reader::operator-> ( ) const
inline

Definition at line 136 of file Reader.h.

bool zypp::xml::Reader::foreachNode ( ProcessNode  fnc_r)
inline

Definition at line 144 of file Reader.h.

bool zypp::xml::Reader::foreachNodeAttribute ( ProcessNode  fnc_r)
inline

Definition at line 157 of file Reader.h.

bool zypp::xml::Reader::foreachNodeOrAttribute ( ProcessNode  fnc_r)
inline

Definition at line 170 of file Reader.h.

bool zypp::xml::Reader::seekToNode ( int  depth_r,
const std::string &  name_r 
)

Definition at line 212 of file Reader.cc.

bool zypp::xml::Reader::seekToEndNode ( int  depth_r,
const std::string &  name_r 
)

Definition at line 232 of file Reader.cc.

void zypp::xml::Reader::close ( )
private

Definition at line 199 of file Reader.cc.

Member Data Documentation

InputStream zypp::xml::Reader::_stream
private

Definition at line 191 of file Reader.h.

xmlTextReaderPtr zypp::xml::Reader::_reader
private

Definition at line 192 of file Reader.h.

Node zypp::xml::Reader::_node
private

Definition at line 193 of file Reader.h.


The documentation for this class was generated from the following files: