Every document save in both encodings lands here. Writing in place truncates the target the moment the stream opens, and a bare temp-then-rename is atomic against a crash but not against lost power, so the write goes thr
The data CRC covers the node stream only, so a flipped byte in the string table used to pass the check and come out as a wrong type name or a wrong asset path. The table's own CRC32 lives in the low 32 bits of the formerly unused stringTableChecksum slot (reserved in v1 readers, which ignore it), with this bit set so a table whose CRC happens to be zero still reads as "present, verify".
static_assert(sizeof(MdfbHeader) == 56, "MdfbHeader must be 56 bytes")
Comments the text parser found around one property, kept verbatim with their delimiters so the writer can put them back where they were. Leading are the lines above the property; SameLine is the one after its value.
Root() never throws: the mutable overload self-heals by creating an unnamed root, the const overload hands back a shared empty node. Check HasRoot() when the distinction matters. A text package (mdf_package.h) leads with its summary node; Root() is the document's own root behind it, so a reader written for the plain document reads the package form unchanged and a writer that edits Root() and writes the document back keeps the summary — and with it the asset's id. Code that wants the summary takes Roots().front().
Carriage returns are dropped from the text so a CRLF file and its LF twin produce the same token, and so the writer — which always emits LF — reproduces the comment byte-for-byte on either host.
The browser's picture of the asset, carried in the summary so a content browser shows it from the registry's read without loading or rendering the asset. Format names the bytes: "png" (encoded) or "rgba8" (Width*Height*4
The Base64 the text encoding writes Bytes as (standard alphabet, padded) — the same bytes Core's FBase64 produces, so a blob written either way reads back through either.
inline void MdfWriter::WriteComments(const std::vector<std::string>& comments, int depth)
Verbatim, one per line at the owner's indent. A block comment keeps its inner newlines and whatever indentation its continuation lines had, so a file written at the indent it was read at comes back byte-identical.
Node types and property keys are written RAW — unquoted and unescaped — so anything that is not an identifier produces a file the parser cannot read back (a display name with a space cost a whole scene once). Sanitising here keeps a bad name from destroying the document: the type still round-trips as an identifier, and the mismatch surfaces as an unknown-type warning on load rather than a parse failure that takes the file with it.
inline void MdfWriter::WriteNodeInternal(const MdfNode& node, int depth)
Shortest round-trip, at the width the value actually came from. Every engine float reaches here promoted to double, so 0.35f arrives as 0.34999999403953552 and a fixed eight significant digits wrote it back as 0.34999999 — a number nobody typed, re-quantized on every save. Integer- valued floats < 1e15 still print as "<int>.0", and ".0" is appended when the shortest form has neither '.' nor 'e'.