Differences From Artifact [be193dc061]:
- File
src/OFXMLAttribute.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: 2272) [annotate] [blame] [check-ins using]
To Artifact [583d33a3b1]:
- File src/OFXMLAttribute.m — part of check-in [dca3061dfc] at 2011-06-03 15:14:18 on branch trunk — Add deserialization. (user: js, size: 3173) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
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 50 51 | #import "OFXMLAttribute.h" #import "OFString.h" #import "OFDictionary.h" #import "OFXMLElement.h" #import "OFAutoreleasePool.h" @implementation OFXMLAttribute + attributeWithName: (OFString*)name namespace: (OFString*)ns stringValue: (OFString*)value { return [[[self alloc] initWithName: name namespace: ns stringValue: value] autorelease]; } - initWithName: (OFString*)name_ namespace: (OFString*)ns_ stringValue: (OFString*)value { self = [super init]; @try { name = [name_ copy]; ns = [ns_ copy]; stringValue = [value copy]; } @catch (id e) { [self release]; @throw e; } return self; } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | #import "OFXMLAttribute.h" #import "OFString.h" #import "OFDictionary.h" #import "OFXMLElement.h" #import "OFAutoreleasePool.h" #import "OFInvalidArgumentException.h" @implementation OFXMLAttribute + attributeWithName: (OFString*)name namespace: (OFString*)ns stringValue: (OFString*)value { return [[[self alloc] initWithName: name namespace: ns stringValue: value] autorelease]; } - initWithName: (OFString*)name_ namespace: (OFString*)ns_ stringValue: (OFString*)value { self = [super init]; @try { name = [name_ copy]; ns = [ns_ copy]; stringValue = [value copy]; } @catch (id e) { [self release]; @throw e; } return self; } - initWithSerialization: (OFXMLElement*)element { self = [super init]; @try { OFAutoreleasePool *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]; name = [[[element elementForName: @"name" namespace: OF_SERIALIZATION_NS] stringValue] retain]; ns = [[[element elementForName: @"namespace" namespace: OF_SERIALIZATION_NS] stringValue] retain]; stringValue = [[[element elementForName: @"stringValue" namespace: OF_SERIALIZATION_NS] stringValue] retain]; [pool release]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ |