4 Copyright (C) 1999 MDlink online service center GmbH and Helge Hess
6 Author: Helge Hess (helge@mdlink.de)
8 This file is part of the FB Adaptor Library
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details.
20 You should have received a copy of the GNU Library General Public
21 License along with this library; see the file COPYING.LIB.
22 If not, write to the Free Software Foundation,
23 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 // $Id: NSString+FB.m 1 2004-08-20 10:38:46Z znek $
27 #if LIB_FOUNDATION_BOEHM_GC
31 #import "NSString+FB.h"
34 @implementation NSString(FBMiscStrings)
36 - (NSString *)_sybModelMakeInstanceVarName {
37 if ([self length] == 0)
44 clen = [self cStringLength];
45 s = objc_atomic_malloc(clen + 5);
47 [self getCString:s maxLength:clen];
49 for (cnt = cnt2 = 0; cnt < clen; cnt++, cnt2++) {
50 if ((s[cnt] == '_') && (s[cnt + 1] != '\0')) {
51 s[cnt2] = toupper(s[cnt + 1]);
54 else if ((s[cnt] == '2') && (s[cnt + 1] != '\0')) {
58 s[cnt2] = toupper(s[cnt]);
61 s[cnt2] = tolower(s[cnt]);
65 return AUTORELEASE([[NSString alloc] initWithCStringNoCopy:s length:strlen(s) freeWhenDone:YES]);
69 - (NSString *)_sybModelMakeClassName {
70 if ([self length] == 0)
77 clen = [self cStringLength];
78 s = objc_atomic_malloc(clen + 1);
80 [self getCString:s maxLength:clen];
82 for (cnt = cnt2 = 0; cnt < clen; cnt++, cnt2++) {
83 if ((s[cnt] == '_') && (s[cnt + 1] != '\0')) {
84 s[cnt2] = toupper(s[cnt + 1]);
87 else if ((s[cnt] == '2') && (s[cnt + 1] != '\0')) {
91 s[cnt2] = toupper(s[cnt]);
94 s[cnt2] = tolower(s[cnt]);
100 return AUTORELEASE([[NSString alloc] initWithCStringNoCopy:s length:s?strlen(s):0 freeWhenDone:YES]);
104 - (NSString *)_sybStringWithCapitalizedFirstChar {
105 NSCharacterSet *upperSet = [NSCharacterSet uppercaseLetterCharacterSet];
107 if ([self length] == 0)
109 else if ([upperSet characterIsMember:[self characterAtIndex:0]])
110 return AUTORELEASE([self copy]);
112 NSMutableString *str = [NSMutableString stringWithCapacity:[self length]];
114 [str appendString:[[self substringToIndex:1] uppercaseString]];
115 [str appendString:[self substringFromIndex:1]];
117 return AUTORELEASE([str copy]);
121 - (NSString *)_sybStripEndSpaces {
122 if ([self length] > 0) {
123 NSCharacterSet *spaceSet = [NSCharacterSet whitespaceCharacterSet];
124 NSMutableString *str = [NSMutableString stringWithCapacity:[self length]];
128 charAtIndex = [self methodForSelector:@selector(characterAtIndex:)];
131 for (range.location = ([self length] - 1);
133 range.location++, range.length++) {
136 c = (unichar)(int)charAtIndex(self, @selector(characterAtIndex:),
138 if (![spaceSet characterIsMember:c])
142 if (range.length > 0) {
143 [str appendString:self];
144 [str deleteCharactersInRange:range];
145 return AUTORELEASE([str copy]);
148 return AUTORELEASE([self copy]);
153 void __link_NSStringFB() {
154 // used to force linking of object file