summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-pkg/deb/debindexfile.cc14
-rw-r--r--apt-pkg/deb/debmetaindex.cc2
-rw-r--r--apt-pkg/indexfile.cc18
-rw-r--r--apt-pkg/indexfile.h16
4 files changed, 38 insertions, 12 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 3e60423ff..7aad65c0e 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -93,9 +93,9 @@ debPackagesIndex::debPackagesIndex(IndexTarget const &Target, bool const Trusted
/* This is a shorter version that is designed to be < 60 chars or so */
string debPackagesIndex::ArchiveInfo(pkgCache::VerIterator Ver) const
{
- std::string const Dist = Target.Option("RELEASE");
- string Res = Target.Option("SITE") + " " + Dist;
- std::string const Component = Target.Option("COMPONENT");
+ std::string const Dist = Target.Option(IndexTarget::RELEASE);
+ string Res = Target.Option(IndexTarget::SITE) + " " + Dist;
+ std::string const Component = Target.Option(IndexTarget::COMPONENT);
if (Component.empty() == false)
Res += "/" + Component;
@@ -115,7 +115,7 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
{
string const PackageFile = IndexFileName();
FileFd Pkg(PackageFile,FileFd::ReadOnly, FileFd::Extension);
- debListParser Parser(&Pkg, Target.Option("ARCHITECTURE"));
+ debListParser Parser(&Pkg, Target.Option(IndexTarget::ARCHITECTURE));
if (_error->PendingError() == true)
return _error->Error("Problem opening %s",PackageFile.c_str());
@@ -123,8 +123,8 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
Prog->SubProgress(0, Target.Description);
- std::string const URI = Target.Option("REPO_URI");
- std::string Dist = Target.Option("RELEASE");
+ std::string const URI = Target.Option(IndexTarget::REPO_URI);
+ std::string Dist = Target.Option(IndexTarget::RELEASE);
if (Dist.empty())
Dist = "/";
::URI Tmp(URI);
@@ -158,7 +158,7 @@ bool debPackagesIndex::Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const
if (_error->PendingError() == true)
return false;
- Parser.LoadReleaseInfo(File, Rel, Target.Option("COMPONENT"));
+ Parser.LoadReleaseInfo(File, Rel, Target.Option(IndexTarget::COMPONENT));
}
return true;
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index 9108a5097..c05e7cdae 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -306,7 +306,7 @@ std::vector <pkgIndexFile *> *debReleaseIndex::GetIndexFiles()
bool const istrusted = IsTrusted();
for (std::vector<IndexTarget>::const_iterator T = Targets.begin(); T != Targets.end(); ++T)
{
- std::string const TargetName = T->Options.find("CREATED_BY")->second;
+ std::string const TargetName = T->Option(IndexTarget::CREATED_BY);
if (TargetName == "Packages")
Indexes->push_back(new debPackagesIndex(*T, istrusted));
else if (TargetName == "Sources")
diff --git a/apt-pkg/indexfile.cc b/apt-pkg/indexfile.cc
index bbcd9246c..72d35ddcc 100644
--- a/apt-pkg/indexfile.cc
+++ b/apt-pkg/indexfile.cc
@@ -120,8 +120,22 @@ IndexTarget::IndexTarget(std::string const &MetaKey, std::string const &ShortDes
{
}
/*}}}*/
-std::string IndexTarget::Option(std::string const &Key) const /*{{{*/
+std::string IndexTarget::Option(OptionKeys const EnumKey) const /*{{{*/
{
+ std::string Key;
+ switch (EnumKey)
+ {
+#define APT_CASE(X) case X: Key = #X; break
+ APT_CASE(SITE);
+ APT_CASE(RELEASE);
+ APT_CASE(COMPONENT);
+ APT_CASE(LANGUAGE);
+ APT_CASE(ARCHITECTURE);
+ APT_CASE(BASE_URI);
+ APT_CASE(REPO_URI);
+ APT_CASE(CREATED_BY);
+#undef APT_CASE
+ }
std::map<std::string,std::string>::const_iterator const M = Options.find(Key);
if (M == Options.end())
return "";
@@ -136,7 +150,7 @@ pkgIndexTargetFile::pkgIndexTargetFile(IndexTarget const &Target, bool const Tru
/*}}}*/
std::string pkgIndexTargetFile::ArchiveURI(std::string File) const/*{{{*/
{
- return Target.Option("REPO_URI") + File;
+ return Target.Option(IndexTarget::REPO_URI) + File;
}
/*}}}*/
std::string pkgIndexTargetFile::Describe(bool Short) const /*{{{*/
diff --git a/apt-pkg/indexfile.h b/apt-pkg/indexfile.h
index e6e429c2c..c38cf0bf0 100644
--- a/apt-pkg/indexfile.h
+++ b/apt-pkg/indexfile.h
@@ -61,14 +61,26 @@ class IndexTarget /*{{{*/
/** \brief Is it okay if the file isn't found in the meta index */
bool IsOptional;
- /** \brief Target specific options defined by the implementation */
+ /** \brief options with which this target was created
+ Prefer the usage of #Option if at all possible.
+ Beware: Not all of these options are intended for public use */
std::map<std::string, std::string> Options;
IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
std::string const &LongDesc, std::string const &URI, bool const IsOptional,
std::map<std::string, std::string> const &Options);
- std::string Option(std::string const &Key) const;
+ enum OptionKeys {
+ SITE,
+ RELEASE,
+ COMPONENT,
+ LANGUAGE,
+ ARCHITECTURE,
+ BASE_URI,
+ REPO_URI,
+ CREATED_BY,
+ };
+ std::string Option(OptionKeys const Key) const;
};
/*}}}*/