33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
}
- initWithString: (OFString*)string
{
self = [super init];
@try {
comment = [string copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
|
|
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
}
- initWithString: (OFString*)string
{
self = [super init];
@try {
_comment = [string copy];
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
|
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
133
134
135
136
137
138
139
140
|
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
comment = [[element stringValue] copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (BOOL)isEqual: (id)object
{
OFXMLComment *otherComment;
if (![object isKindOfClass: [OFXMLComment class]])
return NO;
otherComment = object;
return ([otherComment->comment isEqual: comment]);
}
- (uint32_t)hash
{
return [comment hash];
}
- (OFString*)stringValue
{
return @"";
}
- (OFString*)XMLString
{
return [OFString stringWithFormat: @"<!--%@-->", comment];
}
- (OFString*)XMLStringWithIndentation: (unsigned int)indentation
{
return [OFString stringWithFormat: @"<!--%@-->", comment];
}
- (OFString*)XMLStringWithIndentation: (unsigned int)indentation
level: (unsigned int)level
{
OFString *ret;
if (indentation > 0 && level > 0) {
char *whitespaces = [self allocMemoryWithSize:
(level * indentation) + 1];
memset(whitespaces, ' ', level * indentation);
whitespaces[level * indentation] = 0;
@try {
ret = [OFString stringWithFormat: @"%s<!--%@-->",
whitespaces,
comment];
} @finally {
[self freeMemory: whitespaces];
}
} else
ret = [OFString stringWithFormat: @"<!--%@-->", comment];
return ret;
}
- (OFString*)description
{
return [OFString stringWithFormat: @"<!--%@-->", comment];
}
- (OFXMLElement*)XMLElementBySerializing
{
return [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS
stringValue: comment];
}
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
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
133
134
135
136
137
138
139
140
|
if (![[element name] isEqual: [self className]] ||
![[element namespace] isEqual: OF_SERIALIZATION_NS])
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
_comment = [[element stringValue] copy];
objc_autoreleasePoolPop(pool);
} @catch (id e) {
[self release];
@throw e;
}
return self;
}
- (BOOL)isEqual: (id)object
{
OFXMLComment *comment;
if (![object isKindOfClass: [OFXMLComment class]])
return NO;
comment = object;
return ([comment->_comment isEqual: _comment]);
}
- (uint32_t)hash
{
return [_comment hash];
}
- (OFString*)stringValue
{
return @"";
}
- (OFString*)XMLString
{
return [OFString stringWithFormat: @"<!--%@-->", _comment];
}
- (OFString*)XMLStringWithIndentation: (unsigned int)indentation
{
return [OFString stringWithFormat: @"<!--%@-->", _comment];
}
- (OFString*)XMLStringWithIndentation: (unsigned int)indentation
level: (unsigned int)level
{
OFString *ret;
if (indentation > 0 && level > 0) {
char *whitespaces = [self allocMemoryWithSize:
(level * indentation) + 1];
memset(whitespaces, ' ', level * indentation);
whitespaces[level * indentation] = 0;
@try {
ret = [OFString stringWithFormat: @"%s<!--%@-->",
whitespaces,
_comment];
} @finally {
[self freeMemory: whitespaces];
}
} else
ret = [OFString stringWithFormat: @"<!--%@-->", _comment];
return ret;
}
- (OFString*)description
{
return [OFString stringWithFormat: @"<!--%@-->", _comment];
}
- (OFXMLElement*)XMLElementBySerializing
{
return [OFXMLElement elementWithName: [self className]
namespace: OF_SERIALIZATION_NS
stringValue: _comment];
}
@end
|