From 358f5e7f0f6ed7fc78534f3c6b446692388aa7f4 Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Thu, 15 Oct 2009 20:43:36 +0200 Subject: [PATCH] BitField: add explict set/unset/test/testAnyOf methods --- zypp/Bit.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) 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 + 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 + BitField & set( _IntT rhs ) + { return set( rhs & _Range::Mask::value ); } + + BitField & set( _IntT rhs ) + { _value |= rhs; return *this; } + + /** Unset bits of \a rhs. */ + template + 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 + 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 + bool testAnyOf( _IntT rhs ) + { return testAnyOf( rhs & _Range::Mask::value ); } + + bool testAnyOf( _IntT rhs ) const + { return (_value & rhs); } + public: BitField & operator=( const BitField & rhs ) -- 2.7.4