ObjFW
Loading...
Searching...
No Matches
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 program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef __STDC_LIMIT_MACROS
21# define __STDC_LIMIT_MACROS
22#endif
23#ifndef __STDC_CONSTANT_MACROS
24# define __STDC_CONSTANT_MACROS
25#endif
26
27#include "objfw-defs.h"
28
29#ifdef OF_HAVE_SYS_TYPES_H
30# include <sys/types.h>
31#endif
32
33#import "OFJSONRepresentation.h"
34#import "OFMessagePackRepresentation.h"
35#import "OFValue.h"
36
37OF_ASSUME_NONNULL_BEGIN
38
51@property (readonly, nonatomic) bool boolValue;
52
56@property (readonly, nonatomic) signed char charValue;
57
61@property (readonly, nonatomic) short shortValue;
62
66@property (readonly, nonatomic) int intValue;
67
71@property (readonly, nonatomic) long longValue;
72
76@property (readonly, nonatomic) long long longLongValue;
77
81@property (readonly, nonatomic) unsigned char unsignedCharValue;
82
86@property (readonly, nonatomic) unsigned short unsignedShortValue;
87
91@property (readonly, nonatomic) unsigned int unsignedIntValue;
92
96@property (readonly, nonatomic) unsigned long unsignedLongValue;
97
101@property (readonly, nonatomic) unsigned long long unsignedLongLongValue;
102
106@property (readonly, nonatomic) float floatValue;
107
111@property (readonly, nonatomic) double doubleValue;
112
116@property (readonly, nonatomic) OFString *stringValue;
117
118+ (instancetype)valueWithPointer: (const void *)pointer OF_UNAVAILABLE;
119+ (instancetype)valueWithNonretainedObject: (id)object OF_UNAVAILABLE;
120+ (instancetype)valueWithRange: (OFRange)range OF_UNAVAILABLE;
121+ (instancetype)valueWithPoint: (OFPoint)point OF_UNAVAILABLE;
122+ (instancetype)valueWithSize: (OFSize)size OF_UNAVAILABLE;
123+ (instancetype)valueWithRect: (OFRect)rect OF_UNAVAILABLE;
124
131+ (instancetype)numberWithBool: (bool)value;
132
139+ (instancetype)numberWithChar: (signed char)value;
140
147+ (instancetype)numberWithShort: (short)value;
148
155+ (instancetype)numberWithInt: (int)value;
156
163+ (instancetype)numberWithLong: (long)value;
164
171+ (instancetype)numberWithLongLong: (long long)value;
172
179+ (instancetype)numberWithUnsignedChar: (unsigned char)value;
180
187+ (instancetype)numberWithUnsignedShort: (unsigned short)value;
188
195+ (instancetype)numberWithUnsignedInt: (unsigned int)value;
196
203+ (instancetype)numberWithUnsignedLong: (unsigned long)value;
204
211+ (instancetype)numberWithUnsignedLongLong: (unsigned long long)value;
212
219+ (instancetype)numberWithFloat: (float)value;
220
227+ (instancetype)numberWithDouble: (double)value;
228
235- (instancetype)initWithBool: (bool)value;
236
244- (instancetype)initWithChar: (signed char)value;
245
252- (instancetype)initWithShort: (short)value;
253
260- (instancetype)initWithInt: (int)value;
261
268- (instancetype)initWithLong: (long)value;
269
277- (instancetype)initWithLongLong: (long long)value;
278
286- (instancetype)initWithUnsignedChar: (unsigned char)value;
287
295- (instancetype)initWithUnsignedShort: (unsigned short)value;
296
304- (instancetype)initWithUnsignedInt: (unsigned int)value;
305
313- (instancetype)initWithUnsignedLong: (unsigned long)value;
314
322- (instancetype)initWithUnsignedLongLong: (unsigned long long)value;
323
330- (instancetype)initWithFloat: (float)value;
331
338- (instancetype)initWithDouble: (double)value;
339
346- (OFComparisonResult)compare: (OFNumber *)number;
347@end
348
349OF_ASSUME_NONNULL_END
350
351#if !defined(NSINTEGER_DEFINED) && !__has_feature(modules)
352/* Required for number literals to work */
353@compatibility_alias NSNumber OFNumber;
354#endif
OFComparisonResult
A result of a comparison.
Definition OFObject.h:58
Provides a way to store a number in an object.
Definition OFNumber.h:47
unsigned short unsignedShortValue
The OFNumber as an unsigned short.
Definition OFNumber.h:86
long long longLongValue
The OFNumber as a long long.
Definition OFNumber.h:76
unsigned int unsignedIntValue
The OFNumber as an unsigned int.
Definition OFNumber.h:91
long longValue
The OFNumber as a long.
Definition OFNumber.h:71
double doubleValue
The OFNumber as a double.
Definition OFNumber.h:111
float floatValue
The OFNumber as a float.
Definition OFNumber.h:106
int intValue
The OFNumber as an int.
Definition OFNumber.h:66
OFString * stringValue
The OFNumber as a string.
Definition OFNumber.h:116
short shortValue
The OFNumber as a short.
Definition OFNumber.h:61
unsigned long unsignedLongValue
The OFNumber as an unsigned long.
Definition OFNumber.h:96
bool boolValue
The OFNumber as a bool.
Definition OFNumber.h:51
unsigned long long unsignedLongLongValue
The OFNumber as an unsigned long long.
Definition OFNumber.h:101
unsigned char unsignedCharValue
The OFNumber as an unsigned char.
Definition OFNumber.h:81
signed char charValue
The OFNumber as a signed char.
Definition OFNumber.h:56
A class for handling strings.
Definition OFString.h:143
A class for storing arbitrary values in an object.
Definition OFValue.h:29
A protocol for comparing objects.
Definition OFObject.h:1388
A protocol implemented by classes that support encoding to a JSON representation.
Definition OFJSONRepresentation.h:49
A protocol implemented by classes that support encoding to a MessagePack representation.
Definition OFMessagePackRepresentation.h:33
A point in 2D space.
Definition OFObject.h:161
A range.
Definition OFObject.h:110
A rectangle.
Definition OFObject.h:253
A size.
Definition OFObject.h:207