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

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

#include <someip_serializer.h>

vlink::SomeipSerializer::Reader 的协作图:

Public 成员函数

 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. 更多...
 
size_t position () const noexcept
 Returns the current read position. 更多...
 
size_t size () const noexcept
 Returns the total payload size. 更多...
 
const uint8_t * current_data () const noexcept
 Returns the current byte pointer, or nullptr at the end. 更多...
 
bool read (uint8_t *data, size_t size, size_t end) noexcept
 Reads size bytes without exceeding end. 更多...
 
bool skip (size_t size, size_t end) noexcept
 Advances by size bytes without exceeding end. 更多...
 
bool read_unsigned (uint64_t &value, size_t width, size_t end) noexcept
 Reads a width-byte unsigned integer in the configured byte order. 更多...
 
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. 更多...
 
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. 更多...
 
bool align (size_t end) noexcept
 Skips bytes up to the configured AUTOSAR alignment. 更多...
 

详细描述

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.

参数
dataSource payload.
sizeTotal source size in bytes.
alignmentAUTOSAR payload alignment: 1, 2, 4, 8, 16, or 32 bytes.
endianByte order for payload scalar values.

成员函数说明

◆ align()

bool vlink::SomeipSerializer::Reader::align ( size_t  end)
noexcept

Skips bytes up to the configured AUTOSAR alignment.

参数
endExclusive enclosing boundary.
返回
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.

参数
endExclusive enclosing boundary.
value_endOutput exclusive boundary of the length-delimited body.
widthEncoded width in bytes; must be 1, 2, or 4.
返回
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.

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

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

参数
dataDestination buffer; must hold size bytes when non-zero.
sizeNumber of bytes to copy.
endExclusive enclosing boundary, not greater than size().
返回
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.

参数
valueOutput value; modified only after the range is validated.
widthEncoded width in bytes; must be in the range [1,8].
endianByte order for this value only.
endExclusive enclosing boundary, not greater than size().
返回
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.

参数
valueOutput value; modified only after the range is validated.
widthEncoded width in bytes; must be in the range [1,8].
endExclusive enclosing boundary, not greater than size().
返回
true on success; false for an invalid width or range.
这是这个函数的调用关系图:

◆ size()

size_t vlink::SomeipSerializer::Reader::size ( ) const
noexcept

Returns the total payload size.

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

参数
sizeNumber of bytes to skip.
endExclusive enclosing boundary, not greater than size().
返回
true on success; false when the requested range is invalid.
这是这个函数的调用关系图:

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