OnixS C++ B3 Binary UMDF Market Data Handler  1.4.2
API documentation
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 
30 /// Serializes a fixed-point decimal into a string.
31 template
32 <
33  class Mantissa,
34  class Exponent
35 >
36 inline
37 ONIXS_B3_UMDF_MD_NODISCARD
38 std::string
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 
54 /// Serializes into a stream.
55 template
56  <
57  class Mantissa,
58  class Exponent
59  >
60 inline
61 std::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 
75 /// Compares two fixed-point decimals.
76 template
77 <
78  class Mantissa,
79  class Exponent
80 >
81 ONIXS_B3_UMDF_MD_NODISCARD
82 ONIXS_B3_UMDF_MD_PURE
83 bool
85  const
87  <Mantissa, Exponent>& left,
88  const
90  <Mantissa, Exponent>& right)
91 {
92  if(isNull(left) && isNull(right))
93  return true;
94 
95  return left.mantissa() == right.mantissa();
96 }
97 
98 /// Compares two fixed-point decimals.
99 template
100 <
101  class Mantissa,
102  class Exponent
103 >
104 ONIXS_B3_UMDF_MD_NODISCARD
105 ONIXS_B3_UMDF_MD_PURE
106 bool
108  const
110  <Mantissa, Exponent>& left,
111  const
113  <Mantissa, Exponent>& right)
114 {
115  return !(left == right);
116 }
117 
118 /// Compares two fixed-point decimals.
119 template
120 <
121  class Mantissa,
122  class Exponent
123 >
124 ONIXS_B3_UMDF_MD_NODISCARD
125 ONIXS_B3_UMDF_MD_PURE
126 bool
128  const
130  <Mantissa, Exponent>& left,
131  const
133  <Mantissa, Exponent>& right)
134 {
135  checkAgsValid(left, right);
136 
137  return left.mantissa() < right.mantissa();
138 }
139 
140 /// Compares two fixed-point decimals.
141 template
142 <
143  class Mantissa,
144  class Exponent
145 >
146 ONIXS_B3_UMDF_MD_NODISCARD
147 ONIXS_B3_UMDF_MD_PURE
148 bool
150  const
152  <Mantissa, Exponent>& left,
153  const
155  <Mantissa, Exponent>& right)
156 {
157  checkAgsValid(left, right);
158 
159  return left.mantissa() > right.mantissa();
160 }
161 
162 /// Compares two fixed-point decimals.
163 template
164 <
165  class Mantissa,
166  class Exponent
167 >
168 ONIXS_B3_UMDF_MD_NODISCARD
169 ONIXS_B3_UMDF_MD_PURE
170 bool
172  const
174  <Mantissa, Exponent>& left,
175  const
177  <Mantissa, Exponent>& right)
178 {
179  checkAgsValid(left, right);
180 
181  return left.mantissa() <= right.mantissa();
182 }
183 
184 /// Compares two fixed-point decimals.
185 template
186 <
187  class Mantissa,
188  class Exponent
189 >
190 ONIXS_B3_UMDF_MD_NODISCARD
191 ONIXS_B3_UMDF_MD_PURE
192 bool
194  const
196  <Mantissa, Exponent>& left,
197  const
199  <Mantissa, Exponent>& right)
200 {
201  checkAgsValid(left, right);
202 
203  return left.mantissa() >= right.mantissa();
204 }
205 
ONIXS_B3_UMDF_MD_NODISCARD ONIXS_B3_UMDF_MD_PURE bool operator>=(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
ONIXS_B3_UMDF_MD_NODISCARD bool isNull(const PriceOptional &value)
Definition: Composites.h:253
ONIXS_B3_UMDF_MD_NODISCARD ONIXS_B3_UMDF_MD_PURE bool operator!=(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
ONIXS_B3_UMDF_MD_NODISCARD ONIXS_B3_UMDF_MD_PURE bool operator==(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
#define ONIXS_B3_UMDF_MD_MESSAGING_NAMESPACE_END
Definition: ABI.h:151
ONIXS_B3_UMDF_MD_NODISCARD std::string toStr(const FixedPointDecimal< Mantissa, Exponent > &number)
Serializes a fixed-point decimal into a string.
#define ONIXS_B3_UMDF_MD_MESSAGING_NAMESPACE_BEGIN
Definition: ABI.h:146
ONIXS_B3_UMDF_MD_NODISCARD ONIXS_B3_UMDF_MD_PURE bool operator<=(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
std::ostream & operator<<(std::ostream &stream, const FixedPointDecimal< Mantissa, Exponent > &value)
Serializes into a stream.
ONIXS_B3_UMDF_MD_NODISCARD ONIXS_B3_UMDF_MD_PURE bool operator>(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.
ONIXS_B3_UMDF_MD_NODISCARD ONIXS_B3_UMDF_MD_PURE bool operator<(const FixedPointDecimal< Mantissa, Exponent > &left, const FixedPointDecimal< Mantissa, Exponent > &right)
Compares two fixed-point decimals.