20#include <initializer_list>
26# define SBEPP_WARNINGS_OFF() \
27 _Pragma("clang diagnostic push"); \
28 _Pragma("clang diagnostic ignored \"-Wbraced-scalar-init\"")
29# define SBEPP_WARNINGS_ON() _Pragma("clang diagnostic pop")
31# define SBEPP_WARNINGS_OFF()
32# define SBEPP_WARNINGS_ON()
38# define SBEPP_CPLUSPLUS _MSVC_LANG
40# define SBEPP_CPLUSPLUS __cplusplus
44# if __has_include(<version>)
58#if !defined(SBEPP_HAS_THREE_WAY_COMPARISON) \
59 && defined(__cpp_impl_three_way_comparison) \
60 && defined(__cpp_lib_three_way_comparison)
61# if (__cpp_impl_three_way_comparison >= 201907L) \
62 && (__cpp_lib_three_way_comparison >= 201907L)
63# define SBEPP_HAS_THREE_WAY_COMPARISON 1
67#ifndef SBEPP_HAS_THREE_WAY_COMPARISON
68# define SBEPP_HAS_THREE_WAY_COMPARISON 0
72#if !defined(SBEPP_HAS_CONCEPTS) && defined(__cpp_concepts)
73# if (__cpp_concepts >= 201907L)
74# define SBEPP_HAS_CONCEPTS 1
77#ifndef SBEPP_HAS_CONCEPTS
78# define SBEPP_HAS_CONCEPTS 0
82#if !defined(SBEPP_HAS_INLINE_VARS) && defined(__cpp_inline_variables)
83# if (__cpp_inline_variables >= 201606L)
84# define SBEPP_HAS_INLINE_VARS 1
85# define SBEPP_CPP17_INLINE_VAR inline
88#ifndef SBEPP_CPP17_INLINE_VAR
89# define SBEPP_HAS_INLINE_VARS 0
90# define SBEPP_CPP17_INLINE_VAR
94#if !defined(SBEPP_HAS_ENDIAN) && defined(__cpp_lib_endian)
95# if (__cpp_lib_endian >= 201907L)
96# define SBEPP_HAS_ENDIAN 1
100#ifndef SBEPP_HAS_ENDIAN
101# define SBEPP_HAS_ENDIAN 0
105#if !defined(SBEPP_HAS_BITCAST) && defined(__cpp_lib_bit_cast)
106# if (__cpp_lib_bit_cast >= 201806L)
107# define SBEPP_HAS_BITCAST 1
111#ifndef SBEPP_HAS_BITCAST
112# define SBEPP_HAS_BITCAST 0
116#if !defined(SBEPP_HAS_BYTESWAP) && defined(__cpp_lib_byteswap)
117# if (__cpp_lib_byteswap >= 202110L)
118# define SBEPP_HAS_BYTESWAP 1
122#ifndef SBEPP_HAS_BYTESWAP
123# define SBEPP_HAS_BYTESWAP 0
127#if !defined(SBEPP_HAS_CONSTEXPR_ALGORITHMS) \
128 && defined(__cpp_lib_constexpr_algorithms)
129# if (__cpp_lib_constexpr_algorithms >= 201806L)
130# define SBEPP_HAS_CONSTEXPR_ALGORITHMS 1
133#ifndef SBEPP_HAS_CONSTEXPR_ALGORITHMS
134# define SBEPP_HAS_CONSTEXPR_ALGORITHMS 0
137#ifdef __has_cpp_attribute
139# if __has_cpp_attribute(nodiscard) \
140 && !(defined(__clang__) && (SBEPP_CPLUSPLUS < 201703L))
141# define SBEPP_CPP17_NODISCARD [[nodiscard]]
144# if __has_cpp_attribute(deprecated) \
145 && !(defined(__clang__) && (SBEPP_CPLUSPLUS < 201402L))
146# define SBEPP_DEPRECATED [[deprecated]]
150#ifndef SBEPP_CPP17_NODISCARD
151# define SBEPP_CPP17_NODISCARD
154#ifndef SBEPP_DEPRECATED
155# if defined(__GNUC__) || defined(__clang__)
156# define SBEPP_DEPRECATED __attribute__((deprecated))
157# elif defined(_MSC_VER)
158# define SBEPP_DEPRECATED __declspec(deprecated)
160# define SBEPP_DEPRECATED
165#if SBEPP_HAS_BITCAST && SBEPP_HAS_CONSTEXPR_ALGORITHMS
166# define SBEPP_HAS_CONSTEXPR_ACCESSORS 1
168# define SBEPP_HAS_CONSTEXPR_ACCESSORS 0
171#if SBEPP_HAS_CONSTEXPR_ACCESSORS
173# define SBEPP_CPP20_CONSTEXPR constexpr
175# define SBEPP_CPP20_CONSTEXPR
178#ifdef __cpp_constexpr
179# if (__cpp_constexpr >= 201304L)
180# define SBEPP_CPP14_CONSTEXPR constexpr
183# if (SBEPP_CPLUSPLUS >= 201402L)
184# define SBEPP_CPP14_CONSTEXPR constexpr
187#ifndef SBEPP_CPP14_CONSTEXPR
188# define SBEPP_CPP14_CONSTEXPR
192#if !defined(SBEPP_HAS_RANGES) && defined(__cpp_lib_ranges)
193# if (__cpp_lib_ranges >= 201911L)
194# define SBEPP_HAS_RANGES 1
198#ifndef SBEPP_HAS_RANGES
199# define SBEPP_HAS_RANGES 0
204#if !defined(SBEPP_HAS_IS_CONSTANT_EVALUATED) \
205 && defined(__cpp_lib_is_constant_evaluated) \
206 && (__cpp_lib_is_constant_evaluated >= 201811L)
207# define SBEPP_HAS_IS_CONSTANT_EVALUATED 1
209#ifndef SBEPP_HAS_IS_CONSTANT_EVALUATED
210# define SBEPP_HAS_IS_CONSTANT_EVALUATED 0
217# define SBEPP_DISABLE_ASSERTS
223# define SBEPP_ASSERT_HANDLER
229# define SBEPP_ENABLE_ASSERTS_WITH_HANDLER
244 char const* expr,
char const* function,
char const* file,
long line);
248#ifdef SBEPP_DISABLE_ASSERTS
249# define SBEPP_SIZE_CHECKS_ENABLED 0
250# define SBEPP_ASSERT(expr) ((void)0)
251#elif defined(SBEPP_ASSERT_HANDLER) \
252 || defined(SBEPP_ENABLE_ASSERTS_WITH_HANDLER)
253# if !defined(NDEBUG) || defined(SBEPP_ENABLE_ASSERTS_WITH_HANDLER)
258 char const* expr,
char const* function,
char const* file,
long line);
261# define SBEPP_SIZE_CHECKS_ENABLED 1
262# define SBEPP_ASSERT(expr) \
263 (static_cast<bool>(expr) \
265 : ::sbepp::assertion_failed( \
266 #expr, __func__, __FILE__, __LINE__))
268# define SBEPP_SIZE_CHECKS_ENABLED 0
269# define SBEPP_ASSERT(expr) ((void)0)
274# define SBEPP_SIZE_CHECKS_ENABLED 0
276# define SBEPP_SIZE_CHECKS_ENABLED 1
278# define SBEPP_ASSERT(expr) assert(expr)
281#define SBEPP_SIZE_CHECK(begin, end, offset, size) \
284 && (((offset) + (size)) <= static_cast<std::size_t>((end) - (begin))))
327# define SBEPP_BYTE_ORDER
345#elif SBEPP_HAS_ENDIAN
346using endian = std::endian;
351# if defined(_WIN32) || defined(WIN32)
355# elif defined(__BYTE_ORDER__)
356 little = __ORDER_LITTLE_ENDIAN__,
357 big = __ORDER_BIG_ENDIAN__,
359# elif defined(SBEPP_BYTE_ORDER)
364# error "Byte order cannot be detected.\
365 Define SBEPP_BYTE_ORDER to 'little' or 'big'"
372 "Mixed-endian is not supported");
376template<
typename... Ts>
386template<
bool B,
typename T =
void>
387using enable_if_t =
typename std::enable_if<B, T>::type;
390using remove_cv_t =
typename std::remove_cv<T>::type;
393using remove_reference_t =
typename std::remove_reference<T>::type;
395template<
typename ByteFrom,
typename ByteTo>
396using enable_if_convertible_t =
397 enable_if_t<std::is_convertible<ByteFrom*, ByteTo*>::value>;
399template<
typename Byte,
typename T =
void>
400using enable_if_writable_t = enable_if_t<!std::is_const<Byte>::value, T>;
405#if !SBEPP_HAS_BYTESWAP
408# ifndef __has_builtin
409# define __has_builtin(x) 0
412# if defined(_MSC_VER) && (!defined(__clang__) || defined(__c2__))
416inline std::uint64_t byteswap(std::uint64_t v)
noexcept
418 return _byteswap_uint64(v);
421inline std::uint32_t byteswap(std::uint32_t v)
noexcept
423 return _byteswap_ulong(v);
426inline std::uint16_t byteswap(std::uint16_t v)
noexcept
428 return _byteswap_ushort(v);
432 defined(__clang__) && __has_builtin(__builtin_bswap32) \
433 && __has_builtin(__builtin_bswap64)) \
434 || (defined(__GNUC__) \
435 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
437# if (defined(__clang__) && __has_builtin(__builtin_bswap16)) \
438 || (defined(__GNUC__) \
439 && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
441inline std::uint16_t byteswap(std::uint16_t v)
noexcept
443 return __builtin_bswap16(v);
448inline std::uint16_t byteswap(std::uint16_t v)
noexcept
450 return __builtin_bswap32(v) << 16;
455inline std::uint64_t byteswap(std::uint64_t v)
noexcept
457 return __builtin_bswap64(v);
460inline std::uint32_t byteswap(std::uint32_t v)
noexcept
462 return __builtin_bswap32(v);
467constexpr std::uint64_t byteswap(std::uint64_t v)
noexcept
469 return ((v & UINT64_C(0x00000000000000FF)) << 56)
470 | ((v & UINT64_C(0x000000000000FF00)) << 40)
471 | ((v & UINT64_C(0x0000000000FF0000)) << 24)
472 | ((v & UINT64_C(0x00000000FF000000)) << 8)
473 | ((v & UINT64_C(0x000000FF00000000)) >> 8)
474 | ((v & UINT64_C(0x0000FF0000000000)) >> 24)
475 | ((v & UINT64_C(0x00FF000000000000)) >> 40)
476 | ((v & UINT64_C(0xFF00000000000000)) >> 56);
479constexpr std::uint32_t byteswap(std::uint32_t v)
noexcept
481 return ((v & UINT32_C(0x000000FF)) << 24)
482 | ((v & UINT32_C(0x0000FF00)) << 8)
483 | ((v & UINT32_C(0x00FF0000)) >> 8)
484 | ((v & UINT32_C(0xFF000000)) >> 24);
487constexpr std::uint16_t byteswap(std::uint16_t v)
noexcept
489 return ((v & UINT16_C(0x00FF)) << 8) | ((v & UINT16_C(0xFF00)) >> 8);
496struct fp_underlying_type;
499using fp_underlying_type_t =
typename fp_underlying_type<T>::type;
502struct fp_underlying_type<float>
504 using type = std::uint32_t;
508struct fp_underlying_type<double>
510 using type = std::uint64_t;
517constexpr enable_if_t<
sizeof(T) == 1, T> byteswap(T value)
noexcept
524 enable_if_t<!std::is_floating_point<T>::value && (
sizeof(T) != 1), T>
525 byteswap(T value)
noexcept
527#if SBEPP_HAS_BYTESWAP
530 return static_cast<T
>(std::byteswap(
531 static_cast<typename std::make_unsigned<T>::type
>(value)));
533 return static_cast<T
>(
534 byteswap(
static_cast<typename std::make_unsigned<T>::type
>(value)));
539enable_if_t<std::is_floating_point<T>::value, T> byteswap(T value)
noexcept
541 fp_underlying_type_t<T> underlying{};
542 std::memcpy(&underlying, &value,
sizeof(underlying));
543 underlying = byteswap(underlying);
545 std::memcpy(&value, &underlying,
sizeof(underlying));
550template<
typename T, endian E,
typename Byte>
551SBEPP_CPP20_CONSTEXPR T get_primitive(
const Byte* ptr)
554 std::array<Byte,
sizeof(T)> arr;
557 std::copy(ptr, ptr +
sizeof(T), std::begin(arr));
561 std::reverse_copy(ptr, ptr +
sizeof(T), std::begin(arr));
563 return std::bit_cast<T>(arr);
568 std::memcpy(&res, ptr,
sizeof(T));
575 return byteswap(res);
580template<endian E,
typename T,
typename Byte>
581SBEPP_CPP20_CONSTEXPR
void set_primitive(Byte* ptr, T value)
584 auto arr = std::bit_cast<std::array<Byte,
sizeof(T)>>(value);
587 std::copy(std::begin(arr), std::end(arr), ptr);
591 std::reverse_copy(std::begin(arr), std::end(arr), ptr);
598 value = byteswap(value);
600 std::memcpy(ptr, &value,
sizeof(T));
604struct fill_message_header_tag
606 explicit fill_message_header_tag() =
default;
609struct fill_group_header_tag
611 explicit fill_group_header_tag() =
default;
616 explicit size_bytes_tag() =
default;
621 explicit addressof_tag() =
default;
626 explicit end_ptr_tag() =
default;
631 explicit get_header_tag() =
default;
634struct get_block_length_tag
636 explicit get_block_length_tag() =
default;
641 explicit get_bit_tag() =
default;
646 explicit set_bit_tag() =
default;
651 explicit get_level_tag() =
default;
656 explicit visit_tag() =
default;
659struct visit_children_tag
661 explicit visit_children_tag() =
default;
664struct enum_to_str_tag
666 explicit enum_to_str_tag() =
default;
671 explicit visit_set_tag() =
default;
674struct access_by_tag_tag
676 explicit access_by_tag_tag() =
default;
679template<
typename T,
typename U, endian E,
typename View>
680SBEPP_CPP20_CONSTEXPR T
681 get_value(
const View view,
const std::size_t offset)
noexcept
684 view(addressof_tag{}), view(end_ptr_tag{}), offset,
sizeof(U));
685 return T{get_primitive<U, E>(view(addressof_tag{}) + offset)};
688template<endian E,
typename T,
typename View>
689SBEPP_CPP20_CONSTEXPR
void
690 set_value(
const View view,
const std::size_t offset,
const T value)
noexcept
693 view(addressof_tag{}), view(end_ptr_tag{}), offset,
sizeof(T));
694 set_primitive<E>(view(addressof_tag{}) + offset, value);
697template<
typename Res,
typename View>
698SBEPP_CPP20_CONSTEXPR Res
699 get_static_field_view(
const View view,
const std::size_t offset)
noexcept
701 SBEPP_SIZE_CHECK(view(addressof_tag{}), view(end_ptr_tag{}), offset, 0);
702 return {view(addressof_tag{}) + offset, view(end_ptr_tag{})};
705template<
typename Group,
typename View>
706SBEPP_CPP20_CONSTEXPR Group
707 get_first_dynamic_field_view(
const View view)
noexcept
710 view(get_level_tag{}) + view(get_block_length_tag{}),
711 view(end_ptr_tag{})};
714template<
typename Group,
typename View,
typename Prev>
715SBEPP_CPP20_CONSTEXPR Group
716 get_dynamic_field_view(
const View view,
const Prev prev)
noexcept
719 prev(addressof_tag{}) + prev(size_bytes_tag{}), view(end_ptr_tag{})};
724template<
typename Byte>
728 static_assert(
sizeof(Byte) == 1,
"Byte must represent a single byte");
730 template<
typename Byte2>
731 friend class byte_range;
737 SBEPP_CPP14_CONSTEXPR
byte_range(Byte* begin, Byte* end) noexcept
739#if SBEPP_SIZE_CHECKS_ENABLED
748 constexpr byte_range(Byte* ptr,
const std::size_t size) noexcept
749 : byte_range{ptr, ptr + size}
754 template<
typename Byte2,
typename = enable_if_convertible_t<Byte2, Byte>>
756 constexpr byte_range(
const byte_range<Byte2>& other) noexcept
758#if SBEPP_SIZE_CHECKS_ENABLED
765 constexpr Byte* operator()(addressof_tag)
const noexcept
770 constexpr Byte* operator()(end_ptr_tag)
const noexcept
772#if SBEPP_SIZE_CHECKS_ENABLED
781#if SBEPP_SIZE_CHECKS_ENABLED
793template<
typename Byte>
808 using result_type = T;
822 typename = detail::enable_if_convertible_t<Byte2, Byte>>
824 constexpr cursor(cursor<Byte2> other) noexcept : ptr{other.ptr}
838 typename = detail::enable_if_convertible_t<Byte2, Byte>>
839 SBEPP_CPP14_CONSTEXPR cursor&
operator=(cursor<Byte2> other)
noexcept
851 SBEPP_CPP14_CONSTEXPR Byte*&
pointer() noexcept
861 SBEPP_CPP14_CONSTEXPR Byte*
pointer() const noexcept
866 template<
typename T,
typename U, endian E,
typename View>
867 SBEPP_CPP20_CONSTEXPR T get_value(
869 const std::size_t offset,
870 const std::size_t absolute_offset)
noexcept
873 ((view(detail::addressof_tag{}) + absolute_offset)
875 &&
"Wrong cursor value");
876 SBEPP_SIZE_CHECK(ptr, view(detail::end_ptr_tag{}), offset,
sizeof(U));
877 T res{detail::get_primitive<U, E>(ptr + offset)};
878 ptr += offset +
sizeof(U);
882 template<endian E,
typename T,
typename View>
883 SBEPP_CPP20_CONSTEXPR
void set_value(
885 const std::size_t offset,
886 const std::size_t absolute_offset,
887 const T value)
noexcept
890 ((view(detail::addressof_tag{}) + absolute_offset)
892 &&
"Wrong cursor value");
893 SBEPP_SIZE_CHECK(ptr, view(detail::end_ptr_tag{}), offset,
sizeof(T));
894 detail::set_primitive<E>(ptr + offset, value);
895 ptr += offset +
sizeof(T);
898 template<
typename T,
typename U, endian E,
typename View>
899 SBEPP_CPP20_CONSTEXPR T get_last_value(
901 const std::size_t offset,
902 const std::size_t absolute_offset)
noexcept
905 ((view(detail::addressof_tag{}) + absolute_offset)
907 &&
"Wrong cursor value");
908 SBEPP_SIZE_CHECK(ptr, view(detail::end_ptr_tag{}), offset,
sizeof(U));
909 auto res = T{detail::get_primitive<U, E>(ptr + offset)};
910 ptr = view(detail::get_level_tag{})
911 + view(detail::get_block_length_tag{});
915 template<endian E,
typename T,
typename View>
916 SBEPP_CPP20_CONSTEXPR
void set_last_value(
918 const std::size_t offset,
919 const std::size_t absolute_offset,
920 const T value)
noexcept
923 ((view(detail::addressof_tag{}) + absolute_offset)
925 &&
"Wrong cursor value");
926 SBEPP_SIZE_CHECK(ptr, view(detail::end_ptr_tag{}), offset,
sizeof(T));
927 detail::set_primitive<E>(ptr + offset, value);
928 ptr = view(detail::get_level_tag{})
929 + view(detail::get_block_length_tag{});
932 template<
typename Res,
typename View>
933 SBEPP_CPP20_CONSTEXPR Res get_static_field_view(
935 const std::size_t offset,
936 const std::size_t absolute_offset)
noexcept
939 ((view(detail::addressof_tag{}) + absolute_offset)
941 &&
"Wrong cursor value");
942 SBEPP_SIZE_CHECK(ptr, view(detail::end_ptr_tag{}), offset, 0);
943 Res res{ptr + offset, view(detail::end_ptr_tag{})};
944 ptr += offset + res(detail::size_bytes_tag{});
948 template<
typename Res,
typename View>
949 SBEPP_CPP20_CONSTEXPR Res get_last_static_field_view(
951 const std::size_t offset,
952 const std::size_t absolute_offset)
noexcept
955 ((view(detail::addressof_tag{}) + absolute_offset)
957 &&
"Wrong cursor value");
958 SBEPP_SIZE_CHECK(ptr, view(detail::end_ptr_tag{}), offset, 0);
959 Res res{ptr + offset, view(detail::end_ptr_tag{})};
960 ptr = view(detail::get_level_tag{})
961 + view(detail::get_block_length_tag{});
965 template<
typename ResView,
typename View>
966 SBEPP_CPP20_CONSTEXPR ResView get_first_group_view(
const View view)
noexcept
968 ptr = view(detail::get_level_tag{})
969 + view(detail::get_block_length_tag{});
970 ResView g{ptr, view(detail::end_ptr_tag{})};
971 ptr += g(detail::get_header_tag{})(detail::size_bytes_tag{});
976 template<
typename ResView,
typename View>
977 SBEPP_CPP20_CONSTEXPR ResView get_first_data_view(
const View view)
noexcept
979 ptr = view(detail::get_level_tag{})
980 + view(detail::get_block_length_tag{});
981 ResView d{ptr, view(detail::end_ptr_tag{})};
982 ptr += d(detail::size_bytes_tag{});
987 template<
typename ResView,
typename View,
typename Getter>
988 SBEPP_CPP20_CONSTEXPR ResView
989 get_group_view(
const View view, Getter&& getter)
noexcept
992 (getter()(detail::addressof_tag{}) == ptr) &&
"Wrong cursor value");
993 ResView res{ptr, view(detail::end_ptr_tag{})};
994 auto header = res(detail::get_header_tag{});
995 ptr += header(detail::size_bytes_tag{});
999 template<
typename ResView,
typename View,
typename Getter>
1000 SBEPP_CPP20_CONSTEXPR ResView
1001 get_data_view(
const View view, Getter&& getter)
noexcept
1004 (getter()(detail::addressof_tag{}) == ptr) &&
"Wrong cursor value");
1005 ResView res{ptr, view(detail::end_ptr_tag{})};
1006 ptr += res(detail::size_bytes_tag{});
1011 template<
typename T>
1012 friend class cursor;
1019template<
typename Byte>
1020class init_cursor_wrapper
1023 using byte_type = Byte;
1025 template<
typename T>
1026 using result_type = T;
1028 init_cursor_wrapper() =
default;
1030 explicit constexpr init_cursor_wrapper(sbepp::cursor<Byte>& cursor)
1035 template<
typename T,
typename U, endian E,
typename View>
1036 SBEPP_CPP20_CONSTEXPR T get_value(
1039 const std::size_t absolute_offset)
noexcept
1042 view(addressof_tag{}),
1043 view(end_ptr_tag{}),
1046 T res{get_primitive<U, E>(view(addressof_tag{}) + absolute_offset)};
1047 cursor->pointer() = view(addressof_tag{}) + absolute_offset +
sizeof(U);
1051 template<endian E,
typename T,
typename View>
1052 SBEPP_CPP20_CONSTEXPR
void set_value(
1055 const std::size_t absolute_offset,
1056 const T value)
noexcept
1059 view(addressof_tag{}),
1060 view(end_ptr_tag{}),
1063 set_primitive<E>(view(addressof_tag{}) + absolute_offset, value);
1064 cursor->pointer() = view(addressof_tag{}) + absolute_offset +
sizeof(T);
1067 template<
typename T,
typename U, endian E,
typename View>
1068 SBEPP_CPP20_CONSTEXPR T get_last_value(
1071 const std::size_t absolute_offset)
noexcept
1074 view(addressof_tag{}),
1075 view(end_ptr_tag{}),
1078 T res{get_primitive<U, E>(view(addressof_tag{}) + absolute_offset)};
1080 view(get_level_tag{}) + view(get_block_length_tag{});
1084 template<endian E,
typename T,
typename View>
1085 SBEPP_CPP20_CONSTEXPR
void set_last_value(
1088 const std::size_t absolute_offset,
1089 const T value)
noexcept
1092 view(addressof_tag{}),
1093 view(end_ptr_tag{}),
1096 set_primitive<E>(view(addressof_tag{}) + absolute_offset, value);
1098 view(get_level_tag{}) + view(get_block_length_tag{});
1101 template<
typename Res,
typename View>
1102 SBEPP_CPP20_CONSTEXPR Res get_static_field_view(
1105 const std::size_t absolute_offset)
noexcept
1108 view(addressof_tag{}), view(end_ptr_tag{}), absolute_offset, 0);
1109 Res res{view(addressof_tag{}) + absolute_offset, view(end_ptr_tag{})};
1110 cursor->pointer() = res(addressof_tag{}) + res(size_bytes_tag{});
1114 template<
typename Res,
typename View>
1115 SBEPP_CPP20_CONSTEXPR Res get_last_static_field_view(
1118 const std::size_t absolute_offset)
noexcept
1121 view(addressof_tag{}), view(end_ptr_tag{}), absolute_offset, 0);
1122 Res res{view(addressof_tag{}) + absolute_offset, view(end_ptr_tag{})};
1124 view(get_level_tag{}) + view(get_block_length_tag{});
1128 template<
typename ResView,
typename View>
1129 SBEPP_CPP20_CONSTEXPR ResView get_first_group_view(
const View view)
noexcept
1131 return cursor->template get_first_group_view<ResView>(view);
1134 template<
typename ResView,
typename View>
1135 SBEPP_CPP20_CONSTEXPR ResView get_first_data_view(
const View view)
noexcept
1137 return cursor->template get_first_data_view<ResView>(view);
1140 template<
typename ResView,
typename View,
typename Getter>
1141 SBEPP_CPP20_CONSTEXPR ResView
1142 get_group_view(
const View , Getter&& getter)
noexcept
1144 auto res = getter();
1145 auto header = res(get_header_tag{});
1146 cursor->pointer() = res(addressof_tag{}) + header(size_bytes_tag{});
1150 template<
typename ResView,
typename View,
typename Getter>
1151 SBEPP_CPP20_CONSTEXPR ResView
1152 get_data_view(
const View , Getter&& getter)
noexcept
1154 auto res = getter();
1155 cursor->pointer() = res(addressof_tag{}) + res(size_bytes_tag{});
1160 sbepp::cursor<Byte>* cursor{};
1163template<
typename Byte>
1164class init_dont_move_cursor_wrapper
1167 using byte_type = Byte;
1169 template<
typename T>
1170 using result_type = T;
1172 init_dont_move_cursor_wrapper() =
default;
1174 explicit constexpr init_dont_move_cursor_wrapper(
1175 sbepp::cursor<Byte>& cursor)
1180 template<
typename T,
typename U, endian E,
typename View>
1181 SBEPP_CPP20_CONSTEXPR T get_value(
1183 const std::size_t offset,
1184 const std::size_t absolute_offset)
noexcept
1187 view(addressof_tag{}),
1188 view(end_ptr_tag{}),
1191 cursor->pointer() = view(addressof_tag{}) + absolute_offset - offset;
1192 return T{get_primitive<U, E>(view(addressof_tag{}) + absolute_offset)};
1195 template<endian E,
typename T,
typename View>
1196 SBEPP_CPP20_CONSTEXPR
void set_value(
1198 const std::size_t offset,
1199 const std::size_t absolute_offset,
1200 const T value)
noexcept
1203 view(addressof_tag{}),
1204 view(end_ptr_tag{}),
1207 cursor->pointer() = view(addressof_tag{}) + absolute_offset - offset;
1208 set_primitive<E>(view(addressof_tag{}) + absolute_offset, value);
1211 template<
typename T,
typename U, endian E,
typename View>
1212 SBEPP_CPP20_CONSTEXPR T get_last_value(
1214 const std::size_t offset,
1215 const std::size_t absolute_offset)
noexcept
1217 return get_value<T, U, E>(view, offset, absolute_offset);
1220 template<endian E,
typename T,
typename View>
1221 SBEPP_CPP20_CONSTEXPR
void set_last_value(
1223 const std::size_t offset,
1224 const std::size_t absolute_offset,
1225 const T value)
noexcept
1227 return set_value<E>(view, offset, absolute_offset, value);
1230 template<
typename Res,
typename View>
1231 SBEPP_CPP20_CONSTEXPR Res get_static_field_view(
1233 const std::size_t offset,
1234 const std::size_t absolute_offset)
noexcept
1237 view(addressof_tag{}), view(end_ptr_tag{}), absolute_offset, 0);
1238 cursor->pointer() = view(addressof_tag{}) + absolute_offset - offset;
1239 return {view(addressof_tag{}) + absolute_offset, view(end_ptr_tag{})};
1242 template<
typename Res,
typename View>
1243 SBEPP_CPP20_CONSTEXPR Res get_last_static_field_view(
1245 const std::size_t offset,
1246 const std::size_t absolute_offset)
noexcept
1248 return get_static_field_view<Res>(view, offset, absolute_offset);
1251 template<
typename ResView,
typename View>
1252 SBEPP_CPP20_CONSTEXPR ResView get_first_group_view(
const View view)
noexcept
1255 view(get_level_tag{}) + view(get_block_length_tag{});
1256 ResView g{cursor->pointer(), view(end_ptr_tag{})};
1261 template<
typename ResView,
typename View>
1262 SBEPP_CPP20_CONSTEXPR ResView get_first_data_view(
const View view)
noexcept
1265 view(get_level_tag{}) + view(get_block_length_tag{});
1266 ResView d{cursor->pointer(), view(end_ptr_tag{})};
1271 template<
typename ResView,
typename View,
typename Getter>
1272 SBEPP_CPP20_CONSTEXPR ResView
1273 get_group_view(
const View , Getter&& getter)
noexcept
1275 auto res = getter();
1276 cursor->pointer() = res(addressof_tag{});
1280 template<
typename ResView,
typename View,
typename Getter>
1281 SBEPP_CPP20_CONSTEXPR ResView
1282 get_data_view(
const View , Getter&& getter)
noexcept
1284 auto res = getter();
1285 cursor->pointer() = res(addressof_tag{});
1290 sbepp::cursor<Byte>* cursor{};
1293template<
typename Byte>
1294class dont_move_cursor_wrapper
1297 using byte_type = Byte;
1299 template<
typename T>
1300 using result_type = T;
1302 dont_move_cursor_wrapper() =
default;
1304 explicit constexpr dont_move_cursor_wrapper(sbepp::cursor<Byte>& cursor)
1309 template<
typename T,
typename U, endian E,
typename View>
1310 SBEPP_CPP20_CONSTEXPR T get_value(
1312 const std::size_t offset,
1313 const std::size_t absolute_offset)
noexcept
1316 ((view(detail::addressof_tag{}) + absolute_offset)
1317 == (cursor->pointer() + offset))
1318 &&
"Wrong cursor value");
1320 cursor->pointer(), view(end_ptr_tag{}), offset,
sizeof(U));
1321 return T{get_primitive<U, E>(cursor->pointer() + offset)};
1324 template<endian E,
typename T,
typename View>
1325 SBEPP_CPP20_CONSTEXPR
void set_value(
1327 const std::size_t offset,
1328 const std::size_t absolute_offset,
1329 const T value)
noexcept
1332 ((view(detail::addressof_tag{}) + absolute_offset)
1333 == (cursor->pointer() + offset))
1334 &&
"Wrong cursor value");
1336 cursor->pointer(), view(end_ptr_tag{}), offset,
sizeof(T));
1337 set_primitive<E>(cursor->pointer() + offset, value);
1340 template<
typename T,
typename U, endian E,
typename View>
1341 SBEPP_CPP20_CONSTEXPR T get_last_value(
1343 const std::size_t offset,
1344 const std::size_t absolute_offset)
noexcept
1347 ((view(detail::addressof_tag{}) + absolute_offset)
1348 == (cursor->pointer() + offset))
1349 &&
"Wrong cursor value");
1351 cursor->pointer(), view(end_ptr_tag{}), offset,
sizeof(U));
1352 return T{get_primitive<U, E>(cursor->pointer() + offset)};
1355 template<endian E,
typename T,
typename View>
1356 SBEPP_CPP20_CONSTEXPR
void set_last_value(
1358 const std::size_t offset,
1359 const std::size_t absolute_offset,
1360 const T value)
noexcept
1363 ((view(detail::addressof_tag{}) + absolute_offset)
1364 == (cursor->pointer() + offset))
1365 &&
"Wrong cursor value");
1367 cursor->pointer(), view(end_ptr_tag{}), offset,
sizeof(T));
1368 set_primitive<E>(cursor->pointer() + offset, value);
1371 template<
typename Res,
typename View>
1372 SBEPP_CPP20_CONSTEXPR Res get_static_field_view(
1374 const std::size_t offset,
1375 const std::size_t absolute_offset)
noexcept
1378 ((view(detail::addressof_tag{}) + absolute_offset)
1379 == (cursor->pointer() + offset))
1380 &&
"Wrong cursor value");
1381 SBEPP_SIZE_CHECK(cursor->pointer(), view(end_ptr_tag{}), offset, 0);
1382 return {cursor->pointer() + offset, view(end_ptr_tag{})};
1385 template<
typename Res,
typename View>
1386 SBEPP_CPP20_CONSTEXPR Res get_last_static_field_view(
1388 const std::size_t offset,
1389 const std::size_t absolute_offset)
noexcept
1392 ((view(detail::addressof_tag{}) + absolute_offset)
1393 == (cursor->pointer() + offset))
1394 &&
"Wrong cursor value");
1395 SBEPP_SIZE_CHECK(cursor->pointer(), view(end_ptr_tag{}), offset, 0);
1396 return {cursor->pointer() + offset, view(end_ptr_tag{})};
1399 template<
typename ResView,
typename View>
1400 SBEPP_CPP20_CONSTEXPR ResView get_first_group_view(
const View view)
noexcept
1403 view(get_level_tag{}) + view(get_block_length_tag{});
1404 ResView g{cursor->pointer(), view(end_ptr_tag{})};
1409 template<
typename ResView,
typename View>
1410 SBEPP_CPP20_CONSTEXPR ResView get_first_data_view(
const View view)
noexcept
1413 view(get_level_tag{}) + view(get_block_length_tag{});
1414 ResView d{cursor->pointer(), view(end_ptr_tag{})};
1419 template<
typename ResView,
typename View,
typename Getter>
1420 SBEPP_CPP20_CONSTEXPR ResView
1421 get_group_view(
const View view, Getter&& getter)
noexcept
1424 (getter()(detail::addressof_tag{}) == cursor->pointer())
1425 &&
"Wrong cursor value");
1426 return {cursor->pointer(), view(end_ptr_tag{})};
1429 template<
typename ResView,
typename View,
typename Getter>
1430 SBEPP_CPP20_CONSTEXPR ResView
1431 get_data_view(
const View view, Getter&& getter)
noexcept
1434 (getter()(detail::addressof_tag{}) == cursor->pointer())
1435 &&
"Wrong cursor value");
1436 return {cursor->pointer(), view(end_ptr_tag{})};
1440 sbepp::cursor<Byte>* cursor{};
1443template<
typename Byte>
1444class skip_cursor_wrapper
1447 using byte_type = Byte;
1449 template<
typename T>
1450 using result_type = void;
1452 skip_cursor_wrapper() =
default;
1454 explicit constexpr skip_cursor_wrapper(sbepp::cursor<Byte>& cursor)
1459 template<
typename T,
typename U, endian E,
typename View>
1460 SBEPP_CPP20_CONSTEXPR
void get_value(
1462 const std::size_t offset,
1463 const std::size_t absolute_offset)
noexcept
1466 ((view(detail::addressof_tag{}) + absolute_offset)
1467 == (cursor->pointer() + offset))
1468 &&
"Wrong cursor value");
1470 cursor->pointer(), view(end_ptr_tag{}), offset,
sizeof(U));
1471 cursor->pointer() += offset +
sizeof(U);
1474 template<
typename T,
typename U, endian E,
typename View>
1475 SBEPP_CPP20_CONSTEXPR
void get_last_value(
1477 const std::size_t offset,
1478 const std::size_t absolute_offset)
noexcept
1481 ((view(detail::addressof_tag{}) + absolute_offset)
1482 == (cursor->pointer() + offset))
1483 &&
"Wrong cursor value");
1485 cursor->pointer(), view(end_ptr_tag{}), offset,
sizeof(U));
1487 view(get_level_tag{}) + view(get_block_length_tag{});
1490 template<
typename Res,
typename View>
1491 SBEPP_CPP20_CONSTEXPR
void get_static_field_view(
1493 const std::size_t offset,
1494 const std::size_t absolute_offset)
noexcept
1497 ((view(detail::addressof_tag{}) + absolute_offset)
1498 == (cursor->pointer() + offset))
1499 &&
"Wrong cursor value");
1500 SBEPP_SIZE_CHECK(cursor->pointer(), view(end_ptr_tag{}), offset, 0);
1501 Res res{cursor->pointer(), view(end_ptr_tag{})};
1502 cursor->pointer() += offset + res(size_bytes_tag{});
1505 template<
typename Res,
typename View>
1506 SBEPP_CPP20_CONSTEXPR
void get_last_static_field_view(
1508 const std::size_t offset,
1509 const std::size_t absolute_offset)
noexcept
1512 ((view(detail::addressof_tag{}) + absolute_offset)
1513 == (cursor->pointer() + offset))
1514 &&
"Wrong cursor value");
1515 SBEPP_SIZE_CHECK(cursor->pointer(), view(end_ptr_tag{}), offset, 0);
1517 view(get_level_tag{}) + view(get_block_length_tag{});
1520 template<
typename ResView,
typename View>
1521 SBEPP_CPP20_CONSTEXPR
void get_first_group_view(
const View view)
noexcept
1524 view(get_level_tag{}) + view(get_block_length_tag{});
1525 ResView g{cursor->pointer(), view(end_ptr_tag{})};
1526 cursor->pointer() += g(size_bytes_tag{});
1529 template<
typename ResView,
typename View>
1530 SBEPP_CPP20_CONSTEXPR
void get_first_data_view(
const View view)
noexcept
1533 view(get_level_tag{}) + view(get_block_length_tag{});
1534 ResView d{cursor->pointer(), view(end_ptr_tag{})};
1535 cursor->pointer() += d(size_bytes_tag{});
1538 template<
typename ResView,
typename View,
typename Getter>
1539 SBEPP_CPP20_CONSTEXPR
void
1540 get_group_view(
const View view, Getter&& getter)
noexcept
1543 (getter()(detail::addressof_tag{}) == cursor->pointer())
1544 &&
"Wrong cursor value");
1545 ResView res{cursor->pointer(), view(end_ptr_tag{})};
1546 cursor->pointer() += res(size_bytes_tag{});
1549 template<
typename ResView,
typename View,
typename Getter>
1550 SBEPP_CPP20_CONSTEXPR
void
1551 get_data_view(
const View view, Getter&& getter)
noexcept
1554 (getter()(detail::addressof_tag{}) == cursor->pointer())
1555 &&
"Wrong cursor value");
1556 ResView res{cursor->pointer(), view(end_ptr_tag{})};
1557 cursor->pointer() += res(size_bytes_tag{});
1561 sbepp::cursor<Byte>* cursor{};
1564template<
typename Cursor,
typename T>
1565using cursor_result_type_t =
1566 typename remove_reference_t<Cursor>::template result_type<T>;
1568template<
typename Cursor>
1569using cursor_byte_type_t =
typename remove_reference_t<Cursor>::byte_type;
1571template<
typename MessageByte,
typename CursorByte>
1572using enable_if_cursor_compatible_t =
1573 enable_if_convertible_t<MessageByte, CursorByte>;
1575template<
typename MessageByte,
typename CursorByte>
1576using enable_if_cursor_writeable_t = enable_if_t<
1577 std::is_convertible<MessageByte*, CursorByte*>::value
1578 && !std::is_const<MessageByte>::value && !std::is_const<CursorByte>::value>;
1594 return v(detail::size_bytes_tag{});
1606template<
typename T,
typename Byte>
1609 return v(detail::size_bytes_tag{}, c);
1619constexpr auto get_header(T v)
noexcept ->
decltype(v(detail::get_header_tag{}))
1621 return v(detail::get_header_tag{});
1631constexpr auto addressof(T v)
noexcept ->
decltype(v(detail::addressof_tag{}))
1633 return v(detail::addressof_tag{});
1641template<
typename View>
1646 std::declval<View>()))>
::type;
1650template<
typename View>
1676template<
typename Byte>
1679 return detail::init_cursor_wrapper<Byte>{c};
1704template<
typename Byte>
1705constexpr detail::dont_move_cursor_wrapper<Byte>
1708 return detail::dont_move_cursor_wrapper<Byte>{c};
1718template<
typename Byte>
1719constexpr detail::init_dont_move_cursor_wrapper<Byte>
1722 return detail::init_dont_move_cursor_wrapper<Byte>{c};
1739template<
typename Byte>
1742 return detail::skip_cursor_wrapper<Byte>{c};
1750template<
typename Byte>
1754 using byte_range<Byte>::byte_range;
1755 using byte_range<Byte>::operator();
1759template<
typename Byte,
typename Header>
1763 using byte_range<Byte>::byte_range;
1764 using byte_range<Byte>::operator();
1766 SBEPP_CPP14_CONSTEXPR Header operator()(get_header_tag)
const noexcept
1768 Header header{(*this)(addressof_tag{}), (*
this)(end_ptr_tag{})};
1770 (*
this)(addressof_tag{}),
1771 (*this)(end_ptr_tag{}),
1777 SBEPP_CPP14_CONSTEXPR Byte* operator()(get_level_tag)
const noexcept
1779 auto header = (*this)(get_header_tag{});
1780 return header(addressof_tag{}) + header(size_bytes_tag{});
1783 constexpr typename std::decay<
1784 decltype(std::declval<Header>().blockLength().value())>::type
1785 operator()(get_block_length_tag)
const noexcept
1787 return operator()(get_header_tag{}).blockLength().value();
1792 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
1793 SBEPP_CPP20_CONSTEXPR std::size_t
1796 return c.
pointer() - (*this)(addressof_tag{});
1801template<
typename Byte,
typename BlockLengthType>
1802class entry_base :
public byte_range<Byte>
1805 using byte_range<Byte>::operator();
1807 template<
typename Byte2,
typename BlockLengthType2>
1808 friend class entry_base;
1815 Byte* ptr, Byte* end, BlockLengthType block_length) noexcept
1816 : byte_range<Byte>{ptr, end}, block_length{block_length}
1823 const std::size_t size,
1824 const BlockLengthType block_length) noexcept
1825 : entry_base{ptr, ptr + size, block_length}
1830 template<
typename Byte2,
typename = enable_if_convertible_t<Byte2, Byte>>
1832 cursor<Byte2>& c, Byte* end_ptr, BlockLengthType block_length) noexcept
1833 : entry_base{c.pointer(), end_ptr, block_length}
1842 template<
typename Byte2,
typename = enable_if_convertible_t<Byte2, Byte>>
1844 const entry_base<Byte2, BlockLengthType>& other) noexcept
1845 : byte_range<Byte>{other}, block_length{other.block_length}
1849 constexpr BlockLengthType operator()(get_block_length_tag)
const noexcept
1851 return block_length;
1854 constexpr Byte* operator()(get_level_tag)
const noexcept
1856 return (*
this)(addressof_tag{});
1860 BlockLengthType block_length{};
1863template<
typename Entry>
1867 explicit constexpr arrow_proxy(Entry entry) noexcept : entry{entry}
1871 constexpr const Entry* operator->() const noexcept
1884 typename DifferenceType,
1885 typename BlockLengthType>
1886class forward_iterator
1889 using iterator_category = std::forward_iterator_tag;
1890 using value_type = ValueType;
1891 using reference = value_type;
1892 using difference_type = DifferenceType;
1893 using pointer = arrow_proxy<value_type>;
1895 forward_iterator() =
default;
1897 SBEPP_CPP14_CONSTEXPR forward_iterator(
1899 const IndexType index,
1900 const BlockLengthType block_length,
1904 block_length{block_length}
1905#if SBEPP_SIZE_CHECKS_ENABLED
1913 constexpr reference operator*() const noexcept
1915#if SBEPP_SIZE_CHECKS_ENABLED
1916 return {ptr, end, block_length};
1918 return {ptr,
nullptr, block_length};
1922 constexpr pointer operator->() const noexcept
1924 return pointer{operator*()};
1927 SBEPP_CPP14_CONSTEXPR forward_iterator& operator++() noexcept
1935 SBEPP_CPP14_CONSTEXPR forward_iterator operator++(
int)
noexcept
1942 friend constexpr bool operator==(
1943 const forward_iterator& lhs,
const forward_iterator& rhs)
noexcept
1945 return lhs.index == rhs.index;
1948 friend constexpr bool operator!=(
1949 const forward_iterator& lhs,
const forward_iterator& rhs)
noexcept
1951 return lhs.index != rhs.index;
1957 BlockLengthType block_length{};
1958#if SBEPP_SIZE_CHECKS_ENABLED
1966 typename BlockLengthType,
1967 typename DifferenceType,
1969class random_access_iterator
1972 using iterator_category = std::random_access_iterator_tag;
1973 using value_type = ValueType;
1974 using reference = value_type;
1975 using difference_type = DifferenceType;
1976 using pointer = arrow_proxy<value_type>;
1978 random_access_iterator() =
default;
1980 SBEPP_CPP14_CONSTEXPR random_access_iterator(
1982 const BlockLengthType block_length,
1983 const IndexType index,
1986 block_length{block_length},
1988#if SBEPP_SIZE_CHECKS_ENABLED
1996 constexpr reference operator*() const noexcept
1998#if SBEPP_SIZE_CHECKS_ENABLED
1999 return {ptr, end, block_length};
2001 return {ptr,
nullptr, block_length};
2005 constexpr pointer operator->() const noexcept
2007 return pointer{operator*()};
2010 SBEPP_CPP14_CONSTEXPR random_access_iterator& operator++() noexcept
2012 SBEPP_SIZE_CHECK(ptr, end, 0, block_length);
2013 ptr += block_length;
2018 SBEPP_CPP14_CONSTEXPR random_access_iterator operator++(
int)
noexcept
2025 SBEPP_CPP14_CONSTEXPR random_access_iterator& operator--() noexcept
2027 ptr -= block_length;
2032 SBEPP_CPP14_CONSTEXPR random_access_iterator operator--(
int)
noexcept
2039 SBEPP_CPP14_CONSTEXPR random_access_iterator&
2040 operator+=(difference_type n)
noexcept
2042 ptr += n * block_length;
2047 SBEPP_CPP14_CONSTEXPR random_access_iterator
2048 operator+(difference_type n)
const noexcept
2054 friend constexpr random_access_iterator
2055 operator+(difference_type n,
const random_access_iterator& it)
noexcept
2060 SBEPP_CPP14_CONSTEXPR random_access_iterator&
2061 operator-=(difference_type n)
noexcept
2066 SBEPP_CPP14_CONSTEXPR random_access_iterator
2067 operator-(difference_type n)
const noexcept
2073 constexpr difference_type
2074 operator-(
const random_access_iterator& rhs)
const noexcept
2076 return index - rhs.index;
2079 constexpr reference operator[](difference_type n)
const noexcept
2081 return *(*
this + n);
2084 friend constexpr bool operator==(
2085 const random_access_iterator& lhs,
2086 const random_access_iterator& rhs)
noexcept
2088 return lhs.index == rhs.index;
2091 friend constexpr bool operator!=(
2092 const random_access_iterator& lhs,
2093 const random_access_iterator& rhs)
noexcept
2095 return lhs.index != rhs.index;
2098 friend constexpr bool operator<(
2099 const random_access_iterator& lhs,
2100 const random_access_iterator& rhs)
noexcept
2102 return lhs.index < rhs.index;
2105 friend constexpr bool operator<=(
2106 const random_access_iterator& lhs,
2107 const random_access_iterator& rhs)
noexcept
2109 return lhs.index <= rhs.index;
2112 friend constexpr bool operator>(
2113 const random_access_iterator& lhs,
2114 const random_access_iterator& rhs)
noexcept
2116 return lhs.index > rhs.index;
2119 friend constexpr bool operator>=(
2120 const random_access_iterator& lhs,
2121 const random_access_iterator& rhs)
noexcept
2123 return lhs.index >= rhs.index;
2128 BlockLengthType block_length{};
2132#if SBEPP_SIZE_CHECKS_ENABLED
2140 typename CursorType,
2141 typename BlockLengthType,
2146 using iterator_category = std::input_iterator_tag;
2147 using value_type = ValueType;
2148 using reference = value_type;
2149 using difference_type =
typename std::make_signed<IndexType>::type;
2150 using pointer = arrow_proxy<value_type>;
2152 input_iterator() =
default;
2154 SBEPP_CPP14_CONSTEXPR input_iterator(
2155 const IndexType index,
2157 BlockLengthType block_length,
2161 block_length{block_length}
2162#if SBEPP_SIZE_CHECKS_ENABLED
2170 constexpr reference operator*() const noexcept
2172#if SBEPP_SIZE_CHECKS_ENABLED
2173 return {*cursor, end, block_length};
2175 return {*cursor,
nullptr, block_length};
2179 constexpr pointer operator->() const noexcept
2181 return pointer{operator*()};
2184 SBEPP_CPP14_CONSTEXPR input_iterator& operator++() noexcept
2190 SBEPP_CPP14_CONSTEXPR input_iterator operator++(
int)
noexcept
2197 friend constexpr bool operator==(
2198 const input_iterator& lhs,
const input_iterator& rhs)
noexcept
2200 return lhs.index == rhs.index;
2203 friend constexpr bool operator!=(
2204 const input_iterator& lhs,
const input_iterator& rhs)
noexcept
2206 return lhs.index != rhs.index;
2211 CursorType* cursor{};
2212 BlockLengthType block_length{};
2213#if SBEPP_SIZE_CHECKS_ENABLED
2221 typename CursorType,
2222 typename BlockLengthType,
2227 SBEPP_CPP14_CONSTEXPR cursor_range(
2229 BlockLengthType block_length,
2231 IndexType start_pos,
2232 IndexType length) noexcept
2234 block_length{block_length},
2235 start_pos{start_pos},
2236#if SBEPP_SIZE_CHECKS_ENABLED
2245 input_iterator<ValueType, IndexType, CursorType, BlockLengthType, Byte>;
2247 constexpr iterator begin() const noexcept
2249#if SBEPP_SIZE_CHECKS_ENABLED
2250 return {start_pos, cursor, block_length, end_ptr};
2252 return {start_pos, cursor, block_length,
nullptr};
2256 constexpr iterator end() const noexcept
2258#if SBEPP_SIZE_CHECKS_ENABLED
2260 static_cast<IndexType
>(start_pos + size()),
2266 static_cast<IndexType
>(start_pos + size()),
2273 constexpr IndexType size() const noexcept
2279 CursorType* cursor{};
2280 BlockLengthType block_length{};
2281 IndexType start_pos{};
2282#if SBEPP_SIZE_CHECKS_ENABLED
2289template<
typename Byte,
typename Entry,
typename Dimension>
2299 decltype(std::declval<Dimension>().numInGroup())>::type;
2309 typename std::decay<
2310 decltype(std::declval<Dimension>().blockLength().value())>::type,
2314 using byte_range<Byte>::byte_range;
2315 using byte_range<Byte>::operator();
2317 SBEPP_CPP14_CONSTEXPR Dimension operator()(get_header_tag)
const noexcept
2319 Dimension header{(*this)(addressof_tag{}), (*
this)(end_ptr_tag{})};
2321 (*
this)(addressof_tag{}),
2322 (*this)(end_ptr_tag{}),
2328 SBEPP_CPP20_CONSTEXPR std::size_t operator()(size_bytes_tag)
const noexcept
2330 auto dimension = (*this)(get_header_tag{});
2332 + dimension.numInGroup().value()
2333 * dimension.blockLength().value();
2339 return (*
this)(get_header_tag{}).numInGroup();
2351 (*this)(get_header_tag{}).numInGroup(count);
2355 SBEPP_CPP17_NODISCARD SBEPP_CPP20_CONSTEXPR
bool empty() const noexcept
2363 return sbe_size_type::max_value();
2369 auto dimension = (*this)(get_header_tag{});
2372 dimension.blockLength().value(),
2374 (*this)(end_ptr_tag{})};
2381 (*this)(addressof_tag{}) + (*
this)(size_bytes_tag{}),
2382 (*
this)(get_header_tag{}).blockLength().value(),
2384 (*this)(end_ptr_tag{})};
2391 SBEPP_ASSERT(pos <
size());
2392 return *(
begin() + pos);
2399 SBEPP_ASSERT(!
empty());
2407 SBEPP_ASSERT(!
empty());
2413 SBEPP_CPP14_CONSTEXPR
void clear() const noexcept
2419 template<
typename Byte2>
2424 typename std::decay<
2425 decltype(std::declval<Dimension>().blockLength().value())>::type,
2431 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2437 (*this)(get_header_tag{}).blockLength().value(),
2438 (*this)(end_ptr_tag{}),
2447 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2451 SBEPP_ASSERT(pos <
size());
2455 (*this)(get_header_tag{}).blockLength().value(),
2456 (*this)(end_ptr_tag{}),
2466 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2472 SBEPP_ASSERT(pos <
size());
2473 SBEPP_ASSERT(count <= (
size() - pos));
2477 (*this)(get_header_tag{}).blockLength().value(),
2478 (*this)(end_ptr_tag{}),
2484 template<
typename Byte2>
2490 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2500 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2507 template<
typename Visitor,
typename Cursor>
2508 SBEPP_CPP14_CONSTEXPR
bool
2509 operator()(visit_children_tag, Visitor& v, Cursor& c)
2513 if(v.on_entry(entry, c))
2523template<
typename Byte,
typename Entry,
typename Dimension>
2533 decltype(std::declval<Dimension>().numInGroup())>::type;
2546 typename std::decay<
2547 decltype(std::declval<Dimension>().blockLength().value())>::type>;
2549 using byte_range<Byte>::byte_range;
2550 using byte_range<Byte>::operator();
2552 SBEPP_CPP14_CONSTEXPR Dimension operator()(get_header_tag)
const noexcept
2554 Dimension header{(*this)(addressof_tag{}), (*
this)(end_ptr_tag{})};
2556 (*
this)(addressof_tag{}),
2557 (*this)(end_ptr_tag{}),
2563 SBEPP_CPP20_CONSTEXPR std::size_t operator()(size_bytes_tag)
const noexcept
2566 for(
const auto entry : *
this)
2577 return (*
this)(get_header_tag{}).numInGroup();
2589 (*this)(get_header_tag{}).numInGroup(count);
2593 SBEPP_CPP17_NODISCARD SBEPP_CPP20_CONSTEXPR
bool empty() const noexcept
2601 return sbe_size_type::max_value();
2607 auto dimension = (*this)(get_header_tag{});
2611 dimension.blockLength().value(),
2612 (*this)(end_ptr_tag{})};
2620 (*this)(get_header_tag{}).numInGroup().value(),
2621 (*this)(get_header_tag{}).blockLength().value(),
2622 (*this)(end_ptr_tag{})};
2629 SBEPP_ASSERT(!
empty());
2635 SBEPP_CPP14_CONSTEXPR
void clear() const noexcept
2641 template<
typename Byte2>
2646 typename std::decay<
2647 decltype(std::declval<Dimension>().blockLength().value())>::type,
2653 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2659 (*this)(get_header_tag{}).blockLength().value(),
2660 (*this)(end_ptr_tag{}),
2669 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2673 SBEPP_ASSERT(pos <
size());
2677 (*this)(get_header_tag{}).blockLength().value(),
2678 (*this)(end_ptr_tag{}),
2688 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2694 SBEPP_ASSERT(pos <
size());
2695 SBEPP_ASSERT(count <= (
size() - pos));
2699 (*this)(get_header_tag{}).blockLength().value(),
2700 (*this)(end_ptr_tag{}),
2706 template<
typename Byte2>
2712 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2722 typename = enable_if_cursor_compatible_t<Byte, Byte2>>
2729 template<
typename Visitor,
typename Cursor>
2730 SBEPP_CPP14_CONSTEXPR
bool
2731 operator()(visit_children_tag, Visitor& v, Cursor& c)
2735 if(v.on_entry(entry, c))
2773 return bits & (1 << n);
2776 SBEPP_CPP14_CONSTEXPR
void
2777 operator()(set_bit_tag,
const choice_index_t n,
const bool b)
noexcept
2779 bits = ((bits & ~(1 << n)) | (b << n));
2783 constexpr friend bool
2786 return *lhs == *rhs;
2790 constexpr friend bool
2793 return *lhs != *rhs;
2800template<
typename View,
typename =
void_t<>>
2801struct has_get_header : std::false_type
2805template<
typename View>
2806struct has_get_header<
2808 void_t<decltype(sbepp::
get_header(std::declval<View>()))>> : std::true_type
2814 typename = detail::enable_if_t<detail::has_get_header<View>::value>>
2815constexpr std::size_t get_header_size(View view)
noexcept
2822 typename = detail::enable_if_t<!detail::has_get_header<View>::value>,
2824constexpr std::size_t get_header_size(View)
noexcept
2837template<
typename Enum>
2838constexpr typename std::underlying_type<Enum>::type
2841 return static_cast<typename std::underlying_type<Enum>::type
>(e);
2857template<
typename View>
2879template<
typename View>
2880SBEPP_CPP14_CONSTEXPR cursor<typename std::add_const<byte_type_t<View>>::type>
2892struct default_init_t
2894 explicit default_init_t() =
default;
2921template<
typename From,
typename To>
2922struct copy_cv_qualifiers
2924 using copy_const_t =
typename std::
2925 conditional<std::is_const<From>::value,
const To, To>::type;
2927 using type =
typename std::conditional<
2928 std::is_volatile<From>::value,
2929 volatile copy_const_t,
2930 copy_const_t>::type;
2933template<
typename From,
typename To>
2934using apply_cv_qualifiers_t =
typename copy_cv_qualifiers<From, To>::type;
2938using is_range = std::bool_constant<std::ranges::range<R>>;
2940template<
typename R,
typename =
void_t<>>
2941struct is_range : std::false_type
2949 decltype(std::begin(std::declval<R>())),
2950 decltype(std::end(std::declval<R>()))>> : std::true_type
2955constexpr bool is_constant_evaluated() noexcept
2960#if SBEPP_HAS_IS_CONSTANT_EVALUATED
2961 return std::is_constant_evaluated();
2967inline SBEPP_CPP20_CONSTEXPR std::size_t string_length(
const char* str)
noexcept
2969 if(is_constant_evaluated())
2971 std::size_t length{};
2973 for(; *str !=
'\0'; str++, length++)
2981 return std::strlen(str);
2992template<
typename Byte,
typename Value, std::
size_t N,
typename Tag>
3019 constexpr std::size_t operator()(detail::size_bytes_tag)
const noexcept
3028 SBEPP_ASSERT(pos <
size());
3050 (*
this)(detail::addressof_tag{}),
3051 (*this)(detail::end_ptr_tag{}),
3054 return (
pointer)(*this)(detail::addressof_tag{});
3058 SBEPP_CPP17_NODISCARD
static constexpr bool empty() noexcept
3114 (*this)(detail::addressof_tag{}), (*
this)(detail::end_ptr_tag{})};
3123 SBEPP_CPP20_CONSTEXPR std::size_t
strlen() const noexcept
3125 if(is_constant_evaluated())
3127 return string_length(
data());
3131 const auto first_null =
static_cast<const value_type*
>(
3132 std::memchr(
data(),
'\0',
size()));
3135 return first_null -
data();
3148 SBEPP_CPP20_CONSTEXPR std::size_t
strlen_r() const noexcept
3150 const auto last_non_null = std::find_if(
3155 return value !=
'\0';
3171 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3175 SBEPP_ASSERT(str !=
nullptr);
3176 const auto length = string_length(str);
3177 SBEPP_ASSERT(length <=
size());
3178 const auto eos_pos = std::copy_n(str, length,
begin());
3179 pad(eos_mode, eos_pos);
3198 enable_if_t<!std::is_const<Byte>::value && is_range<R>::value>>
3203 pad(eos_mode, eos_pos);
3219 enable_if_t<!std::is_const<Byte>::value && is_range<R>::value>>
3223 auto res = std::ranges::copy(std::forward<R>(r),
begin()).out;
3225 auto res = std::copy(std::begin(r), std::end(r),
begin());
3227 SBEPP_ASSERT(res <=
end());
3236 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3250 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3254 SBEPP_ASSERT(count <=
size());
3255 return std::fill_n(
begin(), count, value);
3261 template<
typename InputIt,
typename = enable_if_writable_t<Byte, InputIt>>
3264 const auto last_out = std::copy(first, last,
begin());
3276 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3278 assign(std::initializer_list<value_type> ilist)
const noexcept
3280 SBEPP_ASSERT(ilist.size() <=
size());
3281 return assign(std::begin(ilist), std::end(ilist));
3285 SBEPP_CPP20_CONSTEXPR
void
3290 std::fill(eos_pos,
end(),
'\0');
3294 if(eos_pos !=
end())
3314template<
typename Byte,
typename Value,
typename Length, endian E>
3344 return data_checked();
3369 SBEPP_ASSERT(!
empty());
3377 SBEPP_ASSERT(!
empty());
3390 return data_checked();
3397 SBEPP_ASSERT(pos <
size());
3398 return *(
data() + pos);
3404 return detail::get_value<size_type, size_type, E>(*
this, 0);
3414 SBEPP_CPP17_NODISCARD SBEPP_CPP20_CONSTEXPR
bool empty() const noexcept
3422 return sbe_size_type::max_value();
3426 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3427 SBEPP_CPP20_CONSTEXPR
void clear() const noexcept
3433 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3436 const auto old_size =
size();
3438 if(count > old_size)
3440 for(
auto i = old_size; i != count; i++)
3448 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3449 SBEPP_CPP20_CONSTEXPR
void
3452 const auto old_size =
size();
3454 if(count > old_size)
3456 for(
auto i = old_size; i != count; i++)
3464 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3465 SBEPP_CPP20_CONSTEXPR
void
3471 (*
this)(addressof_tag{}),
3472 (*this)(end_ptr_tag{}),
3475 set_primitive<E>((*
this)(addressof_tag{}), count);
3479 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3482 const auto current_size =
size();
3484 (*this)[current_size] = value;
3488 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3491 SBEPP_ASSERT(!
empty());
3496 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3499 SBEPP_ASSERT(pos >=
begin() && pos <
end());
3500 std::copy(pos + 1,
end(), pos);
3506 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3510 SBEPP_ASSERT(first >=
begin() && last <
end());
3511 std::copy(last,
end(), first);
3517 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3521 SBEPP_ASSERT(pos >=
begin() && pos <=
end());
3522 const auto old_end =
end();
3524 std::copy_backward(pos, old_end,
end());
3530 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3534 SBEPP_ASSERT(pos >=
begin() && pos <=
end());
3535 const auto old_end =
end();
3537 std::copy_backward(pos, old_end,
end());
3538 std::fill_n(pos, count, value);
3545 typename = detail::enable_if_t<
3546 !std::is_const<Byte>::value
3547 && std::is_convertible<
3548 typename std::iterator_traits<InputIt>::iterator_category,
3549 std::input_iterator_tag>::value>>
3553 SBEPP_ASSERT(pos >=
begin() && pos <=
end());
3555 typename std::iterator_traits<InputIt>::iterator_category;
3556 return insert_impl(pos, first, last, category_t{});
3560 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3562 iterator pos, std::initializer_list<value_type> ilist)
const noexcept
3564 return insert(pos, std::begin(ilist), std::end(ilist));
3569 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3570 SBEPP_CPP20_CONSTEXPR
void
3574 std::fill_n(
begin(), count, value);
3579 template<
typename InputIt,
typename = enable_if_writable_t<Byte, InputIt>>
3580 SBEPP_CPP20_CONSTEXPR
void assign(InputIt first, InputIt last)
const
3582 auto begin = data_unchecked();
3583 const auto new_end = std::copy(first, last,
begin);
3589 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3590 SBEPP_CPP20_CONSTEXPR
void
3591 assign(std::initializer_list<value_type> ilist)
const noexcept
3594 (*
this)(detail::addressof_tag{}),
3595 (*this)(detail::end_ptr_tag{}),
3598 assign(std::begin(ilist), std::end(ilist));
3611 (*this)(detail::addressof_tag{}), (*
this)(detail::end_ptr_tag{})};
3614 SBEPP_CPP20_CONSTEXPR std::size_t
3615 operator()(detail::size_bytes_tag)
const noexcept
3626 template<
typename T =
void,
typename = enable_if_writable_t<Byte, T>>
3629 SBEPP_ASSERT(str !=
nullptr);
3630 const auto length = string_length(str);
3632 std::copy_n(str, length,
begin());
3645 enable_if_t<!std::is_const<Byte>::value && is_range<R>::value>>
3648 const auto begin = data_unchecked();
3650 const auto new_end = std::ranges::copy(std::forward<R>(r),
begin).out;
3652 const auto new_end = std::copy(std::begin(r), std::end(r),
begin);
3658 SBEPP_CPP14_CONSTEXPR
pointer data_checked() const noexcept
3661 (*
this)(detail::addressof_tag{}),
3662 (*this)(detail::end_ptr_tag{}),
3665 return data_unchecked();
3668 SBEPP_CPP14_CONSTEXPR
pointer data_unchecked() const noexcept
3671 (*
this)(detail::addressof_tag{}),
3672 (*this)(detail::end_ptr_tag{}),
3685 template<
typename It>
3686 SBEPP_CPP14_CONSTEXPR
iterator insert_impl(
3687 iterator pos, It first, It last, std::input_iterator_tag)
const
3690 for(; first != last; ++first, ++out)
3698 template<
typename It>
3699 SBEPP_CPP20_CONSTEXPR
iterator insert_impl(
3700 iterator pos, It first, It last, std::forward_iterator_tag)
const
3702 const auto in_size = std::distance(first, last);
3703 auto old_end =
end();
3705 std::copy_backward(pos, old_end,
end());
3706 std::copy(first, last, pos);
3715 explicit constexpr nullopt_t(
int)
3733template<
typename T,
typename Derived>
3771 return (Derived::min_value() <= val) && (val <= Derived::max_value());
3783#if SBEPP_HAS_THREE_WAY_COMPARISON
3788 constexpr friend bool
3791 return *lhs == *rhs;
3795 constexpr friend bool
3798 return *lhs != *rhs;
3802 constexpr friend bool
3809 constexpr friend bool
3812 return *lhs <= *rhs;
3816 constexpr friend bool
3823 constexpr friend bool
3826 return *lhs >= *rhs;
3840template<
typename T,
typename Derived>
3884 return (Derived::min_value() <= val) && (val <= Derived::max_value());
3894 return default_value;
3900 return (val != Derived::null_value());
3904 constexpr explicit operator bool() const noexcept
3917 constexpr friend bool
3920 return *lhs == *rhs;
3929#if SBEPP_HAS_THREE_WAY_COMPARISON
3930 constexpr friend std::strong_ordering
3935 return *lhs <=> *rhs;
3937 return lhs.has_value() <=> rhs.has_value();
3942 constexpr friend bool
3945 return *lhs != *rhs;
3949 constexpr friend bool
3952 return rhs && (!lhs || (*lhs < *rhs));
3956 constexpr friend bool
3959 return !lhs || (rhs && (*lhs <= *rhs));
3963 constexpr friend bool
3966 return lhs && (!rhs || (*lhs > *rhs));
3970 constexpr friend bool
3973 return !rhs || (lhs && (*lhs >= *rhs));
3979 value_type val{Derived::null_value()};
3997template<
typename Message>
3999 ->
decltype(m(detail::fill_message_header_tag{}))
4001 return m(detail::fill_message_header_tag{});
4017template<
typename Group,
typename Size>
4019 ->
decltype(g(detail::fill_group_header_tag{}, num_in_group))
4021 return g(detail::fill_group_header_tag{}, num_in_group);
4056 template<
typename Byte>
4060 static constexpr const char*
name() noexcept;
4143 template<typename Byte>
4171 static constexpr const char*
name() noexcept;
4217 static constexpr const char*
name() noexcept;
4226 static constexpr ScopedEnumType
value() noexcept;
4247 static constexpr const char*
name() noexcept;
4293 static constexpr const char*
name() noexcept;
4323 static constexpr const char*
name() noexcept;
4343 template<typename Byte>
4369 static constexpr const char*
name() noexcept;
4388 template<typename Byte>
4497 static constexpr const char*
name() noexcept;
4522 template<typename Byte>
4546 static constexpr const char*
name() noexcept;
4565 template<typename Byte>
4572 template<typename Byte>
4581 template<typename Byte>
4594 static constexpr std::
size_t
4622 static constexpr const char*
name() noexcept;
4637 template<typename Byte>
4649 static constexpr std::
size_t
4678template<
typename ValueType>
4682template<
typename ValueType>
4691template<
typename ValueType>
4694template<
typename Byte,
typename Value, std::
size_t N,
typename Tag>
4701#define SBEPP_BUILT_IN_IMPL(NAME, TYPE, MIN, MAX, NULL) \
4704 class NAME##_t : public detail::required_base<TYPE, NAME##_t> \
4707 using detail::required_base<TYPE, NAME##_t>::required_base; \
4710 static constexpr value_type min_value() noexcept \
4716 static constexpr value_type max_value() noexcept \
4724 class NAME##_opt_t : public detail::optional_base<TYPE, NAME##_opt_t> \
4727 using detail::optional_base<TYPE, NAME##_opt_t>::optional_base; \
4730 static constexpr value_type min_value() noexcept \
4736 static constexpr value_type max_value() noexcept \
4742 static constexpr value_type null_value() noexcept \
4749 class type_traits<NAME##_t> \
4752 static constexpr const char* name() noexcept \
4757 static constexpr const char* description() noexcept \
4762 static constexpr field_presence presence() noexcept \
4764 return field_presence::required; \
4767 static constexpr TYPE min_value() noexcept \
4769 return NAME##_t::min_value(); \
4772 static constexpr TYPE max_value() noexcept \
4774 return NAME##_t::max_value(); \
4777 static constexpr length_t length() noexcept \
4782 static constexpr const char* semantic_type() noexcept \
4787 static constexpr version_t since_version() noexcept \
4792 using value_type = NAME##_t; \
4793 using primitive_type = value_type::value_type; \
4797 struct traits_tag<NAME##_t> \
4799 using type = NAME##_t; \
4803 class type_traits<NAME##_opt_t> \
4806 static constexpr const char* name() noexcept \
4811 static constexpr const char* description() noexcept \
4816 static constexpr field_presence presence() noexcept \
4818 return field_presence::optional; \
4821 static constexpr TYPE min_value() noexcept \
4823 return NAME##_opt_t::min_value(); \
4826 static constexpr TYPE max_value() noexcept \
4828 return NAME##_opt_t::max_value(); \
4831 static constexpr TYPE null_value() noexcept \
4833 return NAME##_opt_t::null_value(); \
4836 static constexpr length_t length() noexcept \
4841 static constexpr const char* semantic_type() noexcept \
4846 static constexpr version_t since_version() noexcept \
4851 using value_type = NAME##_opt_t; \
4852 using primitive_type = value_type::value_type; \
4856 struct traits_tag<NAME##_opt_t> \
4858 using type = NAME##_opt_t; \
4861SBEPP_BUILT_IN_IMPL(
char,
char, 0x20, 0x7E, 0);
4865 std::numeric_limits<std::int8_t>::min() + 1,
4866 std::numeric_limits<std::int8_t>::max(),
4867 std::numeric_limits<std::int8_t>::min());
4871 std::numeric_limits<std::uint8_t>::min(),
4872 std::numeric_limits<std::uint8_t>::max() - 1,
4873 std::numeric_limits<std::uint8_t>::max());
4877 std::numeric_limits<std::int16_t>::min() + 1,
4878 std::numeric_limits<std::int16_t>::max(),
4879 std::numeric_limits<std::int16_t>::min());
4883 std::numeric_limits<std::uint16_t>::min(),
4884 std::numeric_limits<std::uint16_t>::max() - 1,
4885 std::numeric_limits<std::uint16_t>::max());
4889 std::numeric_limits<std::int32_t>::min() + 1,
4890 std::numeric_limits<std::int32_t>::max(),
4891 std::numeric_limits<std::int32_t>::min());
4895 std::numeric_limits<std::uint32_t>::min(),
4896 std::numeric_limits<std::uint32_t>::max() - 1,
4897 std::numeric_limits<std::uint32_t>::max());
4901 std::numeric_limits<std::int64_t>::min() + 1,
4902 std::numeric_limits<std::int64_t>::max(),
4903 std::numeric_limits<std::int64_t>::min());
4907 std::numeric_limits<std::uint64_t>::min(),
4908 std::numeric_limits<std::uint64_t>::max() - 1,
4909 std::numeric_limits<std::uint64_t>::max());
4913 std::numeric_limits<float>::min(),
4914 std::numeric_limits<float>::max(),
4915 std::numeric_limits<float>::quiet_NaN());
4919 std::numeric_limits<double>::min(),
4920 std::numeric_limits<double>::max(),
4921 std::numeric_limits<double>::quiet_NaN());
4923#undef SBEPP_BUILT_IN_IMPL
4942template<
template<
typename>
class View,
typename Byte>
4943constexpr View<Byte>
make_view(Byte* ptr,
const std::size_t size)
noexcept
4966template<
template<
typename>
class View,
typename Byte>
4967constexpr View<typename std::add_const<Byte>::type>
4986template<
template<
typename...>
class Base,
typename Derived>
4987struct is_base_of_tmp_impl
4989 static constexpr std::false_type test(...);
4991 template<
typename... Ts>
4992 static constexpr std::true_type test(Base<Ts...>*);
4994 using type =
decltype(test(std::declval<Derived*>()));
4997template<
template<
typename...>
class Base,
typename Derived>
4998using is_base_of_tmp =
typename is_base_of_tmp_impl<Base, Derived>::type;
5000#if SBEPP_HAS_CONCEPTS
5001template<
typename Derived,
template<
typename...>
class Base>
5002concept derived_from_tmp = is_base_of_tmp<Base, Derived>::value;
5008template<
typename Derived>
5009struct is_array_type_impl
5011 static constexpr std::false_type test(...);
5013 template<
typename T1,
typename T2, std::
size_t N,
typename T3>
5014 static constexpr std::true_type
5015 test(detail::static_array_ref<T1, T2, N, T3>*);
5017 using type =
decltype(test(std::declval<Derived*>()));
5028using is_array_type =
typename detail::is_array_type_impl<T>::type;
5066using is_type = std::integral_constant<
5077template<
typename T,
typename =
void>
5078struct is_enum : std::false_type
5085 detail::void_t<decltype(tag_invoke(
5086 std::declval<detail::visit_tag>(),
5088 std::declval<int&>()))>> : std::true_type
5098using is_set = detail::is_base_of_tmp<detail::bitset_base, T>;
5107using is_composite = detail::is_base_of_tmp<detail::composite_base, T>;
5116using is_message = detail::is_base_of_tmp<detail::message_base, T>;
5125using is_flat_group = detail::is_base_of_tmp<detail::flat_group_base, T>;
5134using is_nested_group = detail::is_base_of_tmp<detail::nested_group_base, T>;
5143using is_group = std::integral_constant<
5154using is_group_entry = detail::is_base_of_tmp<detail::entry_base, T>;
5158template<
typename Derived>
5161 static constexpr std::false_type test(...);
5163 template<
typename T1,
typename T2,
typename T3, endian E>
5164 static constexpr std::true_type
5167 using type =
decltype(test(std::declval<Derived*>()));
5177using is_data =
typename detail::is_data_impl<T>::type;
5179#if SBEPP_HAS_INLINE_VARS
5237#if SBEPP_HAS_CONCEPTS
5298using is_cursor_visitable_view = std::integral_constant<
5319 detail::enable_if_t<detail::is_cursor_visitable_view<View>::value>>
5320SBEPP_CPP14_CONSTEXPR Visitor&&
5321 visit(View view, Cursor& c, Visitor&& visitor = {})
5323 view(detail::visit_tag{}, visitor, c);
5324 return std::forward<Visitor>(visitor);
5341 detail::enable_if_t<detail::is_cursor_visitable_view<View>::value>>
5342SBEPP_CPP14_CONSTEXPR Visitor&&
visit(View view, Visitor&& visitor = {})
5345 return sbepp::visit(view, c, std::forward<Visitor>(visitor));
5348#ifndef SBEPP_DOXYGEN
5349template<
typename Visitor,
typename SetOrComposite>
5350SBEPP_CPP14_CONSTEXPR detail::enable_if_t<
5351 is_set<SetOrComposite>::value || is_composite<SetOrComposite>::value,
5353 visit(SetOrComposite setOrComposite, Visitor&& visitor = {})
5355 setOrComposite(detail::visit_tag{}, visitor);
5356 return std::forward<Visitor>(visitor);
5359template<
typename Visitor,
typename Enum>
5360SBEPP_CPP14_CONSTEXPR detail::enable_if_t<is_enum<Enum>::value, Visitor&&>
5361 visit(Enum e, Visitor&& visitor = {})
5363 tag_invoke(detail::visit_tag{}, e, visitor);
5364 return std::forward<Visitor>(visitor);
5379template<
typename Visitor,
typename Composite>
5380SBEPP_CPP14_CONSTEXPR Visitor&&
visit(Composite view, Visitor&& visitor = {});
5398template<
typename Visitor,
typename Set>
5399SBEPP_CPP14_CONSTEXPR Visitor&&
visit(Set s, Visitor&& visitor = {});
5417template<
typename Visitor,
typename Enum>
5418SBEPP_CPP14_CONSTEXPR Visitor&&
visit(Enum e, Visitor&& visitor = {});
5434template<
typename Visitor,
typename View,
typename Cursor>
5435SBEPP_DEPRECATED SBEPP_CPP14_CONSTEXPR
5436 detail::enable_if_t<is_composite<View>::value, Visitor&&>
5437 visit(View view, Cursor& c, Visitor&& visitor = {})
5440 return sbepp::visit(view, std::forward<Visitor>(visitor));
5459 detail::enable_if_t<detail::is_cursor_visitable_view<View>::value>>
5460SBEPP_CPP14_CONSTEXPR Visitor&&
5463 view(detail::visit_children_tag{}, visitor, c);
5464 return std::forward<Visitor>(visitor);
5481 detail::enable_if_t<detail::is_cursor_visitable_view<View>::value>>
5482SBEPP_CPP14_CONSTEXPR Visitor&&
5499template<
typename Visitor,
typename View>
5500SBEPP_CPP14_CONSTEXPR detail::enable_if_t<is_composite<View>::value, Visitor&&>
5503 view(detail::visit_children_tag{}, visitor);
5504 return std::forward<Visitor>(visitor);
5520template<
typename Visitor,
typename View,
typename Cursor>
5521SBEPP_DEPRECATED SBEPP_CPP14_CONSTEXPR
5522 detail::enable_if_t<is_composite<View>::value, Visitor&&>
5526 return visit_children(view, std::forward<Visitor>(visitor));
5531class enum_to_string_visitor
5534 template<
typename Enum,
typename Tag>
5535 SBEPP_CPP14_CONSTEXPR
void on_enum_value(Enum , Tag)
noexcept
5540 template<
typename Enum>
5541 SBEPP_CPP14_CONSTEXPR
void
5542 on_enum_value(Enum , sbepp::unknown_enum_value_tag)
noexcept
5544 name_value =
nullptr;
5547 constexpr const char* name() const noexcept
5553 const char* name_value;
5567template<typename E, typename = detail::enable_if_t<is_enum<E>::value>>
5568SBEPP_DEPRECATED
constexpr const char*
enum_to_string(
const E e)
noexcept
5584template<
typename Set,
typename Visitor>
5585SBEPP_DEPRECATED
constexpr auto
5586 visit_set(
const Set s, Visitor&& visitor)
noexcept
5587 ->
decltype(s(detail::visit_set_tag{}, std::forward<Visitor>(visitor)))
5589 return s(detail::visit_set_tag{}, std::forward<Visitor>(visitor));
5600template<
typename Tag,
typename ViewOrSet>
5601constexpr auto get_by_tag(ViewOrSet viewOrSet)
noexcept
5602 ->
decltype(viewOrSet(detail::access_by_tag_tag{}, Tag{}))
5604 return viewOrSet(detail::access_by_tag_tag{}, Tag{});
5615template<
typename Tag,
typename View,
typename Cursor>
5616constexpr auto get_by_tag(View view, Cursor&& c)
noexcept ->
decltype(view(
5617 detail::access_by_tag_tag{}, Tag{}, std::forward<Cursor>(c)))
5619 return view(detail::access_by_tag_tag{}, Tag{}, std::forward<Cursor>(c));
5631template<
typename Tag,
typename ViewOrSet,
typename Value>
5632constexpr auto set_by_tag(ViewOrSet&& viewOrSet, Value&& value)
noexcept
5633 ->
decltype(std::forward<ViewOrSet>(viewOrSet)(
5634 detail::access_by_tag_tag{}, Tag{}, std::forward<Value>(value)))
5636 return std::forward<ViewOrSet>(viewOrSet)(
5637 detail::access_by_tag_tag{}, Tag{}, std::forward<Value>(value));
5650template<
typename Tag,
typename View,
typename Value,
typename Cursor>
5651constexpr auto set_by_tag(View view, Value&& value, Cursor&& c)
5653 detail::access_by_tag_tag{},
5655 std::forward<Value>(value),
5656 std::forward<Cursor>(c)))
5659 detail::access_by_tag_tag{},
5661 std::forward<Value>(value),
5662 std::forward<Cursor>(c));
5667template<
template<
typename>
class Trait,
typename T,
typename = void_t<>>
5668struct has_traits : std::false_type
5672template<
template<
typename>
class Trait,
typename T>
5673struct has_traits<Trait, T, void_t<decltype(Trait<T>{})>> : std::true_type
5684template<
typename Tag>
5685using is_type_tag = detail::has_traits<type_traits, Tag>;
5693template<
typename Tag>
5694using is_enum_tag = detail::has_traits<enum_traits, Tag>;
5703template<
typename Tag>
5712template<
typename Tag>
5713using is_set_tag = detail::has_traits<set_traits, Tag>;
5722template<
typename Tag>
5731template<
typename Tag>
5740template<
typename Tag>
5741using is_field_tag = detail::has_traits<field_traits, Tag>;
5749template<
typename Tag>
5750using is_group_tag = detail::has_traits<group_traits, Tag>;
5758template<
typename Tag>
5759using is_data_tag = detail::has_traits<data_traits, Tag>;
5767template<
typename Tag>
5776template<
typename Tag>
5777using is_schema_tag = detail::has_traits<schema_traits, Tag>;
5779#if SBEPP_HAS_INLINE_VARS
5781template<
typename Tag>
5785template<
typename Tag>
5789template<
typename Tag>
5793template<
typename Tag>
5797template<
typename Tag>
5801template<
typename Tag>
5805template<
typename Tag>
5809template<
typename Tag>
5813template<
typename Tag>
5817template<
typename Tag>
5821template<
typename Tag>
5825#if SBEPP_HAS_CONCEPTS
5827template<
typename Tag>
5831template<
typename Tag>
5835template<
typename Tag>
5839template<
typename Tag>
5843template<
typename Tag>
5847template<
typename Tag>
5851template<
typename Tag>
5855template<
typename Tag>
5859template<
typename Tag>
5863template<
typename Tag>
5867template<
typename Tag>
5882template<
typename Byte>
5883class size_bytes_checked_impl
5886 template<
typename View>
5888 validate(View view,
const std::size_t size)
noexcept
5894 res.
valid = validate<traits_tag_t<View>>();
5895 res.size = size - this->size;
5904 static constexpr bool validate_data(
type_list<>)
noexcept
5909 template<
typename Tag,
typename... Tags>
5914 return try_consume(
sizeof(
typename decltype(
data)::size_type))
5915 && try_consume(
data.size())
5919 static constexpr bool validate_groups(
type_list<>)
noexcept
5924 template<
typename Tag,
typename... Tags>
5932 const auto block_length = *header.blockLength();
5933 const auto num_in_group = *header.numInGroup();
5934 using index_t = remove_cv_t<
decltype(num_in_group)>;
5939 for(index_t i = 0; i != num_in_group; i++)
5941 if(!validate_level<Tag>(block_length))
5953 template<
typename Tag>
5954 SBEPP_CPP14_CONSTEXPR enable_if_t<is_message_tag<Tag>::value,
bool>
5955 validate_level(
const std::size_t block_length)
noexcept
5957 return try_consume(block_length)
5962 template<
typename Tag>
5963 SBEPP_CPP14_CONSTEXPR enable_if_t<is_group_tag<Tag>::value,
bool>
5964 validate_level(
const std::size_t block_length)
noexcept
5966 return try_consume(block_length)
5971 template<
typename Tag>
5972 SBEPP_CPP14_CONSTEXPR enable_if_t<is_message_tag<Tag>::value,
bool>
5979 && validate_level<Tag>(*header.blockLength());
5982 template<
typename Tag>
5983 SBEPP_CPP14_CONSTEXPR enable_if_t<is_group_tag<Tag>::value,
bool>
5989 SBEPP_CPP14_CONSTEXPR
bool try_consume(
const std::size_t n)
noexcept
6013template<
typename View>
6017 return detail::size_bytes_checked_impl<byte_type_t<View>>{}.validate(
6022#if SBEPP_HAS_RANGES && SBEPP_HAS_CONCEPTS
6024template<
typename Byte,
typename Value, std::
size_t N,
typename Tag>
6025inline constexpr bool std::ranges::enable_borrowed_range<
6026 sbepp::detail::static_array_ref<Byte, Value, N, Tag>> =
true;
6028template<
typename Byte,
typename Value,
typename Length, sbepp::endian E>
6029inline constexpr bool std::ranges::enable_borrowed_range<
6030 sbepp::detail::dynamic_array_ref<Byte, Value, Length, E>> =
true;
6032template<sbepp::detail::derived_from_tmp<sbepp::detail::flat_group_base> T>
6033inline constexpr bool std::ranges::enable_borrowed_range<T> =
true;
6035template<sbepp::detail::derived_from_tmp<sbepp::detail::nested_group_base> T>
6036inline constexpr bool std::ranges::enable_borrowed_range<T> =
true;
6039#undef SBEPP_CPP17_INLINE_VAR
6040#undef SBEPP_DEPRECATED
6041#undef SBEPP_CPLUSPLUS
Provides various traits/attributes of a <composite> element.
Definition sbepp.hpp:4320
CompositeType< Byte > value_type
Representation type.
Definition sbepp.hpp:4344
static constexpr offset_t offset() noexcept
Returns type offset. Available only if offset is static, i.e. not available for public composites who...
static constexpr const char * semantic_type() noexcept
Returns semanticType attribute.
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
sbepp::type_list< ElementTags... > element_tags
Element tags in schema order.
Definition sbepp.hpp:4348
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in.
static constexpr std::size_t size_bytes() noexcept
Returns size of the composite in bytes.
static constexpr const char * name() noexcept
Returns name attribute.
static constexpr const char * description() noexcept
Returns description attribute.
Represents cursor which is used in cursor-based API. Clients should not use undocumented methods.
Definition sbepp.hpp:795
constexpr Byte * pointer() const noexcept
Returns underlying pointer.
Definition sbepp.hpp:861
constexpr cursor(cursor< Byte2 > other) noexcept
Constructs from another cursor. Enabled only if Byte2* is convertible to Byte*.
Definition sbepp.hpp:824
Byte byte_type
same as Byte
Definition sbepp.hpp:798
cursor()=default
Construct a new cursor object initialized with nullptr
constexpr Byte *& pointer() noexcept
Returns underlying pointer. Might be useful in rare cases to initialize cursor with a particular valu...
Definition sbepp.hpp:851
constexpr cursor & operator=(cursor< Byte2 > other) noexcept
Assigns from another cursor. Enabled only if Byte2* is convertible to Byte
Definition sbepp.hpp:839
Provides various traits/attributes of a <data> element.
Definition sbepp.hpp:4619
static constexpr const char * name() noexcept
Returns name attribute.
DataType value_type
Representation type.
Definition sbepp.hpp:4638
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in schema.
LengthTypeTag length_type_tag
length_type tag
Definition sbepp.hpp:4642
LengthType length_type
Length type.
Definition sbepp.hpp:4640
static constexpr const char * description() noexcept
Returns description attribute.
static constexpr std::size_t size_bytes(const length_type::value_type size) noexcept
Returns number of bytes required to represent <data> in memory.
constexpr T operator*() const noexcept
Returns underlying value.
Definition sbepp.hpp:2765
constexpr friend bool operator==(const bitset_base &lhs, const bitset_base &rhs) noexcept
Tests if underlying values are equal.
Definition sbepp.hpp:2784
constexpr T & operator*() noexcept
Returns reference to underlying value.
Definition sbepp.hpp:2759
constexpr bitset_base(T value) noexcept
Constructs from given value.
Definition sbepp.hpp:2754
constexpr friend bool operator!=(const bitset_base &lhs, const bitset_base &rhs) noexcept
Tests if underlying values are not equal.
Definition sbepp.hpp:2791
bitset_base()=default
Default constructs underlying value to 0
Base class for all reference semantics types.
Definition sbepp.hpp:726
constexpr byte_range(Byte *ptr, const std::size_t size) noexcept
Constructs from pointer and size.
Definition sbepp.hpp:748
constexpr byte_range(const byte_range< Byte2 > &other) noexcept
Copy constructor. Available if Byte2* is convertible to Byte*
Definition sbepp.hpp:756
byte_range()=default
Initializes to nullptr
constexpr byte_range(Byte *begin, Byte *end) noexcept
Constructs from a pair of pointers.
Definition sbepp.hpp:737
Base class for composites.
Definition sbepp.hpp:1752
Represents reference to dynamic arrays used for <data> elements.
Definition sbepp.hpp:3316
constexpr sbe_size_type sbe_size() const noexcept
Returns SBE size representation.
Definition sbepp.hpp:3402
pointer iterator
Iterator type. Satisfies std::random_access_iterator
Definition sbepp.hpp:3334
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator type.
Definition sbepp.hpp:3336
constexpr iterator insert(iterator pos, std::initializer_list< value_type > ilist) const noexcept
Inserts elements from ilist before pos
Definition sbepp.hpp:3561
constexpr reverse_iterator rend() const noexcept
Returns a reverse iterator to the end.
Definition sbepp.hpp:3360
static constexpr size_type max_size() noexcept
Returns max value of SBE length representation.
Definition sbepp.hpp:3420
constexpr iterator erase(iterator first, iterator last) const noexcept
Erases elements in [first; last) range.
Definition sbepp.hpp:3508
constexpr void assign_string(const char *str) const noexcept
Assigns null-terminated string.
Definition sbepp.hpp:3627
constexpr iterator insert(iterator pos, InputIt first, InputIt last) const
Inserts elements from [first; last) range before pos
Definition sbepp.hpp:3551
constexpr void assign(std::initializer_list< value_type > ilist) const noexcept
Replaces the contents of the container with the elements from ilist
Definition sbepp.hpp:3591
constexpr reference back() const noexcept
Returns the last element.
Definition sbepp.hpp:3375
constexpr void resize(size_type count, sbepp::default_init_t) const noexcept
Sets size to count, default initializes new elements.
Definition sbepp.hpp:3466
element_type * pointer
Element pointer type.
Definition sbepp.hpp:3332
constexpr void push_back(value_type value) const noexcept
Adds new element to the end.
Definition sbepp.hpp:3480
constexpr iterator insert(iterator pos, const value_type value) const noexcept
Inserts value before pos
Definition sbepp.hpp:3519
constexpr reference operator[](size_type pos) const noexcept
Returns element at pos
Definition sbepp.hpp:3395
constexpr void resize(size_type count) const noexcept
Sets size to count, value initializes new elements.
Definition sbepp.hpp:3434
constexpr reference front() const noexcept
Returns the first element.
Definition sbepp.hpp:3367
std::ptrdiff_t difference_type
std::ptrdiff_t
Definition sbepp.hpp:3328
constexpr void pop_back() const noexcept
Removes the last element.
Definition sbepp.hpp:3489
Value value_type
Same as Value
Definition sbepp.hpp:3322
constexpr dynamic_array_ref< Byte, detail::remove_cv_t< Byte >, Length, E > raw() const noexcept
Returns dynamic_array_ref<Byte, Byte, Length, E>.
Definition sbepp.hpp:3608
detail::apply_cv_qualifiers_t< Byte, Value > element_type
Final element type. value_type with the same cv-qualifiers as Byte
Definition sbepp.hpp:3320
constexpr iterator begin() const noexcept
Returns an iterator to the beginning.
Definition sbepp.hpp:3342
constexpr void assign_range(R &&r) const
Assigns range.
Definition sbepp.hpp:3646
constexpr iterator insert(iterator pos, size_type count, const value_type value) const noexcept
Inserts count copies of value before pos
Definition sbepp.hpp:3531
constexpr void assign(size_type count, const value_type value) const noexcept
Replaces the contents of the container with count copies of value
Definition sbepp.hpp:3571
constexpr pointer data() const noexcept
Returns pointer to the underlying array.
Definition sbepp.hpp:3388
constexpr iterator erase(iterator pos) const noexcept
Erases element at pos
Definition sbepp.hpp:3497
constexpr void clear() const noexcept
Sets size to 0.
Definition sbepp.hpp:3427
constexpr bool empty() const noexcept
Checks if size() != 0
Definition sbepp.hpp:3414
constexpr reverse_iterator rbegin() const noexcept
Returns a reverse iterator to the beginning.
Definition sbepp.hpp:3354
constexpr void resize(size_type count, value_type value) const noexcept
Sets size to count, initializes new elements with value
Definition sbepp.hpp:3450
constexpr void assign(InputIt first, InputIt last) const
Replaces the contents of the container with the elements from [first; last) range.
Definition sbepp.hpp:3580
constexpr iterator end() const noexcept
Returns an iterator to the end.
Definition sbepp.hpp:3348
constexpr size_type size() const noexcept
Returns raw size.
Definition sbepp.hpp:3408
typename sbe_size_type::value_type size_type
Raw size type.
Definition sbepp.hpp:3326
Length sbe_size_type
length SBE representation of data's encoding
Definition sbepp.hpp:3324
element_type & reference
Element reference type.
Definition sbepp.hpp:3330
constexpr entry_base(cursor< Byte2 > &c, Byte *end_ptr, BlockLengthType block_length) noexcept
Constructs from cursor.
Definition sbepp.hpp:1831
constexpr entry_base(const entry_base< Byte2, BlockLengthType > &other) noexcept
Constructs from entry_base of compatible byte type. Available if Byte2* is convertible to Byte*
Definition sbepp.hpp:1843
constexpr entry_base(Byte *ptr, const std::size_t size, const BlockLengthType block_length) noexcept
Constructs from pointer and size.
Definition sbepp.hpp:1821
entry_base()=default
Constructs using nullptr
constexpr entry_base(Byte *ptr, Byte *end, BlockLengthType block_length) noexcept
Constructs from two pointers.
Definition sbepp.hpp:1814
Base class for a flat group.
Definition sbepp.hpp:2291
random_access_iterator< Byte, Entry, typename std::decay< decltype(std::declval< Dimension >().blockLength().value())>::type, difference_type, size_type > iterator
Random access iterator to value_type. Satisfies std::random_access_iterator
Definition sbepp.hpp:2306
constexpr void clear() const noexcept
Resizes to 0
Definition sbepp.hpp:2413
constexpr sbe_size_type sbe_size() const noexcept
Returns header's numInGroup
Definition sbepp.hpp:2337
typename cursor_range_t< Byte2 >::iterator cursor_iterator
cursor_range_t::iterator. Satisfies std::input_iterator
Definition sbepp.hpp:2485
constexpr reference front() const noexcept
Returns the first entry.
Definition sbepp.hpp:2397
constexpr cursor_range_t< Byte2 > cursor_subrange(cursor< Byte2 > &c, const size_type pos) const noexcept
Returns cursor range to [pos; size()) entries.
Definition sbepp.hpp:2449
detail::cursor_range< value_type, size_type, cursor< Byte2 >, typename std::decay< decltype(std::declval< Dimension >().blockLength().value())>::type, Byte > cursor_range_t
Type of a cursor range. Satisfies std::ranges::input_range
Definition sbepp.hpp:2420
typename std::decay< decltype(std::declval< Dimension >().numInGroup())>::type sbe_size_type
numInGroup value type
Definition sbepp.hpp:2298
Entry value_type
Entry type.
Definition sbepp.hpp:2294
constexpr reference operator[](size_type pos) const noexcept
Returns group entry at pos
Definition sbepp.hpp:2389
constexpr size_type size() const noexcept
Returns raw size.
Definition sbepp.hpp:2343
constexpr iterator begin() const noexcept
Returns an iterator to the beginning.
Definition sbepp.hpp:2367
constexpr cursor_iterator< Byte2 > cursor_begin(cursor< Byte2 > &c) const noexcept
Returns cursor iterator to the beginning.
Definition sbepp.hpp:2492
constexpr cursor_range_t< Byte2 > cursor_range(cursor< Byte2 > &c) const noexcept
Returns cursor range to all group entries.
Definition sbepp.hpp:2433
constexpr bool empty() const noexcept
Checks if size() == 0
Definition sbepp.hpp:2355
constexpr iterator end() const noexcept
Returns an iterator to the end.
Definition sbepp.hpp:2378
constexpr void resize(const size_type count) const noexcept
Sets numInGroup to count
Definition sbepp.hpp:2349
constexpr cursor_iterator< Byte2 > cursor_end(cursor< Byte2 > &c) const noexcept
Returns cursor iterator to the end.
Definition sbepp.hpp:2502
static constexpr size_type max_size() noexcept
Returns numInGroup's maxValue
Definition sbepp.hpp:2361
constexpr reference back() const noexcept
Returns the last entry.
Definition sbepp.hpp:2405
typename std::make_signed< size_type >::type difference_type
Signed size_type
Definition sbepp.hpp:2303
constexpr cursor_range_t< Byte2 > cursor_subrange(cursor< Byte2 > &c, const size_type pos, const size_type count) const noexcept
Returns cursor range to [pos; pos+count) entries.
Definition sbepp.hpp:2467
typename sbe_size_type::value_type size_type
Raw size type.
Definition sbepp.hpp:2301
value_type reference
value_type
Definition sbepp.hpp:2296
Base class for messages.
Definition sbepp.hpp:1761
Base class for a nested group.
Definition sbepp.hpp:2525
constexpr size_type size() const noexcept
Returns raw size.
Definition sbepp.hpp:2581
constexpr iterator end() const noexcept
Returns an iterator to the end.
Definition sbepp.hpp:2616
constexpr cursor_range_t< Byte2 > cursor_subrange(cursor< Byte2 > &c, const size_type pos) const noexcept
Returns cursor range to [pos; size()) entries.
Definition sbepp.hpp:2671
Entry value_type
Entry type.
Definition sbepp.hpp:2528
static constexpr size_type max_size() noexcept
Returns numInGroup's maxValue
Definition sbepp.hpp:2599
typename cursor_range_t< Byte2 >::iterator cursor_iterator
cursor_range_t::iterator. Satisfies std::input_iterator
Definition sbepp.hpp:2707
value_type reference
value_type
Definition sbepp.hpp:2530
detail::cursor_range< value_type, size_type, cursor< Byte2 >, typename std::decay< decltype(std::declval< Dimension >().blockLength().value())>::type, Byte > cursor_range_t
Type of a cursor range. Satisfies std::ranges::input_range
Definition sbepp.hpp:2642
typename sbe_size_type::value_type size_type
Raw size type.
Definition sbepp.hpp:2535
typename std::make_signed< size_type >::type difference_type
Signed size_type
Definition sbepp.hpp:2537
constexpr sbe_size_type sbe_size() const noexcept
Returns header's numInGroup
Definition sbepp.hpp:2575
constexpr void resize(const size_type count) const noexcept
Sets numInGroup to count
Definition sbepp.hpp:2587
constexpr reference front() const noexcept
Returns the first element.
Definition sbepp.hpp:2627
constexpr cursor_iterator< Byte2 > cursor_end(cursor< Byte2 > &c) const noexcept
Returns cursor iterator to the end.
Definition sbepp.hpp:2724
constexpr void clear() const noexcept
Resizes to 0
Definition sbepp.hpp:2635
constexpr cursor_iterator< Byte2 > cursor_begin(cursor< Byte2 > &c) const noexcept
Returns cursor iterator to the beginning.
Definition sbepp.hpp:2714
constexpr bool empty() const noexcept
Checks if size() == 0
Definition sbepp.hpp:2593
forward_iterator< Byte, Entry, size_type, difference_type, typename std::decay< decltype(std::declval< Dimension >().blockLength().value())>::type > iterator
Forward iterator to value_type. Satisfies std::forward_iterator
Definition sbepp.hpp:2541
constexpr cursor_range_t< Byte2 > cursor_range(cursor< Byte2 > &c) const noexcept
Returns cursor range to all group entries.
Definition sbepp.hpp:2655
constexpr cursor_range_t< Byte2 > cursor_subrange(cursor< Byte2 > &c, const size_type pos, const size_type count) const noexcept
Returns cursor range to [pos; pos+count) entries.
Definition sbepp.hpp:2689
constexpr iterator begin() const noexcept
Returns an iterator to the beginning.
Definition sbepp.hpp:2605
typename std::decay< decltype(std::declval< Dimension >().numInGroup())>::type sbe_size_type
numInGroup value type
Definition sbepp.hpp:2532
constexpr friend bool operator<(const optional_base &lhs, const optional_base &rhs) noexcept
Tests if lhs is less than rhs
Definition sbepp.hpp:3950
constexpr value_type value() const noexcept
Returns underlying value.
Definition sbepp.hpp:3863
constexpr friend bool operator!=(const optional_base &lhs, const optional_base &rhs) noexcept
Tests if lhs is not equal to rhs
Definition sbepp.hpp:3943
constexpr friend bool operator<=(const optional_base &lhs, const optional_base &rhs) noexcept
Tests if lhs is less than or equal to rhs
Definition sbepp.hpp:3957
constexpr optional_base(nullopt_t) noexcept
Constructs null object.
Definition sbepp.hpp:3852
optional_base()=default
Constructs null object.
constexpr value_type value_or(T default_value) const noexcept
Returns value if not null, default_value otherwise.
Definition sbepp.hpp:3888
constexpr friend bool operator>=(const optional_base &lhs, const optional_base &rhs) noexcept
Tests if lhs is greater than or equal to rhs
Definition sbepp.hpp:3971
T value_type
Underlying type.
Definition sbepp.hpp:3845
constexpr bool in_range() const noexcept
Checks if value is in [Derived::min_value(); Derived::max_value()] range.
Definition sbepp.hpp:3882
constexpr optional_base(value_type val) noexcept
Constructs object from given value.
Definition sbepp.hpp:3858
constexpr bool has_value() const noexcept
Checks if has value.
Definition sbepp.hpp:3898
constexpr friend bool operator>(const optional_base &lhs, const optional_base &rhs) noexcept
Tests if lhs is greater than rhs
Definition sbepp.hpp:3964
constexpr value_type operator*() const noexcept
Returns underlying value.
Definition sbepp.hpp:3875
constexpr value_type & operator*() noexcept
Returns reference to underlying value.
Definition sbepp.hpp:3869
constexpr friend bool operator==(const optional_base &lhs, const optional_base &rhs) noexcept
Tests if lhs is equal to rhs
Definition sbepp.hpp:3918
constexpr friend std::strong_ordering operator<=>(const optional_base &lhs, const optional_base &rhs) noexcept
Available only if SBEPP_HAS_THREE_WAY_COMPARISON == 1.
constexpr friend bool operator>(const required_base &lhs, const required_base &rhs) noexcept
Tests if lhs is greater than rhs
Definition sbepp.hpp:3817
constexpr friend bool operator>=(const required_base &lhs, const required_base &rhs) noexcept
Tests if lhs is greater than or equal to rhs
Definition sbepp.hpp:3824
constexpr value_type value() const noexcept
Returns underlying value.
Definition sbepp.hpp:3750
constexpr friend bool operator!=(const required_base &lhs, const required_base &rhs) noexcept
Tests if lhs is not equal to rhs
Definition sbepp.hpp:3796
constexpr value_type & operator*() noexcept
Returns reference to underlying value.
Definition sbepp.hpp:3756
constexpr friend bool operator==(const required_base &lhs, const required_base &rhs) noexcept
Tests if lhs is equal to rhs
Definition sbepp.hpp:3789
required_base()=default
Default constructor. Constructs value-initialized object.
constexpr bool in_range() const noexcept
Checks if value is in [Derived::min_value(); Derived::max_value()] range.
Definition sbepp.hpp:3769
constexpr friend bool operator<(const required_base &lhs, const required_base &rhs) noexcept
Tests if lhs is less than rhs
Definition sbepp.hpp:3803
T value_type
Underlying type.
Definition sbepp.hpp:3738
constexpr value_type operator*() const noexcept
Returns underlying value.
Definition sbepp.hpp:3762
constexpr friend bool operator<=(const required_base &lhs, const required_base &rhs) noexcept
Tests if lhs is less than or equal to rhs
Definition sbepp.hpp:3810
friend auto operator<=>(const required_base &, const required_base &)=default
Available only if SBEPP_HAS_THREE_WAY_COMPARISON == 1.
constexpr required_base(value_type val) noexcept
Constructs from given value.
Definition sbepp.hpp:3745
Represents reference to fixed-size array.
Definition sbepp.hpp:2994
pointer iterator
Iterator type. Satisfies std::random_access_iterator
Definition sbepp.hpp:3010
constexpr reverse_iterator rend() const noexcept
Returns a reverse iterator to the end.
Definition sbepp.hpp:3094
static constexpr bool empty() noexcept
Checks if size() != 0
Definition sbepp.hpp:3058
detail::apply_cv_qualifiers_t< Byte, Value > element_type
Final element type. value_type with the same cv-qualifiers as Byte
Definition sbepp.hpp:2998
constexpr reference operator[](size_type pos) const noexcept
Returns element at pos
Definition sbepp.hpp:3026
constexpr std::size_t strlen() const noexcept
Calculates string length from left to right.
Definition sbepp.hpp:3123
constexpr iterator assign_string(const char *str, const eos_null eos_mode=eos_null::all) const noexcept
Assigns null-terminated string.
Definition sbepp.hpp:3172
constexpr reference front() const noexcept
Returns the first element.
Definition sbepp.hpp:3033
constexpr iterator begin() const noexcept
Returns an iterator to the beginning.
Definition sbepp.hpp:3076
static constexpr size_type size() noexcept
Returns N
Definition sbepp.hpp:3064
constexpr static_array_ref< Byte, detail::remove_cv_t< Byte >, N, Tag > raw() const noexcept
Returns static_array_ref<Byte, Byte, N, Tag>.
Definition sbepp.hpp:3111
constexpr iterator assign(std::initializer_list< value_type > ilist) const noexcept
Assigns initializer list to first elements.
Definition sbepp.hpp:3278
element_type & reference
Element reference type.
Definition sbepp.hpp:3006
std::reverse_iterator< iterator > reverse_iterator
Reverse iterator type.
Definition sbepp.hpp:3012
constexpr reference back() const noexcept
Returns the last element.
Definition sbepp.hpp:3039
Value value_type
Same as Value
Definition sbepp.hpp:3000
Tag tag
Type tag.
Definition sbepp.hpp:3014
element_type * pointer
Element pointer type.
Definition sbepp.hpp:3008
constexpr std::size_t strlen_r() const noexcept
Calculates string length from right to left.
Definition sbepp.hpp:3148
std::size_t size_type
std::size_t
Definition sbepp.hpp:3002
constexpr iterator end() const noexcept
Returns an iterator to the end.
Definition sbepp.hpp:3082
constexpr iterator assign_string(R &&r, const eos_null eos_mode=eos_null::all) const
Assigns string represented by a range.
Definition sbepp.hpp:3200
constexpr void fill(const value_type value) const noexcept
Assigns value to all elements.
Definition sbepp.hpp:3237
constexpr iterator assign_range(R &&r) const
Assigns range.
Definition sbepp.hpp:3220
constexpr reverse_iterator rbegin() const noexcept
Returns a reverse iterator to the beginning.
Definition sbepp.hpp:3088
constexpr iterator assign(InputIt first, InputIt last) const
Assigns elements from [first; last) range to first elements.
Definition sbepp.hpp:3262
static constexpr size_type max_size() noexcept
Returns size()
Definition sbepp.hpp:3070
std::ptrdiff_t difference_type
std::ptrdiff_t
Definition sbepp.hpp:3004
constexpr pointer data() const noexcept
Returns pointer to the underlying array.
Definition sbepp.hpp:3045
constexpr iterator assign(size_type count, const value_type value) const noexcept
Assigns value to first count elements.
Definition sbepp.hpp:3252
Provides various traits/attributes of an <enum> element.
Definition sbepp.hpp:4168
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in schema.
EncodingType encoding_type
Underlying type, e.g. std::uint8_t
Definition sbepp.hpp:4175
static constexpr offset_t offset() noexcept
Returns enum offset. Available only if offset is static, i.e. not available for public enums whose of...
static constexpr const char * description() noexcept
Returns description attribute.
sbepp::type_list< ValueTags... > value_tags
Value tags in schema order.
Definition sbepp.hpp:4196
EncodingTypeTag encoding_type_tag
Tag of the type specified in the encodingType attribute.
Definition sbepp.hpp:4182
static constexpr const char * name() noexcept
Returns name attribute.
ScopedEnumType value_type
Representation type.
Definition sbepp.hpp:4194
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
Provides various traits/attributes of a <validValue> element.
Definition sbepp.hpp:4214
static constexpr ScopedEnumType value() noexcept
Returns enumerator value.
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
static constexpr const char * name() noexcept
Returns name attribute.
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in schema.
static constexpr const char * description() noexcept
Returns description attribute.
Provides various traits/attributes of a <field> element.
Definition sbepp.hpp:4494
static constexpr const char * name() noexcept
Returns name attribute.
static constexpr const char * description() noexcept
Returns description attribute.
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in schema.
static constexpr offset_t offset() noexcept
Returns actual offset.
ValueType value_type
Representation type.
Definition sbepp.hpp:4516
TypeTag value_type_tag
value_type's tag. Not available for constants of numeric types
Definition sbepp.hpp:4525
static constexpr field_presence presence() noexcept
Returns the actual presence. Note that it can be different from the one provided in schema,...
Provides various traits/attributes of a <group> element.
Definition sbepp.hpp:4543
static constexpr block_length_t block_length() noexcept
Returns blockLength attribute.
static constexpr std::size_t size_bytes(const NumInGroupType num_in_group,...) noexcept
Returns number of bytes required to represent the group in given configuration.
static constexpr const char * description() noexcept
Returns description attribute.
HeaderType< Byte > dimension_type
Group dimension composite type.
Definition sbepp.hpp:4573
sbepp::type_list< FieldTags... > field_tags
Current-level field tags in schema order.
Definition sbepp.hpp:4597
HeaderTag dimension_type_tag
Dimension composite tag.
Definition sbepp.hpp:4575
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
GroupType< Byte > value_type
Representation type.
Definition sbepp.hpp:4566
static constexpr const char * semantic_type() noexcept
Returns semanticType attribute.
sbepp::type_list< DataTags... > data_tags
Current-level data tags in schema order.
Definition sbepp.hpp:4601
EntryType< Byte > entry_type
Group entry type.
Definition sbepp.hpp:4582
static constexpr const char * name() noexcept
Returns name attribute.
sbepp::type_list< GroupTags... > group_tags
Current-level group tags in schema order.
Definition sbepp.hpp:4599
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in schema.
Provides various traits/attributes of a <message> element.
Definition sbepp.hpp:4366
static constexpr std::size_t size_bytes(...) noexcept
Returns number of bytes required to represent the message in given configuration.
sbepp::type_list< GroupTags... > group_tags
Top-level group tags in schema order.
Definition sbepp.hpp:4474
static constexpr const char * name() noexcept
Returns name attribute.
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
sbepp::type_list< DataTags... > data_tags
Top-level data tags in schema order.
Definition sbepp.hpp:4476
static constexpr const char * semantic_type() noexcept
Returns semanticType attribute.
SchemaTag schema_tag
Schema tag.
Definition sbepp.hpp:4391
static constexpr const char * description() noexcept
Returns description attribute.
static constexpr block_length_t block_length() noexcept
Returns blockLength attribute.
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in schema.
MessageType< Byte > value_type
Representation type.
Definition sbepp.hpp:4389
sbepp::type_list< FieldTags... > field_tags
Top-level field tags in schema order.
Definition sbepp.hpp:4472
Provides various traits/attributes of a <messageSchema> element.
Definition sbepp.hpp:4124
static constexpr const char * description() noexcept
Returns description attribute.
HeaderTypeTag header_type_tag
Message header composite tag. Can be used to access its traits.
Definition sbepp.hpp:4146
static constexpr version_t version() noexcept
Returns version attribute.
static constexpr const char * package() noexcept
Returns package attribute.
static constexpr const char * semantic_version() noexcept
Returns semanticVersion attribute.
HeaderComposite< Byte > header_type
Message header composite type.
Definition sbepp.hpp:4144
sbepp::type_list< TypeTags... > type_tags
Public schema type tags, unordered.
Definition sbepp.hpp:4148
static constexpr endian byte_order() noexcept
Returns byteOrder attribute.
sbepp::type_list< MessageTags... > message_tags
Schema message tags in schema order.
Definition sbepp.hpp:4150
Provides various traits/attributes of a <choice> element.
Definition sbepp.hpp:4290
static constexpr choice_index_t index() noexcept
Returns choice bit index.
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in schema.
static constexpr const char * name() noexcept
Returns name attribute.
static constexpr const char * description() noexcept
Returns description attribute.
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
Provides various traits/attributes of a <set> element.
Definition sbepp.hpp:4244
static constexpr const char * description() noexcept
Returns description attribute.
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in schema.
sbepp::type_list< ChoiceTags... > choice_tags
Choice tags in schema order.
Definition sbepp.hpp:4272
static constexpr offset_t offset() noexcept
Returns type offset. Available only if offset is static, i.e. not available for public sets whose off...
EncodingTypeTag encoding_type_tag
Tag of the type specified in the encodingType attribute.
Definition sbepp.hpp:4263
SetType value_type
Representation type.
Definition sbepp.hpp:4270
EncodingType encoding_type
Underlying type, e.g. std::uint8_t
Definition sbepp.hpp:4256
static constexpr const char * name() noexcept
Returns name attribute.
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
Provides various traits and attributes of a <type> element.
Definition sbepp.hpp:4043
static constexpr primitive_type min_value() noexcept
Returns minValue. Available only if length() == 1 and presence() != field_presence::constant
static constexpr const char * character_encoding() noexcept
Returns characterEncoding attribute.
ValueType value_type
Representation type.
Definition sbepp.hpp:4049
static constexpr const char * description() noexcept
Returns description attribute.
static constexpr version_t deprecated() noexcept
Returns deprecated attribute. Available only if provided in schema.
PrimitiveType primitive_type
Underlying type.
Definition sbepp.hpp:4046
static constexpr length_t length() noexcept
Returns length attribute.
static constexpr const char * name() noexcept
Returns name attribute.
static constexpr field_presence presence() noexcept
Returns presence.
static constexpr primitive_type max_value() noexcept
Returns maxValue. Available only if length() == 1 and presence() != field_presence::constant
static constexpr const char * semantic_type() noexcept
Returns semanticType attribute.
static constexpr primitive_type null_value() noexcept
Returns nullValue. Available only if length() == 1 and presence() == field_presence::optional
static constexpr offset_t offset() noexcept
Returns type offset. Available only if offset is static, i.e. not available for public types whose of...
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
Concept for sbepp::is_array_type<T>::value
Definition sbepp.hpp:5239
Concept for sbepp::is_composite_tag<Tag>::value
Definition sbepp.hpp:5847
Concept for sbepp::is_composite<T>::value
Definition sbepp.hpp:5267
Concept for sbepp::is_data_tag<Tag>::value
Definition sbepp.hpp:5859
Concept for sbepp::is_data<T>::value
Definition sbepp.hpp:5291
Concept for sbepp::is_enum_tag<Tag>::value
Definition sbepp.hpp:5831
Concept for sbepp::is_enum_value_tag<Tag>::value
Definition sbepp.hpp:5835
Concept for sbepp::is_enum<T>::value
Definition sbepp.hpp:5259
Concept for sbepp::is_field_tag<Tag>::value
Definition sbepp.hpp:5851
Concept for sbepp::is_flat_group<T>::value
Definition sbepp.hpp:5275
Concept for sbepp::is_group_entry<T>::value
Definition sbepp.hpp:5287
Concept for sbepp::is_group_tag<Tag>::value
Definition sbepp.hpp:5855
Concept for sbepp::is_group<T>::value
Definition sbepp.hpp:5283
Concept for sbepp::is_message_tag<Tag>::value
Definition sbepp.hpp:5863
Concept for sbepp::is_message<T>::value
Definition sbepp.hpp:5271
Concept for sbepp::is_nested_group<T>::value
Definition sbepp.hpp:5279
Concept for sbepp::is_non_array_type<T>::value
Definition sbepp.hpp:5251
Concept for sbepp::is_optional_type<T>::value
Definition sbepp.hpp:5247
Concept for sbepp::is_required_type<T>::value
Definition sbepp.hpp:5243
Concept for sbepp::is_schema_tag<Tag>::value
Definition sbepp.hpp:5867
Concept for sbepp::is_set_choice_tag<Tag>::value
Definition sbepp.hpp:5843
Concept for sbepp::is_set_tag<Tag>::value
Definition sbepp.hpp:5839
Concept for sbepp::is_set<T>::value
Definition sbepp.hpp:5263
Concept for sbepp::is_type_tag<Tag>::value
Definition sbepp.hpp:5827
Concept for sbepp::is_type<T>::value
Definition sbepp.hpp:5255
Contains cursor wrappers which allow more precise control over its position.
Definition sbepp.hpp:1658
constexpr detail::skip_cursor_wrapper< Byte > skip(cursor< Byte > &c) noexcept
Returns a wrapper which moves the cursor to the end of field/group/data without returning the accesse...
Definition sbepp.hpp:1740
constexpr detail::dont_move_cursor_wrapper< Byte > dont_move(cursor< Byte > &c) noexcept
Returns a wrapper which doesn't advance the cursor when it's used.
Definition sbepp.hpp:1706
constexpr detail::init_cursor_wrapper< Byte > init(cursor< Byte > &c) noexcept
Returns a wrapper which will initialize the cursor when it's used and advance after the usage.
Definition sbepp.hpp:1677
constexpr detail::init_dont_move_cursor_wrapper< Byte > init_dont_move(cursor< Byte > &c) noexcept
Returns a wrapper which initializes the cursor but doesn't move it. Behaves like a combination of ini...
Definition sbepp.hpp:1720
Namespace for various implementation details. Should not be used directly.
Definition sbepp.hpp:384
The main sbepp namespace.
Definition sbepp.hpp:232
constexpr bool is_required_type_v
Shorthand for sbepp::is_required_type<T>::value
Definition sbepp.hpp:5185
constexpr bool is_message_tag_v
Shorthand for sbepp::is_message_tag<Tag>::value
Definition sbepp.hpp:5817
constexpr bool is_group_tag_v
Shorthand for sbepp::is_group_tag<Tag>::value
Definition sbepp.hpp:5809
constexpr std::underlying_type< Enum >::type to_underlying(Enum e) noexcept
Converts an enumeration to its underlying type. Equivalent to C++23 std::to_underlying()
Definition sbepp.hpp:2839
detail::is_base_of_tmp< detail::optional_base, T > is_optional_type
Checks if T is an optional numeric type.
Definition sbepp.hpp:5045
constexpr View< Byte > make_view(Byte *ptr, const std::size_t size) noexcept
Constructs view from memory buffer.
Definition sbepp.hpp:4942
typename traits_tag< ValueType >::type traits_tag_t
Shorthand for sbepp::traits_tag<T>::type
Definition sbepp.hpp:4692
constexpr bool is_set_tag_v
Shorthand for sbepp::is_set_tag<Tag>::value
Definition sbepp.hpp:5793
constexpr bool is_non_array_type_v
Shorthand for sbepp::is_non_array_type<T>::value
Definition sbepp.hpp:5193
eos_null
Represents number of null bytes that can be added after the end-of-string by detail::static_array_ref...
Definition sbepp.hpp:2907
@ none
Definition sbepp.hpp:2910
@ all
All bytes after the last string character will be set to null.
Definition sbepp.hpp:2916
@ single
Definition sbepp.hpp:2914
constexpr cursor< byte_type_t< View > > init_cursor(View view) noexcept
Initializes cursor from a message/group view with the same byte type.
Definition sbepp.hpp:2858
constexpr auto get_header(T v) noexcept -> decltype(v(detail::get_header_tag{}))
Returns the header of a message/group.
Definition sbepp.hpp:1619
detail::is_base_of_tmp< detail::required_base, T > is_required_type
Checks if T is a required numeric type.
Definition sbepp.hpp:5036
std::integral_constant< bool, is_flat_group< T >::value||is_nested_group< T >::value > is_group
Checks if T is a group of any kind.
Definition sbepp.hpp:5142
detail::is_base_of_tmp< detail::flat_group_base, T > is_flat_group
Checks if T is a flat group.
Definition sbepp.hpp:5124
detail::has_traits< group_traits, Tag > is_group_tag
Checks if Tag is a group tag.
Definition sbepp.hpp:5749
constexpr nullopt_t nullopt
Helper constant used to initialize optional types with null value.
Definition sbepp.hpp:3725
field_presence
Represents presence trait value type, e.g. type_traits::presence()
Definition sbepp.hpp:313
@ constant
field is constant
Definition sbepp.hpp:319
@ required
field is required
Definition sbepp.hpp:315
@ optional
field is optional
Definition sbepp.hpp:317
constexpr bool is_flat_group_v
Shorthand for sbepp::is_flat_group<T>::value
Definition sbepp.hpp:5217
constexpr Visitor && visit_children(View view, Cursor &c, Visitor &&visitor={})
Visits view's children using provided cursor.
Definition sbepp.hpp:5460
constexpr bool is_set_v
Shorthand for sbepp::is_set<T>::value
Definition sbepp.hpp:5205
detail::has_traits< schema_traits, Tag > is_schema_tag
Checks if Tag is a schema tag.
Definition sbepp.hpp:5776
constexpr bool is_group_entry_v
Shorthand for sbepp::is_group_entry<T>::value
Definition sbepp.hpp:5229
detail::has_traits< field_traits, Tag > is_field_tag
Checks if Tag is a field tag.
Definition sbepp.hpp:5740
detail::has_traits< composite_traits, Tag > is_composite_tag
Checks if Tag is a composite tag.
Definition sbepp.hpp:5731
constexpr cursor< typename std::add_const< byte_type_t< View > >::type > init_const_cursor(View view) noexcept
Initializes cursor from a message/group view with const byte type.
Definition sbepp.hpp:2881
constexpr auto fill_message_header(Message m) noexcept -> decltype(m(detail::fill_message_header_tag{}))
Fills message header.
Definition sbepp.hpp:3998
constexpr bool is_group_v
Shorthand for sbepp::is_group<T>::value
Definition sbepp.hpp:5225
constexpr bool is_composite_v
Shorthand for sbepp::is_composite<T>::value
Definition sbepp.hpp:5209
constexpr Visitor && visit(View view, Cursor &c, Visitor &&visitor={})
Visits a view using given cursor.
Definition sbepp.hpp:5320
constexpr auto set_by_tag(ViewOrSet &&viewOrSet, Value &&value) noexcept -> decltype(std::forward< ViewOrSet >(viewOrSet)(detail::access_by_tag_tag{}, Tag{}, std::forward< Value >(value)))
Sets field or set choice value by tag.
Definition sbepp.hpp:5631
constexpr bool is_composite_tag_v
Shorthand for sbepp::is_composite_tag<Tag>::value
Definition sbepp.hpp:5801
std::uint8_t choice_index_t
Represents set_choice_traits::index() value type.
Definition sbepp.hpp:308
typename detail::is_data_impl< T >::type is_data
Checks if T is a data.
Definition sbepp.hpp:5176
typename byte_type< View >::type byte_type_t
Shortcut for byte_type<T>::type
Definition sbepp.hpp:1651
constexpr bool is_enum_tag_v
Shorthand for sbepp::is_enum_tag<Tag>::value
Definition sbepp.hpp:5785
detail::is_base_of_tmp< detail::nested_group_base, T > is_nested_group
Checks if T is a nested group.
Definition sbepp.hpp:5133
constexpr const char * enum_to_string(const E e) noexcept
Converts enum to string.
Definition sbepp.hpp:5567
detail::is_base_of_tmp< detail::message_base, T > is_message
Checks if T is a message.
Definition sbepp.hpp:5115
detail::has_traits< set_choice_traits, Tag > is_set_choice_tag
Checks if Tag is a set choice tag.
Definition sbepp.hpp:5722
detail::has_traits< enum_traits, Tag > is_enum_tag
Checks if Tag is an enum tag.
Definition sbepp.hpp:5693
constexpr bool is_data_v
Shorthand for sbepp::is_data<T>::value
Definition sbepp.hpp:5233
detail::has_traits< set_traits, Tag > is_set_tag
Checks if Tag is a set tag.
Definition sbepp.hpp:5712
constexpr auto fill_group_header(Group g, Size num_in_group) noexcept -> decltype(g(detail::fill_group_header_tag{}, num_in_group))
Fills group header.
Definition sbepp.hpp:4018
constexpr bool is_field_tag_v
Shorthand for sbepp::is_field_tag<Tag>::value
Definition sbepp.hpp:5805
constexpr bool is_type_tag_v
Shorthand for sbepp::is_type_tag<Tag>::value
Definition sbepp.hpp:5781
constexpr auto addressof(T v) noexcept -> decltype(v(detail::addressof_tag{}))
Returns pointer to the underlying data referenced by a view.
Definition sbepp.hpp:1631
std::uint64_t offset_t
Represents offset trait value type, e.g. type_traits::offset()
Definition sbepp.hpp:294
std::uint32_t message_id_t
Represents message_traits::id() value type.
Definition sbepp.hpp:301
void assertion_failed(char const *expr, char const *function, char const *file, long line)
When SBEPP_ASSERT_HANDLER or SBEPP_ENABLE_ASSERTS_WITH_HANDLER is defined, this function is called fo...
constexpr bool is_enum_value_tag_v
Shorthand for sbepp::is_enum_value_tag<Tag>::value
Definition sbepp.hpp:5789
constexpr bool is_array_type_v
Shorthand for sbepp::is_array_type<T>::value
Definition sbepp.hpp:5181
constexpr std::size_t size_bytes(T v) noexcept
Returns the size of the underlying data represented by message/group/entry/data/composite view,...
Definition sbepp.hpp:1592
std::uint64_t version_t
Represents version trait value type, e.g. type_traits::since_version()
Definition sbepp.hpp:297
detail::is_base_of_tmp< detail::bitset_base, T > is_set
Checks if T is a set.
Definition sbepp.hpp:5097
std::integral_constant< bool, is_required_type< T >::value||is_optional_type< T >::value||is_array_type< T >::value > is_type
Checks if T is a type of any kind.
Definition sbepp.hpp:5065
constexpr bool is_type_v
Shorthand for sbepp::is_type<T>::value
Definition sbepp.hpp:5197
constexpr auto visit_set(const Set s, Visitor &&visitor) noexcept -> decltype(s(detail::visit_set_tag{}, std::forward< Visitor >(visitor)))
Visits set choices in order of their declaration.
Definition sbepp.hpp:5585
constexpr default_init_t default_init
Helper to pass default_init_t to dynamic_array_ref::resize().
Definition sbepp.hpp:2902
std::integral_constant< bool, is_required_type< T >::value||is_optional_type< T >::value > is_non_array_type
Checks if T is a numeric type.
Definition sbepp.hpp:5054
constexpr bool is_message_v
Shorthand for sbepp::is_message<T>::value
Definition sbepp.hpp:5213
std::uint16_t member_id_t
Represents id trait value type, e.g. field_traits::id()
Definition sbepp.hpp:306
constexpr auto get_by_tag(ViewOrSet viewOrSet) noexcept -> decltype(viewOrSet(detail::access_by_tag_tag{}, Tag{}))
Gets field or set choice value by tag.
Definition sbepp.hpp:5600
constexpr bool is_set_choice_tag_v
Shorthand for sbepp::is_set_choice_tag<Tag>::value
Definition sbepp.hpp:5797
constexpr bool is_nested_group_v
Shorthand for sbepp::is_nested_group<T>::value
Definition sbepp.hpp:5221
detail::has_traits< type_traits, Tag > is_type_tag
Checks if Tag is a type tag.
Definition sbepp.hpp:5684
std::uint64_t length_t
Represents type_traits::length() value type.
Definition sbepp.hpp:290
detail::has_traits< data_traits, Tag > is_data_tag
Checks if Tag is a data tag.
Definition sbepp.hpp:5758
constexpr size_bytes_checked_result size_bytes_checked(View view, std::size_t size) noexcept
Calculates view size with additional safety checks.
Definition sbepp.hpp:6014
std::uint64_t block_length_t
Represents block_length trait value type, e.g. message_traits::block_length()
Definition sbepp.hpp:304
constexpr bool is_data_tag_v
Shorthand for sbepp::is_data_tag<Tag>::value
Definition sbepp.hpp:5813
constexpr bool is_enum_v
Shorthand for sbepp::is_enum<T>::value
Definition sbepp.hpp:5201
constexpr bool is_optional_type_v
Shorthand for sbepp::is_optional_type<T>::value
Definition sbepp.hpp:5189
detail::is_base_of_tmp< detail::entry_base, T > is_group_entry
Checks if T is a group entry.
Definition sbepp.hpp:5153
std::uint32_t schema_id_t
Represents schema_traits::id() value type.
Definition sbepp.hpp:299
constexpr View< typename std::add_const< Byte >::type > make_const_view(Byte *ptr, const std::size_t size) noexcept
Constructs read-only view from memory buffer.
Definition sbepp.hpp:4967
detail::has_traits< enum_value_traits, Tag > is_enum_value_tag
Checks if Tag is an enum value tag.
Definition sbepp.hpp:5703
endian
Represents schema_traits::byte_order() value type. When SBEPP_HAS_ENDIAN is 1, it's just an alias to ...
Definition sbepp.hpp:337
@ native
current platform endianness
Definition sbepp.hpp:343
@ little
little-endian
Definition sbepp.hpp:339
@ big
big-endian
Definition sbepp.hpp:341
detail::has_traits< message_traits, Tag > is_message_tag
Checks if Tag is a message tag.
Definition sbepp.hpp:5767
typename detail::is_array_type_impl< T >::type is_array_type
Checks if T is an array type.
Definition sbepp.hpp:5027
constexpr bool is_schema_tag_v
Shorthand for sbepp::is_schema_tag<Tag>::value
Definition sbepp.hpp:5821
detail::is_base_of_tmp< detail::composite_base, T > is_composite
Checks if T is a composite.
Definition sbepp.hpp:5106
#define SBEPP_BYTE_ORDER
Must be defined to either little or big when native endianness cannot be detected automatically.
Definition sbepp.hpp:327
Trait to get view's byte type.
Definition sbepp.hpp:1643
typename std::remove_pointer< decltype(sbepp::addressof( std::declval< View >()))>::type type
Holds View byte type.
Definition sbepp.hpp:1645
Tag for dynamic_array_ref::resize(). Used to skip value initialization.
Definition sbepp.hpp:2893
Checks if T is an enumeration.
Definition sbepp.hpp:5078
Tag type used to initialize optional types with null value.
Definition sbepp.hpp:3714
Result type of size_bytes_checked
Definition sbepp.hpp:5872
bool valid
Denotes whether size is valid.
Definition sbepp.hpp:5874
std::size_t size
Calculated size, valid only if valid == true
Definition sbepp.hpp:5876
Maps representation type to its tag.
Definition sbepp.hpp:4684
Tag type
Tag to access ValueType's traits.
Definition sbepp.hpp:4686
An empty structure to represent a sequence of types.
Definition sbepp.hpp:378
Tag for unknown enum values.
Definition sbepp.hpp:4979