X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FStreams.h;h=445ab98c476d7711a325eb10851944a80d2f59d1;hb=0fd38069cb6699ce21eb159f22d3f23c012c9e81;hp=46bac8baaf6b613c6a9be5bcf01e97180b59cdc5;hpb=3ee3267fc2c4d1d630d9a918ba1453e4fe47c429;p=oota-llvm.git diff --git a/include/llvm/Support/Streams.h b/include/llvm/Support/Streams.h index 46bac8baaf6..445ab98c476 100644 --- a/include/llvm/Support/Streams.h +++ b/include/llvm/Support/Streams.h @@ -19,11 +19,14 @@ namespace llvm { + /// FlushStream - Function called by BaseStream to flush an ostream. + void FlushStream(std::ostream &S); + /// BaseStream - Acts like the STL streams. It's a wrapper for the std::cerr, /// std::cout, std::cin, etc. streams. However, it doesn't require #including - /// @verbatim @endverbatm in every file (doing so increases static + /// @verbatim @endverbatm in every file (doing so increases static /// c'tors & d'tors in the object code). - /// + /// template class BaseStream { StreamTy *Stream; @@ -34,11 +37,21 @@ namespace llvm { StreamTy *stream() const { return Stream; } + inline BaseStream &operator << (std::ios_base &(*Func)(std::ios_base&)) { + if (Stream) *Stream << Func; + return *this; + } + inline BaseStream &operator << (StreamTy &(*Func)(StreamTy&)) { if (Stream) *Stream << Func; return *this; } + void flush() { + if (Stream) + FlushStream(*Stream); + } + template BaseStream &operator << (const Ty &Thing) { if (Stream) *Stream << Thing; @@ -51,6 +64,12 @@ namespace llvm { return *this; } + template + BaseStream &write(const Ty &A, unsigned N) { + if (Stream) Stream->write(A, N); + return *this; + } + operator StreamTy* () { return Stream; } bool operator == (const StreamTy &S) { return &S == Stream; }