Ticket #791 (closed Feature Requests: fixed)

Opened 10 years ago

Last modified 9 years ago

iostreams::tee_filter is for output only

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


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


Change History

comment:1 Changed 10 years ago by alexis_wilke

Logged In: YES 
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 dlwalker

  • Component changed from None to iostreams
  • Severity set to Problem

comment:3 Changed 9 years ago by turkanis

  • Type changed from Bugs to Feature Requests
  • Milestone set to Boost 1.36.0

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 turkanis

  • Status changed from assigned to closed
  • Resolution changed from None to fixed

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


Add a comment

Modify Ticket

Change Properties
<Author field>
as closed
The resolution will be deleted. Next status will be 'reopened'

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

Note: See TracTickets for help on using tickets.