IgrOS-Kernel 0.1.34.545
Simple C++20 Kernel for i386/x86_64
Loading...
Searching...
No Matches
igros::klib::kFlags< T > Class Template Referencefinal

Bit flags of enum type. More...

#include <klib/kFlags.hpp>

Public Member Functions

constexpr kFlags () noexcept=default
 No flags set.
template<std::same_as< T >... Args>
constexpr kFlags (const T flag, const Args... flags) noexcept
 From set flags.
constexpr auto value () const noexcept -> U
 Get value.
constexpr auto isSet (const T flag) const noexcept -> bool
 Check if flag is set (all bits of non-empty flag).
constexpr auto set (const T flag) const noexcept -> kFlags
 Set flag (read-modify-write of hardware registers).

Static Public Member Functions

static constexpr auto from (const U value) noexcept -> kFlags
 From raw value (hardware register, table entry).

Private Types

using U = std::underlying_type_t<T>
 Underlying type of flags.
using W = std::common_type_t<U, unsigned int>
 Type of bit operations (at least unsigned int: narrower types would be promoted to int).

Private Attributes

U mValue
 Flags value.

Detailed Description

template<class T>
requires std::is_enum_v<T>
class igros::klib::kFlags< T >

Bit flags of enum type.

Template Parameters
TFlags enum type (bit values)

Definition at line 29 of file kFlags.hpp.

Member Typedef Documentation

◆ U

template<class T>
using igros::klib::kFlags< T >::U = std::underlying_type_t<T>
private

Underlying type of flags.

Definition at line 32 of file kFlags.hpp.

◆ W

template<class T>
using igros::klib::kFlags< T >::W = std::common_type_t<U, unsigned int>
private

Type of bit operations (at least unsigned int: narrower types would be promoted to int).

Definition at line 34 of file kFlags.hpp.

Constructor & Destructor Documentation

◆ kFlags()

template<class T>
template<std::same_as< T >... Args>
igros::klib::kFlags< T >::kFlags ( const T flag,
const Args... flags )
inlineexplicitconstexprnoexcept

From set flags.

Template Parameters
ArgsFurther flags (same enum type)
Parameters
flagFirst set flag
flagsFurther set flags

Definition at line 48 of file kFlags.hpp.

Member Function Documentation

◆ from()

template<class T>
constexpr auto igros::klib::kFlags< T >::from ( const U value) ->kFlags
inlinestaticnodiscardconstexprnoexcept

From raw value (hardware register, table entry).

Parameters
valueRaw value (unknown bits are kept)
Returns
Flags with given value

Definition at line 55 of file kFlags.hpp.

◆ isSet()

template<class T>
auto igros::klib::kFlags< T >::isSet ( const T flag) const->bool
inlinenodiscardconstexprnoexcept

Check if flag is set (all bits of non-empty flag).

Parameters
flagTested flag (may have several bits)
Returns
true if all bits of flag are set (false for empty flag)

Definition at line 72 of file kFlags.hpp.

◆ set()

template<class T>
auto igros::klib::kFlags< T >::set ( const T flag) const->kFlags
inlinenodiscardconstexprnoexcept

Set flag (read-modify-write of hardware registers).

Parameters
flagSet flag (may have several bits)
Returns
Flags with all bits of flag set (other bits are kept)

Definition at line 81 of file kFlags.hpp.

◆ value()

template<class T>
auto igros::klib::kFlags< T >::value ( ) const->U
inlinenodiscardconstexprnoexcept

Get value.

Returns
Underlying value of flags

Definition at line 64 of file kFlags.hpp.

Member Data Documentation

◆ mValue

template<class T>
U igros::klib::kFlags< T >::mValue
private

Flags value.

Definition at line 36 of file kFlags.hpp.


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