Class XmlBinary¶
Namespace: Apogee.Content.Xml
Assembly: Apogee.Content.dll
A binary encoding of an XML document, for cooked packs (APXB): the tree
public static class XmlBinary
Inheritance¶
Inherited Members¶
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Remarks¶
Little-endian; a varint is an unsigned LEB128 of at most 32 bits.
header u32 magic "APXB" (0x42585041) · u16 version · u16 flags (0) · u32 string count · u32 node count
strings count x { varint byte length, UTF-8 bytes } first-appearance order, string 0 is ""
nodes pre-order, root first: varint name, varint line, varint attribute count,
attributes x { varint name, varint value }, varint text, varint child count
The reader checks every count against the bytes that are left before it allocates for it, so a damaged or hostile file can only make it throw a
Fields¶
Version¶
The version of the encoding that
public const int Version = 1
Field Value¶
Methods¶
IsBinary(ReadOnlySpan<byte>)¶
Whether the bytes start with the magic of a cooked XML file (a text XML file cannot: it begins with <, a byte order mark or white space).
public static bool IsBinary(ReadOnlySpan<byte> bytes)
Parameters¶
bytes ReadOnlySpan<byte>
Returns¶
Read(ReadOnlySpan<byte>, string)¶
The tree encoded in bytes.
public static XmlNode Read(ReadOnlySpan<byte> bytes, string origin)
Parameters¶
bytes ReadOnlySpan<byte>
A cooked XML file.
origin string
The path to name in errors, and what
Returns¶
Exceptions¶
The bytes are not a cooked XML file this engine can read: foreign, cooked by a newer engine, cut short or damaged.
Write(XmlNode)¶
The encoding of the tree. The same tree always gives the same bytes.
public static byte[] Write(XmlNode root)
Parameters¶
root XmlNode
Returns¶
byte[]
Exceptions¶
The tree nests deeper than the text parser allows (