Differences From Artifact [b484829d75]:
- File
src/OFMutableString.m
— part of check-in
[9e8c825616]
at
2012-12-29 14:31:10
on branch trunk
— OFMutableString: Implement more methods.
The only method that needs to be implemented by a subclass now is
-[replaceCharactersInRange:withString:]. (user: js, size: 12655) [annotate] [blame] [check-ins using]
To Artifact [5f0048c446]:
- File
src/OFMutableString.m
— part of check-in
[640b225ba7]
at
2012-12-29 17:56:05
on branch trunk
— OFString: Improve API for Unicode strings.
* Instead of Unicode "strings", it uses the term "Unicode character
array".
* No terminating 0 character anymore, as these are not C strings
anyway. (user: js, size: 11992) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
80 81 82 83 84 85 86 | } - initWithString: (OFString*)string { return (id)[[OFMutableString_UTF8 alloc] initWithString: string]; } | | < < < < < < < < < < < < < | | | | < | < < < < < < < < < < < < < | | > | < > > | < | 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 115 116 117 118 119 120 121 122 123 124 125 | } - initWithString: (OFString*)string { return (id)[[OFMutableString_UTF8 alloc] initWithString: string]; } - initWithCharacters: (const of_unichar_t*)characters length: (size_t)length { return (id)[[OFMutableString_UTF8 alloc] initWithCharacters: characters length: length]; } - initWithCharacters: (const of_unichar_t*)characters length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { return (id)[[OFMutableString_UTF8 alloc] initWithCharacters: characters length: length byteOrder: byteOrder]; } - initWithUTF16String: (const uint16_t*)string length: (size_t)length { return (id)[[OFMutableString_UTF8 alloc] initWithUTF16String: string length: length]; } - initWithUTF16String: (const uint16_t*)string length: (size_t)length byteOrder: (of_byte_order_t)byteOrder { return (id)[[OFMutableString_UTF8 alloc] initWithUTF16String: string length: length byteOrder: byteOrder]; } - initWithFormat: (OFConstantString*)format, ... { id ret; va_list arguments; |
︙ | ︙ | |||
257 258 259 260 261 262 263 | - (void)OF_convertWithWordStartTable: (const of_unichar_t *const[])startTable wordMiddleTable: (const of_unichar_t *const[])middleTable wordStartTableSize: (size_t)startTableSize wordMiddleTableSize: (size_t)middleTableSize { void *pool = objc_autoreleasePoolPush(); | | | | 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | - (void)OF_convertWithWordStartTable: (const of_unichar_t *const[])startTable wordMiddleTable: (const of_unichar_t *const[])middleTable wordStartTableSize: (size_t)startTableSize wordMiddleTableSize: (size_t)middleTableSize { void *pool = objc_autoreleasePoolPush(); const of_unichar_t *characters = [self characters]; size_t i, length = [self length]; BOOL isStart = YES; for (i = 0; i < length; i++) { const of_unichar_t *const *table; size_t tableSize; of_unichar_t c = characters[i]; if (isStart) { table = startTable; tableSize = middleTableSize; } else { table = middleTable; tableSize = middleTableSize; |
︙ | ︙ | |||
300 301 302 303 304 305 306 | - (void)setCharacter: (of_unichar_t)character atIndex: (size_t)index { void *pool = objc_autoreleasePoolPush(); OFString *string; | | | | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | - (void)setCharacter: (of_unichar_t)character atIndex: (size_t)index { void *pool = objc_autoreleasePoolPush(); OFString *string; string = [OFString stringWithCharacters: &character length: 1]; [self replaceCharactersInRange: of_range(index, 1) withString: string]; objc_autoreleasePoolPop(pool); } |
︙ | ︙ | |||
471 472 473 474 475 476 477 | - (void)replaceOccurrencesOfString: (OFString*)string withString: (OFString*)replacement options: (int)options range: (of_range_t)range { void *pool = objc_autoreleasePoolPush(), *pool2; | | | | | | | 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | - (void)replaceOccurrencesOfString: (OFString*)string withString: (OFString*)replacement options: (int)options range: (of_range_t)range { void *pool = objc_autoreleasePoolPush(), *pool2; const of_unichar_t *characters; const of_unichar_t *searchCharacters = [string characters]; size_t searchLength = [string length]; size_t replacementLength = [replacement length]; size_t i; if (range.length > SIZE_MAX - range.location || range.location + range.length > [self length]) @throw [OFOutOfRangeException exceptionWithClass: [self class]]; if (searchLength > range.length) { objc_autoreleasePoolPop(pool); return; } pool2 = objc_autoreleasePoolPush(); characters = [self characters]; for (i = range.location; i <= range.length - searchLength; i++) { if (memcmp(characters + i, searchCharacters, searchLength * sizeof(of_unichar_t))) continue; [self replaceCharactersInRange: of_range(i, searchLength) withString: replacement]; range.length -= searchLength; range.length += replacementLength; i += replacementLength - 1; objc_autoreleasePoolPop(pool2); pool2 = objc_autoreleasePoolPush(); characters = [self characters]; } objc_autoreleasePoolPop(pool); } - (void)deleteLeadingWhitespaces { |
︙ | ︙ |