ObjFW  Check-in [7b15048e25]

Overview
Comment:Move length from base string class to subclasses & others.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7b15048e25db728d33ac77408134d1b28a7b5538fdfe19762c22fd62cc91bb55
User & Date: js on 2008-10-11 20:26:22
Other Links: manifest | tags
Context
2008-10-22
13:32
Reworked OFObject and added append(Wide)CString to OFString. check-in: e47ad44290 user: js tags: trunk
2008-10-11
20:26
Move length from base string class to subclasses & others. check-in: 7b15048e25 user: js tags: trunk
2008-10-09
00:25
Multiple changes, see details. check-in: 7a49441656 user: js tags: trunk
Changes

Modified src/OFCString.h from [6da69d89f7] to [2b50f5bd43].

13
14
15
16
17
18
19

20
21
22
23

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







+




+





#import "OFObject.h"
#import "OFString.h"

@interface OFCString: OFString
{
	char   *string;
	size_t length;
}

- initWithCString: (char*)str;
- (char*)cString;
- (size_t)length;
- (OFString*)clone;
- (int)compareTo: (OFString*)str;
- (OFString*)append: (OFString*)str;
@end

Modified src/OFCString.m from [7d58812826] to [28eeb45980].

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







-
+


















+
+
+
+
+







#import <stdlib.h>
#import <string.h>

#import "OFCString.h"
#import "OFExceptions.h"

@implementation OFCString
- initWithCString: (const char*)str
- initWithCString: (char*)str
{
	if ((self = [super init])) {
		if (str == NULL) {
			length = 0;
			string = NULL;
		} else {
			length = strlen(str);
			string = [self getMemWithSize: length + 1];
			memcpy(string, str, length + 1);
		}
	}
	return self;
}

- (char*)cString
{
	return string;
}

- (size_t)length
{
	return length;
}

- (OFString*)clone
{
	return [OFString newWithCString: string];
}

- (int)compareTo: (OFString*)str

Modified src/OFConstCString.h from [275b3732d6] to [7223dd66b9].

10
11
12
13
14
15
16

17
18
19
20

21
22
23
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25







+




+



 */

#import "OFString.h"

@interface OFConstCString: OFString
{
	const char *string;
	size_t	   length;
}

- initWithConstCString: (const char*)str;
- (const char*)cString;
- (size_t)length;
- (OFString*)clone;
- (int)compareTo: (OFString*)str;
@end

Modified src/OFConstCString.m from [35f5f8dc91] to [1ea6deb553].

29
30
31
32
33
34
35





36
37
38
39
40
41
42
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47







+
+
+
+
+







	return self;
}

- (const char*)cString
{
	return string;
}

- (size_t)length
{
	return length;
}

- (OFString*)clone
{
	return [OFString newWithConstCString: string];
}

- (int)compareTo: (OFString*)str

Modified src/OFConstWideCString.h from [47a8761c52] to [bd14aa93b8].

12
13
14
15
16
17
18

19
20
21
22

23
24
25
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27







+




+



#import <wchar.h>
#import <stddef.h>
#import "OFString.h"

@interface OFConstWideCString: OFString
{
	const wchar_t *string;
	size_t	      length;
}

- initWithConstWideCString: (const wchar_t*)wstr;
- (const wchar_t*)wcString;
- (size_t)length;
- (OFString*)clone;
- (int)compareTo: (OFString*)str;
@end

Modified src/OFConstWideCString.m from [eee891da1e] to [d6f7c115da].

29
30
31
32
33
34
35





36
37
38
39
40
41
42
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47







+
+
+
+
+







	return self;
}

- (const wchar_t*)wcString
{
	return string;
}

- (size_t)length
{
	return length;
}

- (OFString*)clone
{
	return [OFString newWithConstWideCString: string];
}

- (int)compareTo: (OFString*)str

Modified src/OFExceptions.m from [bb044cd27c] to [36864f42d3].

1
2
3
4
5
6
7
8
9
10
11
12


13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21












+
+







/*
 * Copyright (c) 2008
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of libobjfw. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE included in
 * the packaging of this file.
 */

#import "config.h"

#import <objc/objc-api.h>

#import <stdio.h>
#import <stdlib.h>

#import "OFExceptions.h"

#if defined HAVE_SEL_GET_NAME

Modified src/OFString.h from [6806a7a1f1] to [f6f06366e5].

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
10
11
12
13
14
15
16




17
18
19
20
21
22
23







-
-
-
-







 */

#import <wchar.h>
#import <stddef.h>
#import "OFObject.h"

@interface OFString: OFObject
{
	size_t length;
}

+ newWithConstCString: (const char*)str;
+ newWithConstWideCString: (const wchar_t*)str;
+ newWithCString: (char*)str;
+ newWithWideCString: (wchar_t*)str;

- (char*)cString;
- (wchar_t*)wcString;

Modified src/OFString.m from [595a703a5e] to [bf98b3db86].

54
55
56
57
58
59
60


61

62
63
64
65
66
67
68
54
55
56
57
58
59
60
61
62

63
64
65
66
67
68
69
70







+
+
-
+







	[[OFNotImplementedException newWithObject: self
				      andSelector: @selector(wcString)] raise];
	return NULL;
}

- (size_t)length
{
	[[OFNotImplementedException newWithObject: self
				      andSelector: @selector(length)] raise];
	return length;
	return 0;
}

- (OFString*)setTo: (OFString*)str
{
	[self free];
	self = [str clone];
	return self;

Modified src/OFWideCString.h from [3956b2854d] to [c68b96f11d].

13
14
15
16
17
18
19

20
21
22
23

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







+




+




#import <stddef.h>

#import "OFString.h"

@interface OFWideCString: OFString
{
	wchar_t	*string;
	size_t  length;
}

- initWithWideCString: (wchar_t*)str;
- (wchar_t*)wcString;
- (size_t)length;
- (OFString*)clone;
- (int)compareTo: (OFString*)str;
- (OFString*)append: (OFString*)str;
@end

Modified src/OFWideCString.m from [a475d7a419] to [9dbc23240b].

35
36
37
38
39
40
41





42
43
44
45
46
47
48
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53







+
+
+
+
+







	return self;
}

- (wchar_t*)wcString
{
	return string;
}

- (size_t)length
{
	return length;
}

- (OFString*)clone
{
	return [OFString newWithWideCString: string];
}

- (int)compareTo: (OFString*)str