Using boost::iostreams to parse a binary file byte by byte
- by Zsol
So I would like to parse a binary file and extract some data from it. The problem I am facing with this is that I need to convert a stream of chars to a stream of unsigned chars.
Reading the boost documentation, it seems that boost::iostreams::code_converter should be the solution for this, so I tried this:
typedef unsigned char uint8_t;
typedef boost::iostreams::stream<boost::iostreams::code_converter<
boost::iostreams::basic_array_source<uint8_t> >,
std::codecvt<uint8_t, char, std::mbstate_t> > array_stream;
The idea was to specify a codecvt with InternalType=uint8_t and ExternalType=char. Unfortunately this does not compile.
So the question is: how do I convert a stream of chars to a stream of uint8_ts?