ByteReader
Generated from engine/core/byte_reader.h at 862e08b. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.
#include "engine/core/byte_reader.h" · namespace labrador
class ByteReader
Section titled “class ByteReader”A cursor over a buffer of bytes that cannot walk off the end.
EVERY READ IS CHECKED, which the obvious alternative - map a packed struct over the buffer - is not. A truncated file is a plausible thing to have on disk (an interrupted copy, a half-written build step), and the difference between the two designs is a named throw and a read past the end of a heap allocation. It is also the difference between a struct layout this compiler happens to produce and the layout the file actually has.
LITTLE-ENDIAN, SPELT OUT. Both file formats this engine reads are, and assembling the value a byte at a time says so - where a memcpy of four bytes would only say "whatever this machine is".
IN core/ RATHER THAN render/, which is where both of its callers are, because nothing about it is a picture: it reads numbers out of a file.
ByteReader
Section titled “ByteReader” const std::string& what);bytes is borrowed and must outlive the reader. what names the source in every throw - a path, so the message says which file.
read_u32 · read_i32 · read_f32
Section titled “read_u32 · read_i32 · read_f32”uint32_t read_u32();int32_t read_i32();float read_f32();read_bytes · skip
Section titled “read_bytes · skip”std::vector<unsigned char> read_bytes(size_t count);void skip(size_t count);require
Section titled “require”void require(size_t count) const;Throws std::runtime_error naming the source if fewer than count bytes are left. Called by every read above, and callable directly by a reader that is about to size a container from a number it has just read - which is the one place a corrupt file can ask for gigabytes.
position · remaining
Section titled “position · remaining”size_t position() const;size_t remaining() const;read_file_bytes
Section titled “read_file_bytes”The whole file at the UTF-8 path, as bytes.
Throws std::out_of_range naming the path when there is no file there, and std::runtime_error when there is one and it cannot be read. Those are different facts: the first is a name nobody produced, which is a content bug, and the second is a disk.
In the samples and tests
Section titled “In the samples and tests”The files that include this header directly. A file can also reach it through another header.
tests/app/content_root_tests.cpp
Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.