VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
vlink::DynamicData类 参考final

Runtime-typed container that serializes any VLink-compatible message type. 更多...

#include <dynamic_data.h>

vlink::DynamicData 的协作图:

Public 成员函数

 DynamicData ()
 Constructs an empty DynamicData with no payload.
template<uint8_t SizeT, typename T>
DynamicDataload (const char(&type)[SizeT], const T &t)
 Serializes t with a type-name tag into the internal buffer.
template<typename T>
bool convert (T &t) const
 Deserializes the internal buffer into t.
template<typename T>
as () const
 Deserializes the internal buffer and returns the result by value.
const Bytesget_data () const
 Returns a const reference to the raw serialized bytes (including type tag).
const std::string_view & get_type () const
 Returns the type name string embedded in the buffer.
bool is_empty () const
 Returns true if no payload has been loaded.
bool operator== (const DynamicData &target) const
 Returns true if both DynamicData objects have identical buffers.
bool operator!= (const DynamicData &target) const
 Returns true if the objects differ.
bool operator<< (const Bytes &bytes) noexcept
 Deserializes a wire-format Bytes blob into this DynamicData.
bool operator>> (Bytes &bytes) const noexcept
 Serializes this DynamicData to a wire-format Bytes blob.

静态 Public 成员函数

static constexpr bool is_vlink_dynamic_data ()
 Compile-time trait marker – returns true to identify this as a DynamicData type.
static constexpr uint8_t get_offset ()
 Returns the byte offset where the serialized payload begins.

详细描述

Runtime-typed container that serializes any VLink-compatible message type.

Uses Serializer to pack the message into internal Bytes storage. The type tag is embedded in the first kOffset bytes of the buffer.

构造及析构函数说明

◆ DynamicData()

vlink::DynamicData::DynamicData ( )

Constructs an empty DynamicData with no payload.

函数调用图:
这是这个函数的调用关系图:

成员函数说明

◆ as()

template<typename T>
T vlink::DynamicData::as ( ) const
inlinenodiscard

Deserializes the internal buffer and returns the result by value.

Constructs a default T (or shared_ptr<T> for pointer types) and calls convert(). Returns a default-constructed T on failure.

模板参数
TMessage type to deserialize.
返回
Deserialized instance, or default-constructed value on failure.
函数调用图:
这是这个函数的调用关系图:

◆ convert()

template<typename T>
bool vlink::DynamicData::convert ( T & t) const
inline

Deserializes the internal buffer into t.

Uses Serializer to populate t from the payload bytes. Returns false if the buffer is empty or deserialisation fails.

模板参数
TMessage type to deserialize into.
参数
tOutput parameter populated on success.
返回
true if deserialization succeeded; false otherwise.
函数调用图:
这是这个函数的调用关系图:

◆ get_data()

const Bytes & vlink::DynamicData::get_data ( ) const
nodiscard

Returns a const reference to the raw serialized bytes (including type tag).

返回
Internal Bytes buffer.

◆ get_offset()

uint8_t vlink::DynamicData::get_offset ( )
inlinestaticnodiscardconstexpr

Returns the byte offset where the serialized payload begins.

Equal to kOffset (20). The first kOffset bytes are reserved for the type name.

返回
Offset value (20).
这是这个函数的调用关系图:

◆ get_type()

const std::string_view & vlink::DynamicData::get_type ( ) const
nodiscard

Returns the type name string embedded in the buffer.

Points into the first kOffset bytes of the internal Bytes buffer. The view is only valid for the lifetime of this DynamicData instance.

返回
string_view of the type name.

◆ is_empty()

bool vlink::DynamicData::is_empty ( ) const
nodiscard

Returns true if no payload has been loaded.

返回
true if the internal Bytes buffer is empty.

◆ is_vlink_dynamic_data()

bool vlink::DynamicData::is_vlink_dynamic_data ( )
inlinestaticnodiscardconstexpr

Compile-time trait marker – returns true to identify this as a DynamicData type.

Used internally by Serializer via template specialisation detection.

返回
Always true.
这是这个函数的调用关系图:

◆ load()

template<uint8_t SizeT, typename T>
DynamicData & vlink::DynamicData::load ( const char(&) type[SizeT],
const T & t )
inline

Serializes t with a type-name tag into the internal buffer.

Details

The type name is stored in the first kOffset bytes of the underlying Bytes buffer. A static_assert enforces that SizeT < kOffset (20).

模板参数
SizeTLength of the type-name string literal including NUL.
TMessage type to serialize (must be supported by Serializer).
参数
typeType name string literal, e.g., "MyProtoMsg".
tMessage instance to serialize.
返回
Reference to *this for chaining.
注解
Logs a failure if serialisation returns false.
函数调用图:
这是这个函数的调用关系图:

◆ operator!=()

bool vlink::DynamicData::operator!= ( const DynamicData & target) const
nodiscard

Returns true if the objects differ.

参数
targetRight-hand side.
返回
true if the raw bytes differ.
函数调用图:

◆ operator<<()

bool vlink::DynamicData::operator<< ( const Bytes & bytes)
noexcept

Deserializes a wire-format Bytes blob into this DynamicData.

参数
bytesWire-format bytes produced by operator>>.
返回
true on success; false if parsing failed.

◆ operator==()

bool vlink::DynamicData::operator== ( const DynamicData & target) const
nodiscard

Returns true if both DynamicData objects have identical buffers.

参数
targetRight-hand side.
返回
true if the raw bytes are equal.
函数调用图:

◆ operator>>()

bool vlink::DynamicData::operator>> ( Bytes & bytes) const
noexcept

Serializes this DynamicData to a wire-format Bytes blob.

参数
bytesOutput buffer.
返回
true on success; false if the internal buffer is empty.

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