00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00013 #ifndef XMLSourceCacheParser_h 00014 #define XMLSourceCacheParser_h 00015 00016 #include <zypp/target/store/PersistentStorage.h> 00017 #include <zypp/parser/XMLNodeIterator.h> 00018 #include <zypp/parser/LibXMLHelper.h> 00019 #include <list> 00020 00021 typedef zypp::storage::PersistentStorage::SourceData* SourceData_Ptr; 00022 00023 namespace zypp 00024 { 00025 namespace parser 00026 { 00027 namespace xmlstore 00028 { 00029 00030 /* 00031 * Use this class as an iterator that produces, one after one, 00032 * XMLSourceCacheData_Ptr(s) for the XML group elements. 00033 * Here's an example: 00034 * 00035 * for (XMLSourceCacheParser iter(anIstream, baseUrl), 00036 * iter != XMLSourceCacheParser.end(), // or: iter() != 0, or ! iter.atEnd() 00037 * ++iter) { 00038 * doSomething(*iter) 00039 * } 00040 * 00041 * The iterator owns the pointer (i.e., caller must not delete it) 00042 * until the next ++ operator is called. At this time, it will be 00043 * destroyed (and a new ENTRYTYPE is created.) 00044 * 00045 * If the input is fundamentally flawed so that it makes no sense to 00046 * continue parsing, XMLNodeIterator will log it and consider the input as finished. 00047 * You can query the exit status with errorStatus(). 00048 */ 00049 00050 class XMLSourceCacheParser : public zypp::parser::XMLNodeIterator<SourceData_Ptr> 00051 { 00052 public: 00053 XMLSourceCacheParser(std::istream &is, const std::string &baseUrl); 00054 XMLSourceCacheParser(); 00055 XMLSourceCacheParser(SourceData_Ptr & entry); 00056 virtual ~XMLSourceCacheParser(); 00057 00058 private: 00059 virtual bool isInterested(const xmlNodePtr nodePtr); 00060 virtual SourceData_Ptr process(const xmlTextReaderPtr reader); 00061 void parseSourceList(SourceData_Ptr dataPtr, xmlNodePtr node); 00062 zypp::parser::LibXMLHelper _helper; 00063 }; 00064 } // namespace parser 00065 } // namespace xmlstore 00066 } // namespace zypp 00067 00068 #endif
1.4.6