Boost logo

Boost Users :

From: Robert Dodier (robert.dodier_at_[hidden])
Date: 2022-03-28 06:17:50

Hi Gavin, hi everyone. I'm thinking about the concatenated input
stream concept off and on, and I'd like to ask for some help in
organizing a solution.

The easy part to me is figuring out how to manage a collection of
input doodads (be they streams, stream buffers, sources, or whatever)
and satisfy read requests by getting the requested characters from one
or more of them. I have some experience with C++ development (from
about 20+ years ago, so C++03 is, for better or worse, maybe more
familiar to me ...) and so I feel pretty comfortable with the whole
business about classes, constructors, methods, etc.

What I need is for someone to give me some advice about how to
organize the class declarations. Of which existing Boost class should
I be deriving from? What is the type of the underlying resources that
are to be marshalled?

To be a more concrete, here is a snippet of code which uses existing
Boost classes to open an input stream.

    boost::iostreams::file_source fs ("foo.txt");
    boost::iostreams::stream_buffer <boost::iostreams::file_source> sb (fs);
    std::istream is (&sb);

Now I'd like to say something like

    concatenated_source cs (<list of resources to be marshalled goes here>);
    boost::iostreams::stream_buffer <concatenated_source> sb (cs);
    std::istream is (&sb);

What seems obvious to me is to say

class concatenated_source: public boost::iostreams::source {

but apparently source = device<input> and device says, according to
the docs (,

template<typename Mode, typename Ch = char>
struct device {
    typedef Ch char_type;
    typedef see below category;
    void close();
    void close(std::ios_base::openmode);
    void imbue(const std::locale&);

Hmm. I was kind of assuming that a generic source would require
something about reading some bytes and maybe opening or otherwise
creating something to read bytes from, but that doesn't appear to be
the case here.

Can someone suggest how to organize the declarations for a source or
other object from which bytes can be read? I feel pretty certain I can
complete the implementation if I can just get off the ground.

Thanks in advance for any advice.

Robert Dodier

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at