Lagrange
BitField< EnumType_ > Class Template Reference

Bit field utility class. More...

#include <lagrange/utils/BitField.h>

Public Types

using EnumType = EnumType_
 Enum type on top of which the bit field is built.
 
using UnderlyingType = std::underlying_type_t< EnumType >
 Underlying integral type representing the enum type.
 

Public Member Functions

constexpr BitField ()
 Default Constructor.
 
constexpr BitField (EnumType value)
 Constructor. More...
 
constexpr BitField (UnderlyingType bits)
 Constructor. More...
 
constexpr void set (const BitField &other)
 Set to 1 the specified bit. More...
 
constexpr void clear (const BitField &other)
 Set to 0 the specified Bit. More...
 
constexpr void clear_all ()
 Set all bits to 0.
 
constexpr bool test (const BitField &other) const
 Test the specified bit. More...
 
constexpr bool test_any (const BitField &other) const
 Test if any bits are set. More...
 
constexpr void set_bit (const BitField &other, bool is_set)
 Allow to set the value of a bit. More...
 
constexpr operator UnderlyingType () const
 Implicit conversion to the underlying integer type.
 
constexpr const UnderlyingTypeget_value () const
 Gets the underlying integral value. More...
 
constexpr bool operator== (const BitField &other) const
 Equal operator. More...
 
constexpr bool operator!= (const BitField &other) const
 Different operator. More...
 
constexpr BitField operator| (const BitField &other) const
 Bitwise 'or' operator. More...
 
constexpr BitField operator& (const BitField &other) const
 Bitwise 'and' operator. More...
 
constexpr BitField operator^ (const BitField &other) const
 Bitwise 'exclusive or' operator. More...
 
constexpr BitField operator~ () const
 Bitwise 'one's complement' operator. More...
 

Static Public Member Functions

static constexpr BitField none ()
 Named constructor returning a bitfield set to 0. More...
 
static constexpr BitField all ()
 Named constructor returning a bitfield set to 1. More...
 

Detailed Description

template<typename EnumType_>
class lagrange::BitField< EnumType_ >

Bit field utility class.

This class describes a bit field over an enum type.

Template Parameters
EnumType_An enum type whose values are to be used in the bit field.

Constructor & Destructor Documentation

◆ BitField() [1/2]

constexpr BitField ( EnumType  value)
inlineconstexpr

Constructor.

Parameters
[in]valueEnum to initialize the bit field with.

◆ BitField() [2/2]

constexpr BitField ( UnderlyingType  bits)
inlineconstexpr

Constructor.

Parameters
[in]bitsValue to initialize the bit field with.

Member Function Documentation

◆ none()

static constexpr BitField none ( )
inlinestaticconstexpr

Named constructor returning a bitfield set to 0.

Returns
The bit field.

◆ all()

static constexpr BitField all ( )
inlinestaticconstexpr

Named constructor returning a bitfield set to 1.

Returns
The bit field.

◆ set()

constexpr void set ( const BitField< EnumType_ > &  other)
inlineconstexpr

Set to 1 the specified bit.

Parameters
[in]otherThe bits to set.

◆ clear()

constexpr void clear ( const BitField< EnumType_ > &  other)
inlineconstexpr

Set to 0 the specified Bit.

Parameters
[in]otherThe bits to clear.

◆ test()

constexpr bool test ( const BitField< EnumType_ > &  other) const
inlineconstexpr

Test the specified bit.

Parameters
[in]otherThe bits to test.
Returns
True if all the specified bits are set to 1.

◆ test_any()

constexpr bool test_any ( const BitField< EnumType_ > &  other) const
inlineconstexpr

Test if any bits are set.

Parameters
[in]otherThe bits to test.
Returns
true if any of the specified bits is set to 1

◆ set_bit()

constexpr void set_bit ( const BitField< EnumType_ > &  other,
bool  is_set 
)
inlineconstexpr

Allow to set the value of a bit.

Parameters
[in]otherThe bits to modify.
[in]is_setThe value that indicates if the bit is set or not.

◆ get_value()

constexpr const UnderlyingType & get_value ( ) const
inlineconstexpr

Gets the underlying integral value.

Returns
Internal value.

◆ operator==()

constexpr bool operator== ( const BitField< EnumType_ > &  other) const
inlineconstexpr

Equal operator.

Parameters
[in]otherThe other bitfield.
Returns
true if other is equal to current.

◆ operator!=()

constexpr bool operator!= ( const BitField< EnumType_ > &  other) const
inlineconstexpr

Different operator.

Parameters
[in]otherThe other bitfield.
Returns
true if other is equal to current.

◆ operator|()

constexpr BitField operator| ( const BitField< EnumType_ > &  other) const
inlineconstexpr

Bitwise 'or' operator.

Parameters
[in]otherThe other bitfield.
Returns
The result of the bitwise 'or'

◆ operator&()

constexpr BitField operator& ( const BitField< EnumType_ > &  other) const
inlineconstexpr

Bitwise 'and' operator.

Parameters
[in]otherThe other bitfield.
Returns
The result of the bitwise 'and'.

◆ operator^()

constexpr BitField operator^ ( const BitField< EnumType_ > &  other) const
inlineconstexpr

Bitwise 'exclusive or' operator.

Parameters
[in]otherThe other bitfield.
Returns
The result of the bitwise 'exclusive or'.

◆ operator~()

constexpr BitField operator~ ( ) const
inlineconstexpr

Bitwise 'one's complement' operator.

Returns
The result of the bitwise 'one's complement'.

The documentation for this class was generated from the following file: