Import std.io.binary
std.io.binary
Binary streams: BinaryReader reads numbers, Bools, bytes, and text from a Reader, and BinaryWriter writes them to a Writer, each number's bytes in the order its ByteOrder says, whatever the machine's own order is.
std/io/binary.fb
Types
ByteOrder
enum
Public Enum ByteOrder
The order of a number's bytes.
-
Its lowest byte first, as x86-64's and AArch64's memory has them.
-
Its highest byte first, as network protocols do.
BinaryReader
class
Public Class BinaryReader
Reads numbers, Bools, bytes, and text from another Reader. Each read throws an IOError of UNEXPECTED_END when the stream ends before what it reads, and ReadBytes and ReadText one of OTHER for a count past the 2147483647 bytes an array holds.
-
Reads
inner, its numbers' bytes inorder. -
Reads a UInt8.
-
Reads an Int8.
-
Reads a UInt16, in its ByteOrder.
-
Reads an Int16, in its ByteOrder.
-
Reads a UInt32, in its ByteOrder.
-
Reads an Int32, in its ByteOrder.
-
Reads a UInt64, in its ByteOrder.
-
Reads an Int64, in its ByteOrder.
-
Reads a Float32, its bits in its ByteOrder.
-
Reads a Float64, its bits in its ByteOrder.
-
A byte that's 0 for False, and anything else for True.
-
The next
countbytes, read a chunk at a time, so a count that the stream doesn't have, like a broken file's, ends in an IOError, not in asking for all that memory. Panics whencountis negative. -
The next
countbytes as text, with U+FFFD for each one that doesn't start well-formed UTF-8, read as ReadBytes reads them. Panics whencountis negative.
BinaryWriter
class
Public Class BinaryWriter
Writes numbers, Bools, bytes, and text to another Writer.
-
Writes
inner, its numbers' bytes inorder. -
Writes
value, a byte. -
Writes
value, a byte. -
Writes
value, in its ByteOrder. -
Writes
value, in its ByteOrder. -
Writes
value, in its ByteOrder. -
Writes
value, in its ByteOrder. -
Writes
value, in its ByteOrder. -
Writes
value, in its ByteOrder. -
Writes
value, its bits in its ByteOrder. -
Writes
value, its bits in its ByteOrder. -
A byte: 1 for True, and 0 for False.
-
Writes
bytesas they are. -
The
text's UTF-8 bytes, without anything to say how many there are.
Report an issue with this page or with FutureBlitz on GitHub.