Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -178,10 +178,38 @@ * \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 Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -463,10 +463,40 @@ 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]];