20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#import "OFString+Serialization.h"
#import "OFSerialization.h"
#import "OFArray.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"
#import "OFInvalidArgumentException.h"
int _OFString_Serialization_reference;
@implementation OFString (Serialization)
- (id)objectByDeserializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *root = [OFXMLElement elementWithXMLString: self];
OFArray *elements;
id object;
elements = [root elementsForNamespace: OF_SERIALIZATION_NS];
if ([elements count] != 1)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
|
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
#import "OFString+Serialization.h"
#import "OFSerialization.h"
#import "OFArray.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"
#import "OFInvalidArgumentException.h"
#import "OFMalformedXMLException.h"
#import "OFUnboundNamespaceException.h"
int _OFString_Serialization_reference;
@implementation OFString (Serialization)
- (id)objectByDeserializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *root;
OFArray *elements;
id object;
@try {
root = [OFXMLElement elementWithXMLString: self];
} @catch (OFMalformedXMLException *e) {
[e release];
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
} @catch (OFUnboundNamespaceException *e) {
[e release];
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
}
elements = [root elementsForNamespace: OF_SERIALIZATION_NS];
if ([elements count] != 1)
@throw [OFInvalidArgumentException newWithClass: isa
selector: _cmd];
|