0

より複雑な/構造化されたタイプにboost::iostreamsを使用することは可能ですか?

私がやりたいのは画像をストリーミングすることですが、幅、高さ、色深度などの注釈が必要です...私の最初のアイデアは、charまたは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;
    }     
};

私の問題は、ソースとシンクをどのように接続できるかです。

どうも

4

1 に答える 1