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
|
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
|
-
-
+
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#import "OFString.h"
#import "OFXMLElement.h"
#import "OFDataArray.h"
#import "OFInvalidArgumentException.h"
@interface OFNull ()
- (OFString*)OF_JSONRepresentationWithOptions: (int)options
depth: (size_t)depth;
- (OFString *)OF_JSONRepresentationWithOptions: (int)options
depth: (size_t)depth;
@end
static OFNull *null = nil;
@implementation OFNull
+ (void)initialize
{
null = [[self alloc] init];
}
+ (OFNull*)null
+ (OFNull *)null
{
return null;
}
- initWithSerialization: (OFXMLElement*)element
- initWithSerialization: (OFXMLElement *)element
{
void *pool;
[self release];
pool = objc_autoreleasePoolPush();
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException exception];
objc_autoreleasePoolPop(pool);
return [OFNull null];
}
- (OFString*)description
- (OFString *)description
{
return @"<null>";
}
- copy
{
return self;
}
- (OFXMLElement*)XMLElementBySerializing
- (OFXMLElement *)XMLElementBySerializing
{
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
element = [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS];
[element retain];
objc_autoreleasePoolPop(pool);
return [element autorelease];
}
- (OFString*)JSONRepresentation
- (OFString *)JSONRepresentation
{
return [self OF_JSONRepresentationWithOptions: 0
depth: 0];
}
- (OFString*)JSONRepresentationWithOptions: (int)options
- (OFString *)JSONRepresentationWithOptions: (int)options
{
return [self OF_JSONRepresentationWithOptions: options
depth: 0];
}
- (OFString*)OF_JSONRepresentationWithOptions: (int)options
- (OFString *)OF_JSONRepresentationWithOptions: (int)options
depth: (size_t)depth
{
return @"null";
}
- (OFDataArray*)messagePackRepresentation
- (OFDataArray *)messagePackRepresentation
{
OFDataArray *data = [OFDataArray dataArrayWithItemSize: 1
capacity: 1];
uint8_t type = 0xC0;
[data addItem: &type];
|