OnixS C++ B3 Binary UMDF Market Data Handler 1.10.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Decimal.Operations.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
24
27
29
31template
32<
33 class Mantissa,
34 class Exponent
35>
36inline
37ONIXS_B3_UMDF_MD_NODISCARD
38std::string
39toStr(
40 const
42 <
43 Mantissa,
44 Exponent
45 >& number)
46{
47 std::string str;
48
49 toStr(str, number);
50
51 return str;
52}
53
55template
56 <
57 class Mantissa,
58 class Exponent
59 >
60inline
61std::ostream&
63 std::ostream& stream,
64 const
66 <Mantissa, Exponent>& value)
67{
68 std::string str;
69
70 toStr(str, value);
71
72 return stream << str;
73}
74
76template
77<
78 class Mantissa,
79 class Exponent
80>
81ONIXS_B3_UMDF_MD_NODISCARD
82ONIXS_B3_UMDF_MD_PURE
83bool
84operator ==(
85 const
86 FixedPointDecimal
87 <Mantissa, Exponent>& left,
88 const
89 FixedPointDecimal
90 <Mantissa, Exponent>& right)
91{
92 if(isNull(left) && isNull(right))
93 return true;
94
95 return left.mantissa() == right.mantissa();
96}
97
99template
100<
101 class Mantissa,
102 class Exponent
103>
104ONIXS_B3_UMDF_MD_NODISCARD
105ONIXS_B3_UMDF_MD_PURE
106bool
107operator !=(
108 const
109 FixedPointDecimal
110 <Mantissa, Exponent>& left,
111 const
112 FixedPointDecimal
113 <Mantissa, Exponent>& right)
114{
115 return !(left == right);
116}
117
119template
120<
121 class Mantissa,
122 class Exponent
123>
124ONIXS_B3_UMDF_MD_NODISCARD
125ONIXS_B3_UMDF_MD_PURE
126bool
127operator <(
128 const
129 FixedPointDecimal
130 <Mantissa, Exponent>& left,
131 const
132 FixedPointDecimal
133 <Mantissa, Exponent>& right)
134{
135 checkAgsValid(left, right);
136
137 return left.mantissa() < right.mantissa();
138}
139
141template
142<
143 class Mantissa,
144 class Exponent
145>
146ONIXS_B3_UMDF_MD_NODISCARD
147ONIXS_B3_UMDF_MD_PURE
148bool
149operator >(
150 const
151 FixedPointDecimal
152 <Mantissa, Exponent>& left,
153 const
154 FixedPointDecimal
155 <Mantissa, Exponent>& right)
156{
157 checkAgsValid(left, right);
158
159 return left.mantissa() > right.mantissa();
160}
161
163template
164<
165 class Mantissa,
166 class Exponent
167>
168ONIXS_B3_UMDF_MD_NODISCARD
169ONIXS_B3_UMDF_MD_PURE
170bool
171operator <=(
172 const
173 FixedPointDecimal
174 <Mantissa, Exponent>& left,
175 const
176 FixedPointDecimal
177 <Mantissa, Exponent>& right)
178{
179 checkAgsValid(left, right);
180
181 return left.mantissa() <= right.mantissa();
182}
183
185template
186<
187 class Mantissa,
188 class Exponent
189>
190ONIXS_B3_UMDF_MD_NODISCARD
191ONIXS_B3_UMDF_MD_PURE
192bool
193operator >=(
194 const
195 FixedPointDecimal
196 <Mantissa, Exponent>& left,
197 const
198 FixedPointDecimal
199 <Mantissa, Exponent>& right)
200{
201 checkAgsValid(left, right);
202
203 return left.mantissa() >= right.mantissa();
204}
205
#define ONIXS_B3_UMDF_MD_MESSAGING_NAMESPACE_END
Definition ABI.h:158
#define ONIXS_B3_UMDF_MD_MESSAGING_NAMESPACE_BEGIN
Definition ABI.h:153
std::ostream & operator<<(std::ostream &stream, const FixedPointDecimal< Mantissa, Exponent > &value)
Serializes into a stream.
void toStr(std::string &str, Char character)
Appends the character to the given std::string instance.
Definition String.h:34