|
| | FixedBytes () noexcept=default |
| | Construct an empty blob.
|
| |
| | FixedBytes (std::initializer_list< std::uint8_t > init) noexcept |
| | Construct from a brace-enclosed list of bytes (clamped to N; extra bytes are dropped).
|
| |
| FixedBytes & | operator= (std::initializer_list< std::uint8_t > init) noexcept |
| | Replace the contents from a brace-enclosed list (clamped to N; extra bytes are dropped).
|
| |
| FixedBytes & | assign (std::initializer_list< std::uint8_t > init) noexcept |
| | Replace the contents from a brace-enclosed list (clamped to N; extra bytes are dropped).
|
| |
| std::uint8_t * | data () noexcept |
| | Mutable pointer to the byte buffer (decode target).
|
| |
| const std::uint8_t * | data () const noexcept |
| | Const pointer to the byte buffer.
|
| |
| std::size_t | size () const noexcept |
| | Number of bytes currently stored.
|
| |
| bool | empty () const noexcept |
| | True if the blob is empty.
|
| |
| void | set_len (std::size_t n) noexcept |
| | Decode hook: set the logical length (clamped to N).
|
| |
| void | clear () noexcept |
| | Reset to an empty blob.
|
| |
| void | push_back (std::uint8_t b) noexcept |
| | Append one byte (no-op once at capacity N).
|
| |
| std::uint8_t & | operator[] (std::size_t i) noexcept |
| | Access the byte at i (no bounds checking).
|
| |
| const std::uint8_t & | operator[] (std::size_t i) const noexcept |
| | Access the byte at i (no bounds checking).
|
| |
| std::uint8_t * | begin () noexcept |
| | Iterator to the first byte.
|
| |
| std::uint8_t * | end () noexcept |
| | Iterator past the last byte.
|
| |
| const std::uint8_t * | begin () const noexcept |
| | Const iterator to the first byte.
|
| |
| const std::uint8_t * | end () const noexcept |
| | Const iterator past the last byte.
|
| |
| bool | operator== (const FixedBytes &o) const noexcept |
| | Content equality (same logical length and bytes).
|
| |
| bool | operator!= (const FixedBytes &o) const noexcept |
| | Negated operator==.
|
| |
template<std::size_t N>
class sofab::FixedBytes< N >
Fixed-capacity, heap-free byte blob of up to N bytes.
The embedded-friendly counterpart of std::vector<std::uint8_t> for blob fields, mirroring FixedString for bytes. The payload lives in an inline std::array, so an instance allocates nothing and never throws (overflow clamps to N). The buffer never moves, so an instance stays a valid decode destination across every IStreamImpl::feed chunk.
A logical length (size, <= N) is tracked separately from the capacity N: a blob shorter than its schema maxlen occupies only size bytes on the wire. This is exactly why the type cannot be a plain std::array<std::uint8_t,N> (always length N) and must not reintroduce the heap of std::vector.
- Generator integration contract
- Generated code is spelled exactly as for
std::vector<std::uint8_t>:
- encode passes data / size to the blob write, byte-for-byte identical to the same-content vector;
- decode emits
is.readBlob(b, maxlen); โ IStreamImpl::readBlob picks the heap-free branch off set_len / capacity and rejects an over-N wire length as INVALID per MESSAGE_SPEC ยง7.1 instead of truncating it.
- Template Parameters
-
| N | Maximum number of bytes. |
Definition at line 1005 of file sofab.hpp.
Construct from a brace-enclosed list of bytes (clamped to N; extra bytes are dropped).
Providing this constructor makes FixedBytes a non-aggregate, so a brace-init such as b = {1, 2, 3} routes through here and sets size โ it cannot silently fill the buffer while leaving the logical length at zero.
- Parameters
-
| init | Source bytes (excess beyond N is dropped). |
Definition at line 1029 of file sofab.hpp.