C++ Utilities  5.0.0
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Public Member Functions | List of all members
CppUtilities::BinaryWriter Class Reference

Writes primitive data types to a std::ostream. More...

#include <binarywriter.h>

Public Member Functions

 BinaryWriter (std::ostream *stream, bool giveOwnership=false)
 Constructs a new BinaryWriter. More...
 
 BinaryWriter (const BinaryWriter &other)
 Copies the specified BinaryWriter. More...
 
BinaryWriteroperator= (const BinaryWriter &rhs)=delete
 
 ~BinaryWriter ()
 Destroys the BinaryWriter. More...
 
const std::ostream * stream () const
 Returns a pointer to the stream the writer will write to when calling one of the write-methods. More...
 
std::ostream * stream ()
 Returns a pointer to the stream the writer will write to when calling one of the write-methods. More...
 
void setStream (std::ostream *stream, bool giveOwnership=false)
 Assigns the stream the writer will write to when calling one of the write-methods. More...
 
bool hasOwnership () const
 Returns whether the writer takes ownership over the assigned stream. More...
 
void giveOwnership ()
 The writer will take ownership over the assigned stream. More...
 
void detatchOwnership ()
 The writer will not take ownership over the assigned stream. More...
 
void flush ()
 Calls the flush() method of the assigned stream. More...
 
bool fail () const
 Returns an indication whether the fail bit of the assigned stream is set. More...
 
void write (const char *buffer, std::streamsize length)
 Writes a character array to the current stream and advances the current position of the stream by the length of the array. More...
 
void write (const std::vector< char > &buffer, std::streamsize length)
 Writes the specified number of bytes from the buffer to the current stream and advances the current position of the stream by the specified length which must be less or equal to the buffer size. More...
 
void writeChar (char value)
 Writes a single character to the current stream and advances the current position of the stream by one byte. More...
 
void writeByte (std::uint8_t value)
 Writes a single byte to the current stream and advances the current position of the stream by one byte. More...
 
void writeInt16BE (std::int16_t value)
 Writes a 16-bit big endian signed integer to the current stream and advances the current position of the stream by two bytes. More...
 
void writeUInt16BE (std::uint16_t value)
 Writes a 16-bit big endian unsigned integer to the current stream and advances the current position of the stream by two bytes. More...
 
void writeInt24BE (std::int32_t value)
 Writes a 24-bit big endian signed integer to the current stream and advances the current position of the stream by three bytes. More...
 
void writeUInt24BE (std::uint32_t value)
 Writes a 24-bit big endian unsigned integer to the current stream and advances the current position of the stream by three bytes. More...
 
void writeInt32BE (std::int32_t value)
 Writes a 32-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeUInt32BE (std::uint32_t value)
 Writes a 32-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeInt40BE (std::int64_t value)
 Writes a 40-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeUInt40BE (std::uint64_t value)
 Writes a 40-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeInt56BE (std::int64_t value)
 Writes a 56-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeUInt56BE (std::uint64_t value)
 Writes a 56-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeInt64BE (std::int64_t value)
 Writes a 64-bit big endian signed integer to the current stream and advances the current position of the stream by eight bytes. More...
 
void writeUInt64BE (std::uint64_t value)
 Writes a 64-bit big endian unsigned integer to the current stream and advances the current position of the stream by eight bytes. More...
 
void writeVariableLengthUIntBE (std::uint64_t value)
 Writes an up to 8 byte long big endian unsigned integer to the current stream and advances the current position of the stream by one to eight bytes. More...
 
void writeFloat32BE (float value)
 Writes a 32-bit big endian floating point value to the current stream and advances the current position of the stream by four bytes. More...
 
void writeFloat64BE (double value)
 Writes a 64-bit big endian floating point value to the current stream and advances the current position of the stream by eight bytes. More...
 
void writeInt16LE (std::int16_t value)
 Writes a 16-bit little endian signed integer to the current stream and advances the current position of the stream by two bytes. More...
 
void writeUInt16LE (std::uint16_t value)
 Writes a 16-bit little endian unsigned integer to the current stream and advances the current position of the stream by two bytes. More...
 
void writeInt24LE (std::int32_t value)
 Writes a 24-bit little endian signed integer to the current stream and advances the current position of the stream by three bytes. More...
 
