#include <XMLNodeIterator.h>
Inheritance diagram for zypp::parser::XMLNodeIteratorBase:
Public Member Functions | |
XMLNodeIteratorBase (std::istream &input, const std::string &baseUrl, const char *validationPath=0) | |
Constructor. | |
XMLNodeIteratorBase () | |
Constructor for an empty iterator. | |
virtual | ~XMLNodeIteratorBase () |
Destructor. | |
bool | atEnd () const |
Have we reached the end? A parser error also means "end reached". | |
bool | operator== (const XMLNodeIteratorBase &other) const |
Two iterators are equal if both are at the end or if they are identical. | |
bool | operator!= (const XMLNodeIteratorBase &otherNode) const |
Opposit of operator==. | |
const XMLParserError * | errorStatus () const |
returns the error status or 0 if no error the returned pointer is not-owning, it will be deleted upon destruction of the XMLNodeIterator. | |
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 void | _process (const xmlTextReaderPtr readerPtr)=0 |
process an xml node and set it as next element The derived class has to produce the ENTRYTYPE object here. | |
void | fetchNext () |
Fetch the next element and save it as next element. | |
virtual void | setCurrent (const void *data)=0 |
virtual void * | getCurrent () const =0 |
Static Protected Member Functions | |
static void | errorHandler (void *arg, const char *msg, int severity, xmlTextReaderLocatorPtr locator) |
Internal function to set the _error variable in case of a parser error. | |
Private Member Functions | |
XMLNodeIteratorBase & | operator= (const XMLNodeIteratorBase &otherNode) |
assignment is forbidden. | |
XMLNodeIteratorBase (const XMLNodeIteratorBase &otherNode) | |
copy constructor is forbidden. | |
Private Attributes | |
std::auto_ptr< XMLParserError > | _error |
if an error occured, this contains the error. | |
std::istream * | _input |
contains the istream to read the xml file from. | |
xmlTextReaderPtr | _reader |
contains the xmlTextReader used to parse the xml file. | |
std::string | _baseUrl |
contains the base URL of the xml documentation |
Derive from XMLNodeIterator<ENTRYTYPE> to get an iterator that returns ENTRYTYPE objects. A derived class must provide isInterested() and process(). It should also provide a Constructor Derived(std::stream,std::string baseUrl) which must call fetchNext().
The derived iterator class should be compatible with an stl input iterator. Use like this:
for (Iterator iter(anIstream, baseUrl), iter != Iterator.end(), // or: iter() != 0, or ! iter.atEnd() ++iter) { doSomething(*iter) }
The iterator owns the pointer (i.e., caller must not delete it) until the next ++ operator is called. At this time, it will be destroyed (and a new ENTRYTYPE is created.)
If the input is fundamentally flawed so that it makes no sense to continue parsing, XMLNodeIterator will log it and consider the input as finished. You can query the exit status with errorStatus().
Definition at line 133 of file XMLNodeIterator.h.
|
Constructor. Derived classes must call fetchNext() here.
Definition at line 122 of file XMLNodeIterator.cc. References _reader, errorHandler(), and WAR. |
|
Constructor for an empty iterator. An empty iterator is already at its end. This is what end() returns ... Definition at line 147 of file XMLNodeIterator.cc. |
|
Destructor.
Definition at line 153 of file XMLNodeIterator.cc. References _reader. |
|
copy constructor is forbidden. Reason: We can't copy an xmlTextReader FIXME: This prevents implementing the end() method for derived classes.
|
|
Have we reached the end? A parser error also means "end reached".
Definition at line 161 of file XMLNodeIterator.cc. References _error, and getCurrent(). Referenced by zypp::source::yum::YUMSourceImpl::checkMetadataChecksums(), zypp::source::yum::YUMSourceImpl::createResolvables(), zypp::parser::XMLNodeIterator< YUMRepomdData_Ptr >::operator *(), zypp::parser::XMLNodeIterator< YUMRepomdData_Ptr >::operator++(), zypp::parser::XMLNodeIterator< YUMRepomdData_Ptr >::operator->(), operator==(), and zypp::storage::XMLFilesBackend::resolvablesFromFile(). |
|
Two iterators are equal if both are at the end or if they are identical. Since you cannot copy an XMLNodeIterator, everything else is not equal.
Definition at line 169 of file XMLNodeIterator.cc. References atEnd(). Referenced by operator!=(). |
|
Opposit of operator==.
Definition at line 181 of file XMLNodeIterator.h. References operator==(). |
|
returns the error status or 0 if no error the returned pointer is not-owning, it will be deleted upon destruction of the XMLNodeIterator.
Definition at line 179 of file XMLNodeIterator.cc. References _error. |
|
|
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().
Implemented in zypp::parser::XMLNodeIterator< ENTRYTYPE >, zypp::parser::XMLNodeIterator< XMLProductData_Ptr >, zypp::parser::XMLNodeIterator< XMLPatternData_Ptr >, zypp::parser::XMLNodeIterator< XMLLanguageData_Ptr >, zypp::parser::XMLNodeIterator< YUMOtherData_Ptr >, zypp::parser::XMLNodeIterator< XMLPatchData_Ptr >, zypp::parser::XMLNodeIterator< YUMGroupData_Ptr >, zypp::parser::XMLNodeIterator< YUMPatchesData_Ptr >, zypp::parser::XMLNodeIterator< SourceData_Ptr >, zypp::parser::XMLNodeIterator< YUMPatchData_Ptr >, zypp::parser::XMLNodeIterator< YUMPrimaryData_Ptr >, zypp::parser::XMLNodeIterator< YUMFileListData_Ptr >, zypp::parser::XMLNodeIterator< YUMProductData_Ptr >, zypp::parser::XMLNodeIterator< YUMPatternData_Ptr >, and zypp::parser::XMLNodeIterator< YUMRepomdData_Ptr >. Referenced by fetchNext(). |
|
Fetch the next element and save it as next element.
Definition at line 185 of file XMLNodeIterator.cc. References _error, _process(), _reader, errorHandler(), isInterested(), setCurrent(), and xml_assert. Referenced by zypp::parser::XMLNodeIterator< YUMRepomdData_Ptr >::operator++(). |
|
Internal function to set the _error variable in case of a parser error. It logs the message and saves errors in _error, so that they will be thrown by checkError().
Definition at line 221 of file XMLNodeIterator.cc. References ERR, WAR, and xml_assert. Referenced by fetchNext(), and XMLNodeIteratorBase(). |
|
Implemented in zypp::parser::XMLNodeIterator< ENTRYTYPE >, zypp::parser::XMLNodeIterator< XMLProductData_Ptr >, zypp::parser::XMLNodeIterator< XMLPatternData_Ptr >, zypp::parser::XMLNodeIterator< XMLLanguageData_Ptr >, zypp::parser::XMLNodeIterator< YUMOtherData_Ptr >, zypp::parser::XMLNodeIterator< XMLPatchData_Ptr >, zypp::parser::XMLNodeIterator< YUMGroupData_Ptr >, zypp::parser::XMLNodeIterator< YUMPatchesData_Ptr >, zypp::parser::XMLNodeIterator< SourceData_Ptr >, zypp::parser::XMLNodeIterator< YUMPatchData_Ptr >, zypp::parser::XMLNodeIterator< YUMPrimaryData_Ptr >, zypp::parser::XMLNodeIterator< YUMFileListData_Ptr >, zypp::parser::XMLNodeIterator< YUMProductData_Ptr >, zypp::parser::XMLNodeIterator< YUMPatternData_Ptr >, and zypp::parser::XMLNodeIterator< YUMRepomdData_Ptr >. Referenced by fetchNext(). |
|
Implemented in zypp::parser::XMLNodeIterator< ENTRYTYPE >, zypp::parser::XMLNodeIterator< XMLProductData_Ptr >, zypp::parser::XMLNodeIterator< XMLPatternData_Ptr >, zypp::parser::XMLNodeIterator< XMLLanguageData_Ptr >, zypp::parser::XMLNodeIterator< YUMOtherData_Ptr >, zypp::parser::XMLNodeIterator< XMLPatchData_Ptr >, zypp::parser::XMLNodeIterator< YUMGroupData_Ptr >, zypp::parser::XMLNodeIterator< YUMPatchesData_Ptr >, zypp::parser::XMLNodeIterator< SourceData_Ptr >, zypp::parser::XMLNodeIterator< YUMPatchData_Ptr >, zypp::parser::XMLNodeIterator< YUMPrimaryData_Ptr >, zypp::parser::XMLNodeIterator< YUMFileListData_Ptr >, zypp::parser::XMLNodeIterator< YUMProductData_Ptr >, zypp::parser::XMLNodeIterator< YUMPatternData_Ptr >, and zypp::parser::XMLNodeIterator< YUMRepomdData_Ptr >. Referenced by atEnd(). |
|
assignment is forbidden. Reason: We can't copy an xmlTextReader |
|
if an error occured, this contains the error.
Definition at line 273 of file XMLNodeIterator.h. Referenced by atEnd(), errorStatus(), fetchNext(), and zypp::parser::XMLNodeIterator< YUMRepomdData_Ptr >::operator()(). |
|
contains the istream to read the xml file from. Can be 0 if at end or if the current element is the only element left. Definition at line 279 of file XMLNodeIterator.h. |
|
contains the xmlTextReader used to parse the xml file.
Definition at line 284 of file XMLNodeIterator.h. Referenced by fetchNext(), XMLNodeIteratorBase(), and ~XMLNodeIteratorBase(). |
|
contains the base URL of the xml documentation
Definition at line 289 of file XMLNodeIterator.h. |