2

I have an external library which is able to write a bunch of data by passing it a std::ostream* pointer. It writes in binary format

I want to write this data inside a text file, which contains other stuff, by converting it to hexadecimal or base64.

As the data written by the lib can be very large, I want to avoid writing the data to a memory buffer, then convert to text format. I would like to convert on the fly.

Therefore, I am searching how to overload std::streambuf for that purpose. I need to overload the overflow virtual function, and I found the necessary info for this.

The question is, should I write to the file's ostream, or directly to its streambuf which I can get using rdbuf()? Is it allowed to write directly to a stream stringbuf?

Thanks in advance!

galinette
  • 8,896
  • 2
  • 36
  • 87

0 Answers0