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 "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) {
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
} @catch (OFUnboundNamespaceException *e) {
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
}
elements = [root elementsForNamespace: OF_SERIALIZATION_NS];
if ([elements count] != 1)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
#import "OFArray.h"
#import "OFXMLElement.h"
#import "OFAutoreleasePool.h"
#import "OFInvalidArgumentException.h"
#import "OFMalformedXMLException.h"
#import "OFUnboundNamespaceException.h"
#import "OFUnsupportedVersionException.h"
int _OFString_Serialization_reference;
@implementation OFString (Serialization)
- (id)objectByDeserializing
{
OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
OFXMLElement *root;
OFString *version;
OFArray *elements;
id object;
@try {
root = [OFXMLElement elementWithXMLString: self];
} @catch (OFMalformedXMLException *e) {
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
} @catch (OFUnboundNamespaceException *e) {
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
}
version = [[root attributeForName: @"version"] stringValue];
if (version == nil)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
if ([version decimalValue] > 0)
@throw [OFUnsupportedVersionException
exceptionWithClass: [self class]
version: version];
elements = [root elementsForNamespace: OF_SERIALIZATION_NS];
if ([elements count] != 1)
@throw [OFInvalidArgumentException
exceptionWithClass: [self class]
selector: _cmd];
|