summaryrefslogtreecommitdiff
path: root/apt-pkg/indexfile.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-11 11:59:16 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-06-11 11:59:16 +0200
commit001c76fe204e17916a6c8b351ff30b67d32cb779 (patch)
tree5ce4ec8dca05a152e6ecb2daf436cf2b5b0a9a96 /apt-pkg/indexfile.cc
parente3c1cfc767f17f5e9b2cd99f2658db3d6ac8edd9 (diff)
use an enum instead of strings as IndexTarget::Option interface
Strings are easy to typo and we can keep the extensibility we require here with a simple enum we can append to without endangering ABI. Git-Dch: Ignore
Diffstat (limited to 'apt-pkg/indexfile.cc')
-rw-r--r--apt-pkg/indexfile.cc18
1 files changed, 16 insertions, 2 deletions
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 /*{{{*/