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

Static Public Member Functions

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

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]

template<typename EnumType_>
BitField ( EnumType value)
inlineconstexpr

Constructor.

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

◆ BitField() [2/2]

template<typename EnumType_>
BitField ( UnderlyingType bits)
inlineconstexpr

Constructor.

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

Member Function Documentation

◆ none()

template<typename EnumType_>
static constexpr BitField none ( )
inlinestaticconstexpr

Named constructor returning a bitfield set to 0.

Returns
The bit field.

◆ all()

template<typename EnumType_>
static constexpr BitField all ( )
inlinestaticconstexpr

Named constructor returning a bitfield set to 1.

Returns
The bit field.

◆ set()

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

Set to 1 the specified bit.

Parameters
[in]otherThe bits to set.

◆ clear()

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

Set to 0 the specified Bit.

Parameters
[in]otherThe bits to clear.

◆ test()

template<typename EnumType_>
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()

template<typename EnumType_>
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()

template<typename EnumType_>
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()

template<typename EnumType_>
const UnderlyingType & get_value ( ) const
inlineconstexpr

Gets the underlying integral value.

Returns
Internal value.

◆ operator==()

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

Equal operator.

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

◆ operator!=()

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

Different operator.

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

◆ operator|()

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

Bitwise 'or' operator.

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

◆ operator&()

template<typename EnumType_>
BitField operator& ( const BitField< EnumType_ > & other) const
inlineconstexpr

Bitwise 'and' operator.

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

◆ operator^()

template<typename EnumType_>
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~()

template<typename EnumType_>
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: