Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/print-sample-into-trace #478

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/ddscxx/include/org/eclipse/cyclonedds/topic/datatopic.hpp
Expand Up @@ -11,6 +11,7 @@
#ifndef DDSCXXDATATOPIC_HPP_
#define DDSCXXDATATOPIC_HPP_

#include <algorithm>
#include <memory>
#include <string>
#include <cstring>
Expand Down Expand Up @@ -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<ddscxx_serdata<T>*>(static_cast<const ddscxx_serdata<T>*>(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 <typename T>
Expand Down