47void BinaryWriter::writeVariableLengthInteger(std::uint64_t value,
void (*getBytes)(std::uint64_t,
char *))
49 std::uint64_t boundCheck = 0x80;
50 std::uint8_t prefixLength = 1;
51 for (; boundCheck != 0x8000000000000000; boundCheck <<= 7, ++prefixLength) {
52 if (value < boundCheck) {
53 getBytes(value | boundCheck, m_buffer);
57 if (prefixLength == 9) {
58 throw ConversionException(
"The variable-length integer to be written exceeds the maximum.");
60 m_stream->write(m_buffer + 8 - prefixLength, prefixLength);
void giveOwnership()
The writer will take ownership over the assigned stream.
void setStream(std::ostream *stream, bool giveOwnership=false)
Assigns the stream the writer will write to when calling one of the write-methods.
const std::ostream * stream() const
Returns a pointer to the stream the writer will write to when calling one of the write-methods.
Contains all utilities provides by the c++utilities library.