ObjFW  Check-in [a2b0cd02a5]

Overview
Comment:Check version of serialization format.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a2b0cd02a5f6fe395ed606dca94753d3736c7fcb2433760bf81b1d09dd7ca789
User & Date: js on 2012-07-31 11:32:20
Other Links: manifest | tags
Context
2012-07-31
12:05
Slightly changed serialization format. check-in: a6ee2b2065 user: js tags: trunk
11:32
Check version of serialization format. check-in: a2b0cd02a5 user: js tags: trunk
11:27
OFHTTPRequest: Use OFUnsupportedVersionException. check-in: 7008aeed34 user: js tags: trunk
Changes

Modified src/OFString+Serialization.m from [120cf860de] to [7cccc18871].

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];