zypp::parser::XMLNodeIterator< ENTRYTYPE > Class Template Reference

#include <XMLNodeIterator.h>

Inheritance diagram for zypp::parser::XMLNodeIterator< ENTRYTYPE >:
[legend]

List of all members.

Public Member Functions

 XMLNodeIterator (std::istream &input, const std::string &baseUrl, const char *validationPath=0, parser::ParserProgress::Ptr progress=parser::ParserProgress::Ptr())
 Constructor.
 XMLNodeIterator (const Pathname xml_file_path, const std::string &baseUrl, const char *validationPath, parser::ParserProgress::Ptr progress)
 Constructor.
 XMLNodeIterator (ENTRYTYPE &entry)
 Constructor for a trivial iterator.
 XMLNodeIterator ()
 Constructor for an empty iterator.
virtual ~XMLNodeIterator ()
 Destructor.
ENTRYTYPE & operator * () const
 Fetch a pointer to the current element.
ENTRYTYPE * operator() () const
 Fetch the current element.
XMLNodeIterator
< ENTRYTYPE > & 
operator++ ()
 Go to the next element and return it.
XMLNodeIterator operator++ (int)
 remember the current element, go to next and return remembered one.
const ENTRYTYPE * operator-> ()
 similar to operator*, allows direct member access

Protected Member Functions

virtual bool isInterested (const xmlNodePtr nodePtr)=0
 filter for the xml nodes The derived class decides which xml nodes it is actually interested in.
virtual ENTRYTYPE process (const xmlTextReaderPtr readerPtr)=0
 process an xml node The derived class has to produce the ENTRYTYPE object here.
void _process (const xmlTextReaderPtr readerPtr)
 process an xml node and set it as next element The derived class has to produce the ENTRYTYPE object here.

Private Member Functions

void setCurrent (const void *data)
void * getCurrent () const

Private Attributes

std::auto_ptr
< ENTRYTYPE > 
_current
 contains the current element of the iterator.


Detailed Description

template<class ENTRYTYPE>
class zypp::parser::XMLNodeIterator< ENTRYTYPE >

Definition at line 331 of file XMLNodeIterator.h.


Constructor & Destructor Documentation

template<class ENTRYTYPE>
zypp::parser::XMLNodeIterator< ENTRYTYPE >::XMLNodeIterator ( std::istream &  input,
const std::string &  baseUrl,
const char *  validationPath = 0,
parser::ParserProgress::Ptr  progress = parser::ParserProgress::Ptr() 
) [inline]

Constructor.

Derived classes must call fetchNext() here.

Parameters:
input is the input stream (contains the xml stuff)
baseUrl is the base URL of the xml document FIXME: use XMLParserError::operator<< instead of doing it on my own.

Definition at line 340 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
zypp::parser::XMLNodeIterator< ENTRYTYPE >::XMLNodeIterator ( const Pathname  xml_file_path,
const std::string &  baseUrl,
const char *  validationPath,
parser::ParserProgress::Ptr  progress 
) [inline]

Constructor.

Derived classes must call fetchNext() here.

Parameters:
xml_file_path is the xml file
baseUrl is the base URL of the xml document FIXME: use XMLParserError::operator<< instead of doing it on my own.

Definition at line 357 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
zypp::parser::XMLNodeIterator< ENTRYTYPE >::XMLNodeIterator ( ENTRYTYPE &  entry  )  [inline]

Constructor for a trivial iterator.

A trivial iterator contains only one element. This is at least needed internally for the postinc (iter++) operator

Parameters:
entry is the one and only element of this iterator.

Definition at line 370 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
zypp::parser::XMLNodeIterator< ENTRYTYPE >::XMLNodeIterator (  )  [inline]

Constructor for an empty iterator.

An empty iterator is already at its end. This is what end() returns ...

Definition at line 381 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
virtual zypp::parser::XMLNodeIterator< ENTRYTYPE >::~XMLNodeIterator (  )  [inline, virtual]

Destructor.

Definition at line 388 of file XMLNodeIterator.h.


Member Function Documentation

template<class ENTRYTYPE>
ENTRYTYPE& zypp::parser::XMLNodeIterator< ENTRYTYPE >::operator * (  )  const [inline]

Fetch a pointer to the current element.

Returns:
pointer to the current element.

Definition at line 396 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
ENTRYTYPE* zypp::parser::XMLNodeIterator< ENTRYTYPE >::operator() (  )  const [inline]

Fetch the current element.

Returns:
the current element

Definition at line 407 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
XMLNodeIterator<ENTRYTYPE>& zypp::parser::XMLNodeIterator< ENTRYTYPE >::operator++ (  )  [inline]

Go to the next element and return it.

Returns:
the next element

Definition at line 420 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
XMLNodeIterator zypp::parser::XMLNodeIterator< ENTRYTYPE >::operator++ ( int   )  [inline]

remember the current element, go to next and return remembered one.

avoid this, usually you need the preinc operator (++iter) This function may throw ParserError if something is fundamentally wrong with the input.

