OnixS C++ CME iLink 3 Binary Order Entry Handler 1.18.9
API Documentation
Loading...
Searching...
No Matches
Message.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
26
27#include <cstdlib>
28
30
35{
37 virtual Field field(const BinaryBlockBase&, Tag) const ONIXS_ILINK3_NOTHROW = 0;
38
40 virtual void setField(BinaryBlockBase&, Tag, const Field&) const = 0;
41
43 virtual void resetField(BinaryBlockBase&, Tag) const = 0;
44
46 virtual void reset(BinaryBlockBase&) const ONIXS_ILINK3_NOTHROW = 0;
47
48protected:
50};
51
54{
57 {
58 return (ONIXS_ILINK3_NULLPTR != accessor_);
59 }
60
68 {
69 accessor_->reset(binary_);
70
71 return *this;
72 }
73
81 {
82 assert(accessor_);
83
84 return accessor_->field(binary_, tag);
85 }
86
92 Tag tag, const Field& field)
93 {
94 assert(accessor_);
95 assert(field);
96
97 accessor_->setField(binary_, tag, field);
98
99 return *this;
100 }
101
112 {
113 assert(accessor_);
114
115 accessor_->resetField(binary_, tag);
116
117 return *this;
118 }
119
131 {
132 return this->field(tag);
133 }
134
143
154
165
176
187
198
209
220
231
242
253
264
275
286
296 template <typename Enumeration>
297 ONIXS_ILINK3_NODISCARD typename Enumeration::Enum getEnumeration(Tag tag) const
298 {
299 return field(tag).cast<Enumeration>();
300 }
301
311 template <typename BitSet>
313 {
314 return BitSet(field(tag).cast<typename BitSet::Bits>());
315 }
316
321 FieldSet& set(Tag tag, const Field& field)
322 {
323 return setField(tag, field);
324 }
325
330 template <typename BitSet>
331 FieldSet& set(Tag tag, BitSet value, typename BitSet::Bits* = ONIXS_ILINK3_NULLPTR)
332 {
333 return set(tag, value.bits());
334 }
335
340 FieldSet& set(Tag tag, Char value);
341
351 FieldSet& set(Tag tag, UInt64 value);
352
362 FieldSet& set(Tag tag, Int64 value);
363
373 FieldSet& set(Tag tag, UInt32 value);
374
384 FieldSet& set(Tag tag, Int32 value);
385
395 FieldSet& set(Tag tag, UInt16 value);
396
406 FieldSet& set(Tag tag, Int16 value);
407
417 FieldSet& set(Tag tag, UInt8 value);
418
428 FieldSet& set(Tag tag, Int8 value);
429
439 FieldSet& set(Tag tag, const Decimal& value);
440
450 FieldSet& set(Tag tag, StrRef value);
451
461 FieldSet& set(Tag tag, Timestamp value);
462
472 FieldSet& set(Tag tag, const MaturityMonthYear& value);
473
474protected:
476
479 BinaryBlockBase& binary,
480 const FieldAccessor* accessor)
482 : binary_(binary)
483 , accessor_(accessor)
484 {
485 }
486
489 {
490 return accessor_;
491 }
492
495 {
496 accessor_ = obj;
497 }
498
499private:
500 BinaryBlockBase& binary_;
501 const FieldAccessor* accessor_;
502};
503
504typedef
507
516
520GroupEntry : public FieldSet
521{
522public:
527 , binary_()
528 {
529 }
530
534 : FieldSet(binary_, r.accessor())
535 , binary_(r.binary_)
536 {
537 }
538
542 {
543 setAccessor(r.accessor());
544 this->binary_ = r.binary_;
545
546 return *this;
547 }
548
549protected:
550 friend
552 (
553 Group
554 );
555
559 : FieldSet(binary_, &accessor)
560 , binary_(binary)
561 {
562 }
563
564private:
565 GroupEntrySource binary_;
566};
567
568typedef
570<
571 GroupEntrySource,
575>
577
581{
582public:
584 typedef
587
591 : accessor_(ONIXS_ILINK3_NULLPTR)
592 {
593 }
594
598 {
599 return (ONIXS_ILINK3_NULLPTR != accessor_);
600 }
601
605 {
606 return binary_.size();
607 }
608
611 GroupEntry operator [](Size index) const
612 {
613 assert(accessor_);
614 assert(binary_.valid());
615
616 return GroupEntry(binary_[index], *accessor_);
617 }
618
619protected:
622 : binary_(binary)
623 , accessor_(&accessor)
624 {
625 }
626
627private:
628 GroupEntriesSource binary_;
629 const GroupEntryAccessor* accessor_;
630};
631
636{
638 virtual StrRef type() const ONIXS_ILINK3_NOTHROW = 0;
639
641 virtual Group group(const SbeMessage&, Tag) const ONIXS_ILINK3_NOTHROW = 0;
642
644 virtual Group group(SbeMessage&, Tag, MessageSize) const = 0;
645
648
651 virtual void toFix(std::string&, const SbeMessage&) const = 0;
652
654 std::string toFix(const SbeMessage&, Char delimiter) const;
655
656protected:
658};
659
663Message : public FieldSet
664{
665public:
670 , binary_()
671 {
672 }
673
676 : FieldSet(binary_, r.accessor())
677 , binary_(r.binary_)
678 {
679 }
680
682 Message& operator = (const Message& r) ONIXS_ILINK3_NOTHROW
683 {
684 setAccessor(r.accessor());
685 this->binary_ = r.binary_;
686
687 return *this;
688 }
689
692 {
693 return accessor()->type();
694 }
695
701 {
702 assert(binary_.valid());
703
704 return accessor()->group(binary_, tag);
705 }
706
713 {
714 assert(binary_.valid());
715
716 return accessor()->group(binary_, tag, size);
717 }
718
729 {
730 return field(tag).cast<StrRef>();
731 }
732
743 {
744 set(tag, value);
745
746 return *this;
747 }
748
756 {
757 assert(binary_.valid());
758
759 return accessor()->calculateBinarySize(binary_);
760 }
761
763 void toFix(std::string& str) const
764 {
765 accessor()->toFix(str, binary_);
766 }
767
769 ONIXS_ILINK3_NODISCARD std::string toFix(Char delimiter = '\x1') const
770 {
771 return accessor()->toFix(binary_, delimiter);
772 }
773
776 {
777 return accessor()->toFix(binary_, '|');
778 }
779
787 {
788 assert(accessor());
789 assert(binary_.valid());
790
791 return binary_.version();
792 }
793
801 {
802 assert(accessor());
803 assert(binary_.valid());
804
805 return binary_.templateId();
806 }
807
808protected:
811 : FieldSet(binary_, &accessor)
812 , binary_(binary)
813 {
814 }
815
817
818private:
819 const MessageAccessor* accessor() const ONIXS_ILINK3_NOTHROW
820 {
821 const FieldAccessor* const parentAccessor = FieldSet::accessor();
822
823 assert(parentAccessor);
824 assert(dynamic_cast<const MessageAccessor*>(parentAccessor));
825
826 return static_cast<const MessageAccessor*>(parentAccessor);
827 }
828
829private:
830 SbeMessage binary_;
831};
832
834inline void toStr(std::string& str, const Message& message)
835{
836 message.toFix(str);
837}
838
840inline std::string toStr(const Message& message)
841{
842 std::string str;
843
844 toStr(str, message);
845
846 return str;
847}
848
850inline std::ostream& operator<<(std::ostream& stream, const Message& msg)
851{
852 return stream << msg.toString();
853}
854
#define ONIXS_ILINK3_LTWT_CLASS_DECL(name)
Definition ABI.h:96
#define ONIXS_ILINK3_LTWT_CLASS
Definition ABI.h:84
#define ONIXS_ILINK3_MESSAGING_TAGBASED_NAMESPACE_END
Definition ABI.h:153
#define ONIXS_ILINK3_MESSAGING_TAGBASED_NAMESPACE_BEGIN
Definition ABI.h:149
#define ONIXS_ILINK3_EXPORTED_STRUCT
Definition ABI.h:48
#define ONIXS_ILINK3_EXPLICIT
Definition Compiler.h:177
#define ONIXS_ILINK3_NODISCARD
Definition Compiler.h:185
#define ONIXS_ILINK3_NULLPTR
Definition Compiler.h:182
#define ONIXS_ILINK3_DEFAULT
Definition Compiler.h:202
#define ONIXS_ILINK3_NOTHROW
Definition Compiler.h:176
Operations over SBE-encoded repeating group entries.
Definition SbeMessage.h:379
Operations over a repeating group instance.
Definition SbeMessage.h:297
A field in a tag-based message.
Definition Field.h:30
Provides a tag-based access to fields stored in an SBE-encoded repeating group.
Definition Message.h:521
GroupEntry(const GroupEntry &r) noexcept
Initializes the instance as the copy of the given one.
Definition Message.h:533
GroupEntry(const GroupEntrySource &binary, const GroupEntryAccessor &accessor) noexcept
Full-initialized instances are constructed through descendants.
Definition Message.h:558
GroupEntry() noexcept
Initializes the instance which refers to nothing and thus represents a null instance.
Definition Message.h:525
Implements a tag-based repeating group over an SBE-encoded binary data.
Definition Message.h:581
Group()
Initializes the instance which refers to nothing and thus represent a null instance.
Definition Message.h:590
Group(const GroupEntriesSource &binary, const GroupEntryAccessor &accessor) noexcept
Initializes the instance over the binary data.
Definition Message.h:621
Size size() const noexcept
Number of entries in the repeating group being referred by the given instance.
Definition Message.h:604
GroupEntriesSource::Size Size
Number of repeating group entries.
Definition Message.h:586
Implements a tag-based interface over an SBE-encoded message.
Definition Message.h:664
std::string toFix(Char delimiter='\x1') const
Definition Message.h:769
std::string toString() const
Builds a human-readable tag=value representation.
Definition Message.h:775
Message(SbeMessage binary, const MessageAccessor &accessor) noexcept
Initializes the instance from an SBE-encoded message.
Definition Message.h:810
Message() noexcept
Initializes the message which refers to nothing and thus being a null-instance.
Definition Message.h:668
Group group(Tag tag, MessageSize size)
by its tag.
Definition Message.h:712
Message & setVarData(Tag tag, StrRef value)
Sets a variable-length field value.
Definition Message.h:742
MessageSize calculateBinarySize() const noexcept
Definition Message.h:755
void toFix(std::string &str) const
Builds a tag=value representation.
Definition Message.h:763
Group group(Tag tag) const noexcept
Definition Message.h:700
Message(const Message &r) noexcept
Initializes the instance as the copy of the given one.
Definition Message.h:675
The time point without the time-zone information.
Definition Time.h:468
UInt32 Tag
The type whose values are used to locate fields in tag-based messages.
Definition Tag.h:29
std::ostream & operator<<(std::ostream &stream, const Field &field)
Serializes into the given stream.
Definition Field.h:370
void toStr(std::string &str, const Message &message)
Serializes into a tag=value format.
Definition Message.h:834
SbeGroupEntries< GroupEntrySource, MessageSize, MessageSize, MessageSize > GroupEntriesSource
Definition Message.h:576
SbeGroupEntry< MessageSize > GroupEntrySource
Definition Message.h:506
FloatingPointDecimal< Int64, Int32 > Decimal
Universal decimal type.
MessageHeader::Version SchemaVersion
SBE-encoded data version type.
char Char
Character type alias.
Definition String.h:30
UInt16 MessageSize
Message length type.
Definition Aliases.h:29
std::basic_string_view< Char > StrRef
Definition StrRef.h:46
MessageHeader::TemplateId MessageTemplateId
Message type (template) identification.
Provides a tag-based access to fields stored in an SBE-encoded block.
Definition Message.h:35
virtual Field field(const BinaryBlockBase &, Tag) const noexcept=0
virtual void setField(BinaryBlockBase &, Tag, const Field &) const =0
Sets a field value by its tag.
virtual void resetField(BinaryBlockBase &, Tag) const =0
Resets a field value by its tag.
virtual void reset(BinaryBlockBase &) const noexcept=0
Resets all variable-length and optional fields.
FieldSet & set(Tag tag, Int16 value)
Assigns a given value.
FieldSet & set(Tag tag, const Field &field)
Assigns a given value.
Definition Message.h:321
Enumeration::Enum getEnumeration(Tag tag) const
Definition Message.h:297
FieldSet & setField(Tag tag, const Field &field)
Assigns the field by its tag.
Definition Message.h:91
FieldSet & set(Tag tag, const MaturityMonthYear &value)
Assigns a given value.
MaturityMonthYear getMaturityMonthYear(Tag tag) const
FieldSet(BinaryBlockBase &binary, const FieldAccessor *accessor) noexcept
Initializes the instance over the binary data.
Definition Message.h:478
FieldSet & set(Tag tag, UInt64 value)
Assigns a given value.
FieldSet & resetField(Tag tag)
Resets the field by its tag.
Definition Message.h:111
FieldSet & set(Tag tag, UInt32 value)
Assigns a given value.
FieldSet & reset() noexcept
Resets all variable-length and optional fields.
Definition Message.h:67
FieldSet & set(Tag tag, Int32 value)
Assigns a given value.
FieldSet & set(Tag tag, Char value)
Assigns a given value.
FieldSet & set(Tag tag, Int64 value)
Assigns a given value.
const FieldAccessor * accessor() const noexcept
Definition Message.h:488
FieldSet & set(Tag tag, Int8 value)
Assigns a given value.
FieldSet & set(Tag tag, BitSet value, typename BitSet::Bits *=nullptr)
Assigns a given value as a set.
Definition Message.h:331
void setAccessor(const FieldAccessor *obj) noexcept
Sets the FieldAccessor.
Definition Message.h:494
FieldSet & set(Tag tag, Timestamp value)
Assigns a given value.
FieldSet & set(Tag tag, StrRef value)
Assigns a given value.
FieldSet & set(Tag tag, UInt16 value)
Assigns a given value.
FieldSet & set(Tag tag, UInt8 value)
Assigns a given value.
Field field(Tag tag) const noexcept
Definition Message.h:80
FieldSet & set(Tag tag, const Decimal &value)
Assigns a given value.
Provides a tag-based access to fields stored in an SBE-encoded repeating group.
Definition Message.h:512
Implements tag-based services for an SBE-encoded message.
Definition Message.h:636
virtual MessageSize calculateBinarySize(const SbeMessage &) const noexcept=0
virtual void toFix(std::string &, const SbeMessage &) const =0
Serializes the given message into the tag=value presentation.
virtual Group group(const SbeMessage &, Tag) const noexcept=0