From ed1128996b0d99c354f0ced0bbe863cb3d586237 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Wed, 6 Jun 2007 07:56:59 +0000 Subject: [PATCH] PatchesFileReader moved to parser namespace --- zypp/parser/yum/PatchesFileReader.cc | 104 +++++++++++++++------------- zypp/parser/yum/PatchesFileReader.h | 129 ++++++++++++++++++----------------- zypp/parser/yum/RepoParser.cc | 2 +- 3 files changed, 126 insertions(+), 109 deletions(-) diff --git a/zypp/parser/yum/PatchesFileReader.cc b/zypp/parser/yum/PatchesFileReader.cc index eddcb22..2b88306 100644 --- a/zypp/parser/yum/PatchesFileReader.cc +++ b/zypp/parser/yum/PatchesFileReader.cc @@ -16,62 +16,72 @@ using namespace std; using namespace zypp::xml; -namespace zypp { namespace source { namespace yum { - -PatchesFileReader::PatchesFileReader( const Pathname &repomd_file, ProcessResource callback ) - : _tag(tag_NONE), _callback(callback) -{ - Reader reader( repomd_file ); - MIL << "Reading " << repomd_file << endl; - reader.foreachNode( bind( &PatchesFileReader::consumeNode, this, _1 ) ); -} - -bool PatchesFileReader::consumeNode( Reader & reader_r ) +namespace zypp { - //MIL << reader_r->name() << endl; - std::string data_type; - if ( reader_r->nodeType() == XML_READER_TYPE_ELEMENT ) + namespace parser { - if ( reader_r->name() == "patches" ) - { - _tag = tag_Patches; - return true; - } - if ( reader_r->name() == "patch" ) + namespace yum { - _tag = tag_Patch; - _id = reader_r->getAttribute("id").asString(); - return true; - } - if ( reader_r->name() == "location" ) - { - _tag = tag_Location; - _location.filename( reader_r->getAttribute("href").asString() ); - return true; - } - if ( reader_r->name() == "checksum" ) + + + PatchesFileReader::PatchesFileReader( const Pathname &repomd_file, ProcessResource callback ) + : _tag(tag_NONE), _callback(callback) + { + Reader reader( repomd_file ); + MIL << "Reading " << repomd_file << endl; + reader.foreachNode( bind( &PatchesFileReader::consumeNode, this, _1 ) ); + } + + bool PatchesFileReader::consumeNode( Reader & reader_r ) + { + //MIL << reader_r->name() << endl; + std::string data_type; + if ( reader_r->nodeType() == XML_READER_TYPE_ELEMENT ) { - _tag = tag_CheckSum; - string checksum_type = reader_r->getAttribute("type").asString() ; - string checksum_vaue = reader_r.nodeText().asString(); - _location.checksum( CheckSum( checksum_type, checksum_vaue ) ); - return true; + if ( reader_r->name() == "patches" ) + { + _tag = tag_Patches; + return true; + } + if ( reader_r->name() == "patch" ) + { + _tag = tag_Patch; + _id = reader_r->getAttribute("id").asString(); + return true; + } + if ( reader_r->name() == "location" ) + { + _tag = tag_Location; + _location.filename( reader_r->getAttribute("href").asString() ); + return true; + } + if ( reader_r->name() == "checksum" ) + { + _tag = tag_CheckSum; + string checksum_type = reader_r->getAttribute("type").asString() ; + string checksum_vaue = reader_r.nodeText().asString(); + _location.checksum( CheckSum( checksum_type, checksum_vaue ) ); + return true; + } + if ( reader_r->name() == "timestamp" ) + { + // ignore it + return true; + } } - if ( reader_r->name() == "timestamp" ) + else if ( reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT ) { - // ignore it + //MIL << "end element" << endl; + if ( reader_r->name() == "patch" ) + _callback( _location, _id ); return true; } - } - else if ( reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT ) - { - //MIL << "end element" << endl; - if ( reader_r->name() == "patch" ) - _callback( _location, _id ); return true; } - return true; -} -} } } //ns zypp::source::yum + } // ns yum + } // ns parser +} // ns zypp + +// vim: set ts=2 sts=2 sw=2 et ai: diff --git a/zypp/parser/yum/PatchesFileReader.h b/zypp/parser/yum/PatchesFileReader.h index 18df997..ad19303 100644 --- a/zypp/parser/yum/PatchesFileReader.h +++ b/zypp/parser/yum/PatchesFileReader.h @@ -19,70 +19,77 @@ using namespace std; using namespace zypp::xml; + namespace zypp { - namespace source + namespace parser { namespace yum { - /** - * Iterates through a patches.xml file giving on each iteration - * a \ref OnMediaLocation object with the resource and its - * patch id. - * The iteration is done via a callback provided on - * construction. - * - * \code - * PatchesFileReader reader(patches_file, - * bind( &SomeClass::callbackfunc, &object, _1, _2 ) ); - * \endcode - */ - class PatchesFileReader - { - public: - - /** - * Callback definition - * first parameter is a \ref OnMediaLocation object with the resource - * second parameter is the patch id. - */ - typedef function ProcessResource; - - enum Tag - { - tag_NONE, - tag_Patches, - tag_Patch, - tag_Location, - tag_CheckSum, - tag_Timestamp, - tag_OpenCheckSum - }; - - /** - * Constructor - * \param patches_file is the patches.xml file you want to read - * \param callback is a function. \see PatchesFileReader::ProcessResource - */ - PatchesFileReader( const Pathname &patches_file, ProcessResource callback ); - - private: - /** - * Callback provided to the XML parser. Don't use it. - */ - bool consumeNode( Reader & reader_r ); - - private: - OnMediaLocation _location; - Tag _tag; - std::string _id; - ProcessResource _callback; - CheckSum _checksum; - std::string _checksum_type; - Date _timestamp; - }; - } - } -} -#endif + + /** + * Iterates through a patches.xml file giving on each iteration + * a \ref OnMediaLocation object with the resource and its + * patch id. + * The iteration is done via a callback provided on + * construction. + * + * \code + * PatchesFileReader reader(patches_file, + * bind( &SomeClass::callbackfunc, &object, _1, _2 ) ); + * \endcode + */ + class PatchesFileReader + { + public: + + /** + * Callback definition + * first parameter is a \ref OnMediaLocation object with the resource + * second parameter is the patch id. + */ + typedef function ProcessResource; + + enum Tag + { + tag_NONE, + tag_Patches, + tag_Patch, + tag_Location, + tag_CheckSum, + tag_Timestamp, + tag_OpenCheckSum + }; + + /** + * Constructor + * \param patches_file is the patches.xml file you want to read + * \param callback is a function. \see PatchesFileReader::ProcessResource + */ + PatchesFileReader( const Pathname &patches_file, ProcessResource callback ); + + private: + /** + * Callback provided to the XML parser. Don't use it. + */ + bool consumeNode( Reader & reader_r ); + + private: + OnMediaLocation _location; + Tag _tag; + std::string _id; + ProcessResource _callback; + CheckSum _checksum; + std::string _checksum_type; + Date _timestamp; + }; + + + } // ns yum + } // ns parser +} // ns zypp + +#endif /*zypp_source_yum_PatchesFileReader_H*/ + +// vim: set ts=2 sts=2 sw=2 et ai: diff --git a/zypp/parser/yum/RepoParser.cc b/zypp/parser/yum/RepoParser.cc index b9cb451..a3a89fe 100644 --- a/zypp/parser/yum/RepoParser.cc +++ b/zypp/parser/yum/RepoParser.cc @@ -349,7 +349,7 @@ namespace zypp case YUMResourceType::PATCHES_e: { - source::yum::PatchesFileReader( + PatchesFileReader( cache_dir + job.filename(), bind(&RepoParser::Impl::patches_CB, this, _1, _2)); // reset progress reporter max value (number of jobs changed if -- 2.7.4