OnixS C++ B3 Binary UMDF Market Data Handler 1.10.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Integral.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
25
26#include <string>
27
29
30#if defined (_MSC_VER)
31
32typedef signed char Int8;
33typedef unsigned char UInt8;
34
35typedef signed short Int16;
36typedef unsigned short UInt16;
37
38typedef signed int Int32;
39typedef unsigned int UInt32;
40
41typedef signed long long Int64;
42typedef unsigned long long UInt64;
43
44#elif defined (__GNUC__)
45
46typedef signed char Int8;
47typedef unsigned char UInt8;
48
49typedef signed short Int16;
50typedef unsigned short UInt16;
51
52#if defined (__LP64__)
53
54typedef signed int Int32;
55typedef unsigned int UInt32;
56
57typedef signed long Int64;
58typedef unsigned long UInt64;
59
60#else
61
62typedef signed int Int32;
63typedef unsigned int UInt32;
64
65typedef signed long long Int64;
66typedef unsigned long long UInt64;
67
68#endif
69
70#else
71
72// Compiler is not (yet) supported.
73// Integral types must be defined explicitly.
74
75#error \
76 Cannot identify compiler toolset to define integral types. \
77 Please contact support@onixs.biz on further assistance.
78
79#endif
80
82template
83<
84 typename Type,
85 Type Constant
86>
88{
90 typedef Type Value;
91
93 constexpr
94 operator Value() const noexcept
95 {
96 return Constant;
97 }
98
100 constexpr
102 {
103 return Constant;
104 }
105
107 constexpr
109 {
110 return Constant;
111 }
112};
113
116void toStr(std::string&, Int8);
117
119inline
120ONIXS_B3_UMDF_MD_NODISCARD
121std::string
122toStr(
123 Int8 number)
124{
125 std::string str;
126
127 toStr(str, number);
128
129 return str;
130}
131
134void
136 std::string&,
137 UInt8);
138
140inline
141ONIXS_B3_UMDF_MD_NODISCARD
142std::string
143toStr(
144 UInt8 number)
145{
146 std::string str;
147
148 toStr(str, number);
149
150 return str;
151}
152
155void
157 std::string&,
158 Int16);
159
161inline
162ONIXS_B3_UMDF_MD_NODISCARD
163std::string
164toStr(
165 Int16 number)
166{
167 std::string str;
168
169 toStr(str, number);
170
171 return str;
172}
173
176void
178 std::string&,
179 UInt16);
180
182inline
183ONIXS_B3_UMDF_MD_NODISCARD
184std::string
185toStr(
186 UInt16 number)
187{
188 std::string str;
189
190 toStr(str, number);
191
192 return str;
193}
194
197void
199 std::string&,
200 Int32);
201
203inline
204ONIXS_B3_UMDF_MD_NODISCARD
205std::string
206toStr(
207 Int32 number)
208{
209 std::string str;
210
211 toStr(str, number);
212
213 return str;
214}
215
218void
220 std::string&,
221 UInt32);
222
224inline
225ONIXS_B3_UMDF_MD_NODISCARD
226std::string
227toStr(
228 UInt32 number)
229{
230 std::string str;
231
232 toStr(str, number);
233
234 return str;
235}
236
239void
241 std::string&,
242 Int64);
243
245inline
246ONIXS_B3_UMDF_MD_NODISCARD
247std::string
248toStr(
249 Int64 number)
250{
251 std::string str;
252
253 toStr(str, number);
254
255 return str;
256}
257
260void
262 std::string&,
263 UInt64);
264
266inline
267ONIXS_B3_UMDF_MD_NODISCARD
268std::string
269toStr(
270 UInt64 number)
271{
272 std::string str;
273
274 toStr(str, number);
275
276 return str;
277}
278
281ONIXS_B3_UMDF_MD_NODISCARD
282size_t
283toStr(
284 Int8,
285 Char*,
286 size_t);
287
288
291ONIXS_B3_UMDF_MD_NODISCARD
292size_t
293toStr(
294 UInt8,
295 Char*,
296 size_t);
297
300ONIXS_B3_UMDF_MD_NODISCARD
301size_t
302toStr(
303 Int16,
304 Char*,
305 size_t);
306
307
310ONIXS_B3_UMDF_MD_NODISCARD
311size_t
312toStr(
313 UInt16,
314 Char*,
315 size_t);
316
317
320ONIXS_B3_UMDF_MD_NODISCARD
321size_t
322toStr(
323 Int32,
324 Char*,
325 size_t);
326
327
330size_t
331ONIXS_B3_UMDF_MD_NODISCARD
332toStr(
333 UInt32,
334 Char*,
335 size_t);
336
339ONIXS_B3_UMDF_MD_NODISCARD
340size_t
341toStr(
342 Int64,
343 Char*,
344 size_t);
345
346
349ONIXS_B3_UMDF_MD_NODISCARD
350size_t
351toStr(
352 UInt64,
353 Char*,
354 size_t);
355
357template
358<
359 typename Type,
360 Type Constant
361>
362inline
363void
365 std::string& str,
367{
368 toStr(str, constant());
369}
370
372template
373<
374 typename Type,
375 Type Constant
376>
377inline
378ONIXS_B3_UMDF_MD_NODISCARD
379std::string
380toStr(
382 <Type, Constant> constant)
383{
384 std::string str;
385
386 toStr(str, constant);
387
388 return str;
389}
390
396ONIXS_B3_UMDF_MD_NODISCARD
397bool fromStr(Int8&, const Char*, size_t) noexcept;
398
403inline ONIXS_B3_UMDF_MD_NODISCARD
404bool fromStr(Int8& value, const std::string& str) noexcept
405{
406 return
407 fromStr(
408 value,
409 str.c_str(),
410 str.size());
411}
412
418ONIXS_B3_UMDF_MD_NODISCARD
419bool
420fromStr(
421 UInt8&,
422 const Char*,
423 size_t) noexcept;
424
429inline
430ONIXS_B3_UMDF_MD_NODISCARD
431bool fromStr(
432 UInt8& value,
433 const std::string& str) noexcept
434{
435 return
436 fromStr(
437 value,
438 str.c_str(),
439 str.size());
440}
441
447ONIXS_B3_UMDF_MD_NODISCARD
448bool
449fromStr(
450 Int16&,
451 const Char*,
452 size_t) noexcept;
453
458inline
459ONIXS_B3_UMDF_MD_NODISCARD
460bool fromStr(
461 Int16& value,
462 const std::string& str) noexcept
463{
464 return
465 fromStr(
466 value,
467 str.c_str(),
468 str.size());
469}
470
476ONIXS_B3_UMDF_MD_NODISCARD
477bool
478fromStr(
479 UInt16&,
480 const Char*,
481 size_t) noexcept;
482
487inline ONIXS_B3_UMDF_MD_NODISCARD
488bool fromStr(
489 UInt16& value,
490 const std::string& str) noexcept
491{
492 return
493 fromStr(
494 value,
495 str.c_str(),
496 str.size());
497}
498
504ONIXS_B3_UMDF_MD_NODISCARD
505bool
506fromStr(
507 Int32&,
508 const Char*,
509 size_t) noexcept;
510
515inline
516ONIXS_B3_UMDF_MD_NODISCARD
517bool fromStr(
518 Int32& value,
519 const std::string& str) noexcept
520{
521 return
522 fromStr(
523 value,
524 str.c_str(),
525 str.size());
526}
527
533ONIXS_B3_UMDF_MD_NODISCARD
534bool
535fromStr(
536 UInt32&,
537 const Char*,
538 size_t) noexcept;
539
544inline
545ONIXS_B3_UMDF_MD_NODISCARD
546bool fromStr(
547 UInt32& value,
548 const std::string& str) noexcept
549{
550 return
551 fromStr(
552 value,
553 str.c_str(),
554 str.size());
555}
556
562ONIXS_B3_UMDF_MD_NODISCARD
563bool
564fromStr(
565 Int64&,
566 const Char*,
567 size_t) noexcept;
568
573inline
574ONIXS_B3_UMDF_MD_NODISCARD
575bool fromStr(
576 Int64& value,
577 const std::string& str) noexcept
578{
579 return
580 fromStr(
581 value,
582 str.c_str(),
583 str.size());
584}
585
591ONIXS_B3_UMDF_MD_NODISCARD
592bool
593fromStr(
594 UInt64&,
595 const Char*,
596 size_t) noexcept;
597
602inline
603ONIXS_B3_UMDF_MD_NODISCARD
604bool fromStr(
605 UInt64& value,
606 const std::string& str) noexcept
607{
608 return
609 fromStr(
610 value,
611 str.c_str(),
612 str.size());
613}
614
#define ONIXS_B3_UMDF_MD_MESSAGING_NAMESPACE_END
Definition ABI.h:158
#define ONIXS_B3_UMDF_MD_EXPORTED
Definition ABI.h:37
#define ONIXS_B3_UMDF_MD_MESSAGING_NAMESPACE_BEGIN
Definition ABI.h:153
Int8 Int8
1-byte signed integer, from -128 to 127; if optional, null value is -128.
Definition Fields.h:34
Int64 Int64
8-byte signed integer, from -9223372036854775808 (-2^63) to 9223372036854775807 (2^63-1).
Definition Fields.h:46
UInt64 UInt64
8-byte unsigned integer, from 0 to 18446744073709551615 (2^64-1).
Definition Fields.h:62
Int32 Int32
4-byte signed integer, from -2147483648 to 2147483647; if optional, null value is -2147483648.
Definition Fields.h:42
UInt32 UInt32
4-byte unsigned integer, from 0 to 4294967295 (2^32-1).
Definition Fields.h:58
void toStr(std::string &str, Char character)
Appends the character to the given std::string instance.
Definition String.h:34
Int16 Int16
2-byte signed integer, from -32768 to 32767; if optional, null value is -32768.
Definition Fields.h:38
UInt8 UInt8
1-byte unsigned integer, from 0 to 255.
Definition Fields.h:50
UInt16 UInt16
2-byte unsigned integer, from 0 to 65535.
Definition Fields.h:54
Messaging::UInt16 UInt16
Definition Integral.h:34
Messaging::UInt8 UInt8
Definition Integral.h:31
Messaging::Int8 Int8
Definition Integral.h:30
void toStr(std::string &str, TimeSpan timeSpan, TimeSpanFormat::Enum format=TimeSpanFormat::SDHHMMSSnsec)
Appends timespan formatted in specified pattern to given string.
Definition Time.h:400
Messaging::Int32 Int32
Definition Integral.h:36
Messaging::UInt64 UInt64
Definition Integral.h:40
Messaging::UInt32 UInt32
Definition Integral.h:37
ONIXS_B3_UMDF_MD_API bool fromStr(Timestamp &, const char *, size_t)
De-serializes a timestamp from the given string.
Messaging::Int64 Int64
Definition Integral.h:39
Messaging::Int16 Int16
Definition Integral.h:33