34 template<
class _IntT,
unsigned _size>
57 inline std::string
asString( _IntT val,
char zero =
'0',
char one =
'1' )
71 template<
class _IntT,
unsigned _begin,
unsigned _size>
80 template<
class _IntT,
unsigned _begin,
unsigned _size>
87 static const unsigned begin = _begin;
88 static const unsigned size = _size;
89 static const unsigned end = _begin + _size;
95 template<
class _IntT,
unsigned _begin>
109 template<
class _Range,
typename _Range::IntT _value>
113 typedef typename _Range::IntT
IntT;
127 template<
class _Range,
unsigned _pos>
131 typedef typename _Range::IntT
IntT;
158 template<
class _IntT>
173 explicit operator bool()
const
174 {
return _value != (_IntT)0; }
178 template<
class _Range>
181 return _value & _Range::Mask::value;
189 template<
class _Range>
200 template<
class _Range>
204 | (rhs & _Range::Mask::value);
214 template<
class _Range>
217 return (
_value & _Range::Mask::value)
218 == (rhs & _Range::Mask::value);
228 template<
class _Range>
230 {
return set( (rhs & _Range::Mask::value), doset_r ); }
233 {
return doset_r ?
set( rhs ) :
unset( rhs ); }
236 template<
class _Range>
238 {
return set( rhs & _Range::Mask::value ); }
241 {
_value |= rhs;
return *
this; }
244 template<
class _Range>
246 {
return unset( rhs & _Range::Mask::value ); }
249 {
_value &= ~rhs;
return *
this; }
252 template<
class _Range>
254 {
return test( rhs & _Range::Mask::value ); }
257 {
return (
_value & rhs) == rhs; }
260 template<
class _Range>
262 {
return testAnyOf( rhs & _Range::Mask::value ); }
265 {
return (
_value & rhs); }
282 {
_value <<= num;
return *
this; }
285 {
_value >>= num;
return *
this; }
296 template<
class _IntT>
297 std::ostream & operator<<( std::ostream & str, const BitField<_IntT> & obj )
299 return str << obj.asString();
303 template<
class _IntT>
308 template<
class _IntT>
310 {
return ! (lhs == rhs); }
314 template<
class _IntT>
319 template<
class _IntT>
324 template<
class _IntT>
329 template<
class _IntT>
334 template<
class _IntT>
_IntT value() const
Return the value.
BitField()
Default ctor: zero.
BitField & operator=(const BitField &rhs)
BitField & operator<<=(unsigned num)
Number of bits available in _IntT.
std::string asString() const
static const unsigned end
bool isEqual(_IntT rhs) const
zypp::bit::MaxBits< IntT > MaxBits
BitField & unset(_IntT rhs)
Unset bits of rhs.
BitField & operator^=(const BitField &rhs)
BitField< _IntT > operator|(const BitField< _IntT > &lhs, const BitField< _IntT > &rhs)
A bitmaks of _size 1-bits starting at bit _begin.
bool operator==(const BitField< _IntT > &lhs, const BitField< _IntT > &rhs)
BitField< _IntT > operator^(const BitField< _IntT > &lhs, const BitField< _IntT > &rhs)
BitField & assign(_IntT rhs)
Assign Range in rhs to this.
static const IntT inverted
BitField & set(_IntT rhs, bool doset_r)
Set or unset bits of rhs.
BitField & operator>>=(unsigned num)
A single 1-bit within a Range.
bool operator!=(const BitField< _IntT > &lhs, const BitField< _IntT > &rhs)
bool test(_IntT rhs) const
BitField & set(_IntT rhs, bool doset_r)
Generate constants with _size trailing '1'-bits.
std::string asString(_IntT val, char zero= '0', char one= '1')
For printing bits.
BitField & operator&=(const BitField &rhs)
BitField< _IntT > operator&(const BitField< _IntT > &lhs, const BitField< _IntT > &rhs)
BitField & operator|=(const BitField &rhs)
BitField(const _IntT &value_r)
Ctor taking an _IntT.
BitField & unset(_IntT rhs)
static const unsigned begin
BitField operator~() const
An integral type used as BitField.
bool testAnyOf(_IntT rhs) const
BitField & set(_IntT rhs)
Set bits of rhs.
std::string asString() const
Value as bit string.
bool isEqual(_IntT rhs) const
Test for equal value within a Range.
BitField & assign(_IntT rhs)
bool testAnyOf(_IntT rhs)
Test whether at least one bit of rhs is set.
static const unsigned size
BitField< _IntT > operator>>(const BitField< _IntT > &lhs, unsigned num)
zypp::bit::Mask< IntT, _begin, _size > Mask
static const unsigned value
Range of bits starting at bit _begin with length _size.
BitField & set(_IntT rhs)
bool test(_IntT rhs)
Test whether all bits of rhs are set.