|
VLink
2.3.0
A high-performance communication middleware
|
Bounds-checked SOME/IP payload writer. 更多...
#include <someip_serializer.h>
Public 成员函数 | |
| Writer (uint8_t *data, size_t capacity, size_t alignment=1U, Endian endian=Endian::kBig) noexcept | |
Creates a writer over data with capacity bytes. 更多... | |
| size_t | position () const noexcept |
| Returns the number of bytes consumed by this writer. 更多... | |
| bool | is_size_only () const noexcept |
| Reports whether this writer only measures encoded size. 更多... | |
| Writer | size_only () const noexcept |
| Creates a size-only cursor at the current position. 更多... | |
| bool | append (const uint8_t *data, size_t size) noexcept |
Appends size bytes without alignment padding. 更多... | |
| bool | append_unsigned (uint64_t value, size_t width) noexcept |
Appends the low width bytes of value in the configured byte order. 更多... | |
| bool | append_unsigned (uint64_t value, size_t width, Endian endian) noexcept |
Appends the low width bytes of value in an explicit byte order. 更多... | |
| 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. 更多... | |
| 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. 更多... | |
| bool | align () noexcept |
| Pads the current position to the configured AUTOSAR alignment. 更多... | |
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.
|
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.
| 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. |
|
noexcept |
Pads the current position to the configured AUTOSAR alignment.
true on success; false when the destination is too small.
|
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.
| data | Source bytes. |
| size | Number of bytes to append. |
true on success; false when the destination is too small.
|
noexcept |
Appends the low width bytes of value in the configured byte order.
| value | Unsigned value containing the bits to encode. |
| width | Encoded width in bytes; must be in the range [1,8]. |
true on success; false for an invalid width or insufficient storage.
|
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.
| 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. |
true on success; false for an invalid width or insufficient storage.
|
noexcept |
Reserves a length field and records its payload start.
| 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. |
true on success; false when the field cannot be reserved.
|
noexcept |
Finalizes a reserved length field from the current position.
Stores position()- an unsigned byte count at data_position aslength_position. The current position is not changed.
| length_position | Offset returned by begin_length_delimited(). |
| data_position | Payload start returned by begin_length_delimited(). |
| width | Encoded width in bytes; must be 1, 2, or 4. |
true on success; false on an invalid range or length overflow.
|
noexcept |
Reports whether this writer only measures encoded size.
true when no destination buffer is attached.
|
noexcept |
Returns the number of bytes consumed by this writer.
|
noexcept |
Creates a size-only cursor at the current position.