#include <string>
#include <list>
#include <iostream>
+#include <zypp/base/PtrTypes.h>
+
+using namespace zypp::base;
+
namespace zypp {
namespace parser {
std::string source_info;
};
- class YUMPatchPackage : public base::ReferenceCounted, private base::NonCopyable {
+ class YUMPatchAtom : public base::ReferenceCounted, private base::NonCopyable {
public:
- YUMPatchPackage() {};
- // data for primary
- std::string type;
+
+ enum AtomType { Package, Script, Message };
+
+ virtual AtomType atomType() = 0;
std::string name;
- std::string arch;
+ std::string type;
std::string epoch;
std::string ver;
std::string rel;
+ std::string arch;
+ std::list<YUMDependency> provides;
+ std::list<YUMDependency> conflicts;
+ std::list<YUMDependency> obsoletes;
+ std::list<YUMDependency> freshen;
+ std::list<YUMDependency> requires;
+ };
+
+ class YUMPatchPackage : public YUMPatchAtom {
+ public:
+ YUMPatchPackage() {};
+ virtual AtomType atomType() { return Package; };
+ // data for primary
+ std::string type;
std::string checksumType;
std::string checksumPkgid;
std::string checksum;
std::string sourcerpm;
std::string headerStart;
std::string headerEnd;
- std::list<YUMDependency> provides;
- std::list<YUMDependency> conflicts;
- std::list<YUMDependency> obsoletes;
- std::list<YUMDependency> requires;
std::list<FileData> files;
// SuSE specific data
std::list<std::string> authors;
std::list<std::string> keywords;
std::string media;
std::list<YUMDirSize> dirSizes;
- std::list<YUMDependency> freshen;
bool installOnly;
// Change Log
std::list<ChangelogEntry> changelog;
} deltaRpm;
};
- class YUMPatchScript : public base::ReferenceCounted, private base::NonCopyable {
+ class YUMPatchScript : public YUMPatchAtom {
public:
YUMPatchScript() {};
- std::string name;
- std::string epoch;
- std::string ver;
- std::string rel;
+ virtual AtomType atomType() { return Script; };
std::string do_script;
std::string undo_script;
- std::list<YUMDependency> provides;
- std::list<YUMDependency> conflicts;
- std::list<YUMDependency> obsoletes;
- std::list<YUMDependency> freshen;
- std::list<YUMDependency> requires;
};
- class YUMPatchMessage : public base::ReferenceCounted, private base::NonCopyable {
+ class YUMPatchMessage : public YUMPatchAtom {
public:
YUMPatchMessage() {};
- std::string name;
+ virtual AtomType atomType() { return Message; };
std::string type;
- std::string epoch;
- std::string ver;
- std::string rel;
- std::list<YUMDependency> provides;
- std::list<YUMDependency> conflicts;
- std::list<YUMDependency> obsoletes;
- std::list<YUMDependency> freshen;
- std::list<YUMDependency> requires;
std::string text;
};
- class YUMPatchAtom {
- public:
- std::string type;
- // union not possibel due to constructors
- // there is no common parent
- YUMPatchPackagePtr package;
- YUMPatchScriptPtr script;
- YUMPatchMessagePtr message;
- };
-
+
/**
* @short Holds the metadata about a YUM repository
**/
bool packageManager;
std::string updateScript;
// FIXME this copying of structures is inefective
- std::list<YUMPatchAtom> atoms;
+ std::list<shared_ptr<YUMPatchAtom> > atoms;
};
std::ostream& operator<<(std::ostream &out, const zypp::parser::yum::YUMFileListData& data);
std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMOtherData& data);
std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchData& data);
-std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchAtom& data);
+std::ostream& operator<<(std::ostream& out, const shared_ptr<zypp::parser::yum::YUMPatchAtom> data);
std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchMessage& data);
std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchScript& data);
std::ostream& operator<<(std::ostream& out, const zypp::parser::yum::YUMPatchPackage& data);
YUMPatchParser::parsePackageNode(YUMPatchDataPtr dataPtr,
xmlNodePtr formatNode)
{
- YUMPatchAtom at;
- at.type = "package";
- at.package = new YUMPatchPackage;
- at.package->type = _helper.attribute(formatNode,"type");
- at.package->installOnly = false;
+ shared_ptr<YUMPatchPackage> package(new YUMPatchPackage);
+ package->type = _helper.attribute(formatNode,"type");
+ package->installOnly = false;
// FIXME move the respective method to a common class, inherit it
YUMPrimaryParser prim;
if (_helper.isElement(child)) {
string name = _helper.name(child);
if (name == "name") {
- at.package->name = _helper.content(child);
+ package->name = _helper.content(child);
}
else if (name == "arch") {
- at.package->arch = _helper.content(child);
+ package->arch = _helper.content(child);
}
else if (name == "version") {
- at.package->epoch = _helper.attribute(child,"epoch");
- at.package->ver = _helper.attribute(child,"ver");
- at.package->rel = _helper.attribute(child,"rel");
+ package->epoch = _helper.attribute(child,"epoch");
+ package->ver = _helper.attribute(child,"ver");
+ package->rel = _helper.attribute(child,"rel");
}
else if (name == "checksum") {
- at.package->checksumType = _helper.attribute(child,"type");
- at.package->checksumPkgid = _helper.attribute(child,"pkgid");
- at.package->checksum = _helper.content(child);
+ package->checksumType = _helper.attribute(child,"type");
+ package->checksumPkgid = _helper.attribute(child,"pkgid");
+ package->checksum = _helper.content(child);
}
else if (name == "summary") {
- at.package->summary = _helper.content(child);
+ package->summary = _helper.content(child);
}
else if (name == "description") {
- at.package->description = _helper.content(child);
+ package->description = _helper.content(child);
}
else if (name == "packager") {
- at.package->packager = _helper.content(child);
+ package->packager = _helper.content(child);
}
else if (name == "url") {
- at.package->url = _helper.content(child);
+ package->url = _helper.content(child);
}
else if (name == "time") {
- at.package->timeFile = _helper.attribute(child,"file");
- at.package->timeBuild = _helper.attribute(child,"build");
+ package->timeFile = _helper.attribute(child,"file");
+ package->timeBuild = _helper.attribute(child,"build");
}
else if (name == "size") {
- at.package->sizePackage = _helper.attribute(child,"package");
- at.package->sizeInstalled = _helper.attribute(child,"installed");
- at.package->sizeArchive = _helper.attribute(child,"archive");
+ package->sizePackage = _helper.attribute(child,"package");
+ package->sizeInstalled = _helper.attribute(child,"installed");
+ package->sizeArchive = _helper.attribute(child,"archive");
}
else if (name == "location") {
- at.package->location = _helper.attribute(child,"href");
+ package->location = _helper.attribute(child,"href");
}
else if (name == "format") {
- parseFormatNode (&*at.package, child);
+ parseFormatNode (&*package, child);
}
else if (name == "pkgfiles")
{
- parsePkgFilesNode (&*at.package, child);
+ parsePkgFilesNode (&*package, child);
}
else {
WAR << "YUM <atoms/package> contains the unknown element <"
}
}
}
- dataPtr->atoms.push_back(at);
+ dataPtr->atoms.push_back(package);
}
void
YUMPatchParser::parseScriptNode(YUMPatchDataPtr dataPtr,
xmlNodePtr formatNode)
{
- YUMPatchAtom at;
- at.type = "script";
- at.script = new YUMPatchScript;
+ shared_ptr<YUMPatchScript> script(new YUMPatchScript);
// FIXME move the respective method to a common class, inherit it
YUMPrimaryParser prim;
if (_helper.isElement(child)) {
string name = _helper.name(child);
if (name == "name") {
- at.script->name = _helper.content(child);
+ script->name = _helper.content(child);
}
else if (name == "version") {
- at.script->epoch = _helper.attribute(child,"epoch");
- at.script->ver = _helper.attribute(child,"ver");
- at.script->rel = _helper.attribute(child,"rel");
+ script->epoch = _helper.attribute(child,"epoch");
+ script->ver = _helper.attribute(child,"ver");
+ script->rel = _helper.attribute(child,"rel");
}
else if (name == "do") {
- at.script->do_script = _helper.content(child);
+ script->do_script = _helper.content(child);
}
else if (name == "undo") {
- at.script->undo_script = _helper.content(child);
+ script->undo_script = _helper.content(child);
}
else if (name == "provides") {
- prim.parseDependencyEntries(& at.script->provides, child);
+ prim.parseDependencyEntries(& script->provides, child);
}
else if (name == "conflicts") {
- prim.parseDependencyEntries(& at.script->conflicts, child);
+ prim.parseDependencyEntries(& script->conflicts, child);
}
else if (name == "obsoletes") {
- prim.parseDependencyEntries(& at.script->obsoletes, child);
+ prim.parseDependencyEntries(& script->obsoletes, child);
}
else if (name == "requires") {
- prim.parseDependencyEntries(& at.script->requires, child);
+ prim.parseDependencyEntries(& script->requires, child);
}
else if (name == "freshen") {
- prim.parseDependencyEntries(& at.script->requires, child);
+ prim.parseDependencyEntries(& script->requires, child);
}
else {
WAR << "YUM <atoms/script> contains the unknown element <"
}
}
}
- dataPtr->atoms.push_back(at);
+ dataPtr->atoms.push_back(script);
}
void
YUMPatchParser::parseMessageNode(YUMPatchDataPtr dataPtr,
xmlNodePtr formatNode)
{
- YUMPatchAtom at;
- at.type = "message";
- at.message = new YUMPatchMessage;
- at.message->type = _helper.attribute(formatNode,"type");
+ shared_ptr<YUMPatchMessage> message(new YUMPatchMessage);
+ message->type = _helper.attribute(formatNode,"type");
// FIXME move the respective method to a common class, inherit it
YUMPrimaryParser prim;
if (_helper.isElement(child)) {
string name = _helper.name(child);
if (name == "name") {
- at.message->name = _helper.content(child);
+ message->name = _helper.content(child);
}
else if (name == "version") {
- at.message->epoch = _helper.attribute(child,"epoch");
- at.message->ver = _helper.attribute(child,"ver");
- at.message->rel = _helper.attribute(child,"rel");
+ message->epoch = _helper.attribute(child,"epoch");
+ message->ver = _helper.attribute(child,"ver");
+ message->rel = _helper.attribute(child,"rel");
}
else if (name == "text") {
- at.message->text = _helper.content(child);
+ message->text = _helper.content(child);
}
else if (name == "provides") {
- prim.parseDependencyEntries(& at.message->provides, child);
+ prim.parseDependencyEntries(& message->provides, child);
}
else if (name == "conflicts") {
- prim.parseDependencyEntries(& at.message->conflicts, child);
+ prim.parseDependencyEntries(& message->conflicts, child);
}
else if (name == "obsoletes") {
- prim.parseDependencyEntries(& at.message->obsoletes, child);
+ prim.parseDependencyEntries(& message->obsoletes, child);
}
else if (name == "requires") {
- prim.parseDependencyEntries(& at.message->requires, child);
+ prim.parseDependencyEntries(& message->requires, child);
}
else if (name == "freshen") {
- prim.parseDependencyEntries(& at.message->requires, child);
+ prim.parseDependencyEntries(& message->requires, child);
}
else {
WAR << "YUM <atoms/message> contains the unknown element <"
}
}
}
- dataPtr->atoms.push_back(at);
+ dataPtr->atoms.push_back(message);
}
} // namespace yum