00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <unistd.h>
00018
00019 #import "OFObject.h"
00020
00021 enum of_number_type {
00022 OF_NUMBER_BOOL,
00023 OF_NUMBER_CHAR,
00024 OF_NUMBER_SHORT,
00025 OF_NUMBER_INT,
00026 OF_NUMBER_LONG,
00027 OF_NUMBER_UCHAR,
00028 OF_NUMBER_USHORT,
00029 OF_NUMBER_UINT,
00030 OF_NUMBER_ULONG,
00031 OF_NUMBER_INT8,
00032 OF_NUMBER_INT16,
00033 OF_NUMBER_INT32,
00034 OF_NUMBER_INT64,
00035 OF_NUMBER_UINT8,
00036 OF_NUMBER_UINT16,
00037 OF_NUMBER_UINT32,
00038 OF_NUMBER_UINT64,
00039 OF_NUMBER_SIZE,
00040 OF_NUMBER_SSIZE,
00041 OF_NUMBER_INTMAX,
00042 OF_NUMBER_UINTMAX,
00043 OF_NUMBER_PTRDIFF,
00044 OF_NUMBER_INTPTR,
00045 OF_NUMBER_UINTPTR,
00046 OF_NUMBER_FLOAT,
00047 OF_NUMBER_DOUBLE,
00048 };
00049
00053 @interface OFNumber: OFObject <OFCopying>
00054 {
00055 union {
00056 BOOL bool_;
00057 char char_;
00058 short short_;
00059 int int_;
00060 long long_;
00061 unsigned char uchar;
00062 unsigned short ushort;
00063 unsigned int uint;
00064 unsigned long ulong;
00065 int8_t int8;
00066 int16_t int16;
00067 int32_t int32;
00068 int64_t int64;
00069 uint8_t uint8;
00070 uint16_t uint16;
00071 uint32_t uint32;
00072 uint64_t uint64;
00073 size_t size;
00074 ssize_t ssize;
00075 intmax_t intmax;
00076 uintmax_t uintmax;
00077 ptrdiff_t ptrdiff;
00078 intptr_t intptr;
00079 uintptr_t uintptr;
00080 float float_;
00081 double double_;
00082 } value;
00083 enum of_number_type type;
00084 }
00085
00090 + numberWithBool: (BOOL)bool_;
00091
00096 + numberWithChar: (char)char_;
00097
00102 + numberWithShort: (short)short_;
00103
00108 + numberWithInt: (int)int_;
00109
00114 + numberWithLong: (long)long_;
00115
00120 + numberWithUnsignedChar: (unsigned char)uchar;
00121
00126 + numberWithUnsignedShort: (unsigned short)ushort;
00127
00132 + numberWithUnsignedInt: (unsigned int)uint;
00133
00138 + numberWithUnsignedLong: (unsigned long)ulong;
00139
00144 + numberWithInt8: (int8_t)int8;
00145
00150 + numberWithInt16: (int16_t)int16;
00151
00156 + numberWithInt32: (int32_t)int32;
00157
00162 + numberWithInt64: (int64_t)int64;
00163
00168 + numberWithUInt8: (uint8_t)uint8;
00169
00174 + numberWithUInt16: (uint16_t)uint16;
00175
00180 + numberWithUInt32: (uint32_t)uint32;
00181
00186 + numberWithUInt64: (uint64_t)uint64;
00187
00192 + numberWithSize: (size_t)size;
00193
00198 + numberWithSSize: (ssize_t)ssize;
00199
00204 + numberWithIntMax: (intmax_t)intmax;
00205
00210 + numberWithUIntMax: (uintmax_t)uintmax;
00211
00216 + numberWithPtrDiff: (ptrdiff_t)ptrdiff;
00217
00222 + numberWithIntPtr: (intptr_t)intptr;
00223
00228 + numberWithUIntPtr: (uintptr_t)uintptr;
00229
00234 + numberWithFloat: (float)float_;
00235
00240 + numberWithDouble: (double)double_;
00241
00248 - initWithBool: (BOOL)bool_;
00249
00256 - initWithChar: (char)char_;
00257
00264 - initWithShort: (short)short_;
00265
00272 - initWithInt: (int)int_;
00273
00280 - initWithLong: (long)long_;
00281
00288 - initWithUnsignedChar: (unsigned char)uchar;
00289
00296 - initWithUnsignedShort: (unsigned short)ushort;
00297
00304 - initWithUnsignedInt: (unsigned int)uint;
00305
00312 - initWithUnsignedLong: (unsigned long)ulong;
00313
00320 - initWithInt8: (int8_t)int8;
00321
00328 - initWithInt16: (int16_t)int16;
00329
00336 - initWithInt32: (int32_t)int32;
00337
00344 - initWithInt64: (int64_t)int64;
00345
00352 - initWithUInt8: (uint8_t)uint8;
00353
00360 - initWithUInt16: (uint16_t)uint16;
00361
00368 - initWithUInt32: (uint32_t)uint32;
00369
00376 - initWithUInt64: (uint64_t)uint64;
00377
00384 - initWithSize: (size_t)size;
00385
00392 - initWithSSize: (ssize_t)ssize;
00393
00400 - initWithIntMax: (intmax_t)intmax;
00401
00408 - initWithUIntMax: (uintmax_t)uintmax;
00409
00416 - initWithPtrDiff: (ptrdiff_t)ptrdiff;
00417
00424 - initWithIntPtr: (intptr_t)intptr;
00425
00432 - initWithUIntPtr: (uintptr_t)uintptr;
00433
00440 - initWithFloat: (float)float_;
00441
00448 - initWithDouble: (double)double_;
00449
00454 - (enum of_number_type)type;
00455
00459 - (BOOL)boolValue;
00460
00464 - (char)charValue;
00465
00469 - (short)shortValue;
00470
00474 - (int)intValue;
00475
00479 - (long)longValue;
00480
00484 - (unsigned char)unsignedCharValue;
00485
00489 - (unsigned short)unsignedShortValue;
00490
00494 - (unsigned int)unsignedIntValue;
00495
00499 - (unsigned long)unsignedLongValue;
00500
00504 - (int8_t)int8Value;
00505
00509 - (int16_t)int16Value;
00510
00514 - (int32_t)int32Value;
00515
00519 - (int64_t)int64Value;
00520
00524 - (uint8_t)uInt8Value;
00525
00529 - (uint16_t)uInt16Value;
00530
00534 - (uint32_t)uInt32Value;
00535
00539 - (uint64_t)uInt64Value;
00540
00544 - (size_t)sizeValue;
00545
00549 - (ssize_t)sSizeValue;
00550
00554 - (intmax_t)intMaxValue;
00555
00559 - (uintmax_t)uIntMaxValue;
00560
00564 - (ptrdiff_t)ptrDiffValue;
00565
00569 - (intptr_t)intPtrValue;
00570
00574 - (uintptr_t)uIntPtrValue;
00575
00579 - (float)floatValue;
00580
00584 - (double)doubleValue;
00585
00590 - (OFNumber*)numberByAddingNumber: (OFNumber*)num;
00591
00596 - (OFNumber*)numberBySubtractingNumber: (OFNumber*)num;
00597
00602 - (OFNumber*)numberByMultiplyingWithNumber: (OFNumber*)num;
00603
00608 - (OFNumber*)numberByDividingWithNumber: (OFNumber*)num;
00609
00618 - (OFNumber*)numberByANDingWithNumber: (OFNumber*)num;
00619
00628 - (OFNumber*)numberByORingWithNumber: (OFNumber*)num;
00629
00638 - (OFNumber*)numberByXORingWithNumber: (OFNumber*)num;
00639
00650 - (OFNumber*)numberByShiftingLeftWithNumber: (OFNumber*)num;
00651
00662 - (OFNumber*)numberByShiftingRightWithNumber: (OFNumber*)num;
00663
00667 - (OFNumber*)numberByIncreasing;
00668
00672 - (OFNumber*)numberByDecreasing;
00673
00678 - (OFNumber*)remainderOfDivisionWithNumber: (OFNumber*)num;
00679 @end