@@ -730,7 +730,7 @@ uint32_t sertype_rmw_hash(const struct ddsi_sertype * tpcmn)
730730 return h1 ^ h2;
731731}
732732
733- size_t sertype_get_serialized_size (const struct ddsi_sertype * d, const void * sample)
733+ static size_t sertype_get_serialized_size_impl (const struct ddsi_sertype * d, const void * sample)
734734{
735735 const struct sertype_rmw * type = static_cast <const struct sertype_rmw *>(d);
736736 size_t serialized_size = 0 ;
@@ -750,16 +750,13 @@ size_t sertype_get_serialized_size(const struct ddsi_sertype * d, const void * s
750750 return serialized_size;
751751}
752752
753- bool sertype_serialize_into (
753+ static bool sertype_serialize_into_impl (
754754 const struct ddsi_sertype * d,
755755 const void * sample,
756- void * dst_buffer,
757- size_t dst_size)
756+ void * dst_buffer)
758757{
759758 const struct sertype_rmw * type = static_cast <const struct sertype_rmw *>(d);
760759 try {
761- // ignore destination size (assuming that the destination buffer is resized before correctly)
762- static_cast <void >(dst_size);
763760 // ROS 2 doesn't support keys, so its all data (?)
764761 if (!type->is_request_header ) {
765762 type->cdr_writer ->serialize (dst_buffer, sample);
@@ -776,6 +773,53 @@ bool sertype_serialize_into(
776773 return true ;
777774}
778775
776+ #if CDDS_VERSION == CDDS_VERSION_0_10
777+ size_t sertype_get_serialized_size (const struct ddsi_sertype * d, const void * sample)
778+ {
779+ return sertype_get_serialized_size_impl (d, sample);
780+ }
781+
782+ bool sertype_serialize_into (
783+ const struct ddsi_sertype * d,
784+ const void * sample,
785+ void * dst_buffer,
786+ size_t dst_size)
787+ {
788+ static_cast <void >(dst_size);
789+ return sertype_serialize_into_impl (d, sample, dst_buffer);
790+ }
791+ #else
792+ dds_return_t sertype_get_serialized_size (
793+ const struct ddsi_sertype * d,
794+ enum ddsi_serdata_kind sdkind,
795+ const void * sample,
796+ size_t * size,
797+ uint16_t * enc_identifier)
798+ {
799+ static_cast <void >(sdkind);
800+ size_t serialized_size = sertype_get_serialized_size_impl (d, sample);
801+ // encoding identifier is always plain CDR for this serializer
802+ *enc_identifier = (native_endian () == endian::little) ? DDSI_RTPS_CDR_LE : DDSI_RTPS_CDR_BE;
803+ // Cyclone's including or excluding the CDR encoding header in the various situations is
804+ // painfully inconsistent ...
805+ assert (serialized_size >= 4 );
806+ *size = serialized_size - 4 ;
807+ return DDS_RETCODE_OK;
808+ }
809+
810+ bool sertype_serialize_into (
811+ const struct ddsi_sertype * d,
812+ enum ddsi_serdata_kind sdkind,
813+ const void * sample,
814+ void * dst_buffer,
815+ size_t dst_size)
816+ {
817+ static_cast <void >(sdkind);
818+ static_cast <void >(dst_size);
819+ return sertype_serialize_into_impl (d, sample, dst_buffer);
820+ }
821+ #endif
822+
779823#if DDS_HAS_TYPELIB
780824static ddsi_typeid_t * sertype_rmw_typeid (const struct ddsi_sertype * d, ddsi_typeid_kind_t kind)
781825{
0 commit comments