31 #include <type_traits>
34 #include "../base/helpers.h"
35 #include "../base/logger.h"
36 #include "../base/name_detector.h"
37 #include "../base/traits.h"
38 #include "../serializer.h"
40 #ifndef VLINK_DDS_IDL_PREFIX
41 #define VLINK_DDS_IDL_PREFIX "dds::"
44 #if defined(VLINK_SUPPORT_CDR) || defined(VLINK_SUPPORT_ROS2)
45 #if __has_include(<fastcdr/Cdr.h>)
46 #include <fastcdr/Cdr.h>
47 #if FASTCDR_VERSION_MAJOR >= 2
48 #include <fastcdr/CdrSizeCalculator.hpp>
54 #warning "Fast CDR headers are required when CDR serialization support is enabled."
58 #ifdef VLINK_SUPPORT_ROS2
59 #if defined(VLINK_HAS_CDR) && __has_include(<rosidl_typesupport_fastrtps_cpp/message_type_support.h>)
60 #include <rosidl_typesupport_fastrtps_cpp/message_type_support.h>
62 #include <rosidl_runtime_cpp/traits.hpp>
63 #include <rosidl_typesupport_fastrtps_cpp/message_type_support_decl.hpp>
64 #ifndef VLINK_HAS_ROS2
65 #define VLINK_HAS_ROS2
67 #elif defined(VLINK_HAS_CDR)
68 #warning "ROS 2 message headers are required when ROS 2 message support is enabled."
72 #if __has_include(<google/protobuf/message_lite.h>)
73 #ifndef VLINK_HAS_PROTOBUF
74 #define VLINK_HAS_PROTOBUF
76 #include <google/protobuf/message_lite.h>
79 #if __has_include(<flatbuffers/flatbuffers.h>)
80 #ifndef VLINK_HAS_FLATBUFFERS
81 #define VLINK_HAS_FLATBUFFERS
83 #include <flatbuffers/flatbuffers.h>
94 inline constexpr
bool is_ros2_msg_type() noexcept {
96 return rosidl_generator_traits::is_message<RealType>::value;
100 inline const message_type_support_callbacks_t* get_ros2_msg_callbacks() noexcept {
101 const auto* type_support = rosidl_typesupport_fastrtps_cpp::get_message_type_support_handle<T>();
102 return type_support ?
static_cast<const message_type_support_callbacks_t*
>(type_support->data) :
nullptr;
106 template <
typename T>
109 if constexpr (!std::is_same_v<
typename T::weak_type, std::weak_ptr<typename T::element_type>>) {
114 if constexpr (is_bytes_type<T>()) {
116 }
else if constexpr (is_dynamic_type<T>()) {
118 }
else if constexpr (is_someip_type<T>()) {
121 }
else if constexpr (is_cdr_type<T>()) {
124 #ifdef VLINK_HAS_PROTOBUF
125 }
else if constexpr (is_proto_type<T>()) {
127 }
else if constexpr (is_proto_ptr_type<T>()) {
130 #ifdef VLINK_HAS_FLATBUFFERS
131 }
else if constexpr (is_flat_table_type<T>()) {
133 }
else if constexpr (is_flat_ptr_type<T>()) {
135 }
else if constexpr (is_flat_builder_type<T>()) {
138 }
else if constexpr (is_custom_type<T>()) {
140 }
else if constexpr (is_string_type<T>()) {
142 }
else if constexpr (is_chars_type<T>()) {
144 }
else if constexpr (is_standard_type<T>()) {
146 }
else if constexpr (is_standard_ptr_type<T>()) {
148 }
else if constexpr (is_stream_type<T>()) {
155 template <Type TypeT,
typename T>
156 inline static constexpr
SchemaType get_schema_type() noexcept {
163 if constexpr (RealType::kZerocopyTypes) {
169 return RealType::get_schema_type();
173 #ifdef VLINK_HAS_PROTOBUF
177 #ifdef VLINK_HAS_FLATBUFFERS
182 }
else if constexpr (TypeT ==
kCdrType) {
190 template <
typename T>
191 inline static constexpr
SchemaType get_schema_type() noexcept {
192 constexpr
auto kType = get_type_of<T>();
194 return get_schema_type<kType, T>();
197 template <Type TypeT,
typename T>
200 using NamedType = std::remove_pointer_t<RealType>;
205 return "vlink::DynamicData";
208 #ifdef VLINK_HAS_PROTOBUF
210 return std::string(NamedType{}.GetTypeName());
212 #ifdef VLINK_HAS_FLATBUFFERS
214 using TableType =
typename RealType::TableType;
216 return TableType::GetFullyQualifiedName();
218 std::string name = NameDetector::get<TableType>().data();
223 using TableType =
typename RealType::Table;
225 return TableType::GetFullyQualifiedName();
227 std::string name = NameDetector::get<TableType>().data();
232 using TableType = std::remove_pointer_t<T>;
234 return TableType::GetFullyQualifiedName();
236 std::string name = NameDetector::get<TableType>().data();
241 #ifdef VLINK_HAS_ROS2
242 }
else if constexpr (TypeT ==
kCdrType && is_ros2_msg_type<RealType>()) {
243 const auto* callbacks = get_ros2_msg_callbacks<RealType>();
245 if VUNLIKELY (!callbacks || !callbacks->message_namespace_ || !callbacks->message_name_) {
249 std::string name(callbacks->message_namespace_);
250 name.append(
"::dds_::").append(callbacks->message_name_).append(
"_");
256 }
else if constexpr (NameDetector::is_support<NamedType>()) {
257 return NameDetector::get<NamedType>().data();
263 template <
typename T>
265 constexpr
auto kType = get_type_of<T>();
267 return get_serialized_type<kType, T>();
270 template <Type TypeT,
typename T>
285 }
else if constexpr (TypeT ==
kCdrType) {
287 #ifdef VLINK_HAS_ROS2
288 if constexpr (is_ros2_msg_type<RealType>()) {
289 const auto* callbacks = get_ros2_msg_callbacks<RealType>();
291 if VUNLIKELY (!callbacks || !callbacks->get_serialized_size) {
295 const size_t payload_size = callbacks->get_serialized_size(&
deref(src));
296 return payload_size <= std::numeric_limits<uint32_t>::max() - 4U ? payload_size + 4U : 0U;
300 const size_t payload_size = RealType::getCdrSerializedSize(
deref(src));
301 return payload_size <= std::numeric_limits<uint32_t>::max() - 4U ? payload_size + 4U : 0U;
302 #if FASTCDR_VERSION_MAJOR >= 2
304 eprosima::fastcdr::CdrSizeCalculator calculator(eprosima::fastcdr::CdrVersion::XCDRv1);
305 size_t current_alignment = 0;
306 const size_t payload_size = calculator.calculate_serialized_size(
deref(src), current_alignment);
307 return payload_size <= std::numeric_limits<uint32_t>::max() - 4U ? payload_size + 4U : 0U;
313 #ifdef VLINK_HAS_ROS2
316 }
catch (
const eprosima::fastcdr::exception::Exception&) {
318 }
catch (
const std::exception&) {
322 #ifdef VLINK_HAS_PROTOBUF
325 return deref(src).ByteSizeLong();
327 return deref(src).ByteSize();
331 return src->ByteSizeLong();
333 return src->ByteSize();
338 return deref(src).get_serialized_size();
347 template <
typename T>
349 constexpr
auto kType = get_type_of<T>();
351 return get_serialized_size<kType>(src);
354 template <Type TypeT,
typename T>
356 [[maybe_unused]] uint8_t offset) {
368 using ReturnT = decltype(
deref(src) >> des);
370 if constexpr (std::is_convertible_v<ReturnT, bool>) {
372 VLOG_T(
"Serializer: Dynamic serialize failed.");
379 }
else if constexpr (TypeT ==
kCdrType) {
380 const size_t target_size = get_serialized_size<TypeT>(src);
382 if VUNLIKELY (target_size < 4U || target_size > std::numeric_limits<uint32_t>::max()) {
383 VLOG_W(
"Serializer: FastBuffer serialized size is invalid.");
398 eprosima::fastcdr::FastBuffer buffer(
reinterpret_cast<char*
>(des.
data()), des.
size());
399 #if FASTCDR_VERSION_MAJOR >= 2
401 ? eprosima::fastcdr::CdrVersion::DDS_CDR
402 : eprosima::fastcdr::CdrVersion::XCDRv1;
403 eprosima::fastcdr::Cdr cdr(buffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, kCdrVersion);
404 if constexpr (kCdrVersion == eprosima::fastcdr::CdrVersion::XCDRv1) {
405 cdr.set_encoding_flag(eprosima::fastcdr::EncodingAlgorithmFlag::PLAIN_CDR);
408 eprosima::fastcdr::Cdr cdr(buffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR);
410 cdr.serialize_encapsulation();
412 #ifdef VLINK_HAS_ROS2
413 if constexpr (is_ros2_msg_type<RealType>()) {
414 const auto* callbacks = get_ros2_msg_callbacks<RealType>();
416 if VUNLIKELY (!callbacks || !callbacks->cdr_serialize || !callbacks->cdr_serialize(&
deref(src), cdr)) {
422 deref(src).serialize(cdr);
423 #if FASTCDR_VERSION_MAJOR >= 2
428 #ifdef VLINK_HAS_ROS2
431 }
catch (
const eprosima::fastcdr::exception::Exception& e) {
432 VLOG_T(
"Serializer: FastBuffer serialize failed: ", e.what(),
".");
434 }
catch (
const std::exception& e) {
435 VLOG_T(
"Serializer: CDR serialize failed: ", e.what(),
".");
439 #ifdef VLINK_HAS_PROTOBUF
443 size_t target_size =
deref(src).ByteSizeLong();
449 size_t target_size =
deref(src).ByteSize();
458 VLOG_T(
"Serializer: Protobuf serialize failed.");
464 size_t target_size = src->ByteSizeLong();
470 size_t target_size = src->ByteSize();
479 VLOG_T(
"Serializer: Protobuf ptr serialize failed.");
483 #ifdef VLINK_HAS_FLATBUFFERS
485 flatbuffers::FlatBufferBuilder fbb;
486 fbb.Finish(RealType::TableType::Pack(fbb, &
deref(src)));
488 if (des.
is_loaned() && des.
size() >= fbb.GetSize() + offset) {
489 std::memcpy(des.
data() + offset, fbb.GetBufferPointer(), fbb.GetSize());
498 auto& mutable_src =
const_cast<T&
>(src);
499 mutable_src.fbb_.Finish(mutable_src.Finish());
500 des =
Bytes::deep_copy(mutable_src.fbb_.GetBufferPointer(), mutable_src.fbb_.GetSize(), offset);
506 VLOG_T(
"Serializer: SOME/IP serialize failed.");
510 using ReturnT = decltype(
const_cast<RealType&
>(
deref(src)) >> des);
512 if constexpr (std::is_convertible_v<ReturnT, bool>) {
514 VLOG_T(
"Serializer: Custom serialize failed.");
518 const_cast<RealType&
>(
deref(src)) >> des;
529 if constexpr (std::is_array_v<T>) {
530 constexpr
size_t kExtent = std::extent_v<T>;
531 const auto* terminator =
static_cast<const char*
>(std::memchr(src,
'\0', kExtent));
534 VLOG_T(
"Serializer: Chars array is not null-terminated.");
538 size =
static_cast<size_t>(terminator - src);
541 VLOG_T(
"Serializer: Chars source is null.");
545 size = std::strlen(src);
548 des =
Bytes::deep_copy(
reinterpret_cast<const uint8_t*
>(src), size, offset);
550 std::stringstream ss;
552 const std::string str = ss.str();
553 des =
Bytes::deep_copy(
reinterpret_cast<const uint8_t*
>(str.data()), str.size(), offset);
555 const auto* src_ptr =
reinterpret_cast<const uint8_t*
>(&
deref(src));
559 VLOG_T(
"Serializer: Standard ptr does not support offset.");
563 const auto* src_ptr =
reinterpret_cast<const uint8_t*
>(src);
564 constexpr
size_t kSize =
sizeof(std::remove_pointer_t<T>);
567 std::memcpy(des.
data(), src_ptr, kSize);
579 template <
typename T>
581 constexpr
auto kType = get_type_of<T>();
586 template <Type TypeT,
typename T,
typename LoanCallbackT>
588 LoanCallbackT&& loan) {
589 #ifdef VLINK_HAS_FLATBUFFERS
591 auto& mutable_src =
const_cast<T&
>(src);
592 mutable_src.fbb_.Finish(mutable_src.Finish());
594 const size_t size = mutable_src.fbb_.GetSize();
597 des = std::forward<LoanCallbackT>(loan)(size);
603 std::memcpy(des.
data(), mutable_src.fbb_.GetBufferPointer(), size);
612 const size_t size = get_serialized_size<TypeT>(src);
617 des = std::forward<LoanCallbackT>(loan)(size);
626 auto* loan_data = des.
data();
627 const size_t loan_size = des.
size();
628 const bool ret = serialize<TypeT>(src, des, transport);
636 #ifdef VLINK_HAS_FLATBUFFERS
641 template <Type TypeT,
typename T>
655 using ReturnT = decltype(
deref(des) << src);
657 if constexpr (std::is_convertible_v<ReturnT, bool>) {
659 VLOG_T(
"Serializer: Dynamic deserialize failed.");
666 }
else if constexpr (TypeT ==
kCdrType) {
668 VLOG_T(
"Serializer: FastBuffer payload has no CDR encapsulation.");
673 eprosima::fastcdr::FastBuffer buffer(
reinterpret_cast<char*
>(
const_cast<uint8_t*
>(src.
data())), src.
size());
674 #if FASTCDR_VERSION_MAJOR >= 2
675 eprosima::fastcdr::Cdr cdr(buffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN,
676 eprosima::fastcdr::CdrVersion::DDS_CDR);
678 eprosima::fastcdr::Cdr cdr(buffer, eprosima::fastcdr::Cdr::DEFAULT_ENDIAN, eprosima::fastcdr::Cdr::DDS_CDR);
680 cdr.read_encapsulation();
682 #ifdef VLINK_HAS_ROS2
683 if constexpr (is_ros2_msg_type<RealType>()) {
684 const auto* callbacks = get_ros2_msg_callbacks<RealType>();
686 if VUNLIKELY (!callbacks || !callbacks->cdr_deserialize || !callbacks->cdr_deserialize(cdr, &
deref(des))) {
692 deref(des).deserialize(cdr);
693 #if FASTCDR_VERSION_MAJOR >= 2
698 #ifdef VLINK_HAS_ROS2
701 }
catch (
const eprosima::fastcdr::exception::Exception& e) {
702 VLOG_T(
"Serializer: FastBuffer deserialize failed: ", e.what(),
".");
704 }
catch (
const std::exception& e) {
705 VLOG_T(
"Serializer: CDR deserialize failed: ", e.what(),
".");
709 #ifdef VLINK_HAS_PROTOBUF
713 VLOG_T(
"Serializer: Protobuf deserialize failed.");
722 VLOG_T(
"Serializer: Protobuf ptr deserialize failed.");
729 #ifdef VLINK_HAS_FLATBUFFERS
731 deref(des) = RealType{};
734 flatbuffers::Verifier verifier(src.
data(), src.
size());
736 if VUNLIKELY (!verifier.VerifyBuffer<
typename RealType::TableType>(
nullptr)) {
737 VLOG_T(
"Serializer: Flatbuffers table deserialize failed.");
741 auto target = flatbuffers::GetRoot<typename RealType::TableType>(src.
data());
742 target->UnPackTo(&
deref(des));
745 flatbuffers::Verifier verifier(src.
data(), src.
size());
747 if VUNLIKELY (!verifier.VerifyBuffer<std::remove_pointer_t<T>>(
nullptr)) {
748 VLOG_T(
"Serializer: Flatbuffers ptr verify failed.");
752 des =
const_cast<T
>(flatbuffers::GetRoot<std::remove_pointer_t<T>>(src.
data()));
755 VLOG_T(
"Serializer: Flatbuffers ptr deserialize failed.");
761 VLOG_T(
"Serializer: SOME/IP deserialize failed.");
765 using ReturnT = decltype(
deref(des) << src);
767 if constexpr (std::is_convertible_v<ReturnT, bool>) {
769 VLOG_T(
"Serializer: Custom deserialize failed.");
777 deref(des).assign(
reinterpret_cast<const char*
>(src.
data()), src.
size());
784 VLOG_E(
"Serializer: Chars deserialization is not supported; use std::string.");
787 std::stringstream ss(std::string(
reinterpret_cast<const char*
>(src.
data()), src.
size()));
792 VLOG_T(
"Serializer: Stream deserialize failed.");
799 VLOG_T(
"Serializer: Standard layout deserialize failed.");
803 if VLIKELY (!src.
empty() && src.
size() ==
sizeof(std::remove_pointer_t<T>)) {
804 des =
reinterpret_cast<T
>(
const_cast<uint8_t*
>(src.
data()));
806 VLOG_T(
"Serializer: Standard ptr layout deserialize failed.");
817 template <
typename T>
819 constexpr
auto kType = get_type_of<T>();
823 template <
typename SrcT,
typename DesT>
824 inline bool convert(
const SrcT& src, DesT& des) {
825 static_assert(is_bytes_type<SrcT>() || is_bytes_type<DesT>(),
"SrcT or DesT must be Bytes.");
827 if constexpr (is_bytes_type<SrcT>() && is_bytes_type<DesT>()) {
828 des.shallow_copy(src);
830 }
else if constexpr (is_bytes_type<DesT>()) {
837 template <
typename T>
838 inline constexpr
auto&
deref(
const T& t) noexcept {
840 return *
const_cast<T&
>(t).
get();
842 return const_cast<T&
>(t);
846 template <
typename T>
848 return std::is_same_v<T, Bytes>;
851 template <
typename T>
857 template <
typename T>
862 #ifdef VLINK_HAS_ROS2
863 if constexpr (is_ros2_msg_type<RealType>()) {
876 template <
typename T>
878 #ifdef VLINK_HAS_PROTOBUF
886 template <
typename T>
888 #ifdef VLINK_HAS_PROTOBUF
889 return std::is_pointer_v<T> &&
VLINK_HAS_MEMBER(std::remove_pointer_t<T>, SerializeToArray(0, 0)) &&
896 template <
typename T>
898 #ifdef VLINK_HAS_FLATBUFFERS
900 return std::is_base_of_v<flatbuffers::NativeTable, RealType>;
906 template <
typename T>
908 #ifdef VLINK_HAS_FLATBUFFERS
915 template <
typename T>
917 #ifdef VLINK_HAS_FLATBUFFERS
918 return std::is_pointer_v<T> && std::is_base_of_v<flatbuffers::Table, std::remove_pointer_t<T>>;
924 template <
typename T>
930 template <
typename T>
936 template <
typename T>
939 return std::is_same_v<RealType, std::string>;
942 template <
typename T>
944 using DecayedType = std::decay_t<T>;
945 using CharType = std::remove_pointer_t<DecayedType>;
947 return std::is_pointer_v<DecayedType> && std::is_same_v<std::remove_cv_t<CharType>,
char> &&
948 !std::is_volatile_v<CharType>;
951 template <
typename T>
957 template <
typename T>
960 return !std::is_pointer_v<RealType> && std::is_trivial_v<RealType> && std::is_standard_layout_v<RealType>;
963 template <
typename T>
965 return std::is_pointer_v<T> && std::is_trivial_v<std::remove_pointer_t<T>> &&
966 std::is_standard_layout_v<std::remove_pointer_t<T>>;
Fixed-size 128-byte buffer holder with SBO, five ownership modes and integrated codecs.
Definition: bytes.h:120
bool empty() const noexcept
Reports whether the buffer is logically empty.
Definition: bytes.h:871
bool is_loaned() const noexcept
Reports whether the buffer is an iceoryx loan that VLink must not free.
Definition: bytes.h:869
static Bytes shallow_copy(uint8_t *data, size_t size) noexcept
Wraps an external mutable buffer as a non-owning alias.
size_t size() const noexcept
Returns the size of the payload region in bytes.
Definition: bytes.h:859
uint8_t * data() noexcept
Returns a mutable pointer to the start of the payload (post-offset).
Definition: bytes.h:851
static Bytes loan_internal(uint8_t *data, size_t size) noexcept
Wraps an iceoryx-loaned mutable payload as a non-owning, non-aliasing carrier.
uint8_t offset() const noexcept
Returns the reserved header offset preceding the payload.
Definition: bytes.h:865
static Bytes create(size_t size, uint8_t offset=0) noexcept
Allocates an owned buffer of the requested size with an optional header offset.
static Bytes deep_copy(uint8_t *data, size_t size, uint8_t offset=0) noexcept
Produces an owned copy of an external mutable buffer.
#define VLOG_E(...)
Definition: logger.h:904
#define VLOG_W(...)
Definition: logger.h:902
#define VLOG_T(...)
Definition: logger.h:896
#define VUNLIKELY(...)
Short alias for VLINK_UNLIKELY.
Definition: macros.h:292
#define VLIKELY(...)
Short alias for VLINK_LIKELY.
Definition: macros.h:284
Compile-time codec detection and dispatch for VLink message payloads.
constexpr bool contains_substring(std::string_view sv, std::string_view needle) noexcept
Constexpr substring search.
Definition: helpers.h:505
VLINK_EXPORT void replace_string(std::string &str, const std::string &from, const std::string &to) noexcept
Replaces all occurrences of from in str with to in place.
constexpr std::string_view get() noexcept
Returns the trimmed compile-time identifier for TypeT.
Definition: name_detector.h:603
constexpr bool is_proto_ptr_type() noexcept
Reports whether T is a raw pointer to a Protobuf-like message.
Definition: serializer-inl.h:887
std::string get_serialized_type() noexcept
Returns the serialised type-name string for T with explicit codec tag.
Definition: serializer-inl.h:264
constexpr bool is_dynamic_type() noexcept
Reports whether T is a VLink dynamic data type.
Definition: serializer-inl.h:852
constexpr bool is_chars_type() noexcept
Reports whether T is a pointer or array of non-volatile char.
Definition: serializer-inl.h:943
bool deserialize(const Bytes &src, T &des, [[maybe_unused]] TransportType transport)
Definition: serializer-inl.h:642
constexpr Type get_type_of() noexcept
Resolves the codec Type for T at compile time.
Definition: serializer-inl.h:107
Type
Identifies the codec to use for a given C++ message type.
Definition: serializer.h:156
@ kStandardPtrType
Pointer to trivial standard-layout struct (POD pointer).
Definition: serializer.h:172
@ kCustomType
User-defined codec via operator>>/<<.
Definition: serializer.h:160
@ kDynamicType
VLink dynamic typed data.
Definition: serializer.h:159
@ kFlatTableType
FlatBuffers NativeTable (object API).
Definition: serializer.h:165
@ kCharsType
C string serialisation; deserialise as std::string.
Definition: serializer.h:169
@ kUnknownType
Unsupported type; is_supported() returns false.
Definition: serializer.h:157
@ kBytesType
Bytes – raw byte pass-through.
Definition: serializer.h:158
@ kProtoPtrType
Protobuf-like raw pointer; caller-owned.
Definition: serializer.h:164
@ kStandardType
Trivial standard-layout struct (POD value).
Definition: serializer.h:171
@ kStringType
std::string payload bytes; no text-encoding validation.
Definition: serializer.h:168
@ kFlatBuilderType
FlatBuffers builder (fbb_ + Finish()).
Definition: serializer.h:167
@ kSomeipType
Macro-declared SOME/IP structure via operator>>/<<.
Definition: serializer.h:161
@ kStreamType
Stream-serialisable via std::stringstream.
Definition: serializer.h:170
@ kProtoType
Protobuf-like value.
Definition: serializer.h:163
@ kCdrType
FastDDS CDR via serialize(Cdr&) / deserialize(Cdr&).
Definition: serializer.h:162
@ kFlatPtrType
Pointer to flatbuffers::Table (zero-copy view).
Definition: serializer.h:166
constexpr auto & deref(const T &t) noexcept
Dereferences a value, unwrapping std::shared_ptr when present.
Definition: serializer-inl.h:838
constexpr bool is_supported(Type type) noexcept
Reports whether type identifies a usable codec.
Definition: serializer-inl.h:90
constexpr bool is_custom_type() noexcept
Reports whether T provides a custom operator>>/<< codec.
Definition: serializer-inl.h:931
constexpr bool is_someip_type() noexcept
Reports whether T is a macro-declared SOME/IP structure.
Definition: serializer-inl.h:925
size_t get_serialized_size(const T &src) noexcept
Returns a serialised-size hint for src with explicit codec tag.
Definition: serializer-inl.h:271
bool serialize_to_transport(const T &src, Bytes &des, TransportType transport, bool use_loan, LoanCallbackT &&loan)
Serialises into transport-provided storage when available.
Definition: serializer-inl.h:587
bool convert(const SrcT &src, DesT &des)
Converts between two types where at least one side is Bytes.
Definition: serializer-inl.h:824
constexpr bool is_cdr_type() noexcept
Reports whether T is a FastDDS CDR-serialisable type.
Definition: serializer-inl.h:858
constexpr bool is_proto_type() noexcept
Reports whether T is a Protobuf-like message value type.
Definition: serializer-inl.h:877
std::string get_serialized_type() noexcept
Returns the serialised type-name string for T with explicit codec tag.
Definition: serializer-inl.h:198
bool serialize(const T &src, Bytes &des, [[maybe_unused]] TransportType transport, [[maybe_unused]] uint8_t offset)
Definition: serializer-inl.h:355
constexpr bool is_flat_ptr_type() noexcept
Reports whether T is a raw pointer to a flatbuffers::Table.
Definition: serializer-inl.h:916
constexpr bool is_flat_builder_type() noexcept
Reports whether T is a FlatBuffers builder type.
Definition: serializer-inl.h:907
constexpr bool is_standard_ptr_type() noexcept
Reports whether T is a pointer to a trivial standard-layout type.
Definition: serializer-inl.h:964
constexpr bool is_standard_type() noexcept
Reports whether T is a trivial standard-layout value (POD).
Definition: serializer-inl.h:958
constexpr bool is_flat_table_type() noexcept
Reports whether T is a FlatBuffers NativeTable type.
Definition: serializer-inl.h:897
constexpr bool is_string_type() noexcept
Reports whether T is std::string after unwrapping shared_ptr.
Definition: serializer-inl.h:937
constexpr bool is_bytes_type() noexcept
Reports whether T is exactly Bytes.
Definition: serializer-inl.h:847
constexpr bool is_stream_type() noexcept
Reports whether T supports bidirectional std::stringstream streaming.
Definition: serializer-inl.h:952
SchemaType
Coarse runtime schema family used by discovery, bag metadata and proxy routing.
Definition: types.h:203
@ kZeroCopy
Decode through the VLink zero-copy structs.
@ kProtobuf
Decode through the Protocol Buffers stack.
@ kFlatbuffers
Decode through the FlatBuffers stack.
@ kRaw
Treat the payload as opaque bytes.
@ kCdr
Native DDS CDR payload including its encapsulation header.
TransportType
Enumeration of every transport backend recognised by VLink.
Definition: types.h:126
@ kUnknown
Unknown or unsupported transport.
Type trait that always derives from std::false_type for any T.
Definition: traits.h:103
Detects whether T is (or derives from) a std::shared_ptr specialisation.
Definition: traits.h:203
Detects whether OT supports stream insertion (<<) and extraction (>>) with T.
Definition: traits.h:167
T Type
Resolved type after optional shared_ptr removal.
Definition: traits.h:220
#define VLINK_HAS_MEMBER(T, member)
Macro Definitions
Definition: traits.h:325