Bounds-checked SOME/IP payload writer.
More...
#include <someip_serializer.h>
|
| | Writer (uint8_t *data, size_t capacity, size_t alignment=1U, Endian endian=Endian::kBig) noexcept |
| | Creates a writer over data with capacity bytes. More...
|
| |
| size_t | position () const noexcept |
| | Returns the number of bytes consumed by this writer. More...
|
| |
| bool | is_size_only () const noexcept |
| | Reports whether this writer only measures encoded size. More...
|
| |
| Writer | size_only () const noexcept |
| | Creates a size-only cursor at the current position. More...
|
| |
| bool | append (const uint8_t *data, size_t size) noexcept |
| | Appends size bytes without alignment padding. More...
|
| |
| bool | append_unsigned (uint64_t value, size_t width) noexcept |
| | Appends the low width bytes of value in the configured byte order. More...
|
| |
| bool | append_unsigned (uint64_t value, size_t width, Endian endian) noexcept |
| | Appends the low width bytes of value in an explicit byte order. More...
|
| |
| bool | begin_length_delimited (size_t &length_position, size_t &data_position, size_t width=sizeof(uint32_t)) noexcept |
| | Reserves a length field and records its payload start. More...
|
| |
| bool | end_length_delimited (size_t length_position, size_t data_position, size_t width=sizeof(uint32_t)) noexcept |
| | Finalizes a reserved length field from the current position. More...
|
| |
| bool | align () noexcept |
| | Pads the current position to the configured AUTOSAR alignment. More...
|
| |
Bounds-checked SOME/IP payload writer.
A null destination performs a size-only pass. A non-null destination never grows or replaces storage, which allows exact transport loans to be written in place. Every successful append advances position() by the encoded byte count; a failed append leaves the cursor unchanged. The writer never advances beyond kMaxPayloadSize.
◆ Writer()
| vlink::SomeipSerializer::Writer::Writer |
( |
uint8_t * |
data, |
|
|
size_t |
capacity, |
|
|
size_t |
alignment = 1U, |
|
|
Endian |
endian = Endian::kBig |
|
) |
| |
|
noexcept |
Creates a writer over data with capacity bytes.
Passing nullptr selects size-only mode. Otherwise data must remain valid for capacity bytes throughout the writer lifetime. Values above kMaxPayloadSize are clamped to that wire-format limit. The writer does not own or initialize the destination storage.
- Parameters
-
| data | Destination buffer, or nullptr for size-only mode. |
| capacity | Number of writable bytes, or the maximum size to measure. |
| alignment | AUTOSAR payload alignment: 1, 2, 4, 8, 16, or 32 bytes. |
| endian | Byte order for payload scalar values. |
◆ align()
| bool vlink::SomeipSerializer::Writer::align |
( |
| ) |
|
|
noexcept |
Pads the current position to the configured AUTOSAR alignment.
- Returns
true on success; false when the destination is too small.
◆ append()
| bool vlink::SomeipSerializer::Writer::append |
( |
const uint8_t * |
data, |
|
|
size_t |
size |
|
) |
| |
|
noexcept |
Appends size bytes without alignment padding.
Size-only mode advances the cursor without reading data. In write mode, data must identify at least size readable bytes when size is not zero and must not overlap the destination range written by this operation.
- Parameters
-
| data | Source bytes. |
| size | Number of bytes to append. |
- Returns
true on success; false when the destination is too small.
◆ append_unsigned() [1/2]
| bool vlink::SomeipSerializer::Writer::append_unsigned |
( |
uint64_t |
value, |
|
|
size_t |
width |
|
) |
| |
|
noexcept |
Appends the low width bytes of value in the configured byte order.
- Parameters
-
| value | Unsigned value containing the bits to encode. |
| width | Encoded width in bytes; must be in the range [1,8]. |
- Returns
true on success; false for an invalid width or insufficient storage.
◆ append_unsigned() [2/2]
| bool vlink::SomeipSerializer::Writer::append_unsigned |
( |
uint64_t |
value, |
|
|
size_t |
width, |
|
|
Endian |
endian |
|
) |
| |
|
noexcept |
Appends the low width bytes of value 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 | Unsigned value containing the bits to encode. |
| width | Encoded width in bytes; must be in the range [1,8]. |
| endian | Byte order for this value only. |
- Returns
true on success; false for an invalid width or insufficient storage.
◆ begin_length_delimited()
| bool vlink::SomeipSerializer::Writer::begin_length_delimited |
( |
size_t & |
length_position, |
|
|
size_t & |
data_position, |
|
|
size_t |
width = sizeof(uint32_t) |
|
) |
| |
|
noexcept |
Reserves a length field and records its payload start.
- Parameters
-
| length_position | Output offset of the reserved length field. |
| data_position | Output offset of the first length-delimited byte. |
| width | Encoded width in bytes; must be 1, 2, or 4. |
- Returns
true on success; false when the field cannot be reserved.
◆ end_length_delimited()
| bool vlink::SomeipSerializer::Writer::end_length_delimited |
( |
size_t |
length_position, |
|
|
size_t |
data_position, |
|
|
size_t |
width = sizeof(uint32_t) |
|
) |
| |
|
noexcept |
Finalizes a reserved length field from the current position.
Stores position()-data_position as an unsigned byte count at length_position. The current position is not changed.
- Parameters
-
- Returns
true on success; false on an invalid range or length overflow.
◆ is_size_only()
| bool vlink::SomeipSerializer::Writer::is_size_only |
( |
| ) |
const |
|
noexcept |
Reports whether this writer only measures encoded size.
- Returns
true when no destination buffer is attached.
◆ position()
| size_t vlink::SomeipSerializer::Writer::position |
( |
| ) |
const |
|
noexcept |
Returns the number of bytes consumed by this writer.
- Returns
- Current zero-based write position in bytes.
◆ size_only()
| Writer vlink::SomeipSerializer::Writer::size_only |
( |
| ) |
const |
|
noexcept |
Creates a size-only cursor at the current position.
- Returns
- A writer preserving capacity, position, alignment, and byte order without a destination buffer.
The documentation for this class was generated from the following file: