Overview
Comment: | Add OFWideString and OFConstWideString. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
1fe9cb366edef657efbe699a40e1b240 |
User & Date: | js on 2008-09-14 12:53:25 |
Other Links: | manifest | tags |
Context
2008-09-14
| ||
15:12 | Fix a bug in OFWideString and add test for OFWideString. check-in: b4ead4bdd2 user: js tags: trunk | |
12:53 | Add OFWideString and OFConstWideString. check-in: 1fe9cb366e user: js tags: trunk | |
2008-09-12
| ||
18:26 | Add OFConstString. check-in: a566e7bb03 user: js tags: trunk | |
Changes
Modified src/Makefile from [b48a2876b6] to [4590acbe8d].
1 2 3 4 | LIB = ${LIB_PREFIX}objfw${LIB_SUFFIX} LIB_MAJOR = 1 LIB_MINOR = 0 | | > | | | | > > | > | 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 | LIB = ${LIB_PREFIX}objfw${LIB_SUFFIX} LIB_MAJOR = 1 LIB_MINOR = 0 SRCS = OFConstString.m \ OFConstWideString.m \ OFList.m \ OFListObject.m \ OFObject.m \ OFString.m \ OFWideString.m OBJCFLAGS += -fPIC -DPIC -fno-nil-recivers -fconstant-string-class=OFConstString INCLUDES = OFConstString.h \ OFConstWideString.h \ OFList.h \ OFListObject.h \ OFObject.h \ OFString.h \ OFWideString.h include ../buildsys.mk LD = ${OBJC} LIBS += -lobjc |
Modified src/OFConstString.m from [f25f4f5f15] to [8c3560516b].
1 2 3 4 5 6 7 8 9 10 11 | /* * 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. */ | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /* * 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 <string.h> #import "OFConstString.h" @implementation OFConstString + new:(const char*)str { return [[OFConstString alloc] init:str]; |
︙ | ︙ | |||
27 28 29 30 31 32 33 | - init:(const char*)str { if ((self = [super init])) { if (str == NULL) { length = 0; string = NULL; } else { | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - init:(const char*)str { if ((self = [super init])) { if (str == NULL) { length = 0; string = NULL; } else { length = strlen(str); string = str; } } return self; } - (const char*)cString |
︙ | ︙ |
Added src/OFConstWideString.h version [30aab21810].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * 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 <stddef.h> #import <wchar.h> #import "OFObject.h" @interface OFConstWideString: OFObject { const wchar_t *wstring; size_t length; } + new:(const wchar_t*)wstr; - init; - init:(const wchar_t*)wstr; - (const wchar_t*)wcString; - (size_t)length; @end /* vim: se syn=objc: */ |
Added src/OFConstWideString.m version [1ca10a0426].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * 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 <wchar.h> #import "OFConstWideString.h" @implementation OFConstWideString + new:(const wchar_t*)wstr { return [[OFConstWideString alloc] init:wstr]; } - init { return [self init:NULL]; } - init:(const wchar_t*)wstr { if ((self = [super init])) { if (wstr == NULL) { length = 0; wstring = NULL; } else { length = wcslen(wstr); wstring = wstr; } } return self; } - (const wchar_t*)wcString { return wstring; } - (size_t)length { return length; } @end |
Modified src/OFString.m from [ec546376b0] to [7b8481ed3a].
︙ | ︙ | |||
27 28 29 30 31 32 33 | - init:(const char*)str { if ((self = [super init])) { if (str == NULL) { length = 0; string = NULL; } else { | | | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | - init:(const char*)str { if ((self = [super init])) { if (str == NULL) { length = 0; string = NULL; } else { length = strlen(str); if ((string = [self getMem:length]) == NULL) return NULL; memcpy(string, str, length); } } return self; } |
︙ | ︙ | |||
76 77 78 79 80 81 82 | string = newstr; return self; } - (OFString*)clone { | < | < | | | | < | | | | | | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | string = newstr; return self; } - (OFString*)clone { return [OFString new:string]; } - (OFString*)append: (const char*)str { char *newstr; size_t newlen, strlength; if (str == NULL) return [self setTo:str]; strlength = strlen(str); newlen = length + strlength; if ((newstr = [self resizeMem:string toSize:newlen + 1]) == NULL) { /* FIXME: Add error handling */ return nil; } string = newstr; memcpy(string + length, str, strlength); string[newlen] = '\0'; length = newlen; return self; } @end |
Added src/OFWideString.h version [7d19c57893].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* * 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 <stddef.h> #import <wchar.h> #import "OFObject.h" @interface OFWideString: OFObject { wchar_t *wstring; size_t length; } + new:(const wchar_t*)wstr; - init; - init:(const wchar_t*)wstr; - (wchar_t*)wcString; - (size_t)length; - (OFWideString*)setTo:(const wchar_t*)wstr; - (OFWideString*)clone; - (OFWideString*)append:(const wchar_t*)wstr; @end /* vim: se syn=objc: */ |
Added src/OFWideString.m version [b821122f3b].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | /* * 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 <stdlib.h> #import <string.h> #import <wchar.h> #import "OFWideString.h" @implementation OFWideString + new:(const wchar_t*)wstr { return [[OFWideString alloc] init:wstr]; } - init { return [self init:NULL]; } - init:(const wchar_t*)wstr { if ((self = [super init])) { if (wstr == NULL) { length = 0; wstring = NULL; } else { length = wcslen(wstr); if ((wstring = [self getMem:length * sizeof(wchar_t)]) == NULL) return NULL; memcpy(wstring, wstr, length * sizeof(wchar_t)); } } return self; } - (wchar_t*)wcString { return wstring; } - (size_t)length { return length; } - (OFWideString*)setTo:(const wchar_t*)wstr { wchar_t *newstr; size_t newlen; if (wstr == NULL) { [self freeMem:wstring]; length = 0; wstring = NULL; return self; } newlen = wcslen(wstr); if ((newstr = [self getMem:newlen * sizeof(wchar_t)]) == NULL) return nil; memcpy(newstr, wstr, newlen * sizeof(wchar_t)); if (wstring != NULL) [self freeMem:wstring]; length = newlen; wstring = newstr; return self; } - (OFWideString*)clone { return [OFWideString new:wstring]; } - (OFWideString*)append: (const wchar_t*)wstr { wchar_t *newstr; size_t newlen, strlength; if (wstr == NULL) return [self setTo:wstr]; strlength = wcslen(wstr); newlen = length + strlength; if ((newstr = [self resizeMem:wstring toSize:(newlen + 1) * sizeof(wchar_t)]) == NULL) { /* FIXME: Add error handling */ return nil; } wstring = newstr; memcpy(wstring + length, wstr, strlength); wstring[newlen] = '\0'; length = newlen; return self; } @end |