summaryrefslogtreecommitdiff
path: root/apt-pkg/cacheset.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-06-06 21:41:27 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-06-06 21:41:27 +0200
commit9cc83a6fbc089ccf9cb8d52ee9f380cf5df62d5c (patch)
tree739553a52b0abbf5344330fa2c45e0dc7105fbbb /apt-pkg/cacheset.cc
parent07c279d93f0b61e96c9caf8139accd0289feab56 (diff)
add a GroupedFromCommandLine method to the PackageSet to split the
packages on the commandline into groups based on modifiers
Diffstat (limited to 'apt-pkg/cacheset.cc')
-rw-r--r--apt-pkg/cacheset.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/apt-pkg/cacheset.cc b/apt-pkg/cacheset.cc
index c0b06ba32..43ade4b4e 100644
--- a/apt-pkg/cacheset.cc
+++ b/apt-pkg/cacheset.cc
@@ -76,6 +76,39 @@ PackageSet PackageSet::FromRegEx(pkgCacheFile &Cache, std::string pattern, std::
return pkgset;
}
/*}}}*/
+// GroupedFromCommandLine - Return all versions specified on commandline/*{{{*/
+std::map<unsigned short, PackageSet> PackageSet::GroupedFromCommandLine(
+ pkgCacheFile &Cache, const char **cmdline,
+ std::list<PackageSet::Modifier> const &mods,
+ unsigned short const &fallback, std::ostream &out) {
+ std::map<unsigned short, PackageSet> pkgsets;
+ for (const char **I = cmdline; *I != 0; ++I) {
+ unsigned short modID = fallback;
+ std::string str = *I;
+ for (std::list<PackageSet::Modifier>::const_iterator mod = mods.begin();
+ mod != mods.end(); ++mod) {
+ size_t const alength = strlen(mod->Alias);
+ switch(mod->Pos) {
+ case PackageSet::Modifier::POSTFIX:
+ if (str.compare(str.length() - alength, alength,
+ mod->Alias, 0, alength) != 0)
+ continue;
+ str.erase(str.length() - alength);
+ modID = mod->ID;
+ break;
+ case PackageSet::Modifier::PREFIX:
+ continue;
+ case PackageSet::Modifier::NONE:
+ continue;
+ }
+ break;
+ }
+ PackageSet pset = PackageSet::FromString(Cache, str, out);
+ pkgsets[modID].insert(pset.begin(), pset.end());
+ }
+ return pkgsets;
+}
+ /*}}}*/
// FromCommandLine - Return all packages specified on commandline /*{{{*/
PackageSet PackageSet::FromCommandLine(pkgCacheFile &Cache, const char **cmdline, std::ostream &out) {
PackageSet pkgset;