Overview
Comment: | Add support for serialization to OFList. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
046abd074d2405c0aa6ca28f45280f54 |
User & Date: | js on 2011-05-08 20:44:04 |
Other Links: | manifest | tags |
Context
2011-05-08
| ||
22:17 | Add -[string] to OFURL. check-in: 925754a097 user: js tags: trunk | |
20:44 | Add support for serialization to OFList. check-in: 046abd074d user: js tags: trunk | |
20:35 | Nicer formatting for serialization. check-in: bd879fd455 user: js tags: trunk | |
Changes
Modified src/OFArray.m from [31db88bd8e] to [b11d50e081].
︙ | ︙ | |||
432 433 434 435 436 437 438 | - (OFString*)stringBySerializing { OFAutoreleasePool *pool; OFMutableString *ret; OFObject <OFSerialization> **cArray; size_t i, count; | < < < | | | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | - (OFString*)stringBySerializing { OFAutoreleasePool *pool; OFMutableString *ret; OFObject <OFSerialization> **cArray; size_t i, count; if ([array count] == 0) { if ([self isKindOfClass: [OFMutableArray class]]) return @"<mutable,0>()"; else return @"<0>()"; } cArray = [array cArray]; count = [array count]; if ([self isKindOfClass: [OFMutableArray class]]) ret = [OFMutableString stringWithFormat: @"<mutable,%zd>(\n", count]; else ret = [OFMutableString stringWithFormat: @"<%zd>(\n", count]; pool = [[OFAutoreleasePool alloc] init]; for (i = 0; i < count - 1; i++) { [ret appendString: [cArray[i] stringBySerializing]]; [ret appendString: @",\n"]; [pool releaseObjects]; } [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendFormat: @"%@\n)", [cArray[i] stringBySerializing]]; |
︙ | ︙ |
Modified src/OFList.h from [36f81a72ce] to [2f5f6769f6].
︙ | ︙ | |||
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" typedef struct of_list_object_t of_list_object_t; /** * \brief A list object. * * A struct that contains a pointer to the next list object, the previous list * object and the object. */ struct of_list_object_t { /// A pointer to the next list object in the list of_list_object_t *next; /// A pointer to the previous list object in the list of_list_object_t *previous; /// The object for the list object id object; }; /** * \brief A class which provides easy to use double-linked lists. */ | > | > | 13 14 15 16 17 18 19 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 | * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #import "OFObject.h" #import "OFCollection.h" #import "OFEnumerator.h" #import "OFSerialization.h" typedef struct of_list_object_t of_list_object_t; /** * \brief A list object. * * A struct that contains a pointer to the next list object, the previous list * object and the object. */ struct of_list_object_t { /// A pointer to the next list object in the list of_list_object_t *next; /// A pointer to the previous list object in the list of_list_object_t *previous; /// The object for the list object id object; }; /** * \brief A class which provides easy to use double-linked lists. */ @interface OFList: OFObject <OFCopying, OFCollection, OFFastEnumeration, OFSerialization> { of_list_object_t *firstListObject; of_list_object_t *lastListObject; size_t count; unsigned long mutations; } |
︙ | ︙ |
Modified src/OFList.m from [b2fe60dc9c] to [81309c84e2].
︙ | ︙ | |||
304 305 306 307 308 309 310 311 312 313 | [ret appendString: [iter->object description]]; if (iter->next != NULL) [ret appendString: @",\n"]; [pool releaseObjects]; } [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | [ret appendString: [iter->object description]]; if (iter->next != NULL) [ret appendString: @",\n"]; [pool releaseObjects]; } [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n]"]; [pool release]; /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. */ ret->isa = [OFString class]; return ret; } - (OFString*)stringBySerializing { OFMutableString *ret; OFAutoreleasePool *pool; of_list_object_t *iter; if (count == 0) return @"<list,mutable>()"; ret = [OFMutableString stringWithString: @"<list,mutable>(\n"]; pool = [[OFAutoreleasePool alloc] init]; for (iter = firstListObject; iter != NULL; iter = iter->next) { [ret appendString: [iter->object stringBySerializing]]; if (iter->next != NULL) [ret appendString: @",\n"]; [pool releaseObjects]; } [ret replaceOccurrencesOfString: @"\n" withString: @"\n\t"]; [ret appendString: @"\n)"]; [pool release]; /* * Class swizzle the string to be immutable. We declared the return type * to be OFString*, so it can't be modified anyway. But not swizzling it * would create a real copy each time -[copy] is called. */ |
︙ | ︙ |