For my current task I need a possibility to read/write (mostly file based) bitstreams. Though this is a more or less trivial task if coded in standard C/C++ I'd like to rewrite to code using a more generic approach by overloading and using the standard STL iostream or similar so I can write something like
writeHeader();
{
ofstream outfile ("test.bin");
outfile << true; // Write 1 bit
outfile << false; // Write 1 bit
outfile << (char)0x42; // Write 8 bits
}
However I'm not sure which road to go:
- Using Boost.IOStream or
- Derive from streambuf or iostream directly.
So far I never had to derive/provide my own stream classes but I want to improve my knowledge...
Maybe someone can provide some pointers or hints which way to prefer and why!?
Thanks!