OnixS C++ CME MDP Premium Market Data Handler  5.8.9
API Documentation
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 <string>
24 
25 #include <OnixS/CME/MDH/String.h>
26 
28 
29 #if defined(_MSC_VER)
30 
31 typedef signed char Int8;
32 typedef unsigned char UInt8;
33 
34 typedef signed short Int16;
35 typedef unsigned short UInt16;
36 
37 typedef signed int Int32;
38 typedef unsigned int UInt32;
39 
40 typedef signed long long Int64;
41 typedef unsigned long long UInt64;
42 
43 #elif defined(__GNUC__)
44 
45 typedef signed char Int8;
46 typedef unsigned char UInt8;
47 
48 typedef signed short Int16;
49 typedef unsigned short UInt16;
50 
51 # if defined(__LP64__)
52 
53 typedef signed int Int32;
54 typedef unsigned int UInt32;
55 
56 typedef signed long Int64;
57 typedef unsigned long UInt64;
58 
59 # else
60 
61 typedef signed int Int32;
62 typedef unsigned int UInt32;
63 
64 typedef signed long long Int64;
65 typedef unsigned long long UInt64;
66 
67 # endif
68 
69 #else
70 
71 // Compiler is not (yet) supported.
72 // Integral types must be defined explicitly.
73 
74 # error Cannot identify compiler toolset to define integral types. \
75  Please contact support@onixs.biz on further assistance.
76 
77 #endif
78 
79 //
80 
81 /// Integral constant.
82 template <typename Type, Type Constant>
84 {
85  /// Type of the constant.
86  typedef Type Value;
87 
88  /// Returns value of the constant.
89  operator Value() const
90  {
91  return Constant;
92  }
93 
94  /// Returns value of the constant.
95  Value operator()() const
96  {
97  return Constant;
98  }
99 
100  /// Returns value of the constant.
101  static Value value()
102  {
103  return Constant;
104  }
105 };
106 
107 /// Serializes given integer into a string.
109 void toStr(std::string&, Int8);
110 
111 /// Serializes given integer into a string.
112 inline std::string toStr(Int8 number)
113 {
114  std::string str;
115 
116  toStr(str, number);
117 
118  return str;
119 }
120 
121 /// Serializes given integer into a string.
123 void toStr(std::string&, UInt8);
124 
125 /// Serializes given integer into a string.
126 inline std::string toStr(UInt8 number)
127 {
128  std::string str;
129 
130  toStr(str, number);
131 
132  return str;
133 }
134 
135 /// Serializes given integer into a string.
137 void toStr(std::string&, Int16);
138 
139 /// Serializes given integer into a string.
140 inline std::string toStr(Int16 number)
141 {
142  std::string str;
143 
144  toStr(str, number);
145 
146  return str;
147 }
148 
149 /// Serializes given integer into a string.
151 void toStr(std::string&, UInt16);
152 
153 /// Serializes given integer into a string.
154 inline std::string toStr(UInt16 number)
155 {
156  std::string str;
157 
158  toStr(str, number);
159 
160  return str;
161 }
162 
163 /// Serializes given integer into a string.
165 void toStr(std::string&, Int32);
166 
167 /// Serializes given integer into a string.
168 inline std::string toStr(Int32 number)
169 {
170  std::string str;
171 
172  toStr(str, number);
173 
174  return str;
175 }
176 
177 /// Serializes given integer into a string.
179 void toStr(std::string&, UInt32);
180 
181 /// Serializes given integer into a string.
182 inline std::string toStr(UInt32 number)
183 {
184  std::string str;
185 
186  toStr(str, number);
187 
188  return str;
189 }
190 
191 /// Serializes given integer into a string.
193 void toStr(std::string&, Int64);
194 
195 /// Serializes given integer into a string.
196 inline std::string toStr(Int64 number)
197 {
198  std::string str;
199 
200  toStr(str, number);
201 
202  return str;
203 }
204 
205 /// Serializes given integer into a string.
207 void toStr(std::string&, UInt64);
208 
209 /// Serializes given integer into a string.
210 inline std::string toStr(UInt64 number)
211 {
212  std::string str;
213 
214  toStr(str, number);
215 
216  return str;
217 }
218 
219 /// Serializes given constant into a string.
220 template <typename Type, Type Constant>
221 inline void toStr(std::string& str, IntegralConstant<Type, Constant> constant)
222 {
223  toStr(str, constant());
224 }
225 
226 /// Serializes given constant into a string.
227 template <typename Type, Type Constant>
228 inline std::string toStr(IntegralConstant<Type, Constant> constant)
229 {
230  std::string str;
231 
232  toStr(str, constant);
233 
234  return str;
235 }
236 
237 //
238 
239 /// Deserializes numeric value
240 /// from its text representation.
241 ///
242 /// Returns 'true' if the given buffer
243 /// contains a valid representation of a
244 /// number. Otherwise, 'false' is returned.
246 bool fromStr(Int8&, const Char*, size_t);
247 
248 /// Deserializes numeric value
249 /// from its text representation.
250 ///
251 /// Returns 'true' if the given buffer
252 /// contains a valid representation of a
253 /// number. Otherwise, 'false' is returned.
255 bool fromStr(UInt8&, const Char*, size_t);
256 
257 /// Deserializes numeric value
258 /// from its text representation.
259 ///
260 /// Returns 'true' if the given buffer
261 /// contains a valid representation of a
262 /// number. Otherwise, 'false' is returned.
264 bool fromStr(Int16&, const Char*, size_t);
265 
266 /// Deserializes numeric value
267 /// from its text representation.
268 ///
269 /// Returns 'true' if the given buffer
270 /// contains a valid representation of a
271 /// number. Otherwise, 'false' is returned.
273 bool fromStr(UInt16&, const Char*, size_t);
274 
275 /// Deserializes numeric value
276 /// from its text representation.
277 ///
278 /// Returns 'true' if the given buffer
279 /// contains a valid representation of a
280 /// number. Otherwise, 'false' is returned.
282 bool fromStr(Int32&, const Char*, size_t);
283 
284 /// Deserializes numeric value
285 /// from its text representation.
286 ///
287 /// Returns 'true' if the given buffer
288 /// contains a valid representation of a
289 /// number. Otherwise, 'false' is returned.
291 bool fromStr(UInt32&, const Char*, size_t);
292 
293 /// Deserializes numeric value
294 /// from its text representation.
295 ///
296 /// Returns 'true' if the given buffer
297 /// contains a valid representation of a
298 /// number. Otherwise, 'false' is returned.
300 bool fromStr(Int64&, const Char*, size_t);
301 
302 /// Deserializes numeric value
303 /// from its text representation.
304 ///
305 /// Returns 'true' if the given buffer
306 /// contains a valid representation of a
307 /// number. Otherwise, 'false' is returned.
309 bool fromStr(UInt64&, const Char*, size_t);
310 
Int32 Int32
int32.
Definition: Fields.h:60
bool fromStr(UInt64 &, const Char *, size_t)
Deserializes numeric value from its text representation.
UInt32 UInt32
uInt32.
Definition: Fields.h:192
Value operator()() const
Returns value of the constant.
Definition: Integral.h:95
UInt8 UInt8
uInt8.
Definition: Fields.h:198
Type Value
Type of the constant.
Definition: Integral.h:86
char Char
Character type alias.
Definition: String.h:36
std::string toStr(IntegralConstant< Type, Constant > constant)
Serializes given constant into a string.
Definition: Integral.h:228
UInt64 UInt64
uInt64.
Definition: Fields.h:195
Int16 Int16
int16.
Definition: Fields.h:57
#define ONIXS_CMEMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:67
#define ONIXS_CMEMDH_EXPORTED
Definition: Compiler.h:160
UInt16 UInt16
uInt16 optional.
Definition: Fields.h:189
Int8 Int8
int8.
Definition: Fields.h:63
static Value value()
Returns value of the constant.
Definition: Integral.h:101
Integral constant.
Definition: Integral.h:83
#define ONIXS_CMEMDH_NAMESPACE_END
Definition: Bootstrap.h:68