OnixS C++ FMX UST BIMP Market Data Handler 1.2.0
API documentation
Loading...
Searching...
No Matches
Decimal.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
28namespace OnixS
29{
30 namespace FmxUST
31 {
32 namespace MarketData
33 {
34 namespace Bimp
35 {
36
44 template<class MantissaType, class ExponentType>
45 class ONIXS_FMXUST_BIMP_API FixedPointDecimal
46 {
47 // Only mantissa is stored.
48 MantissaType mantissa_;
49
50 public:
52 typedef MantissaType Mantissa;
53
55 typedef ExponentType Exponent;
56
58 enum
59 {
66 Size = sizeof(Mantissa)
67 };
68
72 : mantissa_()
73 {
74 }
75
77 explicit
83
87 : mantissa_(other.mantissa_)
88 {
89 }
90
94 {
95 return mantissa_;
96 }
97
101 {
102 return Exponent();
103 }
104
106 FixedPointDecimal& operator =(const FixedPointDecimal& other)
108 {
109 mantissa_ = other.mantissa_;
110
111 return *this;
112 }
113 };
114
116 template<class Mantissa, class Exponent>
120 {
121 return left.mantissa() == right.mantissa();
122 }
123
125 template <class Mantissa, class Exponent>
129 {
130 return left.mantissa() != right.mantissa();
131 }
132
134 template<class Mantissa, class Exponent>
138 {
139 return left.mantissa() < right.mantissa();
140 }
141
143 template<class Mantissa, class Exponent>
147 {
148 return left.mantissa() > right.mantissa();
149 }
150
152 template<class Mantissa, class Exponent>
156 {
157 return left.mantissa() <= right.mantissa();
158 }
159
161 template<class Mantissa, class Exponent>
165 {
166 return left.mantissa() >= right.mantissa();
167 }
168
171 ONIXS_FMXUST_BIMP_API void decimalToStr(std::string&, Int64, Int32);
172
174 template <class Mantissa, class Exponent>
175 inline void toStr(std::string& str, const FixedPointDecimal<Mantissa, Exponent>& number)
176 {
177 decimalToStr(str, number.mantissa(), static_cast<Int32>(number.exponent().value()));
178 }
179
181 template<class Mantissa, class Exponent>
182 inline std::string toStr(const FixedPointDecimal<Mantissa, Exponent>& number)
183 {
184 std::string str;
185
186 toStr(str, number);
187
188 return str;
189 }
190
191 // Serializes fixed-point decimal to stream
192 template<class Mantissa, class Exponent>
193 std::ostream& operator << (std::ostream& stream, const FixedPointDecimal<Mantissa, Exponent>& number)
194 {
195 return stream << toStr(number);
196 }
197 }
198 }
199 }
200}
#define ONIXS_FMXUST_BIMP_NOTHROW
Definition Compiler.h:108
ExponentType Exponent
Aliases exponent component type.
Definition Decimal.h:55
FixedPointDecimal(const FixedPointDecimal &other) ONIXS_FMXUST_BIMP_NOTHROW
Initializes instance as copy of the other one.
Definition Decimal.h:85
FixedPointDecimal() ONIXS_FMXUST_BIMP_NOTHROW
Default (zero) initialization.
Definition Decimal.h:70
Mantissa mantissa() const ONIXS_FMXUST_BIMP_NOTHROW
Returns mantissa of given decimal.
Definition Decimal.h:92
MantissaType Mantissa
Aliases mantissa component type.
Definition Decimal.h:52
Exponent exponent() const ONIXS_FMXUST_BIMP_NOTHROW
Returns exponent of given decimal.
Definition Decimal.h:99
FixedPointDecimal(Mantissa mantissa) ONIXS_FMXUST_BIMP_NOTHROW
Explicitly initializes instance from its mantissa value.
Definition Decimal.h:78
bool operator>(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
Definition Decimal.h:144
bool operator!=(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
Definition Decimal.h:126
ONIXS_FMXUST_BIMP_API void decimalToStr(std::string &, Int64, Int32)
bool operator<=(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
Definition Decimal.h:153
ONIXS_FMXUST_BIMP_API void toStr(std::string &, EventCode::Enum)
Appends string presentation of object.
bool operator>=(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
Definition Decimal.h:162
bool operator<(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
Definition Decimal.h:135
bool operator==(const PriceLevel &l, const PriceLevel &r) ONIXS_FMXUST_BIMP_NOTHROW
compare
Definition OrderBook.h:302
ONIXS_FMXUST_BIMP_API std::ostream & operator<<(std::ostream &stream, const ServiceDescriptor &descriptor)