OnixS C++ CBOE CFE Binary Order Entry (BOE) Handler 1.12.0
API documentation
Loading...
Searching...
No Matches
BinaryMessage.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 <cassert>
28
29namespace OnixS
30{
31 namespace CboeCFE
32 {
33 namespace Trading
34 {
35 namespace BOE
36 {
38 template <class FieldValue>
40 {
41 static FieldValue extract(const void* p)
42 {
44 }
45 };
46
47 template<class MantissaType, class ExponentType>
56
61 template <class Block, class BlockSize>
63 {
66 const Block& block() const
67 {
68 return *static_cast<const Block*>(this);
69 }
70
71 protected:
73 template <class SubMessage>
74 const SubMessage submessage(BlockSize offset, BlockSize size) const
75 {
76 assert(block().binarySize() >= (offset + size));
77
78 const void* const data = advanceByBytes(block().binary(), offset);
79
80 return SubMessage(data, size);
81 }
82
84 template <class FieldValue>
85 const FieldValue& ordinaryRef(BlockSize offset) const
86 {
87 assert(block().binarySize() >= (offset + sizeof(FieldValue)));
88
89 const void* const fieldValue = advanceByBytes(block().binary(), offset);
90 return *static_cast <const FieldValue*>(fieldValue);
91 }
92
94 template <class FieldValue>
95 FieldValue ordinary(BlockSize offset) const
96 {
97 assert(block().binarySize() >= (offset + sizeof(FieldValue)));
98
99 return OrdinaryExtractor<FieldValue>::extract(advanceByBytes(block().binary(), offset));
100 }
101
106 template <class Enumeration>
107 typename Enumeration::Enum enumeration(BlockSize offset) const
108 {
109 typedef typename Enumeration::Base Base;
110
111 typedef typename Enumeration::Enum Enum;
112
113 return static_cast<Enum>( ordinary<Base>(offset));
114 }
115
120 template <BlockSize Size>
121 StrRef fixedStr(BlockSize offset) const
122 {
123 typedef Char Str[Size];
124
125 const Str& str = ordinaryRef<Str>(offset);
126
127 return StrRef(str, strnlen(str, Size));
128 }
129 };
130
133
135 class ONIXS_CBOE_CFE_BOE_API BinaryMessage : public BinaryFields<BinaryMessage, MessageSize>
136 {
137 const void* data_;
138 MessageSize size_;
139
140 public:
143
146 : data_(ONIXS_BATS_BOE_NULLPTR)
147 , size_(0)
148 {
149 }
150
153 const void* data,
154 MessageSize size)
155 : data_(data)
156 , size_(size)
157 {
158 assert(ONIXS_BATS_BOE_NULLPTR != data);
159 }
160
163 const BinaryMessage& other)
164 : data_(other.data_)
165 , size_(other.size_)
166 {
167 }
168
170 operator bool() const
171 {
172 return (ONIXS_BATS_BOE_NULLPTR != data_);
173 }
174
176 const void* binary() const
177 {
178 return data_;
179 }
180
183 {
184 return size_;
185 }
186
189 operator =(
190 const BinaryMessage& other)
191 {
192 data_ = other.data_;
193 size_ = other.size_;
194
195 return *this;
196 }
197 };
198 }
199 }
200 }
201}
Enumeration::Enum enumeration(BlockSize offset) const
const FieldValue & ordinaryRef(BlockSize offset) const
Returns value of a field by its offset.
StrRef fixedStr(BlockSize offset) const
FieldValue ordinary(BlockSize offset) const
Returns value of a field by its offset.
const SubMessage submessage(BlockSize offset, BlockSize size) const
Returns sub message.
Encapsulates services for manipulating little endian encoded messages.
const void * binary() const
Message content.
BinaryMessage()
Initializes blank instance referencing to nothing.
MessageSize BinarySize
Length of message binary data.
BinaryMessage(const void *data, MessageSize size)
Initializes instance over given memory block.
MessageSize binarySize() const
Size of message.
BinaryMessage(const BinaryMessage &other)
Initializes instance as copy of the other one.
MantissaType Mantissa
Aliases mantissa component type.
Definition Decimal.h:51
Provides efficient way of accessing text-based field values.
Definition String.h:46
Type * advanceByBytes(Type *pointer, ptrdiff_t distance)
Advances given pointer to a given offset (distance) in bytes.
Definition Memory.h:126
Binary2 MessageSize
Aliases message length type.
char Char
Character type alias.
Definition String.h:42
FieldValue unalignedCopy(const void *p) ONIXS_BATS_BOE_NOTHROW
Definition Memory.h:180
static FixedPointDecimal< MantissaType, ExponentType > extract(const void *p)
static FieldValue extract(const void *p)