void writeUInt24LE (std::uint32_t value)
 Writes a 24-bit little endian unsigned integer to the current stream and advances the current position of the stream by three bytes. More...
 
void writeInt32LE (std::int32_t value)
 Writes a 32-bit little endian signed integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeUInt32LE (std::uint32_t value)
 Writes a 32-bit little endian unsigned integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeInt40LE (std::int64_t value)
 Writes a 40-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeUInt40LE (std::uint64_t value)
 Writes a 40-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeInt56LE (std::int64_t value)
 Writes a 56-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeUInt56LE (std::uint64_t value)
 Writes a 56-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeInt64LE (std::int64_t value)
 Writes a 64-bit little endian signed integer to the current stream and advances the current position of the stream by eight bytes. More...
 
void writeUInt64LE (std::uint64_t value)
 Writes a 64-bit little endian unsigned integer to the current stream and advances the current position of the stream by eight bytes. More...
 
void writeVariableLengthUIntLE (std::uint64_t value)
 Writes an up to 8 byte long little endian unsigned integer to the current stream and advances the current position of the stream by one to eight bytes. More...
 
void writeFloat32LE (float value)
 Writes a 32-bit little endian floating point value to the current stream and advances the current position of the stream by four bytes. More...
 
void writeFloat64LE (double value)
 Writes a 64-bit little endian floating point value to the current stream and advances the current position of the stream by eight bytes. More...
 
void writeString (const std::string &value)
 Writes a string to the current stream and advances the current position of the stream by the length of the string. More...
 
void writeTerminatedString (const std::string &value)
 Writes a terminated string to the current stream and advances the current position of the stream by the length of the string plus 1. More...
 
void writeLengthPrefixedString (const std::string &value)
 Writes the length of a string and the string itself to the current stream. More...
 
void writeLengthPrefixedCString (const char *value, std::size_t size)
 Writes the length of a string and the string itself to the current stream. More...
 
void writeBool (bool value)
 Writes a boolean value to the current stream and advances the current position of the stream by one byte. More...
 
void writeSynchsafeUInt32BE (std::uint32_t valueToConvertAndWrite)
 Writes a 32-bit big endian synchsafe integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeFixed8BE (float valueToConvertAndWrite)
 Writes the 8.8 fixed point big endian representation for the specified 32-bit floating point value to the current stream and advances the current position of the stream by two bytes. More...
 
void writeFixed16BE (float valueToConvertAndWrite)
 Writes the 16.16 fixed point big endian representation for the specified 32-bit floating point value to the current stream and advances the current position of the stream by four bytes. More...
 
void writeSynchsafeUInt32LE (std::uint32_t valueToConvertAndWrite)
 Writes a 32-bit little endian synchsafe integer to the current stream and advances the current position of the stream by four bytes. More...
 
void writeFixed8LE (float valueToConvertAndWrite)
 Writes the 8.8 fixed point little endian representation for the specified 32-bit floating point value to the current stream and advances the current position of the stream by two bytes. More...
 
void writeFixed16LE (float valueToConvertAndWrite)
 Writes the 16.16 fixed point little endian representation for the specified 32-bit floating point value to the current stream and advances the current position of the stream by four bytes. More...
 
void write (char oneChar)
 Writes a single character to the current stream and advances the current position of the stream by one byte. More...
 
void write (std::uint8_t oneByte)
 Writes a single byte to the current stream and advances the current position of the stream by one byte. More...
 
void write (bool oneBool)
 Writes a boolean value to the current stream and advances the current position of the stream by one byte. More...
 
void write (const std::string &lengthPrefixedString)
 Writes the length of a string and the string itself to the current stream. More...
 
void write (const char *lengthPrefixedString)
 Writes the length of a string and the string itself to the current stream. More...
 
void write (std::int16_t one16BitInt)
 Writes a 16-bit big endian signed integer to the current stream and advances the current position of the stream by two bytes. More...
 
void write (std::uint16_t one16BitUint)
 Writes a 16-bit big endian unsigned integer to the current stream and advances the current position of the stream by two bytes. More...
 
void write (std::int32_t one32BitInt)
 Writes a 32-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes. More...
 
