41 template <
class Container,
class BlockLength>
52 template <
class Value>
55 const size_t sizeOfValue =
sizeof(Value);
57 assert((offset + sizeOfValue) <= container().blockLength());
59 const void*
const location =
advanceByBytes(container().block(), offset);
63 memcpy(&result, location, sizeOfValue);
74 template <
class Value,
class NullValue>
75 bool ordinary(Value&
value, BlockLength offset,
const NullValue& null)
const 77 const Value optional = ordinary<Value>(offset);
101 template <
class Value,
class NullValue>
104 return (since <= container().version() && ordinary(value, offset, null));
111 template <
class Enumeration>
114 typedef typename Enumeration::Base
Base;
116 typedef typename Enumeration::Enum Enum;
118 return static_cast<Enum
>(ordinary<Base>(offset));
126 template <
class Enumeration,
class NullValue>
127 bool enumeration(
typename Enumeration::Enum&
value, BlockLength offset,
const NullValue& null)
const 129 typedef typename Enumeration::Base
Base;
131 typedef typename Enumeration::Enum Enum;
133 const Base optional = ordinary<Base>(offset);
135 if (null != optional)
137 value =
static_cast<Enum
>(optional);
150 template <
class Enumeration,
class NullValue>
154 return (since <= container().version() && enumeration<Enumeration, NullValue>(value, offset, null));
159 template <
class Value>
162 return Decimal(ordinary<Value>(offset));
172 template <
class NullValue>
175 typedef typename NullValue::Value Value;
177 const Value optional = ordinary<Value>(offset);
179 if (null != optional)
202 template <
class NullValue>
205 return (since <= container().version() && decimal(value, offset, null));
212 template <BlockLength Length>
215 assert((offset + Length) <= container().blockLength());
219 return StrRef(text, strnlen(text, Length));
227 template <BlockLength Length>
230 return (since <= container().version() ? fixedStr<Length>(offset) :
StrRef());
236 const Container& container()
const 238 return *
static_cast<const Container*
>(
this);
249 template <
class Length>
278 assert(version >= SchemaTraits::minimalVersion());
283 : encoded_(other.encoded_)
284 , length_(other.length_)
285 , version_(other.version_)
290 operator bool()
const 333 encoded_ = other.encoded_;
334 length_ = other.length_;
336 version_ = other.version_;
342 const void* encoded_;
349 template <
class EntryType,
class BlockLength,
class NumInGroup,
class Length>
401 : encoded_(other.encoded_)
402 , length_(other.length_)
403 , version_(other.version_)
408 const Entry
get()
const 412 return Entry(encoded_, length_, version_);
424 return encoded_ == other.encoded_;
430 return encoded_ != other.encoded_;
436 return encoded_ < other.encoded_;
442 return encoded_ > other.encoded_;
465 advanceByBytes(encoded_, distance * static_cast<difference_type>(length_)), length_, version_
473 advanceBackByBytes(encoded_, distance * static_cast<difference_type>(length_)), length_, version_
480 encoded_ = other.encoded_;
481 length_ = other.length_;
482 version_ = other.version_;
488 const void* encoded_;
506 , blockLength_(blockLength)
513 template <
class OtherEntry,
class OtherBlockLength,
class OtherNumInGroup,
class OtherLength>
515 : encoded_(other.encoded_)
516 , blockLength_(other.blockLength_)
518 , version_(other.version_)
524 assert(blockLength_ == other.blockLength_);
526 assert(size_ == other.size_);
531 operator bool()
const 552 return Iterator(encoded_, blockLength_, version_);
559 advanceByBytes(encoded_, static_cast<ptrdiff_t>(blockLength_) * static_cast<ptrdiff_t>(size_)),
572 assert(index < size_);
575 advanceByBytes(encoded_, static_cast<ptrdiff_t>(blockLength_) * static_cast<ptrdiff_t>(index)),
591 return (static_cast<EncodedLength>(blockLength_) * static_cast<EncodedLength>(size_));
596 template <
class OtherEntry,
class OtherBlockLength,
class OtherNumInGroup,
class OtherLength>
600 encoded_ = other.encoded_;
602 blockLength_ = other.blockLength_;
604 assert(blockLength_ == other.blockLength_);
608 assert(size_ == other.size_);
610 version_ = other.version_;
618 template <
class OtherEntry,
class OtherBlockLength,
class OtherNumInGroup,
class OtherLength>
623 const void* encoded_;
625 BlockLength blockLength_;
636 template <
class EntryType,
class DimensionType,
class LengthType>
669 : header_(static_cast<const Dimension*>(encoded))
671 if (length < Dimension::Size)
678 advanceByBytes(header_, Dimension::Size), header_->blockLength(), header_->numInGroup(), version
681 if (length < encodedLength())
690 : header_(other.header_)
691 , entries_(other.entries_)
697 operator bool()
const 706 return (0 == size());
713 return entries_.size();
720 return entries_.begin();
727 return entries_.end();
737 return entries_[index];
757 return (Dimension::Size + entries_.encodedLength());
763 header_ = other.header_;
764 entries_ = other.entries_;
770 const Dimension* header_;
776 template <
class Length>
803 : encoded_(other.encoded_)
804 , length_(other.length_)
805 , version_(other.version_)
812 return (0 == length_);
816 template <
class Group>
819 return Group(encoded_, length_, version_);
823 template <
class Group>
826 const EncodedLength headLength = head<Group>().encodedLength();
828 assert(length_ >= headLength);
849 encoded_ = other.encoded_;
850 length_ = other.length_;
852 version_ = other.version_;
858 const void* encoded_;
868 throw std::runtime_error(
"Cannot construct message instance. Memory " 869 "block is too small to access SBE message header. ");
910 if (length < MessageHeader::Size || length < (MessageHeader::Size + header_->blockLength()))
918 : header_(other.header_)
919 , length_(other.length_)
924 operator bool()
const 934 return header_->templateId();
942 return header_->version();
971 return header_->blockLength();
982 length_ - MessageHeader::Size - header_->blockLength(),
990 header_ = other.header_;
991 length_ = other.length_;
Iterator()
Initializes instance referring to nothing.
BinaryGroups(const BinaryGroups &other)
Initializes as copy of other list.
bool operator>(const Iterator &other) const
Established order between two iterators.
~BinaryBlock()
Ends life of the instance.
Iterator end() const
Returns iterator pointing to the entry behind the end of the group.
ptrdiff_t difference_type
Iterator difference type.
StrRef fixedStr(BlockLength offset) const
Provides access to string field by its offset.
bool empty() const
Indicates whether group list is empty.
BlockLength blockLength() const
Length of the message body ( block of fixed-length fields).
Encapsulates services for manipulating SBE-encoded groups stored sequentially in SBE-encoded message...
BinaryMessage & operator=(const BinaryMessage &other)
Re-initializes instance as a copy of the other one.
BinaryGroupEntries & operator=(const BinaryGroupEntries< OtherEntry, OtherBlockLength, OtherNumInGroup, OtherLength > &other)
Re-initializes instance as copy of the other one.
const Entry * pointer
Aliases pointer to entry for STL conformance.
Provides iterating facilities over SBE-encoded group entries.
Iterator end() const
Returns iterator pointing to the entry behind the end of the group.
EncodedLength encodedLength() const
Length of SBE-encoded content referenced by the given group list.
const void * encoded() const
SBE-encoded content referenced by the list.
Entries::Entry Entry
Aliases type of the group entry.
Group head() const
Provides access to the head group of the list.
BinaryGroupEntries< EntryType, typename Dimension::BlockLength, typename Dimension::NumInGroup, LengthType > Entries
Binary group blocks.
#define ONIXS_CMEMDH_NULLPTR
bool enumeration(typename Enumeration::Enum &value, BlockLength offset, const NullValue &null) const
Provides access to value of an optional field by its offset.
Decimal decimal(BlockLength offset) const
Returns value of a field by its offset converted into a decimal.
const void * encoded() const
Binary data occupied by the given group entries.
Value ordinary(BlockLength offset) const
Returns value of a field by its offset.
Iterator & operator--()
Advances instance to the next repeating group entry.
Iterator(const Iterator &other)
Initializes instance as copy of the other one.
BinaryGroup & operator=(const BinaryGroup &other)
Re-initializes instance as copy of the other one.
BinaryMessage()
Initializes the instance referencing to nothing.
MessageSize BlockLength
Length of message body representing a block of fixed-length fields.
Length EncodedLength
Represents the length of binary data occupied by the given group entry.
BinaryGroupEntry()
Initializes instance referring to nothing.
BinaryGroups< MessageSize > Groups
Repeating groups.
const Entry & reference
Aliases entry reference for STL conformance.
bool operator!=(const Iterator &other) const
Compares the given iterator with the other instance.
EncodedLength encodedLength() const
Length of the SBE-encoded data referring to the given entry.
BinaryGroupEntries(const BinaryGroupEntries< OtherEntry, OtherBlockLength, OtherNumInGroup, OtherLength > &other)
Initializes instance as a copy of the other one.
BinaryGroup(const void *encoded, EncodedLength length, SchemaVersion version)
Initializes instance referencing to a valid group of a given message.
#define ONIXS_CMEMDH_LTWT
bool decimal(Decimal &value, BlockLength offset, const NullValue &null) const
Provides access to a value of an optional field by its offset.
Enumeration::Enum enumeration(BlockLength offset) const
Returns value of a field by its offset.
bool ordinary(Value &value, BlockLength offset, const NullValue &null, SchemaVersion since) const
Provides access to a value of an optional field by its offset.
BinaryGroupEntries()
Initializes blank instance referencing to nothing.
bool operator<(const Iterator &other) const
Established order between two iterators.
const void * encoded() const
Pointer to the binary data referring to the given entry.
BinaryGroupEntry(const BinaryGroupEntry &other)
Initializes instance as a copy of the other one.
BinaryGroupEntry(const void *encoded, BlockLength length, SchemaVersion version)
Initializes instance from memory block of given SBE-encoded message.
std::random_access_iterator_tag iterator_category
Identifies iterator category.
Encapsulates operations over SBE-encoded repeating group entry instance.
char Char
Character type alias.
UInt16 MessageSize
Aliases message length type.
BinaryMessage(const void *encoded, EncodedLength length)
Initializes instance over the given encoded data.
MessageSize EncodedLength
Length of message binary data.
BinaryMessage(const BinaryMessage &other)
Initializes instance as copy of the other one.
bool value(Number &number, const MultiContainer &container, Tag tag)
Finds a tag-value entry in the given collection by the given tag and returns its value component tran...
SchemaVersion version() const
Version of message containing given repeating group instance.
const void * encoded() const
SBE-encoded data representing the given repeating group.
const void * block() const
Returns pointer to the block containing fixed-length fields of the given entry.
Iterator & operator=(const Iterator &other)
Re-initializes instance as copy of the other one.
EntryType Entry
The type of repeating group entry.
Exposes base services to access fields stored in a SBE-encoded block of fixed-length fields...
BinaryGroups tail() const
Returns the groups following the head.
Iterator operator-(difference_type distance) const
Advances instance by given number of entries.
Iterator(const void *block, BlockLength length, SchemaVersion version)
Initializes instance for given repeating group.
void throwBadMessageVersion(const Char *, SchemaVersion, SchemaVersion)
Raises exception on bad message version.
MessageTemplateId templateId() const
Template identifier of message being referenced.
void throwBadBinaryGroup()
Throws exception on bad repeating group.
Provides efficient way of accessing text-based values without copying content of the text being refer...
Iterator & operator++()
Advances instance to the next repeating group entry.
MessageHeader::Version SchemaVersion
Aliases SBE-encoded data version type.
StrRef fixedStr(BlockLength offset, SchemaVersion since) const
Provides access to an optional field of string type by its offset.
EncodedLength encodedLength() const
Length of the binary data occupied by the given collection of entries.
A real number with floating exponent.
Entries::Iterator Iterator
Defines type of iterator for group entries.
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
BinaryGroupEntry & operator=(const BinaryGroupEntry &other)
Re-initializes instance as a copy of the other one.
BinaryGroup()
Initializes blank instance referencing to nothing.
BlockLength blockLength() const
Returns length of the block containing fixed-length fields of the given entry.
Type * advanceByBytes(Type *pointer, ptrdiff_t distance)
Advances given pointer to a given offset (distance) in bytes.
Length EncodedLength
Represents the length of binary data occupied by the given group entries.
Groups groups() const
Collection of repeating groups of the message being referenced.
Encapsulates services for manipulating SBE-encoded messages.
#define ONIXS_CMEMDH_EXPORTED
const Entry operator[](Size index) const
Provides access to the group entry by its index in the group.
Length EncodedLength
Represents the length of binary data occupied by the given list of groups.
const Entry operator*() const
Repeating group block referenced by the iterator.
EncodedLength encodedLength() const
Size of SBE-encoded message.
Length BlockLength
Represents the length of binary block storing fixed-length fields of the group entry.
Encapsulates operations over SBE-encoded repeating group.
void throwBadBinaryData(const Char *className)
Throws exception on bad repeating group entry.
const Entries & entries() const
Location of repeating group entries.
EncodedLength encodedLength() const
Length of the SBE-encoded data representing the given group.
DimensionType Dimension
Binary group dimensions (actual length, number of entries, etc).
Iterator begin() const
Returns iterator pointing to the first repeating group entry.
Entry operator[](Size index) const
Provides access to the repeating group entry by its index in the group.
UInt16 UInt16
uInt16 optional.
Type * advanceBackByBytes(Type *pointer, ptrdiff_t distance)
Returns pointer which is lower than given one to a given number of bytes.
BinaryGroups & operator=(const BinaryGroups &other)
Re-initializes instance as copy of the other one.
bool empty() const
Indicates whether a repeating group being referenced is empty.
BinaryGroups(const void *encoded, EncodedLength length, SchemaVersion version)
Initializes list over memory block, where given message is stored.
Iterator begin() const
Returns iterator pointing to the first repeating group entry.
const void * block() const
Indicates beginning of message body.
LengthType EncodedLength
Measures binary length of the group.
Iterator operator+(difference_type distance) const
Advances instance by given number of entries.
Size size() const
Returns number of entries in a repeating group being referenced.
bool enumeration(typename Enumeration::Enum &value, BlockLength offset, const NullValue &null, SchemaVersion since) const
Provides access to value of an optional field by its offset.
const void * encoded() const
SBE-encoded message content.
SchemaVersion version() const
Version of message being referenced.
NumInGroup Size
Number of entries in the collection.
bool ordinary(Value &value, BlockLength offset, const NullValue &null) const
Provides access to a value of an optional field by its offset.
MessageHeader::TemplateId MessageTemplateId
Aliases message type (template) identification.
bool empty() const
Indicates whether a repeating group being referenced is empty.
BinaryBlock()
Initializes the blank instance.
Size size() const
Returns number of blocks.
bool operator==(const Iterator &other) const
Compares the given iterator with the other instance.
BinaryGroupEntries(const void *encoded, BlockLength blockLength, Size groupSize, SchemaVersion version)
Initializes the instance referencing to a real data.
Encapsulates operations over SBE-encoded repeating group entries.
BinaryGroup(const BinaryGroup &other)
Initializes instance as a copy of the other one.
BinaryGroups()
Initializes empty list.
Entries::Size Size
Type representing a number of entries in the group.
bool decimal(Decimal &value, BlockLength offset, const NullValue &null, SchemaVersion since) const
Provides access to a value of an optional field by its offset.
void throwBadBinaryMessage()
Raises exception on bad binary message.
const Entry value_type
Aliases entry for STL conformance.
#define ONIXS_CMEMDH_NAMESPACE_END