aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2017-01-16 13:03:26 -0800
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2017-01-16 13:56:45 -0800
commit6b0e48f888cf983f6a3e3640c8e2e76a0826632f (patch)
tree47cc378051c6e260f58e149e6f012b264ad20c44 /src
parente023360dbf9b38671dbccbafdfdd26fb87c1c21b (diff)
downloadpaludis-6b0e48f888cf983f6a3e3640c8e2e76a0826632f.tar.gz
paludis-6b0e48f888cf983f6a3e3640c8e2e76a0826632f.tar.xz
paludis: c++11-ify repository iteration
Add a `repositories` in `Environment` which provides an iterator range for the repositories, allowing C++11 style range based iteration.
Diffstat (limited to 'src')
-rw-r--r--src/clients/cave/cmd_find_candidates.cc5
-rw-r--r--src/clients/cave/cmd_info.cc5
-rw-r--r--src/clients/cave/cmd_print_categories.cc10
-rw-r--r--src/clients/cave/cmd_print_packages.cc10
-rw-r--r--src/clients/cave/cmd_print_unused_distfiles.cc7
-rw-r--r--src/clients/cave/cmd_sync.cc11
6 files changed, 20 insertions, 28 deletions
diff --git a/src/clients/cave/cmd_find_candidates.cc b/src/clients/cave/cmd_find_candidates.cc
index 684a92348..6c8500c4a 100644
--- a/src/clients/cave/cmd_find_candidates.cc
+++ b/src/clients/cave/cmd_find_candidates.cc
@@ -209,9 +209,8 @@ FindCandidatesCommand::run_hosted(
step("Searching repositories");
RepositoryNames repository_names;
- for (Environment::RepositoryConstIterator r(env->begin_repositories()),
- r_end(env->end_repositories()) ; r != r_end ; ++r)
- repository_names.insert((*r)->name());
+ for (const auto & repository : env->repositories())
+ repository_names.insert(repository->name());
step("Searching categories");
diff --git a/src/clients/cave/cmd_info.cc b/src/clients/cave/cmd_info.cc
index 72a755e73..f01a9b352 100644
--- a/src/clients/cave/cmd_info.cc
+++ b/src/clients/cave/cmd_info.cc
@@ -403,9 +403,8 @@ InfoCommand::run(
do_about(cmdline, env);
do_env(cmdline, env);
- for (auto r(env->begin_repositories()), r_end(env->end_repositories()) ;
- r != r_end ; ++r)
- do_one_repository(cmdline, env, *r);
+ for (const auto & repository : env->repositories())
+ do_one_repository(cmdline, env, repository);
if (cmdline.begin_parameters() == cmdline.end_parameters())
{
diff --git a/src/clients/cave/cmd_print_categories.cc b/src/clients/cave/cmd_print_categories.cc
index f27693357..87526fd14 100644
--- a/src/clients/cave/cmd_print_categories.cc
+++ b/src/clients/cave/cmd_print_categories.cc
@@ -95,12 +95,10 @@ PrintCategoriesCommand::run(
throw args::DoHelp("print-categories takes no parameters");
std::set<CategoryNamePart> categories;
- for (auto r(env->begin_repositories()), r_end(env->end_repositories()) ;
- r != r_end ; ++r)
+ for (const auto & repository : env->repositories())
{
if (cmdline.a_repository.specified())
- if (cmdline.a_repository.end_args() == std::find(cmdline.a_repository.begin_args(),
- cmdline.a_repository.end_args(), stringify((*r)->name())))
+ if (cmdline.a_repository.end_args() == std::find(cmdline.a_repository.begin_args(), cmdline.a_repository.end_args(), stringify(repository->name())))
continue;
if (cmdline.a_containing.specified())
@@ -108,13 +106,13 @@ PrintCategoriesCommand::run(
for (args::StringSetArg::ConstIterator p(cmdline.a_containing.begin_args()), p_end(cmdline.a_containing.end_args()) ;
p != p_end ; ++p)
{
- std::shared_ptr<const CategoryNamePartSet> cats((*r)->category_names_containing_package(PackageNamePart(*p), { }));
+ std::shared_ptr<const CategoryNamePartSet> cats(repository->category_names_containing_package(PackageNamePart(*p), { }));
std::copy(cats->begin(), cats->end(), std::inserter(categories, categories.begin()));
}
}
else
{
- std::shared_ptr<const CategoryNamePartSet> cats((*r)->category_names({ }));
+ std::shared_ptr<const CategoryNamePartSet> cats(repository->category_names({ }));
std::copy(cats->begin(), cats->end(), std::inserter(categories, categories.begin()));
}
}
diff --git a/src/clients/cave/cmd_print_packages.cc b/src/clients/cave/cmd_print_packages.cc
index 278f2e413..b765ea2b0 100644
--- a/src/clients/cave/cmd_print_packages.cc
+++ b/src/clients/cave/cmd_print_packages.cc
@@ -94,15 +94,13 @@ PrintPackagesCommand::run(
std::set<QualifiedPackageName> all_packages;
- for (auto r(env->begin_repositories()), r_end(env->end_repositories());
- r != r_end; ++r)
+ for (const auto & repository : env->repositories())
{
if (cmdline.a_repository.specified())
- if (cmdline.a_repository.end_args() == std::find(
- cmdline.a_repository.begin_args(), cmdline.a_repository.end_args(), stringify((*r)->name())))
+ if (cmdline.a_repository.end_args() == std::find(cmdline.a_repository.begin_args(), cmdline.a_repository.end_args(), stringify(repository->name())))
continue;
- std::shared_ptr<const CategoryNamePartSet> categories((*r)->category_names({ }));
+ std::shared_ptr<const CategoryNamePartSet> categories(repository->category_names({}));
for (CategoryNamePartSet::ConstIterator c(categories->begin()), c_end(categories->end());
c != c_end; ++c)
{
@@ -111,7 +109,7 @@ PrintPackagesCommand::run(
cmdline.a_category.begin_args(), cmdline.a_category.end_args(), stringify(*c)))
continue;
- std::shared_ptr<const QualifiedPackageNameSet> packages((*r)->package_names(*c, { }));
+ std::shared_ptr<const QualifiedPackageNameSet> packages(repository->package_names(*c, { }));
std::copy(packages->begin(), packages->end(), std::inserter(all_packages, all_packages.begin()));
}
}
diff --git a/src/clients/cave/cmd_print_unused_distfiles.cc b/src/clients/cave/cmd_print_unused_distfiles.cc
index 6bea3554a..47a3753ad 100644
--- a/src/clients/cave/cmd_print_unused_distfiles.cc
+++ b/src/clients/cave/cmd_print_unused_distfiles.cc
@@ -188,11 +188,10 @@ PrintUnusedDistfilesCommand::run(
std::set<FSPath, FSPathComparator> distdirs;
- for (auto repo(env->begin_repositories()), end(env->end_repositories()) ;
- repo != end ; ++repo)
+ for (const auto & repository : env->repositories())
{
- auto distdir_metadata((*repo)->find_metadata("distdir"));
- if (distdir_metadata != (*repo)->end_metadata())
+ auto distdir_metadata(repository->find_metadata("distdir"));
+ if (distdir_metadata != repository->end_metadata())
{
auto path_key(visitor_cast<const MetadataValueKey<FSPath>>(**distdir_metadata));
if (path_key)
diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc
index 5ca1f9de2..cf31017d1 100644
--- a/src/clients/cave/cmd_sync.cc
+++ b/src/clients/cave/cmd_sync.cc
@@ -382,9 +382,8 @@ SyncCommand::run(
repos.insert(n);
}
else
- for (auto p(env->begin_repositories()), p_end(env->end_repositories()) ;
- p != p_end ; ++p)
- repos.insert((*p)->name());
+ for (const auto & repository : env->repositories())
+ repos.insert(repository->name());
if (1 == repos.size())
cmdline.a_sequential.set_specified(args::aos_weak);
@@ -400,10 +399,10 @@ SyncCommand::run(
retcode |= sync_these(env, cmdline, repos);
- for (auto r(env->begin_repositories()), r_end(env->end_repositories()) ; r != r_end ; ++r)
+ for (const auto & repository : env->repositories())
{
- (*r)->invalidate();
- (*r)->purge_invalid_cache();
+ repository->invalidate();
+ repository->purge_invalid_cache();
}
if (0 != env->perform_hook(Hook("sync_all_post")