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_UINTPTR,
00040 OF_NUMBER_FLOAT,
00041 OF_NUMBER_DOUBLE,
00042 };
00043
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 uintptr_t uintptr;
00073 float float_;
00074 double double_;
00075 } value;
00076 enum of_number_type type;
00077 }
00078
00083 + numberWithChar: (char)char_;
00084
00089 + numberWithShort: (short)short_;
00090
00095 + numberWithInt: (int)int_;
00096
00101 + numberWithLong: (long)long_;
00102
00107 + numberWithUnsignedChar: (unsigned char)uchar;
00108
00113 + numberWithUnsignedShort: (unsigned short)ushort;
00114
00119 + numberWithUnsignedInt: (unsigned int)uint;
00120
00125 + numberWithUnsignedLong: (unsigned long)ulong;
00126
00131 + numberWithInt8: (int8_t)int8;
00132
00137 + numberWithInt16: (int16_t)int16;
00138
00143 + numberWithInt32: (int32_t)int32;
00144
00149 + numberWithInt64: (int64_t)int64;
00150
00155 + numberWithUInt8: (uint8_t)uint8;
00156
00161 + numberWithUInt16: (uint16_t)uint16;
00162
00167 + numberWithUInt32: (uint32_t)uint32;
00168
00173 + numberWithUInt64: (uint64_t)uint64;
00174
00179 + numberWithSize: (size_t)size;
00180
00185 + numberWithSSize: (ssize_t)ssize;
00186
00191 + numberWithIntMax: (intmax_t)intmax;
00192
00197 + numberWithUIntMax: (uintmax_t)uintmax;
00198
00203 + numberWithPtrDiff: (ptrdiff_t)ptrdiff;
00204
00209 + numberWithIntPtr: (intptr_t)intptr;
00210
00215 + numberWithUIntPtr: (uintptr_t)uintptr;
00216
00221 + numberWithFloat: (float)float_;
00222
00227 + numberWithDouble: (double)double_;
00228
00235 - initWithChar: (char)char_;
00236
00243 - initWithShort: (short)short_;
00244
00251 - initWithInt: (int)int_;
00252
00259 - initWithLong: (long)long_;
00260
00267 - initWithUnsignedChar: (unsigned char)uchar;
00268
00275 - initWithUnsignedShort: (unsigned short)ushort;
00276
00283 - initWithUnsignedInt: (unsigned int)uint;
00284
00291 - initWithUnsignedLong: (unsigned long)ulong;
00292
00299 - initWithInt8: (int8_t)int8;
00300
00307 - initWithInt16: (int16_t)int16;
00308
00315 - initWithInt32: (int32_t)int32;
00316
00323 - initWithInt64: (int64_t)int64;
00324
00331 - initWithUInt8: (uint8_t)uint8;
00332
00339 - initWithUInt16: (uint16_t)uint16;
00340
00347 - initWithUInt32: (uint32_t)uint32;
00348
00355 - initWithUInt64: (uint64_t)uint64;
00356
00363 - initWithSize: (size_t)size;
00364
00371 - initWithSSize: (ssize_t)ssize;
00372
00379 - initWithIntMax: (intmax_t)intmax;
00380
00387 - initWithUIntMax: (uintmax_t)uintmax;
00388
00395 - initWithPtrDiff: (ptrdiff_t)ptrdiff;
00396
00403 - initWithIntPtr: (intptr_t)intptr;
00404
00411 - initWithUIntPtr: (uintptr_t)uintptr;
00412
00419 - initWithFloat: (float)float_;
00420
00427 - initWithDouble: (double)double_;
00428
00433 - (enum of_number_type)type;
00434
00438 - (char)charValue;
00439
00443 - (short)shortValue;
00444
00448 - (int)intValue;
00449
00453 - (long)longValue;
00454
00458 - (unsigned char)unsignedCharValue;
00459
00463 - (unsigned short)unsignedShortValue;
00464
00468 - (unsigned int)unsignedIntValue;
00469
00473 - (unsigned long)unsignedLongValue;
00474
00478 - (int8_t)int8Value;
00479
00483 - (int16_t)int16Value;
00484
00488 - (int32_t)int32Value;
00489
00493 - (int64_t)int64Value;
00494
00498 - (uint8_t)uInt8Value;
00499
00503 - (uint16_t)uInt16Value;
00504
00508 - (uint32_t)uInt32Value;
00509
00513 - (uint64_t)uInt64Value;
00514
00518 - (size_t)sizeValue;
00519
00523 - (ssize_t)sSizeValue;
00524
00528 - (intmax_t)intMaxValue;
00529
00533 - (uintmax_t)uIntMaxValue;
00534
00538 - (ptrdiff_t)ptrDiffValue;
00539
00543 - (intptr_t)intPtrValue;
00544
00548 - (uintptr_t)uIntPtrValue;
00549
00553 - (float)floatValue;
00554
00558 - (double)doubleValue;
00559
00564 - (OFNumber*)numberByAddingNumber: (OFNumber*)num;
00565
00570 - (OFNumber*)numberBySubtractingNumber: (OFNumber*)num;
00571
00576 - (OFNumber*)numberByMultiplyingWithNumber: (OFNumber*)num;
00577
00582 - (OFNumber*)numberByDividingWithNumber: (OFNumber*)num;
00583
00592 - (OFNumber*)numberByANDingWithNumber: (OFNumber*)num;
00593
00602 - (OFNumber*)numberByORingWithNumber: (OFNumber*)num;
00603
00612 - (OFNumber*)numberByXORingWithNumber: (OFNumber*)num;
00613
00624 - (OFNumber*)numberByShiftingLeftWithNumber: (OFNumber*)num;
00625
00636 - (OFNumber*)numberByShiftingRightWithNumber: (OFNumber*)num;
00637
00641 - (OFNumber*)numberByIncreasing;
00642
00646 - (OFNumber*)numberByDecreasing;
00647 @end