cout << tbl;
}
+static void list_patterns_xml(Zypper & zypper)
+{
+ cout << "<pattern-list>" << endl;
-void list_patterns(Zypper & zypper)
+ ResPool::byKind_iterator
+ it = God->pool().byKindBegin(ResKind::pattern),
+ e = God->pool().byKindEnd(ResKind::pattern);
+ for (; it != e; ++it )
+ {
+ Pattern::constPtr pattern = asKind<Pattern>(it->resolvable());
+ cout << asXML(*pattern, it->isSatisfied()) << endl;
+ }
+
+ cout << "</pattern-list>" << endl;
+}
+
+static void list_pattern_table(Zypper & zypper)
{
MIL << "Going to list patterns." << std::endl;
cout << tbl;
}
+void list_patterns(Zypper & zypper)
+{
+ if (zypper.out().type() == Out::TYPE_XML)
+ list_patterns_xml(zypper);
+ else
+ list_pattern_table(zypper);
+}
+
void list_packages(Zypper & zypper)
{
MIL << "Going to list packages." << std::endl;
return Capability();
}
+/**
+ * \todo this is an ugly quick-hack code, let's do something reusable and maintainable in libzypp later
+ */
+// ----------------------------------------------------------------------------
string asXML(const Product & p, bool is_installed)
{
ostringstream str;
string asXML(const Pattern & p, bool is_installed)
{
- return "";
+ ostringstream str;
+ str
+ << "<pattern"
+ " name=\"" << xml_encode(p.name()) << "\""
+ " version=\"" << p.edition() << "\""
+ " arch=\"" << p.arch() << "\""
+ " vendor=\"" << xml_encode(p.vendor()) << "\""
+ " summary=\"" << xml_encode(p.summary()) << "\""
+ " repo=\"" << xml_encode(p.repoInfo().alias()) << "\""
+ " installed=\"" << (is_installed ? 1 : 0) << "\"";
+ if (p.description().empty())
+ str << "/>";
+ else
+ str
+ << ">" << endl << "<description>" << p.description() << "</description>"
+ << endl << "</pattern>";
+ return str.str();
}
+
+// ----------------------------------------------------------------------------
\ No newline at end of file