void write (std::uint32_t one32BitUint)
 Writes a 32-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes. More...
 
void write (std::int64_t one64BitInt)
 Writes a 64-bit big endian signed integer to the current stream and advances the current position of the stream by eight bytes. More...
 
void write (std::uint64_t one64BitUint)
 Writes a 64-bit big endian unsigned integer to the current stream and advances the current position of the stream by eight bytes. More...
 
void write (float one32BitFloat)
 Writes a 32-bit big endian floating point value to the current stream and advances the current position of the stream by four bytes. More...
 
void write (double one64BitFloat)
 Writes a 64-bit big endian floating point value to the current stream and advances the current position of the stream by eight bytes. More...
 

Detailed Description

Writes primitive data types to a std::ostream.

Remarks
Supports both, little endian and big endian.
See also
For automatic deserialization of structs, see https://github.com/Martchus/reflective-rapidjson.

Definition at line 14 of file binarywriter.h.

Constructor & Destructor Documentation

◆ BinaryWriter() [1/2]

CppUtilities::BinaryWriter::BinaryWriter ( std::ostream *  stream,
bool  giveOwnership = false 
)
inline

Constructs a new BinaryWriter.

Parameters
streamSpecifies the stream to write to.
giveOwnershipSpecifies whether the writer should take ownership.

Definition at line 103 of file binarywriter.h.

◆ BinaryWriter() [2/2]

CppUtilities::BinaryWriter::BinaryWriter ( const BinaryWriter other)
inline

Copies the specified BinaryWriter.

Remarks
The copy will not take ownership over the stream.

Definition at line 113 of file binarywriter.h.

◆ ~BinaryWriter()

CppUtilities::BinaryWriter::~BinaryWriter ( )
inline

Destroys the BinaryWriter.

Definition at line 122 of file binarywriter.h.

Member Function Documentation

◆ detatchOwnership()

void CppUtilities::BinaryWriter::detatchOwnership ( )
inline

The writer will not take ownership over the assigned stream.

See also
setStream()
giveOwnership()
hasOwnership()

Definition at line 182 of file binarywriter.h.

◆ fail()

bool CppUtilities::BinaryWriter::fail ( ) const
inline

Returns an indication whether the fail bit of the assigned stream is set.

Definition at line 198 of file binarywriter.h.

◆ flush()

void CppUtilities::BinaryWriter::flush ( )
inline

Calls the flush() method of the assigned stream.

Definition at line 190 of file binarywriter.h.

◆ giveOwnership()

void CppUtilities::BinaryWriter::giveOwnership ( )
inline

The writer will take ownership over the assigned stream.

See also
setStream()
detatchOwnership()
hasOwnership()

Definition at line 168 of file binarywriter.h.

◆ hasOwnership()

bool CppUtilities::BinaryWriter::hasOwnership ( ) const
inline

Returns whether the writer takes ownership over the assigned stream.

See also
setStream()
giveOwnership()
detatchOwnership()

Definition at line 156 of file binarywriter.h.

◆ operator=()

BinaryWriter& CppUtilities::BinaryWriter::operator= ( const BinaryWriter rhs)
delete

◆ setStream()

void CppUtilities::BinaryWriter::setStream ( std::ostream *  stream,
bool  giveOwnership = false 
)

Assigns the stream the writer will write to when calling one of the write-methods.

You can assign a null pointer when ensuring that none of the write-methods is called until a stream is assigned.

Parameters
streamSpecifies the stream to be assigned.
giveOwnershipSpecifies whether the writer should take ownership.
See also
setStream()

Definition at line 30 of file binarywriter.cpp.

◆ stream() [1/2]

std::ostream * CppUtilities::BinaryWriter::stream ( )
inline

Returns a pointer to the stream the writer will write to when calling one of the write-methods.

See also
setStream()

Definition at line 134 of file binarywriter.h.

◆ stream() [2/2]

const std::ostream * CppUtilities::BinaryWriter::stream ( ) const
inline

Returns a pointer to the stream the writer will write to when calling one of the write-methods.

See also
setStream()

Definition at line 144 of file binarywriter.h.

◆ write() [1/15]

void CppUtilities::BinaryWriter::write ( bool  oneBool)
inline

