From e3c1cfc767f17f5e9b2cd99f2658db3d6ac8edd9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Jun 2015 11:38:04 +0200 Subject: use IndexTarget to get to IndexFile Removes a bunch of duplicated code in the deb-specific parts. Especially the Description part is now handled centrally by IndexTarget instead of being duplicated to the derivations of IndexFile. Git-Dch: Ignore --- apt-pkg/deb/debmetaindex.cc | 56 ++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) (limited to 'apt-pkg/deb/debmetaindex.cc') diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc index d4e340be0..9108a5097 100644 --- a/apt-pkg/deb/debmetaindex.cc +++ b/apt-pkg/deb/debmetaindex.cc @@ -140,6 +140,7 @@ void foreachTarget(std::string const URI, std::string const Dist, Options.insert(std::make_pair("LANGUAGE", *l)); Options.insert(std::make_pair("ARCHITECTURE", "source")); Options.insert(std::make_pair("BASE_URI", baseURI)); + Options.insert(std::make_pair("REPO_URI", URI)); Options.insert(std::make_pair("CREATED_BY", *T)); Call(MetaKey, ShortDesc, LongDesc, IsOptional, Options); @@ -186,6 +187,7 @@ void foreachTarget(std::string const URI, std::string const Dist, Options.insert(std::make_pair("LANGUAGE", *l)); Options.insert(std::make_pair("ARCHITECTURE", a->first)); Options.insert(std::make_pair("BASE_URI", baseURI)); + Options.insert(std::make_pair("REPO_URI", URI)); Options.insert(std::make_pair("CREATED_BY", *T)); Call(MetaKey, ShortDesc, LongDesc, IsOptional, Options); @@ -294,55 +296,25 @@ bool debReleaseIndex::IsTrusted() const return FileExists(VerifiedSigFile); } -struct GetIndexFilesClass +std::vector *debReleaseIndex::GetIndexFiles() { - vector * const Indexes; - std::string const URI; - std::string const Release; - bool const IsTrusted; + if (Indexes != NULL) + return Indexes; - void operator()(std::string const &/*URI*/, std::string const &/*ShortDesc*/, std::string const &/*LongDesc*/, - bool const /*IsOptional*/, std::map Options) + Indexes = new std::vector(); + std::vector const Targets = GetIndexTargets(); + bool const istrusted = IsTrusted(); + for (std::vector::const_iterator T = Targets.begin(); T != Targets.end(); ++T) { - std::string const TargetName = Options.find("CREATED_BY")->second; + std::string const TargetName = T->Options.find("CREATED_BY")->second; if (TargetName == "Packages") - { - Indexes->push_back(new debPackagesIndex( - URI, - Release, - Options.find("COMPONENT")->second, - IsTrusted, - Options.find("ARCHITECTURE")->second - )); - } + Indexes->push_back(new debPackagesIndex(*T, istrusted)); else if (TargetName == "Sources") - Indexes->push_back(new debSourcesIndex( - URI, - Release, - Options.find("COMPONENT")->second, - IsTrusted - )); + Indexes->push_back(new debSourcesIndex(*T, istrusted)); else if (TargetName == "Translations") - Indexes->push_back(new debTranslationsIndex( - URI, - Release, - Options.find("COMPONENT")->second, - Options.find("LANGUAGE")->second - )); + Indexes->push_back(new debTranslationsIndex(*T)); } - - GetIndexFilesClass(std::string const &URI, std::string const &Release, bool const IsTrusted) : - Indexes(new vector ), URI(URI), Release(Release), IsTrusted(IsTrusted) {} -}; - -std::vector *debReleaseIndex::GetIndexFiles() -{ - if (Indexes != NULL) - return Indexes; - - GetIndexFilesClass comp(URI, Dist, IsTrusted()); - foreachTarget(URI, Dist, ArchEntries, comp); - return Indexes = comp.Indexes; + return Indexes; } void debReleaseIndex::PushSectionEntry(vector const &Archs, const debSectionEntry *Entry) { -- cgit v1.2.3