[quote author="devlikeme" date="1340723379"]Thanks to your advice, I began to see how to do ...
My understanding is the following, I have a friend ostream& operator<<() in a class. I use a QdataStream << operator in my Qt Application. So I need a buffer for my ostream to send that buffer to the QDataStream.
My first problem being buffering my ostream, thanks to google, i think but i'm not sure that rdbuf is my solution.
My second problem is what can I do with my buffer, again with no certainty, i believe that using streambuf::sgetc I might be able to create a QDataStream using the QDataStream & operator<< ( const char * s )
Google lost me my friend :( I really need a "how to" on this one because i'm lost between the documentations of C++ reference and Qt. They are sometimes hard to understand. I'm going to try what i explainded. I'll post my code if I succeed :)
[/quote]
No, you do not have to make so complicated.
Your ostream & operator<< can be used directly with an ostringstream. E.g.
@
#include <sstream> // required for ostringstream
void foo ()
{
std :: ostringstream ostr;
int nr = 10;
ostr << nr; // streams 10 to ostr;
string str = ostr.str(); // copies the ostringstream to a string
}
@