1.10
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
BitFields< T > Class Template Reference

#include <bitfields.h>

Public Member Functions

constexpr BitFields () noexcept=default
 
 BitFields (BitFields &&) noexcept=default
 
constexpr BitFields (const BitFields &rhs) noexcept
 Copy constructor.
 
 BitFields (const char *str)
 
 BitFields (const std::string &str)
 
constexpr BitFields (const T &field)
 
 ~BitFields () noexcept=default
 
bool clear ()
 Clear all bit-fields.
 
bool clear (const T &field)
 Clear a single bit-field.
 
bool empty () const
 
void from_string (const std::string &str)
 Convert from string.
 
EGT_NODISCARD constexpr bool is_set (const T &field) const noexcept
 
bool operator!= (const BitFields &rhs) const
 
BitFieldsoperator= (BitFields &&) noexcept=default
 
BitFieldsoperator= (const BitFields &rhs)
 Assignment operator.
 
bool operator== (const BitFields &rhs) const
 
constexpr BitFields< T > operator| (const T &field) const noexcept
 Or operator.
 
bool set (const T &field)
 Set a single bit-field.
 
EGT_NODISCARD std::string to_string () const
 Convert the bit-fields to strings.
 

Public Attributes

Signal on_change
 Event signal.
 

Static Public Attributes

static constexpr const char BITFIELDS_DELIMITER = '|'
 Delimiter used to separate bit-fields in string representation.
 

Protected Member Functions

bool update (uint32_t new_word)
 

Protected Attributes

uint32_t m_word {0}
 

Constructor & Destructor Documentation

◆ BitFields() [1/6]

template<class T >
constexpr BitFields ( )
constexprdefaultnoexcept

◆ BitFields() [2/6]

template<class T >
BitFields ( const std::string &  str)
inlineexplicit
Parameters
[in]strString representation of the bit-fields.

◆ BitFields() [3/6]

template<class T >
BitFields ( const char *  str)
inlineexplicit
Parameters
[in]strString representation of the bit-fields.

◆ BitFields() [4/6]

template<class T >
constexpr BitFields ( const T &  field)
inlineconstexpr

◆ BitFields() [5/6]

template<class T >
constexpr BitFields ( const BitFields< T > &  rhs)
inlineconstexprnoexcept

Copy constructor.

◆ BitFields() [6/6]

template<class T >
BitFields ( BitFields< T > &&  )
defaultnoexcept

◆ ~BitFields()

template<class T >
~BitFields ( )
defaultnoexcept

Member Function Documentation

◆ clear() [1/2]

template<class T >
bool clear ( )
inline

Clear all bit-fields.

◆ clear() [2/2]

template<class T >
bool clear ( const T &  field)
inline

Clear a single bit-field.

◆ empty()

template<class T >
bool empty ( ) const
inline

◆ from_string()

template<class T >
void from_string ( const std::string &  str)
inline

Convert from string.

Note
This will clear any existing bit-field first.

◆ is_set()

template<class T >
EGT_NODISCARD constexpr bool is_set ( const T &  field) const
inlineconstexprnoexcept

◆ operator!=()

template<class T >
bool operator!= ( const BitFields< T > &  rhs) const
inline

◆ operator=() [1/2]

template<class T >
BitFields & operator= ( BitFields< T > &&  )
defaultnoexcept

◆ operator=() [2/2]

template<class T >
BitFields & operator= ( const BitFields< T > &  rhs)
inline

Assignment operator.

◆ operator==()

template<class T >
bool operator== ( const BitFields< T > &  rhs) const
inline

◆ operator|()

template<class T >
constexpr BitFields< T > operator| ( const T &  field) const
inlineconstexprnoexcept

Or operator.

◆ set()

template<class T >
bool set ( const T &  field)
inline

Set a single bit-field.

◆ to_string()

template<class T >
EGT_NODISCARD std::string to_string ( ) const
inline

Convert the bit-fields to strings.

◆ update()

template<class T >
bool update ( uint32_t  new_word)
inlineprotected

Member Data Documentation

◆ BITFIELDS_DELIMITER

template<class T >
constexpr const char BITFIELDS_DELIMITER = '|'
staticconstexpr

Delimiter used to separate bit-fields in string representation.

◆ m_word

template<class T >
uint32_t m_word {0}
protected

◆ on_change

template<class T >
Signal on_change

Event signal.

Invoked when the bit-fields are changed.