ObjFW  Check-in [41974cf38d]

Overview
Comment:Move documentation of mutating methods.
Mutating methods are now documented in the mutable class.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 41974cf38d53b6788650085de007fa05ed77a1dd6135207bf52b7e6c6c81325b
User & Date: js on 2009-06-09 20:10:52
Other Links: manifest | tags
Context
2009-06-09
20:44
Make OFSocket a class cluster. check-in: f847f82b75 user: js tags: trunk
20:10
Move documentation of mutating methods.
Mutating methods are now documented in the mutable class.
check-in: 41974cf38d user: js tags: trunk
17:19
Rename ERROR to SYNC_ERR in objc_sync.m to prevent conflicts. check-in: e58b9661a5 user: js tags: trunk
Changes

Modified src/OFArray.h from [ac035c3b46] to [51f96ac011].

98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
- (id)objectAtIndex: (size_t)index;

/**
 * \return The last object of the OFDataArray
 */
- (id)lastObject;

/**
 * Adds an object to the OFDataArray.
 *
 * \param obj An object to add
 */
- addObject: (OFObject*)obj;

/**
 * Removes the specified amount of object from the end of the OFDataArray.
 *
 * \param nobjects The number of objects to remove
 */
- removeNObjects: (size_t)nobjects;
@end

#import "OFMutableArray.h"







<
<
<
<
<

<
<
<
<
<
<




98
99
100
101
102
103
104





105






106
107
108
109
- (id)objectAtIndex: (size_t)index;

/**
 * \return The last object of the OFDataArray
 */
- (id)lastObject;






- addObject: (OFObject*)obj;






- removeNObjects: (size_t)nobjects;
@end

#import "OFMutableArray.h"

Modified src/OFArray.m from [7d64d3ae66] to [37a3e697c0].

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231












232
	for (i = 0; i < len; i++)
		if (![objs[i] isEqual: objs2[i]])
			return NO;

	return YES;
}

- addObject: (OFObject*)obj
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- removeNObjects: (size_t)nobjects
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- (void)dealloc
{
	OFObject **objs;
	size_t len, i;

	if (array != nil) {
		objs = [array data];
		len = [array count];

		for (i = 0; i < len; i++)
			[objs[i] release];

		[array release];
	}

	[super dealloc];
}












@end







<
<
<
<
<
<
<
<
<
<
<
<

















>
>
>
>
>
>
>
>
>
>
>
>

196
197
198
199
200
201
202












203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
	for (i = 0; i < len; i++)
		if (![objs[i] isEqual: objs2[i]])
			return NO;

	return YES;
}













- (void)dealloc
{
	OFObject **objs;
	size_t len, i;

	if (array != nil) {
		objs = [array data];
		len = [array count];

		for (i = 0; i < len; i++)
			[objs[i] release];

		[array release];
	}

	[super dealloc];
}

- addObject: (OFObject*)obj
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- removeNObjects: (size_t)nobjects
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}
@end

Modified src/OFDictionary.h from [12bb9cf14f] to [c2a0d12c52].

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

/**
 * \param key The key whose object should be returned
 * \return The object for the given key or nil if the key was not found
 */
- (id)objectForKey: (OFObject*)key;

/**
 * Sets a key to an object. A key can be any object.
 *
 * \param key The key to set
 * \param obj The object to set the key to
 */
- setObject: (OFObject*)obj
     forKey: (OFObject <OFCopying>*)key;

/**
 * Remove the object with the given key from the dictionary.
 *
 * \param key The key whose object should be removed
 */
- removeObjectForKey: (OFObject*)key;

/**
 * Changes the hash size of the dictionary.
 *
 * \param hashsize The new hash size for the dictionary
 */
- changeHashSize: (int)hashsize;
@end

#import "OFIterator.h"
#import "OFMutableDictionary.h"







<
<
<
<
<
<


<
<
<
<
<
<

<
<
<
<
<
<





132
133
134
135
136
137
138






139
140






141






142
143
144
145
146

/**
 * \param key The key whose object should be returned
 * \return The object for the given key or nil if the key was not found
 */
- (id)objectForKey: (OFObject*)key;







