00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <unistd.h>
00013
00014 #import "OFObject.h"
00015
00016 enum of_number_type {
00017 OF_NUMBER_CHAR,
00018 OF_NUMBER_SHORT,
00019 OF_NUMBER_INT,
00020 OF_NUMBER_LONG,
00021 OF_NUMBER_UCHAR,
00022 OF_NUMBER_USHORT,
00023 OF_NUMBER_UINT,
00024 OF_NUMBER_ULONG,
00025 OF_NUMBER_INT8,
00026 OF_NUMBER_INT16,
00027 OF_NUMBER_INT32,
00028 OF_NUMBER_INT64,
00029 OF_NUMBER_UINT8,
00030 OF_NUMBER_UINT16,
00031 OF_NUMBER_UINT32,
00032 OF_NUMBER_UINT64,
00033 OF_NUMBER_SIZE,
00034 OF_NUMBER_SSIZE,
00035 OF_NUMBER_INTMAX,
00036 OF_NUMBER_UINTMAX,
00037 OF_NUMBER_PTRDIFF,
00038 OF_NUMBER_INTPTR,
00039 OF_NUMBER_FLOAT,
00040 OF_NUMBER_DOUBLE,
00041 };
00042
00047 @interface OFNumber: OFObject
00048 {
00049 union {
00050 char char_;
00051 short short_;
00052 int int_;
00053 long long_;
00054 unsigned char uchar;
00055 unsigned short ushort;
00056 unsigned int uint;
00057 unsigned long ulong;
00058 int8_t int8;
00059 int16_t int16;
00060 int32_t int32;
00061 int64_t int64;
00062 uint8_t uint8;
00063 uint16_t uint16;
00064 uint32_t uint32;
00065 uint64_t uint64;
00066 size_t size;
00067 ssize_t ssize;
00068 intmax_t intmax;
00069 uintmax_t uintmax;
00070 ptrdiff_t ptrdiff;
00071 intptr_t intptr;
00072 float float_;
00073 double double_;
00074 } value;
00075 enum of_number_type type;
00076 }
00077
00082 + numberWithChar: (char)char_;
00083
00088 + numberWithShort: (short)short_;
00089
00094 + numberWithInt: (int)int_;
00095
00100 + numberWithLong: (long)long_;
00101
00106 + numberWithUChar: (unsigned char)uchar;
00107
00112 + numberWithUShort: (unsigned short)ushort;
00113
00118 + numberWithUInt: (unsigned int)uint;
00119
00124 + numberWithULong: (unsigned long)ulong;
00125
00130 + numberWithInt8: (int8_t)int8;
00131
00136 + numberWithInt16: (int16_t)int16;
00137
00142 + numberWithInt32: (int32_t)int32;
00143
00148 + numberWithInt64: (int64_t)int64;
00149
00154 + numberWithUInt8: (uint8_t)uint8;
00155
00160 + numberWithUInt16: (uint16_t)uint16;
00161
00166 + numberWithUInt32: (uint32_t)uint32;
00167
00172 + numberWithUInt64: (uint64_t)uint64;
00173
00178 + numberWithSize: (size_t)size;
00179
00184 + numberWithSSize: (ssize_t)ssize;
00185
00190 + numberWithIntMax: (intmax_t)intmax;
00191
00196 + numberWithUIntMax: (uintmax_t)uintmax;
00197
00202 + numberWithPtrDiff: (ptrdiff_t)ptrdiff;
00203
00208 + numberWithIntPtr: (intptr_t)intptr;
00209
00214 + numberWithFloat: (float)float_;
00215
00220 + numberWithDouble: (double)double_;
00221
00228 - initWithChar: (char)char_;
00229
00236 - initWithShort: (short)short_;
00237
00244 - initWithInt: (int)int_;
00245
00252 - initWithLong: (long)long_;
00253
00260 - initWithUChar: (unsigned char)uchar;
00261
00268 - initWithUShort: (unsigned short)ushort;
00269
00276 - initWithUInt: (unsigned int)uint;
00277
00284 - initWithULong: (unsigned long)ulong;
00285
00292 - initWithInt8: (int8_t)int8;
00293
00300 - initWithInt16: (int16_t)int16;
00301
00308 - initWithInt32: (int32_t)int32;
00309
00316 - initWithInt64: (int64_t)int64;
00317
00324 - initWithUInt8: (uint8_t)uint8;
00325
00332 - initWithUInt16: (uint16_t)uint16;
00333
00340 - initWithUInt32: (uint32_t)uint32;
00341
00348 - initWithUInt64: (uint64_t)uint64;
00349
00356 - initWithSize: (size_t)size;
00357
00364 - initWithSSize: (ssize_t)ssize;
00365
00372 - initWithIntMax: (intmax_t)intmax;
00373
00380 - initWithUIntMax: (uintmax_t)uintmax;
00381
00388 - initWithPtrDiff: (ptrdiff_t)ptrdiff;
00389
00396 - initWithIntPtr: (intptr_t)intptr;
00397
00404 - initWithFloat: (float)float_;
00405
00412 - initWithDouble: (double)double_;
00413
00418 - (enum of_number_type)type;
00419
00423 - (char)asChar;
00424
00428 - (short)asShort;
00429
00433 - (int)asInt;
00434
00438 - (long)asLong;
00439
00443 - (unsigned char)asUChar;
00444
00448 - (unsigned short)asUShort;
00449
00453 - (unsigned int)asUInt;
00454
00458 - (unsigned long)asULong;
00459
00463 - (int8_t)asInt8;
00464
00468 - (int16_t)asInt16;
00469
00473 - (int32_t)asInt32;
00474
00478 - (int64_t)asInt64;
00479
00483 - (uint8_t)asUInt8;
00484
00488 - (uint16_t)asUInt16;
00489
00493 - (uint32_t)asUInt32;
00494
00498 - (uint64_t)asUInt64;
00499
00503 - (size_t)asSize;
00504
00508 - (ssize_t)asSSize;
00509
00513 - (intmax_t)asIntMax;
00514
00518 - (uintmax_t)asUIntMax;
00519
00523 - (ptrdiff_t)asPtrDiff;
00524
00528 - (intptr_t)asIntPtr;
00529
00533 - (float)asFloat;
00534
00538 - (double)asDouble;
00539
00545 - add: (OFNumber*)num;
00546
00552 - subtract: (OFNumber*)num;
00553
00559 - multiplyWith: (OFNumber*)num;
00560
00566 - divideBy: (OFNumber*)num;
00567
00571 - increase;
00572
00576 - decrease;
00577 @end