Bounds-checked reader for canonical little-endian binary data.
More...
#include <serialization.h>
|
|
| BinaryReader (std::span< const std::byte > data) |
| | Construct a reader over caller-owned data.
|
| |
|
bool | empty () const noexcept |
| | Return whether all input bytes have been consumed.
|
| |
|
std::size_t | size_bytes () const noexcept |
| | Return the total number of bytes in this reader.
|
| |
|
std::size_t | position () const noexcept |
| | Return the number of bytes consumed by this reader.
|
| |
|
std::size_t | byte_offset () const noexcept |
| | Return the current byte offset in the outermost input.
|
| |
|
std::size_t | remaining () const noexcept |
| | Return the number of unconsumed bytes.
|
| |
|
std::span< const std::byte > | remaining_bytes () const noexcept |
| | Return all currently unconsumed bytes.
|
| |
|
std::uint8_t | read_u8 () |
| | Read an unsigned eight-bit integer.
|
| |
|
std::uint16_t | read_u16 () |
| | Read an unsigned little-endian 16-bit integer.
|
| |
|
std::uint32_t | read_u32 () |
| | Read an unsigned little-endian 32-bit integer.
|
| |
|
std::uint64_t | read_u64 () |
| | Read an unsigned little-endian 64-bit integer.
|
| |
|
std::int8_t | read_i8 () |
| | Read a signed eight-bit integer.
|
| |
|
std::int16_t | read_i16 () |
| | Read a signed little-endian 16-bit integer.
|
| |
|
std::int32_t | read_i32 () |
| | Read a signed little-endian 32-bit integer.
|
| |
|
std::int64_t | read_i64 () |
| | Read a signed little-endian 64-bit integer.
|
| |
| std::size_t | read_size () |
| | Read an unsigned 64-bit size and convert it to size_t.
|
| |
| std::span< const std::byte > | read_bytes (std::size_t count) |
| | Read exactly count uninterpreted bytes.
|
| |
| BinaryReader | read_subreader (std::size_t count) |
| | Read a bounded region as an independent child reader.
|
| |
| void | skip (std::size_t count) |
| | Advance by exactly count bytes.
|
| |
| void | require_zero_padding (std::size_t maximum) |
| | Consume at most maximum trailing zero-padding bytes.
|
| |
Bounds-checked reader for canonical little-endian binary data.
The reader does not own its input. Copies have independent cursors, which allows a compound deserializer to parse into a temporary reader and assign it back only after validation succeeds.
◆ read_bytes()
| std::span< const std::byte > pixie::BinaryReader::read_bytes |
( |
std::size_t | count | ) |
|
|
inline |
Read exactly count uninterpreted bytes.
- Exceptions
-
◆ read_size()
| std::size_t pixie::BinaryReader::read_size |
( |
| ) |
|
|
inline |
Read an unsigned 64-bit size and convert it to size_t.
- Exceptions
-
| std::length_error | if the value is not representable. |
◆ read_subreader()
| BinaryReader pixie::BinaryReader::read_subreader |
( |
std::size_t | count | ) |
|
|
inline |
Read a bounded region as an independent child reader.
- Exceptions
-
◆ require_zero_padding()
| void pixie::BinaryReader::require_zero_padding |
( |
std::size_t | maximum | ) |
|
|
inline |
Consume at most maximum trailing zero-padding bytes.
- Exceptions
-
◆ skip()
| void pixie::BinaryReader::skip |
( |
std::size_t | count | ) |
|
|
inline |
Advance by exactly count bytes.
- Exceptions
-
The documentation for this class was generated from the following file: