DCL 4.0
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(const wchar_t* _number, unsigned _base, int _default)
43{
44 return Int32::parse(_number, _base, _default);
45}
46
48
49inline UInteger::UInteger(unsigned int _u)
50{
51 __u = _u;
52}
53
54inline String UInteger::toString(unsigned _base) const
55{
56 return UInteger::toString(__u, _base);
57}
58
59inline String UInteger::toString(unsigned int _u, unsigned _base)
60{
61 return UInt32::toString((uint32_t)_u, _base);
62}
63
64inline String UInteger::toString(unsigned int _u, const wchar_t* _format)
65{
66 return UInt32::toString((uint32_t)_u, _format);
67}
68
69inline unsigned int UInteger::parse(const wchar_t* _number, unsigned _base)
71{
72 return UInt32::parse(_number, _base);
73}
74
75inline unsigned int UInteger::parse(const wchar_t* _number, unsigned _base, unsigned int _default)
76{
77 return UInt32::parse(_number, _base, _default);
78}
79
81
82inline Int32::Int32(int32_t _n)
83{
84 __n = _n;
85}
86
87inline String Int32::toString(unsigned _base) const
88{
89 return Int32::toString(__n, _base);
90}
91
93
94inline UInt32::UInt32(uint32_t _u)
95{
96 __u = _u;
97}
98
99inline String UInt32::toString(unsigned _base) const
100{
101 return UInt32::toString(__u, _base);
102}
103
105
106inline Int64::Int64(int64_t _n)
107{
108 __n = _n;
109}
110
111inline String Int64::toString(unsigned _base) const
112{
113 return Int64::toString(__n, _base);
114}
115
117
118inline UInt64::UInt64(uint64_t _u)
119{
120 __u = _u;
121}
122
123inline String UInt64::toString(unsigned _base) const
124{
125 return UInt64::toString(__u, _base);
126}
127
129
130inline Single::Single(float _f)
131{
132 __f = _f;
133}
134
135inline String Single::toString() const
136{
137 return Single::toString(__f, NULL);
138}
139
141
142inline Double::Double(double _d)
143{
144 __d = _d;
145}
146
147inline String Double::toString() const
148{
149 return Double::toString(__d, NULL);
150}
151
154{
155}
156
157inline Decimal::Decimal(const Decimal& value)
158 : m_value(value.m_value)
159{
160}
161#if 0
162inline Decimal::Decimal(int _n)
163{
164 *this = _n;
165}
166
167inline Decimal::Decimal(unsigned int _u)
168{
169 *this = _u;
170}
171#endif
172inline Decimal::Decimal(int32_t _n)
173{
174 *this = _n;
175}
176
177inline Decimal::Decimal(uint32_t _u)
178{
179 *this = _u;
180}
181
182inline Decimal::Decimal(int64_t _n)
183{
184 *this = _n;
185}
186
187inline Decimal::Decimal(uint64_t _u)
188{
189 *this = _u;
190}
191
192inline Decimal::Decimal(float f)
193{
194 *this = f;
195}
196
197inline Decimal::Decimal(double d)
198{
199 *this = d;
200}
201
202inline Decimal::Decimal(const String& strNumber)
203 : m_value(strNumber)
204{
205}
206
207inline void Decimal::assign(const wchar_t* _number, int _n)
208{
209 m_value.assign(_number, _n);
210}
211
212inline const Decimal& Decimal::operator = (const Decimal& value)
213{
214 m_value = value.m_value;
215 return *this;
216}
217
218#if 0
219inline const Decimal& Decimal::operator = (int _n)
220{
221#if __WORDSIZE == 64
222 *this = (int64_t)_n;
223#else
224 *this = (int32_t)_n;
225#endif
226 return *this;
227}
228
229inline const Decimal& Decimal::operator = (unsigned int _u)
230{
231#if __WORDSIZE == 64
232 *this = (uint64_t)_u;
233#else
234 *this = (uint32_t)_u;
235#endif
236 return *this;
237}
238#endif
239
240inline const Decimal& Decimal::operator = (int32_t _n)
241{
242 m_value = Int32::toString(_n, 10);
243 return *this;
244}
245
246inline const Decimal& Decimal::operator = (uint32_t _u)
247{
248 m_value = UInt32::toString(_u, 10);
249 return *this;
250}
251
252inline const Decimal& Decimal::operator = (int64_t _n)
253{
254 m_value = Int64::toString(_n, 10);
255 return *this;
256}
257
258inline const Decimal& Decimal::operator = (uint64_t _u)
259{
260 m_value = UInt64::toString(_u, 10);
261 return *this;
262}
263
264inline const Decimal& Decimal::operator = (const String& strNumber)
265{
266 m_value = strNumber;
267 return *this;
268}
269
270inline String Decimal::toString() const
271{
272 return m_value;
273}
274
275inline String Decimal::toStringF(
276 const char* pszDecimalFormat // = FORMAT_DEFAULT
277 ) const
278{
279 return Decimal::toStringF(*this, pszDecimalFormat);
280}
281
282#endif // __DCL_NUMERIC_INL__
283
284
#define NULL
Definition Config.h:340
#define __DCL_THROWS1(e)
Definition Config.h:167
String toStringF(const char *pszDecimalFormat=NULL) const
Definition Numeric.inl:275
void assign(const wchar_t *_number, int _n)
Definition Numeric.inl:207
String toString() const
Definition Numeric.inl:270
const Decimal & operator=(const Decimal &value)
Definition Numeric.inl:212
String m_value
Definition Numeric.h:199
double __d
Definition Numeric.h:176
Double(double _d)
Definition Numeric.inl:142
String toString() const
Definition Numeric.inl:147
String toString(unsigned _base=10) const
Definition Numeric.inl:87
int32_t __n
Definition Numeric.h:70
static int32_t parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.cpp:284
Int32(int32_t _n)
Definition Numeric.inl:82
int64_t __n
Definition Numeric.h:110
String toString(unsigned _base=10) const
Definition Numeric.inl:111
Int64(int64_t _n)
Definition Numeric.inl:106
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:150
String toString() const
Definition Numeric.inl:135
Single(float _f)
Definition Numeric.inl:130
UInt32(uint32_t _u)
Definition Numeric.inl:94
static uint32_t parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.cpp:401
uint32_t __u
Definition Numeric.h:90
String toString(unsigned _base=10) const
Definition Numeric.inl:99
UInt64(uint64_t _u)
Definition Numeric.inl:118
String toString(unsigned _base=10) const
Definition Numeric.inl:123
uint64_t __u
Definition Numeric.h:130
unsigned int __u
Definition Numeric.h:50
UInteger(unsigned int _u)
Definition Numeric.inl:49
String toString(unsigned _base=10) const
Definition Numeric.inl:54
static unsigned int parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.inl:69