Boost logo

Boost :

Subject: Re: [boost] [iostreams] output_filter works only once
From: Olaf van der Spek (ml_at_[hidden])
Date: 2012-02-13 04:43:45


On Mon, Feb 13, 2012 at 7:30 AM, Steven Samuel Cole
<steven.samuel.cole_at_[hidden]> wrote:
> class add_string_output_filter
>  : public boost::iostreams::multichar_output_filter
> {
>    public:
>
>    template<typename Sink>
>    streamsize write(Sink& sink, const char* s, streamsize n)
>    {
>        string out_string = string(s);

Shouldn't that be string out_string(s, n);?

>        // remove trailing '\0' to prevent line break
>        if (out_string[out_string.size()-1] = '\0')
>            out_string = out_string.substr(0, out_string.size()-1);

I'd use out_string.erase(out_string.size() - 1);

I've no experience with iostreams though, can't help you with the real problem.

Olaf


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk