Index: src/OFDataArray.h ================================================================== --- src/OFDataArray.h +++ src/OFDataArray.h @@ -172,10 +172,10 @@ * * The OFBigDataArray class is a class for storing arbitrary data in an array * and is designed to store large hunks of data. Therefore, it allocates * memory in pages rather than a chunk of memory for each item. */ -@interface OFBigDataArray: OFDataArray +@interface OFBigDataArray: OFDataArray { size_t size; } @end Index: src/OFXMLElement.h ================================================================== --- src/OFXMLElement.h +++ src/OFXMLElement.h @@ -198,11 +198,11 @@ /** * \return A new autoreleased OFString representing the OFXMLElement as an * XML string */ -- (OFString*)string; +- (OFString*)stringValue; /** * Adds the specified attribute. * * \param attr The attribute to add Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -9,12 +9,12 @@ * the packaging of this file. */ #include "config.h" -#include #include +#include #import "OFXMLElement.h" #import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" @@ -188,12 +188,12 @@ - (OFArray*)children { return [[children copy] autorelease]; } -- (OFString*)_stringWithParentNamespaces: (OFDictionary*)parent_namespaces - parentDefaultNamespace: (OFString*)parent_default_ns +- (OFString*)_stringValueWithParentNamespaces: (OFDictionary*)parent_namespaces + parentDefaultNamespace: (OFString*)parent_default_ns { OFAutoreleasePool *pool, *pool2; char *str_c; size_t len, i, j, attrs_count; OFString *prefix = nil; @@ -328,11 +328,11 @@ for (j = 0; j < children_count; j++) append(tmp, @selector( appendCStringWithoutUTF8Checking:), [[children_carray[j] - _stringWithParentNamespaces: all_namespaces + _stringValueWithParentNamespaces: all_namespaces parentDefaultNamespace: defaultNamespace] cString]); len += [tmp cStringLength] + [name cStringLength] + 2; @try { str_c = [self resizeMemory: str_c @@ -379,14 +379,19 @@ [self freeMemory: str_c]; } return ret; } -- (OFString*)string +- (OFString*)stringValue +{ + return [self _stringValueWithParentNamespaces: nil + parentDefaultNamespace: nil]; +} + +- (OFString*)description { - return [self _stringWithParentNamespaces: nil - parentDefaultNamespace: nil]; + return [self stringValue]; } - (void)addAttribute: (OFXMLAttribute*)attr { if (name == nil) Index: tests/OFXMLElementBuilderTests.m ================================================================== --- tests/OFXMLElementBuilderTests.m +++ tests/OFXMLElementBuilderTests.m @@ -9,11 +9,10 @@ * the packaging of this file. */ #include "config.h" -#include #include #import "OFXMLElement.h" #import "OFXMLParser.h" #import "OFXMLElementBuilder.h" @@ -35,22 +34,20 @@ - (void)XMLElementBuilderTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFXMLParser *p = [OFXMLParser parser]; OFXMLElementBuilder *builder = [OFXMLElementBuilder elementBuilder]; - const char *str = "barbaz" + OFString *str = @"barbaz" " " ""; [p setDelegate: builder]; [builder setDelegate: self]; TEST(@"Building element from parsed XML", - R([p parseBuffer: str - withSize: strlen(str)]) && - elem != nil && !strcmp([[elem string] cString], str)) - + R([p parseString: str]) && + elem != nil && [[elem stringValue] isEqual: str]) [elem release]; [pool drain]; } @end Index: tests/OFXMLElementTests.m ================================================================== --- tests/OFXMLElementTests.m +++ tests/OFXMLElementTests.m @@ -28,72 +28,74 @@ OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; OFXMLElement *elem[4]; TEST(@"+[elementWithName:]", (elem[0] = [OFXMLElement elementWithName: @"foo"]) && - [[elem[0] string] isEqual: @""]) + [[elem[0] stringValue] isEqual: @""]) TEST(@"+[elementWithName:stringValue:]", (elem[1] = [OFXMLElement elementWithName: @"foo" stringValue: @"b&ar"]) && - [[elem[1] string] isEqual: @"b&ar"]) + [[elem[1] stringValue] isEqual: @"b&ar"]) TEST(@"+[elementWithName:namespace:]", (elem[2] = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test"]) && R([elem[2] addAttributeWithName: @"test" stringValue: @"test"]) && R([elem[2] setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]) && - [[elem[2] string] isEqual: @""]) + [[elem[2] stringValue] isEqual: @""]) TEST(@"+[elementWithName:namespace:stringValue:]", (elem[3] = [OFXMLElement elementWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"x"]) && R([elem[3] setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"]) && - [[elem[3] string] isEqual: @"x"]) + [[elem[3] stringValue] isEqual: + @"x"]) TEST(@"+[elementWithCharacters:]", (elem[3] = [OFXMLElement elementWithCharacters: @""]) && - [[elem[3] string] isEqual: @"<foo>"]) + [[elem[3] stringValue] isEqual: @"<foo>"]) TEST(@"+[elementWithCDATA:]", (elem[3] = [OFXMLElement elementWithCDATA: @""]) && - [[elem[3] string] isEqual: @"]]>"]); + [[elem[3] stringValue] isEqual: @"]]>"]); TEST(@"+[elementWithComment:]", (elem[3] = [OFXMLElement elementWithComment: @" comment "]) && - [[elem[3] string] isEqual: @""]) + [[elem[3] stringValue] isEqual: @""]) TEST(@"-[addAttributeWithName:stringValue:]", R([elem[0] addAttributeWithName: @"foo" stringValue: @"b&ar"]) && - [[elem[0] string] isEqual: @""] && + [[elem[0] stringValue] isEqual: @""] && R([elem[1] addAttributeWithName: @"foo" stringValue: @"b&ar"]) && - [[elem[1] string] isEqual: @"b&ar"]) + [[elem[1] stringValue] isEqual: + @"b&ar"]) TEST(@"-[setPrefix:forNamespace:]", R([elem[1] setPrefix: @"objfw-test" forNamespace: @"urn:objfw:test"])) TEST(@"-[addAttributeWithName:namespace:stringValue:]", R([elem[1] addAttributeWithName: @"foo" namespace: @"urn:objfw:test" stringValue: @"bar"]) && - [[elem[1] string] isEqual: + [[elem[1] stringValue] isEqual: @"b&ar"]) TEST(@"-[addChild:]", R([elem[0] addChild: [OFXMLElement elementWithName: @"bar"]]) && - [[elem[0] string] isEqual: @""] && - R([elem[2] addChild: - [OFXMLElement elementWithName: @"bar" - namespace: @"urn:objfw:test"]]) && - [[elem[2] string] isEqual: + [[elem[0] stringValue] isEqual: + @""] && + R([elem[2] addChild: [OFXMLElement elementWithName: @"bar" + namespace: @"urn:objfw:test"]]) && + [[elem[2] stringValue] isEqual: @""]) [pool drain]; } @end