aboutsummaryrefslogtreecommitdiff
path: root/paludis/package_id.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-07-16 19:19:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-07-16 19:19:52 +0000
commitae97e3f4b15b180fe0d1bcc4257103c3ad116f83 (patch)
tree6150b02237e5b668b36743d296df0cf799347b55 /paludis/package_id.cc
parent4efa00282a8282be189bcda866a8fad9c448a407 (diff)
downloadpaludis-ae97e3f4b15b180fe0d1bcc4257103c3ad116f83.tar.gz
paludis-ae97e3f4b15b180fe0d1bcc4257103c3ad116f83.tar.xz
Smarter mask reasons code. Fixes: ticket:317
Diffstat (limited to 'paludis/package_id.cc')
-rw-r--r--paludis/package_id.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/paludis/package_id.cc b/paludis/package_id.cc
index 37ba5141b..183aedb03 100644
--- a/paludis/package_id.cc
+++ b/paludis/package_id.cc
@@ -51,6 +51,7 @@ namespace paludis
struct Implementation<PackageID>
{
mutable std::list<tr1::shared_ptr<const MetadataKey> > keys;
+ mutable std::list<tr1::shared_ptr<const Mask> > masks;
};
}
@@ -67,6 +68,7 @@ void
PackageID::add_metadata_key(const tr1::shared_ptr<const MetadataKey> & k) const
{
using namespace tr1::placeholders;
+
if (_imp->keys.end() != std::find_if(_imp->keys.begin(), _imp->keys.end(),
tr1::bind(std::equal_to<std::string>(), k->raw_name(), tr1::bind(tr1::mem_fn(&MetadataKey::raw_name), _1))))
throw ConfigurationError("Tried to add duplicate key '" + k->raw_name() + "' to ID '" + stringify(*this) + "'");
@@ -88,6 +90,32 @@ PackageID::end_metadata() const
return MetadataIterator(indirect_iterator(_imp->keys.end()));
}
+void
+PackageID::add_mask(const tr1::shared_ptr<const Mask> & k) const
+{
+ _imp->masks.push_back(k);
+}
+
+PackageID::MasksIterator
+PackageID::begin_masks() const
+{
+ need_masks_added();
+ return MasksIterator(indirect_iterator(_imp->masks.begin()));
+}
+
+PackageID::MasksIterator
+PackageID::end_masks() const
+{
+ need_masks_added();
+ return MasksIterator(indirect_iterator(_imp->masks.end()));
+}
+
+bool
+PackageID::masked() const
+{
+ return begin_masks() != end_masks();
+}
+
PackageID::MetadataIterator
PackageID::find_metadata(const std::string & s) const
{