ObjFW  Check-in [978e88a43c]

Overview
Comment:Add -[writeInt8:] and -[writeBigEndianInt{16,32,64}:] to OFStream.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 978e88a43c0885c1b766ddea62ed85c2560c34632cb96155fb090f03154d8f63
User & Date: js on 2010-04-08 23:48:01
Other Links: manifest | tags
Context
2010-04-09
00:17
Add -[terminateWithStatus:] to OFApplication. check-in: 3edacb0511 user: js tags: trunk
2010-04-08
23:48
Add -[writeInt8:] and -[writeBigEndianInt{16,32,64}:] to OFStream. check-in: 978e88a43c user: js tags: trunk
23:37
Add -[readInt8] and -[readBigEndianInt{16,32,64}] to OFStream. check-in: c82e7f02f0 user: js tags: trunk
Changes

Modified src/OFStream.h from [b0e6f5f9a4] to [c88d590591].

176
177
178
179
180
181
182




























183
184
185
186
187
188
189
 * \param buf The buffer from which the data is written to the stream
 * \param size The size of the data that should be written
 * \return The number of bytes written
 */
- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const char*)buf;





























/**
 * Writes from an OFDataArray into the stream.
 *
 * \param dataarray The OFDataArray to write into the stream
 * \return The number of bytes written
 */
- (size_t)writeDataArray: (OFDataArray*)dataarray;







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







176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
 * \param buf The buffer from which the data is written to the stream
 * \param size The size of the data that should be written
 * \return The number of bytes written
 */
- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const char*)buf;

/**
 * Writes an uint8_t into the stream.
 *
 * \param int8 An uint8_t
 */
- (void)writeInt8: (uint8_t)int8;

/**
 * Writes an uint16_t into the stream, encoded in big endian.
 *
 * \param int16 An uint16_t
 */
- (void)writeBigEndianInt16: (uint16_t)int16;

/**
 * Writes an uint32_t into the stream, encoded in big endian.
 *
 * \param int32 An uint32_t
 */
- (void)writeBigEndianInt32: (uint32_t)int32;

/**
 * Writes an uint64_t into the stream, encoded in big endian.
 *
 * \param int64 An uint64_t
 */
- (void)writeBigEndianInt64: (uint64_t)int64;

/**
 * Writes from an OFDataArray into the stream.
 *
 * \param dataarray The OFDataArray to write into the stream
 * \return The number of bytes written
 */
- (size_t)writeDataArray: (OFDataArray*)dataarray;

Modified src/OFStream.m from [fa0d06eb4d] to [2c3719ee49].

461
462
463
464
465
466
467






























468
469
470
471
472
473
474

- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const char*)buf
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}































- (size_t)writeDataArray: (OFDataArray*)dataarray
{
	return [self writeNBytes: [dataarray count] * [dataarray itemSize]
		      fromBuffer: [dataarray cArray]];
}








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







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
494
495
496
497
498
499
500
501
502
503
504

- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const char*)buf
{
	@throw [OFNotImplementedException newWithClass: isa
					      selector: _cmd];
}

- (void)writeInt8: (uint8_t)int8
{
	[self writeNBytes: 1
	       fromBuffer: (char*)&int8];
}

- (void)writeBigEndianInt16: (uint16_t)int16
{
	int16 = OF_BSWAP16_IF_LE(int16);

	[self writeNBytes: 2
	       fromBuffer: (char*)&int16];
}

- (void)writeBigEndianInt32: (uint32_t)int32
{
	int32 = OF_BSWAP32_IF_LE(int32);

	[self writeNBytes: 4
	       fromBuffer: (char*)&int32];
}

- (void)writeBigEndianInt64: (uint64_t)int64
{
	int64 = OF_BSWAP64_IF_LE(int64);

	[self writeNBytes: 8
	       fromBuffer: (char*)&int64];
}

- (size_t)writeDataArray: (OFDataArray*)dataarray
{
	return [self writeNBytes: [dataarray count] * [dataarray itemSize]
		      fromBuffer: [dataarray cArray]];
}