17 #ifndef __STDC_LIMIT_MACROS
18 # define __STDC_LIMIT_MACROS
20 #ifndef __STDC_CONSTANT_MACROS
21 # define __STDC_CONSTANT_MACROS
24 #include <sys/types.h>
27 #import "OFSerialization.h"
28 #import "OFJSONRepresentation.h"
33 typedef enum of_number_type_t {
34 OF_NUMBER_BOOL = 0x01,
35 OF_NUMBER_UCHAR = 0x02,
36 OF_NUMBER_USHORT = 0x03,
37 OF_NUMBER_UINT = 0x04,
38 OF_NUMBER_ULONG = 0x05,
39 OF_NUMBER_SIZE = 0x06,
40 OF_NUMBER_UINT8 = 0x07,
41 OF_NUMBER_UINT16 = 0x08,
42 OF_NUMBER_UINT32 = 0x09,
43 OF_NUMBER_UINT64 = 0x0A,
44 OF_NUMBER_UINTPTR = 0x0B,
45 OF_NUMBER_UINTMAX = 0x0C,
46 OF_NUMBER_SIGNED = 0x10,
47 OF_NUMBER_CHAR = OF_NUMBER_UCHAR | OF_NUMBER_SIGNED,
48 OF_NUMBER_SHORT = OF_NUMBER_USHORT | OF_NUMBER_SIGNED,
49 OF_NUMBER_INT = OF_NUMBER_UINT | OF_NUMBER_SIGNED,
50 OF_NUMBER_LONG = OF_NUMBER_ULONG | OF_NUMBER_SIGNED,
51 OF_NUMBER_INT8 = OF_NUMBER_UINT8 | OF_NUMBER_SIGNED,
52 OF_NUMBER_INT16 = OF_NUMBER_UINT16 | OF_NUMBER_SIGNED,
53 OF_NUMBER_INT32 = OF_NUMBER_UINT32 | OF_NUMBER_SIGNED,
54 OF_NUMBER_INT64 = OF_NUMBER_UINT64 | OF_NUMBER_SIGNED,
55 OF_NUMBER_SSIZE = OF_NUMBER_SIZE | OF_NUMBER_SIGNED,
56 OF_NUMBER_INTMAX = OF_NUMBER_UINTMAX | OF_NUMBER_SIGNED,
57 OF_NUMBER_PTRDIFF = 0x0D | OF_NUMBER_SIGNED,
58 OF_NUMBER_INTPTR = 0x0E | OF_NUMBER_SIGNED,
59 OF_NUMBER_FLOAT = 0x20,
60 OF_NUMBER_DOUBLE = 0x40 | OF_NUMBER_FLOAT,
69 union of_number_value {
76 unsigned short ushort;
97 of_number_type_t
type;
100 #ifdef OF_HAVE_PROPERTIES
101 @property (readonly) of_number_type_t type;
110 + (instancetype)numberWithBool: (BOOL)bool_;
118 + (instancetype)numberWithChar: (
signed char)char_;
126 + (instancetype)numberWithShort: (
signed short)short_;
134 + (instancetype)numberWithInt: (
signed int)int_;
142 + (instancetype)numberWithLong: (
signed long)long_;
150 + (instancetype)numberWithUnsignedChar: (
unsigned char)uchar;
158 + (instancetype)numberWithUnsignedShort: (
unsigned short)ushort;
166 + (instancetype)numberWithUnsignedInt: (
unsigned int)uint;
174 + (instancetype)numberWithUnsignedLong: (
unsigned long)ulong;
182 + (instancetype)numberWithInt8: (int8_t)int8;
190 + (instancetype)numberWithInt16: (int16_t)int16;
198 + (instancetype)numberWithInt32: (int32_t)int32;
206 + (instancetype)numberWithInt64: (int64_t)int64;
214 + (instancetype)numberWithUInt8: (uint8_t)uint8;
222 + (instancetype)numberWithUInt16: (uint16_t)uint16;
230 + (instancetype)numberWithUInt32: (uint32_t)uint32;
238 + (instancetype)numberWithUInt64: (uint64_t)uint64;
246 + (instancetype)numberWithSize: (
size_t)size;
254 + (instancetype)numberWithSSize: (ssize_t)ssize;
262 + (instancetype)numberWithIntMax: (intmax_t)intmax;
270 + (instancetype)numberWithUIntMax: (uintmax_t)uintmax;
278 + (instancetype)numberWithPtrDiff: (ptrdiff_t)ptrdiff;
286 + (instancetype)numberWithIntPtr: (intptr_t)intptr;
294 + (instancetype)numberWithUIntPtr: (uintptr_t)uintptr;
302 + (instancetype)numberWithFloat: (
float)float_;
310 + (instancetype)numberWithDouble: (
double)double_;
318 - initWithBool: (BOOL)bool_;
327 - initWithChar: (
signed char)char_;
336 - initWithShort: (
signed short)short_;
345 - initWithInt: (
signed int)int_;
354 - initWithLong: (
signed long)long_;
363 - initWithUnsignedChar: (
unsigned char)uchar;
372 - initWithUnsignedShort: (
unsigned short)ushort;
381 - initWithUnsignedInt: (
unsigned int)uint;
390 - initWithUnsignedLong: (
unsigned long)ulong;
398 - initWithInt8: (int8_t)int8;
406 - initWithInt16: (int16_t)int16;
414 - initWithInt32: (int32_t)int32;
422 - initWithInt64: (int64_t)int64;
430 - initWithUInt8: (uint8_t)uint8;
438 - initWithUInt16: (uint16_t)uint16;
446 - initWithUInt32: (uint32_t)uint32;
454 - initWithUInt64: (uint64_t)uint64;
462 - initWithSize: (
size_t)size;
470 - initWithSSize: (ssize_t)ssize;
478 - initWithIntMax: (intmax_t)intmax;
487 - initWithUIntMax: (uintmax_t)uintmax;
496 - initWithPtrDiff: (ptrdiff_t)ptrdiff;
504 - initWithIntPtr: (intptr_t)intptr;
513 - initWithUIntPtr: (uintptr_t)uintptr;
521 - initWithFloat: (
float)float_;
529 - initWithDouble: (
double)double_;
536 - (of_number_type_t)type;
550 - (
signed char)charValue;
557 - (
signed short)shortValue;
564 - (
signed int)intValue;
571 - (
signed long)longValue;
578 - (
unsigned char)unsignedCharValue;
585 - (
unsigned short)unsignedShortValue;
592 - (
unsigned int)unsignedIntValue;
599 - (
unsigned long)unsignedLongValue;
613 - (int16_t)int16Value;
620 - (int32_t)int32Value;
627 - (int64_t)int64Value;
634 - (uint8_t)uInt8Value;
641 - (uint16_t)uInt16Value;
648 - (uint32_t)uInt32Value;
655 - (uint64_t)uInt64Value;
669 - (ssize_t)sSizeValue;
676 - (intmax_t)intMaxValue;
683 - (uintmax_t)uIntMaxValue;
690 - (ptrdiff_t)ptrDiffValue;
697 - (intptr_t)intPtrValue;
704 - (uintptr_t)uIntPtrValue;
718 - (double)doubleValue;
830 #ifndef NSINTEGER_DEFINED
832 @compatibility_alias NSNumber
OFNumber;