43template<
typename Message>
inline
44void checkBinaryLength(
const Message&, MessageSize length, MessageSize minimalRequiredLength)
46 if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(length < minimalRequiredLength)
47 throwBinaryBlockIsTooSmall(length, minimalRequiredLength, Message::className());
62template < class Container, class BlockLength >
68 return *
static_cast <const Container*
> (
this);
81 assert(container().blockLength() >= (offset + size<Value>()) &&
82 "The requested field exceeds provided block boundaries.");
84 const void*
const location = advanceByBytes(container().block(), offset);
85 return getValue<Value>(location);
97 return (null != value);
107 return (since <= container().version() &&
ordinary (value, offset, null ) );
114 typedef typename Enumeration::Base Base;
115 typedef typename Enumeration::Enum Enum;
124 typedef typename Enumeration::Base Base;
125 typedef typename Enumeration::Enum Enum;
128 return null != value;
142 assert(container().blockLength() >= (offset + Length) &&
"The requested field exceeds provided block boundaries.");
144 const Char*
const text =
reinterpret_cast <const Char*
> (advanceByBytes(container().block(), offset));
146 return StrRef(text, strnlen(text, Length));
157 return !value.empty();
175template <
class Container,
class BlockLength >
185template <class BodySizeType>
245 const void* encoded_;
251template <
class EntryType,
class BlockLength,
class NumInGroup,
class Length >
308 return Entry(entry_, size_, version_);
320 return entry_ == other.entry_;
326 return entry_ != other.entry_;
332 return entry_ < other.entry_;
338 return entry_ > other.entry_;
346 entry_ = advanceByBytes(entry_, size_);
356 entry_ = advanceBackByBytes(entry_, size_);
367 return Iterator(advanceByBytes(entry_, distance * size_), size_, version_);
376 return Iterator(advanceBackByBytes(entry_, distance * size_), size_, version_);
397 , blockLength_(blockLength)
402 assert(blockLength > 0);
403 assert(version != 0);
427 return Iterator(
encoded(), blockLength_, version_);
441 assert(index < size_);
444 return Entry(advanceByBytes(encoded_,
static_cast<ptrdiff_t
>(index) * blockLength_), blockLength_, version_);
460 template<
class OtherEntry,
class OtherBlockLength,
class OtherNumInGroup,
class OtherLength >
462 : encoded_(other.encoded_)
463 , blockLength_(other.blockLength_)
465 , version_(other.version_)
470 assert(blockLength_ == other.blockLength_);
471 assert(size_ == other.size_);
474 template <
class OtherEntry,
class OtherBlockLength,
class OtherNumInGroup,
class OtherLength>
477 encoded_ = other.encoded_;
479 blockLength_ = other.blockLength_;
481 assert(blockLength_ == other.blockLength_);
485 assert(size_ == other.size_);
487 version_ = other.version_;
494 template <
class OtherEntry,
class OtherBlockLength,
class OtherNumInGroup,
class OtherLength>
friend class SbeGroupEntries;
496 const void* encoded_;
497 BlockLength blockLength_;
503template <
class EntryType,
class DimensionType,
class GroupSizeType >
520 typedef SbeGroupEntries <EntryType, typename Dimension::BlockLength, typename Dimension::NumInGroup, GroupSizeType >
Entries;
543 : header_(
static_cast <const Dimension*
>(data))
605 assert(index <
size());
617 return Entries (entries_, header_->blockLength(), header_->numInGroup(), version_);
658 const Dimension* header_;
659 const void* entries_;
666template <
class BinarySize>
691 return Group(binary_, size_, version_);
700 const BinarySize headSize =
head<Group>().binarySize();
702 assert(headSize <= size_);
704 return SbeGroupList(advanceByBytes(binary_, headSize), size_ - headSize, version_);
713 const BinarySize headSize = checkHead<Group>();
715 return SbeGroupList(advanceByBytes(binary_, headSize), size_ - headSize, version_);
719 template<
class Group>
720 BinarySize checkHead()
const
722 if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(size_ < Group::Dimension::Size)
724 throwBadBinaryBlock();
727 const Group group = head<Group>();
729 const BinarySize headSize = group.binarySize();
731 if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(headSize > size_)
733 throwBadBinaryBlock();
738 const BinarySize entrySize = group.entrySize();
739 const BinarySize expectedEntrySize = Group::Entry::minimalBlockLength(version_);
741 if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(entrySize < expectedEntrySize)
743 throwBadBinaryBlock();
752 SchemaVersion version_;
756template<
typename Traits>
759 if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(version < Traits::MinimalVersion)
761 throwBadMessageVersion(version, Traits::MinimalVersion);
766template<
typename Traits>
771 if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(version < since)
773 throwBadMessageVersion(version, since);
778template<
typename Traits>
781 if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(
id != Traits::Id)
783 throwBadSchemaId(Traits::Id,
id);
788template<
typename Traits>
865 return header_->templateId();
873 return header_->version();
881 return header_->schemaId();
897 return advanceByBytes(header_, size_);
911 return header_->blockLength();
936 return GroupList(
const_cast<void*
>(list), listSize, header_->version());
940 template<
class Group,
class Callable,
class Owner>
943 ONIXS_EURONEXT_OPTIQMDG_CHECK_NOTHROW(callable(owner));
944 return callable(owner);
948 template<
class Group,
class Callable,
class Owner>
951 if ONIXS_EURONEXT_OPTIQMDG_UNLIKELY(since >
version())
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_BEGIN
#define ONIXS_EURONEXT_OPTIQMDG_MESSAGING_NAMESPACE_END
#define ONIXS_EURONEXT_OPTIQMDG_LTWT_CLASS
#define ONIXS_EURONEXT_OPTIQMDG_NODISCARD
#define ONIXS_EURONEXT_OPTIQMDG_NOTHROW
#define ONIXS_EURONEXT_OPTIQMDG_NULLPTR
#define ONIXS_EURONEXT_OPTIQMDG_UNUSED
#define ONIXS_EURONEXT_OPTIQMDG_DEFAULT
#define ONIXS_EURONEXT_OPTIQMDG_HOTPATH
bool fixedStr(StrRef &value, BlockLength offset) const noexcept
Provides access to an optional string field value.
Value ordinary(BlockLength offset) const noexcept
bool fixedStr(StrRef &value, BlockLength offset, SchemaVersion since) const noexcept
Provides access to an optional string field value.
bool ordinary(Value &value, BlockLength offset, NullValue null) const noexcept
Provides access to an optional field value.
Enumeration::Enum enumeration(BlockLength offset) const noexcept
bool enumeration(typename Enumeration::Enum &value, BlockLength offset, NullValue null) const noexcept
Provides access to an optional field value.
BinaryBlock()=default
Initializes a blank instance.
bool ordinary(Value &value, BlockLength offset, NullValue null, SchemaVersion since) const noexcept
Provides access to an optional field value.
StrRef fixedStr(BlockLength offset) const noexcept
Provides access to a string field value.
bool enumeration(typename Enumeration::Enum &value, BlockLength offset, NullValue null, SchemaVersion since) const noexcept
Provides access to an optional field value.
NumInGroup numInGroup() const noexcept
BlockLength blockLength() const noexcept
SbeFields()=default
Initializes a blank instance.
Iterator(const void *entry, Size size, SchemaVersion version) noexcept
Initializes the instance to the given repeating group.
std::random_access_iterator_tag iterator_category
Iterator() noexcept
Initializes the instance that refers to nothing.
bool valid() const noexcept
ptrdiff_t difference_type
SbeGroupEntries() noexcept
Initializes a blank instance referencing to nothing.
bool empty() const noexcept
SbeGroupEntries(const void *encoded, BlockLength blockLength, Size groupSize, SchemaVersion version) noexcept
Initializes the instance referencing to data.
EntryType Entry
The type of the repeating group entry.
Iterator end() const
Returns the iterator pointing to the entry behind the end of the group.
Size size() const noexcept
EncodedLength encodedLength() const noexcept
SbeGroupEntries(const SbeGroupEntries< OtherEntry, OtherBlockLength, OtherNumInGroup, OtherLength > &other) noexcept
Copy constructor.
bool valid() const noexcept
friend class SbeGroupEntries
Length EncodedLength
The length of the binary data occupied by the group entries.
NumInGroup Size
Number of entries in the collection.
const void * encoded() const noexcept
SbeGroupEntry()
Initializes a blank instance.
SbeGroupEntry(const void *encoded, BlockLength size, SchemaVersion version)
Initializes the instance from the memory block of the encoded message.
const void * block() const noexcept
SchemaVersion version() const noexcept
bool valid() const noexcept
const void * encoded() const noexcept
BlockLength blockLength() const noexcept
BodySizeType BlockLength
Type to present the length of binary data of the repeating group entry.
SbeGroupList(const void *binary, BinarySize size, SchemaVersion version) noexcept
Initializes the list over the memory block.
bool empty() const noexcept
SbeGroupList tail() const noexcept
SbeGroupList checkTail() const
Checks the list consistency.
Group head() const noexcept
const void * binary() const noexcept
const void * tail() const noexcept
SbeGroup() noexcept
Initializes a blank instance referencing to nothing.
SbeGroup(const void *data, BinarySize size, SchemaVersion version) noexcept
Initializes an instance referencing to a valid group of a given message.
Entries::Size Size
Number of entries in the group.
GroupSizeType BinarySize
Length of group data.
EntrySize entrySize() const noexcept
BinarySize binarySize() const noexcept
bool empty() const noexcept
DimensionType::BlockLength EntrySize
Length of group entry data.
Entries::Iterator Iterator
The iterator type for group entries.
Entries::Entry Entry
Group entry type.
Entries entries() const noexcept
Size size() const noexcept
Iterator end() const noexcept
bool valid() const noexcept
const void * encoded() const noexcept
SbeGroupEntries< EntryType, typename Dimension::BlockLength, typename Dimension::NumInGroup, GroupSizeType > Entries
Binary group blocks.
DimensionType Dimension
Repeating group dimension type.
Iterator begin() const noexcept
void clear() noexcept
Blank the instance.
const void * binary() const noexcept
MessageTemplateId templateId() const noexcept
SchemaId schemaId() const noexcept
GroupList groups() const noexcept
const void * blockEnd() const noexcept
Group getGroup(Callable callable, Owner &owner) const noexcept
Group getGroup(Callable callable, SchemaVersion since, Owner &owner) const noexcept
MessageSize EncodedLength
Length of the message binary data.
const void * block() const noexcept
SbeMessage(const void *data, MessageSize size, NoCheck) noexcept
Initializes the instance over the given memory block.
SchemaVersion version() const noexcept
SbeMessage(const void *data, MessageSize size)
Initializes the instance over the given memory block.
SbeGroupList< MessageSize > GroupList
Binary group list instantiation.
MessageSize bufferSize() const noexcept
bool valid() const noexcept
BlockLength blockLength() const noexcept
SbeMessage() noexcept
Initializes a blank instance.
MessageSize BlockLength
Length of the message body representing a block of fixed-length fields.
void checkSchemaId(SchemaId id)
Checks the compatibility with the provided SBE Schema ID.
MessageHeader::Version SchemaVersion
SBE-encoded data version type.
char Char
Character type alias.
constexpr UInt16 MaxMessageSize
Maximum supported message size.
UInt16 MessageSize
Message length type.
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.
MessageHeader::TemplateId MessageTemplateId
Message type (template) identification.