
25 Mar
2011
25 Mar
'11
1:44 a.m.
Hi, all, I usually want to read a file, and group the bytes into some object (eg: struct MyData) for further use. boost::iostreams provides the filtering_stream, but it seems all filters along the chain MUST have the same char_type. Is there a way that transform a byte stream into MyData stream? eg: ifstream file("d.gz", ios_base::in | ios_base::binary); filtering_streambuf<input> in; in.push(MyDataExtractor()); in.push(gzip_decompressor()); in.push(file); class MyDataExtractor { public: typedef MyData char_type; struct category ...; template<typename Source> std::streamsize read(Source& src, char_type* s, std::streamsize n) {...} }; Thank you in advance! -- melon