Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-02-28 18:08:54


Brian Braatz wrote:
> First off THANK YOU Johnathon Turkanis for help with "tee" earlier.
> That saved me a great amount of pain.

Glad to be of service ;-)

> Below is part of what I am trying to use it with.
>
> My next question is what is the best way to deal with an "output"
> device having a different cr\lf than another one?

Have you tried to use a newline filter:

   http://www.kangaroologic.com/iostreams/libs/iostreams/doc/?path=6.2.2

?

I'm not familiar with the function OutputDebugString, but you might be able to
do this:

    struct debug_out_sink : boost::iostreams::sink
    {
       void write(const char* s, std::streamsize n)
        {
            std::string s(s, n);
            OutputDebugString(s.c_str());
        }
    };

    void Test_Profile()
    {
        // Note: library now uses namespace iostreams

        using namespace boost::iostreams;
        filtering_ostream out;
        std::ofstream log("log.txt");
        debug_out_sink dbosink;
        out.push(tee(log));
        out.push(tee(std::cout));
        out.push(newline_filter(newline::windows));
        out.push(dbosink);

        out << "LINE ONE" << endl
            << "Next line" << endl
            << "third line" << endl;
    }

Jonathan


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