0
是否有可能爲更復雜/結構化的類型使用boost :: iostreams?使用boost :: stream更復雜/結構化類型,然後字符?
我想要做的就是流式傳輸的圖像,但他們應該有一些註解像寬度,高度,色彩深度,...我的第一個想法是使用結構,而不是一個字符或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;
}
};
我現在的問題是如何連接源和接收器?
THX