aboutsummaryrefslogtreecommitdiff
path: root/paludis
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2016-12-07 08:24:59 -0800
committerAvatar Saleem Abdulrasool <compnerd@compnerd.org> 2016-12-07 08:27:24 -0800
commitdc5c9bb30f29e402e3d4b2a9e0251ab64ec98eda (patch)
tree6a8b2005eca1c561484f3a9d69f29cfb85bb061c /paludis
parent8f321d9a3dd1701fcec489362bbc74f37e102fb4 (diff)
downloadpaludis-dc5c9bb30f29e402e3d4b2a9e0251ab64ec98eda.tar.gz
paludis-dc5c9bb30f29e402e3d4b2a9e0251ab64ec98eda.tar.xz
introduce and use an iterator range in BrokenLinkageFinder
Add some convenience helpers for iteration to BrokenLinkageFinder. This allows us to use range based for loops in cave fix-linkage.
Diffstat (limited to 'paludis')
-rw-r--r--paludis/broken_linkage_finder.cc27
-rw-r--r--paludis/broken_linkage_finder.hh14
2 files changed, 30 insertions, 11 deletions
diff --git a/paludis/broken_linkage_finder.cc b/paludis/broken_linkage_finder.cc
index 601281b..617e8bb 100644
--- a/paludis/broken_linkage_finder.cc
+++ b/paludis/broken_linkage_finder.cc
@@ -359,6 +359,12 @@ BrokenLinkageFinder::end_broken_packages() const
return BrokenPackageConstIterator(first_iterator(_imp->breakage.end()));
}
+IteratorRange<BrokenLinkageFinder::BrokenPackageConstIterator>
+BrokenLinkageFinder::broken_packages() const
+{
+ return {begin_broken_packages(), end_broken_packages()};
+}
+
BrokenLinkageFinder::BrokenFileConstIterator
BrokenLinkageFinder::begin_broken_files(const std::shared_ptr<const PackageID> & pkg) const
{
@@ -389,9 +395,15 @@ BrokenLinkageFinder::end_broken_files(const std::shared_ptr<const PackageID> & p
return BrokenFileConstIterator(first_iterator(_imp->orphan_breakage.end()));
}
+IteratorRange<BrokenLinkageFinder::BrokenFileConstIterator>
+BrokenLinkageFinder::broken_files(const std::shared_ptr<const PackageID> & package) const
+{
+ return {begin_broken_files(package), end_broken_files(package)};
+}
+
BrokenLinkageFinder::MissingRequirementConstIterator
-BrokenLinkageFinder::begin_missing_requirements(
- const std::shared_ptr<const PackageID> & pkg, const FSPath & file) const
+BrokenLinkageFinder::begin_missing_requirements(const std::shared_ptr<const PackageID> & pkg,
+ const FSPath & file) const
{
if (pkg)
{
@@ -416,8 +428,8 @@ BrokenLinkageFinder::begin_missing_requirements(
}
BrokenLinkageFinder::MissingRequirementConstIterator
-BrokenLinkageFinder::end_missing_requirements(
- const std::shared_ptr<const PackageID> & pkg, const FSPath & file) const
+BrokenLinkageFinder::end_missing_requirements(const std::shared_ptr<const PackageID> & pkg,
+ const FSPath & file) const
{
if (pkg)
{
@@ -441,6 +453,13 @@ BrokenLinkageFinder::end_missing_requirements(
}
}
+IteratorRange<BrokenLinkageFinder::MissingRequirementConstIterator>
+BrokenLinkageFinder::missing_requirements(const std::shared_ptr<const PackageID> & package,
+ const FSPath & file) const
+{
+ return {begin_missing_requirements(package, file), end_missing_requirements(package, file)};
+}
+
namespace paludis
{
template class PALUDIS_VISIBLE WrappedForwardIterator<BrokenLinkageFinder::BrokenPackageConstIteratorTag, const std::shared_ptr<const PackageID>>;
diff --git a/paludis/broken_linkage_finder.hh b/paludis/broken_linkage_finder.hh
index 4680a34..144da09 100644
--- a/paludis/broken_linkage_finder.hh
+++ b/paludis/broken_linkage_finder.hh
@@ -22,6 +22,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/fs_path-fwd.hh>
+#include <paludis/util/iterator_range.hh>
#include <paludis/util/pimp.hh>
#include <paludis/util/sequence-fwd.hh>
#include <paludis/util/wrapped_forward_iterator-fwd.hh>
@@ -46,11 +47,10 @@ namespace paludis
BrokenLinkageFinder & operator= (const BrokenLinkageFinder &) = delete;
struct BrokenPackageConstIteratorTag;
- typedef WrappedForwardIterator<BrokenPackageConstIteratorTag,
- const std::shared_ptr<const PackageID>
- > BrokenPackageConstIterator;
+ typedef WrappedForwardIterator<BrokenPackageConstIteratorTag, const std::shared_ptr<const PackageID>> BrokenPackageConstIterator;
BrokenPackageConstIterator begin_broken_packages() const PALUDIS_ATTRIBUTE((warn_unused_result));
BrokenPackageConstIterator end_broken_packages() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ IteratorRange<BrokenPackageConstIterator> broken_packages() const;
struct BrokenFileConstIteratorTag;
typedef WrappedForwardIterator<BrokenFileConstIteratorTag, const FSPath> BrokenFileConstIterator;
@@ -58,15 +58,15 @@ namespace paludis
const PALUDIS_ATTRIBUTE((warn_unused_result));
BrokenFileConstIterator end_broken_files(const std::shared_ptr<const PackageID> &)
const PALUDIS_ATTRIBUTE((warn_unused_result));
+ IteratorRange<BrokenFileConstIterator> broken_files(const std::shared_ptr<const PackageID> &) const;
struct MissingRequirementConstIteratorTag;
typedef WrappedForwardIterator<MissingRequirementConstIteratorTag, const std::string> MissingRequirementConstIterator;
- MissingRequirementConstIterator begin_missing_requirements(
- const std::shared_ptr<const PackageID> &, const FSPath &)
+ MissingRequirementConstIterator begin_missing_requirements(const std::shared_ptr<const PackageID> &, const FSPath &)
const PALUDIS_ATTRIBUTE((warn_unused_result));
- MissingRequirementConstIterator end_missing_requirements(
- const std::shared_ptr<const PackageID> &, const FSPath &)
+ MissingRequirementConstIterator end_missing_requirements(const std::shared_ptr<const PackageID> &, const FSPath &)
const PALUDIS_ATTRIBUTE((warn_unused_result));
+ IteratorRange<MissingRequirementConstIterator> missing_requirements(const std::shared_ptr<const PackageID> &, const FSPath &) const;
};
}