mFrame
載入中...
搜尋中...
無符合項目
Number.h
1
8#ifndef MFRAME_C6CF2DB4_1F61_4562_8698_C0C22D0C69FA
9#define MFRAME_C6CF2DB4_1F61_4562_8698_C0C22D0C69FA
10
11/* ***************************************************************************************
12 * Include
13 */
14
15//----------------------------------------------------------------------------------------
16
17//----------------------------------------------------------------------------------------
18#include "./../lang/Object.h"
19
20/* ***************************************************************************************
21 * Namespace
22 */
23namespace ufm::numb {
24 class Number;
25} // namespace ufm::numb
26
27/* ***************************************************************************************
28 * Class Number
29 */
45 /* *************************************************************************************
46 * Subclass
47 */
48 protected:
54 union Value {
55 bool b;
56 uint8 u8[4];
57 char s8[4];
58 uint16 u16[2];
59 short s16[2];
60 uint32 u32[2];
61 int s32[2];
62 float f32[2];
63 uint64_t u64;
64 int64_t s64;
65 double d64;
66 };
67
68 /* *************************************************************************************
69 * Variable
70 */
71 protected:
73
74 /* *************************************************************************************
75 * Abstract Method
76 */
77
78 /* *************************************************************************************
79 * Construct Method
80 */
81 public:
87 Number(void);
88
89 /* *************************************************************************************
90 * Operator Method
91 */
92 public:
98 inline operator bool&(void) {
99 return this->vValue.b;
100 }
101
107 inline operator const bool&(void) const {
108 return this->vValue.b;
109 }
110
116 inline operator int&(void) {
117 return this->vValue.s32[0];
118 }
119
125 inline operator const int&(void) const {
126 return this->vValue.s32[0];
127 }
128
134 inline operator uint32&(void) {
135#ifdef __GNUC__
136 return *reinterpret_cast<uint32*>(&this->vValue);
137#else
138 return this->vValue.u32[0];
139#endif
140 }
141
147 inline operator const uint32&(void) const {
148#ifdef __GNUC__
149 return *reinterpret_cast<uint32 const*>(&this->vValue);
150#else
151 return this->vValue.u32[0];
152#endif
153 }
154
160 inline operator float&(void) {
161 return this->vValue.f32[0];
162 }
163
169 inline operator const float&(void) const {
170 return this->vValue.f32[0];
171 }
172
178 inline operator double&(void) {
179 return this->vValue.d64;
180 }
181
187 inline operator const double&(void) const {
188 return this->vValue.d64;
189 }
190
198 inline bool operator==(Number& v) {
199 return (Number::vValue.u64 == v.vValue.u64);
200 }
201
202 /* *************************************************************************************
203 * Override Method - ufm::lang::Object
204 */
205 public:
212 virtual int hashcode(void) const override;
213
214 /* *************************************************************************************
215 * Public Method
216 */
217
218 /* *************************************************************************************
219 * Protected Method
220 */
221
222 /* *************************************************************************************
223 * Private Method
224 */
225
226 /* *************************************************************************************
227 * Static Variable
228 */
229
230 /* *************************************************************************************
231 * Static Method
232 */
233};
234
235/* ***************************************************************************************
236 * End of file
237 */
238
239#endif /* MFRAME_C6CF2DB4_1F61_4562_8698_C0C22D0C69FA */
物件基底類別
Definition Object.h:63
[Interface] 數值基礎抽象類
Definition Number.h:44
virtual int hashcode(void) const override
返回對象的哈希碼值
Number(void)
建構 Number 物件
bool operator==(Number &v)
比較兩個 Number 物件是否相等
Definition Number.h:198
Value vValue
數值儲存體
Definition Number.h:72
Definition Boolean.h:23
數值聯合體
Definition Number.h:54
char s8[4]
有符號8位元陣列
Definition Number.h:57
float f32[2]
32位元浮點數陣列
Definition Number.h:62
uint8 u8[4]
無符號8位元陣列
Definition Number.h:56
uint32 u32[2]
無符號32位元陣列
Definition Number.h:60
bool b
布林值
Definition Number.h:55
short s16[2]
有符號16位元陣列
Definition Number.h:59
uint64_t u64
無符號64位元整數
Definition Number.h:63
int s32[2]
有符號32位元陣列
Definition Number.h:61
uint16 u16[2]
無符號16位元陣列
Definition Number.h:58
double d64
64位元浮點數
Definition Number.h:65
int64_t s64
有符號64位元整數
Definition Number.h:64