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
00046 @interface OFNumber: OFObject
00047 {
00048 union {
00049 char char_;
00050 short short_;
00051 int int_;
00052 long long_;
00053 unsigned char uchar;
00054 unsigned short ushort;
00055 unsigned int uint;
00056 unsigned long ulong;
00057 int8_t int8;
00058 int16_t int16;
00059 int32_t int32;
00060 int64_t int64;
00061 uint8_t uint8;
00062 uint16_t uint16;
00063 uint32_t uint32;
00064 uint64_t uint64;
00065 size_t size;
00066 ssize_t ssize;
00067 intmax_t intmax;
00068 uintmax_t uintmax;
00069 ptrdiff_t ptrdiff;
00070 intptr_t intptr;
00071 float float_;
00072 double double_;
00073 } value;
00074 enum of_number_type type;
00075 }
00076
00081 + numberWithChar: (char)char_;
00082
00087 + numberWithShort: (short)short_;
00088
00093 + numberWithInt: (int)int_;
00094
00099 + numberWithLong: (long)long_;
00100
00105 + numberWithUChar: (unsigned char)uchar;
00106
00111 + numberWithUShort: (unsigned short)ushort;
00112
00117 + numberWithUInt: (unsigned int)uint;
00118
00123 + numberWithULong: (unsigned long)ulong;
00124
00129 + numberWithInt8: (int8_t)int8;
00130
00135 + numberWithInt16: (int16_t)int16;
00136
00141 + numberWithInt32: (int32_t)int32;
00142
00147 + numberWithInt64: (int64_t)int64;
00148
00153 + numberWithUInt8: (uint8_t)uint8;
00154
00159 + numberWithUInt16: (uint16_t)uint16;
00160
00165 + numberWithUInt32: (uint32_t)uint32;
00166
00171 + numberWithUInt64: (uint64_t)uint64;
00172
00177 + numberWithSize: (size_t)size;
00178
00183 + numberWithSSize: (ssize_t)ssize;
00184
00189 + numberWithIntMax: (intmax_t)intmax;
00190
00195 + numberWithUIntMax: (uintmax_t)uintmax;
00196
00201 + numberWithPtrDiff: (ptrdiff_t)ptrdiff;
00202
00207 + numberWithIntPtr: (intptr_t)intptr;
00208
00213 + numberWithFloat: (float)float_;
00214
00219 + numberWithDouble: (double)double_;
00220
00227 - initWithChar: (char)char_;
00228
00235 - initWithShort: (short)short_;
00236
00243 - initWithInt: (int)int_;
00244
00251 - initWithLong: (long)long_;
00252
00259 - initWithUChar: (unsigned char)uchar;
00260
00267 - initWithUShort: (unsigned short)ushort;
00268
00275 - initWithUInt: (unsigned int)uint;
00276
00283 - initWithULong: (unsigned long)ulong;
00284
00291 - initWithInt8: (int8_t)int8;
00292
00299 - initWithInt16: (int16_t)int16;
00300
00307 - initWithInt32: (int32_t)int32;
00308
00315 - initWithInt64: (int64_t)int64;
00316
00323 - initWithUInt8: (uint8_t)uint8;
00324
00331 - initWithUInt16: (uint16_t)uint16;
00332
00339 - initWithUInt32: (uint32_t)uint32;
00340
00347 - initWithUInt64: (uint64_t)uint64;
00348
00355 - initWithSize: (size_t)size;
00356
00363 - initWithSSize: (ssize_t)ssize;
00364
00371 - initWithIntMax: (intmax_t)intmax;
00372
00379 - initWithUIntMax: (uintmax_t)uintmax;
00380
00387 - initWithPtrDiff: (ptrdiff_t)ptrdiff;
00388
00395 - initWithIntPtr: (intptr_t)intptr;
00396
00403 - initWithFloat: (float)float_;
00404
00411 - initWithDouble: (double)double_;
00412
00417 - (enum of_number_type)type;
00418
00422 - (char)asChar;
00423
00427 - (short)asShort;
00428
00432 - (int)asInt;
00433
00437 - (long)asLong;
00438
00442 - (unsigned char)asUChar;
00443
00447 - (unsigned short)asUShort;
00448
00452 - (unsigned int)asUInt;
00453
00457 - (unsigned long)asULong;
00458
00462 - (int8_t)asInt8;
00463
00467 - (int16_t)asInt16;
00468
00472 - (int32_t)asInt32;
00473
00477 - (int64_t)asInt64;
00478
00482 - (uint8_t)asUInt8;
00483
00487 - (uint16_t)asUInt16;
00488
00492 - (uint32_t)asUInt32;
00493
00497 - (uint64_t)asUInt64;
00498
00502 - (size_t)asSize;
00503
00507 - (ssize_t)asSSize;
00508
00512 - (intmax_t)asIntMax;
00513
00517 - (uintmax_t)asUIntMax;
00518
00522 - (ptrdiff_t)asPtrDiff;
00523
00527 - (intptr_t)asIntPtr;
00528
00532 - (float)asFloat;
00533
00537 - (double)asDouble;
00538
00544 - add: (OFNumber*)num;
00545
00551 - subtract: (OFNumber*)num;
00552
00558 - multiplyWith: (OFNumber*)num;
00559
00565 - divideBy: (OFNumber*)num;
00566
00570 - increase;
00571
00575 - decrease;
00576 @end