Overview
Comment: | Add -[writeFormat:] to OFStream. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
fe3b6e54571316055d84bf9c25f8cbb7 |
User & Date: | js on 2010-04-07 18:43:41 |
Other Links: | manifest | tags |
Context
2010-04-07
| ||
19:55 | Add OFApplication. check-in: f034850a98 user: js tags: trunk | |
18:43 | Add -[writeFormat:] to OFStream. check-in: fe3b6e5457 user: js tags: trunk | |
18:39 | Rename -[appendWithFormat:] to -[appendFormat:]. check-in: 66bbe6da24 user: js tags: trunk | |
Changes
Modified src/OFStream.h from [ad729fbb54] to [ed7d8ab9b7].
︙ | |||
140 141 142 143 144 145 146 147 148 149 150 151 | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | + + + + + + + + | * 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; /** * Writes a formatted string into the stream. * * \param fmt A string used as format * \return The number of bytes written */ - (size_t)writeFormat: (OFString*)fmt, ...; /** * Closes the stream. */ - close; @end |
Modified src/OFStream.m from [0fee79697f] to [6cded45acb].
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | + + | /* * Copyright (c) 2008 - 2010 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ #include "config.h" #include <stdlib.h> #include <string.h> #include <assert.h> #import "OFStream.h" #import "OFString.h" #import "OFDataArray.h" #import "OFExceptions.h" #import "macros.h" |
︙ | |||
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | @try { return [self writeNBytes: len + 1 fromBuffer: tmp]; } @finally { [self freeMemory: tmp]; } /* Get rid of a warning, never reached anyway */ assert(0); } - (size_t)writeFormat: (OFString*)fmt, ... { va_list args; char *t; size_t len; if (fmt == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; va_start(args, fmt); if ((len = vasprintf(&t, [fmt cString], args)) == -1) { /* * This is only the most likely error to happen. Unfortunately, * there is no good way to check what really happened. */ @throw [OFOutOfMemoryException newWithClass: isa]; } va_end(args); @try { return [self writeNBytes: len fromBuffer: t]; } @finally { free(t); } /* Get rid of a warning, never reached anyway */ assert(0); } - close { @throw [OFNotImplementedException newWithClass: isa selector: _cmd]; } @end |