ObjFW
OFNumber.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3  *
4  * All rights reserved.
5  *
6  * This file is part of ObjFW. It may be distributed under the terms of the
7  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8  * the packaging of this file.
9  *
10  * Alternatively, it may be distributed under the terms of the GNU General
11  * Public License, either version 2 or 3, which can be found in the file
12  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13  * file.
14  */
15 
16 #ifndef __STDC_LIMIT_MACROS
17 # define __STDC_LIMIT_MACROS
18 #endif
19 #ifndef __STDC_CONSTANT_MACROS
20 # define __STDC_CONSTANT_MACROS
21 #endif
22 
23 #include "objfw-defs.h"
24 
25 #ifdef OF_HAVE_SYS_TYPES_H
26 # include <sys/types.h>
27 #endif
28 
29 #import "OFJSONRepresentation.h"
30 #import "OFMessagePackRepresentation.h"
31 #import "OFValue.h"
32 
33 OF_ASSUME_NONNULL_BEGIN
34 
47 @property (readonly, nonatomic) bool boolValue;
48 
52 @property (readonly, nonatomic) signed char charValue;
53 
57 @property (readonly, nonatomic) short shortValue;
58 
62 @property (readonly, nonatomic) int intValue;
63 
67 @property (readonly, nonatomic) long longValue;
68 
72 @property (readonly, nonatomic) long long longLongValue;
73 
77 @property (readonly, nonatomic) unsigned char unsignedCharValue;
78 
82 @property (readonly, nonatomic) unsigned short unsignedShortValue;
83 
87 @property (readonly, nonatomic) unsigned int unsignedIntValue;
88 
92 @property (readonly, nonatomic) unsigned long unsignedLongValue;
93 
97 @property (readonly, nonatomic) unsigned long long unsignedLongLongValue;
98 
102 @property (readonly, nonatomic) float floatValue;
103 
107 @property (readonly, nonatomic) double doubleValue;
108 
112 @property (readonly, nonatomic) OFString *stringValue;
113 
114 + (instancetype)valueWithPointer: (const void *)pointer OF_UNAVAILABLE;
115 + (instancetype)valueWithNonretainedObject: (id)object OF_UNAVAILABLE;
116 + (instancetype)valueWithRange: (OFRange)range OF_UNAVAILABLE;
117 + (instancetype)valueWithPoint: (OFPoint)point OF_UNAVAILABLE;
118 + (instancetype)valueWithSize: (OFSize)size OF_UNAVAILABLE;
119 + (instancetype)valueWithRect: (OFRect)rect OF_UNAVAILABLE;
120 
127 + (instancetype)numberWithBool: (bool)value;
128 
135 + (instancetype)numberWithChar: (signed char)value;
136 
143 + (instancetype)numberWithShort: (short)value;
144 
151 + (instancetype)numberWithInt: (int)value;
152 
159 + (instancetype)numberWithLong: (long)value;
160 
167 + (instancetype)numberWithLongLong: (long long)value;
168 
175 + (instancetype)numberWithUnsignedChar: (unsigned char)value;
176 
183 + (instancetype)numberWithUnsignedShort: (unsigned short)value;
184 
191 + (instancetype)numberWithUnsignedInt: (unsigned int)value;
192 
199 + (instancetype)numberWithUnsignedLong: (unsigned long)value;
200 
207 + (instancetype)numberWithUnsignedLongLong: (unsigned long long)value;
208 
215 + (instancetype)numberWithFloat: (float)value;
216 
223 + (instancetype)numberWithDouble: (double)value;
224 
231 - (instancetype)initWithBool: (bool)value;
232 
240 - (instancetype)initWithChar: (signed char)value;
241 
248 - (instancetype)initWithShort: (short)value;
249 
256 - (instancetype)initWithInt: (int)value;
257 
264 - (instancetype)initWithLong: (long)value;
265 
273 - (instancetype)initWithLongLong: (long long)value;
274 
282 - (instancetype)initWithUnsignedChar: (unsigned char)value;
283 
291 - (instancetype)initWithUnsignedShort: (unsigned short)value;
292 
300 - (instancetype)initWithUnsignedInt: (unsigned int)value;
301 
309 - (instancetype)initWithUnsignedLong: (unsigned long)value;
310 
318 - (instancetype)initWithUnsignedLongLong: (unsigned long long)value;
319 
326 - (instancetype)initWithFloat: (float)value;
327 
334 - (instancetype)initWithDouble: (double)value;
335 
342 - (OFComparisonResult)compare: (OFNumber *)number;
343 @end
344 
345 OF_ASSUME_NONNULL_END
346 
347 #if !defined(NSINTEGER_DEFINED) && !__has_feature(modules)
348 /* Required for number literals to work */
349 @compatibility_alias NSNumber OFNumber;
350 #endif
OFComparisonResult
A result of a comparison.
Definition: OFObject.h:54
Provides a way to store a number in an object.
Definition: OFNumber.h:43
unsigned short unsignedShortValue
The OFNumber as an unsigned short.
Definition: OFNumber.h:82
long long longLongValue
The OFNumber as a long long.
Definition: OFNumber.h:72
unsigned int unsignedIntValue
The OFNumber as an unsigned int.
Definition: OFNumber.h:87
long longValue
The OFNumber as a long.
Definition: OFNumber.h:67
double doubleValue
The OFNumber as a double.
Definition: OFNumber.h:107
float floatValue
The OFNumber as a float.
Definition: OFNumber.h:102
int intValue
The OFNumber as an int.
Definition: OFNumber.h:62
OFString * stringValue
The OFNumber as a string.
Definition: OFNumber.h:112
short shortValue
The OFNumber as a short.
Definition: OFNumber.h:57
unsigned long unsignedLongValue
The OFNumber as an unsigned long.
Definition: OFNumber.h:92
bool boolValue
The OFNumber as a bool.
Definition: OFNumber.h:47
unsigned long long unsignedLongLongValue
The OFNumber as an unsigned long long.
Definition: OFNumber.h:97
unsigned char unsignedCharValue
The OFNumber as an unsigned char.
Definition: OFNumber.h:77
signed char charValue
The OFNumber as a signed char.
Definition: OFNumber.h:52
A class for handling strings.
Definition: OFString.h:135
A class for storing arbitrary values in an object.
Definition: OFValue.h:25
A protocol for comparing objects.
Definition: OFObject.h:1384
A protocol implemented by classes that support encoding to a JSON representation.
Definition: OFJSONRepresentation.h:44
A protocol implemented by classes that support encoding to a MessagePack representation.
Definition: OFMessagePackRepresentation.h:29
A point in 2D space.
Definition: OFObject.h:157
A range.
Definition: OFObject.h:106
A rectangle.
Definition: OFObject.h:249
A size.
Definition: OFObject.h:203