ObjFW  Check-in [da71912af5]

Overview
Comment:Add -[writeLine:] to OFStream.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: da71912af5397f54f47a780d597addc48acce4580a56a59970c3ef63907cf6da
User & Date: js on 2010-04-03 01:34:55
Other Links: manifest | tags
Context
2010-04-03
01:47
Pass a default mode to open(). check-in: 0c99c954e2 user: js tags: trunk
01:34
Add -[writeLine:] to OFStream. check-in: da71912af5 user: js tags: trunk
2010-04-02
16:33
-[hexadecimalValueAsInteger] returns an unsigned value now. check-in: 59dd873fd0 user: js tags: trunk
Changes

Modified src/OFStream.h from [abdf3e16b1] to [6718a13472].

125
126
127
128
129
130
131








132
133
134
135
136
 * Writes a string into the stream, without the trailing zero.
 *
 * \param str The string from which the data is written to the stream
 * \return The number of bytes written
 */
- (size_t)writeString: (OFString*)str;









/**
 * Closes the stream.
 */
- close;
@end







>
>
>
>
>
>
>
>





125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
 * Writes a string into the stream, without the trailing zero.
 *
 * \param str The string from which the data is written to the stream
 * \return The number of bytes written
 */
- (size_t)writeString: (OFString*)str;

/**
 * Writes a string into the stream with a trailing newline.
 *
 * \param str The string from which the data is written to the stream
 * \return The number of bytes written
 */
- (size_t)writeLine: (OFString*)str;

/**
 * Closes the stream.
 */
- close;
@end

Modified src/OFStream.m from [c5232e5990] to [08f611f86c].

362
363
364
365
366
367
368





















369
370
371
372
373
374
375
}

- (size_t)writeString: (OFString*)str
{
	return [self writeNBytes: [str cStringLength]
		      fromBuffer: [str cString]];
}






















- close
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}
@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
}

- (size_t)writeString: (OFString*)str
{
	return [self writeNBytes: [str cStringLength]
		      fromBuffer: [str cString]];
}

- (size_t)writeLine: (OFString*)str
{
	size_t len = [str cStringLength];
	char *tmp;

	tmp = [self allocMemoryWithSize: len + 2];
	memcpy(tmp, [str cString], len);
	tmp[len] = '\n';
	tmp[len + 1] = '\0';

	@try {
		return [self writeNBytes: len + 1
			      fromBuffer: tmp];
	} @finally {
		[self freeMemory: tmp];
	}

	/* Get rid of a warning, never reached anyway */
	assert(0);
}

- close
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}
@end