Skip to content

Enum helpers

Raymond Chen edited this page Mar 19, 2019 · 2 revisions

The enum helpers are include as part of meta_reader.h and they exist in the xlang::meta::reader namespace.

These methods assist in defining and operating on enumerations defined by the Xlang metadata file format.

coded_index_bits, coded_index_bits_v

template <typename T>
struct coded_index_bits : std::integral_constant<uint32_t, N> {};

template <typename T>
inline constexpr uint32_t coded_index_bits_v = coded_index_bits<T>::value;

The xlang::meta::reader::coded_index_bits traits type defines the number of bits consumed to encode a particular value in the metadata file format.

The xlang::meta::reader::coded_index_bits_v constant expression simplifies the extraction of the value from the coded_index_bits.

enum_mask

template <typename T>
constexpr inline T enum_mask(T value, T mask) noexcept;

The xlang::meta::reader::enum_mask function combines a value with a mask via bitwise logical AND, and it returns the result as the same enumerated type.

index_tag, index_tag_v

template <typename Index, typename Row>
struct index_tag;

template <typename Index, typename Row>
inline constexpr auto index_tag_v = index_tag<Index, Row>::value;

The xlang::meta::reader::index_tag traits type defines the value of a particular enumerated type. It is used for template programming purposes. For example, index_tag<HasContent, Field>::value is the value HasContent::Field.

The xlang::meta::reader::index_tag_v constant expression simplifies the extraction of the value from the index_tag.

Clone this wiki locally