diff --git a/src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp b/src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp index 9b14df9b..419b5f50 100644 --- a/src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp +++ b/src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp @@ -11,6 +11,7 @@ #ifndef DDSCXXDATATOPIC_HPP_ #define DDSCXXDATATOPIC_HPP_ +#include #include #include #include @@ -623,10 +624,24 @@ size_t serdata_print( { (void)tpcmn; (void)dcmn; - //implementation to follow!!! - if (bufsize > 0) - buf[0] = 0x0; - return 0; + + size_t copy_len = 0; + auto d = const_cast*>(static_cast*>(dcmn)); + auto t_ptr = d->getT(); + + if (t_ptr) { + std::stringstream ss; + ss << *t_ptr; + + const std::string data = ss.str(); + const size_t len = data.size(); + copy_len = len < bufsize ? len : bufsize; + + std::copy_n(data.c_str(), copy_len, buf); + buf[len < bufsize ? copy_len : copy_len - 1] = '\0'; + } + + return copy_len; } template