11.12. Bitfield name traits
The BITFIELD_TRAIT module implements reflection utilities for bitfield types: converting bitfield values to and from human-readable strings, iterating over individual set bits, and constructing bitfield values from string names.
All functions and symbols are in “bitfield_trait” module, use require to get access to it.
require daslib/bitfield_trait
11.12.1. Function annotations
- bitfield_trait::EachBitfieldMacro
- This macro converts each(bitfield) to the following code::
- generator<string>() <|
yield field1 yield field2 … return false
- bitfield_trait::EachBitNameBitfieldMacro
- This macro converts each(bitfield) to the following code::
- generator<string>() <|
yield “field1” yield “field2” … return false
11.12.2. Iteration
- bitfield_trait::each(argT: auto) : auto()
Iterates over the names of a bitfield type, yielding each bit as a bitfield value (1ul << bitIndex).
- Arguments
argT : auto
- bitfield_trait::each_bit_name(argT: auto) : auto()
Iterates over the names of a bitfield type, yielding each bit name as a string.
- Arguments
argT : auto