|
VLink
2.0.0
A high-performance communication middleware
|
Self-describing serialised payload tagged with an inline type name. 更多...
类 | |
| class | vlink::DynamicData |
| Type-erased wrapper that pairs an inline type name with a serialised payload. 更多... | |
命名空间 | |
| vlink | |
Self-describing serialised payload tagged with an inline type name.
DynamicData carries a serialised VLink-compatible message together with a short type-name tag inside a single Bytes buffer. The first kOffset = 20 bytes of the buffer hold the type name (NUL-padded), and the remainder holds the payload as produced by Serializer. This layout lets transports route, log and inspect a payload without knowing its concrete C++ type at compile time – the recipient picks the matching deserialiser at run time using the embedded tag.
Supported dynamic categories (chosen automatically by Serializer):
| Category | Examples | Notes |
|---|---|---|
| Protobuf | MyProto, std::shared_ptr<P> | Encoded with the message's wire format |
| FlatBuffer | MyTable, FlatPtr<T> | Encoded via FlatBuilder |
| POD/Std | int, struct Foo (trivial) | Standard layout copy |
| Bytes | vlink::Bytes | Stored verbatim |
| String | std::string | Length-prefixed |
| Chars | char[N], const char* | NUL-terminated |
| Custom | Types with explicit Serializer | User-provided serialise/deserialise hooks |
Two categories are forbidden and rejected by static_assert: nested DynamicData (avoids recursive type-name layout) and CDR types (their wire format does not allow the in-place prefix used here). The type-name literal (including its trailing NUL) must fit in fewer than kOffset bytes.
Buffer layout:
* +----------------------------+-----------------------------------------+ * | type name (20 bytes max) | serialised payload | * +----------------------------+-----------------------------------------+ * ^ ^ * data_.real_data() data_.real_data() + kOffset *