Modify

Opened 11 years ago

Closed 9 years ago

#791 closed Feature Requests (fixed)

iostreams::tee_filter is for output only

Reported by: alexis_wilke Owned by: Jonathan Turkanis
Milestone: Boost 1.36.0 Component: iostreams
Version: None Severity: Problem
Keywords: Cc:

Description

I faught the C++ compiler for a little while before I realized that the iostreams::tee_filter was written as an output filter only. I needed it to work for an input chain and I do not see why there is such a limitation.

My idea is to catch a copy of the data somewhere in the chain before it gets transformed further. Whether it is input our output it should work, right? (at least in theory...)

Anyone has input in that regard?

Thank you,
Alexis Wilke

Attachments (0)

Change History (4)

comment:1 Changed 11 years ago by alexis_wilke

Logged In: YES 
user_id=554061
Originator: YES

I propose the following additional function and adding multichar_input_filter_tag to the category. My software seems to work just fine with this addition.


    template<typename Source>
    std::streamsize read(Source& src, char_type* s, std::streamsize n)
    {
        int   c;
        char_type* first = s;
        char_type* last  = s + n;
        while ( first != last &&
                (c = boost::iostreams::get(src)) != EOF &&
                 c != WOULD_BLOCK )
        {
            *first++ = c;
        }
        std::streamsize result = static_cast<std::streamsize>(first - s);
        if(result == 0)
        {
           return c;
        }
        std::streamsize result2 = iostreams::write(this->component(), s, result);
        (void) result2; // Suppress 'unused variable' warning.
        assert(result == result2);
        return result;
    }

comment:2 Changed 10 years ago by Daryle Walker

Component: Noneiostreams
Severity: Problem

comment:3 Changed 10 years ago by Jonathan Turkanis

Milestone: Boost 1.36.0
Type: BugsFeature Requests

When I wrote tee, I couldn't think of a way to apply the concept to an input stream, but your idea looks pretty good. I will consider it for 1.36.

comment:4 Changed 9 years ago by Jonathan Turkanis

Resolution: Nonefixed
Status: assignedclosed

(In [45752]) made tee work with input streams (fixes #791)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonathan Turkanis.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.