OnixS C++ ICE Binary Order Entry Handler 1.0.0
API Documentation
Loading...
Searching...
No Matches
SbeMessage.h
Go to the documentation of this file.
1// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
2//
3// This software owned by Onix Solutions Limited [OnixS] and is
4// protected by copyright law and international copyright treaties.
5//
6// Access to and use of the software is governed by the terms of the applicable
7// OnixS Software Services Agreement (the Agreement) and Customer end user license
8// agreements granting a non-assignable, non-transferable and non-exclusive license
9// to use the software for it's own data processing purposes under the terms defined
10// in the Agreement.
11//
12// Except as otherwise granted within the terms of the Agreement, copying or
13// reproduction of any part of this source code or associated reference material
14// to any other location for further reproduction or redistribution, and any
15// amendments to this copyright notice, are expressly prohibited.
16//
17// Any reproduction or redistribution for sale or hiring of the Software not in
18// accordance with the terms of the Agreement is a violation of copyright law.
19//
20
21#pragma once
22
23#include <OnixS/ICE/BOE/ABI.h>
33
34#include <cassert>
35#include <limits>
36#include <stdexcept>
37
39
41typedef
42MessageHeader::TemplateId MessageTemplateId;
43
44template<typename Message> inline
45void checkBinaryLength(const Message&, MessageSize length, MessageSize minimalRequiredLength)
46{
47 if ONIXS_ICEBOE_UNLIKELY(length < minimalRequiredLength)
48 throwBinaryBlockIsTooSmall(length, minimalRequiredLength, Message::className());
49}
50
51
53{
54protected:
55 ~BinaryBlockBase() = default;
56};
57
63template < class Container, class BlockLength >
65{
67 const Container& container() const noexcept
68 {
69 return *static_cast <const Container*> (this);
70 }
71
72protected:
74 BinaryBlock() = default;
75
76 ~BinaryBlock() = default;
77
79 template <typename Value>
80 ONIXS_ICEBOE_FORCEINLINE
81 Value ordinary(BlockLength offset) const noexcept
82 {
83 assert(container().blockLength() >= (offset + size<Value>()) && "The requested field exceeds provided block boundaries.");
84
85 const void* const location = advanceByBytes(container().block(), offset);
86 return getValue<Value>(location);
87 }
88
89 template <typename NullValue>
90 ONIXS_ICEBOE_FORCEINLINE
91 typename std::enable_if<!isComposite<typename NullValue::Value>::value, SbeOptional<typename NullValue::Value, NullValue>>::type
92 ordinary(BlockLength offset, OptionalTag) const noexcept
93 {
95 }
96
97 template <typename NullValue>
98 ONIXS_ICEBOE_FORCEINLINE
99 typename std::enable_if<!isComposite<typename NullValue::Value>::value, SbeOptional<typename NullValue::Value, NullValue>>::type
100 ordinary(BlockLength offset, SchemaVersion since, OptionalTag) const noexcept
101 {
102 using Value = typename NullValue::Value;
103
104 if(since > container().version())
106
107 return {ordinary<Value>(offset)};
108 }
109
110 template <typename NullValue>
111 ONIXS_ICEBOE_FORCEINLINE
112 typename std::enable_if<isComposite<typename NullValue::Value>::value, SbeOptional<typename NullValue::Value, NullValue>>::type
113 ordinary(BlockLength offset, OptionalTag) const noexcept
114 {
115 using Value = typename NullValue::Value;
116
117 assert(container().blockLength() >= (offset + size<Value>()) && "The requested field exceeds provided block boundaries.");
118
119 using RetType = SbeOptional<Value, NullValue>;
120
121 const void* const location = advanceByBytes(container().block(), offset);
122 return makeFromTuple<RetType>(CompositeExtractor<Value::MemberTraits::Count>:: template extractAsTuple<Value>(location));
123 }
124
125 template <typename NullValue>
126 ONIXS_ICEBOE_FORCEINLINE
127 typename std::enable_if<isComposite<typename NullValue::Value>::value, SbeOptional<typename NullValue::Value, NullValue>>::type
128 ordinary(BlockLength offset, SchemaVersion since, OptionalTag) const noexcept
129 {
131
132 if(since > container().version())
133 return RetType::null();
134
135 return ordinary<NullValue>(offset, optional);
136 }
137
139 template <typename Enumeration>
140 ONIXS_ICEBOE_FORCEINLINE
141 Enumeration enumeration(BlockLength offset) const noexcept
142 {
143 using Base = typename underlyingType<Enumeration>::type;
144 return static_cast<Enumeration>(ordinary<Base>(offset));
145 }
146
148 template <typename Enumeration, typename NullValue>
149 ONIXS_ICEBOE_FORCEINLINE
151 {
152 using Base = typename underlyingType<Enumeration>::type;
153 return {static_cast<Enumeration>(ordinary<Base>(offset))};
154 }
155
157 template <typename Enumeration, typename NullValue>
158 ONIXS_ICEBOE_FORCEINLINE
160 {
161 if(since > container().version())
163
165 }
166
168 template <BlockLength Length>
169 ONIXS_ICEBOE_FORCEINLINE
170 StrRef fixedStr(BlockLength offset) const noexcept
171 {
172 assert(container().blockLength() >= (offset + Length) && "The requested field exceeds provided block boundaries.");
173
174 const Char* const text = reinterpret_cast<const Char*>(advanceByBytes(container().block(), offset));
175 return StrRef(text, stringLen<Length>(text));
176 }
177
178 template<BlockLength Length>
179 ONIXS_ICEBOE_FORCEINLINE
180 SbeOptionalStr fixedStr(BlockLength offset, OptionalTag) const noexcept
181 {
182 return {fixedStr<Length>(offset)};
183 }
184
185 template<BlockLength Length>
186 ONIXS_ICEBOE_FORCEINLINE
187 SbeOptionalStr fixedStr(BlockLength offset, SchemaVersion since, OptionalTag) const noexcept
188 {
189 if(since > container().version())
190 return SbeOptionalStr::null();
191
192 return fixedStr<Length>(offset, optional);
193 }
194
195 template <typename Value>
196 ONIXS_ICEBOE_FORCEINLINE
197 Value decimal(BlockLength offset) const noexcept
198 {
199 return ordinary<Value>(offset);
200 }
201
202 template <typename NullValue>
204 ONIXS_ICEBOE_FORCEINLINE
205 decimal(BlockLength offset, OptionalTag) const noexcept
206 {
207 using Value = typename NullValue::Value;
208
209 assert(container().blockLength() >= (offset + size<Value>()) && "The requested field exceeds provided block boundaries.");
210
211 using RetType = SbeOptional<Value, NullValue>;
212 const void* const location = advanceByBytes(container().block(), offset);
213 return makeFromTuple<RetType>(CompositeExtractor<Value::MemberTraits::Count>:: template extractAsTuple<Value>(location));
214 }
215
216 template <typename NullValue>
217 ONIXS_ICEBOE_FORCEINLINE
219 decimal(BlockLength offset, SchemaVersion since, OptionalTag) const noexcept
220 {
221 if(since > container().version())
223
224 return decimal<NullValue>(offset, optional);
225 }
226
227 template <typename NullValue, typename Callable>
228 ONIXS_ICEBOE_FORCEINLINE
229 typename std::enable_if<!isComposite<typename NullValue::Value>::value, SbeOptionalConverted<decltype(std::declval<Callable>()(std::declval<typename ArgType<Callable>::type>()))>>::type
230 convertible(BlockLength offset, OptionalTag) const noexcept(noexcept(Callable::Nothrow))
231 {
232 typedef typename ArgType<Callable>::type InputType;
233 typedef decltype(std::declval<Callable>()(std::declval<InputType>())) ReturnType;
234
235 static_assert(!std::is_convertible<InputType, ReturnType>::value, "Direct conversion can be done.");
236
237 const auto value = ordinary<NullValue>(offset, optional);
238
239 if(!value)
241
242 return SbeOptionalConverted<ReturnType>(Callable{}(*value));
243 }
244
245 template <typename Callable>
246 ONIXS_ICEBOE_FORCEINLINE
247 auto convertible(BlockLength offset) const noexcept(noexcept(Callable::Nothrow))
248 -> decltype(std::declval<Callable>()(std::declval<typename ArgType<Callable>::type>()))
249 {
250 typedef typename ArgType<Callable>::type InputType;
251 return Callable{}(ordinary<InputType>(offset));
252 }
253};
254
259template <class Container, class BlockLength >
260class SbeFields : public BinaryBlock<Container, BlockLength>
261{
262public:
264 ONIXS_ICEBOE_FORCEINLINE
265 Container& container() noexcept
266 {
267 return *static_cast<Container*>(this);
268 }
269
272 void zeroPaddingBytes(BlockLength offset) noexcept
273 {
274 const BlockLength encodedBlockLength = container().blockLength();
275
276 assert(encodedBlockLength >= offset);
277
278 const size_t paddingLength = encodedBlockLength - offset;
279 std::memset(advanceByBytes(container().block(), offset), 0, paddingLength);
280 }
281
283 template<class FieldValue>
284 ONIXS_ICEBOE_FORCEINLINE
285 void setOrdinary(BlockLength offset, FieldValue value) noexcept
286 {
287 assert(container().blockLength() >= (offset + size<FieldValue>()) && "The requested field exceeds provided block boundaries.");
288
289 void* const fieldPos = advanceByBytes(container().block(), offset);
290 setValue(fieldPos, value);
291 }
292
294 template<class FieldValue>
295 ONIXS_ICEBOE_FORCEINLINE
296 void setOrdinary(BlockLength offset, FieldValue value, SchemaVersion since)
297 {
298 if ONIXS_ICEBOE_UNLIKELY(since > container().version())
300
301 setOrdinary(offset, value);
302 }
303
305 template<class Enumeration>
306 ONIXS_ICEBOE_FORCEINLINE
307 void setEnumeration(BlockLength offset, Enumeration value) noexcept
308 {
309 using Base = typename underlyingType<Enumeration>::type;
310 setOrdinary<Base>(offset, static_cast<Base>(value));
311 }
312
314 template<class Enumeration>
315 ONIXS_ICEBOE_FORCEINLINE
316 void setEnumeration(BlockLength offset, Enumeration value, SchemaVersion since)
317 {
318 using Base = typename underlyingType<Enumeration>::type;
319 setOrdinary(offset, static_cast<Base>(value), since);
320 }
321
323 template<BlockLength Size>
324 ONIXS_ICEBOE_FORCEINLINE
325 void setFixedStr(BlockLength offset, StrRef value) noexcept
326 {
327 assert(container().blockLength() >= (offset + Size) && "The requested field exceeds provided block boundaries.");
328 assert(value.size() <= Size && "The string is truncated.");
329
330 void* const fieldPos = advanceByBytes(container().block(), offset);
331 const size_t sizeToCopy = (std::min)(Size, static_cast<BlockLength>(value.size()));
332
333 if(sizeToCopy > 0)
334 std::memcpy(fieldPos, value.data(), sizeToCopy);
335
336 std::memset(advanceByBytes(fieldPos, sizeToCopy), 0, Size - sizeToCopy);
337 }
338
340 template<BlockLength Size>
341 ONIXS_ICEBOE_FORCEINLINE
342 void setFixedStr(BlockLength offset, StrRef value, SchemaVersion since)
343 {
344 if ONIXS_ICEBOE_UNLIKELY(since > container().version())
346
347 setFixedStr<Size>(offset, value);
348 }
349
350protected:
352 SbeFields() = default;
353
354 ~SbeFields() = default;
355};
356
358template <class BodySizeType>
359class SbeGroupEntry : public SbeFields<SbeGroupEntry<BodySizeType>, BodySizeType>
360{
361public:
363 typedef BodySizeType BlockLength;
364
367 : encoded_(nullptr)
368 , size_(0)
369 , version_(0)
370 {
371 }
372
376 : encoded_(encoded)
377 , size_(size)
378 , version_(version)
379 {
380 assert(encoded);
381 }
382
384 bool valid() const noexcept
385 {
386 return (encoded_ != nullptr);
387 }
388
390 const void* encoded() const noexcept
391 {
392 assert(valid());
393
394 return encoded_;
395 }
396
398 void* encoded() noexcept
399 {
400 assert(valid());
401
402 return encoded_;
403 }
404
406 const void* block() const noexcept
407 {
408 assert(valid());
409
410 return encoded_;
411 }
412
414 void* block() noexcept
415 {
416 assert(valid());
417
418 return encoded_;
419 }
420
422 BlockLength blockLength() const noexcept
423 {
424 return size_;
425 }
426
428 SchemaVersion version() const noexcept
429 {
430 return version_;
431 }
432
433 private:
434 void* encoded_;
435 BodySizeType size_;
436 SchemaVersion version_;
437};
438
440template <class EntryType, class BlockLength, class NumInGroup, class Length >
442{
443public:
445 typedef Length EncodedLength;
446
448 typedef EntryType Entry;
449
451 typedef NumInGroup Size;
452
455 {
456 public:
457 typedef EntryType Entry;
459
460 typedef Entry* pointer;
461 typedef Entry& reference;
462
463 typedef ptrdiff_t difference_type;
464
465 typedef std::random_access_iterator_tag iterator_category;
466
468 Iterator() noexcept
469 : entry_(nullptr)
470 , size_(0)
471 , version_(0)
472 {
473 }
474
477 Iterator(void* entry, Size size, SchemaVersion version) noexcept
478 : entry_(entry)
479 , size_(size)
480 , version_(version)
481 {
482 assert(valid());
483 }
484
486 bool valid() const noexcept
487 {
488 return (entry_ != nullptr);
489 }
490
493 Entry get() const
494 {
495 assert(valid());
496
497 return Entry(entry_, size_, version_);
498 }
499
501 Entry operator *() const
502 {
503 return get();
504 }
505
507 bool operator == (const Iterator& other) const noexcept
508 {
509 return entry_ == other.entry_;
510 }
511
513 bool operator !=(const Iterator& other) const noexcept
514 {
515 return entry_ != other.entry_;
516 }
517
519 bool operator < (const Iterator& other) const noexcept
520 {
521 return entry_ < other.entry_;
522 }
523
525 bool operator > (const Iterator& other) const noexcept
526 {
527 return entry_ > other.entry_;
528 }
529
531 Iterator& operator ++()
532 {
533 assert(valid());
534
535 entry_ = advanceByBytes(entry_, size_);
536
537 return *this;
538 }
539
541 Iterator& operator --()
542 {
543 assert(valid());
544
545 entry_ = advanceBackByBytes(entry_, size_);
546
547 return *this;
548 }
549
552 Iterator operator +(difference_type distance) const
553 {
554 assert(valid());
555
556 return Iterator(advanceByBytes(entry_, distance * size_), size_, version_);
557 }
558
561 Iterator operator - (difference_type distance) const
562 {
563 assert(valid());
564
565 return Iterator(advanceBackByBytes(entry_, distance * size_), size_, version_);
566 }
567
568 private:
569 void* entry_;
570 Size size_;
571 SchemaVersion version_;
572 };
573
576 : encoded_(nullptr)
577 , blockLength_(0)
578 , size_(0)
579 , version_(0)
580 {
581 }
582
584 SbeGroupEntries(void* encoded, BlockLength blockLength, Size groupSize, SchemaVersion version) noexcept
585 : encoded_(encoded)
586 , blockLength_(blockLength)
587 , size_(groupSize)
588 , version_(version)
589 {
590 assert(encoded_);
591 assert(blockLength > 0);
592 assert(version != 0);
593 }
594
596 bool valid() const noexcept
597 {
598 return (nullptr != encoded_);
599 }
600
602 bool empty() const noexcept
603 {
604 return (0 == size_);
605 }
606
608 Size size() const noexcept
609 {
610 return size_;
611 }
612
614 Iterator begin() const
615 {
616 return Iterator(encoded(), blockLength_, version_);
617 }
618
620 Iterator end() const
621 {
622 return Iterator(advanceByBytes(encoded(), encodedLength()), blockLength_, version_);
623 }
624
628 Entry operator [](Size index) const
629 {
630 assert(index < size_);
631 assert(encoded_);
632
633 return Entry(advanceByBytes(encoded_, static_cast<ptrdiff_t>(index) * blockLength_), blockLength_, version_);
634 }
635
637 void* encoded() const noexcept
638 {
639 return encoded_;
640 }
641
644 {
645 return (static_cast<EncodedLength>(blockLength_) * static_cast<EncodedLength>(size_) );
646 }
647
649 template<class OtherEntry, class OtherBlockLength, class OtherNumInGroup, class OtherLength >
651 : encoded_(other.encoded_)
652 , blockLength_(other.blockLength_)
653 , size_(other.size_)
654 , version_(other.version_)
655 {
656 // Dimension types may vary for the different instantiations of the template.
657 // Therefore, truncation of the dimensions must be avoided.
658
659 assert(blockLength_ == other.blockLength_);
660 assert(size_ == other.size_);
661 }
662
663 template <class OtherEntry, class OtherBlockLength, class OtherNumInGroup, class OtherLength>
664 SbeGroupEntries& operator = (const SbeGroupEntries <OtherEntry, OtherBlockLength, OtherNumInGroup, OtherLength>& other) noexcept
665 {
666 encoded_ = other.encoded_;
667
668 blockLength_ = other.blockLength_;
669
670 assert(blockLength_ == other.blockLength_);
671
672 size_ = other.size_;
673
674 assert(size_ == other.size_);
675
676 version_ = other.version_;
677
678 return *this;
679 }
680
681private:
682 // Allows coping and cloning for different instantiations.
683 template <class OtherEntry, class OtherBlockLength, class OtherNumInGroup, class OtherLength> friend class SbeGroupEntries;
684
685 void* encoded_;
686 BlockLength blockLength_;
687 NumInGroup size_;
688 SchemaVersion version_;
689};
690
692template < class EntryType, class DimensionType, class GroupSizeType >
694{
695public:
697 typedef DimensionType Dimension;
698
700 typedef GroupSizeType BinarySize;
701
704
706 typedef typename DimensionType::BlockLength EntrySize;
707
709 typedef SbeGroupEntries <EntryType, typename Dimension::BlockLength, typename Dimension::NumInGroup, GroupSizeType > Entries;
710
712 typedef typename Entries::Iterator Iterator;
713
715 typedef typename Entries::Entry Entry;
716
718 typedef typename Entries::Size Size;
719
722 noexcept
723 : header_(nullptr)
724 , entries_(nullptr)
725 , version_(0)
726 {
727 }
728
732 : header_(static_cast <Dimension*>(data))
733 , entries_(advanceByBytes(data, Dimension::Size))
734 , version_(version)
735 {
736 ONIXS_ICEBOE_ASSERT(size >= Dimension::Size);
737 assert(header_);
738 assert(entries_);
739
740 assert(valid());
741 }
742
744 bool valid() const noexcept
745 {
746 return (entries_ != nullptr);
747 }
748
750 bool empty() const noexcept
751 {
752 assert(valid());
753
754 return 0 == size();
755 }
756
759 Size size() const noexcept
760 {
761 assert(valid());
762 assert(header_);
763
764 const Dimension* const group = static_cast<const Dimension*>(header_);
765
766 return group->numInGroup();
767 }
768
771 Iterator begin() const noexcept
772 {
773 assert(valid());
774
775 return Iterator(entries_, numericCast<Size>(entrySize()), version_);
776 }
777
780 Iterator end() const noexcept
781 {
782 assert(valid());
783
784 return Iterator(advanceByBytes(binary(), binarySize()), numericCast<Size>(entrySize()), version_);
785 }
786
791 Entry operator [](Size index) const
792 {
793 assert(valid());
794 assert(index < size());
795
796 return Entry(advanceByBytes(entries_, static_cast<ptrdiff_t>(index) * entrySize()), entrySize(), version_);
797 }
798
801 Entries entries() const noexcept
802 {
803 assert(valid());
804 assert(header_);
805
806 return Entries (entries_, header_->blockLength(), header_->numInGroup(), version_);
807 }
808
810 const void* encoded() const noexcept
811 {
812 return header_;
813 }
814
816 ONIXS_ICEBOE_FORCEINLINE
817 const void* tail() const noexcept
818 {
820 }
821
824 void* binary() const noexcept
825 {
826 return header_;
827 }
828
831 BinarySize binarySize() const noexcept
832 {
833 return Dimension::Size + (static_cast<BinarySize>(entrySize()) * static_cast<BinarySize>(size()));
834 }
835
838 EntrySize entrySize() const noexcept
839 {
840 assert(valid());
841 assert(header_);
842
843 Dimension* const group = static_cast<Dimension*>(header_);
844 return group->blockLength();
845 }
846
847private:
849 void init(EntrySize entrySize) noexcept
850 {
851 assert(valid());
852 assert(header_);
853
854 Dimension* const group = static_cast<Dimension*>(header_);
855 group->blockLength(entrySize);
856 group->numInGroup(0);
857 }
858
860 Size allocate(Size entryCount, const void* messageTail, const void* blockEnd)
861 {
862 assert(valid());
863 assert(blockEnd);
864 assert(messageTail);
865
866 Dimension* const group = static_cast<Dimension*>(header_);
867
868 const EntrySize entrySize = group->blockLength();
869
870 if ONIXS_ICEBOE_UNLIKELY(
871 entrySize < EntryType::blockLength(version_))
872 {
874 }
875
876 const Size oldEntryCount = group->numInGroup();
877
878 if(oldEntryCount == entryCount)
879 return entryCount;
880
881 const ptrdiff_t memShift =
882 (entryCount - oldEntryCount) * static_cast<ptrdiff_t>(entrySize);
883
884 const void* const newMessageTail =
885 advanceByBytes(messageTail, memShift);
886
887 if ONIXS_ICEBOE_UNLIKELY(byteDistance(blockEnd, newMessageTail) < 0)
888 throwNotEnoughSpace();
889
890 const void* const oldEndOfGroup =
891 advanceByBytes(entries_, static_cast<ptrdiff_t>(entrySize) * oldEntryCount);
892
893 void* const newEndGroup =
894 advanceByBytes(entries_, static_cast<ptrdiff_t>(entrySize) * entryCount);
895
896 std::memmove(
897 newEndGroup,
898 oldEndOfGroup,
899 byteDistance(messageTail, oldEndOfGroup));
900
901 group->numInGroup(entryCount);
902
903 return oldEntryCount;
904 }
905
908 void setup(Size entryCount, const void* messageTail, const void* blockEnd)
909 {
910 assert(valid());
911 assert(blockEnd);
912 assert(messageTail);
913
914 const Size oldEntryCount = allocate(entryCount, messageTail, blockEnd);
915
916 for(Size index = oldEntryCount; index < entryCount; ++index)
917 zeroPaddingBytes((*this)[index].resetVariableFields());
918 }
919
922 void construct(Size entryCount, const void* messageTail, const void* blockEnd)
923 {
924 assert(valid());
925 assert(blockEnd);
926 assert(messageTail);
927
928 const Size oldEntryCount = allocate(entryCount, messageTail, blockEnd);
929
930 for(Size index = oldEntryCount; index < entryCount; ++index)
931 zeroPaddingBytes((*this)[index].reset());
932 }
933
935 static void zeroPaddingBytes(Entry& entry)
936 {
937 assert(entry.valid());
938 entry.zeroPaddingBytes(EntryType::minimalBlockLength(entry.version()));
939 }
940
941private:
942 Dimension* header_;
943 void* entries_;
944 SchemaVersion version_;
945
946 friend class SbeMessage;
947};
948
950template < class BinarySize >
952{
953public:
956 SbeVariableLengthFieldList(void* binary, BinarySize size, SchemaVersion version) noexcept
957 : binary_(binary)
958 , size_(size)
959 , version_(version)
960 {
961 }
962
964 bool empty() const noexcept
965 {
966 return (0 == size_);
967 }
968
970 template<class BinaryVariableLengthFieldType>
971 BinaryVariableLengthFieldType& head() const noexcept
972 {
973 return *static_cast<BinaryVariableLengthFieldType*>(binary_);
974 }
975
977 template<class BinaryVariableLengthFieldType> ONIXS_ICEBOE_HOTPATH
979 {
980 assert(!empty());
981
982 const BinarySize headSize = head<BinaryVariableLengthFieldType>().binarySize();
983
984 assert(headSize <= size_);
985
986 return SbeVariableLengthFieldList(advanceByBytes( binary_, headSize), size_ - headSize, version_);
987 }
988
992 template<class BinaryVariableLengthFieldType> ONIXS_ICEBOE_HOTPATH
994 {
995 if ONIXS_ICEBOE_UNLIKELY(empty() || (size_ < BinaryVariableLengthFieldType::Size))
996 {
998 }
999
1000 const BinarySize headSize = head<BinaryVariableLengthFieldType>().binarySize();
1001
1002 if ONIXS_ICEBOE_UNLIKELY(headSize > size_)
1003 {
1005 }
1006
1007 return SbeVariableLengthFieldList(advanceByBytes(binary_, headSize), size_ - headSize, version_);
1008 }
1009
1010 private:
1011 void* binary_;
1012 BinarySize size_;
1013 SchemaVersion version_;
1014
1015};
1016
1018template <class BinarySize>
1020{
1021public:
1024 SbeGroupList(void* binary, BinarySize size, SchemaVersion version) noexcept
1025 : binary_(binary)
1026 , size_(size)
1027 , version_(version)
1028 {
1029 }
1030
1032 bool empty() const noexcept
1033 {
1034 return (0 == size_);
1035 }
1036
1038 template<class Group> ONIXS_ICEBOE_HOTPATH
1039 Group head() const noexcept
1040 {
1041 assert(!empty());
1042
1043 return Group(binary_, size_, version_);
1044 }
1045
1047 template<class Group> ONIXS_ICEBOE_HOTPATH
1048 SbeGroupList tail() const noexcept
1049 {
1050 assert(!empty());
1051
1052 const BinarySize headSize = head<Group>().binarySize();
1053
1054 assert(headSize <= size_);
1055
1056 return SbeGroupList(advanceByBytes(binary_, headSize), size_ - headSize, version_);
1057 }
1058
1060 template <class Group> ONIXS_ICEBOE_HOTPATH
1062 {
1063 assert(!empty());
1064
1065 const BinarySize headSize = head<Group>().binarySize();
1066
1067 assert(headSize <= size_);
1068
1069 return SbeVariableLengthFieldList<BinarySize>(advanceByBytes(binary_, headSize), size_ - headSize, version_);
1070 }
1071
1075 template<class Group> ONIXS_ICEBOE_HOTPATH
1077 {
1078 const BinarySize headSize = checkHead<Group>();
1079
1080 return SbeGroupList(advanceByBytes(binary_, headSize), size_ - headSize, version_);
1081 }
1082
1086 template <class Group> ONIXS_ICEBOE_HOTPATH
1088 {
1089 const BinarySize headSize = checkHead<Group>();
1090
1091 return SbeVariableLengthFieldList<BinarySize>(advanceByBytes(binary_, headSize), size_ - headSize, version_);
1092 }
1093
1094private:
1095 template<class Group>
1096 BinarySize checkHead() const
1097 {
1098 if ONIXS_ICEBOE_UNLIKELY(size_ < Group::Dimension::Size)
1099 {
1101 }
1102
1103 const Group group = head<Group>();
1104
1105 const BinarySize headSize = group.binarySize();
1106
1107 if ONIXS_ICEBOE_UNLIKELY(headSize > size_)
1108 {
1110 }
1111
1112 if(!group.empty())
1113 {
1114 const BinarySize entrySize = group.entrySize();
1115 const BinarySize expectedEntrySize = Group::Entry::minimalBlockLength(version_);
1116
1117 if ONIXS_ICEBOE_UNLIKELY(entrySize < expectedEntrySize)
1118 {
1119 throwBadBinaryBlock();
1120 }
1121 }
1122
1123 return headSize;
1124 }
1125
1126 void* binary_;
1127 BinarySize size_;
1128 SchemaVersion version_;
1129};
1130
1132template<typename Traits>
1134{
1135 if ONIXS_ICEBOE_UNLIKELY(version < Traits::MinimalVersion)
1136 {
1137 throwBadMessageVersion(version, Traits::MinimalVersion);
1138 }
1139}
1140
1142template<typename Traits>
1144{
1145 checkVersion<Traits>(version);
1146
1147 if ONIXS_ICEBOE_UNLIKELY(version < since)
1148 {
1149 throwBadMessageVersion(version, since);
1150 }
1151}
1152
1154template<typename Traits>
1156{
1157 if ONIXS_ICEBOE_UNLIKELY(id != Traits::Id)
1158 {
1159 throwBadSchemaId(Traits::Id, id);
1160 }
1161}
1162
1164template<typename Traits>
1166{
1168 checkVersion<Traits>(version);
1169}
1170
1172class SbeMessage : public SbeFields<Messaging::SbeMessage, MessageSize>
1173{
1174public:
1177 struct NoInit{};
1178 struct NoCheck{};
1179
1182
1185
1187 SbeMessage() noexcept
1188 : header_(nullptr)
1189 , size_(0)
1190 {
1191 }
1192
1196 : header_(static_cast<MessageHeader*>(data))
1197 , size_(size)
1198 {
1199 assert(data);
1200 assert(size <= MaxSbeMessageSize);
1201
1202 if ONIXS_ICEBOE_UNLIKELY(size < MessageHeader::Size)
1204
1205 this->version(version);
1206 }
1207
1211 : header_(static_cast<MessageHeader*>(data))
1212 , size_(size)
1213 {
1214 assert(data);
1215 assert(size <= MaxSbeMessageSize);
1216
1217 if ONIXS_ICEBOE_UNLIKELY(size < MessageHeader::Size)
1219
1220 // Now it is safe to read header_.
1221 if ONIXS_ICEBOE_UNLIKELY(size < (MessageHeader::Size + header_->blockLength()))
1222 throwBinaryBlockIsTooSmall(size, MessageHeader::Size + header_->blockLength());
1223 }
1224
1229 SbeMessage(void* data, MessageSize size, NoCheck) noexcept
1230 : header_(static_cast<MessageHeader*>(data))
1231 , size_(size)
1232 {
1233 assert(data);
1234 assert(size <= MaxSbeMessageSize);
1235
1236 assert(size >= MessageHeader::Size);
1237 assert(size >= MessageHeader::Size + header_->blockLength());
1238 }
1239
1241 void clear() noexcept
1242 {
1243 *this = SbeMessage();
1244 assert(!valid());
1245 }
1246
1248 bool valid() const noexcept
1249 {
1250 return (nullptr != header_);
1251 }
1252
1253 explicit operator bool() const noexcept
1254 {
1255 return valid();
1256 }
1257
1260 {
1261 assert(valid());
1262
1263 return header_->templateId();
1264 }
1265
1267 SchemaVersion version() const noexcept
1268 {
1269 assert(valid());
1270
1271 return header_->version();
1272 }
1273
1275 SchemaId schemaId() const noexcept
1276 {
1277 assert(valid());
1278
1279 return header_->schemaId();
1280 }
1281
1283 SequenceId sequenceId() const noexcept
1284 {
1285 assert(valid());
1286
1287 return header_->sequenceId();
1288 }
1289
1292 {
1293 assert(valid());
1294
1295 header_->sequenceId(value);
1296
1297 return *this;
1298 }
1299
1301 Timestamp sendTime() const noexcept
1302 {
1303 assert(valid());
1304
1305 return header_->sendTime();
1306 }
1307
1308
1311 {
1312 assert(valid());
1313
1314 header_->sendTime(value);
1315
1316 return *this;
1317 }
1318
1320 HeaderFlags headerFlags() const noexcept
1321 {
1322 assert(valid());
1323
1324 return header_->headerFlags();
1325 }
1326
1329 {
1330 assert(valid());
1331
1332 header_->headerFlags(value);
1333
1334 return *this;
1335 }
1336
1338 const void* binary() const noexcept
1339 {
1340 assert(valid());
1341
1342 return header_;
1343 }
1344
1346 void* binary() noexcept
1347 {
1348 assert(valid());
1349
1350 return header_;
1351 }
1352
1353 // \return the end of the memory block.
1354 const void* blockEnd() noexcept
1355 {
1356 assert(valid());
1357
1358 return advanceByBytes(header_, size_);
1359 }
1360
1361 // \return the end of the memory block.
1362 const void* blockEnd() const noexcept
1363 {
1364 assert(valid());
1365
1366 return advanceByBytes(header_, size_);
1367 }
1368
1370 MessageSize bufferSize() const noexcept
1371 {
1372 return size_;
1373 }
1374
1376 void* body() noexcept
1377 {
1378 assert(valid());
1379
1380 return advanceByBytes(header_, MessageHeader::Size);
1381 }
1382
1384 BlockLength blockLength() const noexcept
1385 {
1386 assert(valid());
1387
1388 return header_->blockLength();
1389 }
1390
1392 const void* block() const noexcept
1393 {
1394 assert(valid());
1395
1396 return advanceByBytes(header_, MessageHeader::Size);
1397 }
1398
1400 void* block() noexcept
1401 {
1402 assert(valid());
1403
1404 return advanceByBytes(header_, MessageHeader::Size);
1405 }
1406
1407protected:
1410
1413 {
1414 assert(valid());
1415
1416 header_->version(version);
1417
1418 return *this;
1419 }
1420
1424 {
1425 assert(header_);
1426
1427 void* list = advanceByBytes<void>(body(), blockLength());
1428
1429 const MessageSize listSize = size_ - MessageHeader::Size - header_->blockLength();
1430
1431 return GroupList(list, listSize, header_->version());
1432 }
1433
1436 GroupList groups() const noexcept
1437 {
1438 assert(header_);
1439
1440 const void* list = advanceByBytes(block(), blockLength());
1441
1442 const MessageSize listSize = size_ - MessageHeader::Size - header_->blockLength();
1443
1444 return GroupList(const_cast<void*>(list), listSize, header_->version());
1445 }
1446
1448 template<typename Group>
1450 void initGroup(Group& group, typename Group::EntrySize entrySize) noexcept
1451 {
1452 assert(group.valid());
1453 group.init(entrySize);
1454 }
1455
1457 template<typename Group>
1459 void setupGroup(Group& group, typename Group::Size entryCount, const void* messageTail)
1460 {
1461 assert(messageTail);
1462 assert(group.valid());
1463 group.setup(entryCount, messageTail, blockEnd());
1464 }
1465
1467 template<typename Group>
1469 void constructGroup(Group& group, typename Group::Size entryCount, const void* messageTail)
1470 {
1471 assert(messageTail);
1472 assert(group.valid());
1473 group.construct(entryCount, messageTail, blockEnd());
1474 }
1475
1477 template<typename DATA>
1478 void setVarDataField(DATA& data, StrRef value, const void* oldMessageTail)
1479 {
1480 assert(oldMessageTail);
1481
1482 const ptrdiff_t lengthChange = static_cast<ptrdiff_t>(value.length() - data.length());
1483
1484 const void* const newMessageTail = advanceByBytes(oldMessageTail, lengthChange);
1485
1486 if ONIXS_ICEBOE_UNLIKELY(byteDistance(blockEnd(), newMessageTail) < 0)
1488
1489 const void* const oldEndOfData = advanceByBytes(data.varData().data(), data.varData().size());
1490
1491 void* const newEndOfData = toOpaquePtr(advanceByBytes(&data, value.length() + DATA::Size));
1492
1493 std::memmove(newEndOfData, oldEndOfData, byteDistance(oldMessageTail, oldEndOfData));
1494
1495 data.varData(value);
1496 }
1497
1500
1504 {
1505 assert(header_);
1506
1507 void* list = advanceByBytes<void>(body(), blockLength());
1508
1509 const MessageSize listSize = size_ - MessageHeader::Size - header_->blockLength();
1510
1511 return VariableLengthFieldList(list, listSize, header_->version());
1512 }
1513
1517 {
1518 assert(header_);
1519
1520 const void* list = advanceByBytes(block(), blockLength());
1521
1522 const MessageSize listSize = size_ - MessageHeader::Size - header_->blockLength();
1523
1524 return VariableLengthFieldList(const_cast<void*>(list), listSize, header_->version());
1525 }
1526
1528 void init(
1530 MessageHeader::BlockLength minimalBlockLength,
1532 SchemaId id) noexcept
1533 {
1534 assert(header_);
1535 assert(blockLength >= minimalBlockLength);
1536
1537 header_->templateId(value);
1538 header_->blockLength(blockLength);
1539 header_->schemaId(id);
1540 header_->sequenceId(0);
1541 header_->sendTime(Timestamp{});
1542 header_->headerFlags(HeaderFlags::None);
1543
1544 zeroPaddingBytes(minimalBlockLength);
1545 }
1546
1548 MessageSize calculateBinarySize(const void* tail) const noexcept
1549 {
1550 assert(tail);
1551
1552 const ptrdiff_t distance = byteDistance(tail, binary());
1553
1554 assert(distance > 0);
1555
1556 assert(distance <= (std::numeric_limits<MessageSize>::max)());
1557
1558 const MessageSize size = static_cast<MessageSize>(distance);
1559
1560 assert(size <= size_);
1561
1562 return size;
1563 }
1564
1566 template<class Callable, class Owner>
1567 void setVariableLengthField(Callable callable, StrRef value, Owner& owner)
1568 {
1569 setVarDataField(callable(owner), value, owner.tail());
1570 }
1571
1573 template<class Callable, class Owner>
1574 void setVariableLengthField(Callable callable, StrRef value, SchemaVersion since, Owner& owner)
1575 {
1576 if ONIXS_ICEBOE_UNLIKELY(since > version())
1578
1579 setVariableLengthField(callable, value, owner);
1580 }
1581
1583 template<class Callable, class Owner>
1584 StrRef getVariableLengthField(Callable callable, const Owner& owner) const noexcept
1585 {
1586 ONIXS_ICEBOE_CHECK_NOTHROW(callable(owner));
1587 return callable(owner).varData();
1588 }
1589
1591 template<class Callable, class Owner>
1592 StrRef getVariableLengthField(Callable callable, SchemaVersion since, Owner& owner) const noexcept
1593 {
1594 if ONIXS_ICEBOE_UNLIKELY(since > version())
1595 return StrRef();
1596
1597 return getVariableLengthField(callable, owner);
1598 }
1599
1601 template<class Callable, class Owner>
1602 void setVariableLengthFieldToNull(Callable callable, Owner& owner) noexcept
1603 {
1604 ONIXS_ICEBOE_CHECK_NOTHROW(callable(owner));
1605 callable(owner).length(0);
1606 }
1607
1609 template<class Group, class Callable, class Owner>
1610 void resetGroup(Callable callable, Owner& owner) noexcept
1611 {
1612 const typename Group::EntrySize entrySize = Group::Entry::blockLength(version());
1613
1614 Group grp = callable(owner);
1615
1616 initGroup(grp, entrySize);
1617 }
1618
1620 template<class Callable, class Owner>
1621 void setVariableLengthFieldToNull(Callable callable, SchemaVersion since, Owner& owner) noexcept
1622 {
1623 if ONIXS_ICEBOE_UNLIKELY(since > version())
1624 return;
1625
1626 setVariableLengthFieldToNull(callable, owner);
1627 }
1628
1630 template<class Group, class Callable, class Owner>
1631 void resetGroup(Callable callable, SchemaVersion since, Owner& owner)
1632 {
1633 if ONIXS_ICEBOE_UNLIKELY(since > version())
1634 return;
1635
1636 resetGroup<Group>(callable, owner);
1637 }
1638
1640 template<class Group, class Callable, class Owner>
1641 ONIXS_ICEBOE_FORCEINLINE
1642 Group getGroup(Callable callable, Owner& owner) const noexcept
1643 {
1644 ONIXS_ICEBOE_CHECK_NOTHROW(callable(owner));
1645 return callable(owner);
1646 }
1647
1649 template<class Group, class Callable, class Owner>
1650 ONIXS_ICEBOE_FORCEINLINE
1651 Group getGroup(Callable callable, SchemaVersion since, Owner& owner) const noexcept
1652 {
1653 if ONIXS_ICEBOE_UNLIKELY(since > version())
1654 return Group();
1655
1656 return getGroup<Group>(callable, owner);
1657 }
1658
1660 template<class Group, class Callable, class Owner>
1661 ONIXS_ICEBOE_FORCEINLINE
1662 Group constructGroup(Callable callable, typename Group::Size length, SchemaVersion since, Owner& owner)
1663 {
1664 if ONIXS_ICEBOE_UNLIKELY(since > version())
1665 return Group();
1666
1667 return constructGroup<Group>(callable, length, owner);
1668 }
1669
1671 template<class Group, class Callable, class Owner>
1672 ONIXS_ICEBOE_FORCEINLINE
1673 Group constructGroup(Callable callable, typename Group::Size length, Owner& owner)
1674 {
1675 Group group = callable(owner);
1676
1677 constructGroup(group, length, owner.tail());
1678
1679 return group;
1680 }
1681
1683 template<class Group, class Callable, class Owner>
1684 Group setupGroup(Callable callable, typename Group::Size length, SchemaVersion since, Owner& owner)
1685 {
1686 if ONIXS_ICEBOE_UNLIKELY(since > version())
1687 return Group();
1688
1689 return setupGroup<Group>(callable, length, owner);
1690 }
1691
1693 template<class Group, class Callable, class Owner>
1694 Group setupGroup(Callable callable, typename Group::Size length, Owner& owner)
1695 {
1696 Group group = callable(owner);
1697
1698 setupGroup(group, length, owner.tail());
1699
1700 return group;
1701 }
1702
1706 constexpr
1708 {
1709 return
1711 }
1712
1713private:
1714 MessageHeader* header_;
1715 MessageSize size_;
1716};
1717
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_BEGIN
Definition ABI.h:102
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE_END
Definition ABI.h:106
#define ONIXS_ICEBOE_HOTPATH
Definition Compiler.h:155
#define ONIXS_ICEBOE_UNUSED
Definition Compiler.h:162
#define ONIXS_ICEBOE_EXPORTED
Definition Compiler.h:153
#define ONIXS_ICEBOE_NODISCARD
Definition Compiler.h:154
ONIXS_ICEBOE_FORCEINLINE std::enable_if<!isComposite< typenameNullValue::Value >::value, SbeOptional< typenameNullValue::Value, NullValue > >::type ordinary(BlockLength offset, OptionalTag) const noexcept
Definition SbeMessage.h:92
ONIXS_ICEBOE_FORCEINLINE Enumeration enumeration(BlockLength offset) const noexcept
Definition SbeMessage.h:141
SbeOptional< typename NullValue::Value, NullValue > ONIXS_ICEBOE_FORCEINLINE decimal(BlockLength offset, OptionalTag) const noexcept
Definition SbeMessage.h:205
ONIXS_ICEBOE_FORCEINLINE std::enable_if< isComposite< typenameNullValue::Value >::value, SbeOptional< typenameNullValue::Value, NullValue > >::type ordinary(BlockLength offset, OptionalTag) const noexcept
Definition SbeMessage.h:113
ONIXS_ICEBOE_FORCEINLINE SbeOptional< typename NullValue::Value, NullValue > decimal(BlockLength offset, SchemaVersion since, OptionalTag) const noexcept
Definition SbeMessage.h:219
ONIXS_ICEBOE_FORCEINLINE Value ordinary(BlockLength offset) const noexcept
Definition SbeMessage.h:81
ONIXS_ICEBOE_FORCEINLINE SbeOptionalStr fixedStr(BlockLength offset, SchemaVersion since, OptionalTag) const noexcept
Definition SbeMessage.h:187
ONIXS_ICEBOE_FORCEINLINE Value decimal(BlockLength offset) const noexcept
Definition SbeMessage.h:197
ONIXS_ICEBOE_FORCEINLINE std::enable_if<!isComposite< typenameNullValue::Value >::value, SbeOptional< typenameNullValue::Value, NullValue > >::type ordinary(BlockLength offset, SchemaVersion since, OptionalTag) const noexcept
Definition SbeMessage.h:100
ONIXS_ICEBOE_FORCEINLINE SbeOptionalEnumeration< Enumeration, NullValue > enumeration(BlockLength offset, OptionalTag) const noexcept
Provides access to an optional field value.
Definition SbeMessage.h:150
ONIXS_ICEBOE_FORCEINLINE SbeOptionalStr fixedStr(BlockLength offset, OptionalTag) const noexcept
Definition SbeMessage.h:180
ONIXS_ICEBOE_FORCEINLINE StrRef fixedStr(BlockLength offset) const noexcept
Provides access to a string field value.
Definition SbeMessage.h:170
BinaryBlock()=default
Initializes a blank instance.
ONIXS_ICEBOE_FORCEINLINE std::enable_if< isComposite< typenameNullValue::Value >::value, SbeOptional< typenameNullValue::Value, NullValue > >::type ordinary(BlockLength offset, SchemaVersion since, OptionalTag) const noexcept
Definition SbeMessage.h:128
ONIXS_ICEBOE_FORCEINLINE SbeOptionalEnumeration< Enumeration, NullValue > enumeration(BlockLength offset, SchemaVersion since, OptionalTag) const noexcept
Provides access to an optional field value.
Definition SbeMessage.h:159
ONIXS_ICEBOE_FORCEINLINE std::enable_if<!isComposite< typenameNullValue::Value >::value, SbeOptionalConverted< decltype(std::declval< Callable >()(std::declval< typenameArgType< Callable >::type >()))> >::type convertible(BlockLength offset, OptionalTag) const noexcept(noexcept(Callable::Nothrow))
Definition SbeMessage.h:230
ONIXS_ICEBOE_FORCEINLINE auto convertible(BlockLength offset) const noexcept(noexcept(Callable::Nothrow)) -> decltype(std::declval< Callable >()(std::declval< typename ArgType< Callable >::type >()))
Definition SbeMessage.h:247
NumInGroup numInGroup() const noexcept
Definition Composites.h:383
BlockLength blockLength() const noexcept
Definition Composites.h:370
Message identifiers and length of message root.
Definition Composites.h:57
UInt16 BlockLength
Type alias for the BlockLength.
Definition Composites.h:63
UInt16 TemplateId
Type alias for the TemplateId.
Definition Composites.h:66
ONIXS_ICEBOE_FORCEINLINE void setEnumeration(BlockLength offset, Enumeration value) noexcept
Sets the field value.
Definition SbeMessage.h:307
ONIXS_ICEBOE_FORCEINLINE void setEnumeration(BlockLength offset, Enumeration value, SchemaVersion since)
Sets the field value.
Definition SbeMessage.h:316
ONIXS_ICEBOE_FORCEINLINE void setFixedStr(BlockLength offset, StrRef value, SchemaVersion since)
Sets the field value.
Definition SbeMessage.h:342
SbeFields()=default
Initializes a blank instance.
ONIXS_ICEBOE_FORCEINLINE void setOrdinary(BlockLength offset, FieldValue value, SchemaVersion since)
Sets the field value.
Definition SbeMessage.h:296
ONIXS_ICEBOE_FORCEINLINE void setOrdinary(BlockLength offset, FieldValue value) noexcept
Sets the field value.
Definition SbeMessage.h:285
void zeroPaddingBytes(BlockLength offset) noexcept
If specified, the extra space is padded at the end of each entry and should be set to zeroes by encod...
Definition SbeMessage.h:272
ONIXS_ICEBOE_FORCEINLINE Container & container() noexcept
Definition SbeMessage.h:265
ONIXS_ICEBOE_FORCEINLINE void setFixedStr(BlockLength offset, StrRef value) noexcept
Sets the field value.
Definition SbeMessage.h:325
An iterator over SBE-encoded group entries.
Definition SbeMessage.h:455
Iterator(void *entry, Size size, SchemaVersion version) noexcept
Initializes the instance to the given repeating group.
Definition SbeMessage.h:477
std::random_access_iterator_tag iterator_category
Definition SbeMessage.h:465
Iterator() noexcept
Initializes the instance that refers to nothing.
Definition SbeMessage.h:468
SbeGroupEntries() noexcept
Initializes a blank instance referencing to nothing.
Definition SbeMessage.h:575
SbeGroupEntries(void *encoded, BlockLength blockLength, Size groupSize, SchemaVersion version) noexcept
Initializes the instance referencing to data.
Definition SbeMessage.h:584
EntryType Entry
The type of the repeating group entry.
Definition SbeMessage.h:448
Iterator end() const
Returns the iterator pointing to the entry behind the end of the group.
Definition SbeMessage.h:620
SbeGroupEntries(const SbeGroupEntries< OtherEntry, OtherBlockLength, OtherNumInGroup, OtherLength > &other) noexcept
Copy constructor.
Definition SbeMessage.h:650
Length EncodedLength
The length of the binary data occupied by the group entries.
Definition SbeMessage.h:445
NumInGroup Size
Number of entries in the collection.
Definition SbeMessage.h:451
SbeGroupEntry()
Initializes a blank instance.
Definition SbeMessage.h:366
const void * block() const noexcept
Definition SbeMessage.h:406
SbeGroupEntry(void *encoded, BlockLength size, SchemaVersion version)
Initializes the instance from the memory block of the encoded message.
Definition SbeMessage.h:375
BlockLength blockLength() const noexcept
Definition SbeMessage.h:422
SbeVariableLengthFieldList< BinarySize > checkVariableLengthFields() const
Checks the variable length fields list consistency.
SbeGroupList tail() const noexcept
SbeGroupList checkTail() const
Checks the list consistency.
SbeVariableLengthFieldList< BinarySize > variableLengthFields() const noexcept
SbeGroupList(void *binary, BinarySize size, SchemaVersion version) noexcept
Initializes the list over the memory block.
SbeGroup() noexcept
Initializes a blank instance referencing to nothing.
Definition SbeMessage.h:721
ONIXS_ICEBOE_FORCEINLINE const void * tail() const noexcept
Definition SbeMessage.h:817
SbeGroup(void *data, BinarySize size, SchemaVersion version) noexcept
Initializes an instance referencing to a valid group of a given message.
Definition SbeMessage.h:731
Entries entries() const noexcept
Definition SbeMessage.h:801
Iterator end() const noexcept
Definition SbeMessage.h:780
const void * encoded() const noexcept
Definition SbeMessage.h:810
SbeGroupEntries< BlockDetailsEntry, typename Dimension::BlockLength, typename Dimension::NumInGroup, MessageSize > Entries
Definition SbeMessage.h:709
Iterator begin() const noexcept
Definition SbeMessage.h:771
void clear() noexcept
Blank the instance.
const void * binary() const noexcept
MessageTemplateId templateId() const noexcept
SbeMessage & headerFlags(HeaderFlags value) noexcept
Sets Send Time.
SchemaId schemaId() const noexcept
Group setupGroup(Callable callable, typename Group::Size length, SchemaVersion since, Owner &owner)
Setups the repeating group with the given number of entries.
GroupList groups() const noexcept
Group setupGroup(Callable callable, typename Group::Size length, Owner &owner)
Setups the repeating group with the given number of entries.
StrRef getVariableLengthField(Callable callable, SchemaVersion since, Owner &owner) const noexcept
const void * blockEnd() const noexcept
void setVariableLengthField(Callable callable, StrRef value, SchemaVersion since, Owner &owner)
Sets the value of the variable length field.
SbeMessage(void *data, MessageSize size)
Initializes the instance over the given memory block.
SbeVariableLengthFieldList< MessageSize > VariableLengthFieldList
Binary group list instantiation.
SbeMessage & sequenceId(SequenceId value) noexcept
Sets Sequence ID.
SbeMessage & version(SchemaVersion version) noexcept
Sets the SBE Schema version.
ONIXS_ICEBOE_FORCEINLINE Group constructGroup(Callable callable, typename Group::Size length, Owner &owner)
Creates a repeating group with the given number of entries, sets all optional fields of the group ent...
Timestamp sendTime() const noexcept
MessageSize EncodedLength
Length of the message binary data.
const void * block() const noexcept
void setVarDataField(DATA &data, StrRef value, const void *oldMessageTail)
Sets the variable length field value.
SbeMessage(void *data, MessageSize size, NoCheck) noexcept
Initializes the instance over the given memory block.
ONIXS_ICEBOE_FORCEINLINE Group getGroup(Callable callable, SchemaVersion since, Owner &owner) const noexcept
void initGroup(Group &group, typename Group::EntrySize entrySize) noexcept
Resets the group to the initial state.
void setupGroup(Group &group, typename Group::Size entryCount, const void *messageTail)
Initializes the group header.
VariableLengthFieldList variableLengthFields() const noexcept
SchemaVersion version() const noexcept
SbeGroupList< MessageSize > GroupList
Binary group list instantiation.
SbeMessage(void *data, MessageSize size, SchemaVersion version)
Initializes the instance over the given memory block.
MessageSize bufferSize() const noexcept
SequenceId sequenceId() const noexcept
SbeMessage & sendTime(Timestamp value) noexcept
Sets Send Time.
ONIXS_ICEBOE_FORCEINLINE Group constructGroup(Callable callable, typename Group::Size length, SchemaVersion since, Owner &owner)
Creates a repeating group with the given number of entries, sets all optional fields of the group ent...
static constexpr MessageSize getMaxMessageSize() noexcept
Maximal message size.
void setVariableLengthFieldToNull(Callable callable, SchemaVersion since, Owner &owner) noexcept
Sets the variable length field to null.
BlockLength blockLength() const noexcept
void setVariableLengthFieldToNull(Callable callable, Owner &owner) noexcept
Resets the variable length field.
void resetGroup(Callable callable, SchemaVersion since, Owner &owner)
Resets the repeating group.
SbeMessage() noexcept
Initializes a blank instance.
void setVariableLengthField(Callable callable, StrRef value, Owner &owner)
Sets the value of the variable length field.
void init(MessageHeader::TemplateId value, MessageHeader::BlockLength minimalBlockLength, MessageHeader::BlockLength blockLength, SchemaId id) noexcept
ONIXS_ICEBOE_FORCEINLINE Group getGroup(Callable callable, Owner &owner) const noexcept
VariableLengthFieldList variableLengthFields() noexcept
MessageSize BlockLength
Length of the message body representing a block of fixed-length fields.
HeaderFlags headerFlags() const noexcept
StrRef getVariableLengthField(Callable callable, const Owner &owner) const noexcept
void resetGroup(Callable callable, Owner &owner) noexcept
Sets the group to the initial state.
MessageSize calculateBinarySize(const void *tail) const noexcept
void constructGroup(Group &group, typename Group::Size entryCount, const void *messageTail)
Initializes the group header, sets all optional fields to null.
static ONIXS_ICEBOE_FORCEINLINE constexpr SbeOptionalEnumeration< T, Null > null() noexcept
Definition SbeOptional.h:70
SbeVariableLengthFieldList(void *binary, BinarySize size, SchemaVersion version) noexcept
Initializes the list over the given memory block.
Definition SbeMessage.h:956
SbeVariableLengthFieldList tail() const noexcept
Definition SbeMessage.h:978
BinaryVariableLengthFieldType & head() const noexcept
Definition SbeMessage.h:971
SbeVariableLengthFieldList checkTail() const
Checks the variable-length field list consistency.
Definition SbeMessage.h:993
The time point without the time-zone information.
Definition Time.h:470
void throwBadSchemaId(SchemaId expected, SchemaId provided)
Raises an exception on a bad message id.
void checkSchemaId(SchemaId id)
Checks the compatibility with the provided SBE Schema ID.
ONIXS_ICEBOE_FORCEINLINE std::enable_if< details::HasMemberTraits< Value >::value, Value >::type getValue(const void *location) noexcept(noexcept(makeFromTuple< Value >(CompositeExtractor< Value::MemberTraits::Count >::template extractAsTuple< Value >(location))))
Definition Memory.h:284
void checkBinaryLength(const Message &, MessageSize length, MessageSize minimalRequiredLength)
Definition SbeMessage.h:45
constexpr std::enable_if<!details::HasMemberTraits< Value >::value, size_t >::type size() noexcept
Definition Memory.h:303
ONIXS_ICEBOE_FORCEINLINE std::enable_if<!details::HasValueStaticMember< Value >::value >::type setValue(void *location, Value value) noexcept
Definition Memory.h:342
void throwDisallowedField()
Throws an exception on a bad repeating group entry.
MessageHeader::Version SchemaVersion
SBE-encoded data version type.
constexpr UInt16 MaxSbeMessageSize
Maximum supported message size.
char Char
Character type alias.
Definition String.h:31
ONIXS_ICEBOE_FORCEINLINE void * toOpaquePtr(Type *ptr) noexcept
Makes the pointer an opaque one.
Definition Memory.h:51
ONIXS_ICEBOE_FORCEINLINE Type * advanceByBytes(Type *pointer, ptrdiff_t distance) noexcept
Advances the pointer to a given offset (distance) in bytes.
Definition Memory.h:110
void throwBinaryBlockIsTooSmall(MessageSize actual, MessageSize required)
Raises an exception when the given binary block is too small.
void throwNotEnoughSpace()
Throws an exception on a bad repeating group entry.
UInt16 MessageSize
Message length type.
Definition Aliases.h:29
HeaderFlags
HeaderFlags type.
Definition Fields.h:923
std::basic_string_view< Char > StrRef
Definition StrRef.h:46
void checkVersion(SchemaVersion version)
Checks the compatibility with the provided SBE Schema version.
MessageHeader::SchemaId SchemaId
void checkSchema(SchemaId id, SchemaVersion version)
Checks the compatibility with the provided SBE Schema version.
ONIXS_ICEBOE_FORCEINLINE Byte * toByteBlock(Type *ptr) noexcept
Reinterprets the pointer as a byte block one.
Definition Memory.h:86
void throwBadBinaryBlock()
Throws an exception on a bad repeating group.
ONIXS_ICEBOE_FORCEINLINE ptrdiff_t byteDistance(Left *left, Right *right) noexcept
Definition Memory.h:135
MessageHeader::SequenceId SequenceId
ONIXS_ICEBOE_FORCEINLINE Type * advanceBackByBytes(Type *pointer, ptrdiff_t distance) noexcept
Definition Memory.h:123
ONIXS_ICEBOE_FORCEINLINE std::enable_if<(MaxLen<=16), size_t >::type stringLen(const Char *s) noexcept
Definition String.h:73
constexpr OptionalTag optional
void throwBadMessageVersion(SchemaVersion messageVersion, SchemaVersion minimalVersion)
Raises an exception on a bad message version.
MessageHeader::TemplateId MessageTemplateId
Message type (template) identification.