OnixS C++ CME Streamlined Market Data Handler  1.1.0.5
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 
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 \
75  Cannot identify compiler toolset to define integral types. \
76  Please contact support@onixs.biz on further assistance.
77 
78 #endif
79 
80 //
81 
82 /// Integral constant.
83 template
84 <
85  typename Type,
86  Type Constant
87 >
89 {
90  /// Type of the constant.
91  typedef Type Value;
92 
93  /// Returns value of the constant.
94  operator Value() const
95  {
96  return Constant;
97  }
98 
99  /// Returns value of the constant.
100  Value operator()() const
101  {
102  return Constant;
103  }
104 
105  /// Returns value of the constant.
106  static const Value value()
107  {
108  return Constant;
109  }
110 };
111 
112 /// Serializes given integer into a string.
113 ONIXS_CMESTREAMLINEDMDH_EXPORTED
114 void
115 toStr(
116  std::string&,
117  Int8);
118 
119 /// Serializes given integer into a string.
120 inline
121 std::string
123  Int8 number)
124 {
125  std::string str;
126 
127  toStr(str, number);
128 
129  return str;
130 }
131 
132 /// Serializes given integer into a string.
133 ONIXS_CMESTREAMLINEDMDH_EXPORTED
134 void
135 toStr(
136  std::string&,
137  UInt8);
138 
139 /// Serializes given integer into a string.
140 inline
141 std::string
143  UInt8 number)
144 {
145  std::string str;
146 
147  toStr(str, number);
148 
149  return str;
150 }
151 
152 /// Serializes given integer into a string.
153 ONIXS_CMESTREAMLINEDMDH_EXPORTED
154 void
155 toStr(
156  std::string&,
157  Int16);
158 
159 /// Serializes given integer into a string.
160 inline
161 std::string
163  Int16 number)
164 {
165  std::string str;
166 
167  toStr(str, number);
168 
169  return str;
170 }
171 
172 /// Serializes given integer into a string.
173 ONIXS_CMESTREAMLINEDMDH_EXPORTED
174 void
175 toStr(
176  std::string&,
177  UInt16);
178 
179 /// Serializes given integer into a string.
180 inline
181 std::string
183  UInt16 number)
184 {
185  std::string str;
186 
187  toStr(str, number);
188 
189  return str;
190 }
191 
192 /// Serializes given integer into a string.
193 ONIXS_CMESTREAMLINEDMDH_EXPORTED
194 void
195 toStr(
196  std::string&,
197  Int32);
198 
199 /// Serializes given integer into a string.
200 inline
201 std::string
203  Int32 number)
204 {
205  std::string str;
206 
207  toStr(str, number);
208 
209  return str;
210 }
211 
212 /// Serializes given integer into a string.
213 ONIXS_CMESTREAMLINEDMDH_EXPORTED
214 void
215 toStr(
216  std::string&,
217  UInt32);
218 
219 /// Serializes given integer into a string.
220 inline
221 std::string
223  UInt32 number)
224 {
225  std::string str;
226 
227  toStr(str, number);
228 
229  return str;
230 }
231 
232 /// Serializes given integer into a string.
233 ONIXS_CMESTREAMLINEDMDH_EXPORTED
234 void
235 toStr(
236  std::string&,
237  Int64);
238 
239 /// Serializes given integer into a string.
240 inline
241 std::string
243  Int64 number)
244 {
245  std::string str;
246 
247  toStr(str, number);
248 
249  return str;
250 }
251 
252 /// Serializes given integer into a string.
253 ONIXS_CMESTREAMLINEDMDH_EXPORTED
254 void
255 toStr(
256  std::string&,
257  UInt64);
258 
259 /// Serializes given integer into a string.
260 inline
261 std::string
263  UInt64 number)
264 {
265  std::string str;
266 
267  toStr(str, number);
268 
269  return str;
270 }
271 
272 /// Serializes given constant into a string.
273 template
274 <
275  typename Type,
276  Type Constant
277 >
278 inline
279 void
281  std::string& str,
283 {
284  toStr(str, constant());
285 }
286 
287 /// Serializes given constant into a string.
288 template
289 <
290  typename Type,
291  Type Constant
292 >
293 inline
294 std::string
297 {
298  std::string str;
299 
300  toStr(str, constant);
301 
302  return str;
303 }
304 
UInt64 UInt64
uInt64.
Definition: Fields.h:187
UInt16 UInt16
uInt16.
Definition: Fields.h:179
Type Value
Type of the constant.
Definition: Integral.h:91
std::string toStr(IntegralConstant< Type, Constant > constant)
Serializes given constant into a string.
Definition: Integral.h:295
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_END
Definition: Bootstrap.h:172
Value operator()() const
Returns value of the constant.
Definition: Integral.h:100
static const Value value()
Returns value of the constant.
Definition: Integral.h:106
UInt32 UInt32
uInt32.
Definition: Fields.h:183
#define ONIXS_CMESTREAMLINEDMDH_NAMESPACE_BEGIN
Definition: Bootstrap.h:168