OnixS C++ eSpeed ITCH Market Data Handler  1.7.3
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 
27 
29 
30 #if defined (_MSC_VER)
31 
32  typedef signed char Int8;
33  typedef unsigned char UInt8;
34 
35  typedef signed short Int16;
36  typedef unsigned short UInt16;
37 
38  typedef signed int Int32;
39  typedef unsigned int UInt32;
40 
41  typedef signed long long Int64;
42  typedef unsigned long long UInt64;
43 
44 #elif defined (__GNUC__)
45 
46  typedef signed char Int8;
47  typedef unsigned char UInt8;
48 
49  typedef signed short Int16;
50  typedef unsigned short UInt16;
51 
52  #if defined (__LP64__)
53 
54  typedef signed int Int32;
55  typedef unsigned int UInt32;
56 
57  typedef signed long Int64;
58  typedef unsigned long UInt64;
59 
60 #else
61 
62  typedef signed int Int32;
63  typedef unsigned int UInt32;
64 
65  typedef signed long long Int64;
66  typedef 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 
81 //
82 
83 /// Integral constant.
84 template<typename Type, Type Constant>
86 {
87  /// Type of the constant.
88  typedef Type Value;
89 
90  /// Returns value of the constant.
91  operator Value() const
92  {
93  return Constant;
94  }
95 
96  /// Returns value of the constant.
97  Value operator()() const
98  {
99  return Constant;
100  }
101 
102  /// Returns value of the constant.
103  static const Value value()
104  {
105  return Constant;
106  }
107 };
108 
109 /// Serializes given integer into a string.
110 ONIXS_ESPEED_ITCH_API void toStr(std::string&, Int8);
111 
112 /// Serializes given integer into a string.
113 inline std::string toStr(Int8 number)
114 {
115  std::string str;
116 
117  toStr(str, number);
118 
119  return str;
120 }
121 
122 /// Serializes given integer into a string.
123 ONIXS_ESPEED_ITCH_API 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.
136 ONIXS_ESPEED_ITCH_API void toStr(std::string&, Int16);
137 
138 /// Serializes given integer into a string.
139 inline std::string toStr(Int16 number)
140 {
141  std::string str;
142 
143  toStr(str, number);
144 
145  return str;
146 }
147 
148 /// Serializes given integer into a string.
149 ONIXS_ESPEED_ITCH_API void toStr(std::string&, UInt16);
150 
151 /// Serializes given integer into a string.
152 inline std::string toStr(UInt16 number)
153 {
154  std::string str;
155 
156  toStr(str, number);
157 
158  return str;
159 }
160 
161 /// Serializes given integer into a string.
162 ONIXS_ESPEED_ITCH_API void toStr(std::string&, Int32);
163 
164 /// Serializes given integer into a string.
165 inline std::string toStr(Int32 number)
166 {
167  std::string str;
168 
169  toStr(str, number);
170 
171  return str;
172 }
173 
174 /// Serializes given integer into a string.
175 ONIXS_ESPEED_ITCH_API void toStr(std::string&, UInt32);
176 
177 /// Serializes given integer into a string.
178 inline std::string toStr(UInt32 number)
179 {
180  std::string str;
181 
182  toStr(str, number);
183 
184  return str;
185 }
186 
187 /// Serializes given integer into a string.
188 ONIXS_ESPEED_ITCH_API void toStr(std::string&, Int64);
189 
190 /// Serializes given integer into a string.
191 inline std::string toStr(Int64 number)
192 {
193  std::string str;
194 
195  toStr(str, number);
196 
197  return str;
198 }
199 
200 /// Serializes given integer into a string.
201 ONIXS_ESPEED_ITCH_API void toStr(std::string&, UInt64);
202 
203 /// Serializes given integer into a string.
204 inline std::string toStr(UInt64 number)
205 {
206  std::string str;
207 
208  toStr(str, number);
209 
210  return str;
211 }
212 
213 /// Serializes given constant into a string.
214 template <typename Type,Type Constant>
215 inline void toStr(std::string& str, IntegralConstant<Type, Constant> constant)
216 {
217  toStr(str, constant());
218 }
219 
220 /// Serializes given constant into a string.
221 template <typename Type, Type Constant >
222 inline std::string toStr( IntegralConstant<Type, Constant> constant)
223 {
224  std::string str;
225 
226  toStr(str, constant);
227 
228  return str;
229 }
230 
#define ONIXS_ESPEED_ITCH_NAMESPACE_END
Definition: Bootstrap.h:31
#define ONIXS_ESPEED_ITCH_NAMESPACE_BEGIN
Definition: Bootstrap.h:27
Value operator()() const
Returns value of the constant.
Definition: Integral.h:97
static const Value value()
Returns value of the constant.
Definition: Integral.h:103
ONIXS_ESPEED_ITCH_API void toStr(std::string &, Int8)
Serializes given integer into a string.
Integral constant.
Definition: Integral.h:85
Type Value
Type of the constant.
Definition: Integral.h:88