Haio 0.2.X
Homebrew Asset IO/CDN
Loading...
Searching...
No Matches
Haio::Util Namespace Reference

Namespaces

namespace  Dither
namespace  GPU

Functions

bool matches (Bytes data, Bytes magic)
bool matches (Bytes data, std::string_view magic)
bool hasBytes (Bytes data, size_t off, size_t len)
constexpr uint32_t fourccLE (char a, char b, char c, char d)
void appendU32LE (std::vector< uint8_t > &out, uint32_t value)
void appendU64LE (std::vector< uint8_t > &out, uint64_t value)
uint32_t readU32LE (Bytes data, size_t off)
uint32_t readU32BE (Bytes data, size_t off)
uint64_t readU64LE (Bytes data, size_t off)
Result< std::vector< uint8_t > > slice (Bytes data, size_t off, size_t len)

Detailed Description

byte level helpers shared by the codecs. every container haio reads or writes stores its integers little endian, which the names say out loud: ktx even carries an endianness marker that the decoder checks, so leaving it implicit was asking for a silent bug on a big endian host.

Function Documentation

◆ appendU32LE()

void Haio::Util::appendU32LE ( std::vector< uint8_t > & out,
uint32_t value )

Definition at line 9 of file bytes.cpp.

Here is the call graph for this function:

◆ appendU64LE()

void Haio::Util::appendU64LE ( std::vector< uint8_t > & out,
uint64_t value )

Definition at line 16 of file bytes.cpp.

Here is the call graph for this function:

◆ fourccLE()

uint32_t Haio::Util::fourccLE ( char a,
char b,
char c,
char d )
constexpr

a four character code, the tag formats put at the front of a header. it is the same operation as readU32LE over a literal, and it carries the suffix for the same reason: riff and dds pack it little endian, iff and aiff pack it the other way round, so "fourcc" alone does not say which.

Definition at line 29 of file haio_util.hpp.

Here is the call graph for this function:

◆ hasBytes()

bool Haio::Util::hasBytes ( Bytes data,
size_t off,
size_t len )

true when data holds len bytes starting at off, so a decoder checks once

Definition at line 5 of file bytes.cpp.

Here is the call graph for this function:

◆ matches() [1/2]

bool Haio::Util::matches ( Bytes data,
Bytes magic )

Definition at line 7 of file matches.cpp.

Here is the call graph for this function:

◆ matches() [2/2]

bool Haio::Util::matches ( Bytes data,
std::string_view magic )

Definition at line 11 of file matches.cpp.

Here is the call graph for this function:

◆ readU32BE()

uint32_t Haio::Util::readU32BE ( Bytes data,
size_t off )

png and the netpbm family are big endian, unlike every gpu container here

Definition at line 29 of file bytes.cpp.

Here is the call graph for this function:

◆ readU32LE()

uint32_t Haio::Util::readU32LE ( Bytes data,
size_t off )

reads zero when out of range; pair it with hasBytes where that matters

Definition at line 21 of file bytes.cpp.

Here is the call graph for this function:

◆ readU64LE()

uint64_t Haio::Util::readU64LE ( Bytes data,
size_t off )

Definition at line 37 of file bytes.cpp.

Here is the call graph for this function:

◆ slice()

Result< std::vector< uint8_t > > Haio::Util::slice ( Bytes data,
size_t off,
size_t len )

Definition at line 42 of file bytes.cpp.

Here is the call graph for this function: