1 #ifndef ZSERIO_TYPES_H_INC
2 #define ZSERIO_TYPES_H_INC
41 template <
typename VALUE_TYPE>
42 class NumericTypeWrapper
46 using ValueType = VALUE_TYPE;
51 constexpr
explicit NumericTypeWrapper() noexcept :
60 constexpr NumericTypeWrapper(ValueType value) noexcept :
67 constexpr
operator ValueType() const noexcept
80 constexpr NumericTypeWrapper& operator++() noexcept
86 constexpr NumericTypeWrapper operator++(
int) noexcept
88 NumericTypeWrapper old = *
this;
93 constexpr NumericTypeWrapper& operator--() noexcept
99 constexpr NumericTypeWrapper operator--(
int) noexcept
101 NumericTypeWrapper old = *
this;
106 constexpr NumericTypeWrapper& operator+=(ValueType value) noexcept
112 constexpr NumericTypeWrapper& operator-=(ValueType value) noexcept
118 constexpr NumericTypeWrapper& operator*=(ValueType value) noexcept
124 constexpr NumericTypeWrapper& operator/=(ValueType value) noexcept
130 constexpr NumericTypeWrapper& operator%=(ValueType value) noexcept
136 constexpr NumericTypeWrapper& operator&=(ValueType value) noexcept
142 constexpr NumericTypeWrapper& operator|=(ValueType value) noexcept
148 constexpr NumericTypeWrapper& operator^=(ValueType value) noexcept
154 constexpr NumericTypeWrapper& operator<<=(ValueType value) noexcept
160 constexpr NumericTypeWrapper& operator>>=(ValueType value) noexcept
172 class BoolWrapper :
public NumericTypeWrapper<bool>
175 using NumericTypeWrapper<bool>::NumericTypeWrapper;
178 constexpr
bool operator<(
const BoolWrapper& lhs,
const BoolWrapper& rhs)
180 return static_cast<int>(lhs) <
static_cast<int>(rhs);
183 constexpr
bool operator>(
const BoolWrapper& lhs,
const BoolWrapper& rhs)
188 constexpr
bool operator<=(
const BoolWrapper& lhs,
const BoolWrapper& rhs)
193 constexpr
bool operator>=(
const BoolWrapper& lhs,
const BoolWrapper& rhs)
198 template <BitSize BIT_SIZE,
bool IS_SIGNED,
typename =
void>
199 struct fixed_int_value_type;
201 template <BitSize BIT_SIZE>
202 struct fixed_int_value_type<BIT_SIZE, true,
std::enable_if_t<(BIT_SIZE > 0 && BIT_SIZE <= 8)>>
207 template <BitSize BIT_SIZE>
208 struct fixed_int_value_type<BIT_SIZE, true,
std::enable_if_t<(BIT_SIZE > 8 && BIT_SIZE <= 16)>>
210 using type = int16_t;
213 template <BitSize BIT_SIZE>
214 struct fixed_int_value_type<BIT_SIZE, true,
std::enable_if_t<(BIT_SIZE > 16 && BIT_SIZE <= 32)>>
216 using type = int32_t;
219 template <BitSize BIT_SIZE>
220 struct fixed_int_value_type<BIT_SIZE, true,
std::enable_if_t<(BIT_SIZE > 32 && BIT_SIZE <= 64)>>
222 using type = int64_t;
225 template <BitSize BIT_SIZE>
226 struct fixed_int_value_type<BIT_SIZE, false,
std::enable_if_t<(BIT_SIZE > 0 && BIT_SIZE <= 8)>>
228 using type = uint8_t;
231 template <BitSize BIT_SIZE>
232 struct fixed_int_value_type<BIT_SIZE, false,
std::enable_if_t<(BIT_SIZE > 8 && BIT_SIZE <= 16)>>
234 using type = uint16_t;
237 template <BitSize BIT_SIZE>
238 struct fixed_int_value_type<BIT_SIZE, false,
std::enable_if_t<(BIT_SIZE > 16 && BIT_SIZE <= 32)>>
240 using type = uint32_t;
243 template <BitSize BIT_SIZE>
244 struct fixed_int_value_type<BIT_SIZE, false,
std::enable_if_t<(BIT_SIZE > 32 && BIT_SIZE <= 64)>>
246 using type = uint64_t;
249 template <BitSize BIT_SIZE,
bool IS_SIGNED>
250 using fixed_int_value_type_t =
typename fixed_int_value_type<BIT_SIZE, IS_SIGNED>::type;
252 template <BitSize BIT_SIZE,
bool IS_SIGNED>
253 class FixedIntWrapper :
public NumericTypeWrapper<fixed_int_value_type_t<BIT_SIZE, IS_SIGNED>>
256 using ValueType = fixed_int_value_type_t<BIT_SIZE, IS_SIGNED>;
257 using NumericTypeWrapper<ValueType>::NumericTypeWrapper;
259 static_assert(BIT_SIZE > 0,
"BitSize cannot be 0!");
260 static_assert((BIT_SIZE + 7) / 8 <=
sizeof(ValueType),
"BitSize doesn't fit to the VALUE_TYPE!");
263 template <
typename VALUE_TYPE>
264 class DynIntWrapper :
public NumericTypeWrapper<VALUE_TYPE>
267 using NumericTypeWrapper<VALUE_TYPE>::NumericTypeWrapper;
270 enum class VarIntType : uint8_t
279 template <
typename VALUE_TYPE, VarIntType VAR_TYPE>
280 class VarIntWrapper :
public NumericTypeWrapper<VALUE_TYPE>
283 VAR_TYPE != VarIntType::VARSIZE || std::is_unsigned_v<VALUE_TYPE>,
"VARSIZE must be unsigned!");
286 using NumericTypeWrapper<VALUE_TYPE>::NumericTypeWrapper;
289 enum class FloatType : uint8_t
296 template <
typename VALUE_TYPE, FloatType FLOAT_TYPE>
297 class FloatWrapper :
public NumericTypeWrapper<VALUE_TYPE>
300 using NumericTypeWrapper<VALUE_TYPE>::NumericTypeWrapper;
304 template <
typename T>
305 struct needs_range_check
308 template <
typename T>
309 inline constexpr
bool needs_range_check_v = needs_range_check<T>::value;
312 struct needs_range_check<BoolWrapper> : std::false_type
315 template <BitSize BIT_SIZE,
bool IS_SIGNED>
316 struct needs_range_check<FixedIntWrapper<BIT_SIZE, IS_SIGNED>>
318 using ValueType =
typename FixedIntWrapper<BIT_SIZE, IS_SIGNED>::ValueType;
320 static constexpr
bool value =
sizeof(ValueType) * 8 != BIT_SIZE ||
321 (BIT_SIZE != 8 && BIT_SIZE != 16 && BIT_SIZE != 32 && BIT_SIZE != 64);
324 template <
typename VALUE_TYPE>
325 struct needs_range_check<DynIntWrapper<VALUE_TYPE>> : std::true_type
328 template <
typename VALUE_TYPE, VarIntType VAR_TYPE>
329 struct needs_range_check<VarIntWrapper<VALUE_TYPE, VAR_TYPE>>
331 static constexpr
bool value = VAR_TYPE != VarIntType::VAR;
334 template <
typename VALUE_TYPE, FloatType FLOAT_TYPE>
335 struct needs_range_check<FloatWrapper<VALUE_TYPE, FLOAT_TYPE>> : std::false_type
341 template <
typename T>
344 static constexpr
void check(
typename T::ValueType value, std::string_view fieldName =
"")
346 std::string_view fieldNamePrefix = (fieldName.empty()) ?
"" :
" for field ";
347 if constexpr (std::is_signed_v<typename T::ValueType>)
349 if (value < NumericLimits<T>::min() || value > NumericLimits<T>::max())
351 throw OutOfRangeException(
"Value '")
352 << value <<
"' out of range '<" << NumericLimits<T>::min() <<
", "
353 << NumericLimits<T>::max() <<
">'" << fieldNamePrefix << fieldName <<
"!";
358 if (value > NumericLimits<T>::max())
360 throw OutOfRangeException(
"Value '")
361 << value <<
"' out of bounds '" << NumericLimits<T>::max() <<
"'" << fieldNamePrefix
368 template <
typename VALUE_TYPE>
369 struct RangeChecker<DynIntWrapper<VALUE_TYPE>>
371 static constexpr
void check(VALUE_TYPE value,
BitSize numBits, std::string_view fieldName =
"")
373 std::string_view fieldNamePrefix = (fieldName.empty()) ?
"" :
" for field ";
374 if constexpr (std::is_signed_v<VALUE_TYPE>)
376 if (value < NumericLimits<DynIntWrapper<VALUE_TYPE>>::min(
numBits) ||
377 value > NumericLimits<DynIntWrapper<VALUE_TYPE>>::max(
numBits))
379 throw OutOfRangeException(
"Value '")
380 << value <<
"' out of range '<"
381 << NumericLimits<DynIntWrapper<VALUE_TYPE>>::min(
numBits) <<
", "
382 << NumericLimits<DynIntWrapper<VALUE_TYPE>>::max(
numBits) <<
">'" << fieldNamePrefix
388 if (value > NumericLimits<DynIntWrapper<VALUE_TYPE>>::max(
numBits))
390 throw OutOfRangeException(
"Value '")
391 << value <<
"' out of bounds '"
392 << NumericLimits<DynIntWrapper<VALUE_TYPE>>::max(
numBits) <<
"'" << fieldNamePrefix
405 struct NumericLimits<detail::BoolWrapper>
407 static constexpr detail::BoolWrapper min() noexcept
412 static constexpr detail::BoolWrapper max() noexcept
421 template <BitSize BIT_SIZE,
bool IS_SIGNED>
422 struct NumericLimits<detail::FixedIntWrapper<BIT_SIZE, IS_SIGNED>>
424 using ValueType =
typename detail::FixedIntWrapper<BIT_SIZE, IS_SIGNED>::ValueType;
426 static constexpr detail::FixedIntWrapper<BIT_SIZE, IS_SIGNED> min() noexcept
428 if constexpr (!detail::needs_range_check_v<detail::FixedIntWrapper<BIT_SIZE, IS_SIGNED>>)
430 return std::numeric_limits<ValueType>::min();
432 else if constexpr (std::is_signed_v<ValueType>)
434 return static_cast<ValueType
>(-
static_cast<ValueType
>(1ULL << (BIT_SIZE - 1U)));
442 static constexpr detail::FixedIntWrapper<BIT_SIZE, IS_SIGNED> max() noexcept
444 if constexpr (!detail::needs_range_check_v<detail::FixedIntWrapper<BIT_SIZE, IS_SIGNED>>)
446 return std::numeric_limits<ValueType>::max();
448 else if constexpr (std::is_signed_v<ValueType>)
450 return static_cast<ValueType
>((1ULL << (BIT_SIZE - 1U)) - 1U);
454 return static_cast<ValueType
>((1ULL << BIT_SIZE) - 1U);
462 template <
typename VALUE_TYPE, detail::VarIntType VAR_TYPE>
463 struct NumericLimits<detail::VarIntWrapper<VALUE_TYPE, VAR_TYPE>>
465 static constexpr detail::VarIntWrapper<VALUE_TYPE, VAR_TYPE> min() noexcept
467 if constexpr (std::is_signed_v<VALUE_TYPE>)
469 if constexpr (VAR_TYPE == detail::VarIntType::VAR)
471 return std::numeric_limits<VALUE_TYPE>::min();
484 static constexpr detail::VarIntWrapper<VALUE_TYPE, VAR_TYPE> max() noexcept
486 if constexpr (VAR_TYPE == detail::VarIntType::VAR16)
488 return static_cast<VALUE_TYPE
>((UINT64_C(1) << (FIRST_BYTE_BITS + 8)) - 1);
490 else if constexpr (VAR_TYPE == detail::VarIntType::VAR32)
492 return static_cast<VALUE_TYPE
>((UINT64_C(1) << (FIRST_BYTE_BITS + 7 + 7 + 8)) - 1);
494 else if constexpr (VAR_TYPE == detail::VarIntType::VAR64)
496 return static_cast<VALUE_TYPE
>((UINT64_C(1) << (FIRST_BYTE_BITS + 7 + 7 + 7 + 7 + 7 + 7 + 8)) - 1);
498 else if constexpr (VAR_TYPE == detail::VarIntType::VAR)
500 return std::numeric_limits<VALUE_TYPE>::max();
504 return (UINT64_C(1) << (2U + 7U + 7U + 7U + 8U)) - 1;
509 static constexpr uint64_t FIRST_BYTE_BITS = std::is_signed_v<VALUE_TYPE> ? 6 : 7;
515 template <
typename VALUE_TYPE>
516 struct NumericLimits<detail::DynIntWrapper<VALUE_TYPE>>
518 static constexpr detail::DynIntWrapper<VALUE_TYPE> min(
BitSize numBits)
520 if constexpr (std::is_signed_v<VALUE_TYPE>)
524 return minSignedValue(
numBits);
532 static constexpr detail::DynIntWrapper<VALUE_TYPE> max(
BitSize numBits)
536 if constexpr (std::is_signed_v<VALUE_TYPE>)
538 return maxSignedValue(
numBits);
542 return maxUnsignedValue(
numBits);
549 if (numBits < 1 || numBits >
sizeof(VALUE_TYPE) * 8)
551 throw OutOfRangeException(
"Dynamic bit field numBits '")
552 <<
numBits <<
"' out of range '<1, " <<
sizeof(VALUE_TYPE) * 8 <<
">'!";
558 if constexpr (std::is_same_v<VALUE_TYPE, int64_t>)
566 return static_cast<VALUE_TYPE
>(-
static_cast<int64_t
>(1ULL << (
numBits - 1U)));
571 if constexpr (std::is_same_v<VALUE_TYPE, int64_t>)
579 return static_cast<VALUE_TYPE
>((1ULL << (
numBits - 1U)) - 1U);
584 if constexpr (std::is_same_v<VALUE_TYPE, uint64_t>)
592 return static_cast<VALUE_TYPE
>((1ULL <<
numBits) - 1U);
602 struct NumericLimits<detail::FloatWrapper<float, detail::FloatType::FLOAT16>>
604 static constexpr detail::FloatWrapper<float, detail::FloatType::FLOAT16> min() noexcept
606 return 6.103515625e-05F;
609 static constexpr detail::FloatWrapper<float, detail::FloatType::FLOAT16> max() noexcept
619 struct NumericLimits<detail::FloatWrapper<float, detail::FloatType::FLOAT32>>
621 static constexpr detail::FloatWrapper<float, detail::FloatType::FLOAT32> min() noexcept
623 return std::numeric_limits<float>::min();
626 static constexpr detail::FloatWrapper<float, detail::FloatType::FLOAT32> max() noexcept
628 return std::numeric_limits<float>::max();
636 struct NumericLimits<detail::FloatWrapper<double, detail::FloatType::FLOAT64>>
638 static constexpr detail::FloatWrapper<double, detail::FloatType::FLOAT64> min() noexcept
640 return std::numeric_limits<double>::min();
643 static constexpr detail::FloatWrapper<double, detail::FloatType::FLOAT64> max() noexcept
645 return std::numeric_limits<double>::max();
658 template <
typename T, std::enable_if_t<is_numeric_wrapper_v<T>,
int> = 0>
659 constexpr T
fromCheckedValue(
typename T::ValueType value) noexcept(!detail::needs_range_check_v<T>)
661 if constexpr (detail::needs_range_check_v<T>)
663 detail::RangeChecker<T>::check(value);
681 template <
typename T, std::enable_if_t<is_numeric_wrapper_v<T>,
int> = 0>
684 detail::RangeChecker<T>::check(value,
numBits);
698 template <
typename T, std::enable_if_t<is_numeric_wrapper_v<T>,
int> = 0>
699 constexpr
typename T::ValueType
toCheckedValue(T wrapper) noexcept(!detail::needs_range_check_v<T>)
701 if constexpr (detail::needs_range_check_v<T>)
703 detail::RangeChecker<T>::check(wrapper);
721 template <
typename T, std::enable_if_t<is_numeric_wrapper_v<T>,
int> = 0>
724 detail::RangeChecker<T>::check(wrapper,
numBits);
732 using Bool = detail::BoolWrapper;
734 using Int1 = detail::FixedIntWrapper<1, true>;
735 using Int2 = detail::FixedIntWrapper<2, true>;
736 using Int3 = detail::FixedIntWrapper<3, true>;
737 using Int4 = detail::FixedIntWrapper<4, true>;
738 using Int5 = detail::FixedIntWrapper<5, true>;
739 using Int6 = detail::FixedIntWrapper<6, true>;
740 using Int7 = detail::FixedIntWrapper<7, true>;
741 using Int8 = detail::FixedIntWrapper<8, true>;
742 using Int9 = detail::FixedIntWrapper<9, true>;
743 using Int10 = detail::FixedIntWrapper<10, true>;
744 using Int11 = detail::FixedIntWrapper<11, true>;
745 using Int12 = detail::FixedIntWrapper<12, true>;
746 using Int13 = detail::FixedIntWrapper<13, true>;
747 using Int14 = detail::FixedIntWrapper<14, true>;
748 using Int15 = detail::FixedIntWrapper<15, true>;
749 using Int16 = detail::FixedIntWrapper<16, true>;
750 using Int17 = detail::FixedIntWrapper<17, true>;
751 using Int18 = detail::FixedIntWrapper<18, true>;
752 using Int19 = detail::FixedIntWrapper<19, true>;
753 using Int20 = detail::FixedIntWrapper<20, true>;
754 using Int21 = detail::FixedIntWrapper<21, true>;
755 using Int22 = detail::FixedIntWrapper<22, true>;
756 using Int23 = detail::FixedIntWrapper<23, true>;
757 using Int24 = detail::FixedIntWrapper<24, true>;
758 using Int25 = detail::FixedIntWrapper<25, true>;
759 using Int26 = detail::FixedIntWrapper<26, true>;
760 using Int27 = detail::FixedIntWrapper<27, true>;
761 using Int28 = detail::FixedIntWrapper<28, true>;
762 using Int29 = detail::FixedIntWrapper<29, true>;
763 using Int30 = detail::FixedIntWrapper<30, true>;
764 using Int31 = detail::FixedIntWrapper<31, true>;
765 using Int32 = detail::FixedIntWrapper<32, true>;
766 using Int33 = detail::FixedIntWrapper<33, true>;
767 using Int34 = detail::FixedIntWrapper<34, true>;
768 using Int35 = detail::FixedIntWrapper<35, true>;
769 using Int36 = detail::FixedIntWrapper<36, true>;
770 using Int37 = detail::FixedIntWrapper<37, true>;
771 using Int38 = detail::FixedIntWrapper<38, true>;
772 using Int39 = detail::FixedIntWrapper<39, true>;
773 using Int40 = detail::FixedIntWrapper<40, true>;
774 using Int41 = detail::FixedIntWrapper<41, true>;
775 using Int42 = detail::FixedIntWrapper<42, true>;
776 using Int43 = detail::FixedIntWrapper<43, true>;
777 using Int44 = detail::FixedIntWrapper<44, true>;
778 using Int45 = detail::FixedIntWrapper<45, true>;
779 using Int46 = detail::FixedIntWrapper<46, true>;
780 using Int47 = detail::FixedIntWrapper<47, true>;
781 using Int48 = detail::FixedIntWrapper<48, true>;
782 using Int49 = detail::FixedIntWrapper<49, true>;
783 using Int50 = detail::FixedIntWrapper<50, true>;
784 using Int51 = detail::FixedIntWrapper<51, true>;
785 using Int52 = detail::FixedIntWrapper<52, true>;
786 using Int53 = detail::FixedIntWrapper<53, true>;
787 using Int54 = detail::FixedIntWrapper<54, true>;
788 using Int55 = detail::FixedIntWrapper<55, true>;
789 using Int56 = detail::FixedIntWrapper<56, true>;
790 using Int57 = detail::FixedIntWrapper<57, true>;
791 using Int58 = detail::FixedIntWrapper<58, true>;
792 using Int59 = detail::FixedIntWrapper<59, true>;
793 using Int60 = detail::FixedIntWrapper<60, true>;
794 using Int61 = detail::FixedIntWrapper<61, true>;
795 using Int62 = detail::FixedIntWrapper<62, true>;
796 using Int63 = detail::FixedIntWrapper<63, true>;
797 using Int64 = detail::FixedIntWrapper<64, true>;
799 using UInt1 = detail::FixedIntWrapper<1, false>;
800 using UInt2 = detail::FixedIntWrapper<2, false>;
801 using UInt3 = detail::FixedIntWrapper<3, false>;
802 using UInt4 = detail::FixedIntWrapper<4, false>;
803 using UInt5 = detail::FixedIntWrapper<5, false>;
804 using UInt6 = detail::FixedIntWrapper<6, false>;
805 using UInt7 = detail::FixedIntWrapper<7, false>;
806 using UInt8 = detail::FixedIntWrapper<8, false>;
807 using UInt9 = detail::FixedIntWrapper<9, false>;
808 using UInt10 = detail::FixedIntWrapper<10, false>;
809 using UInt11 = detail::FixedIntWrapper<11, false>;
810 using UInt12 = detail::FixedIntWrapper<12, false>;
811 using UInt13 = detail::FixedIntWrapper<13, false>;
812 using UInt14 = detail::FixedIntWrapper<14, false>;
813 using UInt15 = detail::FixedIntWrapper<15, false>;
814 using UInt16 = detail::FixedIntWrapper<16, false>;
815 using UInt17 = detail::FixedIntWrapper<17, false>;
816 using UInt18 = detail::FixedIntWrapper<18, false>;
817 using UInt19 = detail::FixedIntWrapper<19, false>;
818 using UInt20 = detail::FixedIntWrapper<20, false>;
819 using UInt21 = detail::FixedIntWrapper<21, false>;
820 using UInt22 = detail::FixedIntWrapper<22, false>;
821 using UInt23 = detail::FixedIntWrapper<23, false>;
822 using UInt24 = detail::FixedIntWrapper<24, false>;
823 using UInt25 = detail::FixedIntWrapper<25, false>;
824 using UInt26 = detail::FixedIntWrapper<26, false>;
825 using UInt27 = detail::FixedIntWrapper<27, false>;
826 using UInt28 = detail::FixedIntWrapper<28, false>;
827 using UInt29 = detail::FixedIntWrapper<29, false>;
828 using UInt30 = detail::FixedIntWrapper<30, false>;
829 using UInt31 = detail::FixedIntWrapper<31, false>;
830 using UInt32 = detail::FixedIntWrapper<32, false>;
831 using UInt33 = detail::FixedIntWrapper<33, false>;
832 using UInt34 = detail::FixedIntWrapper<34, false>;
833 using UInt35 = detail::FixedIntWrapper<35, false>;
834 using UInt36 = detail::FixedIntWrapper<36, false>;
835 using UInt37 = detail::FixedIntWrapper<37, false>;
836 using UInt38 = detail::FixedIntWrapper<38, false>;
837 using UInt39 = detail::FixedIntWrapper<39, false>;
838 using UInt40 = detail::FixedIntWrapper<40, false>;
839 using UInt41 = detail::FixedIntWrapper<41, false>;
840 using UInt42 = detail::FixedIntWrapper<42, false>;
841 using UInt43 = detail::FixedIntWrapper<43, false>;
842 using UInt44 = detail::FixedIntWrapper<44, false>;
843 using UInt45 = detail::FixedIntWrapper<45, false>;
844 using UInt46 = detail::FixedIntWrapper<46, false>;
845 using UInt47 = detail::FixedIntWrapper<47, false>;
846 using UInt48 = detail::FixedIntWrapper<48, false>;
847 using UInt49 = detail::FixedIntWrapper<49, false>;
848 using UInt50 = detail::FixedIntWrapper<50, false>;
849 using UInt51 = detail::FixedIntWrapper<51, false>;
850 using UInt52 = detail::FixedIntWrapper<52, false>;
851 using UInt53 = detail::FixedIntWrapper<53, false>;
852 using UInt54 = detail::FixedIntWrapper<54, false>;
853 using UInt55 = detail::FixedIntWrapper<55, false>;
854 using UInt56 = detail::FixedIntWrapper<56, false>;
855 using UInt57 = detail::FixedIntWrapper<57, false>;
856 using UInt58 = detail::FixedIntWrapper<58, false>;
857 using UInt59 = detail::FixedIntWrapper<59, false>;
858 using UInt60 = detail::FixedIntWrapper<60, false>;
859 using UInt61 = detail::FixedIntWrapper<61, false>;
860 using UInt62 = detail::FixedIntWrapper<62, false>;
861 using UInt63 = detail::FixedIntWrapper<63, false>;
862 using UInt64 = detail::FixedIntWrapper<64, false>;
864 template <
size_t BIT_SIZE>
865 using Int = detail::FixedIntWrapper<BIT_SIZE, true>;
867 template <
size_t BIT_SIZE>
868 using UInt = detail::FixedIntWrapper<BIT_SIZE, false>;
870 using DynInt8 = detail::DynIntWrapper<int8_t>;
880 using VarInt16 = detail::VarIntWrapper<int16_t, detail::VarIntType::VAR16>;
881 using VarInt32 = detail::VarIntWrapper<int32_t, detail::VarIntType::VAR32>;
882 using VarInt64 = detail::VarIntWrapper<int64_t, detail::VarIntType::VAR64>;
883 using VarInt = detail::VarIntWrapper<int64_t, detail::VarIntType::VAR>;
885 using VarUInt16 = detail::VarIntWrapper<uint16_t, detail::VarIntType::VAR16>;
886 using VarUInt32 = detail::VarIntWrapper<uint32_t, detail::VarIntType::VAR32>;
887 using VarUInt64 = detail::VarIntWrapper<uint64_t, detail::VarIntType::VAR64>;
888 using VarUInt = detail::VarIntWrapper<uint64_t, detail::VarIntType::VAR>;
890 using VarSize = detail::VarIntWrapper<uint32_t, detail::VarIntType::VARSIZE>;
892 using Float16 = detail::FloatWrapper<float, detail::FloatType::FLOAT16>;
893 using Float32 = detail::FloatWrapper<float, detail::FloatType::FLOAT32>;
894 using Float64 = detail::FloatWrapper<double, detail::FloatType::FLOAT64>;
906 template <
typename VALUE_TYPE>
909 return exception << static_cast<VALUE_TYPE>(value);
915 template <
typename T, std::enable_if_t<is_numeric_wrapper_v<T>,
int> = 0>
916 void validate(T wrapper, std::string_view fieldName) noexcept(!detail::needs_range_check_v<T>)
918 if constexpr (detail::needs_range_check_v<T>)
920 detail::RangeChecker<T>::check(wrapper, fieldName);
924 template <
typename T, std::enable_if_t<is_numeric_wrapper_v<T>,
int> = 0>
925 void validate(T wrapper,
BitSize numBits, std::string_view fieldName)
927 detail::RangeChecker<T>::check(wrapper,
numBits, fieldName);
935 template <BitSize BIT_SIZE,
bool IS_SIGNED>
936 BitSize bitSizeOf(FixedIntWrapper<BIT_SIZE, IS_SIGNED>,
BitSize = 0)
938 static_assert(BIT_SIZE != 0,
"Variable dynamic bit fields not allowed here!");
975 inline BitSize initializeOffsets(BoolWrapper value,
BitSize bitPosition)
977 return bitSizeOf(value, bitPosition);
980 template <BitSize BIT_SIZE,
bool IS_SIGNED>
981 BitSize initializeOffsets(FixedIntWrapper<BIT_SIZE, IS_SIGNED> value,
BitSize bitPosition)
983 return bitSizeOf(value, bitPosition);
1006 return bitSizeOf(value, bitPosition);
1011 return bitSizeOf(value, bitPosition);
1016 return bitSizeOf(value, bitPosition);
uint8_t numBits(uint64_t numValues)
detail::FixedIntWrapper< 39, false > UInt39
detail::FixedIntWrapper< 14, true > Int14
detail::FixedIntWrapper< 6, false > UInt6
detail::DynIntWrapper< uint16_t > DynUInt16
detail::FixedIntWrapper< 19, true > Int19
detail::FixedIntWrapper< 44, false > UInt44
detail::FixedIntWrapper< 31, false > UInt31
detail::FixedIntWrapper< 23, false > UInt23
detail::FixedIntWrapper< 28, false > UInt28
bool operator>(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
detail::FixedIntWrapper< 45, false > UInt45
detail::FixedIntWrapper< 33, false > UInt33
detail::FixedIntWrapper< 60, true > Int60
detail::FixedIntWrapper< 2, false > UInt2
detail::FixedIntWrapper< 35, true > Int35
constexpr T fromCheckedValue(typename T::ValueType value) noexcept(!detail::needs_range_check_v< T >)
detail::FixedIntWrapper< 64, false > UInt64
detail::FixedIntWrapper< 48, false > UInt48
detail::DynIntWrapper< uint32_t > DynUInt32
detail::FixedIntWrapper< 16, true > Int16
detail::FixedIntWrapper< 61, false > UInt61
detail::FixedIntWrapper< 4, true > Int4
detail::FixedIntWrapper< 59, false > UInt59
detail::FixedIntWrapper< 49, true > Int49
detail::FixedIntWrapper< 9, true > Int9
detail::FixedIntWrapper< 2, true > Int2
detail::FixedIntWrapper< 37, true > Int37
detail::FixedIntWrapper< 10, true > Int10
detail::FixedIntWrapper< BIT_SIZE, true > Int
detail::FixedIntWrapper< 18, true > Int18
detail::FixedIntWrapper< 15, false > UInt15
detail::FixedIntWrapper< 56, false > UInt56
detail::FixedIntWrapper< 20, true > Int20
detail::VarIntWrapper< uint64_t, detail::VarIntType::VAR > VarUInt
detail::FixedIntWrapper< 7, true > Int7
detail::FixedIntWrapper< 16, false > UInt16
detail::FixedIntWrapper< 56, true > Int56
detail::FixedIntWrapper< 11, false > UInt11
detail::FixedIntWrapper< 8, false > UInt8
detail::FixedIntWrapper< 53, true > Int53
detail::FixedIntWrapper< 63, true > Int63
detail::FixedIntWrapper< 26, true > Int26
detail::FixedIntWrapper< 14, false > UInt14
detail::FixedIntWrapper< 25, true > Int25
detail::FixedIntWrapper< 42, false > UInt42
detail::FixedIntWrapper< 32, true > Int32
detail::FixedIntWrapper< 5, false > UInt5
detail::FixedIntWrapper< 17, false > UInt17
detail::FixedIntWrapper< 6, true > Int6
detail::FloatWrapper< float, detail::FloatType::FLOAT16 > Float16
detail::FixedIntWrapper< 20, false > UInt20
detail::FloatWrapper< float, detail::FloatType::FLOAT32 > Float32
detail::FixedIntWrapper< 49, false > UInt49
detail::FixedIntWrapper< 51, true > Int51
detail::FixedIntWrapper< 28, true > Int28
detail::VarIntWrapper< int32_t, detail::VarIntType::VAR32 > VarInt32
detail::FixedIntWrapper< 40, false > UInt40
detail::FixedIntWrapper< 40, true > Int40
detail::FixedIntWrapper< 30, true > Int30
detail::FixedIntWrapper< 60, false > UInt60
detail::FixedIntWrapper< 42, true > Int42
detail::FixedIntWrapper< 7, false > UInt7
detail::DynIntWrapper< int8_t > DynInt8
detail::FixedIntWrapper< 3, true > Int3
detail::FixedIntWrapper< 38, false > UInt38
detail::DynIntWrapper< uint64_t > DynUInt64
detail::FixedIntWrapper< 43, false > UInt43
detail::VarIntWrapper< uint16_t, detail::VarIntType::VAR16 > VarUInt16
bool operator<(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
detail::FixedIntWrapper< 36, false > UInt36
detail::FixedIntWrapper< 58, true > Int58
detail::FixedIntWrapper< 22, true > Int22
detail::FixedIntWrapper< 25, false > UInt25
detail::FixedIntWrapper< 29, false > UInt29
detail::FixedIntWrapper< 1, false > UInt1
detail::DynIntWrapper< int64_t > DynInt64
detail::FixedIntWrapper< 55, false > UInt55
detail::FixedIntWrapper< 45, true > Int45
detail::FixedIntWrapper< 11, true > Int11
detail::FixedIntWrapper< 39, true > Int39
detail::FixedIntWrapper< 58, false > UInt58
detail::FixedIntWrapper< 43, true > Int43
detail::FixedIntWrapper< 24, true > Int24
detail::FixedIntWrapper< 3, false > UInt3
detail::VarIntWrapper< uint64_t, detail::VarIntType::VAR64 > VarUInt64
detail::FixedIntWrapper< 18, false > UInt18
detail::FixedIntWrapper< 22, false > UInt22
detail::FixedIntWrapper< 4, false > UInt4
detail::FixedIntWrapper< 34, true > Int34
detail::FixedIntWrapper< 54, false > UInt54
detail::FixedIntWrapper< 32, false > UInt32
detail::FixedIntWrapper< 41, true > Int41
detail::FixedIntWrapper< 37, false > UInt37
detail::FixedIntWrapper< 27, true > Int27
detail::FixedIntWrapper< 13, true > Int13
detail::FixedIntWrapper< 57, true > Int57
detail::FixedIntWrapper< 53, false > UInt53
constexpr T::ValueType toCheckedValue(T wrapper) noexcept(!detail::needs_range_check_v< T >)
CppRuntimeException & operator<<(CppRuntimeException &exception, const BasicBitBuffer< ALLOC > &bitBuffer)
detail::FixedIntWrapper< 62, false > UInt62
detail::FixedIntWrapper< 15, true > Int15
detail::FixedIntWrapper< 46, false > UInt46
detail::FixedIntWrapper< 12, true > Int12
detail::FixedIntWrapper< 10, false > UInt10
detail::FixedIntWrapper< 52, false > UInt52
detail::FixedIntWrapper< 8, true > Int8
detail::FixedIntWrapper< 64, true > Int64
detail::FixedIntWrapper< 48, true > Int48
detail::FixedIntWrapper< 41, false > UInt41
detail::FixedIntWrapper< 30, false > UInt30
detail::FixedIntWrapper< 26, false > UInt26
detail::FixedIntWrapper< 36, true > Int36
detail::FixedIntWrapper< 19, false > UInt19
detail::FixedIntWrapper< 35, false > UInt35
detail::FixedIntWrapper< BIT_SIZE, false > UInt
detail::FixedIntWrapper< 50, true > Int50
detail::VarIntWrapper< int16_t, detail::VarIntType::VAR16 > VarInt16
detail::FixedIntWrapper< 13, false > UInt13
bool operator<=(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
detail::FixedIntWrapper< 46, true > Int46
detail::FixedIntWrapper< 29, true > Int29
detail::FixedIntWrapper< 55, true > Int55
detail::FixedIntWrapper< 33, true > Int33
detail::FixedIntWrapper< 61, true > Int61
detail::FixedIntWrapper< 57, false > UInt57
detail::DynIntWrapper< int16_t > DynInt16
detail::FloatWrapper< double, detail::FloatType::FLOAT64 > Float64
detail::FixedIntWrapper< 38, true > Int38
detail::FixedIntWrapper< 17, true > Int17
detail::FixedIntWrapper< 24, false > UInt24
detail::FixedIntWrapper< 47, true > Int47
detail::VarIntWrapper< uint32_t, detail::VarIntType::VAR32 > VarUInt32
detail::FixedIntWrapper< 21, true > Int21
detail::FixedIntWrapper< 50, false > UInt50
detail::FixedIntWrapper< 62, true > Int62
detail::FixedIntWrapper< 34, false > UInt34
detail::FixedIntWrapper< 54, true > Int54
detail::DynIntWrapper< int32_t > DynInt32
detail::FixedIntWrapper< 23, true > Int23
bool operator>=(const BasicBitBufferView< ALLOC > &lhs, const BasicBitBufferView< ALLOC > &rhs)
detail::FixedIntWrapper< 21, false > UInt21
detail::FixedIntWrapper< 44, true > Int44
detail::FixedIntWrapper< 1, true > Int1
detail::FixedIntWrapper< 51, false > UInt51
detail::DynIntWrapper< uint8_t > DynUInt8
detail::FixedIntWrapper< 12, false > UInt12
detail::FixedIntWrapper< 9, false > UInt9
detail::FixedIntWrapper< 47, false > UInt47
detail::FixedIntWrapper< 59, true > Int59
detail::VarIntWrapper< int64_t, detail::VarIntType::VAR > VarInt
detail::FixedIntWrapper< 63, false > UInt63
detail::VarIntWrapper< int64_t, detail::VarIntType::VAR64 > VarInt64
detail::VarIntWrapper< uint32_t, detail::VarIntType::VARSIZE > VarSize
detail::FixedIntWrapper< 31, true > Int31
detail::FixedIntWrapper< 27, false > UInt27
detail::FixedIntWrapper< 52, true > Int52
detail::FixedIntWrapper< 5, true > Int5