OnixS C++ CBOE CFE Binary Order Entry (BOE) Handler 1.12.0
API documentation
Loading...
Searching...
No Matches
Defines.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable ONIXS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19
20#pragma once
21
27
28#include <string>
29#include <ostream>
30
31namespace OnixS
32{
33 namespace CboeCFE
34 {
35 namespace Trading
36 {
37 namespace BOE
38 {
39 typedef unsigned short Port;
40
41
43 struct ONIXS_CBOE_CFE_BOE_API StringTraits
44 {
45 static void fillBufferAndAddSpaces(Byte* buffer, size_t size, Byte filler, const char* data, size_t dataSize);
46
47 static void fillBufferAndAddSpaces(Byte* buffer, size_t size, Byte filler, StrRef data)
48 {
49 fillBufferAndAddSpaces(buffer, size, filler, data.items(), data.size());
50 }
51
52 static void fillBufferAndAddSpaces(Byte* buffer, size_t size, Byte filler, Byte value);
53 };
54
56 template <size_t N, Byte FILLER = 0>
57 struct ONIXS_CBOE_CFE_BOE_API String
58 {
60
62 size_t size() const
63 {
64 return N;
65 }
66
71
72 String(const std::string& value)
73 {
75 }
76
77 String(Byte value)
78 {
80 }
81
83 std::string toString () const
84 {
85 return std::string ((const char*)data, strnlen((const char*)data, N));
86 }
87
90 {
91 return StrRef((const char*)data, strnlen((const char*)data, N));
92 }
93
96 {
97 return toStrRef();
98 }
99
101 String<N>& operator =(const StrRef value)
102 {
103 StringTraits::fillBufferAndAddSpaces(data, N, FILLER, value.items(), value.size());
104
105 return *this;
106 }
107
109 bool operator == (const String<N>& other) const
110 {
111 return ( 0 == memcmp(data, other.data, N));
112 }
113
115 bool operator != (const String<N>& other) const
116 {
117 return ( 0 != memcmp(data, other.data, N));
118 }
119 };
120
121 template <size_t N>
122 bool operator == (const String<N>& ref, const std::string& str)
123 {
124 return ref == String<N>(str);
125 }
126
127 template <size_t N>
128 bool operator != (const String<N>& ref, const std::string& str)
129 {
130 return ref != String<N>(str);
131 }
132
133 template <size_t N>
134 bool operator == (const String<N>& ref, Byte ch)
135 {
136 return ref.size() == 1 && ref == String<N>(ch);
137 }
138
139 template <size_t N>
140 bool operator != (const String<N>& ref, Byte ch)
141 {
142 return ref.size() != 1 || ref != String<N>(ch);
143 }
144
145 template <size_t N>
146 std::ostream& operator << (std::ostream& stream, const String<N>& value)
147 {
148 stream << '\'' << value.toString () << '\'';
149 return stream;
150 }
151
153 template <size_t N>
154 void toStr(std::string& str, const String<N>& value)
155 {
156 str.append((const char*)value.data, strnlen((const char*)value.data, N));
157 }
158
160 template <size_t N>
161 inline std::string toStr(const String<N>& value)
162 {
163 std::string str;
164
165 toStr(str, value);
166
167 return str;
168 }
169
170 typedef UInt8 Binary1;
171 typedef UInt16 Binary2;
172 typedef UInt32 Binary4;
173 typedef UInt64 Binary8;
174
175 typedef Int32 SignedBinary4;
176
178 typedef
180 <
181 Int64,
182 IntegralConstant<Int8, -4>
183 >
185
186 template <size_t N>
187 struct ONIXS_CBOE_CFE_BOE_API Alpha : public String<N>
188 {
189 using String<N>::operator=;
190 };
191
192 template <size_t N>
193 struct ONIXS_CBOE_CFE_BOE_API Alphanumeric : public String<N>
194 {
195 using String<N>::operator=;
196 };
197
198 template <size_t N>
199 struct ONIXS_CBOE_CFE_BOE_API Text : public String<N>
200 {
201 using String<N>::operator=;
202 };
203
204 typedef UInt64 DateTime;
205 typedef UInt32 Date;
206
207 struct ONIXS_CBOE_CFE_BOE_API Unit
208 {
211
213 {
214 return number_;
215 }
216
218 {
219 return sequence_;
220 }
221
224
225 size_t serializeTo(unsigned char*) const ONIXS_BATS_BOE_NOEXCEPT;
226 };
227
229
230 struct NotImplementedException : public std::runtime_error
231 {
233 : std::runtime_error("Not implemented")
234 {}
235 };
236
238
240 {
241 static const SeqNumber InvalidValue = SeqNumber(-1);
242 };
243 }
244 }
245 }
246}
247
#define ONIXS_BATS_BOE_NOEXCEPT
Definition ABI.h:49
#define ONIXS_CBOE_CFE_BOE_DECLARE_T0_STR_FUNCTIONS(Type)
Definition ABI.h:38
Provides efficient way of accessing text-based field values.
Definition String.h:46
size_t size() const ONIXS_BATS_BOE_NOEXCEPT
Number of chars.
Definition String.h:103
const Char * items() const ONIXS_BATS_BOE_NOEXCEPT
Read-only content.
Definition String.h:97
bool operator!=(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
Definition Decimal.h:117
std::ostream & operator<<(std::ostream &stream, const FixedPointDecimal< Mantissa, Exponent > &number)
Definition Decimal.h:174
FixedPointDecimal< Int64, IntegralConstant< Int8, -4 > > BinaryPrice
Binary Price.
Definition Defines.h:184
StrRef constructStrRef(const char(&value)[Size])
Definition String.h:404
void toStr(std::string &str, const FixedPointDecimal< Mantissa, Exponent > &number)
Serializes fixed-point decimal into a string.
Definition Decimal.h:156
bool operator==(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
Definition Decimal.h:110
UInt8 Byte
Alias for Byte.
Definition Memory.h:37
static void fillBufferAndAddSpaces(Byte *buffer, size_t size, Byte filler, const char *data, size_t dataSize)
static void fillBufferAndAddSpaces(Byte *buffer, size_t size, Byte filler, Byte value)
static void fillBufferAndAddSpaces(Byte *buffer, size_t size, Byte filler, StrRef data)
Definition Defines.h:47
ASCII encoded, right-padded with filler.
Definition Defines.h:58
std::string toString() const
Returns string representation.
Definition Defines.h:83
String(const std::string &value)
Definition Defines.h:72
StrRef toStrRef() const ONIXS_BATS_BOE_NOEXCEPT
Constructs StrRef instance.
Definition Defines.h:89
Unit(Binary1 number, Binary4 sequence)
size_t serializeTo(unsigned char *) const ONIXS_BATS_BOE_NOEXCEPT