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:
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<bool( const OnMediaLocation &, const string & )> 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<bool( const OnMediaLocation &, const string & )> 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: