Boost logo

Boost Users :

From: EMalenfant_at_[hidden]
Date: 2006-03-22 17:06:28


Hi,

I wanted an InputFilter for removing comments from C++ source files. Since
it seemed easier to write an OutputFilter, I decided to write that, and use
iostreams::inverse to make an InputFilter out of it. However, it seems that
inverse can't be used with "stateful" filters.

Consider the following, using dictionary_output_filter from the tutorial:
(http://www.boost.org/libs/iostreams/doc/index.html?path=2.2.6.3)

    namespace io = boost::iostreams;

    const std::string source("This foo will be bar");

    io::example::dictionary dict;
    dict.add("foo", "bar");

    io::filtering_istream in;
    in.push(io::invert(io::example::dictionary_output_filter(dict)));
    in.push(io::array_source(source.c_str(), source.length()));

    io::copy(in, std::cout);

Output:
    This bar will be
    
instead of the expected:
    This bar will be bar
    
Is this a "known limitation"? Is there a workaround? Am I doing something
silly?
 

-----------------------------
Éric

A conclusion is the place where you got tired of thinking


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net