-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathNSNumber+stdint.h
132 lines (107 loc) · 3.82 KB
/
NSNumber+stdint.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//
// NSNumber+stdint.h
// PebbleKit
//
// Created by Martijn The on 3/20/13.
// Copyright (c) 2013 Pebble Technology. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
* This category exposes the capabilities the underlying CFNumber to explicitely
* store the signedness and the width of the storage.
*/
@interface NSNumber (PBStandardIntegerExtensions)
/**
* Interprets the receiver as a 32-bits wide, unsigned integer.
*/
@property (readonly) uint32_t pb_uint32Value;
/**
* Interprets the receiver as a 16-bits wide, unsigned integer.
*/
@property (readonly) uint16_t pb_uint16Value;
/**
* Interprets the receiver as a 8-bits wide, unsigned integer.
*/
@property (readonly) uint8_t pb_uint8Value;
/**
* Interprets the receiver as a 32-bits wide, signed integer.
*/
@property (readonly) int32_t pb_int32Value;
/**
* Interprets the receiver as a 16-bits wide, signed integer.
*/
@property (readonly) int16_t pb_int16Value;
/**
* Interprets the receiver as a 8-bits wide, signed integer.
*/
@property (readonly) int8_t pb_int8Value;
/**
* Gets whether the number that is stored by the receiver should be interpreted
* as a floating pointer number or not.
*/
@property (readonly, getter=pb_isFloat) BOOL pb_float;
/**
* Gets whether the number that is stored by the receiver should be interpreted
* as a signed integer or not.
*/
@property (readonly, getter=pb_isSigned) BOOL pb_signed;
/**
* Gets the width in bytes of the integer that is stored by the receiver.
*/
@property (readonly) uint8_t pb_byteWidth;
/**
* Creates an NSNumber with a 32-bits wide, unsigned integer.
*
* @param value The value for the created number.
*/
+ (NSNumber *)pb_numberWithUint32:(uint32_t)value;
/**
* Creates an NSNumber with a 16-bits wide, unsigned integer.
*
* @param value The value for the created number.
*/
+ (NSNumber *)pb_numberWithUint16:(uint16_t)value;
/**
* Creates an NSNumber with a 8-bits wide, unsigned integer.
*
* @param value The value for the created number.
*/
+ (NSNumber *)pb_numberWithUint8:(uint8_t)value;
/**
* Creates an NSNumber with a 32-bits wide, signed integer.
*
* @param value The value for the created number.
*/
+ (NSNumber *)pb_numberWithInt32:(int32_t)value;
/**
* Creates an NSNumber with a 16-bits wide, signed integer.
*
* @param value The value for the created number.
*/
+ (NSNumber *)pb_numberWithInt16:(int16_t)value;
/**
* Creates an NSNumber with a 8-bits wide, signed integer.
*
* @param value The value for the created number.
*/
+ (NSNumber *)pb_numberWithInt8:(int8_t)value;
@end
@interface NSNumber (PBStandardIntegerExtensionsDeprecated)
- (uint32_t)uint32Value DEPRECATED_MSG_ATTRIBUTE("Use pb_uint32Value");
- (uint16_t)uint16Value DEPRECATED_MSG_ATTRIBUTE("Use pb_uint16Value");
- (uint8_t)uint8Value DEPRECATED_MSG_ATTRIBUTE("Use pb_uint8Value");
- (int32_t)int32Value DEPRECATED_MSG_ATTRIBUTE("Use pb_int32Value");
- (int16_t)int16Value DEPRECATED_MSG_ATTRIBUTE("Use pb_int16Value");
- (int8_t)int8Value DEPRECATED_MSG_ATTRIBUTE("Use pb_int8Value");
+ (NSNumber *)numberWithUint32:(uint32_t)value DEPRECATED_MSG_ATTRIBUTE("Use pb_numberWithUint32:");
+ (NSNumber *)numberWithUint16:(uint16_t)value DEPRECATED_MSG_ATTRIBUTE("Use pb_numberWithUint16:");
+ (NSNumber *)numberWithUint8:(uint8_t)value DEPRECATED_MSG_ATTRIBUTE("Use pb_numberWithUint8:");
+ (NSNumber *)numberWithInt32:(int32_t)value DEPRECATED_MSG_ATTRIBUTE("Use pb_numberWithInt32:");
+ (NSNumber *)numberWithInt16:(int16_t)value DEPRECATED_MSG_ATTRIBUTE("Use pb_numberWithInt16:");
+ (NSNumber *)numberWithInt8:(int8_t)value DEPRECATED_MSG_ATTRIBUTE("Use pb_numberWithInt8:");
- (BOOL)isFloat DEPRECATED_MSG_ATTRIBUTE("Use pb_isFloat");
- (BOOL)isSigned DEPRECATED_MSG_ATTRIBUTE("Use pb_isSigned");
- (uint8_t)width DEPRECATED_MSG_ATTRIBUTE("Use pb_byteWidth");
@end
NS_ASSUME_NONNULL_END