Writes a boolean value to the current stream and advances the current position of the stream by one byte.

Definition at line 644 of file binarywriter.h.

◆ write() [2/15]

void CppUtilities::BinaryWriter::write ( char  oneChar)
inline

Writes a single character to the current stream and advances the current position of the stream by one byte.

Definition at line 628 of file binarywriter.h.

◆ write() [3/15]

void CppUtilities::BinaryWriter::write ( const char *  buffer,
std::streamsize  length 
)
inline

Writes a character array to the current stream and advances the current position of the stream by the length of the array.

Definition at line 206 of file binarywriter.h.

◆ write() [4/15]

void CppUtilities::BinaryWriter::write ( const char *  lengthPrefixedString)
inline

Writes the length of a string and the string itself to the current stream.

Advances the current position of the stream by the length of the string plus the size of the length prefix.

Definition at line 664 of file binarywriter.h.

◆ write() [5/15]

void CppUtilities::BinaryWriter::write ( const std::string &  lengthPrefixedString)
inline

Writes the length of a string and the string itself to the current stream.

Advances the current position of the stream by the length of the string plus the size of the length prefix.

Definition at line 654 of file binarywriter.h.

◆ write() [6/15]

void CppUtilities::BinaryWriter::write ( const std::vector< char > &  buffer,
std::streamsize  length 
)
inline

Writes the specified number of bytes from the buffer to the current stream and advances the current position of the stream by the specified length which must be less or equal to the buffer size.

Definition at line 215 of file binarywriter.h.

◆ write() [7/15]

void CppUtilities::BinaryWriter::write ( double  one64BitFloat)
inline

Writes a 64-bit big endian floating point value to the current stream and advances the current position of the stream by eight bytes.

Definition at line 728 of file binarywriter.h.

◆ write() [8/15]

void CppUtilities::BinaryWriter::write ( float  one32BitFloat)
inline

Writes a 32-bit big endian floating point value to the current stream and advances the current position of the stream by four bytes.

Definition at line 720 of file binarywriter.h.

◆ write() [9/15]

void CppUtilities::BinaryWriter::write ( std::int16_t  one16BitInt)
inline

Writes a 16-bit big endian signed integer to the current stream and advances the current position of the stream by two bytes.

Definition at line 672 of file binarywriter.h.

◆ write() [10/15]

void CppUtilities::BinaryWriter::write ( std::int32_t  one32BitInt)
inline

Writes a 32-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes.

Definition at line 688 of file binarywriter.h.

◆ write() [11/15]

void CppUtilities::BinaryWriter::write ( std::int64_t  one64BitInt)
inline

Writes a 64-bit big endian signed integer to the current stream and advances the current position of the stream by eight bytes.

Definition at line 704 of file binarywriter.h.

◆ write() [12/15]

void CppUtilities::BinaryWriter::write ( std::uint16_t  one16BitUint)
inline

Writes a 16-bit big endian unsigned integer to the current stream and advances the current position of the stream by two bytes.

Definition at line 680 of file binarywriter.h.

◆ write() [13/15]

void CppUtilities::BinaryWriter::write ( std::uint32_t  one32BitUint)
inline

Writes a 32-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes.

Definition at line 696 of file binarywriter.h.

◆ write() [14/15]

void CppUtilities::BinaryWriter::write ( std::uint64_t  one64BitUint)
inline

Writes a 64-bit big endian unsigned integer to the current stream and advances the current position of the stream by eight bytes.

Definition at line 712 of file binarywriter.h.

◆ write() [15/15]

void CppUtilities::BinaryWriter::write ( std::uint8_t  oneByte)
inline

Writes a single byte to the current stream and advances the current position of the stream by one byte.

Definition at line 636 of file binarywriter.h.

◆ writeBool()

void CppUtilities::BinaryWriter::writeBool ( bool  value)
inline

Writes a boolean value to the current stream and advances the current position of the stream by one byte.

Definition at line 241 of file binarywriter.h.

◆ writeByte()

void CppUtilities::BinaryWriter::writeByte ( std::uint8_t  value)
inline

Writes a single byte to the current stream and advances the current position of the stream by one byte.

Definition at line 232 of file binarywriter.h.

◆ writeChar()

void CppUtilities::BinaryWriter::writeChar ( char  value)
inline

