1 #ifndef ZSERIO_ENUMS_H_INC
2 #define ZSERIO_ENUMS_H_INC
74 [itemName](std::string_view enumItemName) {
75 return itemName.compare(enumItemName) == 0;
83 const size_t ordinal =
static_cast<size_t>(std::distance(
EnumTraits<T>::names.begin(), foundIt));
103 template <
typename T>
104 std::enable_if_t<std::is_enum_v<T>> validate(T value, std::string_view fieldName)
109 template <
typename T>
110 std::enable_if_t<std::is_enum_v<T>,
BitSize> bitSizeOf(T value,
BitSize bitPosition = 0)
115 template <
typename T>
116 std::enable_if_t<std::is_enum_v<T>> write(BitStreamWriter& writer, T value)
121 template <
typename T>
124 typename EnumTraits<T>::ZserioType rawValue;
125 read(reader, rawValue);
126 value = valueToEnum<T>(rawValue);
129 template <
typename T, std::enable_if_t<std::is_enum_v<T>,
int> = 0>
130 inline void initContext(DeltaContext& deltaContext, T value)
135 template <
typename T>
136 std::enable_if_t<std::is_enum_v<T>,
BitSize> bitSizeOf(DeltaContext& deltaContext, T value,
BitSize = 0)
141 template <
typename T>
142 std::enable_if_t<std::is_enum_v<T>> write(DeltaContext& deltaContext, BitStreamWriter& writer, T value)
147 template <
typename T>
148 std::enable_if_t<std::is_enum_v<T>> read(DeltaContext& deltaContext, BitStreamReader& reader, T& value)
150 typename EnumTraits<T>::ZserioType rawValue;
151 deltaContext.read(reader, rawValue);
152 value = valueToEnum<T>(rawValue);
165 template <
typename T, std::enable_if_t<std::is_enum_v<T>,
int> = 0>
166 CppRuntimeException&
operator<<(CppRuntimeException& exception, T value)
T valueToEnum(typename EnumTraits< T >::ZserioType rawValue)
constexpr EnumTraits< T >::ZserioType enumToValue(T value)
T stringToEnum(std::string_view itemName)
std::string_view enumToString(T value)
CppRuntimeException & operator<<(CppRuntimeException &exception, const BasicBitBuffer< ALLOC > &bitBuffer)
size_t enumToOrdinal(T value)