c++ - Using boost::stream for more complex/structuered types then chars? -


is possible use boost::iostreams more complex / structured types?

what want stream images should have annotations width, height, color depth,... first idea use struct instead of char or wchar

namespace io = boost::iostreams;  struct singleimagestream{    unsigned int  width;    unsigned int height;    unsigned char colordepth;    unsigned char* frame; };   class singleimagesource { public:     typedef struct singleimagestream            char_type;     typedef io::source_tag  category;      std::streamsize read(struct singleimagestream* s, std::streamsize n)     {         char* frame = new char[640*480];         std::fill( frame, frame + sizeof( frame ), 0 );          s->width = 640;         s->height = 480;          std::copy(frame, frame + sizeof(frame), s->frame);          return -1;     }     };   class singleimagesink { public:     typedef struct singleimagestream        char_type;     typedef io::sink_tag                    category;      std::streamsize write(const struct singleimagestream* s, std::streamsize n)     {             std::cout << "frame width : " << s->width << " frame height : " << s->height << std::endl;             return n;     }      }; 

my problem how connect source , sink?

thx

boost.iostreams seems wrong tool job here.

the goal of source , sink mechanism allow specify where data gets serialized to - example whether want write file, location in memory or i/o port.

what want specify how kind of data gets serialized. correct tool in boost boost.serialization.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -