Index: src/OFXMLComment.h ================================================================== --- src/OFXMLComment.h +++ src/OFXMLComment.h @@ -22,30 +22,35 @@ * * @brief A class for representing XML comments. */ @interface OFXMLComment: OFXMLNode { - OFString *_comment; + OFString *_text; OF_RESERVE_IVARS(OFXMLComment, 4) } /** - * @brief Creates a new OFXMLComment with the specified string. + * @brief The comment text. + */ +@property (readonly, nonatomic) OFString *text; + +/** + * @brief Creates a new OFXMLComment with the specified text. * - * @param string The string for the comment + * @param text The text for the comment * @return A new OFXMLComment */ -+ (instancetype)commentWithString: (OFString *)string; ++ (instancetype)commentWithText: (OFString *)text; /** * @brief Initializes an already allocated OFXMLComment with the specified - * string. + * text. * - * @param string The string for the comment + * @param text The text for the comment * @return An initialized OFXMLComment */ -- (instancetype)initWithString: (OFString *)string; +- (instancetype)initWithText: (OFString *)text; - (instancetype)initWithSerialization: (OFXMLElement *)element; @end OF_ASSUME_NONNULL_END Index: src/OFXMLComment.m ================================================================== --- src/OFXMLComment.m +++ src/OFXMLComment.m @@ -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; } @@ -53,11 +55,11 @@ if (![element.name isEqual: self.className] || ![element.namespace isEqual: OF_SERIALIZATION_NS]) @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,31 +85,31 @@ 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 { @@ -118,28 +120,27 @@ memset(whitespaces, ' ', level * indentation); whitespaces[level * indentation] = 0; @try { ret = [OFString stringWithFormat: @"%s", - whitespaces, - _comment]; + whitespaces, _text]; } @finally { free(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]; + stringValue: _text]; } @end Index: src/OFXMLElementBuilder.m ================================================================== --- src/OFXMLElementBuilder.m +++ src/OFXMLElementBuilder.m @@ -152,11 +152,11 @@ } - (void)parser: (OFXMLParser *)parser foundComment: (OFString *)comment { - OFXMLComment *node = [OFXMLComment commentWithString: comment]; + OFXMLComment *node = [OFXMLComment commentWithText: comment]; OFXMLElement *parent = _stack.lastObject; if (parent != nil) [parent addChild: node]; else if ([_delegate respondsToSelector: Index: tests/OFXMLNodeTests.m ================================================================== --- tests/OFXMLNodeTests.m +++ tests/OFXMLNodeTests.m @@ -63,12 +63,12 @@ TEST(@"+[CDATAWithString:]", (nodes[3] = [OFXMLCDATA CDATAWithString: @""]) && [[nodes[3] XMLString] isEqual: @"]]>"]); - TEST(@"+[commentWithString:]", - (nodes[3] = [OFXMLComment commentWithString: @" comment "]) && + TEST(@"+[commentWithText:]", + (nodes[3] = [OFXMLComment commentWithText: @" comment "]) && [[nodes[3] XMLString] isEqual: @""]) module = @"OFXMLElement"; TEST(@"-[addAttributeWithName:stringValue:]",