ref: refs/heads/master
commit 358f5e7f0f6ed7fc78534f3c6b446692388aa7f4
Author: Michael Andres
Date: Thu Oct 15 20:43:36 2009 +0200
BitField: add explict set/unset/test/testAnyOf methods
---
zypp/Bit.h | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/zypp/Bit.h b/zypp/Bit.h
index 1a04819..c12d0a1 100644
--- a/zypp/Bit.h
+++ b/zypp/Bit.h
@@ -225,6 +225,49 @@ namespace zypp
{
return _value == rhs;
}
+
+ public:
+
+ /** Set or unset bits of \a rhs. */
+ template<class _Range>
+ BitField & set( _IntT rhs, bool doset_r )
+ { return set( (rhs & _Range::Mask::value), doset_r ); }
+
+ BitField & set( _IntT rhs, bool doset_r )
+ { return doset_r ? set( rhs ) : unset( rhs ); }
+
+ /** Set bits of \a rhs. */
+ template<class _Range>
+ BitField & set( _IntT rhs )
+ { return set( rhs & _Range::Mask::value ); }
+
+ BitField & set( _IntT rhs )
+ { _value |= rhs; return *this; }
+
+ /** Unset bits of \a rhs. */
+ template<class _Range>
+ BitField & unset( _IntT rhs )
+ { return unset( rhs & _Range::Mask::value ); }
+
+ BitField & unset( _IntT rhs )
+ { _value &= ~rhs; return *this; }
+
+ /** Test whether \b all bits of \a rhs are set. */
+ template<class _Range>
+ bool test( _IntT rhs )
+ { return test( rhs & _Range::Mask::value ); }
+
+ bool test( _IntT rhs ) const
+ { return (_value & rhs) == rhs; }
+
+ /** Test whether \b at \b least \b one bit of \a rhs is set. */
+ template<class _Range>
+ bool testAnyOf( _IntT rhs )
+ { return testAnyOf( rhs & _Range::Mask::value ); }
+
+ bool testAnyOf( _IntT rhs ) const
+ { return (_value & rhs); }
+
public:
BitField & operator=( const BitField & rhs )
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org