Returns:
the current element

Definition at line 432 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
const ENTRYTYPE* zypp::parser::XMLNodeIterator< ENTRYTYPE >::operator-> (  )  [inline]

similar to operator*, allows direct member access

Returns:
pointer to current element

Definition at line 445 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
virtual bool zypp::parser::XMLNodeIterator< ENTRYTYPE >::isInterested ( const xmlNodePtr  nodePtr  )  [protected, pure virtual]

filter for the xml nodes The derived class decides which xml nodes it is actually interested in.

For each that is selected, process() will be called an the resulting ENTRYTYPE object used as the next value for the iterator. Documentation for the node structure can be found in the libxml2 documentation. Have a look at LibXMLHelper to access node attributes and contents.

Parameters:
nodePtr points to the xml node in question. Only the node is available, not the subtree. See libxml2 documentation.
Returns:
true if interested

Implements zypp::parser::XMLNodeIteratorBase.

Implemented in zypp::parser::xmlstore::XMLLanguageParser, zypp::parser::xmlstore::XMLPatchParser, zypp::parser::xmlstore::XMLPatternParser, zypp::parser::xmlstore::XMLProductParser, and zypp::parser::xmlstore::XMLSourceCacheParser.

template<class ENTRYTYPE>
virtual ENTRYTYPE zypp::parser::XMLNodeIterator< ENTRYTYPE >::process ( const xmlTextReaderPtr  readerPtr  )  [protected, pure virtual]

process an xml node The derived class has to produce the ENTRYTYPE object here.

Details about the xml reader is in the libxml2 documentation. You'll most probably want to use xmlTextReaderExpand(reader) to request the full subtree, and then use the links in the resulting node structure to traverse, and class LibXMLHelper to access the attributes and element contents. fetchNext() cannot throw an error since it will be called in the constructor. Instead, in case of a fundamental syntax error the error is saved and will be thrown with the next checkError().

Parameters:
readerPtr points to the xmlTextReader that reads the xml stream.
Returns:

Implemented in zypp::parser::xmlstore::XMLLanguageParser, zypp::parser::xmlstore::XMLPatchParser, zypp::parser::xmlstore::XMLPatternParser, zypp::parser::xmlstore::XMLProductParser, and zypp::parser::xmlstore::XMLSourceCacheParser.

Referenced by zypp::parser::XMLNodeIterator< shared_ptr >::_process().

template<class ENTRYTYPE>
void zypp::parser::XMLNodeIterator< ENTRYTYPE >::_process ( const xmlTextReaderPtr  readerPtr  )  [inline, protected, virtual]

process an xml node and set it as next element The derived class has to produce the ENTRYTYPE object here.

Details about the xml reader is in the libxml2 documentation. You'll most probably want to use xmlTextReaderExpand(reader) to request the full subtree, and then use the links in the resulting node structure to traverse, and class LibXMLHelper to access the attributes and element contents. fetchNext() cannot throw an error since it will be called in the constructor. Instead, in case of a fundamental syntax error the error is saved and will be thrown with the next checkError().

Parameters:
readerPtr points to the xmlTextReader that reads the xml stream.

Implements zypp::parser::XMLNodeIteratorBase.

Definition at line 485 of file XMLNodeIterator.h.

template<class ENTRYTYPE>
void zypp::parser::XMLNodeIterator< ENTRYTYPE >::setCurrent ( const void *  data  )  [inline, private, virtual]

Implements zypp::parser::XMLNodeIteratorBase.

Definition at line 492 of file XMLNodeIterator.h.

Referenced by zypp::parser::XMLNodeIterator< shared_ptr >::XMLNodeIterator().

template<class ENTRYTYPE>
void* zypp::parser::XMLNodeIterator< ENTRYTYPE >::getCurrent (  )  const [inline, private, virtual]

Implements zypp::parser::XMLNodeIteratorBase.

Definition at line 500 of file XMLNodeIterator.h.

Referenced by zypp::parser::XMLNodeIterator< shared_ptr >::operator *(), zypp::parser::XMLNodeIterator< shared_ptr >::operator()(), and zypp::parser::XMLNodeIterator< shared_ptr >::operator->().


Member Data Documentation

template<class ENTRYTYPE>
std::auto_ptr<ENTRYTYPE> zypp::parser::XMLNodeIterator< ENTRYTYPE >::_current [private]

contains the current element of the iterator.

a pointer is used to be able to handle non-assigneable ENTRYTYPEs. The iterator owns the element until the next ++ operation. It can be 0 when the end has been reached.

Definition at line 511 of file XMLNodeIterator.h.

Referenced by zypp::parser::XMLNodeIterator< shared_ptr >::_process(), zypp::parser::XMLNodeIterator< shared_ptr >::getCurrent(), and zypp::parser::XMLNodeIterator< shared_ptr >::setCurrent().


The documentation for this class was generated from the following file:
Generated on Tue Sep 25 19:23:22 2007 for libzypp by  doxygen 1.5.3