writing multifile from memory

Edit: This was about how to write to a multifile from memory, but I found it shortly afterwards. For reference: mf->add_subfile( “test”, ifstream, …

I’m not 100% sure what you’re asking. You mean you’re building up a multifile, and you want to call add_subfile() to add data to that subfile, without first having to write that data to a temporary file? There’s a version of add_subfile() that accepts an istream. Use an istringstream here. You have to be sure the istringstream pointer stays valid until the next call to flush().

David

Oh too late. Yeah I noticed it now, I don’t know why I didn’t see it (I guess I was paying too much attention to the manual page). It suits my needs perfectly -because I’m already using a fstream-.

This took me a while to figure out, because I was trying to use a stringbuffer. So, for future reference:

std::ostringstream os (std::ios::in | std::ios::out);
std::istream is (os.rdbuf ());

os.write((char*)&stuff, sizeof(stuff));

PT(Multifile) mf = new Multifile();
mf->open_write(fileName);
mf->add_subfile("filename.ext", &is, 5);
mf->flush();
mf->close();

One of my favorite features of Panda is that it uses the standard library. Why do people always reinvent the std in their frameworks and add their own classes for strings, iterators, etc? Is the std supposed to be slow or something? Cause of internationalization issues? Just curious.