Template Class desfire::key_actor

Class Documentation

template<class SpecialT>
class key_actor

Variant structure that at a given time represents either one key index, or one of two special values, one of which being no_key (i.e. no key has the given right) or a custom meaning implied by the template parameter. This class can be packed into a nibble (i.e. a 4 bits sequence).

Template Parameters:

SpecialT – Monostate structure type which represents the other special value used in alternative to the no_key special value, e.g. free_access_t or same_key_t.

Assignment operators mimicking constructors

inline key_actor &operator=(std::uint8_t key_index)
key_actor &operator=(bool) = delete
inline key_actor &operator=(SpecialT)
inline key_actor &operator=(no_key_t)

Comparison operators

inline bool operator==(key_actor const &other) const
inline bool operator!=(key_actor const &other) const

Public Functions

inline void set_nibble(std::uint8_t v)

Sets the value of this class based on the lower nibble of v.

Parameters:

v – Value representing the key actor.

inline std::uint8_t get_nibble() const

Returns a byte whose lower nibble contains a numeric representation of this class.

Returns:

A byte masked by 0xF, the lower 4 bits contain the representation of the key actor.

constexpr key_actor()

Default-constructs this class with the key index 0.

constexpr key_actor(std::uint8_t key_index)

Creates a key actor referencing the given key_index.

Parameters:

key_index – A value between 0 and 13 (included).

key_actor(bool) = delete

Prevent accidental conversions from bool.

constexpr key_actor(SpecialT)

Constructs a key actor using the special value.

constexpr key_actor(no_key_t)

Constructs a key actor with the no_key special value.

constexpr char describe() const

Returns a single character representing the actor for description purpose.

Returns:

A hex value for the key index, or “N” for no_key, or “S” for the special value.