YUMPatchesParser.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00013 #include <zypp/parser/yum/YUMPatchesParser.h>
00014 #include <zypp/parser/yum/YUMPrimaryParser.h>
00015 #include <istream>
00016 #include <string>
00017 #include "zypp/parser/xml_parser_assert.h"
00018 #include <libxml/xmlreader.h>
00019 #include <libxml/tree.h>
00020 #include <zypp/parser/LibXMLHelper.h>
00021 #include <zypp/base/Logger.h>
00022 #include <zypp/parser/yum/schemanames.h>
00023 
00024 using namespace std;
00025 namespace zypp
00026 {
00027 namespace parser
00028 {
00029 namespace yum
00030 {
00031 
00032 YUMPatchesParser::~YUMPatchesParser()
00033 { }
00034 
00035 YUMPatchesParser::YUMPatchesParser(std::istream &is, const std::string& baseUrl, parser::ParserProgress::Ptr progress )
00036     : XMLNodeIterator<YUMPatchesData_Ptr>(is, baseUrl,PATCHESSCHEMA, progress)
00037 {
00038   fetchNext();
00039 }
00040 
00041 YUMPatchesParser::YUMPatchesParser()
00042 { }
00043 
00044 YUMPatchesParser::YUMPatchesParser(YUMPatchesData_Ptr& entry)
00045     : XMLNodeIterator<YUMPatchesData_Ptr>(entry)
00046 { }
00047 
00048 
00049 // select for which elements process() will be called
00050 bool
00051 YUMPatchesParser::isInterested(const xmlNodePtr nodePtr)
00052 {
00053   return _helper.isElement(nodePtr) && _helper.name(nodePtr) == "patch";
00054 }
00055 
00056 // do the actual processing
00057 YUMPatchesData_Ptr
00058 YUMPatchesParser::process(const xmlTextReaderPtr reader)
00059 {
00060   xml_assert(reader);
00061   YUMPatchesData_Ptr patchPtr = new YUMPatchesData;
00062   xmlNodePtr dataNode = xmlTextReaderExpand(reader);
00063   xml_assert(dataNode);
00064 
00065   patchPtr->id = _helper.attribute(dataNode,"id");
00066 
00067   for (xmlNodePtr child = dataNode->children;
00068        child && child != dataNode;
00069        child = child->next)
00070   {
00071     if (_helper.isElement(child))
00072     {
00073       string name = _helper.name(child);
00074       if (name == "location")
00075       {
00076         patchPtr->location = _helper.attribute(child,"href");
00077       }
00078       else if (name == "checksum")
00079       {
00080         patchPtr->checksumType = _helper.attribute(child,"type");
00081         patchPtr->checksum = _helper.content(child);
00082       }
00083       else
00084       {
00085         WAR << "YUM <data> contains the unknown element <" << name << "> "
00086         << _helper.positionInfo(child) << ", skipping" << endl;
00087       }
00088     }
00089   }
00090   return patchPtr;
00091 } /* end process */
00092 
00093 
00094 } // namespace yum
00095 } // namespace parser
00096 } // namespace zypp

Generated on Tue Nov 28 16:49:30 2006 for zypp by  doxygen 1.5.0