I'm using boost.serialization to send some data over a socket. I believe I can only serialize to fstream or to stringstream (the only two classes that inherit iostream) so I chose stringstream as my memory buffer. am i correct in this choice?
std::stringstream outbuffer(std::stringstream::out);
{
boost::archive::text_oarchive outarchive(outbuffer);
outarchive & frame; //serialize my data frame
}
So now I think I can send over my socket starting at outbuffer.str().c_str(), for length outbuffer.str().length(). I emulate this with a copy.
size_t outlength = outbuffer.str().length();
const std::string outstr = outbuffer.str();
const char* outraw = outbuffer.str().c_str();
std::vector<char> RecvBuffer;
RecvBuffer.resize(outlength); //edited
std::copy(outraw, outraw+outlength, RecvBuffer.begin());
i see the string contents are correct, but why can't i see the contents in the equivalent c_str?
[Edited by - thedustbustr on June 12, 2008 10:45:00 AM]