open62541pp 0.17.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
opcua::Bitmask< T > Class Template Reference

#include <bitmask.hpp>

Detailed Description

template<typename T>
class opcua::Bitmask< T >

Bitmask using (scoped) enums.

Zero-cost abstraction to specify bitmasks with enums/ints or enum classes.

// construct with scoped enums
// construct with unscoped enums or ints
Bitmask using (scoped) enums.
Definition bitmask.hpp:127
UA_NODECLASS_OBJECT
UA_NODECLASS_VARIABLE
Exposes the possibilities of a client to write the attributes of the node In contrast to the write mask

Bitmask enums are defined by specializing the IsBitmaskEnum trait.

Template Parameters
TEnumeration type
See also
https://www.strikerx3.dev/cpp/2019/02/27/typesafe-enum-class-bitmasks-in-cpp.html
https://andreasfertig.blog/2024/01/cpp20-concepts-applied/
Examples
server_accesscontrol.cpp.

Definition at line 127 of file bitmask.hpp.

Public Types

using Underlying = std::underlying_type_t<T>
 

Public Member Functions

constexpr Bitmask () noexcept=default
 
constexpr Bitmask (T mask) noexcept
 
constexpr Bitmask (Underlying mask) noexcept
 
constexpr operator T () const noexcept
 
constexpr operator Underlying () const noexcept
 
constexpr Underlying get () const noexcept
 
constexpr Bitmaskset () noexcept
 
constexpr Bitmaskset (T mask) noexcept
 
constexpr Bitmaskreset () noexcept
 
constexpr Bitmaskreset (T mask) noexcept
 
constexpr Bitmaskflip () noexcept
 
constexpr bool all () const noexcept
 
constexpr bool allOf (T mask) const noexcept
 
constexpr bool any () const noexcept
 
constexpr bool anyOf (T mask) const noexcept
 
constexpr bool none () const noexcept
 
constexpr bool noneOf (T mask) const noexcept
 

Related Symbols

(Note that these are not member symbols.)

template<typename T , typename U >
constexpr bool operator== (Bitmask< T > lhs, U rhs) noexcept
 
template<typename T , typename U >
constexpr bool operator!= (Bitmask< T > lhs, U rhs) noexcept
 
template<typename T , typename U >
constexpr bool operator== (U lhs, Bitmask< T > rhs) noexcept
 
template<typename T , typename U >
constexpr bool operator!= (U lhs, Bitmask< T > rhs) noexcept
 

Member Typedef Documentation

◆ Underlying

template<typename T >
using opcua::Bitmask< T >::Underlying = std::underlying_type_t<T>

Definition at line 132 of file bitmask.hpp.

Constructor & Destructor Documentation

◆ Bitmask() [1/3]

template<typename T >
opcua::Bitmask< T >::Bitmask ( )
constexprdefaultnoexcept

Create an empty bitmask.

◆ Bitmask() [2/3]

template<typename T >
opcua::Bitmask< T >::Bitmask ( T mask)
inlineconstexprnoexcept

Create a bitmask from the enumeration type.

Definition at line 138 of file bitmask.hpp.

◆ Bitmask() [3/3]

template<typename T >
opcua::Bitmask< T >::Bitmask ( Underlying mask)
inlineconstexprnoexcept

Create a bitmask from the underlying type.

Definition at line 142 of file bitmask.hpp.

Member Function Documentation

◆ operator T()

template<typename T >
opcua::Bitmask< T >::operator T ( ) const
inlineexplicitconstexprnoexcept

Conversion to the enum type.

Definition at line 146 of file bitmask.hpp.

◆ operator Underlying()

template<typename T >
opcua::Bitmask< T >::operator Underlying ( ) const
inlineexplicitconstexprnoexcept

Conversion to the underlying type.

Definition at line 151 of file bitmask.hpp.

◆ get()

template<typename T >
Underlying opcua::Bitmask< T >::get ( ) const
inlineconstexprnoexcept

Get the bitmask as the underlying type (integer).

Definition at line 156 of file bitmask.hpp.

Referenced by opcua::Bitmask< T >::operator!=(), opcua::Bitmask< T >::operator!=(), opcua::Bitmask< T >::operator==(), and opcua::Bitmask< T >::operator==().

◆ set() [1/2]

template<typename T >
Bitmask & opcua::Bitmask< T >::set ( )
inlineconstexprnoexcept

Set all bits.

Definition at line 161 of file bitmask.hpp.

◆ set() [2/2]

template<typename T >
Bitmask & opcua::Bitmask< T >::set ( T mask)
inlineconstexprnoexcept

Set specified bits.

Definition at line 167 of file bitmask.hpp.

◆ reset() [1/2]

template<typename T >
Bitmask & opcua::Bitmask< T >::reset ( )
inlineconstexprnoexcept

Reset all bits.

Definition at line 173 of file bitmask.hpp.

◆ reset() [2/2]

template<typename T >
Bitmask & opcua::Bitmask< T >::reset ( T mask)
inlineconstexprnoexcept

Reset specified bits.

Definition at line 179 of file bitmask.hpp.

◆ flip()

template<typename T >
Bitmask & opcua::Bitmask< T >::flip ( )
inlineconstexprnoexcept

Flip all bits.

Definition at line 185 of file bitmask.hpp.

◆ all()

template<typename T >
bool opcua::Bitmask< T >::all ( ) const
inlineconstexprnoexcept

Check if all bits are set.

Definition at line 191 of file bitmask.hpp.

◆ allOf()

template<typename T >
bool opcua::Bitmask< T >::allOf ( T mask) const
inlineconstexprnoexcept

Check if all of the specified bits are set.

Definition at line 196 of file bitmask.hpp.

◆ any()

template<typename T >
bool opcua::Bitmask< T >::any ( ) const
inlineconstexprnoexcept

Check if any bits are set.

Definition at line 201 of file bitmask.hpp.

◆ anyOf()

template<typename T >
bool opcua::Bitmask< T >::anyOf ( T mask) const
inlineconstexprnoexcept

Check if any of the specified bits are set.

Definition at line 206 of file bitmask.hpp.

◆ none()

template<typename T >
bool opcua::Bitmask< T >::none ( ) const
inlineconstexprnoexcept

Check if none bits are set.

Definition at line 211 of file bitmask.hpp.

◆ noneOf()

template<typename T >
bool opcua::Bitmask< T >::noneOf ( T mask) const
inlineconstexprnoexcept

Check if none of the specified bits are set.

Definition at line 216 of file bitmask.hpp.