Bounds-checked SOME/IP payload reader.
More...
#include <someip_serializer.h>
|
| | Reader (const uint8_t *data, size_t size, size_t alignment=1U, Endian endian=Endian::kBig) noexcept |
| | Creates a reader over an immutable size-byte payload. More...
|
| |
| size_t | position () const noexcept |
| | Returns the current read position. More...
|
| |
| size_t | size () const noexcept |
| | Returns the total payload size. More...
|
| |
| const uint8_t * | current_data () const noexcept |
| | Returns the current byte pointer, or nullptr at the end. More...
|
| |
| bool | read (uint8_t *data, size_t size, size_t end) noexcept |
| | Reads size bytes without exceeding end. More...
|
| |
| bool | skip (size_t size, size_t end) noexcept |
| | Advances by size bytes without exceeding end. More...
|
| |
| bool | read_unsigned (uint64_t &value, size_t width, size_t end) noexcept |
| | Reads a width-byte unsigned integer in the configured byte order. More...
|
| |
| bool | read_unsigned (uint64_t &value, size_t width, Endian endian, size_t end) noexcept |
| | Reads a width-byte unsigned integer in an explicit byte order. More...
|
| |
| bool | begin_length_delimited (size_t end, size_t &value_end, size_t width=sizeof(uint32_t)) noexcept |
| | Reads a length field and returns its validated end position. More...
|
| |
| bool | align (size_t end) noexcept |
| | Skips bytes up to the configured AUTOSAR alignment. More...
|
| |
Bounds-checked SOME/IP payload reader.
Every operation accepts an enclosing end position, so nested arrays cannot consume bytes belonging to their parent structure. Successful operations advance the cursor. The cursor state after a failed compound field is not specified; a top-level failure may leave already decoded destination fields updated.
◆ Reader()
| vlink::SomeipSerializer::Reader::Reader |
( |
const uint8_t * |
data, |
|
|
size_t |
size, |
|
|
size_t |
alignment = 1U, |
|
|
Endian |
endian = Endian::kBig |
|
) |
| |
|
noexcept |
Creates a reader over an immutable size-byte payload.
The reader does not own the source storage. When size is non-zero, data must remain valid throughout the reader lifetime.
- Parameters
-
| data | Source payload. |
| size | Total source size in bytes. |
| alignment | AUTOSAR payload alignment: 1, 2, 4, 8, 16, or 32 bytes. |
| endian | Byte order for payload scalar values. |
◆ align()
| bool vlink::SomeipSerializer::Reader::align |
( |
size_t |
end | ) |
|
|
noexcept |
Skips bytes up to the configured AUTOSAR alignment.
- Parameters
-
| end | Exclusive enclosing boundary. |
- Returns
true on success; false when the padding exceeds end.
◆ begin_length_delimited()
| bool vlink::SomeipSerializer::Reader::begin_length_delimited |
( |
size_t |
end, |
|
|
size_t & |
value_end, |
|
|
size_t |
width = sizeof(uint32_t) |
|
) |
| |
|
noexcept |
Reads a length field and returns its validated end position.
The prefix is a big-endian byte count. On success, value_end is the exclusive end of the declared body and the reader points to its first byte.
- Parameters
-
| end | Exclusive enclosing boundary. |
| value_end | Output exclusive boundary of the length-delimited body. |
| width | Encoded width in bytes; must be 1, 2, or 4. |
- Returns
true on success; false when the prefix or declared body exceeds end.
◆ current_data()
| const uint8_t* vlink::SomeipSerializer::Reader::current_data |
( |
| ) |
const |
|
noexcept |
Returns the current byte pointer, or nullptr at the end.
- Returns
- Pointer to the unread byte at
position(), or nullptr when no bytes remain.
◆ position()
| size_t vlink::SomeipSerializer::Reader::position |
( |
| ) |
const |
|
noexcept |
Returns the current read position.
- Returns
- Current zero-based read position in bytes.
◆ read()
| bool vlink::SomeipSerializer::Reader::read |
( |
uint8_t * |
data, |
|
|
size_t |
size, |
|
|
size_t |
end |
|
) |
| |
|
noexcept |
Reads size bytes without exceeding end.
The destination range must not overlap the source range read by this operation.
- Parameters
-
| data | Destination buffer; must hold size bytes when non-zero. |
| size | Number of bytes to copy. |
| end | Exclusive enclosing boundary, not greater than size(). |
- Returns
true on success; false when the requested range is invalid.
◆ read_unsigned() [1/2]
| bool vlink::SomeipSerializer::Reader::read_unsigned |
( |
uint64_t & |
value, |
|
|
size_t |
width, |
|
|
Endian |
endian, |
|
|
size_t |
end |
|
) |
| |
|
noexcept |
Reads a width-byte unsigned integer in an explicit byte order.
Wire-format metadata such as TLV tags and union type selectors keeps network byte order independently of the configured payload byte order.
- Parameters
-
| value | Output value; modified only after the range is validated. |
| width | Encoded width in bytes; must be in the range [1,8]. |
| endian | Byte order for this value only. |
| end | Exclusive enclosing boundary, not greater than size(). |
- Returns
true on success; false for an invalid width or range.
◆ read_unsigned() [2/2]
| bool vlink::SomeipSerializer::Reader::read_unsigned |
( |
uint64_t & |
value, |
|
|
size_t |
width, |
|
|
size_t |
end |
|
) |
| |
|
noexcept |
Reads a width-byte unsigned integer in the configured byte order.
- Parameters
-
| value | Output value; modified only after the range is validated. |
| width | Encoded width in bytes; must be in the range [1,8]. |
| end | Exclusive enclosing boundary, not greater than size(). |
- Returns
true on success; false for an invalid width or range.
◆ size()
| size_t vlink::SomeipSerializer::Reader::size |
( |
| ) |
const |
|
noexcept |
Returns the total payload size.
- Returns
- Source payload size supplied to the constructor.
◆ skip()
| bool vlink::SomeipSerializer::Reader::skip |
( |
size_t |
size, |
|
|
size_t |
end |
|
) |
| |
|
noexcept |
Advances by size bytes without exceeding end.
- Parameters
-
| size | Number of bytes to skip. |
| end | Exclusive enclosing boundary, not greater than size(). |
- Returns
true on success; false when the requested range is invalid.
The documentation for this class was generated from the following file: