41template <
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
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;
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;
135 if (null != optional)
137 value =
static_cast<Enum
>(optional);
150 template <
class Enumeration,
class NullValue>
159 template <
class Value>
172 template <
class NullValue>
175 typedef typename NullValue::Value Value;
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>
236 const Container& container()
const
238 return *
static_cast<const Container*
>(
this);
249template <
class Length>
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_;
349template <
class EntryType,
class BlockLength,
class NumInGroup,
class Length>
401 : encoded_(other.encoded_)
402 , length_(other.length_)
403 , version_(other.version_)
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_;
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)),
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_;
636template <
class EntryType,
class DimensionType,
class LengthType>
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];
763 header_ = other.header_;
764 entries_ = other.entries_;
770 const Dimension* header_;
776template <
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>
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. ");
918 : header_(other.header_)
919 , length_(other.length_)
924 operator bool()
const
934 return header_->templateId();
942 return header_->version();
971 return header_->blockLength();
990 header_ = other.header_;
991 length_ = other.length_;
1009 if (current < since)
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
#define ONIXS_CMEMDH_LTWT
#define ONIXS_CMEMDH_NAMESPACE_END
#define ONIXS_CMEMDH_NULLPTR
#define ONIXS_CMEMDH_EXPORTED
Exposes base services to access fields stored in a SBE-encoded block of fixed-length fields.
BinaryBlock()
Initializes the blank instance.
StrRef fixedStr(BlockLength offset, SchemaVersion since) const
Provides access to an optional field of string type by its offset.
StrRef fixedStr(BlockLength offset) const
Provides access to string field by its offset.
Enumeration::Enum enumeration(BlockLength offset) const
Returns value of a field by its offset.
bool decimal(Decimal &value, BlockLength offset, const NullValue &null) const
Provides access to a value of an optional field by its offset.
~BinaryBlock()
Ends life of the instance.
bool ordinary(Value &value, BlockLength offset, const NullValue &null) const
Provides access to a value of an optional field by its offset.
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.
Value ordinary(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.
Decimal decimal(BlockLength offset) const
Returns value of a field by its offset converted into a decimal.
bool enumeration(typename Enumeration::Enum &value, BlockLength offset, const NullValue &null) const
Provides access to value of an optional field by its offset.
bool decimal(Decimal &value, BlockLength offset, const NullValue &null, SchemaVersion since) const
Provides access to a value of an optional field by its offset.
const Entry * pointer
Aliases pointer to entry for STL conformance.
Iterator()
Initializes instance referring to nothing.
Iterator(const Iterator &other)
Initializes instance as copy of the other one.
Iterator operator+(difference_type distance) const
Advances instance by given number of entries.
bool operator<(const Iterator &other) const
Established order between two iterators.
const Entry & reference
Aliases entry reference for STL conformance.
const Entry value_type
Aliases entry for STL conformance.
std::random_access_iterator_tag iterator_category
Identifies iterator category.
Iterator operator-(difference_type distance) const
Advances instance by given number of entries.
bool operator!=(const Iterator &other) const
Compares the given iterator with the other instance.
const Entry operator*() const
Repeating group block referenced by the iterator.
const Entry get() const
Repeating group entry referenced by the instance.
bool operator>(const Iterator &other) const
Established order between two iterators.
ptrdiff_t difference_type
Iterator difference type.
Iterator & operator=(const Iterator &other)
Re-initializes instance as copy of the other one.
Iterator & operator++()
Advances instance to the next repeating group entry.
Iterator & operator--()
Advances instance to the next repeating group entry.
Iterator(const void *block, BlockLength length, SchemaVersion version)
Initializes instance for given repeating group.
bool operator==(const Iterator &other) const
Compares the given iterator with the other instance.
Encapsulates operations over SBE-encoded repeating group entries.
Iterator begin() const
Returns iterator pointing to the first repeating group entry.
BinaryGroupEntries(const void *encoded, BlockLength blockLength, Size groupSize, SchemaVersion version)
Initializes the instance referencing to a real data.
const Entry operator[](Size index) const
Provides access to the group entry by its index in the group.
BinaryGroupEntries()
Initializes blank instance referencing to nothing.
Iterator end() const
Returns iterator pointing to the entry behind the end of the group.
bool empty() const
Indicates whether a repeating group being referenced is empty.
friend class BinaryGroupEntries
EncodedLength encodedLength() const
Length of the binary data occupied by the given collection of entries.
MessageSize EncodedLength
const void * encoded() const
Size size() const
Returns number of blocks.
BinaryGroupEntries & operator=(const BinaryGroupEntries< OtherEntry, OtherBlockLength, OtherNumInGroup, OtherLength > &other)
Re-initializes instance as copy of the other one.
BinaryGroupEntries(const BinaryGroupEntries< OtherEntry, OtherBlockLength, OtherNumInGroup, OtherLength > &other)
Initializes instance as a copy of the other one.
SchemaVersion version() const
BinaryGroupEntry()
Initializes instance referring to nothing.
BlockLength blockLength() const
Returns length of the block containing fixed-length fields of the given entry.
const void * block() const
Returns pointer to the block containing fixed-length fields of the given entry.
BinaryGroupEntry(const BinaryGroupEntry &other)
Initializes instance as a copy of the other one.
EncodedLength encodedLength() const
Length of the SBE-encoded data referring to the given entry.
MessageSize EncodedLength
const void * encoded() const
BinaryGroupEntry(const void *encoded, BlockLength length, SchemaVersion version)
Initializes instance from memory block of given SBE-encoded message.
BinaryGroupEntry & operator=(const BinaryGroupEntry &other)
Re-initializes instance as a copy of the other one.
Iterator begin() const
Returns iterator pointing to the first repeating group entry.
Entries::Size Size
Type representing a number of entries in the group.
const Entries & entries() const
Location of repeating group entries.
Entries::Iterator Iterator
Defines type of iterator for group entries.
Entries::Entry Entry
Aliases type of the group entry.
BinaryGroup(const void *encoded, EncodedLength length, SchemaVersion version)
Initializes instance referencing to a valid group of a given message.
Iterator end() const
Returns iterator pointing to the entry behind the end of the group.
bool empty() const
Indicates whether a repeating group being referenced is empty.
BinaryGroupEntries< EntryType, typename Dimension::BlockLength, typename Dimension::NumInGroup, LengthType > Entries
Binary group blocks.
Entry operator[](Size index) const
Provides access to the repeating group entry by its index in the group.
BinaryGroup(const BinaryGroup &other)
Initializes instance as a copy of the other one.
EncodedLength encodedLength() const
DimensionType Dimension
Binary group dimensions (actual length, number of entries, etc).
const void * encoded() const
BinaryGroup()
Initializes blank instance referencing to nothing.
LengthType EncodedLength
Measures binary length of the group.
BinaryGroup & operator=(const BinaryGroup &other)
Re-initializes instance as copy of the other one.
Encapsulates services for manipulating SBE-encoded groups stored sequentially in SBE-encoded message.
BinaryGroups(const void *encoded, EncodedLength length, SchemaVersion version)
Initializes list over memory block, where given message is stored.
Group head() const
Provides access to the head group of the list.
bool empty() const
Indicates whether group list is empty.
BinaryGroups()
Initializes empty list.
BinaryGroups & operator=(const BinaryGroups &other)
Re-initializes instance as copy of the other one.
BinaryGroups(const BinaryGroups &other)
Initializes as copy of other list.
EncodedLength encodedLength() const
Length of SBE-encoded content referenced by the given group list.
Length EncodedLength
Represents the length of binary data occupied by the given list of groups.
const void * encoded() const
BinaryGroups tail() const
Returns the groups following the head.
BinaryMessage()
Initializes the instance referencing to nothing.
BinaryMessage(const void *encoded, EncodedLength length, SchemaVersion since)
Initializes instance over the given encoded data.
SchemaVersion version() const
Version of message being referenced.
BlockLength blockLength() const
Length of the message body ( block of fixed-length fields).
BinaryMessage & operator=(const BinaryMessage &other)
Re-initializes instance as a copy of the other one.
BinaryGroups< MessageSize > Groups
Repeating groups.
BinaryMessage(const void *encoded, EncodedLength length)
Initializes instance over the given encoded data.
Groups groups() const
Collection of repeating groups of the message being referenced.
MessageSize EncodedLength
Length of message binary data.
const void * block() const
Indicates beginning of message body.
EncodedLength encodedLength() const
Size of SBE-encoded message.
MessageTemplateId templateId() const
Template identifier of message being referenced.
const void * encoded() const
SBE-encoded message content.
BinaryMessage(const BinaryMessage &other)
Initializes instance as copy of the other one.
MessageSize BlockLength
Length of message body representing a block of fixed-length fields.
A real number with floating exponent.
Provides efficient way of accessing text-based values without copying content of the text being refer...
Type * advanceByBytes(Type *pointer, ptrdiff_t distance)
Advances given pointer to a given offset (distance) in bytes.
void throwBadBinaryData(const Char *className)
Throws exception on bad repeating group entry.
Type * advanceBackByBytes(Type *pointer, ptrdiff_t distance)
Returns pointer which is lower than given one to a given number of bytes.
MessageHeader::Version SchemaVersion
Aliases SBE-encoded data version type.
char Char
Character type alias.
void throwBadBinaryGroup()
Throws exception on bad repeating group.
UInt16 MessageSize
Aliases message length type.
void throwBadMessageVersion(SchemaVersion, SchemaVersion, const Char *=nullptr)
Raises exception on bad message version.
void throwBadBinaryMessage()
Raises exception on bad binary message.
MessageHeader::TemplateId MessageTemplateId
Aliases message type (template) identification.
static SchemaVersion minimalVersion()
Returns minimal version supported by the SDK.