ObjFW  Check-in [7bc07fede9]

Overview
Comment:Rename -[splitWithDelimiter:] to -[componentsSeparatedByString:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7bc07fede9f5920cc8a673def4c1149f46a0926c5a053efd51326c9263da9b5c
User & Date: js on 2010-04-04 16:50:03
Other Links: manifest | tags
Context
2010-04-07
18:39
Rename -[appendWithFormat:] to -[appendFormat:]. check-in: 66bbe6da24 user: js tags: trunk
2010-04-04
16:50
Rename -[splitWithDelimiter:] to -[componentsSeparatedByString:]. check-in: 7bc07fede9 user: js tags: trunk
16:41
Add -[readDataArrayTillEndOfStream] to OFStream. check-in: 1813376c4a user: js tags: trunk
Changes

Modified src/OFString.h from [2ed8d736d0] to [f68ed3b0a1].

278
279
280
281
282
283
284
285
286
287
288
289
290
291
292

/**
 * Splits an OFString into an OFArray of OFStrings.
 *
 * \param delimiter The delimiter for splitting
 * \return An autoreleased OFArray with the splitted string
 */
- (OFArray*)splitWithDelimiter: (OFString*)delimiter;

/**
 * Returns the decimal value of the string as an intmax_t or throws an
 * OFInvalidEncoding exception if the string contains any non-number characters.
 *
 * \return An OFNumber
 */







|







278
279
280
281
282
283
284
285
286
287
288
289
290
291
292

/**
 * Splits an OFString into an OFArray of OFStrings.
 *
 * \param delimiter The delimiter for splitting
 * \return An autoreleased OFArray with the splitted string
 */
- (OFArray*)componentsSeparatedByString: (OFString*)delimiter;

/**
 * Returns the decimal value of the string as an intmax_t or throws an
 * OFInvalidEncoding exception if the string contains any non-number characters.
 *
 * \return An OFNumber
 */

Modified src/OFString.m from [2490a2fe1b] to [e681f2fd16].

771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
	if (len > length)
		return NO;

	return (memcmp(string + (length - len), [suffix cString], len)
	    ? NO : YES);
}

- (OFArray*)splitWithDelimiter: (OFString*)delimiter
{
	OFAutoreleasePool *pool;
	OFMutableArray *array;
	const char *delim = [delimiter cString];
	size_t delim_len = [delimiter cStringLength];
	size_t i, last;








|







771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
	if (len > length)
		return NO;

	return (memcmp(string + (length - len), [suffix cString], len)
	    ? NO : YES);
}

- (OFArray*)componentsSeparatedByString: (OFString*)delimiter
{
	OFAutoreleasePool *pool;
	OFMutableArray *array;
	const char *delim = [delimiter cString];
	size_t delim_len = [delimiter cStringLength];
	size_t i, last;

Modified tests/OFString.m from [24ab0d52a6] to [e66119ebd2].

182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
	TEST(@"-[hasPrefix:]", [@"foobar" hasPrefix: @"foo"] &&
	    ![@"foobar" hasPrefix: @"foobar0"])

	TEST(@"-[hasSuffix:]", [@"foobar" hasSuffix: @"bar"] &&
	    ![@"foobar" hasSuffix: @"foobar0"])

	i = 0;
	TEST(@"-[splitWithDelimiter:]",
	    (a = [@"fooXXbarXXXXbazXXXX" splitWithDelimiter: @"XX"]) &&
	    [[a objectAtIndex: i++] isEqual: @"foo"] &&
	    [[a objectAtIndex: i++] isEqual: @"bar"] &&
	    [[a objectAtIndex: i++] isEqual: @""] &&
	    [[a objectAtIndex: i++] isEqual: @"baz"] &&
	    [[a objectAtIndex: i++] isEqual: @""] &&
	    [[a objectAtIndex: i++] isEqual: @""])








|
|







182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
	TEST(@"-[hasPrefix:]", [@"foobar" hasPrefix: @"foo"] &&
	    ![@"foobar" hasPrefix: @"foobar0"])

	TEST(@"-[hasSuffix:]", [@"foobar" hasSuffix: @"bar"] &&
	    ![@"foobar" hasSuffix: @"foobar0"])

	i = 0;
	TEST(@"-[componentsSeparatedByString:]",
	    (a = [@"fooXXbarXXXXbazXXXX" componentsSeparatedByString: @"XX"]) &&
	    [[a objectAtIndex: i++] isEqual: @"foo"] &&
	    [[a objectAtIndex: i++] isEqual: @"bar"] &&
	    [[a objectAtIndex: i++] isEqual: @""] &&
	    [[a objectAtIndex: i++] isEqual: @"baz"] &&
	    [[a objectAtIndex: i++] isEqual: @""] &&
	    [[a objectAtIndex: i++] isEqual: @""])