ObjFW  Check-in [8d3b009af1]

Overview
Comment:Throw an OFInvalidArgumentException if serialization can't be parsed.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8d3b009af11c1f88f0fc1943477b422d6203d9c2a7ff853515f1ad23cac8a314
User & Date: js on 2011-09-01 14:25:09
Other Links: manifest | tags
Context
2011-09-01
18:08
Add serialization and deserialization for OFSet and OFCountedSet. check-in: 8d5ca84bc5 user: js tags: trunk
14:25
Throw an OFInvalidArgumentException if serialization can't be parsed. check-in: 8d3b009af1 user: js tags: trunk
2011-08-31
20:16
Don't install headers for implementations in Xcode project. check-in: abad97e74c user: js tags: trunk
Changes

Modified src/OFString+Serialization.m from [9bfc5b2d3f] to [a5b47627ae].

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

Modified src/exceptions/OFInvalidArgumentException.m from [2aae04b428] to [6c8188e145].

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"The argument for method %s of class %@ is invalid!",
	    sel_getName(selector), inClass];

	return description;
}

- (SEL)selector
{







|







51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"The argument or receiver for method %s of class %@ is invalid!",
	    sel_getName(selector), inClass];

	return description;
}

- (SEL)selector
{