- setObject: (OFObject*)obj
     forKey: (OFObject <OFCopying>*)key;






- removeObjectForKey: (OFObject*)key;






- changeHashSize: (int)hashsize;
@end

#import "OFIterator.h"
#import "OFMutableDictionary.h"

Modified src/OFDictionary.m from [2b0ed74966] to [01f5ecb4a1].

332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
	for (iter = [data[hash] first]; iter != NULL; iter = iter->next->next)
		if ([iter->object isEqual: key])
			return iter->next->object;

	return nil;
}

- setObject: (OFObject*)obj
     forKey: (OFObject <OFCopying>*)key
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- removeObjectForKey: (OFObject*)key
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- changeHashSize: (int)hashsize
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

/* FIXME: Implement this! */
/*
- (BOOL)isEqual
{
}

- (id)copy







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







332
333
334
335
336
337
338



















339
340
341
342
343
344
345
	for (iter = [data[hash] first]; iter != NULL; iter = iter->next->next)
		if ([iter->object isEqual: key])
			return iter->next->object;

	return nil;
}




















/* FIXME: Implement this! */
/*
- (BOOL)isEqual
{
}

- (id)copy
376
377
378
379
380
381
382



















383

	for (i = 0; i < size; i++)
		if (data[i] != nil)
			[data[i] release];

	[super dealloc];
}



















@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383

	for (i = 0; i < size; i++)
		if (data[i] != nil)
			[data[i] release];

	[super dealloc];
}

- setObject: (OFObject*)obj
     forKey: (OFObject <OFCopying>*)key
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- removeObjectForKey: (OFObject*)key
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- changeHashSize: (int)hashsize
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}
@end

Modified src/OFMutableArray.h from [521f11b9ef] to [f3a9e17092].

12
13
14
15
16
17
18













19
#import "OFArray.h"

/**
 * The OFMutableArray class provides a class for storing, adding and removing
 * objects in an array.
 */
@interface OFMutableArray: OFArray













@end







>
>
>
>
>
>
>
>
>
>
>
>
>

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#import "OFArray.h"

/**
 * The OFMutableArray class provides a class for storing, adding and removing
 * objects in an array.
 */
@interface OFMutableArray: OFArray
/**
 * Adds an object to the OFDataArray.
 *
 * \param obj An object to add
 */
- addObject: (OFObject*)obj;

/**
 * Removes the specified amount of objects from the end of the OFDataArray.
 *
 * \param nobjects The number of objects to remove
 */
- removeNObjects: (size_t)nobjects;
@end

Modified src/OFMutableDictionary.h from [457d6af9f3] to [b962c4babf].

11
12
13
14
15
16
17






















18

#import "OFDictionary.h"

/**
 * The OFMutableDictionary class provides a class for using mutable hash tables.
 */
@interface OFMutableDictionary: OFDictionary






















@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

#import "OFDictionary.h"

/**
 * The OFMutableDictionary class provides a class for using mutable hash tables.
 */
@interface OFMutableDictionary: OFDictionary
/**
 * Sets a key to an object. A key can be any object.
 *
 * \param key The key to set
 * \param obj The object to set the key to
 */
- setObject: (OFObject*)obj
     forKey: (OFObject <OFCopying>*)key;

/**
 * Remove the object with the given key from the dictionary.
 *
 * \param key The key whose object should be removed
 */
- removeObjectForKey: (OFObject*)key;

/**
 * Changes the hash size of the dictionary.
 *
 * \param hashsize The new hash size for the dictionary
 */
- changeHashSize: (int)hashsize;
@end

Modified src/OFMutableString.h from [50d5f8f8b9] to [4823c3305e].

14
15
16
17
18
19
20













































































21

#import "OFString.h"

/**
 * A class for storing and modifying strings.
 */
@interface OFMutableString: OFString













































































@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

14
15
16
17
18
19
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
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
95
96
97
98

#import "OFString.h"

/**
 * A class for storing and modifying strings.
 */
@interface OFMutableString: OFString
/**
 * Sets the OFString to the specified OFString.
 *
 * \param str An OFString to set the OFString to.
 */
- setToCString: (const char*)str;

