50 #ifndef COMMON_WRITESTREAM_H 51 #define COMMON_WRITESTREAM_H 76 virtual size_t write(
const void *dataPtr,
size_t dataSize) = 0;
89 if (
write(&value, 1) != 1)
94 if (
write(&value, 1) != 1)
99 value = TO_LE_16(value);
100 if (
write(&value, 2) != 2)
105 value = TO_LE_32(value);
106 if (
write(&value, 4) != 4)
111 value = TO_LE_64(value);
112 if (
write(&value, 8) != 8)
117 value = TO_BE_16(value);
118 if (
write(&value, 2) != 2)
123 value = TO_BE_32(value);
124 if (
write(&value, 4) != 4)
129 value = TO_BE_64(value);
130 if (
write(&value, 8) != 8)
136 for (
size_t i = 0; i < n; ++i) {
137 if (
write(&value, 1) != 1)
232 virtual size_t pos()
const = 0;
239 virtual size_t size()
const = 0;
265 virtual size_t skip(ptrdiff_t offset) {
275 #endif // COMMON_WRITESTREAM_H
Generic interface for a readable data stream.
virtual void flush()
Commit any buffered data to the underlying channel or storage medium; unbuffered streams can use the ...
A class holding an UTF-8 string.
void writeString(const UString &str)
Write the given string to the stream, encoded as UTF-8.
static size_t evalSeek(ptrdiff_t offset, Origin whence, size_t pos, size_t begin, size_t size)
Evaluate the seek offset relative to whence into a position from the beginning.
void writeBytes(byte value, size_t n)
Write n bytes of value to the stream.
Seek from the current position of the stream.
FORCEINLINE void writeIEEEDoubleBE(double value)
Low-level macros and functions to handle different endianness portably.
FORCEINLINE void writeSint16BE(int16 value)
FORCEINLINE void writeSint64BE(int64 value)
FORCEINLINE void writeSint32LE(int32 value)
void writeUint64LE(uint64 value)
virtual size_t pos() const =0
Obtains the current value of the stream position indicator of the stream.
double convertIEEEDouble(uint64 data)
Convert a uint64 holding the bit pattern of a 64-bit IEEE 754 double precision floating point value i...
virtual size_t seek(ptrdiff_t offset, Origin whence=kOriginBegin)=0
Sets the stream position indicator for the stream.
FORCEINLINE void writeIEEEDoubleLE(double value)
Basic exceptions to throw.
void writeUint16BE(uint16 value)
void writeUint64BE(uint64 value)
Utility templates and functions.
virtual size_t skip(ptrdiff_t offset)
Skip the specified number of bytes, adding that offset to the current position in the stream...
FORCEINLINE void writeSint64LE(int64 value)
const Exception kWriteError("Write error")
Exception when writing to a stream failed.
Low-level type definitions to handle fixed width types portably.
void writeUint16LE(uint16 value)
Seek from the end of the stream.
FORCEINLINE void writeSint16LE(int16 value)
virtual size_t write(const void *dataPtr, size_t dataSize)=0
Write data into the stream.
void writeByte(byte value)
Generic interface for a writable data stream.
void writeSByte(int8 value)
float convertIEEEFloat(uint32 data)
Convert a uint32 holding the bit pattern of a 32-bit IEEE 754 single precision floating point value i...
FORCEINLINE void writeIEEEFloatLE(float value)
FORCEINLINE void writeSint32BE(int32 value)
size_t writeStream(ReadStream &stream, size_t n)
Copy n bytes of the given stream into the stream.
Origin
The position a seeking offset takes as a base.
virtual size_t size() const =0
Obtains the total size of the stream, measured in bytes.
FORCEINLINE void writeIEEEFloatBE(float value)
void writeUint32BE(uint32 value)
FORCEINLINE void writeZeros(size_t n)
Write n zeros to the stream.
void writeUint32LE(uint32 value)
Seek from the begin of the stream.