Jean-Marc Lasgouttes wrote:

>>>>>> "Angus" == Angus Leeming <[EMAIL PROTECTED]>
>>>>>> writes:
> 
> Angus> Jean-Marc Lasgouttes wrote:
>>> I am still missing the most basic information: what is the ostream
>>> method I should hook to in order to intercept all outputs to the
>>> stream?
> 
> Angus> I don't follow. I think that you have to define something like:
> 
> But then the code may use << on char or int. I need to catch them too.
> So I guess I need a hook at lower level.

I don't think so. It's streams, not streambufs, that do the formatting.

Why not define olatexstream, so, and collate all your magic formating
inside print()?

Angus


#ifndef OLATEXSTREAM_H
#define OLATEXSTREAM_H

#include "support/tostr.h"

#include <iosfwd>
#include <string>


struct olatexstream {
        olatexstream(std::ostream & os_)
            : macro_without_args(false),
              os(os_) {}

        void print(std::string const &);

        bool macro_without_args;
        std::ostream & os;
};

olatexstream & operator<<(olatexstream & ls, int data)
{
        ls.print(support::tostr(data));
        return ls;
}

olatexstream & operator<<(olatexstream & ls, char data)
{
        ls.print(support::tostr(data));
        return ls;
}

olatexstream & operator<<(olatexstream & ls, std::string const & data)
{
        ls.print(data);
        return ls;
}

#endif // OLATEXSTREAM_H


Reply via email to