OnixS C++ Euronext Optiq MDG Handler  1.3.1
API documentation
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 
31 
32 #include <cassert>
33 #include <limits>
34 #include <stdexcept>
35 
37 
38 /// Message type (template) identification.
39 typedef
40 MessageHeader::TemplateId MessageTemplateId;
41 
42 /// \private
43 template<typename Message> inline
44 void checkBinaryLength(const Message&, MessageSize length, MessageSize minimalRequiredLength)
45 {
46  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(length < minimalRequiredLength)
47  throwBinaryBlockIsTooSmall(length, minimalRequiredLength, Message::className());
48 }
49 
50 /// \private
52 {
53 protected:
54  ~BinaryBlockBase() ONIXS_EURONEXT_OPTIQMDG_DEFAULT;
55 };
56 
57 /// Services to access fields stored
58 /// in an SBE-encoded block of fixed-length fields.
59 ///
60 /// The given class represents an abstraction to be used
61 /// by descendants as a base class with static polymorphism.
62 template < class Container, class BlockLength >
64 {
65  /// \return The block container that provides access to the encoded data.
66  const Container& container() const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
67  {
68  return *static_cast <const Container*> (this);
69  }
70 
71 protected:
72  /// Initializes a blank instance.
74 
76 
77  /// \return the field value.
78  template < class Value > ONIXS_EURONEXT_OPTIQMDG_HOTPATH
79  Value ordinary(BlockLength offset) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
80  {
81  assert(container().blockLength() >= (offset + size<Value>()) &&
82  "The requested field exceeds provided block boundaries.");
83 
84  const void* const location = advanceByBytes(container().block(), offset);
85  return getValue<Value>(location);
86  }
87 
88  /// Provides access to an optional field value.
89  ///
90  /// \return `true` if the field is present in the field block and its value was copied,
91  /// otherwise - `false`.
92  template <class Value, class NullValue > ONIXS_EURONEXT_OPTIQMDG_HOTPATH
93  bool ordinary(Value& value, BlockLength offset, NullValue null) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
94  {
95  value = ordinary<Value>(offset);
96 
97  return (null != value);
98  }
99 
100  /// Provides access to an optional field value.
101  ///
102  /// \return `true` if the field is present in the field block and its value was copied,
103  /// otherwise - `false`.
104  template < class Value, class NullValue > ONIXS_EURONEXT_OPTIQMDG_HOTPATH
105  bool ordinary(Value& value, BlockLength offset, NullValue null, SchemaVersion since) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
106  {
107  return (since <= container().version() && ordinary (value, offset, null ) );
108  }
109 
110  /// \return the field value.
111  template < class Enumeration > ONIXS_EURONEXT_OPTIQMDG_HOTPATH
112  typename Enumeration::Enum enumeration(BlockLength offset) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
113  {
114  typedef typename Enumeration::Base Base;
115  typedef typename Enumeration::Enum Enum;
116 
117  return static_cast<Enum>(ordinary<Base>(offset));
118  }
119 
120  /// Provides access to an optional field value.
121  template < class Enumeration, class NullValue > ONIXS_EURONEXT_OPTIQMDG_HOTPATH
122  bool enumeration(typename Enumeration::Enum& value, BlockLength offset, NullValue null) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
123  {
124  typedef typename Enumeration::Base Base;
125  typedef typename Enumeration::Enum Enum;
126 
127  value = static_cast <Enum>(ordinary<Base>(offset));
128  return null != value;
129  }
130 
131  /// Provides access to an optional field value.
132  template < class Enumeration, class NullValue > ONIXS_EURONEXT_OPTIQMDG_HOTPATH
133  bool enumeration(typename Enumeration::Enum& value, BlockLength offset, NullValue null, SchemaVersion since) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
134  {
135  return (since <= container().version() && enumeration<Enumeration>(value, offset, null) );
136  }
137 
138  /// Provides access to a string field value.
139  template < BlockLength Length > ONIXS_EURONEXT_OPTIQMDG_HOTPATH
141  {
142  assert(container().blockLength() >= (offset + Length) && "The requested field exceeds provided block boundaries.");
143 
144  const Char* const text = reinterpret_cast <const Char*> (advanceByBytes(container().block(), offset));
145 
146  return StrRef(text, strnlen(text, Length));
147  }
148 
149  /// Provides access to an optional string field value.
150  ///
151  /// \return `true` if the field is present in the field block and its value was copied,
152  /// otherwise - `false`.
153  template<BlockLength Length> ONIXS_EURONEXT_OPTIQMDG_HOTPATH
154  bool fixedStr(StrRef& value, BlockLength offset) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
155  {
156  value = fixedStr<Length>(offset);
157  return !value.empty();
158  }
159 
160  /// Provides access to an optional string field value.
161  ///
162  /// \return `true` if the field is present in the field block and its value was copied,
163  /// otherwise - `false`.
164  template<BlockLength Length> ONIXS_EURONEXT_OPTIQMDG_HOTPATH
165  bool fixedStr(StrRef& value, BlockLength offset, SchemaVersion since) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
166  {
167  return (since <= container().version() && fixedStr<Length>(value, offset));
168  }
169 };
170 
171 /// Base services to access fields stored in an SBE-encoded block of memory.
172 ///
173 /// This class represents an abstraction to be used
174 /// by descendants as a base class with static polymorphism.
175 template <class Container, class BlockLength >
177 {
178 protected:
179  /// Initializes a blank instance.
182 };
183 
184 /// Operations over a repeating group instance.
185 template <class BodySizeType>
187 {
188 public:
189  /// Type to present the length of binary data of the repeating group entry.
190  typedef BodySizeType BlockLength;
191 
192  /// Initializes a blank instance.
195  , size_(0)
196  , version_(0)
197  {
198  }
199 
200  /// Initializes the instance from the memory block of the encoded message.
202  SbeGroupEntry(const void* encoded, BlockLength size, SchemaVersion version)
203  : encoded_(encoded)
204  , size_(size)
205  , version_(version)
206  {
207  assert(encoded);
208  }
209 
210  /// \return `true` if the instance refers to a valid content, otherwise - `false`.
212  {
213  return (encoded_ != ONIXS_EURONEXT_OPTIQMDG_NULLPTR);
214  }
215 
216  /// \return the beginning of the group entry body.
218  {
219  assert(valid());
220 
221  return encoded_;
222  }
223 
224  /// \return the pointer to the block containing fixed-length fields.
226  {
227  assert(valid());
228 
229  return encoded_;
230  }
231 
232  /// \return Block length.
234  {
235  return size_;
236  }
237 
238  /// \return SBE Schema version.
240  {
241  return version_;
242  }
243 
244 private:
245  const void* encoded_;
246  BodySizeType size_;
247  SchemaVersion version_;
248 };
249 
250 /// Operations over SBE-encoded repeating group entries.
251 template <class EntryType, class BlockLength, class NumInGroup, class Length >
253 {
254 public:
255  /// The length of the binary data occupied by the group entries.
256  typedef Length EncodedLength;
257 
258  /// The type of the repeating group entry.
259  typedef EntryType Entry;
260 
261  /// Number of entries in the collection.
262  typedef NumInGroup Size;
263 
264  /// An iterator over SBE-encoded group entries.
266  {
267  public:
268  typedef EntryType Entry;
269  typedef Entry value_type;
270 
271  typedef Entry* pointer;
272  typedef Entry& reference;
273 
274  typedef ptrdiff_t difference_type;
275 
276  typedef std::random_access_iterator_tag iterator_category;
277 
278  /// Initializes the instance that refers to nothing.
281  , size_(0)
282  , version_(0)
283  {
284  }
285 
286  /// Initializes the instance to the given repeating group.
288  Iterator(const void* entry, Size size, SchemaVersion version) ONIXS_EURONEXT_OPTIQMDG_NOTHROW
289  : entry_(entry)
290  , size_(size)
291  , version_(version)
292  {
293  assert(valid());
294  }
295 
296  /// \return `true` if the instance is valid, otherwise - `false`.
298  {
299  return (entry_ != ONIXS_EURONEXT_OPTIQMDG_NULLPTR);
300  }
301 
302  /// \return the repeating group entry.
304  Entry get() const
305  {
306  assert(valid());
307 
308  return Entry(entry_, size_, version_);
309  }
310 
311  /// \return the repeating group entry.
312  Entry operator *() const
313  {
314  return get();
315  }
316 
317  /// Compares iterators.
319  {
320  return entry_ == other.entry_;
321  }
322 
323  /// Compares iterators.
325  {
326  return entry_ != other.entry_;
327  }
328 
329  /// Established the order between two iterators.
331  {
332  return entry_ < other.entry_;
333  }
334 
335  /// Established the order between two iterators.
337  {
338  return entry_ > other.entry_;
339  }
340 
341  /// Advances the next repeating group entry.
342  Iterator& operator ++()
343  {
344  assert(valid());
345 
346  entry_ = advanceByBytes(entry_, size_);
347 
348  return *this;
349  }
350 
351  /// Advances to the previous repeating group entry.
352  Iterator& operator --()
353  {
354  assert(valid());
355 
356  entry_ = advanceBackByBytes(entry_, size_);
357 
358  return *this;
359  }
360 
361  /// Advances by given number of entries.
363  Iterator operator +(difference_type distance) const
364  {
365  assert(valid());
366 
367  return Iterator(advanceByBytes(entry_, distance * size_), size_, version_);
368  }
369 
370  /// Advances back by given number of entries.
372  Iterator operator - (difference_type distance) const
373  {
374  assert(valid());
375 
376  return Iterator(advanceBackByBytes(entry_, distance * size_), size_, version_);
377  }
378 
379  private:
380  const void* entry_;
381  Size size_;
382  SchemaVersion version_;
383  };
384 
385  /// Initializes a blank instance referencing to nothing.
388  , blockLength_(0)
389  , size_(0)
390  , version_(0)
391  {
392  }
393 
394  /// Initializes the instance referencing to data.
395  SbeGroupEntries(const void* encoded, BlockLength blockLength, Size groupSize, SchemaVersion version) ONIXS_EURONEXT_OPTIQMDG_NOTHROW
396  : encoded_(encoded)
397  , blockLength_(blockLength)
398  , size_(groupSize)
399  , version_(version)
400  {
401  assert(encoded_);
402  assert(blockLength > 0);
403  assert(version != 0);
404  }
405 
406  /// \return `true` if the instance refers to a valid repeating group, otherwise - `false`.
408  {
409  return (ONIXS_EURONEXT_OPTIQMDG_NULLPTR != encoded_);
410  }
411 
412  /// \return `true` if the referenced repeating group is empty, otherwise - `false`.
414  {
415  return (0 == size_);
416  }
417 
418  /// \return number of blocks.
420  {
421  return size_;
422  }
423 
424  /// \return the iterator pointing to the first repeating group entry.
425  Iterator begin() const
426  {
427  return Iterator(encoded(), blockLength_, version_);
428  }
429 
430  /// Returns the iterator pointing to the entry behind the end of the group.
431  Iterator end() const
432  {
433  return Iterator(advanceByBytes(encoded(), encodedLength()), blockLength_, version_);
434  }
435 
436  /// Provides access to the group entry by its index in the repeating group.
437  ///
438  /// \note Index validness is not checked due to performance considerations.
439  Entry operator [](Size index) const
440  {
441  assert(index < size_);
442  assert(encoded_);
443 
444  return Entry(advanceByBytes(encoded_, static_cast<ptrdiff_t>(index) * blockLength_), blockLength_, version_);
445  }
446 
447  /// \return Binary data occupied by the group entries.
449  {
450  return encoded_;
451  }
452 
453  /// \return the length of the binary data occupied by the group entries.
455  {
456  return (static_cast<EncodedLength>(blockLength_) * static_cast<EncodedLength>(size_) );
457  }
458 
459  /// Copy constructor.
460  template<class OtherEntry, class OtherBlockLength, class OtherNumInGroup, class OtherLength >
462  : encoded_(other.encoded_)
463  , blockLength_(other.blockLength_)
464  , size_(other.size_)
465  , version_(other.version_)
466  {
467  // Dimension types may vary for the different instantiations of the template.
468  // Therefore, truncation of the dimensions must be avoided.
469 
470  assert(blockLength_ == other.blockLength_);
471  assert(size_ == other.size_);
472  }
473 
474  template <class OtherEntry, class OtherBlockLength, class OtherNumInGroup, class OtherLength>
476  {
477  encoded_ = other.encoded_;
478 
479  blockLength_ = other.blockLength_;
480 
481  assert(blockLength_ == other.blockLength_);
482 
483  size_ = other.size_;
484 
485  assert(size_ == other.size_);
486 
487  version_ = other.version_;
488 
489  return *this;
490  }
491 
492 private:
493  // Allows coping and cloning for different instantiations.
494  template <class OtherEntry, class OtherBlockLength, class OtherNumInGroup, class OtherLength> friend class SbeGroupEntries;
495 
496  const void* encoded_;
497  BlockLength blockLength_;
498  NumInGroup size_;
499  SchemaVersion version_;
500 };
501 
502 /// SBE-encoded repeating group.
503 template < class EntryType, class DimensionType, class GroupSizeType >
505 {
506 public:
507  /// Repeating group dimension type.
508  typedef DimensionType Dimension;
509 
510  /// Length of group data.
511  typedef GroupSizeType BinarySize;
512 
513  /// Length of an empty group.
514  enum { EmptySize = Dimension::Size };
515 
516  /// Length of group entry data.
517  typedef typename DimensionType::BlockLength EntrySize;
518 
519  /// Binary group blocks.
521 
522  /// The iterator type for group entries.
523  typedef typename Entries::Iterator Iterator;
524 
525  /// Group entry type.
526  typedef typename Entries::Entry Entry;
527 
528  /// Number of entries in the group.
529  typedef typename Entries::Size Size;
530 
531  /// Initializes a blank instance referencing to nothing.
535  , entries_(ONIXS_EURONEXT_OPTIQMDG_NULLPTR)
536  , version_(0)
537  {
538  }
539 
540  /// Initializes an instance referencing to a valid group of a given message.
543  : header_(static_cast <const Dimension*>(data))
544  , entries_(advanceByBytes(data, Dimension::Size))
545  , version_(version)
546  {
547  assert(header_);
548  assert(entries_);
549  assert(size >= Dimension::Size);
550 
551  assert(valid());
552  }
553 
554  /// \return `true` if the instance refers to a valid repeating group, otherwise - `false`.
556  {
557  return (entries_ != ONIXS_EURONEXT_OPTIQMDG_NULLPTR);
558  }
559 
560  /// \return `true` if the repeating group is empty, otherwise - `false`.
562  {
563  assert(valid());
564 
565  return 0 == size();
566  }
567 
568  /// \return the number of entries in the repeating group.
571  {
572  assert(valid());
573  assert(header_);
574 
575  const Dimension* const group = static_cast<const Dimension*>(header_);
576 
577  return group->numInGroup();
578  }
579 
580  /// \return an iterator pointing to the first repeating group entry.
583  {
584  assert(valid());
585 
586  return Iterator(entries_, numericCast<Size>(entrySize()), version_);
587  }
588 
589  /// \return an iterator pointing to the entry behind the end of the group.
592  {
593  assert(valid());
594 
595  return Iterator(advanceByBytes(binary(), binarySize()), numericCast<Size>(entrySize()), version_);
596  }
597 
598  /// Provides access to a repeating group entry by the given index.
599  ///
600  /// \note Index validness is not checked due to performance considerations.
602  Entry operator [](Size index) const
603  {
604  assert(valid());
605  assert(index < size());
606 
607  return Entry(advanceByBytes(entries_, static_cast<ptrdiff_t>(index) * entrySize()), entrySize(), version_);
608  }
609 
610  /// \return Repeating group entries.
613  {
614  assert(valid());
615  assert(header_);
616 
617  return Entries (entries_, header_->blockLength(), header_->numInGroup(), version_);
618  }
619 
620  /// \return SBE-encoded data that represents the repeating group.
622  {
623  return header_;
624  }
625 
626  /// \return the end of SBE-encoded data that represents the repeating group.
628  {
629  return advanceByBytes(toByteBlock(encoded()), binarySize());
630  }
631 
632  /// \return SBE-encoded data that represends the repeating group.
635  {
636  return header_;
637  }
638 
639  /// \return the size of SBE-encoded data that represends the repeating group.
642  {
643  return Dimension::Size + (static_cast<BinarySize>(entrySize()) * static_cast<BinarySize>(size()));
644  }
645 
646  /// \return the size of a single repeating group entry.
649  {
650  assert(valid());
651  assert(header_);
652 
653  const Dimension* const group = static_cast<const Dimension*>(header_);
654  return group->blockLength();
655  }
656 
657 private:
658  const Dimension* header_;
659  const void* entries_;
660  SchemaVersion version_;
661 
662  friend class SbeMessage;
663 };
664 
665 /// Groups list.
666 template <class BinarySize>
668 {
669 public:
670  /// Initializes the list over the memory block.
672  SbeGroupList(const void* binary, BinarySize size, SchemaVersion version) ONIXS_EURONEXT_OPTIQMDG_NOTHROW
673  : binary_(binary)
674  , size_(size)
675  , version_(version)
676  {
677  }
678 
679  /// \return `true` if the list is empty, otherwise - `false`.
681  {
682  return (0 == size_);
683  }
684 
685  /// \return the head group.
686  template<class Group> ONIXS_EURONEXT_OPTIQMDG_HOTPATH
688  {
689  assert(!empty());
690 
691  return Group(binary_, size_, version_);
692  }
693 
694  /// \return the list of groups that follow the head.
695  template<class Group> ONIXS_EURONEXT_OPTIQMDG_HOTPATH
697  {
698  assert(!empty());
699 
700  const BinarySize headSize = head<Group>().binarySize();
701 
702  assert(headSize <= size_);
703 
704  return SbeGroupList(advanceByBytes(binary_, headSize), size_ - headSize, version_);
705  }
706 
707  /// Checks the list consistency.
708  ///
709  /// \return the list of groups that follow the head.
710  template<class Group> ONIXS_EURONEXT_OPTIQMDG_HOTPATH
712  {
713  const BinarySize headSize = checkHead<Group>();
714 
715  return SbeGroupList(advanceByBytes(binary_, headSize), size_ - headSize, version_);
716  }
717 
718 private:
719  template<class Group>
720  BinarySize checkHead() const
721  {
722  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(size_ < Group::Dimension::Size)
723  {
724  throwBadBinaryBlock();
725  }
726 
727  const Group group = head<Group>();
728 
729  const BinarySize headSize = group.binarySize();
730 
731  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(headSize > size_)
732  {
733  throwBadBinaryBlock();
734  }
735 
736  if(!group.empty())
737  {
738  const BinarySize entrySize = group.entrySize();
739  const BinarySize expectedEntrySize = Group::Entry::minimalBlockLength(version_);
740 
741  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(entrySize < expectedEntrySize)
742  {
743  throwBadBinaryBlock();
744  }
745  }
746 
747  return headSize;
748  }
749 
750  const void* binary_;
751  BinarySize size_;
752  SchemaVersion version_;
753 };
754 
755 /// Checks the compatibility with the provided SBE Schema version.
756 template<typename Traits>
758 {
759  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(version < Traits::MinimalVersion)
760  {
761  throwBadMessageVersion(version, Traits::MinimalVersion);
762  }
763 }
764 
765 /// Checks the compatibility with the provided SBE Schema version.
766 template<typename Traits>
768 {
769  checkVersion<Traits>(version);
770 
771  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(version < since)
772  {
773  throwBadMessageVersion(version, since);
774  }
775 }
776 
777 /// Checks the compatibility with the provided SBE Schema ID.
778 template<typename Traits>
780 {
781  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(id != Traits::Id)
782  {
783  throwBadSchemaId(Traits::Id, id);
784  }
785 }
786 
787 /// Checks the compatibility with the provided SBE Schema version.
788 template<typename Traits>
790 {
791  checkSchemaId<Traits>(id);
792  checkVersion<Traits>(version);
793 }
794 
795 /// SBE-encoded message.
797 {
798 public:
799  /// For tagged constructors
800  struct NoCheck{};
801 
802  /// Length of the message binary data.
804 
805  /// Length of the message body representing a block of fixed-length fields.
807 
808  /// Initializes a blank instance.
811  , size_(0)
812  {
813  }
814 
815  /// Initializes the instance over the given memory block.
817  SbeMessage(const void* data, MessageSize size)
818  : header_(static_cast<const MessageHeader*>(data))
819  , size_(size)
820  {
821  assert(data);
822  assert(size <= MaxMessageSize);
823 
824  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(size < MessageHeader::Size)
825  throwBinaryBlockIsTooSmall(size, MessageHeader::Size);
826 
827  // Now it is safe to read header_.
828  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(size < (MessageHeader::Size + header_->blockLength()))
829  throwBinaryBlockIsTooSmall(size, MessageHeader::Size + header_->blockLength());
830  }
831 
832  /// Initializes the instance over the given memory block.
833  ///
834  /// \note Performs no check of the data consistency
837  : header_(static_cast<const MessageHeader*>(data))
838  , size_(size)
839  {
840  assert(data);
841  assert(size <= MaxMessageSize);
842 
843  assert(size >= MessageHeader::Size);
844  assert(size >= MessageHeader::Size + header_->blockLength());
845  }
846 
847  /// Blank the instance.
849  {
850  *this = SbeMessage();
851  assert(!valid());
852  }
853 
854  /// \return `true` if the instance refers to a valid message, otherwise - `false`.
856  {
857  return (ONIXS_EURONEXT_OPTIQMDG_NULLPTR != header_);
858  }
859 
860  /// \return SBE Template identifier.
862  {
863  assert(valid());
864 
865  return header_->templateId();
866  }
867 
868  /// \return SBE Schema version.
870  {
871  assert(valid());
872 
873  return header_->version();
874  }
875 
876  /// \return SBE Schema ID.
878  {
879  assert(valid());
880 
881  return header_->schemaId();
882  }
883 
884  /// \return SBE-encoded message content.
886  {
887  assert(valid());
888 
889  return header_;
890  }
891 
892  // \return the end of the memory block.
894  {
895  assert(valid());
896 
897  return advanceByBytes(header_, size_);
898  }
899 
900  /// \return the size of the message buffer.
902  {
903  return size_;
904  }
905 
906  /// \return the size of the message body in bytes.
908  {
909  assert(valid());
910 
911  return header_->blockLength();
912  }
913 
914  /// \return the beginning of the message body.
916  {
917  assert(valid());
918 
919  return advanceByBytes(header_, MessageHeader::Size);
920  }
921 
922 protected:
923  /// Binary group list instantiation.
925 
926  /// \return the list of repeating groups
929  {
930  assert(header_);
931 
932  const void* list = advanceByBytes(block(), blockLength());
933 
934  const MessageSize listSize = size_ - MessageHeader::Size - header_->blockLength();
935 
936  return GroupList(const_cast<void*>(list), listSize, header_->version());
937  }
938 
939  /// \return the repeating group.
940  template<class Group, class Callable, class Owner>
941  Group getGroup(Callable callable, Owner& owner) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
942  {
943  ONIXS_EURONEXT_OPTIQMDG_CHECK_NOTHROW(callable(owner));
944  return callable(owner);
945  }
946 
947  /// \return the repeating group.
948  template<class Group, class Callable, class Owner>
949  Group getGroup(Callable callable, SchemaVersion since, Owner& owner) const ONIXS_EURONEXT_OPTIQMDG_NOTHROW
950  {
951  if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(since > version())
952  return Group();
953 
954  return getGroup<Group>(callable, owner);
955  }
956 
957 
958 private:
959  const MessageHeader* header_;
960  MessageSize size_;
961 };
962 
#define ONIXS_EURONEXT_OPTIQMDG_UNUSED
Definition: Compiler.h:211
bool fixedStr(StrRef &value, BlockLength offset) const noexcept
Provides access to an optional string field value.
Definition: SbeMessage.h:154
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_END
Definition: ABI.h:151
bool operator==(const TimeSpan &left, const TimeSpan &right)
Compares with other instance for equality.
Definition: Time.h:327
SbeGroupList< MessageSize > GroupList
Binary group list instantiation.
Definition: SbeMessage.h:924
SbeGroupList checkTail() const
Checks the list consistency.
Definition: SbeMessage.h:711
#define ONIXS_EURONEXT_OPTIQMDG_LTWT_CLASS
Definition: ABI.h:90
BodySizeType BlockLength
Type to present the length of binary data of the repeating group entry.
Definition: SbeMessage.h:190
#define ONIXS_EURONEXT_OPTIQMDG_NOTHROW
Definition: Compiler.h:186
SbeGroupEntries(const void *encoded, BlockLength blockLength, Size groupSize, SchemaVersion version) noexcept
Initializes the instance referencing to data.
Definition: SbeMessage.h:395
Entries::Size Size
Number of entries in the group.
Definition: SbeMessage.h:529
SbeMessage() noexcept
Initializes a blank instance.
Definition: SbeMessage.h:809
Value ordinary(BlockLength offset) const noexcept
Definition: SbeMessage.h:79
SbeGroupEntries(const SbeGroupEntries< OtherEntry, OtherBlockLength, OtherNumInGroup, OtherLength > &other) noexcept
Copy constructor.
Definition: SbeMessage.h:461
Enumeration::Enum enumeration(BlockLength offset) const noexcept
Definition: SbeMessage.h:112
Operations over a repeating group instance.
Definition: SbeMessage.h:186
bool enumeration(typename Enumeration::Enum &value, BlockLength offset, NullValue null, SchemaVersion since) const noexcept
Provides access to an optional field value.
Definition: SbeMessage.h:133
Timestamp operator-(const Timestamp &timestamp, const TimeSpan &timeSpan)
Subtracts time interval from given time point.
Definition: Time.h:805
Iterator() noexcept
Initializes the instance that refers to nothing.
Definition: SbeMessage.h:279
Services to access fields stored in an SBE-encoded block of fixed-length fields.
Definition: SbeMessage.h:63
MessageHeader::TemplateId MessageTemplateId
Message type (template) identification.
Message identifiers and length of message root.
Definition: Composites.h:32
Group getGroup(Callable callable, Owner &owner) const noexcept
Definition: SbeMessage.h:941
SbeGroup() noexcept
Initializes a blank instance referencing to nothing.
Definition: SbeMessage.h:532
SbeGroupEntries() noexcept
Initializes a blank instance referencing to nothing.
Definition: SbeMessage.h:386
Iterator end() const
Returns the iterator pointing to the entry behind the end of the group.
Definition: SbeMessage.h:431
#define ONIXS_EURONEXT_OPTIQMDG_NODISCARD
Definition: Compiler.h:195
#define ONIXS_EURONEXT_OPTIQMDG_DEFAULT
Definition: Compiler.h:212
Length EncodedLength
The length of the binary data occupied by the group entries.
Definition: SbeMessage.h:256
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_BEGIN
Definition: ABI.h:146
bool operator!=(const TimeSpan &left, const TimeSpan &right)
Compares with other instance for in-equality.
Definition: Time.h:337
SbeGroupEntry(const void *encoded, BlockLength size, SchemaVersion version)
Initializes the instance from the memory block of the encoded message.
Definition: SbeMessage.h:202
void checkSchema(SchemaId id, SchemaVersion version)
Checks the compatibility with the provided SBE Schema version.
Definition: SbeMessage.h:789
bool fixedStr(StrRef &value, BlockLength offset, SchemaVersion since) const noexcept
Provides access to an optional string field value.
Definition: SbeMessage.h:165
bool ordinary(Value &value, BlockLength offset, NullValue null, SchemaVersion since) const noexcept
Provides access to an optional field value.
Definition: SbeMessage.h:105
bool enumeration(typename Enumeration::Enum &value, BlockLength offset, NullValue null) const noexcept
Provides access to an optional field value.
Definition: SbeMessage.h:122
MessageSize BlockLength
Length of the message body representing a block of fixed-length fields.
Definition: SbeMessage.h:806
void checkSchemaId(SchemaId id)
Checks the compatibility with the provided SBE Schema ID.
Definition: SbeMessage.h:779
bool operator<(const TimeSpan &left, const TimeSpan &right)
Checks whether left time interval less than right one.
Definition: Time.h:347
SbeGroup(const void *data, BinarySize size, SchemaVersion version) noexcept
Initializes an instance referencing to a valid group of a given message.
Definition: SbeMessage.h:542
bool ordinary(Value &value, BlockLength offset, NullValue null) const noexcept
Provides access to an optional field value.
Definition: SbeMessage.h:93
MessageSize EncodedLength
Length of the message binary data.
Definition: SbeMessage.h:803
constexpr UInt16 MaxMessageSize
Maximum supported message size.
DimensionType::BlockLength EntrySize
Length of group entry data.
Definition: SbeMessage.h:517
#define ONIXS_EURONEXT_OPTIQMDG_HOTPATH
Definition: Compiler.h:197
MessageHeader::Version SchemaVersion
SBE-encoded data version type.
Definition: SchemaTraits.h:30
SbeMessage(const void *data, MessageSize size)
Initializes the instance over the given memory block.
Definition: SbeMessage.h:817
#define ONIXS_EURONEXT_OPTIQMDG_NULLPTR
Definition: Compiler.h:192
Operations over SBE-encoded repeating group entries.
Definition: SbeMessage.h:252
Group getGroup(Callable callable, SchemaVersion since, Owner &owner) const noexcept
Definition: SbeMessage.h:949
SbeGroupEntries< EntryType, typename Dimension::BlockLength, typename Dimension::NumInGroup, GroupSizeType > Entries
Binary group blocks.
Definition: SbeMessage.h:520
UInt16 MessageSize
Message length type.
Definition: Aliases.h:29
SbeMessage(const void *data, MessageSize size, NoCheck) noexcept
Initializes the instance over the given memory block.
Definition: SbeMessage.h:836
Iterator(const void *entry, Size size, SchemaVersion version) noexcept
Initializes the instance to the given repeating group.
Definition: SbeMessage.h:288
EntryType Entry
The type of the repeating group entry.
Definition: SbeMessage.h:259
SbeGroupList(const void *binary, BinarySize size, SchemaVersion version) noexcept
Initializes the list over the memory block.
Definition: SbeMessage.h:672
DimensionType Dimension
Repeating group dimension type.
Definition: SbeMessage.h:508
NumInGroup Size
Number of entries in the collection.
Definition: SbeMessage.h:262
Base services to access fields stored in an SBE-encoded block of memory.
Definition: SbeMessage.h:176
GroupSizeType BinarySize
Length of group data.
Definition: SbeMessage.h:511
bool operator>(const TimeSpan &left, const TimeSpan &right)
Checks whether left time interval greater than right one.
Definition: Time.h:357
void checkVersion(SchemaVersion since, SchemaVersion version)
Checks the compatibility with the provided SBE Schema version.
Definition: SbeMessage.h:767
Timestamp operator+(const Timestamp &timestamp, const TimeSpan &timeSpan)
Adds time interval to given time point.
Definition: Time.h:791
Entries::Iterator Iterator
The iterator type for group entries.
Definition: SbeMessage.h:523
StrRef fixedStr(BlockLength offset) const noexcept
Provides access to a string field value.
Definition: SbeMessage.h:140