OnixS C++ B3 BOE Binary Order Entry 1.3.0
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
23#include <OnixS/B3/BOE/ABI.h>
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
94 operator Value() const ONIXS_B3_BOE_NOTHROW
95 {
96 return Constant;
97 }
98
102 {
103 return Constant;
104 }
105
109 {
110 return Constant;
111 }
112};
113
116void toStr(std::string&, Int8);
117
119inline
121std::string
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
142std::string
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
163std::string
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
184std::string
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
205std::string
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
226std::string
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
247std::string
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
268std::string
270 UInt64 number)
271{
272 std::string str;
273
274 toStr(str, number);
275
276 return str;
277}
278
282size_t
284 Int8,
285 Char*,
286 size_t);
287
288
292size_t
294 UInt8,
295 Char*,
296 size_t);
297
301size_t
303 Int16,
304 Char*,
305 size_t);
306
307
311size_t
313 UInt16,
314 Char*,
315 size_t);
316
317
321size_t
323 Int32,
324 Char*,
325 size_t);
326
327
330size_t
333 UInt32,
334 Char*,
335 size_t);
336
340size_t
342 Int64,
343 Char*,
344 size_t);
345
346
350size_t
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
379std::string
382 <Type, Constant> constant)
383{
384 std::string str;
385
386 toStr(str, constant);
387
388 return str;
389}
390
397bool fromStr(Int8&, const Char*, size_t) ONIXS_B3_BOE_NOTHROW;
398
404bool fromStr(Int8& value, const std::string& str) ONIXS_B3_BOE_NOTHROW
405{
406 return
407 fromStr(
408 value,
409 str.c_str(),
410 str.size());
411}
412
419bool
421 UInt8&,
422 const Char*,
423 size_t) ONIXS_B3_BOE_NOTHROW;
424
429inline
432 UInt8& value,
433 const std::string& str) ONIXS_B3_BOE_NOTHROW
434{
435 return
436 fromStr(
437 value,
438 str.c_str(),
439 str.size());
440}
441
448bool
450 Int16&,
451 const Char*,
452 size_t) ONIXS_B3_BOE_NOTHROW;
453
458inline
461 Int16& value,
462 const std::string& str) ONIXS_B3_BOE_NOTHROW
463{
464 return
465 fromStr(
466 value,
467 str.c_str(),
468 str.size());
469}
470
477bool
479 UInt16&,
480 const Char*,
481 size_t) ONIXS_B3_BOE_NOTHROW;
482
489 UInt16& value,
490 const std::string& str) ONIXS_B3_BOE_NOTHROW
491{
492 return
493 fromStr(
494 value,
495 str.c_str(),
496 str.size());
497}
498
505bool
507 Int32&,
508 const Char*,
509 size_t) ONIXS_B3_BOE_NOTHROW;
510
515inline
518 Int32& value,
519 const std::string& str) ONIXS_B3_BOE_NOTHROW
520{
521 return
522 fromStr(
523 value,
524 str.c_str(),
525 str.size());
526}
527
534bool
536 UInt32&,
537 const Char*,
538 size_t) ONIXS_B3_BOE_NOTHROW;
539
544inline
547 UInt32& value,
548 const std::string& str) ONIXS_B3_BOE_NOTHROW
549{
550 return
551 fromStr(
552 value,
553 str.c_str(),
554 str.size());
555}
556
563bool
565 Int64&,
566 const Char*,
567 size_t) ONIXS_B3_BOE_NOTHROW;
568
573inline
576 Int64& value,
577 const std::string& str) ONIXS_B3_BOE_NOTHROW
578{
579 return
580 fromStr(
581 value,
582 str.c_str(),
583 str.size());
584}
585
592bool
594 UInt64&,
595 const Char*,
596 size_t) ONIXS_B3_BOE_NOTHROW;
597
602inline
605 UInt64& value,
606 const std::string& str) ONIXS_B3_BOE_NOTHROW
607{
608 return
609 fromStr(
610 value,
611 str.c_str(),
612 str.size());
613}
614
#define ONIXS_B3_BOE_MESSAGING_NAMESPACE_END
Definition ABI.h:144
#define ONIXS_B3_BOE_MESSAGING_NAMESPACE_BEGIN
Definition ABI.h:140
#define ONIXS_B3_BOE_CONSTEXPR
Definition Compiler.h:185
#define ONIXS_B3_BOE_NODISCARD
Definition Compiler.h:191
#define ONIXS_B3_BOE_EXPORTED
Definition Compiler.h:181
#define ONIXS_B3_BOE_NOTHROW
Definition Compiler.h:182
char Char
Character type alias.
Definition String.h:30
std::string toStr(const FixedPointDecimal< Mantissa, Exponent > &)
Serializes a fixed-point decimal into a string.
bool fromStr(Decimal &, const Char *, size_t) noexcept
Deserializes a decimal number from the given text presentation.
constexpr Value operator()() const noexcept
Definition Integral.h:101
static constexpr Value value() noexcept
Definition Integral.h:108
Type Value
Type of the constant.
Definition Integral.h:90