/**
 * Appends another OFString to the OFString.
 *
 * \param str An OFString to append
 */
- append: (OFString*)str;

/**
 * Appends a C string to the OFString.
 *
 * \param str A C string to append
 */
- appendCString: (const char*)str;

/**
 * Appends a formatted C string to the OFString.
 * See printf for the format syntax.
 *
 * \param fmt A format string which generates the string to append
 */
- appendWithFormat: (OFString*)fmt, ...;

/**
 * Appends a formatted C string to the OFString.
 * See printf for the format syntax.
 *
 * \param fmt A format string which generates the string to append
 * \param args The arguments used in the format string
 */
- appendWithFormat: (OFString*)fmt
      andArguments: (va_list)args;

/**
 * Reverse the OFString.
 */
- reverse;

/**
 * Upper the OFString.
 */
- upper;

/**
 * Lower the OFString.
 */
- lower;

/**
 * Replaces all occurrences of a string with another string.
 *
 * \param str The string to replace
 * \param repl The string with which it should be replaced
 */
- replaceOccurrencesOfString: (OFString*)str
		  withString: (OFString*)repl;

/**
 * Removes all whitespaces at the beginning of a string.
 */
- removeLeadingWhitespaces;

/**
 * Removes all whitespaces at the end of a string.
 */
- removeTrailingWhitespaces;

/**
 * Removes all whitespaces at the beginning and the end of a string.
 */
- removeLeadingAndTrailingWhitespaces;
@end

Modified src/OFString.h from [444a655483] to [0a39997d8c].

122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213















214
215
216
217
218
 *
 * \param obj An object to compare with
 * \return An integer which is the result of the comparison, see for example
 *	   strcmp
 */
- (int)compare: (id)obj;

/**
 * Sets the OFString to the specified OFString.
 *
 * \param str An OFString to set the OFString to.
 */
- setToCString: (const char*)str;

/**
 * Appends another OFString to the OFString.
 *
 * \param str An OFString to append
 */
- append: (OFString*)str;

/**
 * Appends a C string to the OFString.
 *
 * \param str A C string to append
 */
- appendCString: (const char*)str;

/**
 * Appends a formatted C string to the OFString.
 * See printf for the format syntax.
 *
 * \param fmt A format string which generates the string to append
 */
- appendWithFormat: (OFString*)fmt, ...;

/**
 * Appends a formatted C string to the OFString.
 * See printf for the format syntax.
 *
 * \param fmt A format string which generates the string to append
 * \param args The arguments used in the format string
 */
- appendWithFormat: (OFString*)fmt
      andArguments: (va_list)args;

/**
 * Reverse the OFString.
 */
- reverse;

/**
 * Upper the OFString.
 */
- upper;

/**
 * Lower the OFString.
 */
- lower;

/**
 * Replaces all occurrences of a string with another string.
 *
 * \param str The string to replace
 * \param repl The string with which it should be replaced
 */
- replaceOccurrencesOfString: (OFString*)str
		  withString: (OFString*)repl;

/**
 * Removes all whitespaces at the beginning of a string.
 */
- removeLeadingWhitespaces;

/**
 * Removes all whitespaces at the end of a string.
 */
- removeTrailingWhitespaces;

/**
 * Removes all whitespaces at the beginning and the end of a string.
 */
- removeLeadingAndTrailingWhitespaces;

/**
 * Splits an OFString into an OFArray of OFStrings.
 *
 * \param delimiter The delimiter for splitting
 * \return An autoreleased OFArray with the splitted string
 */
- (OFArray*)splitWithDelimiter: (OFString*)delimiter;















@end

#import "OFConstString.h"
#import "OFMutableString.h"
#import "OFURLEncoding.h"







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





122
123
124
125
126
127
128














































































129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
 *
 * \param obj An object to compare with
 * \return An integer which is the result of the comparison, see for example
 *	   strcmp
 */
- (int)compare: (id)obj;















































































/**
 * Splits an OFString into an OFArray of OFStrings.
 *
 * \param delimiter The delimiter for splitting
 * \return An autoreleased OFArray with the splitted string
 */
- (OFArray*)splitWithDelimiter: (OFString*)delimiter;

