VLink  2.3.0
A high-performance communication middleware
vlink::SomeipSerializer::Writer类 参考final

Bounds-checked SOME/IP payload writer. 更多...

#include <someip_serializer.h>

vlink::SomeipSerializer::Writer 的协作图:

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.

构造及析构函数说明

◆ 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.

参数
dataDestination buffer, or nullptr for size-only mode.
capacityNumber of writable bytes, or the maximum size to measure.
alignmentAUTOSAR payload alignment: 1, 2, 4, 8, 16, or 32 bytes.
endianByte order for payload scalar values.

成员函数说明

◆ align()

bool vlink::SomeipSerializer::Writer::align ( )
noexcept

Pads the current position to the configured AUTOSAR alignment.

返回
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.

参数
dataSource bytes.
sizeNumber of bytes to append.
返回
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.

参数
valueUnsigned value containing the bits to encode.
widthEncoded width in bytes; must be in the range [1,8].
返回
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.

参数
valueUnsigned value containing the bits to encode.
widthEncoded width in bytes; must be in the range [1,8].
endianByte order for this value only.
返回
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.

参数
length_positionOutput offset of the reserved length field.
data_positionOutput offset of the first length-delimited byte.
widthEncoded width in bytes; must be 1, 2, or 4.
返回
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.

参数
length_positionOffset returned by begin_length_delimited().
data_positionPayload start returned by begin_length_delimited().
widthEncoded width in bytes; must be 1, 2, or 4.
返回
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.

返回
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.

返回
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.

返回
A writer preserving capacity, position, alignment, and byte order without a destination buffer.
这是这个函数的调用关系图:

该类的文档由以下文件生成: