diff options
author | 2011-02-28 15:57:21 +0000 | |
---|---|---|
committer | 2011-02-28 16:50:38 +0000 | |
commit | 8d632ee9edebdbaa00c31200d97db506b5bf9cac (patch) | |
tree | 604b5c309944f468cc792698f2d3ae66a47b4313 | |
parent | 6af1661baa97ae5f10da9cbc3b9899eb2be16f87 (diff) | |
download | paludis-8d632ee9edebdbaa00c31200d97db506b5bf9cac.tar.gz paludis-8d632ee9edebdbaa00c31200d97db506b5bf9cac.tar.xz |
Add intersects to Options
-rw-r--r-- | paludis/util/options.cc | 8 | ||||
-rw-r--r-- | paludis/util/options.hh | 26 |
2 files changed, 32 insertions, 2 deletions
diff --git a/paludis/util/options.cc b/paludis/util/options.cc index 2445c4564..d3c0f40c3 100644 --- a/paludis/util/options.cc +++ b/paludis/util/options.cc @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2009, 2010 Ciaran McCreesh + * Copyright (c) 2007, 2009, 2010, 2011 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -74,6 +74,12 @@ OptionsStore::subtract(const OptionsStore & e) _bits &= ~e._bits; } +void +OptionsStore::intersect(const OptionsStore & e) +{ + _bits &= e._bits; +} + bool OptionsStore::test(const unsigned e) const { diff --git a/paludis/util/options.hh b/paludis/util/options.hh index fe00e2d76..4ac2e07bf 100644 --- a/paludis/util/options.hh +++ b/paludis/util/options.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2009, 2010 Ciaran McCreesh + * Copyright (c) 2007, 2009, 2010, 2011 Ciaran McCreesh * * This file is part of the Paludis package manager. Paludis is free software; * you can redistribute it and/or modify it under the terms of the GNU General @@ -84,6 +84,11 @@ namespace paludis */ void subtract(const OptionsStore &); + /** + * Unset any bit that is not set in the parameter. + */ + void intersect(const OptionsStore &); + ///\} ///\name Tests @@ -190,6 +195,25 @@ namespace paludis } /** + * Return a copy of ourself, bitwise 'and'ed with another Options set. + */ + Options operator& (const Options<E_> & e) const + { + Options result(*this); + result._store.intersect(e._store); + return result; + } + + /** + * Disable any bits that are not enabled in the parameter. + */ + Options & operator&= (const Options<E_> & e) + { + _store.intersect(e._store); + return *this; + } + + /** * Disable any bits that are enabled in the parameter. */ Options & subtract(const Options<E_> & e) |