open62541pp 0.16.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:125
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
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 125 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 130 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 136 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 140 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 144 of file bitmask.hpp.

◆ operator Underlying()

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

Conversion to the underlying type.

Definition at line 149 of file bitmask.hpp.

◆ get()

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

◆ set() [1/2]

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

Set all bits.

Definition at line 159 of file bitmask.hpp.

◆ set() [2/2]

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

Set specified bits.

Definition at line 165 of file bitmask.hpp.

◆ reset() [1/2]

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

Reset all bits.

Definition at line 171 of file bitmask.hpp.

◆ reset() [2/2]

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

Reset specified bits.

Definition at line 177 of file bitmask.hpp.

◆ flip()

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

Flip all bits.

Definition at line 183 of file bitmask.hpp.

◆ all()

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

Check if all bits are set.

Definition at line 189 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 194 of file bitmask.hpp.

◆ any()

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

Check if any bits are set.

Definition at line 199 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 204 of file bitmask.hpp.

◆ none()

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

Check if none bits are set.

Definition at line 209 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 214 of file bitmask.hpp.