CoreComponents 4.0.0
A Modern C++ Toolkit
Loading...
Searching...
No Matches
ByteSink Class Reference

Byte encoding sink. More...

#include <cc/ByteSink>

Public Member Functions

 ByteSink (const Stream &sink, const Bytes &buffer, ByteOrder endian=ByteOrder::LittleEndian)
 Open a new ByteSink.
 ByteSink (const Stream &sink, ByteOrder endian=ByteOrder::LittleEndian)
 Open a new ByteSink.
 ByteSink (const Bytes &buffer, ByteOrder endian=ByteOrder::LittleEndian)
 Open a new ByteSink.
void write (char ch)
 Write character ch.
void write (const char *s)
 Write all characters of s.
void write (const Bytes &s)
 Write string s.
void writeUInt8 (uint8_t x)
 Write byte x.
void writeUInt16 (uint16_t x)
 Write 2-byte word x.
void writeUInt32 (uint32_t x)
 Write 4-byte word x.
void writeUInt64 (uint64_t x)
 Write 8-byte word x.
void writeInt8 (int8_t x)
 Write signed byte x.
void writeInt16 (int16_t x)
 Write signed 2-byte word x.
void writeInt32 (int32_t x)
 Write signed 4-byte word x.
void writeInt64 (int64_t x)
 Write signed 8-byte word x.
void flush ()
 Flush the output buffer and write cached bytes to the output sink.
Stream sink () const
 The output sink.
const Bytes & buffer () const
 The output buffer.
ByteOrder endian () const
 Byte-order for encoding multi-byte words.
void setEndian (ByteOrder endian)
 Set byte-order
long long currentOffset () const
 Total number of bytes written.

Detailed Description

Byte encoding sink.

Exceptions
OutputExhaustion

Constructor & Destructor Documentation

◆ ByteSink() [1/3]

ByteSink ( const Stream & sink,
const Bytes & buffer,
ByteOrder endian = ByteOrder::LittleEndian )

Open a new ByteSink.

Parameters
sinkDatra sink to write bytes to
bufferOutput buffer
endianEndianess for writing multi-byte words

◆ ByteSink() [2/3]

ByteSink ( const Stream & sink,
ByteOrder endian = ByteOrder::LittleEndian )

Open a new ByteSink.

Parameters
sinkSink to write bytes to
endianEndianess for writing multi-byte words

◆ ByteSink() [3/3]

ByteSink ( const Bytes & buffer,
ByteOrder endian = ByteOrder::LittleEndian )

Open a new ByteSink.

Parameters
bufferOutput buffer
endianEndianess for writing multi-byte words

Member Function Documentation

◆ write() [1/3]

void write ( char ch)

Write character ch.

◆ write() [2/3]

void write ( const char * s)

Write all characters of s.

◆ write() [3/3]

void write ( const Bytes & s)

Write string s.

◆ writeUInt8()

void writeUInt8 ( uint8_t x)

Write byte x.

◆ writeUInt16()

void writeUInt16 ( uint16_t x)

Write 2-byte word x.

◆ writeUInt32()

void writeUInt32 ( uint32_t x)

Write 4-byte word x.

◆ writeUInt64()

void writeUInt64 ( uint64_t x)

Write 8-byte word x.

◆ writeInt8()

void writeInt8 ( int8_t x)

Write signed byte x.

◆ writeInt16()

void writeInt16 ( int16_t x)

Write signed 2-byte word x.

◆ writeInt32()

void writeInt32 ( int32_t x)

Write signed 4-byte word x.

◆ writeInt64()

void writeInt64 ( int64_t x)

Write signed 8-byte word x.

◆ flush()

void flush ( )

Flush the output buffer and write cached bytes to the output sink.

◆ sink()

Stream sink ( ) const

The output sink.

◆ buffer()

const Bytes & buffer ( ) const

The output buffer.

◆ endian()

ByteOrder endian ( ) const

Byte-order for encoding multi-byte words.

◆ setEndian()

void setEndian ( ByteOrder endian)

Set byte-order

◆ currentOffset()

long long currentOffset ( ) const

Total number of bytes written.