@@ -23,21 +23,23 @@ #import "OFXMLElement.h" #import "OFInvalidArgumentException.h" @implementation OFXMLComment -+ (instancetype)commentWithString: (OFString *)string +@synthesize text = _text; + ++ (instancetype)commentWithText: (OFString *)text { - return [[[self alloc] initWithString: string] autorelease]; + return [[[self alloc] initWithText: text] autorelease]; } -- (instancetype)initWithString: (OFString *)string +- (instancetype)initWithText: (OFString *)text { self = [super of_init]; @try { - _comment = [string copy]; + _text = [text copy]; } @catch (id e) { [self release]; @throw e; } @@ -50,14 +52,14 @@ @try { void *pool = objc_autoreleasePoolPush(); if (![element.name isEqual: self.className] || - ![element.namespace isEqual: OF_SERIALIZATION_NS]) + ![element.namespace isEqual: OFSerializationNS]) @throw [OFInvalidArgumentException exception]; - _comment = [element.stringValue copy]; + _text = [element.stringValue copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -66,11 +68,11 @@ return self; } - (void)dealloc { - [_comment release]; + [_text release]; [super dealloc]; } - (bool)isEqual: (id)object @@ -83,63 +85,62 @@ if (![object isKindOfClass: [OFXMLComment class]]) return false; comment = object; - return ([comment->_comment isEqual: _comment]); + return ([comment->_text isEqual: _text]); } - (unsigned long)hash { - return _comment.hash; + return _text.hash; } - (OFString *)stringValue { return @""; } - (OFString *)XMLString { - return [OFString stringWithFormat: @"", _comment]; + return [OFString stringWithFormat: @"", _text]; } - (OFString *)XMLStringWithIndentation: (unsigned int)indentation { - return [OFString stringWithFormat: @"", _comment]; + return [OFString stringWithFormat: @"", _text]; } - (OFString *)XMLStringWithIndentation: (unsigned int)indentation level: (unsigned int)level { OFString *ret; if (indentation > 0 && level > 0) { - char *whitespaces = of_alloc((level * indentation) + 1, 1); + char *whitespaces = OFAllocMemory((level * indentation) + 1, 1); memset(whitespaces, ' ', level * indentation); whitespaces[level * indentation] = 0; @try { ret = [OFString stringWithFormat: @"%s", - whitespaces, - _comment]; + whitespaces, _text]; } @finally { - free(whitespaces); + OFFreeMemory(whitespaces); } } else - ret = [OFString stringWithFormat: @"", _comment]; + ret = [OFString stringWithFormat: @"", _text]; return ret; } - (OFString *)description { - return [OFString stringWithFormat: @"", _comment]; + return [OFString stringWithFormat: @"", _text]; } - (OFXMLElement *)XMLElementBySerializing { return [OFXMLElement elementWithName: self.className - namespace: OF_SERIALIZATION_NS - stringValue: _comment]; + namespace: OFSerializationNS + stringValue: _text]; } @end