ObjXMPP  Diff

Differences From Artifact [f859e69a55]:

To Artifact [0ded529f90]:


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
87
88
89
90
91
92
93
94
- initWithFile: (OFString*)file_
{
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [OFAutoreleasePool new];

		file = [file_ copy];
		@try {
			data = [[[OFString stringWithContentsOfFile:
			    file] JSONValue] retain];
		} @catch (id e) {
			data = [OFMutableDictionary new];
		}

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[file release];
	[data release];

	[super dealloc];
}

- (void)save
{
	[[data JSONRepresentation] writeToFile: file];
}

- (void)XMPP_setObject: (id)object
	       forPath: (OFString*)path
{
	OFArray *pathComponents = [path componentsSeparatedByString: @"."];
	OFMutableDictionary *iter = data;
	OFEnumerator *enumerator = [pathComponents objectEnumerator];
	OFString *component;
	size_t i = 0, components = [pathComponents count];

	while ((component = [enumerator nextObject]) != nil) {
		if (i++ == components - 1)
			continue;







|

|
|

|













|
|






|






|







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
87
88
89
90
91
92
93
94
- initWithFile: (OFString*)file_
{
	self = [super init];

	@try {
		OFAutoreleasePool *pool = [OFAutoreleasePool new];

		_file = [file_ copy];
		@try {
			_data = [[[OFString stringWithContentsOfFile:
			    _file] JSONValue] retain];
		} @catch (id e) {
			_data = [OFMutableDictionary new];
		}

		[pool release];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_file release];
	[_data release];

	[super dealloc];
}

- (void)save
{
	[[_data JSONRepresentation] writeToFile: _file];
}

- (void)XMPP_setObject: (id)object
	       forPath: (OFString*)path
{
	OFArray *pathComponents = [path componentsSeparatedByString: @"."];
	OFMutableDictionary *iter = _data;
	OFEnumerator *enumerator = [pathComponents objectEnumerator];
	OFString *component;
	size_t i = 0, components = [pathComponents count];

	while ((component = [enumerator nextObject]) != nil) {
		if (i++ == components - 1)
			continue;
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
}

- (id)XMPP_objectForPath: (OFString*)path
{
	OFArray *pathComponents = [path componentsSeparatedByString: @"."];
	OFEnumerator *enumerator = [pathComponents objectEnumerator];
	OFString *component;
	id object = data;

	while ((component = [enumerator nextObject]) != nil)
		object = [object objectForKey: component];

	return object;
}








|







112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
}

- (id)XMPP_objectForPath: (OFString*)path
{
	OFArray *pathComponents = [path componentsSeparatedByString: @"."];
	OFEnumerator *enumerator = [pathComponents objectEnumerator];
	OFString *component;
	id object = _data;

	while ((component = [enumerator nextObject]) != nil)
		object = [object objectForKey: component];

	return object;
}