Writes a single character to the current stream and advances the current position of the stream by one byte.

Definition at line 223 of file binarywriter.h.

◆ writeFixed16BE()

void CppUtilities::BinaryWriter::writeFixed16BE ( float  valueToConvertAndWrite)
inline

Writes the 16.16 fixed point big endian representation for the specified 32-bit floating point value to the current stream and advances the current position of the stream by four bytes.

Definition at line 594 of file binarywriter.h.

◆ writeFixed16LE()

void CppUtilities::BinaryWriter::writeFixed16LE ( float  valueToConvertAndWrite)
inline

Writes the 16.16 fixed point little endian representation for the specified 32-bit floating point value to the current stream and advances the current position of the stream by four bytes.

Definition at line 620 of file binarywriter.h.

◆ writeFixed8BE()

void CppUtilities::BinaryWriter::writeFixed8BE ( float  valueToConvertAndWrite)
inline

Writes the 8.8 fixed point big endian representation for the specified 32-bit floating point value to the current stream and advances the current position of the stream by two bytes.

Definition at line 586 of file binarywriter.h.

◆ writeFixed8LE()

void CppUtilities::BinaryWriter::writeFixed8LE ( float  valueToConvertAndWrite)
inline

Writes the 8.8 fixed point little endian representation for the specified 32-bit floating point value to the current stream and advances the current position of the stream by two bytes.

Definition at line 612 of file binarywriter.h.

◆ writeFloat32BE()

void CppUtilities::BinaryWriter::writeFloat32BE ( float  value)
inline

Writes a 32-bit big endian floating point value to the current stream and advances the current position of the stream by four bytes.

Definition at line 373 of file binarywriter.h.

◆ writeFloat32LE()

void CppUtilities::BinaryWriter::writeFloat32LE ( float  value)
inline

Writes a 32-bit little endian floating point value to the current stream and advances the current position of the stream by four bytes.

Definition at line 516 of file binarywriter.h.

◆ writeFloat64BE()

void CppUtilities::BinaryWriter::writeFloat64BE ( double  value)
inline

Writes a 64-bit big endian floating point value to the current stream and advances the current position of the stream by eight bytes.

Definition at line 382 of file binarywriter.h.

◆ writeFloat64LE()

void CppUtilities::BinaryWriter::writeFloat64LE ( double  value)
inline

Writes a 64-bit little endian floating point value to the current stream and advances the current position of the stream by eight bytes.

Definition at line 525 of file binarywriter.h.

◆ writeInt16BE()

void CppUtilities::BinaryWriter::writeInt16BE ( std::int16_t  value)
inline

Writes a 16-bit big endian signed integer to the current stream and advances the current position of the stream by two bytes.

Definition at line 249 of file binarywriter.h.

◆ writeInt16LE()

void CppUtilities::BinaryWriter::writeInt16LE ( std::int16_t  value)
inline

Writes a 16-bit little endian signed integer to the current stream and advances the current position of the stream by two bytes.

Definition at line 391 of file binarywriter.h.

◆ writeInt24BE()

void CppUtilities::BinaryWriter::writeInt24BE ( std::int32_t  value)
inline

Writes a 24-bit big endian signed integer to the current stream and advances the current position of the stream by three bytes.

Remarks
The most significant byte of the specified 32-bit signed integer value will be discarded.

Definition at line 268 of file binarywriter.h.

◆ writeInt24LE()

void CppUtilities::BinaryWriter::writeInt24LE ( std::int32_t  value)
inline

Writes a 24-bit little endian signed integer to the current stream and advances the current position of the stream by three bytes.

Remarks
The most significant byte of the specified 32-bit signed integer value will be discarded.

Definition at line 410 of file binarywriter.h.

◆ writeInt32BE()

void CppUtilities::BinaryWriter::writeInt32BE ( std::int32_t  value)
inline

Writes a 32-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes.

Definition at line 288 of file binarywriter.h.

◆ writeInt32LE()

void CppUtilities::BinaryWriter::writeInt32LE ( std::int32_t  value)
inline

Writes a 32-bit little endian signed integer to the current stream and advances the current position of the stream by four bytes.

Definition at line 431 of file binarywriter.h.

◆ writeInt40BE()

