LibCppBinary
Modern cross-platform C++ binary parsing library
Loading...
Searching...
No Matches
Binary Namespace Reference

Classes

class  BufferStream
 Represents a memory buffer that can be used as a stream. More...
struct  ChunkHeader
 Represents the header of a binary data chunk. More...
class  DataField
 Abstract base class representing a data field in a binary file. More...
struct  DataStructure
 Abstract base struct representing data structure in binary file. More...
class  FileStream
 Abstract base class representing a file stream. More...
class  IntField
 Represents an integer field in a binary file. More...
class  RawField
 Represents a raw data field in a binary file. More...
class  StandardFileStream
 Provides a standard file stream for manipulating binary files. More...
class  Stream
 Abstract base class representing a binary stream. More...
class  StringField
 Represents a string field in a binary file. More...

Typedefs

using UInt8Field = IntField<uint8_t, 1>
 Represents an unsigned 8-bit integer field in a binary file.
using UInt16Field = IntField<uint16_t, 2>
 Represents an unsigned 16-bit integer field in a binary file.
using UInt24Field = IntField<uint32_t, 3>
 Represents an unsigned 24-bit integer field in a binary file.
using UInt32Field = IntField<uint32_t, 4>
 Represents an unsigned 32-bit integer field in a binary file.
using UInt64Field = IntField<uint64_t, 8>
 Represents an unsigned 64-bit integer field in a binary file.
using Int8Field = IntField<int8_t, 1>
 Represents a signed 8-bit integer field in a binary file.
using Int16Field = IntField<int16_t, 2>
 Represents a signed 16-bit integer field in a binary file.
using Int24Field = IntField<int32_t, 3>
 Represents a signed 24-bit integer field in a binary file.
using Int32Field = IntField<int32_t, 4>
 Represents a signed 32-bit integer field in a binary file.
using Int64Field = IntField<int64_t, 8>
 Represents a signed 64-bit integer field in a binary file.

Enumerations

enum class  FieldEndianness { Little , Big }
 Determines the byte order of an integer. More...
enum class  FileMode { Read , Write , ReadWrite }
 Determines the mode to open a file in. More...
enum class  StringFormat {
  Terminated , Raw , Printable , Bin ,
  Hex , Dec
}
 Determines the format to output a string representation in. More...

Functions

FieldEndianness GetSystemEndianness ()
 Determines the endianness of the system.

Variables

constexpr int chunkIDSize { 4 }
 The size of the chunk ID field, in bytes.
const char * chunkIDSizeError
 Error message for invalid chunk ID size.
constexpr int bitsPerByte { 8 }
 Indicates the number of bits in a byte of data.
constexpr int byteMask { 0xFF }
 Used for selecting the least significant byte on little endian.
FieldEndianness defaultEndianness
 Controls what endianness IntFields are created with by default.

Typedef Documentation

◆ Int16Field

using Binary::Int16Field = IntField<int16_t, 2>

Represents a signed 16-bit integer field in a binary file.

◆ Int24Field

using Binary::Int24Field = IntField<int32_t, 3>

Represents a signed 24-bit integer field in a binary file.

◆ Int32Field

using Binary::Int32Field = IntField<int32_t, 4>

Represents a signed 32-bit integer field in a binary file.

◆ Int64Field

using Binary::Int64Field = IntField<int64_t, 8>

Represents a signed 64-bit integer field in a binary file.

◆ Int8Field

using Binary::Int8Field = IntField<int8_t, 1>

Represents a signed 8-bit integer field in a binary file.

◆ UInt16Field

using Binary::UInt16Field = IntField<uint16_t, 2>

Represents an unsigned 16-bit integer field in a binary file.

◆ UInt24Field

using Binary::UInt24Field = IntField<uint32_t, 3>

Represents an unsigned 24-bit integer field in a binary file.

◆ UInt32Field

using Binary::UInt32Field = IntField<uint32_t, 4>

Represents an unsigned 32-bit integer field in a binary file.

◆ UInt64Field

using Binary::UInt64Field = IntField<uint64_t, 8>

Represents an unsigned 64-bit integer field in a binary file.

◆ UInt8Field

using Binary::UInt8Field = IntField<uint8_t, 1>

Represents an unsigned 8-bit integer field in a binary file.

Enumeration Type Documentation

◆ FieldEndianness

enum class Binary::FieldEndianness
strong

Determines the byte order of an integer.

Enumerator
Little 

Least significant byte comes first.

Big 

Most significant byte comes first.

◆ FileMode

enum class Binary::FileMode
strong

Determines the mode to open a file in.

Enumerator
Read 

File should be opened for reading.

Write 

File should be opened for writing.

ReadWrite 

File should be opened for reading and writing.

◆ StringFormat

enum class Binary::StringFormat
strong

Determines the format to output a string representation in.

Data fields can be converted to a string representation. This enum allows you to choose the format of the string representation.

Enumerator
Terminated 

Formats the string as a null-terminated string.

Raw 

Formats the string's characters "as-is" from the bytes.

Printable 

Replaces any non-printable characters with a space.

Bin 

Provides a binary representation of the data bytes.

Hex 

Provides a hexadecimal representation of the bytes.

Dec 

Formats bytes as decimal. Only works on int field types.

Function Documentation

◆ GetSystemEndianness()

FieldEndianness Binary::GetSystemEndianness ( )

Determines the endianness of the system.

Returns
The endianness of the current system.

Variable Documentation

◆ bitsPerByte

int Binary::bitsPerByte { 8 }
inlineconstexpr

Indicates the number of bits in a byte of data.

◆ byteMask

int Binary::byteMask { 0xFF }
constexpr

Used for selecting the least significant byte on little endian.

◆ chunkIDSize

int Binary::chunkIDSize { 4 }
inlineconstexpr

The size of the chunk ID field, in bytes.

◆ chunkIDSizeError

const char* Binary::chunkIDSizeError
extern

Error message for invalid chunk ID size.

◆ defaultEndianness

FieldEndianness Binary::defaultEndianness
extern

Controls what endianness IntFields are created with by default.