return true;
}
- bool YUMParser::primary_CB(const zypp::data::Package & package)
+ bool YUMParser::primary_CB(const data::Package_Ptr & package_r)
{
- NVRA nvra(package.name, package.edition, package.arch);
+ NVRA nvra(package_r->name, package_r->edition, package_r->arch);
data::RecordId pkgid =
_consumer.appendResolvable(
- _catalog_id, ResTraits<Package>::kind, nvra, package.deps);
+ _catalog_id, ResTraits<Package>::kind, nvra, package_r->deps);
/* MIL << "got package "
<< package.name << package.edition << " "
void doJobs(const zypp::Pathname & path, ParserProgress::Ptr progress);
bool repomd_CB(const OnMediaLocation & loc, const YUMResourceType & dtype);
- bool primary_CB(const zypp::data::Package & package);
+ bool primary_CB(const data::Package_Ptr & package_r);
bool patches_CB(const OnMediaLocation &loc, const std::string & patch_id);
bool patch_CB(const zypp::data::Patch & patch);
:
_callback(callback), _package(NULL),
_count(0), _total_packages(0),
- _tag(tag_NONE), _expect_rpm_entry(false), _dtype(zypp::Dep::REQUIRES),
+ _tag(tag_NONE), _expect_rpm_entry(false),
+ _dtype(zypp::Dep::REQUIRES),
_progress(progress), _old_progress(0)
{
Reader reader( primary_file );
{
_tag = tag_package;
// DBG << "got " << reader_r->getAttribute("type") << " package" << endl;
- if (_package) delete _package;
- _package = new zypp::data::Package();
+ _package = new data::Package;
return true;
}
_package->edition = Edition(reader_r->getAttribute("ver").asString(),
reader_r->getAttribute("rel").asString(),
reader_r->getAttribute("epoch").asString());
+ return true;
}
if (reader_r->name() == "checksum")
{
if (reader_r->name() == "package")
{
- _callback(*_package);
- if (_package)
- {
- delete _package;
- _package = NULL;
- }
+ if (_package && _callback)
+ _callback(handoutPackage());
+
_count++;
// report progress
return true;
}
+ data::Package_Ptr PrimaryFileReader::handoutPackage()
+ {
+ data::Package_Ptr ret;
+ ret.swap(_package);
+ return ret;
+ }
} // ns yum
} // ns parser
/**
* Callback definition.
*/
- typedef function<bool(const zypp::data::Package &)> ProcessPackage;
+ typedef function<bool(const data::Package_Ptr &)> ProcessPackage;
/**
* Enumeration of some primary.xml tags.
*/
bool consumeFormatChildNodes(zypp::xml::Reader & reader_r);
- private:
- /** Used to remember primary.xml tag beeing currently processed. */
- Tag _tag;
+ /**
+ * Creates a new Package_Ptr swaps its contents with \ref _package and
+ * returns it.
+ */
+ data::Package_Ptr handoutPackage();
+ private:
/**
- * Used to remember whether we are expecting an rpm:entry tag
- * e.g. for rpm:requires
+ * Callback for processing package metadata passed in through constructor.
*/
- bool _expect_rpm_entry;
+ ProcessPackage _callback;
/**
- * Type of dependecy beeing processed.
+ * \ref zypp::data::Package object for storing the package metada
*/
- Dep _dtype;
+ data::Package_Ptr _package;
/**
* Number of packages read so far.
*/
unsigned _total_packages;
+ /** Used to remember primary.xml tag beeing currently processed. */
+ Tag _tag;
+
/**
- * Pointer to the \ref zypp::data::Package object for storing the package
- * metada
+ * Used to remember whether we are expecting an rpm:entry tag
+ * e.g. for rpm:requires
*/
- zypp::data::Package *_package;
+ bool _expect_rpm_entry;
/**
- * Callback for processing package metadata passed in through constructor.
+ * Type of dependecy beeing processed.
*/
- ProcessPackage _callback;
+ Dep _dtype;
/**
* Progress reporting object.
*/
ParserProgress::Ptr _progress;
-
+
long int _old_progress;
};