|
VLink
2.0.0
A high-performance communication middleware
|
Compile-time codec dispatch for VLink message payloads. 更多...
#include <string>#include "./base/bytes.h"#include "./impl/types.h"#include "./internal/serializer-inl.h"命名空间 | |
| vlink | |
| Serializer | |
| Compile-time codec detection and dispatch for VLink message payloads. | |
| vlink::Serializer | |
枚举 | |
| enum | vlink::Serializer::Type : uint8_t { vlink::Serializer::kUnknownType = 0 , vlink::Serializer::kBytesType = 1 , vlink::Serializer::kDynamicType = 2 , vlink::Serializer::kCustomType = 3 , vlink::Serializer::kCdrType = 4 , vlink::Serializer::kProtoType = 5 , vlink::Serializer::kProtoPtrType = 6 , vlink::Serializer::kFlatTableType = 7 , vlink::Serializer::kFlatPtrType = 8 , vlink::Serializer::kFlatBuilderType = 9 , vlink::Serializer::kStringType = 10 , vlink::Serializer::kCharsType = 11 , vlink::Serializer::kStreamType = 12 , vlink::Serializer::kStandardType = 13 , vlink::Serializer::kStandardPtrType = 14 } |
| Identifies the codec to use for a given C++ message type. 更多... | |
函数 | |
| constexpr bool | vlink::Serializer::is_supported (Type type) noexcept |
Reports whether type identifies a usable codec. 更多... | |
Compile-time codec dispatch for VLink message payloads.
The Serializer namespace is the codec router used by every VLink primitive. Given a C++ type T it determines, at compile time, which encoding family applies (raw bytes, Protobuf, FlatBuffers, FastDDS CDR, standard-layout POD, etc.) and dispatches serialize() / deserialize() to the appropriate code path with zero runtime cost.
Application code rarely calls these helpers directly; Publisher, Subscriber, Client, Server, Setter, and Getter call them internally as part of their publish() / listen() / invoke() / set() / get() implementations.
Serializer::Type Enum| Constant | C++ Type Criterion | Trait check | Notes |
|---|---|---|---|
kBytesType | T == Bytes | is_bytes_type | Pass-through, no codec. |
kDynamicType | Has is_vlink_dynamic_data() | is_dynamic_type | Dynamic typed data. |
kCdrType | Has serialize/deserialize(Cdr&) | is_cdr_type | FastDDS CDR fast path. |
kProtoType | Has SerializeToArray/ParseFromArray | is_proto_type | Protobuf-like value. |
kProtoPtrType | Pointer with proto serialize/parse | is_proto_ptr_type | Caller owns the pointee. |
kFlatTableType | Derives from FB NativeTable | is_flat_table_type | FlatBuffers object API. |
kFlatPtrType | Pointer to flatbuffers::Table | is_flat_ptr_type | Zero-copy FlatBuffers view. |
kFlatBuilderType | Has fbb_ member and Finish() | is_flat_builder_type | FlatBuffers builder. |
kCustomType | Has operator>>/<<(Bytes&) | is_custom_type | User-supplied codec. |
kStringType | T == std::string | is_string_type | UTF-8 string. |
kCharsType | String-constructible (not string) | is_chars_type | C string / char*. |
kStreamType | Streamable via std::stringstream | is_stream_type | Reached only as fallback. |
kStandardType | Trivial standard-layout value (POD) | is_standard_type | sizeof(T) byte copy. |
kStandardPtrType | Pointer to trivial standard-layout | is_standard_ptr_type | Zero-copy POD pointer. |
Most value-like detectors unwrap std::shared_ptr<T> before matching (e.g. Protobuf values, CDR values, FlatBuffers native tables, custom codecs, strings, stream types, and standard-layout values).
* get_type_of<T>() probes traits in this fixed order; first match wins: * * Bytes --(no)--> Dynamic --(no)--> CDR --(no)--> Proto * | * v (no) * FlatPtr <--(no)-- FlatTable <--(no)-- ProtoPtr <--(no)--+ * | * v (no) * FlatBuilder --(no)--> Custom --(no)--> String --(no)--> Chars * | * v (no) * Stream <--(no)-- StandardPtr <--(no)-- Standard <--(no)----+ * | * v (no) * kUnknownType *
dds://) use pointer passing for CDR types. Use the explicit overloads to opt into the transport-specific path: static or inline where appropriate.