DCL 3.7.4
Loading...
Searching...
No Matches
Numeric.inl
Go to the documentation of this file.
1#ifndef __DCL_NUMERIC_H__
2 #error "Never use <dcl/core/Numeric.inl> directly; include <dcl/core/Numeric.h> instead."
3#endif
4#ifndef __DCL_NUMERIC_INL__
5#define __DCL_NUMERIC_INL__
6
7#ifndef __WORDSIZE
8#error "must defined __WORDSIZE"
9#endif
10
11#if !(__WORDSIZE == 32 || __WORDSIZE == 64)
12#error "unsupported __WORDSIZE"
13#endif
14
16inline Integer::Integer(int _n)
17{
18 __n = _n;
19}
20
21inline String Integer::toString(unsigned _base) const
22{
23 return Integer::toString(__n, _base);
24}
25
26inline String Integer::toString(int _n, unsigned _base)
27{
28 return Int32::toString((int32_t) _n, _base);
29}
30
31inline String Integer::toString(int _n, const wchar_t* _format)
32{
33 return Int32::toString((int32_t)_n, _format);
34}
35
36inline int Integer::parse(const wchar_t* _number, unsigned _base)
38{
39 return Int32::parse(_number, _base);
40}
41
42inline int Integer::parse(
43 const wchar_t* _number, unsigned _base,
44 int _default
45)
46{
47 return Int32::parse(_number, _base, _default);
48}
49
51
52inline UInteger::UInteger(unsigned int _u)
53{
54 __u = _u;
55}
56
57inline String UInteger::toString(unsigned _base) const
58{
59 return UInteger::toString(__u, _base);
60}
61
62inline String UInteger::toString(unsigned int _u, unsigned _base)
63{
64 return UInt32::toString((uint32_t)_u, _base);
65}
66
67inline String UInteger::toString(unsigned int _u, const wchar_t* _format)
68{
69 return UInt32::toString((uint32_t)_u, _format);
70}
71
72inline unsigned int UInteger::parse(const wchar_t* _number, unsigned _base)
74{
75 return UInt32::parse(_number, _base);
76}
77
78inline unsigned int UInteger::parse(
79 const wchar_t* _number, unsigned _base,
80 unsigned int _default
81)
82{
83 return UInt32::parse(_number, _base, _default);
84}
85
87
88inline Int32::Int32(int32_t _n)
89{
90 __n = _n;
91}
92
93inline String Int32::toString(unsigned _base) const
94{
95 return Int32::toString(__n, _base);
96}
97
99
100inline UInt32::UInt32(uint32_t _u)
101{
102 __u = _u;
103}
104
105inline String UInt32::toString(unsigned _base) const
106{
107 return UInt32::toString(__u, _base);
108}
109
111
112inline Int64::Int64(int64_t _n)
113{
114 __n = _n;
115}
116
117inline String Int64::toString(unsigned _base) const
118{
119 return Int64::toString(__n, _base);
120}
121
123
124inline UInt64::UInt64(uint64_t _u)
125{
126 __u = _u;
127}
128
129inline String UInt64::toString(unsigned _base) const
130{
131 return UInt64::toString(__u, _base);
132}
133
135
136inline Single::Single(float _f)
137{
138 __f = _f;
139}
140
141inline String Single::toString() const
142{
143 return Single::toString(__f, NULL);
144}
145
147
148inline Double::Double(double _d)
149{
150 __d = _d;
151}
152
153inline String Double::toString() const
154{
155 return Double::toString(__d, NULL);
156}
157
160{
161}
162
163inline Decimal::Decimal(const Decimal& _value)
164 : __value(_value.__value)
165{
166}
167#if 0
168inline Decimal::Decimal(int _n)
169{
170 *this = _n;
171}
172
173inline Decimal::Decimal(unsigned int _u)
174{
175 *this = _u;
176}
177#endif
178inline Decimal::Decimal(int32_t _n)
179{
180 *this = _n;
181}
182
183inline Decimal::Decimal(uint32_t _u)
184{
185 *this = _u;
186}
187
188inline Decimal::Decimal(int64_t _n)
189{
190 *this = _n;
191}
192
193inline Decimal::Decimal(uint64_t _u)
194{
195 *this = _u;
196}
197
198inline Decimal::Decimal(float f)
199{
200 *this = f;
201}
202
203inline Decimal::Decimal(double d)
204{
205 *this = d;
206}
207
208inline Decimal::Decimal(const String& strNumber)
209 : __value(strNumber)
210{
211}
212
213inline void Decimal::assign(const wchar_t* _number, int _n)
214{
215 __value.assign(_number, _n);
216}
217
218inline const Decimal& Decimal::operator = (const Decimal& _value)
219{
220 __value = _value.__value;
221 return *this;
222}
223
224#if 0
225inline const Decimal& Decimal::operator = (int _n)
226{
227#if __WORDSIZE == 64
228 *this = (int64_t)_n;
229#else
230 *this = (int32_t)_n;
231#endif
232 return *this;
233}
234
235inline const Decimal& Decimal::operator = (unsigned int _u)
236{
237#if __WORDSIZE == 64
238 *this = (uint64_t)_u;
239#else
240 *this = (uint32_t)_u;
241#endif
242 return *this;
243}
244#endif
245
246inline const Decimal& Decimal::operator = (int32_t _n)
247{
248 __value = Int32::toString(_n, 10);
249 return *this;
250}
251
252inline const Decimal& Decimal::operator = (uint32_t _u)
253{
254 __value = UInt32::toString(_u, 10);
255 return *this;
256}
257
258inline const Decimal& Decimal::operator = (int64_t _n)
259{
260 __value = Int64::toString(_n, 10);
261 return *this;
262}
263
264inline const Decimal& Decimal::operator = (uint64_t _u)
265{
266 __value = UInt64::toString(_u, 10);
267 return *this;
268}
269
270inline const Decimal& Decimal::operator = (const String& strNumber)
271{
272 __value = strNumber;
273 return *this;
274}
275
276inline String Decimal::toString() const
277{
278 return __value;
279}
280
281inline String Decimal::toStringF(
282 const char* pszDecimalFormat // = FORMAT_DEFAULT
283) const
284{
285 return Decimal::toStringF(*this, pszDecimalFormat);
286}
287
288#endif // __DCL_NUMERIC_INL__
#define NULL
Definition Config.h:312
#define __DCL_THROWS1(e)
Definition Config.h:152
String toStringF(const char *pszDecimalFormat=NULL) const
Definition Numeric.inl:281
void assign(const wchar_t *_number, int _n)
Definition Numeric.inl:213
String toString() const
Definition Numeric.inl:276
String __value
Definition Numeric.h:217
const Decimal & operator=(const Decimal &_value)
Definition Numeric.inl:218
double __d
Definition Numeric.h:194
Double(double _d)
Definition Numeric.inl:148
String toString() const
Definition Numeric.inl:153
String toString(unsigned _base=10) const
Definition Numeric.inl:93
int32_t __n
Definition Numeric.h:76
static int32_t parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.cpp:264
Int32(int32_t _n)
Definition Numeric.inl:88
int64_t __n
Definition Numeric.h:122
String toString(unsigned _base=10) const
Definition Numeric.inl:117
Int64(int64_t _n)
Definition Numeric.inl:112
int __n
Definition Numeric.h:29
Integer(int _n)
Definition Numeric.inl:16
String toString(unsigned _base=10) const
Definition Numeric.inl:21
static int parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.inl:36
float __f
Definition Numeric.h:168
String toString() const
Definition Numeric.inl:141
Single(float _f)
Definition Numeric.inl:136
UInt32(uint32_t _u)
Definition Numeric.inl:100
static uint32_t parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.cpp:391
uint32_t __u
Definition Numeric.h:99
String toString(unsigned _base=10) const
Definition Numeric.inl:105
UInt64(uint64_t _u)
Definition Numeric.inl:124
String toString(unsigned _base=10) const
Definition Numeric.inl:129
uint64_t __u
Definition Numeric.h:145
unsigned int __u
Definition Numeric.h:53
UInteger(unsigned int _u)
Definition Numeric.inl:52
String toString(unsigned _base=10) const
Definition Numeric.inl:57
static unsigned int parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.inl:72