Public Member Functions | |
(NSString *) | - stringByReplacingRange:with: [implementation] |
Definition at line 128 of file SDLMain.mm.
Definition at line 130 of file SDLMain.mm.
References buffer.
00132 :(NSRange)aRange with:(NSString *)aString 00133 { 00134 unsigned int bufferSize; 00135 unsigned int selfLen = [self length]; 00136 unsigned int aStringLen = [aString length]; 00137 unichar *buffer; 00138 NSRange localRange; 00139 NSString *result; 00140 00141 bufferSize = selfLen + aStringLen - aRange.length; 00142 buffer = (unichar *) NSAllocateMemoryPages(bufferSize*sizeof(unichar)); 00143 00144 /* Get first part into buffer */ 00145 localRange.location = 0; 00146 localRange.length = aRange.location; 00147 [self getCharacters:buffer range:localRange]; 00148 00149 /* Get middle part into buffer */ 00150 localRange.location = 0; 00151 localRange.length = aStringLen; 00152 [aString getCharacters:(buffer+aRange.location) range:localRange]; 00153 00154 /* Get last part into buffer */ 00155 localRange.location = aRange.location + aRange.length; 00156 localRange.length = selfLen - localRange.location; 00157 [self getCharacters:(buffer+aRange.location+aStringLen) range:localRange]; 00158 00159 /* Build output string */ 00160 result = [NSString stringWithCharacters:buffer length:bufferSize]; 00161 NSDeallocateMemoryPages(buffer, bufferSize); 00162