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