ObjFW
|
00001 /* 00002 * Copyright (c) 2008, 2009, 2010, 2011, 2012 00003 * Jonathan Schleifer <js@webkeks.org> 00004 * 00005 * All rights reserved. 00006 * 00007 * This file is part of ObjFW. It may be distributed under the terms of the 00008 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in 00009 * the packaging of this file. 00010 * 00011 * Alternatively, it may be distributed under the terms of the GNU General 00012 * Public License, either version 2 or 3, which can be found in the file 00013 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this 00014 * file. 00015 */ 00016 00017 #ifndef __STDC_LIMIT_MACROS 00018 # define __STDC_LIMIT_MACROS 00019 #endif 00020 #ifndef __STDC_CONSTANT_MACROS 00021 # define __STDC_CONSTANT_MACROS 00022 #endif 00023 00024 #include <sys/types.h> 00025 00026 #import "OFObject.h" 00027 #import "OFSerialization.h" 00028 #import "OFJSONEncoding.h" 00029 00033 typedef enum of_number_type_t { 00034 OF_NUMBER_BOOL, 00035 OF_NUMBER_CHAR, 00036 OF_NUMBER_SHORT, 00037 OF_NUMBER_INT, 00038 OF_NUMBER_LONG, 00039 OF_NUMBER_UCHAR, 00040 OF_NUMBER_USHORT, 00041 OF_NUMBER_UINT, 00042 OF_NUMBER_ULONG, 00043 OF_NUMBER_INT8, 00044 OF_NUMBER_INT16, 00045 OF_NUMBER_INT32, 00046 OF_NUMBER_INT64, 00047 OF_NUMBER_UINT8, 00048 OF_NUMBER_UINT16, 00049 OF_NUMBER_UINT32, 00050 OF_NUMBER_UINT64, 00051 OF_NUMBER_SIZE, 00052 OF_NUMBER_SSIZE, 00053 OF_NUMBER_INTMAX, 00054 OF_NUMBER_UINTMAX, 00055 OF_NUMBER_PTRDIFF, 00056 OF_NUMBER_INTPTR, 00057 OF_NUMBER_UINTPTR, 00058 OF_NUMBER_FLOAT, 00059 OF_NUMBER_DOUBLE, 00060 } of_number_type_t; 00061 00065 @interface OFNumber: OFObject <OFCopying, OFSerialization, OFJSON> 00066 { 00067 union of_number_value { 00068 BOOL bool_; 00069 signed char char_; 00070 signed short short_; 00071 signed int int_; 00072 signed long long_; 00073 unsigned char uchar; 00074 unsigned short ushort; 00075 unsigned int uint; 00076 unsigned long ulong; 00077 int8_t int8; 00078 int16_t int16; 00079 int32_t int32; 00080 int64_t int64; 00081 uint8_t uint8; 00082 uint16_t uint16; 00083 uint32_t uint32; 00084 uint64_t uint64; 00085 size_t size; 00086 ssize_t ssize; 00087 intmax_t intmax; 00088 uintmax_t uintmax; 00089 ptrdiff_t ptrdiff; 00090 intptr_t intptr; 00091 uintptr_t uintptr; 00092 float float_; 00093 double double_; 00094 } value; 00095 of_number_type_t type; 00096 } 00097 00104 + numberWithBool: (BOOL)bool_; 00105 00112 + numberWithChar: (signed char)char_; 00113 00120 + numberWithShort: (signed short)short_; 00121 00128 + numberWithInt: (signed int)int_; 00129 00136 + numberWithLong: (signed long)long_; 00137 00144 + numberWithUnsignedChar: (unsigned char)uchar; 00145 00152 + numberWithUnsignedShort: (unsigned short)ushort; 00153 00160 + numberWithUnsignedInt: (unsigned int)uint; 00161 00168 + numberWithUnsignedLong: (unsigned long)ulong; 00169 00176 + numberWithInt8: (int8_t)int8; 00177 00184 + numberWithInt16: (int16_t)int16; 00185 00192 + numberWithInt32: (int32_t)int32; 00193 00200 + numberWithInt64: (int64_t)int64; 00201 00208 + numberWithUInt8: (uint8_t)uint8; 00209 00216 + numberWithUInt16: (uint16_t)uint16; 00217 00224 + numberWithUInt32: (uint32_t)uint32; 00225 00232 + numberWithUInt64: (uint64_t)uint64; 00233 00240 + numberWithSize: (size_t)size; 00241 00248 + numberWithSSize: (ssize_t)ssize; 00249 00256 + numberWithIntMax: (intmax_t)intmax; 00257 00264 + numberWithUIntMax: (uintmax_t)uintmax; 00265 00272 + numberWithPtrDiff: (ptrdiff_t)ptrdiff; 00273 00280 + numberWithIntPtr: (intptr_t)intptr; 00281 00288 + numberWithUIntPtr: (uintptr_t)uintptr; 00289 00296 + numberWithFloat: (float)float_; 00297 00304 + numberWithDouble: (double)double_; 00305 00312 - initWithBool: (BOOL)bool_; 00313 00321 - initWithChar: (signed char)char_; 00322 00330 - initWithShort: (signed short)short_; 00331 00339 - initWithInt: (signed int)int_; 00340 00348 - initWithLong: (signed long)long_; 00349 00357 - initWithUnsignedChar: (unsigned char)uchar; 00358 00366 - initWithUnsignedShort: (unsigned short)ushort; 00367 00375 - initWithUnsignedInt: (unsigned int)uint; 00376 00384 - initWithUnsignedLong: (unsigned long)ulong; 00385 00392 - initWithInt8: (int8_t)int8; 00393 00400 - initWithInt16: (int16_t)int16; 00401 00408 - initWithInt32: (int32_t)int32; 00409 00416 - initWithInt64: (int64_t)int64; 00417 00424 - initWithUInt8: (uint8_t)uint8; 00425 00432 - initWithUInt16: (uint16_t)uint16; 00433 00440 - initWithUInt32: (uint32_t)uint32; 00441 00448 - initWithUInt64: (uint64_t)uint64; 00449 00456 - initWithSize: (size_t)size; 00457 00464 - initWithSSize: (ssize_t)ssize; 00465 00472 - initWithIntMax: (intmax_t)intmax; 00473 00481 - initWithUIntMax: (uintmax_t)uintmax; 00482 00490 - initWithPtrDiff: (ptrdiff_t)ptrdiff; 00491 00498 - initWithIntPtr: (intptr_t)intptr; 00499 00507 - initWithUIntPtr: (uintptr_t)uintptr; 00508 00515 - initWithFloat: (float)float_; 00516 00523 - initWithDouble: (double)double_; 00524 00530 - (of_number_type_t)type; 00531 00537 - (BOOL)boolValue; 00538 00544 - (signed char)charValue; 00545 00551 - (signed short)shortValue; 00552 00558 - (signed int)intValue; 00559 00565 - (signed long)longValue; 00566 00572 - (unsigned char)unsignedCharValue; 00573 00579 - (unsigned short)unsignedShortValue; 00580 00586 - (unsigned int)unsignedIntValue; 00587 00593 - (unsigned long)unsignedLongValue; 00594 00600 - (int8_t)int8Value; 00601 00607 - (int16_t)int16Value; 00608 00614 - (int32_t)int32Value; 00615 00621 - (int64_t)int64Value; 00622 00628 - (uint8_t)uInt8Value; 00629 00635 - (uint16_t)uInt16Value; 00636 00642 - (uint32_t)uInt32Value; 00643 00649 - (uint64_t)uInt64Value; 00650 00656 - (size_t)sizeValue; 00657 00663 - (ssize_t)sSizeValue; 00664 00670 - (intmax_t)intMaxValue; 00671 00677 - (uintmax_t)uIntMaxValue; 00678 00684 - (ptrdiff_t)ptrDiffValue; 00685 00691 - (intptr_t)intPtrValue; 00692 00698 - (uintptr_t)uIntPtrValue; 00699 00705 - (float)floatValue; 00706 00712 - (double)doubleValue; 00713 00720 - (OFNumber*)numberByAddingNumber: (OFNumber*)num; 00721 00728 - (OFNumber*)numberBySubtractingNumber: (OFNumber*)num; 00729 00736 - (OFNumber*)numberByMultiplyingWithNumber: (OFNumber*)num; 00737 00744 - (OFNumber*)numberByDividingWithNumber: (OFNumber*)num; 00745 00754 - (OFNumber*)numberByANDingWithNumber: (OFNumber*)num; 00755 00764 - (OFNumber*)numberByORingWithNumber: (OFNumber*)num; 00765 00774 - (OFNumber*)numberByXORingWithNumber: (OFNumber*)num; 00775 00786 - (OFNumber*)numberByShiftingLeftWithNumber: (OFNumber*)num; 00787 00798 - (OFNumber*)numberByShiftingRightWithNumber: (OFNumber*)num; 00799 00805 - (OFNumber*)numberByIncreasing; 00806 00812 - (OFNumber*)numberByDecreasing; 00813 00821 - (OFNumber*)remainderOfDivisionWithNumber: (OFNumber*)num; 00822 @end