1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
| // -----------------------------------------------------------------------------------
// syscurr.h: Currency Wrapper
//
// $Rev: 27016 $
//
// Copyright(c) 1995-2010 Embarcadero Technologies, Inc.
// -----------------------------------------------------------------------------------
#if !defined(SYSCURR_H)
#define SYSCURR_H
#if !defined(SystemHPP)
#error Do not include this file directly. Include 'System.hpp'.
#endif
#if !defined(SYSMAC_H)
#include <sysmac.h>
#endif
#if !defined(DSTRING_H)
#include <dstring.h>
#endif
#if !defined(WSTRING_H)
#include <wstring.h>
#endif
#pragma option push -w-inl -w-lvc
namespace System
{
// Forward ref.
class RTL_DELPHIRETURN Currency;
// (See classcre.asm)
extern "C" __int64 __cdecl _roundToInt64(long double);
extern "C" void __fastcall __currMul(const System::Currency c1, System::Currency &c2);
class RTL_DELPHIRETURN CurrencyBase
{
public:
__int64 Val;
};
class RTL_DELPHIRETURN Currency : public CurrencyBase
{
friend Currency __fastcall operator +(int lhs, const Currency& rhs);
friend Currency __fastcall operator -(int lhs, const Currency& rhs);
friend Currency __fastcall operator *(int lhs, const Currency& rhs);
friend Currency __fastcall operator /(int lhs, const Currency& rhs);
friend Currency __fastcall operator +(double lhs, const Currency& rhs);
friend Currency __fastcall operator -(double lhs, const Currency& rhs);
friend Currency __fastcall operator *(double lhs, const Currency& rhs);
friend Currency __fastcall operator /(double lhs, const Currency& rhs);
public:
__fastcall Currency() {Val = 0;}
__fastcall Currency(double val) {Val = _roundToInt64(10000 * val);}
__fastcall Currency(int val) {Val = 10000*(__int64)val;}
__fastcall Currency(const CurrencyBase& src) {Val = src.Val;}
__fastcall Currency(const Currency& src) {Val = src.Val;}
__fastcall Currency(const System::String& src);
Currency& __fastcall operator =(double rhs)
{
Val = _roundToInt64(10000 * rhs);
return *this;
}
Currency& __fastcall operator =(int rhs)
{Val = 10000*(__int64)rhs; return *this;}
Currency& __fastcall operator =(const CurrencyBase& rhs)
{Val=rhs.Val;return *this;}
Currency& __fastcall operator =(const Currency& rhs)
{Val = rhs.Val; return *this;}
Currency& __fastcall operator +=(const Currency& rhs)
{Val += rhs.Val; return *this;}
Currency& __fastcall operator -=(const Currency& rhs)
{Val -= rhs.Val; return *this;}
Currency& __fastcall operator *=(const Currency& rhs)
/* Following has overflow issues - See @__currMul in CLASSCRE.ASM
{Val *= rhs.Val; Val /= 10000; return *this;}
*/
{ __currMul(rhs, *this); return *this; }
Currency& __fastcall operator /=(const Currency& rhs)
{Val *= 10000; Val /= rhs.Val; return *this;}
Currency& __fastcall operator %=(int rhs)
{Val %= 10000 * (__int64)rhs; return *this;}
Currency& operator ++() {Val += 10000; return *this;}
Currency operator ++(int) {Currency tmp(*this); Val += 10000; return tmp;}
Currency& operator --() {Val -= 10000; return *this;}
Currency operator --(int) {Currency tmp(*this); Val -= 10000; return tmp;}
Currency __fastcall operator +(const Currency& rhs) const
{Currency tmp(*this); return tmp += rhs;}
Currency __fastcall operator -(const Currency& rhs) const
{Currency tmp(*this); return tmp -= rhs;}
Currency __fastcall operator *(const Currency& rhs) const
{Currency tmp(*this); return tmp *= rhs;}
Currency __fastcall operator /(const Currency& rhs) const
{Currency tmp(*this); return tmp /= rhs;}
Currency __fastcall operator +(int rhs) const
{Currency tmp(*this); return tmp += Currency(rhs);}
Currency __fastcall operator -(int rhs) const
{Currency tmp(*this); return tmp -= Currency(rhs);}
Currency __fastcall operator *(int rhs) const
{Currency tmp(*this); return tmp *= Currency(rhs);}
Currency __fastcall operator /(int rhs) const
{Currency tmp(*this); return tmp /= Currency(rhs);}
Currency __fastcall operator %(int rhs) const
{return Currency(static_cast<int>(Val % (10000 * (__int64)rhs))) / 10000;}
Currency __fastcall operator +(double rhs) const
{Currency tmp(*this); return tmp += Currency(rhs);}
Currency __fastcall operator -(double rhs) const
{Currency tmp(*this); return tmp -= Currency(rhs);}
Currency __fastcall operator *(double rhs) const
{Currency tmp(*this); return tmp *= Currency(rhs);}
Currency __fastcall operator /(double rhs) const
{Currency tmp(*this); return tmp /= Currency(rhs);}
Currency __fastcall operator -() const
{Currency tmp(*this); tmp.Val = -(tmp.Val); return tmp;}
Currency __fastcall operator !() const
{Currency tmp(*this); tmp.Val = !(tmp.Val); return tmp;}
// comparisons (Currency rhs)
bool __fastcall operator ==(const Currency& rhs) const
{return Val == rhs.Val;}
bool __fastcall operator !=(const Currency& rhs) const
{return Val != rhs.Val;}
bool __fastcall operator >(const Currency& rhs) const
{return Val > rhs.Val;}
bool __fastcall operator <(const Currency& rhs) const
{return Val < rhs.Val;}
bool __fastcall operator >=(const Currency& rhs) const
{return Val >= rhs.Val;}
bool __fastcall operator <=(const Currency& rhs) const
{return Val <= rhs.Val;}
// comparisons (int rhs)
bool __fastcall operator ==(int rhs) const
{return Val == 10000 * (__int64)rhs;}
bool __fastcall operator !=(int rhs) const
{return Val != 10000 * (__int64)rhs;}
bool __fastcall operator >(int rhs) const
{return Val > 10000 * (__int64)rhs;}
bool __fastcall operator <(int rhs) const
{return Val < 10000 * (__int64)rhs;}
bool __fastcall operator >=(int rhs) const
{return Val >= 10000 * (__int64)rhs;}
bool __fastcall operator <=(int rhs) const
{return Val <= 10000 * (__int64)rhs;}
// comparisons (double rhs)
bool __fastcall operator ==(double rhs) const
{return Val == _roundToInt64(10000 * (long double)rhs);}
bool __fastcall operator !=(double rhs) const
{return Val != _roundToInt64(10000 * (long double)rhs);}
bool __fastcall operator >(double rhs) const
{return Val > _roundToInt64(10000 * (long double)rhs);}
bool __fastcall operator <(double rhs) const
{return Val < _roundToInt64(10000 * (long double)rhs);}
bool __fastcall operator >=(double rhs) const
{return Val >= _roundToInt64(10000 * (long double)rhs);}
bool __fastcall operator <=(double rhs) const
{return Val <= _roundToInt64(10000 * (long double)rhs);}
__fastcall operator double() const {return ((double)Val) / 10000;}
__fastcall operator int() const {return (int) (Val / 10000);}
__fastcall operator System::String() const;
};
// Currency friends
//
inline Currency __fastcall operator +(int lhs, const Currency& rhs)
{Currency tmp(lhs); return tmp += rhs;}
inline Currency __fastcall operator -(int lhs, const Currency& rhs)
{Currency tmp(lhs); return tmp -= rhs;}
inline Currency __fastcall operator *(int lhs, const Currency& rhs)
{Currency tmp(lhs); return tmp *= rhs;}
inline Currency __fastcall operator /(int lhs, const Currency& rhs)
{Currency tmp(lhs); return tmp /= rhs;}
inline Currency __fastcall operator +(double lhs, const Currency& rhs)
{Currency tmp(lhs); return tmp += rhs;}
inline Currency __fastcall operator -(double lhs, const Currency& rhs)
{Currency tmp(lhs); return tmp -= rhs;}
inline Currency __fastcall operator *(double lhs, const Currency& rhs)
{Currency tmp(lhs); return tmp *= rhs;}
inline Currency __fastcall operator /(double lhs, const Currency& rhs)
{Currency tmp(lhs); return tmp /= rhs;}
// NOTE: Insertion/Extraction operators of VCL classes are only visible
// if VCL_IOSTREAM is defined.
//
#if defined(VCL_IOSTREAM)
std::ostream& operator << (std::ostream& os, const Currency& arg);
std::istream& operator >> (std::istream& is, Currency& arg);
#endif
}
#pragma option pop
#endif |