void CppUtilities::BinaryWriter::writeInt40BE ( std::int64_t  value)
inline

Writes a 40-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes.

Remarks
The most significant bytes of the specified 64-bit unsigned integer value will be discarded.

Definition at line 307 of file binarywriter.h.

◆ writeInt40LE()

void CppUtilities::BinaryWriter::writeInt40LE ( std::int64_t  value)
inline

Writes a 40-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes.

Remarks
The most significant bytes of the specified 64-bit unsigned integer value will be discarded.

Definition at line 450 of file binarywriter.h.

◆ writeInt56BE()

void CppUtilities::BinaryWriter::writeInt56BE ( std::int64_t  value)
inline

Writes a 56-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes.

Remarks
The most significant byte of the specified 64-bit unsigned integer value will be discarded.

Definition at line 327 of file binarywriter.h.

◆ writeInt56LE()

void CppUtilities::BinaryWriter::writeInt56LE ( std::int64_t  value)
inline

Writes a 56-bit big endian signed integer to the current stream and advances the current position of the stream by four bytes.

Remarks
The most significant byte of the specified 64-bit unsigned integer value will be discarded.

Definition at line 470 of file binarywriter.h.

◆ writeInt64BE()

void CppUtilities::BinaryWriter::writeInt64BE ( std::int64_t  value)
inline

Writes a 64-bit big endian signed integer to the current stream and advances the current position of the stream by eight bytes.

Definition at line 346 of file binarywriter.h.

◆ writeInt64LE()

void CppUtilities::BinaryWriter::writeInt64LE ( std::int64_t  value)
inline

Writes a 64-bit little endian signed integer to the current stream and advances the current position of the stream by eight bytes.

Definition at line 489 of file binarywriter.h.

◆ writeLengthPrefixedCString()

void CppUtilities::BinaryWriter::writeLengthPrefixedCString ( const char *  value,
std::size_t  size 
)
inline

Writes the length of a string and the string itself to the current stream.

Advances the current position of the stream by the length of the string plus the size of the length prefix.

Exceptions
ThrowsConversionException if the string size exceeds the maximum.

Definition at line 567 of file binarywriter.h.

◆ writeLengthPrefixedString()

void CppUtilities::BinaryWriter::writeLengthPrefixedString ( const std::string &  value)
inline

Writes the length of a string and the string itself to the current stream.

Advances the current position of the stream by the length of the string plus the size of the length prefix.

Exceptions
ThrowsConversionException if the string size exceeds the maximum.

Definition at line 554 of file binarywriter.h.

◆ writeString()

void CppUtilities::BinaryWriter::writeString ( const std::string &  value)
inline

Writes a string to the current stream and advances the current position of the stream by the length of the string.

Definition at line 534 of file binarywriter.h.

◆ writeSynchsafeUInt32BE()

void CppUtilities::BinaryWriter::writeSynchsafeUInt32BE ( std::uint32_t  valueToConvertAndWrite)
inline

Writes a 32-bit big endian synchsafe integer to the current stream and advances the current position of the stream by four bytes.

Remarks
Synchsafe integers appear in ID3 tags that are attached to an MP3 file.
See also
ID3 tag version 2.4.0 - Main Structure

Definition at line 578 of file binarywriter.h.

◆ writeSynchsafeUInt32LE()

void CppUtilities::BinaryWriter::writeSynchsafeUInt32LE ( std::uint32_t  valueToConvertAndWrite)
inline

Writes a 32-bit little endian synchsafe integer to the current stream and advances the current position of the stream by four bytes.

Remarks
Synchsafe integers appear in ID3 tags that are attached to an MP3 file.
See also
ID3 tag version 2.4.0 - Main Structure

Definition at line 604 of file binarywriter.h.

◆ writeTerminatedString()

void CppUtilities::BinaryWriter::writeTerminatedString ( const std::string &  value)
inline

Writes a terminated string to the current stream and advances the current position of the stream by the length of the string plus 1.

Definition at line 542 of file binarywriter.h.

◆ writeUInt16BE()

void CppUtilities::BinaryWriter::writeUInt16BE ( std::uint16_t  value)
inline

Writes a 16-bit big endian unsigned integer to the current stream and advances the current position of the stream by two bytes.

