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;
4210 static constexpr const char*
name() noexcept;
4219 static constexpr ScopedEnumType
value() noexcept;
4240 static constexpr const char*
name() noexcept;
4279 static constexpr const char*
name() noexcept;
4309 static constexpr const char*
name() noexcept;
4329 template<typename Byte>
4355 static constexpr const char*
name() noexcept;
4374 template<typename Byte>
4483 static constexpr const char*
name() noexcept;
4508 template<typename Byte>
4532 static constexpr const char*
name() noexcept;
4551 template<typename Byte>
4558 template<typename Byte>
4567 template<typename Byte>
4580 static constexpr std::
size_t
4608 static constexpr const char*
name() noexcept;
4623 template<typename Byte>
4635 static constexpr std::
size_t
4663template<
typename ValueType>
4667template<
typename ValueType>
4676template<
typename ValueType>
4679template<
typename Byte,
typename Value, std::
size_t N,
typename Tag>
4686#define SBEPP_BUILT_IN_IMPL(NAME, TYPE, MIN, MAX, NULL) \
4689 class NAME##_t : public detail::required_base<TYPE, NAME##_t> \
4692 using detail::required_base<TYPE, NAME##_t>::required_base; \
4695 static constexpr value_type min_value() noexcept \
4701 static constexpr value_type max_value() noexcept \
4709 class NAME##_opt_t : public detail::optional_base<TYPE, NAME##_opt_t> \
4712 using detail::optional_base<TYPE, NAME##_opt_t>::optional_base; \
4715 static constexpr value_type min_value() noexcept \
4721 static constexpr value_type max_value() noexcept \
4727 static constexpr value_type null_value() noexcept \
4734 class type_traits<NAME##_t> \
4737 static constexpr const char* name() noexcept \
4742 static constexpr const char* description() noexcept \
4747 static constexpr field_presence presence() noexcept \
4749 return field_presence::required; \
4752 static constexpr TYPE min_value() noexcept \
4754 return NAME##_t::min_value(); \
4757 static constexpr TYPE max_value() noexcept \
4759 return NAME##_t::max_value(); \
4762 static constexpr length_t length() noexcept \
4767 static constexpr const char* semantic_type() noexcept \
4772 static constexpr version_t since_version() noexcept \
4777 using value_type = NAME##_t; \
4778 using primitive_type = value_type::value_type; \
4782 struct traits_tag<NAME##_t> \
4784 using type = NAME##_t; \
4788 class type_traits<NAME##_opt_t> \
4791 static constexpr const char* name() noexcept \
4796 static constexpr const char* description() noexcept \
4801 static constexpr field_presence presence() noexcept \
4803 return field_presence::optional; \
4806 static constexpr TYPE min_value() noexcept \
4808 return NAME##_opt_t::min_value(); \
4811 static constexpr TYPE max_value() noexcept \
4813 return NAME##_opt_t::max_value(); \
4816 static constexpr TYPE null_value() noexcept \
4818 return NAME##_opt_t::null_value(); \
4821 static constexpr length_t length() noexcept \
4826 static constexpr const char* semantic_type() noexcept \
4831 static constexpr version_t since_version() noexcept \
4836 using value_type = NAME##_opt_t; \
4837 using primitive_type = value_type::value_type; \
4841 struct traits_tag<NAME##_opt_t> \
4843 using type = NAME##_opt_t; \
4846SBEPP_BUILT_IN_IMPL(
char,
char, 0x20, 0x7E, 0);
4850 std::numeric_limits<std::int8_t>::min() + 1,
4851 std::numeric_limits<std::int8_t>::max(),
4852 std::numeric_limits<std::int8_t>::min());
4856 std::numeric_limits<std::uint8_t>::min(),
4857 std::numeric_limits<std::uint8_t>::max() - 1,
4858 std::numeric_limits<std::uint8_t>::max());
4862 std::numeric_limits<std::int16_t>::min() + 1,
4863 std::numeric_limits<std::int16_t>::max(),
4864 std::numeric_limits<std::int16_t>::min());
4868 std::numeric_limits<std::uint16_t>::min(),
4869 std::numeric_limits<std::uint16_t>::max() - 1,
4870 std::numeric_limits<std::uint16_t>::max());
4874 std::numeric_limits<std::int32_t>::min() + 1,
4875 std::numeric_limits<std::int32_t>::max(),
4876 std::numeric_limits<std::int32_t>::min());
4880 std::numeric_limits<std::uint32_t>::min(),
4881 std::numeric_limits<std::uint32_t>::max() - 1,
4882 std::numeric_limits<std::uint32_t>::max());
4886 std::numeric_limits<std::int64_t>::min() + 1,
4887 std::numeric_limits<std::int64_t>::max(),
4888 std::numeric_limits<std::int64_t>::min());
4892 std::numeric_limits<std::uint64_t>::min(),
4893 std::numeric_limits<std::uint64_t>::max() - 1,
4894 std::numeric_limits<std::uint64_t>::max());
4898 std::numeric_limits<float>::min(),
4899 std::numeric_limits<float>::max(),
4900 std::numeric_limits<float>::quiet_NaN());
4904 std::numeric_limits<double>::min(),
4905 std::numeric_limits<double>::max(),
4906 std::numeric_limits<double>::quiet_NaN());
4908#undef SBEPP_BUILT_IN_IMPL
4927template<
template<
typename>
class View,
typename Byte>
4928constexpr View<Byte>
make_view(Byte* ptr,
const std::size_t size)
noexcept
4951template<
template<
typename>
class View,
typename Byte>
4952constexpr View<typename std::add_const<Byte>::type>
4971template<
template<
typename...>
class Base,
typename Derived>
4972struct is_base_of_tmp_impl
4974 static constexpr std::false_type test(...);
4976 template<
typename... Ts>
4977 static constexpr std::true_type test(Base<Ts...>*);
4979 using type =
decltype(test(std::declval<Derived*>()));
4982template<
template<
typename...>
class Base,
typename Derived>
4983using is_base_of_tmp =
typename is_base_of_tmp_impl<Base, Derived>::type;
4985#if SBEPP_HAS_CONCEPTS
4986template<
typename Derived,
template<
typename...>
class Base>
4987concept derived_from_tmp = is_base_of_tmp<Base, Derived>::value;
4993template<
typename Derived>
4994struct is_array_type_impl
4996 static constexpr std::false_type test(...);
4998 template<
typename T1,
typename T2, std::
size_t N,
typename T3>
4999 static constexpr std::true_type
5000 test(detail::static_array_ref<T1, T2, N, T3>*);
5002 using type =
decltype(test(std::declval<Derived*>()));
5008using is_array_type =
typename detail::is_array_type_impl<T>::type;
5026using is_type = std::integral_constant<
5032template<
typename T,
typename =
void>
5033struct is_enum : std::false_type
5040 detail::void_t<decltype(tag_invoke(
5041 std::declval<detail::visit_tag>(),
5043 std::declval<int&>()))>> : std::true_type
5049using is_set = detail::is_base_of_tmp<detail::bitset_base, T>;
5053using is_composite = detail::is_base_of_tmp<detail::composite_base, T>;
5057using is_message = detail::is_base_of_tmp<detail::message_base, T>;
5061using is_flat_group = detail::is_base_of_tmp<detail::flat_group_base, T>;
5065using is_nested_group = detail::is_base_of_tmp<detail::nested_group_base, T>;
5069using is_group = std::integral_constant<
5075using is_group_entry = detail::is_base_of_tmp<detail::entry_base, T>;
5079template<
typename Derived>
5082 static constexpr std::false_type test(...);
5084 template<
typename T1,
typename T2,
typename T3, endian E>
5085 static constexpr std::true_type
5088 using type =
decltype(test(std::declval<Derived*>()));
5094using is_data =
typename detail::is_data_impl<T>::type;
5096#if SBEPP_HAS_INLINE_VARS
5150#if SBEPP_HAS_CONCEPTS
5207using is_cursor_visitable_view = std::integral_constant<
5228 detail::enable_if_t<detail::is_cursor_visitable_view<View>::value>>
5229SBEPP_CPP14_CONSTEXPR Visitor&&
5230 visit(View view, Cursor& c, Visitor&& visitor = {})
5232 view(detail::visit_tag{}, visitor, c);
5233 return std::forward<Visitor>(visitor);
5250 detail::enable_if_t<detail::is_cursor_visitable_view<View>::value>>
5251SBEPP_CPP14_CONSTEXPR Visitor&&
visit(View view, Visitor&& visitor = {})
5254 return sbepp::visit(view, c, std::forward<Visitor>(visitor));
5257#ifndef SBEPP_DOXYGEN
5258template<
typename Visitor,
typename SetOrComposite>
5259SBEPP_CPP14_CONSTEXPR detail::enable_if_t<
5260 is_set<SetOrComposite>::value || is_composite<SetOrComposite>::value,
5262 visit(SetOrComposite setOrComposite, Visitor&& visitor = {})
5264 setOrComposite(detail::visit_tag{}, visitor);
5265 return std::forward<Visitor>(visitor);
5268template<
typename Visitor,
typename Enum>
5269SBEPP_CPP14_CONSTEXPR detail::enable_if_t<is_enum<Enum>::value, Visitor&&>
5270 visit(Enum e, Visitor&& visitor = {})
5272 tag_invoke(detail::visit_tag{}, e, visitor);
5273 return std::forward<Visitor>(visitor);
5288template<
typename Visitor,
typename Composite>
5289SBEPP_CPP14_CONSTEXPR Visitor&&
visit(Composite view, Visitor&& visitor = {});
5307template<
typename Visitor,
typename Set>
5308SBEPP_CPP14_CONSTEXPR Visitor&&
visit(Set s, Visitor&& visitor = {});
5326template<
typename Visitor,
typename Enum>
5327SBEPP_CPP14_CONSTEXPR Visitor&&
visit(Enum e, Visitor&& visitor = {});
5343template<
typename Visitor,
typename View,
typename Cursor>
5344SBEPP_DEPRECATED SBEPP_CPP14_CONSTEXPR
5345 detail::enable_if_t<is_composite<View>::value, Visitor&&>
5346 visit(View view, Cursor& c, Visitor&& visitor = {})
5349 return sbepp::visit(view, std::forward<Visitor>(visitor));
5368 detail::enable_if_t<detail::is_cursor_visitable_view<View>::value>>
5369SBEPP_CPP14_CONSTEXPR Visitor&&
5372 view(detail::visit_children_tag{}, visitor, c);
5373 return std::forward<Visitor>(visitor);
5390 detail::enable_if_t<detail::is_cursor_visitable_view<View>::value>>
5391SBEPP_CPP14_CONSTEXPR Visitor&&
5408template<
typename Visitor,
typename View>
5409SBEPP_CPP14_CONSTEXPR detail::enable_if_t<is_composite<View>::value, Visitor&&>
5412 view(detail::visit_children_tag{}, visitor);
5413 return std::forward<Visitor>(visitor);
5429template<
typename Visitor,
typename View,
typename Cursor>
5430SBEPP_DEPRECATED SBEPP_CPP14_CONSTEXPR
5431 detail::enable_if_t<is_composite<View>::value, Visitor&&>
5435 return visit_children(view, std::forward<Visitor>(visitor));
5440class enum_to_string_visitor
5443 template<
typename Enum,
typename Tag>
5444 SBEPP_CPP14_CONSTEXPR
void on_enum_value(Enum , Tag)
noexcept
5449 template<
typename Enum>
5450 SBEPP_CPP14_CONSTEXPR
void
5451 on_enum_value(Enum , sbepp::unknown_enum_value_tag)
noexcept
5453 name_value =
nullptr;
5456 constexpr const char* name() const noexcept
5462 const char* name_value;
5476template<typename E, typename = detail::enable_if_t<is_enum<E>::value>>
5477SBEPP_DEPRECATED
constexpr const char*
enum_to_string(
const E e)
noexcept
5493template<
typename Set,
typename Visitor>
5494SBEPP_DEPRECATED
constexpr auto
5495 visit_set(
const Set s, Visitor&& visitor)
noexcept
5496 ->
decltype(s(detail::visit_set_tag{}, std::forward<Visitor>(visitor)))
5498 return s(detail::visit_set_tag{}, std::forward<Visitor>(visitor));
5503class size_bytes_checked_visitor
5506 constexpr explicit size_bytes_checked_visitor(
5507 const std::size_t size) noexcept
5512 template<
typename T,
typename Cursor,
typename Tag>
5513 SBEPP_CPP14_CONSTEXPR
void on_message(T m, Cursor& c, Tag)
noexcept
5517 if(!validate_and_subtract(header_size))
5522 if(!validate_and_subtract(*header.blockLength()))
5530 template<
typename T,
typename Cursor,
typename Tag>
5531 SBEPP_CPP14_CONSTEXPR
bool on_group(T g, Cursor& c, Tag)
noexcept
5535 if(!validate_and_subtract(header_size))
5540 const auto prev_block_length =
5541 set_group_block_length(*header.blockLength());
5543 set_group_block_length(prev_block_length);
5548 template<
typename T,
typename Cursor>
5549 SBEPP_CPP14_CONSTEXPR
bool on_entry(T e, Cursor& c)
noexcept
5551 if(!validate_and_subtract(group_block_length))
5559 template<
typename T,
typename Tag>
5560 SBEPP_CPP14_CONSTEXPR
bool on_data(T d, Tag)
noexcept
5566 template<
typename T,
typename Tag>
5567 constexpr bool on_field(T, Tag)
const noexcept
5572 constexpr bool is_valid() const noexcept
5578 SBEPP_CPP14_CONSTEXPR std::size_t
5579 set_group_block_length(
const std::size_t block_length)
noexcept
5581 auto prev = group_block_length;
5582 group_block_length = block_length;
5586 constexpr std::size_t get_size() const noexcept
5595 std::size_t group_block_length{};
5597 SBEPP_CPP14_CONSTEXPR
bool
5598 validate_and_subtract(
const std::size_t n)
noexcept
5633template<
typename View>
5643 detail::size_bytes_checked_visitor visitor{size};
5646 if(visitor.is_valid())
5648 return {
true, size - visitor.get_size()};
5661template<
typename Tag,
typename ViewOrSet>
5662constexpr auto get_by_tag(ViewOrSet viewOrSet)
noexcept
5663 ->
decltype(viewOrSet(detail::access_by_tag_tag{}, Tag{}))
5665 return viewOrSet(detail::access_by_tag_tag{}, Tag{});
5676template<
typename Tag,
typename View,
typename Cursor>
5677constexpr auto get_by_tag(View view, Cursor&& c)
noexcept ->
decltype(view(
5678 detail::access_by_tag_tag{}, Tag{}, std::forward<Cursor>(c)))
5680 return view(detail::access_by_tag_tag{}, Tag{}, std::forward<Cursor>(c));
5692template<
typename Tag,
typename ViewOrSet,
typename Value>
5693constexpr auto set_by_tag(ViewOrSet&& viewOrSet, Value&& value)
noexcept
5694 ->
decltype(std::forward<ViewOrSet>(viewOrSet)(
5695 detail::access_by_tag_tag{}, Tag{}, std::forward<Value>(value)))
5697 return std::forward<ViewOrSet>(viewOrSet)(
5698 detail::access_by_tag_tag{}, Tag{}, std::forward<Value>(value));
5711template<
typename Tag,
typename View,
typename Value,
typename Cursor>
5712constexpr auto set_by_tag(View view, Value&& value, Cursor&& c)
5714 detail::access_by_tag_tag{},
5716 std::forward<Value>(value),
5717 std::forward<Cursor>(c)))
5720 detail::access_by_tag_tag{},
5722 std::forward<Value>(value),
5723 std::forward<Cursor>(c));
5728template<
template<
typename>
class Trait,
typename T,
typename = void_t<>>
5729struct has_traits : std::false_type
5733template<
template<
typename>
class Trait,
typename T>
5734struct has_traits<Trait, T, void_t<decltype(Trait<T>{})>> : std::true_type
5744template<
typename Tag>
5745using is_type_tag = detail::has_traits<type_traits, Tag>;
5752template<
typename Tag>
5753using is_enum_tag = detail::has_traits<enum_traits, Tag>;
5760template<
typename Tag>
5768template<
typename Tag>
5769using is_set_tag = detail::has_traits<set_traits, Tag>;
5776template<
typename Tag>
5784template<
typename Tag>
5792template<
typename Tag>
5793using is_field_tag = detail::has_traits<field_traits, Tag>;
5800template<
typename Tag>
5801using is_group_tag = detail::has_traits<group_traits, Tag>;
5808template<
typename Tag>
5809using is_data_tag = detail::has_traits<data_traits, Tag>;
5816template<
typename Tag>
5824template<
typename Tag>
5825using is_schema_tag = detail::has_traits<schema_traits, Tag>;
5827#if SBEPP_HAS_INLINE_VARS
5829template<
typename Tag>
5833template<
typename Tag>
5837template<
typename Tag>
5841template<
typename Tag>
5845template<
typename Tag>
5849template<
typename Tag>
5853template<
typename Tag>
5857template<
typename Tag>
5861template<
typename Tag>
5865template<
typename Tag>
5869template<
typename Tag>
5873#if SBEPP_HAS_CONCEPTS
5875template<
typename Tag>
5879template<
typename Tag>
5883template<
typename Tag>
5887template<
typename Tag>
5891template<
typename Tag>
5895template<
typename Tag>
5899template<
typename Tag>
5903template<
typename Tag>
5907template<
typename Tag>
5911template<
typename Tag>
5915template<
typename Tag>
5920#if SBEPP_HAS_RANGES && SBEPP_HAS_CONCEPTS
5922template<
typename Byte,
typename Value, std::
size_t N,
typename Tag>
5923inline constexpr bool std::ranges::enable_borrowed_range<
5926template<
typename Byte,
typename Value,
typename Length, sbepp::endian E>
5927inline constexpr bool std::ranges::enable_borrowed_range<
5930template<sbepp::detail::derived_from_tmp<sbepp::detail::flat_group_base> T>
5931inline constexpr bool std::ranges::enable_borrowed_range<T> =
true;
5933template<sbepp::detail::derived_from_tmp<sbepp::detail::nested_group_base> T>
5934inline constexpr bool std::ranges::enable_borrowed_range<T> =
true;
5937#undef SBEPP_CPP17_INLINE_VAR
5938#undef SBEPP_DEPRECATED
5939#undef SBEPP_CPLUSPLUS
Provides various traits/attributes of a <composite> element.
Definition sbepp.hpp:4306
CompositeType< Byte > value_type
Representation type.
Definition sbepp.hpp:4330
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 addedSince attribute.
sbepp::type_list< ElementTags... > element_tags
Element tags in schema order.
Definition sbepp.hpp:4334
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:4605
static constexpr const char * name() noexcept
Returns name attribute.
DataType value_type
Representation type.
Definition sbepp.hpp:4624
static constexpr version_t since_version() noexcept
Returns addedSince 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:4628
LengthType length_type
Length type.
Definition sbepp.hpp:4626
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.
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:4189
static constexpr const char * name() noexcept
Returns name attribute.
ScopedEnumType value_type
Representation type.
Definition sbepp.hpp:4187
static constexpr version_t since_version() noexcept
Returns sinceVersion attribute.
Provides various traits/attributes of a <validValue> element.
Definition sbepp.hpp:4207
static constexpr ScopedEnumType value() noexcept
Returns enumerator value.
static constexpr version_t since_version() noexcept
Returns addedSince 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:4480
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 addedSince 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:4502
TypeTag value_type_tag
value_type's tag. Not available for constants of numeric types
Definition sbepp.hpp:4511
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:4529
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:4559
sbepp::type_list< FieldTags... > field_tags
Current-level field tags in schema order.
Definition sbepp.hpp:4583
HeaderTag dimension_type_tag
Dimension composite tag.
Definition sbepp.hpp:4561
static constexpr version_t since_version() noexcept
Returns addedSince attribute.
GroupType< Byte > value_type
Representation type.
Definition sbepp.hpp:4552
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:4587
EntryType< Byte > entry_type
Group entry type.
Definition sbepp.hpp:4568
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:4585
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:4352
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:4460
static constexpr const char * name() noexcept
Returns name attribute.
static constexpr version_t since_version() noexcept
Returns addedSince attribute.
sbepp::type_list< DataTags... > data_tags
Top-level data tags in schema order.
Definition sbepp.hpp:4462
static constexpr const char * semantic_type() noexcept
Returns semanticType attribute.
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:4375
sbepp::type_list< FieldTags... > field_tags
Top-level field tags in schema order.
Definition sbepp.hpp:4458
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:4276
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 addedSince attribute.
Provides various traits/attributes of a <set> element.
Definition sbepp.hpp:4237
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:4258
static constexpr offset_t offset() noexcept
Returns type offset. Available only if offset is static, i.e. not available for public sets whose off...
SetType value_type
Representation type.
Definition sbepp.hpp:4256
EncodingType encoding_type
Underlying type.
Definition sbepp.hpp:4249
static constexpr const char * name() noexcept
Returns name attribute.
static constexpr version_t since_version() noexcept
Returns addedSince 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:5152
Concept for sbepp::is_composite_tag<Tag>::value
Definition sbepp.hpp:5895
Concept for sbepp::is_composite<T>::value
Definition sbepp.hpp:5180
Concept for sbepp::is_data_tag<Tag>::value
Definition sbepp.hpp:5907
Concept for sbepp::is_data<T>::value
Definition sbepp.hpp:5200
Concept for sbepp::is_enum_tag<Tag>::value
Definition sbepp.hpp:5879
Concept for sbepp::is_enum_value_tag<Tag>::value
Definition sbepp.hpp:5883
Concept for sbepp::is_enum<T>::value
Definition sbepp.hpp:5172
Concept for sbepp::is_field_tag<Tag>::value
Definition sbepp.hpp:5899
Concept for sbepp::is_flat_group<T>::value
Definition sbepp.hpp:5188
Concept for sbepp::is_group_tag<Tag>::value
Definition sbepp.hpp:5903
Concept for sbepp::is_group<T>::value
Definition sbepp.hpp:5196
Concept for sbepp::is_message_tag<Tag>::value
Definition sbepp.hpp:5911
Concept for sbepp::is_message<T>::value
Definition sbepp.hpp:5184
Concept for sbepp::is_nested_group<T>::value
Definition sbepp.hpp:5192
Concept for sbepp::is_non_array_type<T>::value
Definition sbepp.hpp:5164
Concept for sbepp::is_optional_type<T>::value
Definition sbepp.hpp:5160
Concept for sbepp::is_required_type<T>::value
Definition sbepp.hpp:5156
Concept for sbepp::is_schema_tag<Tag>::value
Definition sbepp.hpp:5915
Concept for sbepp::is_set_choice_tag<Tag>::value
Definition sbepp.hpp:5891
Concept for sbepp::is_set_tag<Tag>::value
Definition sbepp.hpp:5887
Concept for sbepp::is_set<T>::value
Definition sbepp.hpp:5176
Concept for sbepp::is_type_tag<Tag>::value
Definition sbepp.hpp:5875
Concept for sbepp::is_type<T>::value
Definition sbepp.hpp:5168
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 auto is_composite_v
Shorthand for sbepp::is_composite<T>::value
Definition sbepp.hpp:5126
constexpr auto is_required_type_v
Shorthand for sbepp::is_required_type<T>::value
Definition sbepp.hpp:5102
constexpr auto is_type_v
Shorthand for sbepp::is_type<T>::value
Definition sbepp.hpp:5114
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 a non-array optional type.
Definition sbepp.hpp:5015
constexpr View< Byte > make_view(Byte *ptr, const std::size_t size) noexcept
Constructs view from memory buffer.
Definition sbepp.hpp:4927
typename traits_tag< ValueType >::type traits_tag_t
Shorthand for sbepp::traits_tag<T>::type
Definition sbepp.hpp:4677
constexpr auto is_flat_group_v
Shorthand for sbepp::is_flat_group<T>::value
Definition sbepp.hpp:5134
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 non-array required type.
Definition sbepp.hpp:5011
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:5068
detail::is_base_of_tmp< detail::flat_group_base, T > is_flat_group
Checks if T is a flat group.
Definition sbepp.hpp:5060
detail::has_traits< group_traits, Tag > is_group_tag
Checks if Tag is a group tag.
Definition sbepp.hpp:5800
constexpr auto is_array_type_v
Shorthand for sbepp::is_array_type<T>::value
Definition sbepp.hpp:5098
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 Visitor && visit_children(View view, Cursor &c, Visitor &&visitor={})
Visits view's children using provided cursor.
Definition sbepp.hpp:5369
constexpr auto is_group_tag_v
Shorthand for sbepp::is_group_tag<Tag>::value
Definition sbepp.hpp:5857
constexpr auto is_enum_v
Shorthand for sbepp::is_enum<T>::value
Definition sbepp.hpp:5118
detail::has_traits< schema_traits, Tag > is_schema_tag
Checks if Tag is a schema tag.
Definition sbepp.hpp:5824
detail::has_traits< field_traits, Tag > is_field_tag
Checks if Tag is a field tag.
Definition sbepp.hpp:5792
detail::has_traits< composite_traits, Tag > is_composite_tag
Checks if Tag is a composite tag.
Definition sbepp.hpp:5784
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 auto is_non_array_type_v
Shorthand for sbepp::is_non_array_type<T>::value
Definition sbepp.hpp:5110
constexpr auto is_field_tag_v
Shorthand for sbepp::is_field_tag<Tag>::value
Definition sbepp.hpp:5853
constexpr Visitor && visit(View view, Cursor &c, Visitor &&visitor={})
Visits a view using given cursor.
Definition sbepp.hpp:5229
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:5692
constexpr auto is_set_choice_tag_v
Shorthand for sbepp::is_set_choice_tag<Tag>::value
Definition sbepp.hpp:5845
constexpr auto is_message_tag_v
Shorthand for sbepp::is_message_tag<Tag>::value
Definition sbepp.hpp:5865
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:5093
typename byte_type< View >::type byte_type_t
Shortcut for byte_type<T>::type
Definition sbepp.hpp:1651
constexpr auto is_data_tag_v
Shorthand for sbepp::is_data_tag<Tag>::value
Definition sbepp.hpp:5861
detail::is_base_of_tmp< detail::nested_group_base, T > is_nested_group
Checks if T is a nested group.
Definition sbepp.hpp:5064
constexpr const char * enum_to_string(const E e) noexcept
Converts enum to string.
Definition sbepp.hpp:5476
detail::is_base_of_tmp< detail::message_base, T > is_message
Checks if T is a message.
Definition sbepp.hpp:5056
detail::has_traits< set_choice_traits, Tag > is_set_choice_tag
Checks if Tag is a set choice tag.
Definition sbepp.hpp:5776
detail::has_traits< enum_traits, Tag > is_enum_tag
Checks if Tag is an enum tag.
Definition sbepp.hpp:5752
detail::has_traits< set_traits, Tag > is_set_tag
Checks if Tag is a set tag.
Definition sbepp.hpp:5768
constexpr auto is_enum_value_tag_v
Shorthand for sbepp::is_enum_value_tag<Tag>::value
Definition sbepp.hpp:5837
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 auto is_composite_tag_v
Shorthand for sbepp::is_composite_tag<Tag>::value
Definition sbepp.hpp:5849
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 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:5048
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:5025
constexpr auto is_group_v
Shorthand for sbepp::is_group<T>::value
Definition sbepp.hpp:5142
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:5494
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 non-array type.
Definition sbepp.hpp:5019
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:5661
constexpr auto is_optional_type_v
Shorthand for sbepp::is_optional_type<T>::value
Definition sbepp.hpp:5106
detail::has_traits< type_traits, Tag > is_type_tag
Checks if Tag is a type tag.
Definition sbepp.hpp:5744
std::uint64_t length_t
Represents type_traits::length() value type.
Definition sbepp.hpp:290
constexpr auto is_set_tag_v
Shorthand for sbepp::is_set_tag<Tag>::value
Definition sbepp.hpp:5841
detail::has_traits< data_traits, Tag > is_data_tag
Checks if Tag is a data tag.
Definition sbepp.hpp:5808
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:5634
constexpr auto is_message_v
Shorthand for sbepp::is_message<T>::value
Definition sbepp.hpp:5130
std::uint64_t block_length_t
Represents block_length trait value type, e.g. message_traits::block_length()
Definition sbepp.hpp:304
constexpr auto is_schema_tag_v
Shorthand for sbepp::is_schema_tag<Tag>::value
Definition sbepp.hpp:5869
constexpr auto is_enum_tag_v
Shorthand for sbepp::is_enum_tag<Tag>::value
Definition sbepp.hpp:5833
constexpr auto is_type_tag_v
Shorthand for sbepp::is_type_tag<Tag>::value
Definition sbepp.hpp:5829
constexpr auto is_set_v
Shorthand for sbepp::is_set<T>::value
Definition sbepp.hpp:5122
detail::is_base_of_tmp< detail::entry_base, T > is_group_entry
Checks if T is a group entry.
Definition sbepp.hpp:5074
std::uint32_t schema_id_t
Represents schema_traits::id() value type.
Definition sbepp.hpp:299
constexpr auto is_nested_group_v
Shorthand for sbepp::is_nested_group<T>::value
Definition sbepp.hpp:5138
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:4952
constexpr auto is_data_v
Shorthand for sbepp::is_data<T>::value
Definition sbepp.hpp:5146
detail::has_traits< enum_value_traits, Tag > is_enum_value_tag
Checks if Tag is an enum value tag.
Definition sbepp.hpp:5760
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:5816
typename detail::is_array_type_impl< T >::type is_array_type
Checks is T is an array type.
Definition sbepp.hpp:5007
detail::is_base_of_tmp< detail::composite_base, T > is_composite
Checks if T is a composite.
Definition sbepp.hpp:5052
#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:5033
Tag type used to initialize optional types with null value.
Definition sbepp.hpp:3714
Result type of size_bytes_checked
Definition sbepp.hpp:5615
bool valid
Denotes whether size is valid.
Definition sbepp.hpp:5617
std::size_t size
Calculated size, valid only if valid == true
Definition sbepp.hpp:5619
Maps representation type to its tag.
Definition sbepp.hpp:4669
Tag type
Tag to access ValueType's traits.
Definition sbepp.hpp:4671
An empty structure to represent a sequence of types.
Definition sbepp.hpp:378
Tag for unknown enum values.
Definition sbepp.hpp:4964