Differences From Artifact [5f45c17283]:
- File
src/OFDictionary.m
— part of check-in
[494dca4ae4]
at
2011-05-14 12:26:39
on branch trunk
— Use XML for serialization.
This way, we don't need a new parser and don't use a new format. (user: js, size: 18060) [annotate] [blame] [check-ins using]
To Artifact [a5322a8311]:
- File src/OFDictionary.m — part of check-in [dca3061dfc] at 2011-06-03 15:14:18 on branch trunk — Add deserialization. (user: js, size: 19835) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
462 463 464 465 466 467 468 469 470 471 472 473 474 475 | } @catch (id e) { [object release]; @throw e; } data[j]->object = object; } } @catch (id e) { [self release]; @throw e; } return self; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | } @catch (id e) { [object release]; @throw e; } data[j]->object = object; } } @catch (id e) { [self release]; @throw e; } return self; } - initWithSerialization: (OFXMLElement*)element { @try { OFAutoreleasePool *pool, *pool2; OFMutableDictionary *dictionary; OFArray *pairs; OFEnumerator *enumerator; OFXMLElement *pair; pool = [[OFAutoreleasePool alloc] init]; if (![[element name] isEqual: @"object"] || ![[element namespace] isEqual: OF_SERIALIZATION_NS] || ![[[element attributeForName: @"class"] stringValue] isEqual: [isa className]]) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; dictionary = [OFMutableDictionary dictionary]; pairs = [element elementsForName: @"pair" namespace: OF_SERIALIZATION_NS]; enumerator = [pairs objectEnumerator]; pool2 = [[OFAutoreleasePool alloc] init]; while ((pair = [enumerator nextObject]) != nil) { OFXMLElement *keyElement, *valueElement; id <OFSerialization, OFCopying> key; id <OFSerialization> object; keyElement = [pair elementForName: @"key" namespace: OF_SERIALIZATION_NS]; valueElement = [pair elementForName: @"value" namespace: OF_SERIALIZATION_NS]; if (keyElement == nil || valueElement == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; key = [OFSerialization objectByDeserializingXMLElement: [keyElement elementForName: @"object" namespace: OF_SERIALIZATION_NS]]; object = [OFSerialization objectByDeserializingXMLElement: [valueElement elementForName: @"object" namespace: OF_SERIALIZATION_NS]]; [dictionary setObject: object forKey: key]; [pool2 releaseObjects]; } self = [self initWithDictionary: dictionary]; [pool release]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ |