Boost logo

Boost Users :

From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2008-06-25 02:40:38


Hi,
 
I've looked at iostream library for the first time in a long while and had
couple surprises waiting for me right at doorstep (I am boost 1.33.1 under vc
7.1 io=boost::iostream).
 
1) io::array_source( "Hello World!" ) doesn't compile
2) io::array_source( std::string( "Hello World!" ) ) doesn't compile
3) can't seem to find toupper and similar filters as part of the library
4) Given line filter like this:

struct toupper_line_filter : io::line_filter {
    virtual std::string do_filter( const std::string& line )
    {
        std::string result;
        result.reserve( line.size() );
        for( std::string::size_type i = 0, size = line.size(); i < size; ++i )
            result.push_back( std::toupper((unsigned char)line[i]) );

          return result;
    }
};

Following code seems to produce an error

std::string result;
io::filtering_ostream out;

out.push( toupper_line_filter() );
out.push( io::back_inserter(result) );

out << "Hello World!";

BOOST_CHECK_EQUAL( result, "HELLO WORLD!\n" );

5) my next attempt was to add flush before check - still the same result
std::string result;
io::filtering_ostream out;

out.push( toupper_line_filter() );
out.push( io::back_inserter(result) );

out << "Hello World!";
out.flush()

BOOST_CHECK_EQUAL( result, "HELLO WORLD!\n" );

It appears flush had no effect whatsoever. After long battle i found that reset
seems to do the trick. But what if I do not want to destroy stream

6) out.sync() doesn't seems to compile, in spite of what docs say

7) stringstream can't be used at sink:
    std::stringstream buffer;
    io::filtering_ostream out;
 
    out.push( buffer );

fails to compile

8) library seems to have it's own mind about when to invoke my filter. Can I
enforce to be called manually?

Thanks,

Gennadiy


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