- setToCString: (const char*)str;
- append: (OFString*)str;
- appendCString: (const char*)str;
- appendWithFormat: (OFString*)fmt, ...;
- appendWithFormat: (OFString*)fmt
      andArguments: (va_list)args;
- reverse;
- upper;
- lower;
- replaceOccurrencesOfString: (OFString*)str
		  withString: (OFString*)repl;
- removeLeadingWhitespaces;
- removeTrailingWhitespaces;
- removeLeadingAndTrailingWhitespaces;
@end

#import "OFConstString.h"
#import "OFMutableString.h"
#import "OFURLEncoding.h"

Modified src/OFString.m from [24b458f3b5] to [5d82d403f3].

304
305
306
307
308
309
310


























































311
312
313
314
315
316
317
	OF_HASH_INIT(hash);
	for (i = 0; i < length; i++)
		OF_HASH_ADD(hash, string[i]);
	OF_HASH_FINALIZE(hash);

	return hash;
}



























































- setToCString: (const char*)str
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
	OF_HASH_INIT(hash);
	for (i = 0; i < length; i++)
		OF_HASH_ADD(hash, string[i]);
	OF_HASH_FINALIZE(hash);

	return hash;
}

- (OFArray*)splitWithDelimiter: (OFString*)delimiter
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFArray *array = nil;
	OFString *str;
	const char *delim = [delimiter cString];
	size_t delim_len = [delimiter length];
	size_t i, last;

	array = [OFMutableArray array];

	if (delim_len > length) {
		str = [[self copy] autorelease];
		[array addObject: str];

		[array retain];
		[pool release];

		return array;
	}

	for (i = 0, last = 0; i <= length - delim_len; i++) {
		char *tmp;

		if (memcmp(string + i, delim, delim_len))
			continue;

		/*
		 * We can't use [self allocMemoryWithSize:] here as self might
		 * be a @""-literal.
		 */
		if ((tmp = malloc(i - last + 1)) == NULL)
			@throw [OFOutOfMemoryException
			    newWithClass: isa
				 andSize: i - last + 1];
		memcpy(tmp, string + last, i - last);
		tmp[i - last] = '\0';
		@try {
			str = [OFString stringWithCString: tmp];
		} @finally {
			free(tmp);
		}

		[array addObject: str];
		[array retain];
		[pool releaseObjects];

		i += delim_len - 1;
		last = i + 1;
	}
	[array addObject: [OFString stringWithCString: string + last]];

	[array retain];
	[pool release];

	return array;
}

- setToCString: (const char*)str
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
}

- removeLeadingAndTrailingWhitespaces
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}

- (OFArray*)splitWithDelimiter: (OFString*)delimiter
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFArray *array = nil;
	OFString *str;
	const char *delim = [delimiter cString];
	size_t delim_len = [delimiter length];
	size_t i, last;

	array = [OFMutableArray array];

	if (delim_len > length) {
		str = [[self copy] autorelease];
		[array addObject: str];

		[array retain];
		[pool release];

		return array;
	}

	for (i = 0, last = 0; i <= length - delim_len; i++) {
		char *tmp;

		if (memcmp(string + i, delim, delim_len))
			continue;

		/*
		 * We can't use [self allocMemoryWithSize:] here as self might
		 * be a @""-literal.
		 */
		if ((tmp = malloc(i - last + 1)) == NULL)
			@throw [OFOutOfMemoryException
			    newWithClass: isa
				 andSize: i - last + 1];
		memcpy(tmp, string + last, i - last);
		tmp[i - last] = '\0';
		@try {
			str = [OFString stringWithCString: tmp];
		} @finally {
			free(tmp);
		}

		[array addObject: str];
		[array retain];
		[pool releaseObjects];

		i += delim_len - 1;
		last = i + 1;
	}
	[array addObject: [OFString stringWithCString: string + last]];

	[array retain];
	[pool release];

	return array;
}
@end







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

436
437
438
439
440
441
442


























































443
}

- removeLeadingAndTrailingWhitespaces
{
	@throw [OFNotImplementedException newWithClass: isa
					   andSelector: _cmd];
}


























































@end