Boost logo

Boost Users :

Subject: [Boost-users] [iostreams] Can I apply different char_type on a chain of filters?
From: Ìð¹Ï (littlesweetmelon_at_[hidden])
Date: 2011-03-24 21:44:02


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

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net