YUMGroupParser.h \
YUMParserData.h \
YUMPatchParser.h \
+ YUMProductParser.h \
YUMRepomdParser.h \
schemanames.h
YUMGroupParser.cc \
YUMPatchParser.cc \
YUMOtherParser.cc \
- YUMPrimaryParser.cc
+ YUMPrimaryParser.cc \
+ YUMProductParser.cc
## ##################################################
#ifndef YUMParser_h
#define YUMParser_h
-#include <zypp/parser/yum/YUMParserData.h>
-#include <zypp/parser/yum/YUMRepomdParser.h>
-#include <zypp/parser/yum/YUMPrimaryParser.h>
-#include <zypp/parser/yum/YUMGroupParser.h>
-#include <zypp/parser/yum/YUMFileListParser.h>
-#include <zypp/parser/yum/YUMOtherParser.h>
-#include <zypp/parser/yum/YUMPatchParser.h>
+#include "zypp/parser/yum/YUMParserData.h"
+#include "zypp/parser/yum/YUMRepomdParser.h"
+#include "zypp/parser/yum/YUMPrimaryParser.h"
+#include "zypp/parser/yum/YUMGroupParser.h"
+#include "zypp/parser/yum/YUMFileListParser.h"
+#include "zypp/parser/yum/YUMOtherParser.h"
+#include "zypp/parser/yum/YUMPatchParser.h"
+#include "zypp/parser/yum/YUMProductParser.h"
#endif
IMPL_PTR_TYPE(YUMFileListData);
IMPL_PTR_TYPE(YUMOtherData);
IMPL_PTR_TYPE(YUMPatchData);
+ IMPL_PTR_TYPE(YUMProductData);
IMPL_PTR_TYPE(YUMPatchPackage);
IMPL_PTR_TYPE(YUMPatchScript);
IMPL_PTR_TYPE(YUMPatchMessage);
return out;
}
+ostream& operator<<(ostream &out, const YUMProductData& data)
+{
+ out << "-------------------------------------------------" << endl
+ << "Product Data: " << endl
+ << " type: " << data.type << endl
+ << " vendor: " << data.vendor << endl
+ << " name: " << data.name << endl
+ << " display name: " << data.displayname << endl
+ << " description: " << data.description << endl
+ << " epoch: " << data.epoch << endl
+ << " version: " << data.ver << endl
+ << " release: " << data.rel << endl
+ << " provides: " << data.provides << endl
+ << " conflicts: " << data.conflicts << endl
+ << " obsoletes: " << data.obsoletes << endl
+ << " freshen: " << data.freshen << endl
+ << " requires: " << data.requires << endl;
+ return out;
+}
+
std::ostream& operator<<(std::ostream& out, const shared_ptr<YUMPatchAtom> data)
{
out << "Atom data" << endl;
DEFINE_PTR_TYPE( YUMFileListData );
DEFINE_PTR_TYPE( YUMOtherData );
DEFINE_PTR_TYPE( YUMPatchData );
+ DEFINE_PTR_TYPE( YUMProductData );
DEFINE_PTR_TYPE( YUMPatchPackage );
DEFINE_PTR_TYPE( YUMPatchScript );
DEFINE_PTR_TYPE( YUMPatchMessage );
std::list<shared_ptr<YUMPatchAtom> > atoms;
};
+ class YUMProductData : public YUMObjectData {
+ public:
+ YUMProductData() {};
+ ~YUMProductData() {};
+
+ std::string type;
+ std::string vendor;
+ std::string name;
+ std::list<MultiLang> displayname;
+ std::list<MultiLang> description;
+ };
+
} // namespace yum
} // namespace parser
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::YUMProductData& 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);
prim.parseDependencyEntries(& patchPtr->requires, child);
}
else if (name == "freshen") {
- prim.parseDependencyEntries(& patchPtr->requires, child);
+ prim.parseDependencyEntries(& patchPtr->freshen, child);
}
else if (name == "category") {
patchPtr->category = _helper.content(child);
private:
// FIXME move needed method to a common class, inherit it
friend class YUMPatchParser;
+ friend class YUMProductParser;
virtual bool isInterested(const xmlNodePtr nodePtr);
virtual YUMPrimaryData_Ptr process(const xmlTextReaderPtr reader);
void parseFormatNode(YUMPrimaryData_Ptr dataPtr,
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/yum/YUMProductParser.cc
+ *
+*/
+
+#include <istream>
+#include <string>
+#include <cassert>
+#include <libxml/xmlreader.h>
+#include <libxml/tree.h>
+#include "zypp/parser/yum/YUMProductParser.h"
+#include "zypp/parser/yum/YUMPrimaryParser.h"
+#include "zypp/parser/LibXMLHelper.h"
+#include "zypp/base/Logger.h"
+#include "zypp/parser/yum/schemanames.h"
+
+using namespace std;
+namespace zypp {
+ namespace parser {
+ namespace yum {
+
+ YUMProductParser::~YUMProductParser()
+ { }
+
+ YUMProductParser::YUMProductParser(istream &is, const string& baseUrl)
+ : XMLNodeIterator<YUMProductData_Ptr>(is, baseUrl,PRODUCTSCHEMA)
+ {
+ fetchNext();
+ }
+
+ YUMProductParser::YUMProductParser()
+ { }
+
+ YUMProductParser::YUMProductParser(YUMProductData_Ptr& entry)
+ : XMLNodeIterator<YUMProductData_Ptr>(entry)
+ { }
+
+
+ // select for which elements process() will be called
+ bool
+ YUMProductParser::isInterested(const xmlNodePtr nodePtr)
+ {
+ return _helper.isElement(nodePtr) && _helper.name(nodePtr) == "product";
+ }
+
+ // do the actual processing
+ YUMProductData_Ptr
+ YUMProductParser::process(const xmlTextReaderPtr reader)
+ {
+ assert(reader);
+ YUMProductData_Ptr productPtr = new YUMProductData;
+ xmlNodePtr dataNode = xmlTextReaderExpand(reader);
+ assert(dataNode);
+ productPtr->type = _helper.attribute(dataNode,"type");
+
+ // FIXME move the respective method to a common class, inherit it
+ YUMPrimaryParser prim;
+
+ for (xmlNodePtr child = dataNode->children;
+ child && child != dataNode;
+ child = child->next) {
+ if (_helper.isElement(child)) {
+ string name = _helper.name(child);
+ if (name == "name") {
+ productPtr->name = _helper.content(child);
+ }
+ else if (name == "vendor") {
+ productPtr->vendor = _helper.content(child);
+ }
+ else if (name == "displayname") {
+ productPtr->displayname.push_back(MultiLang(
+ _helper.attribute(child,"lang"),
+ _helper.content(child)));
+ }
+ else if (name == "description") {
+ productPtr->description.push_back(MultiLang(
+ _helper.attribute(child,"lang"),
+ _helper.content(child)));
+ }
+ else if (name == "version") {
+ productPtr->epoch = _helper.attribute(child,"epoch");
+ productPtr->ver = _helper.attribute(child,"ver");
+ productPtr->rel = _helper.attribute(child,"rel");
+ }
+ else if (name == "provides") {
+ prim.parseDependencyEntries(& productPtr->provides, child);
+ }
+ else if (name == "conflicts") {
+ prim.parseDependencyEntries(& productPtr->conflicts, child);
+ }
+ else if (name == "obsoletes") {
+ prim.parseDependencyEntries(& productPtr->obsoletes, child);
+ }
+ else if (name == "requires") {
+ prim.parseDependencyEntries(& productPtr->requires, child);
+ }
+ else {
+ WAR << "YUM <data> contains the unknown element <" << name << "> "
+ << _helper.positionInfo(child) << ", skipping" << endl;
+ }
+ }
+ }
+ return productPtr;
+ } /* end process */
+
+
+
+ } // namespace yum
+ } // namespace parser
+} // namespace zypp
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/parser/yum/YUMProductParser.h
+ *
+*/
+
+
+
+#ifndef YUMProductParser_h
+#define YUMProductParser_h
+
+#include "zypp/parser/yum/YUMParserData.h"
+#include "zypp/parser/XMLNodeIterator.h"
+#include "zypp/parser/LibXMLHelper.h"
+#include <list>
+
+namespace zypp {
+ namespace parser {
+ namespace yum {
+
+ /**
+ * @short Parser for YUM primary.xml files (containing package metadata)
+ * Use this class as an iterator that produces, one after one,
+ * YUMProductData_Ptr(s) for the XML package elements in the input.
+ * Here's an example:
+ *
+ * for (YUMProductParser iter(anIstream, baseUrl),
+ * iter != YUMOtherParser.end(), // or: iter() != 0, or ! iter.atEnd()
+ * ++iter) {
+ * doSomething(*iter)
+ * }
+ *
+ * The iterator owns the pointer (i.e., caller must not delete it)
+ * until the next ++ operator is called. At this time, it will be
+ * destroyed (and a new ENTRYTYPE is created.)
+ *
+ * If the input is fundamentally flawed so that it makes no sense to
+ * continue parsing, XMLNodeIterator will log it and consider the input as finished.
+ * You can query the exit status with errorStatus().
+ */
+ class YUMProductParser : public XMLNodeIterator<YUMProductData_Ptr>
+ {
+ public:
+ YUMProductParser(std::istream &is, const std::string &baseUrl);
+ YUMProductParser();
+ YUMProductParser(YUMProductData_Ptr& entry);
+ virtual ~YUMProductParser();
+
+ private:
+ virtual bool isInterested(const xmlNodePtr nodePtr);
+ virtual YUMProductData_Ptr process(const xmlTextReaderPtr reader);
+ LibXMLHelper _helper;
+ };
+ } // namespace yum
+ } // namespace parser
+} // namespace zypp
+
+#endif
attribute lang { text },
text
}+,
- element ns1:version {
- attribute epoch { xsd:nonNegativeInteger },
- attribute ver { text },
- attribute rel { text }
- },
element provides {
element entry {
attribute name { text },
+ attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
(attribute flags { "EQ" | "LE" | "GE" },
attribute epoch { xsd:nonNegativeInteger },
attribute ver { text },
attribute rel { text }?)?,
empty
}+
- },
+ }?,
element conflicts {
element entry {
attribute name { text },
+ attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
(attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" },
attribute epoch { xsd:nonNegativeInteger },
attribute ver { text },
element obsoletes {
element entry {
attribute name { text },
+ attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
(attribute flags { "EQ" | "LE" | "GE" | "LT" },
attribute epoch { xsd:nonNegativeInteger },
attribute ver { text },
element requires {
element entry {
attribute name { text },
+ attribute kind { "package" | "patch" | "script" | "message" | "product"}?,
(attribute flags { "EQ" | "LE" | "GE" | "LT" | "GT" },
attribute epoch { xsd:nonNegativeInteger },
attribute ver { text },
attribute pre { "1" | "0" }?,
empty
}*
- }
+ }?
}
<text/>
</element>
</oneOrMore>
- <element name="ns1:version">
- <attribute name="epoch">
- <data type="nonNegativeInteger"/>
- </attribute>
- <attribute name="ver"/>
- <attribute name="rel"/>
- </element>
- <element name="provides">
- <oneOrMore>
- <element name="entry">
- <attribute name="name"/>
- <optional>
- <attribute name="flags">
- <choice>
- <value>EQ</value>
- <value>LE</value>
- <value>GE</value>
- </choice>
- </attribute>
- <attribute name="epoch">
- <data type="nonNegativeInteger"/>
- </attribute>
- <attribute name="ver"/>
+ <optional>
+ <element name="provides">
+ <oneOrMore>
+ <element name="entry">
+ <attribute name="name"/>
<optional>
- <attribute name="rel"/>
+ <attribute name="kind">
+ <choice>
+ <value>package</value>
+ <value>patch</value>
+ <value>script</value>
+ <value>message</value>
+ <value>product</value>
+ </choice>
+ </attribute>
</optional>
- </optional>
- <empty/>
- </element>
- </oneOrMore>
- </element>
+ <optional>
+ <attribute name="flags">
+ <choice>
+ <value>EQ</value>
+ <value>LE</value>
+ <value>GE</value>
+ </choice>
+ </attribute>
+ <attribute name="epoch">
+ <data type="nonNegativeInteger"/>
+ </attribute>
+ <attribute name="ver"/>
+ <optional>
+ <attribute name="rel"/>
+ </optional>
+ </optional>
+ <empty/>
+ </element>
+ </oneOrMore>
+ </element>
+ </optional>
<optional>
<element name="conflicts">
<oneOrMore>
</oneOrMore>
</element>
</optional>
- <element name="requires">
- <zeroOrMore>
- <element name="entry">
- <attribute name="name"/>
- <optional>
- <attribute name="flags">
- <choice>
- <value>EQ</value>
- <value>LE</value>
- <value>GE</value>
- <value>LT</value>
- <value>GT</value>
- </choice>
- </attribute>
- <attribute name="epoch">
- <data type="nonNegativeInteger"/>
- </attribute>
- <attribute name="ver"/>
+ <optional>
+ <element name="requires">
+ <zeroOrMore>
+ <element name="entry">
+ <attribute name="name"/>
+ <optional>
+ <attribute name="flags">
+ <choice>
+ <value>EQ</value>
+ <value>LE</value>
+ <value>GE</value>
+ <value>LT</value>
+ <value>GT</value>
+ </choice>
+ </attribute>
+ <attribute name="epoch">
+ <data type="nonNegativeInteger"/>
+ </attribute>
+ <attribute name="ver"/>
+ <optional>
+ <attribute name="rel"/>
+ </optional>
+ </optional>
<optional>
- <attribute name="rel"/>
+ <attribute name="pre">
+ <choice>
+ <value>1</value>
+ <value>0</value>
+ </choice>
+ </attribute>
</optional>
- </optional>
- <optional>
- <attribute name="pre">
- <choice>
- <value>1</value>
- <value>0</value>
- </choice>
- </attribute>
- </optional>
- <empty/>
- </element>
- </zeroOrMore>
- </element>
+ <empty/>
+ </element>
+ </zeroOrMore>
+ </element>
+ </optional>
</element>
#define FILELISTSCHEMA (SCHEMABASE "filelists.rng")
#define OTHERSCHEMA (SCHEMABASE "other.rng")
#define PATCHSCHEMA (SCHEMABASE "patch.rng")
+ #define PRODUCTSCHEMA (SCHEMABASE "product.rng")
} // namespace yum
} // namespace parser
} // namespace zypp