ObjFW  Check-in [a7bed8325c]

Overview
Comment:Add of_range_t and add methods taking an of_range_t.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: a7bed8325c1046e6b59d38cf0cfeb4c06109d1914cc4014b432ca680630bb779
User & Date: js on 2010-02-11 14:05:15
Other Links: manifest | tags
Context
2010-02-11
14:58
Documentation improvements. check-in: 72caeab860 user: js tags: trunk
14:05
Add of_range_t and add methods taking an of_range_t. check-in: a7bed8325c user: js tags: trunk
2010-02-10
20:30
Documentation improvements. check-in: 6a65366467 user: js tags: trunk
Changes

Modified src/OFMutableString.h from [cbc1131fbc] to [f11024a606].

111
112
113
114
115
116
117







118
119
120
121
122
123
124
 * \param start The index where the deletion should be started
 * \param end The index until which the characters should be deleted.
 *	      This points BEHIND the last character!
 */
- removeCharactersFromIndex: (size_t)start
		    toIndex: (size_t)end;








/**
 * 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







>
>
>
>
>
>
>







111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 * \param start The index where the deletion should be started
 * \param end The index until which the characters should be deleted.
 *	      This points BEHIND the last character!
 */
- removeCharactersFromIndex: (size_t)start
		    toIndex: (size_t)end;

/**
 * Removes the characters at the specified range.
 *
 * \param range The range of the characters which should be removed
 */
- removeCharactersInRange: (of_range_t)range;

/**
 * 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

Modified src/OFMutableString.m from [ca1764da14] to [9cfb356b64].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#ifdef HAVE_MADVISE
#include <sys/mman.h>
#else
#define madvise(addr, len, advise)
#endif

#import "OFString.h"
#import "OFExceptions.h"
#import "macros.h"

#import "asprintf.h"







|

|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#ifdef HAVE_MADVISE
# include <sys/mman.h>
#else
# define madvise(addr, len, advise)
#endif

#import "OFString.h"
#import "OFExceptions.h"
#import "macros.h"

#import "asprintf.h"
405
406
407
408
409
410
411






412
413
414
415
416
417
418
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e dealloc];
	}

	return self;
}







- replaceOccurrencesOfString: (OFString*)str
		  withString: (OFString*)repl
{
	const char *str_c = [str cString];
	const char *repl_c = [repl cString];
	size_t str_len = [str cStringLength];







>
>
>
>
>
>







405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
	} @catch (OFOutOfMemoryException *e) {
		/* We don't really care, as we only made it smaller */
		[e dealloc];
	}

	return self;
}

- removeCharactersInRange: (of_range_t)range
{
	return [self removeCharactersFromIndex: range.start
				       toIndex: range.start + range.length];
}

- replaceOccurrencesOfString: (OFString*)str
		  withString: (OFString*)repl
{
	const char *str_c = [str cString];
	const char *repl_c = [repl cString];
	size_t str_len = [str cStringLength];

Modified src/OFObject.h from [e2a29ab486] to [db793b12be].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30








31
32
33
34
35
36
37
#include <stdint.h>

#import <objc/objc.h>

/**
 * A result of a comparison.
 */
typedef enum {
	/// The left object is smaller than the right
	OF_ORDERED_ASCENDING = -1,
	/// Both objects are equal
	OF_ORDERED_SAME = 0,
	/// The left object is bigger than the right
	OF_ORDERED_DESCENDING = 1
} of_comparison_result_t;









/**
 * The OFObject class is the base class for all other classes inside ObjFW.
 */
@interface OFObject
{
	/// The class of the object
	Class isa;







|








>
>
>
>
>
>
>
>







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
#include <stdint.h>

#import <objc/objc.h>

/**
 * A result of a comparison.
 */
typedef enum __of_comparison_result {
	/// The left object is smaller than the right
	OF_ORDERED_ASCENDING = -1,
	/// Both objects are equal
	OF_ORDERED_SAME = 0,
	/// The left object is bigger than the right
	OF_ORDERED_DESCENDING = 1
} of_comparison_result_t;

/**
 * A range.
 */
typedef struct __of_range {
	size_t start;
	size_t length;
} of_range_t;

/**
 * The OFObject class is the base class for all other classes inside ObjFW.
 */
@interface OFObject
{
	/// The class of the object
	Class isa;

Modified src/OFString.h from [24fcd165e3] to [d23b48aa76].

242
243
244
245
246
247
248






249
250
251
252
253
254
255
 * \param end The index where the substring ends.
 *	      This points BEHIND the last character!
 * \return The substring as a new autoreleased OFString
 */
- (OFString*)substringFromIndex: (size_t)start
			toIndex: (size_t)end;







/**
 * Creates a new string by appending another string.
 *
 * \param str The string to append
 * \return A new autoreleased OFString with the specified string appended
 */
- (OFString*)stringByAppendingString: (OFString*)str;







>
>
>
>
>
>







242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
 * \param end The index where the substring ends.
 *	      This points BEHIND the last character!
 * \return The substring as a new autoreleased OFString
 */
- (OFString*)substringFromIndex: (size_t)start
			toIndex: (size_t)end;

/**
 * \param range The range of the substring
 * \return The substring as a new autoreleased OFString
 */
- (OFString*)substringWithRange: (of_range_t)range;

/**
 * Creates a new string by appending another string.
 *
 * \param str The string to append
 * \return A new autoreleased OFString with the specified string appended
 */
- (OFString*)stringByAppendingString: (OFString*)str;

Modified src/OFString.m from [a8326e5274] to [d1ca63d71a].

733
734
735
736
737
738
739






740
741
742
743
744
745
746

	if (end > length)
		@throw [OFOutOfRangeException newWithClass: isa];

	return [OFString stringWithCString: string + start
				    length: end - start];
}







- (OFString*)stringByAppendingString: (OFString*)str
{
	return [[OFMutableString stringWithString: self] appendString: str];
}

- (BOOL)hasPrefix: (OFString*)prefix







>
>
>
>
>
>







733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752

	if (end > length)
		@throw [OFOutOfRangeException newWithClass: isa];

	return [OFString stringWithCString: string + start
				    length: end - start];
}

- (OFString*)substringWithRange: (of_range_t)range
{
	return [self substringFromIndex: range.start
				toIndex: range.start + range.length];
}

- (OFString*)stringByAppendingString: (OFString*)str
{
	return [[OFMutableString stringWithString: self] appendString: str];
}

- (BOOL)hasPrefix: (OFString*)prefix