[llvm-commits] [llvm] r75674 - /llvm/trunk/include/llvm/Support/FormattedStream.h

Chris Lattner sabre at nondot.org
Tue Jul 14 13:34:05 PDT 2009


Author: lattner
Date: Tue Jul 14 15:33:33 2009
New Revision: 75674

URL: http://llvm.org/viewvc/llvm-project?rev=75674&view=rev
Log:
allow default construction of formatted_raw_ostream.


Modified:
    llvm/trunk/include/llvm/Support/FormattedStream.h

Modified: llvm/trunk/include/llvm/Support/FormattedStream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FormattedStream.h?rev=75674&r1=75673&r2=75674&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/FormattedStream.h (original)
+++ llvm/trunk/include/llvm/Support/FormattedStream.h Tue Jul 14 15:33:33 2009
@@ -35,7 +35,7 @@
   private:
     /// TheStream - The real stream we output to.
     ///
-    raw_ostream &TheStream;
+    raw_ostream *TheStream;
     /// DeleteStream - Do we need to delete TheStream in the
     /// destructor?
     ///
@@ -48,7 +48,7 @@
 
     virtual void write_impl(const char *Ptr, unsigned Size) {
       ComputeColumn(Ptr, Size);
-      TheStream.write(Ptr, Size);
+      TheStream->write(Ptr, Size);
     }
 
     /// current_pos - Return the current position within the stream,
@@ -56,7 +56,7 @@
     virtual uint64_t current_pos() { 
       // This has the same effect as calling TheStream.current_pos(),
       // but that interface is private.
-      return TheStream.tell() - TheStream.GetNumBytesInBuffer();
+      return TheStream->tell() - TheStream->GetNumBytesInBuffer();
     }
 
     /// ComputeColumn - Examine the current output and figure out
@@ -75,12 +75,19 @@
     /// \param Binary - The file should be opened in binary mode on
     /// platforms that support this distinction.
     formatted_raw_ostream(raw_ostream &Stream, bool Delete = false) 
-        : raw_ostream(), TheStream(Stream), DeleteStream(Delete), Column(0) {}
+        : raw_ostream(), TheStream(&Stream), DeleteStream(Delete), Column(0) {}
+    explicit formatted_raw_ostream() 
+      : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {}
 
     ~formatted_raw_ostream() {
       if (DeleteStream)
         delete &TheStream;
     }
+    
+    void setStream(raw_ostream &Stream, bool Delete = false) {
+      TheStream = &Stream;
+      DeleteStream = Delete;
+    }
 
     /// PadToColumn - Align the output to some column number.
     ///





More information about the llvm-commits mailing list