Overview
Context
Changes
Modified src/Makefile
from [c065590079]
to [5b39d3317f].
︙ | | |
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
+
|
OFConstString.m \
OFDictionary.m \
OFExceptions.m \
OFFile.m \
OFHashes.m \
OFIterator.m \
OFList.m \
OFMutableString.m \
OFNumber.m \
OFObject.m \
${OFPLUGIN_M} \
OFStream.m \
OFString.m \
OFTCPSocket.m \
OFThread.m \
|
︙ | | |
Modified src/OFConstString.h
from [b313df5022]
to [1e291d5edd].
1
2
3
4
5
6
7
8
9
10
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008 - 2009
* 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 "OFObject.h"
#import "OFString.h"
#ifndef __objc_INCLUDE_GNU
#import <objc/runtime.h>
extern void *_OFConstStringClassReference;
#endif
/**
* A class for storing static strings using the @"" literal.
*/
@interface OFConstString: OFObject
@interface OFConstString: OFString {}
{
char *string;
#ifdef __objc_INCLUDE_GNU
unsigned int length;
#else
int length;
#if __LP64__
int _unused;
#endif
#endif
}
/**
* \return The OFString as a C string
*/
- (const char*)cString;
/**
* \return The length of the OFString
*/
- (size_t)length;
/**
* Compares the OFString to another object.
*
* \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;
@end
|
Modified src/OFConstString.m
from [4dca2f32e1]
to [382b8cbac7].
1
2
3
4
5
6
7
8
9
10
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
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
|
1
2
3
4
5
6
7
8
9
10
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
|
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
* Copyright (c) 2008 - 2009
* 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 <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#import "OFConstString.h"
#import "OFString.h"
#import "OFExceptions.h"
#import "OFMacros.h"
#ifndef __objc_INCLUDE_GNU
void *_OFConstStringClassReference;
#endif
@implementation OFConstString
#ifndef __objc_INCLUDE_GNU
+ (void)load
{
objc_setFutureClass((Class)&_OFConstStringClassReference,
"OFConstString");
}
#endif
- (const char*)cString
{
return string;
}
- (size_t)length
{
return length;
}
- (BOOL)isEqual: (id)obj
{
if (![obj isKindOf: [OFString class]] &&
![obj isKindOf: [OFConstString class]])
return NO;
if (strcmp(string, [obj cString]))
return NO;
return YES;
}
- (int)compare: (id)obj
{
if (![obj isKindOf: [OFString class]] &&
![obj isKindOf: [OFConstString class]])
@throw [OFInvalidArgumentException newWithClass: isa];
return strcmp(string, [obj cString]);
}
- (uint32_t)hash
{
uint32_t hash;
size_t i;
OF_HASH_INIT(hash);
for (i = 0; i < length; i++)
OF_HASH_ADD(hash, string[i]);
OF_HASH_FINALIZE(hash);
return hash;
}
- retain
{
return self;
}
- release
{
|
︙ | | |
Added src/OFMutableString.h version [ed681a0579].
|
1
2
3
4
5
6
7
8
9
10
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
/*
* Copyright (c) 2008 - 2009
* 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.
*/
#include <stdio.h>
#include <stdarg.h>
#import "OFString.h"
/**
* A class for storing and modifying strings.
*/
@interface OFMutableString: OFString
{
BOOL is_utf8;
}
/**
* Initializes an already allocated OFString.
*
* \return An initialized OFString
*/
- init;
/**
* Initializes an already allocated OFString from a C string.
*
* \param str A C string to initialize the OFString with
* \return An initialized OFString
*/
- initWithCString: (const char*)str;
/**
* Initializes an already allocated OFString from a format C string.
* See printf for the format syntax.
*
* \param fmt A C string used as format to initialize the OFString
* \return An initialized OFString
*/
- initWithFormat: (const char*)fmt, ...;
/**
* Initializes an already allocated OFString from a format C string.
* See printf for the format syntax.
*
* \param fmt A C string used as format to initialize the OFString
* \param args The arguments used in the format string
* \return An initialized OFString
*/
- initWithFormat: (const char*)fmt
andArguments: (va_list)args;
@end
|
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
Added src/OFMutableString.m version [d47bbbd95a].