Using boost::iostreams to parse a binary file byte by byte
        Posted  
        
            by Zsol
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Zsol
        
        
        
        Published on 2010-06-12T08:59:48Z
        Indexed on 
            2010/06/12
            9:02 UTC
        
        
        Read the original article
        Hit count: 548
        
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?
© Stack Overflow or respective owner