Hi!
I'm trying to redirect the output of print_data into a stringstream. I wrote the following code:
Foo *myFoo = Foo::TypeSupport::create_data();std::stringstream buffer;
std::streambuf * old = std::cout.rdbuf(buffer.rdbuf());
Foo::TypeSupport::print_data(myFoo);
std::string text = buffer.str(); // text will now contain "Bla\n"
std::cout.rdbuf(old);Foo::TypeSupport::delete_data(status);
But the ouput of print_data is still written in the standard output.
Note that if I replace "Foo::TypeSupport::print_data(myFoo)" by "std::cout << "Print MyFoo;", the string "Print MyFoo" is correctly saved in my buffer stringstream.
Do you know how is printed the print_data output ? Using a printf? Something else?
Thank you for your help :-)
Lucie
DDS_UnsignedLong size = 10; char test [size]; DDS_PrintFormatProperty format; retcode = testTypeSupport::data_to_string(&data_seq[i], test, size, format); if (retcode != DDS_RETCODE_OK) { fprintf(stderr, "return data_to_string error %d\n", retcode); } else { printf("Received data %s . Size %d\n", test, size); }