acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
c_number.h
1
#pragma once
2
3
4
template
<
typename
T >
5
class
c_number
6
{
7
public
:
8
9
typedef
T TYPE;
10
11
T m_number;
12
13
inline
c_number()
14
{
15
m_number = (T) 0;
16
}
17
18
inline
c_number(T number)
19
{
20
m_number = number;
21
}
22
23
inline
c_number(const ::scoped_string & scopedstr)
24
{
25
from(scopedstr);
26
}
27
28
inline
operator
T &()
29
{
30
return
m_number;
31
}
32
33
inline
operator
const
T &()
const
34
{
35
return
m_number;
36
}
37
38
inline
c_number < T > & from(const ::scoped_string & scopedstr);
39
40
/* bool operator == (const c_number & n) const;
41
bool operator > (const c_number & n) const;
42
bool operator < (const c_number & n) const;
43
bool operator >= (const c_number & n) const;
44
bool operator <= (const c_number & n) const;
45
bool operator != (const c_number & n) const;
46
47
c_number & operator = (const c_number & n);
48
c_number & operator += (const c_number & n);
49
c_number & operator -= (const c_number & n);*/
50
51
52
inline
static
T max_value()
53
{
54
return ::numeric_info< T >::maximum();
55
}
56
57
inline
static
T min_value()
58
{
59
return ::numeric_info< T >::minimum();
60
}
61
62
inline
static
T allset_value()
63
{
64
return ::numeric_info< T >::allset();
65
}
66
67
inline
void
set_maximum()
68
{
69
m_number = max_value();
70
}
71
72
73
template
<
typename
TYPE >
74
inline
TYPE * cast()
const
75
{
76
return
(TYPE *) m_number;
77
}
78
79
template
<
typename
TYPE >
80
inline
TYPE scast()
const
81
{
82
return
(TYPE)m_number;
83
}
84
85
86
};
87
88
89
/*template < typename T >
90
inline bool c_number<T> ::operator == (const c_number < T > & n) const
91
{
92
return m_number == n.m_number;
93
}
94
95
template < typename T >
96
inline bool c_number<T> ::operator > (const c_number < T > & n) const
97
{
98
return m_number > n.m_number;
99
}
100
101
template < typename T >
102
inline bool c_number<T> ::operator < (const c_number < T > & n) const
103
{
104
return m_number < n.m_number;
105
}
106
107
template < typename T >
108
inline bool c_number<T> ::operator >= (const c_number < T > & n) const
109
{
110
return m_number >= n.m_number;
111
}
112
113
template < typename T >
114
inline bool c_number<T> ::operator <= (const c_number < T > & n) const
115
{
116
return m_number <= n.m_number;
117
}
118
119
template < typename T >
120
inline bool c_number<T> ::operator != (const c_number < T > & n) const
121
{
122
return m_number != n.m_number;
123
}
124
125
template < typename T >
126
inline c_number<T> & c_number<T> ::operator = (const c_number < T > & n)
127
{
128
m_number = n.m_number;
129
return *this;
130
}
131
132
template < typename T >
133
inline c_number<T> & c_number<T> ::operator += (const c_number<T> & n)
134
{
135
m_number += n.m_number;
136
return *this;
137
}
138
139
template < typename T >
140
inline c_number<T> & c_number<T> ::operator -= (const c_number<T> & n)
141
{
142
m_number -= n.m_number;
143
return *this;
144
}
145
146
template < typename T >
147
inline c_number<T> operator + (const c_number<T> & n1, const c_number<T> & n2)
148
{
149
return n1.m_number + n2.m_number;
150
}
151
152
template < typename T >
153
inline c_number<T> operator - (const c_number<T> & n1, const c_number<T> & n2)
154
{
155
return n1.m_number - n2.m_number;
156
}
157
158
*/
159
160
161
162
163
164
165
166
167
168
169
170
#define DEFINE_UNIT(e, ca, T) \
171
class e ca : \
172
public c_number < T > \
173
{ \
174
public: \
175
ca() \
176
{ \
177
} \
178
\
179
ca(const T & ca) : \
180
c_number < T > ((const c_number < T > &) ca) \
181
{ \
182
} \
183
\
184
};
185
186
187
class
time
;
188
189
190
//class microsecond;
191
192
193
//class nanosecond;
194
195
196
class
time
;
197
198
199
200
201
//class CLASS_DECL_ACME class ::time
202
//{
203
//public:
204
//
205
//
206
// ::i64 m_i32;
207
//
208
//
209
// class ::time() { m_i32 = 0; }
210
// class ::time(::i64 i) { m_i32 = i; }
211
//
212
//
213
// class ::time & operator = (const second & second) { m_i32 = second.m_i32 * 1'000; return *this; }
214
// class ::time & operator = (const class time & time) { m_i32 = class ::time.m_i32; return *this; }
215
// class ::time & operator = (const microsecond & microsecond);
216
// class ::time & operator = (const nanosecond & nanosecond);
217
// class ::time & operator = (const class time & time);
218
// class ::time & operator = (::i64 i) { m_i32 = i; return *this; }
219
//
220
//
221
//};
222
223
224
225
226
227
228
229
230
232
//DEFINE_UNIT(CLASS_DECL_ACME, lock_time, ::u32)
233
//DEFINE_UNIT(CLASS_DECL_ACME, tick_time, ::u32)
235
236
//DEFINE_C_NUMBER(CLASS_DECL_ACME, filesize , ::u64)
237
//DEFINE_C_NUMBER(CLASS_DECL_ACME, filesize , ::u64)
238
//DEFINE_C_NUMBER(CLASS_DECL_ACME, filesize , ::i64)
239
240
241
/*namespace numeric_info
242
{
243
244
245
template <>
246
inline filesize get_maximum_value < filesize > ()
247
{
248
return static_cast < filesize > (0xffffffffffffffff);
249
}
250
251
template <>
252
inline filesize get_minimum_value < filesize > ()
253
{
254
return static_cast < ::u64 > (0);
255
}
256
257
template <>
258
inline filesize get_allset_value < filesize > ()
259
{
260
return static_cast < filesize > (0xffffffffffffffff);
261
}
262
263
template <>
264
inline filesize get_null_value < filesize > ()
265
{
266
return 0;
267
}
268
269
template <>
270
inline filesize get_unitary_value < filesize >()
271
{
272
return 1;
273
}
274
275
276
} // namespace numeric_info
277
278
279
280
*/
281
282
283
namespace
numeric_info_internal
284
{
285
286
287
template
<
typename
T >
288
class
CLASS_DECL_ACME
numeric_info
< ::
c_number
< T > > :
289
public
numeric_info
< T >
290
{
291
public
:
292
293
294
};
295
296
297
}
// namespace numeric_info_internal
298
299
300
//template < typename T >
301
//inline stream & operator >>(stream & istream, c_number < T > & t)
302
//{
303
//
304
// return istream >> t.m_number;
305
//
306
//}
307
//
308
//template < typename T >
309
//inline stream & operator <<(stream & ostream, const c_number < T > & t)
310
//{
311
//
312
// return ostream << t.m_number;
313
//
314
//}
c_number
Definition
c_number.h:6
numeric_info_internal::numeric_info
Definition
numeric_info.h:25
time
Definition
aaa_time.h:13
prototype
mathematics
c_number.h
Generated by
1.17.0