From 001c76fe204e17916a6c8b351ff30b67d32cb779 Mon Sep 17 00:00:00 2001
From: David Kalnischkies <david@kalnischkies.de>
Date: Thu, 11 Jun 2015 11:59:16 +0200
Subject: 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
---
 apt-pkg/deb/debindexfile.cc | 14 +++++++-------
 apt-pkg/deb/debmetaindex.cc |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

(limited to 'apt-pkg/deb')

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")
-- 
cgit v1.2.3