Runtime-typed container that serializes any VLink-compatible message type.
更多...
#include <dynamic_data.h>
|
| | DynamicData () |
| | Constructs an empty DynamicData with no payload.
|
| template<uint8_t SizeT, typename T> |
| DynamicData & | load (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> |
| T | as () const |
| | Deserializes the internal buffer and returns the result by value.
|
| const Bytes & | get_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.
|
|
| 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 |
( |
| ) |
|
◆ 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.
- 模板参数
-
| T | Message 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.
- 模板参数
-
| T | Message type to deserialize into. |
- 参数
-
| t | Output 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).
- 模板参数
-
| SizeT | Length of the type-name string literal including NUL. |
| T | Message type to serialize (must be supported by Serializer). |
- 参数
-
| type | Type name string literal, e.g., "MyProtoMsg". |
| t | Message 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.
- 参数
-
- 返回
true if the raw bytes differ.
◆ operator<<()
| bool vlink::DynamicData::operator<< |
( |
const Bytes & | bytes | ) |
|
|
noexcept |
Deserializes a wire-format Bytes blob into this DynamicData.
- 参数
-
| bytes | Wire-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.
- 参数
-
- 返回
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.
- 参数
-
- 返回
true on success; false if the internal buffer is empty.
该类的文档由以下文件生成: