X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FSupport%2FStreams.h;h=445ab98c476d7711a325eb10851944a80d2f59d1;hb=0fd38069cb6699ce21eb159f22d3f23c012c9e81;hp=6758c35e3d39310e0d73924182943e24a7b6f637;hpb=181b6c9cb5def44658d15848e34c5c45d973f065;p=oota-llvm.git diff --git a/include/llvm/Support/Streams.h b/include/llvm/Support/Streams.h index 6758c35e3d3..445ab98c476 100644 --- a/include/llvm/Support/Streams.h +++ b/include/llvm/Support/Streams.h @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by Bill Wendling and is distributed under the -// University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -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; @@ -46,11 +59,17 @@ namespace llvm { } template - BaseStream &operator >> (const Ty &Thing) { + BaseStream &operator >> (Ty &Thing) { if (Stream) *Stream >> Thing; 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; }