Definition at line 258 of file binarywriter.h.

◆ writeUInt16LE()

void CppUtilities::BinaryWriter::writeUInt16LE ( std::uint16_t  value)
inline

Writes a 16-bit little endian unsigned integer to the current stream and advances the current position of the stream by two bytes.

Definition at line 400 of file binarywriter.h.

◆ writeUInt24BE()

void CppUtilities::BinaryWriter::writeUInt24BE ( std::uint32_t  value)
inline

Writes a 24-bit big endian unsigned integer to the current stream and advances the current position of the stream by three bytes.

Remarks
The most significant byte of the specified 32-bit unsigned integer value will be discarded.

Definition at line 278 of file binarywriter.h.

◆ writeUInt24LE()

void CppUtilities::BinaryWriter::writeUInt24LE ( std::uint32_t  value)
inline

Writes a 24-bit little endian unsigned integer to the current stream and advances the current position of the stream by three bytes.

Remarks
The most significant byte of the specified 32-bit unsigned integer value will be discarded.

Definition at line 421 of file binarywriter.h.

◆ writeUInt32BE()

void CppUtilities::BinaryWriter::writeUInt32BE ( std::uint32_t  value)
inline

Writes a 32-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes.

Definition at line 297 of file binarywriter.h.

◆ writeUInt32LE()

void CppUtilities::BinaryWriter::writeUInt32LE ( std::uint32_t  value)
inline

Writes a 32-bit little endian unsigned integer to the current stream and advances the current position of the stream by four bytes.

Definition at line 440 of file binarywriter.h.

◆ writeUInt40BE()

void CppUtilities::BinaryWriter::writeUInt40BE ( std::uint64_t  value)
inline

Writes a 40-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes.

Remarks
The most significant bytes of the specified 64-bit unsigned integer value will be discarded.

Definition at line 317 of file binarywriter.h.

◆ writeUInt40LE()

void CppUtilities::BinaryWriter::writeUInt40LE ( std::uint64_t  value)
inline

Writes a 40-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes.

Remarks
The most significant bytes of the specified 64-bit unsigned integer value will be discarded.

Definition at line 460 of file binarywriter.h.

◆ writeUInt56BE()

void CppUtilities::BinaryWriter::writeUInt56BE ( std::uint64_t  value)
inline

Writes a 56-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes.

Remarks
The most significant byte of the specified 64-bit unsigned integer value will be discarded.

Definition at line 337 of file binarywriter.h.

◆ writeUInt56LE()

void CppUtilities::BinaryWriter::writeUInt56LE ( std::uint64_t  value)
inline

Writes a 56-bit big endian unsigned integer to the current stream and advances the current position of the stream by four bytes.

Remarks
The most significant byte of the specified 64-bit unsigned integer value will be discarded.

Definition at line 480 of file binarywriter.h.

◆ writeUInt64BE()

void CppUtilities::BinaryWriter::writeUInt64BE ( std::uint64_t  value)
inline

Writes a 64-bit big endian unsigned integer to the current stream and advances the current position of the stream by eight bytes.

Definition at line 355 of file binarywriter.h.

◆ writeUInt64LE()

void CppUtilities::BinaryWriter::writeUInt64LE ( std::uint64_t  value)
inline

Writes a 64-bit little endian unsigned integer to the current stream and advances the current position of the stream by eight bytes.

Definition at line 498 of file binarywriter.h.

◆ writeVariableLengthUIntBE()

void CppUtilities::BinaryWriter::writeVariableLengthUIntBE ( std::uint64_t  value)
inline

Writes an up to 8 byte long big endian unsigned integer to the current stream and advances the current position of the stream by one to eight bytes.

Exceptions
ThrowsConversionException if value exceeds the maximum.

Definition at line 365 of file binarywriter.h.

◆ writeVariableLengthUIntLE()

void CppUtilities::BinaryWriter::writeVariableLengthUIntLE ( std::uint64_t  value)
inline

Writes an up to 8 byte long little endian unsigned integer to the current stream and advances the current position of the stream by one to eight bytes.

Exceptions
ThrowsConversionException if value exceeds the maximum.

Definition at line 508 of file binarywriter.h.


The documentation for this class was generated from the following files: