llvm.org GIT mirror llvm / 4a18d2f
allow default construction of formatted_raw_ostream. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75674 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
1 changed file(s) with 11 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
3434 private:
3535 /// TheStream - The real stream we output to.
3636 ///
37 raw_ostream &TheStream;
37 raw_ostream *TheStream;
3838 /// DeleteStream - Do we need to delete TheStream in the
3939 /// destructor?
4040 ///
4747
4848 virtual void write_impl(const char *Ptr, unsigned Size) {
4949 ComputeColumn(Ptr, Size);
50 TheStream.write(Ptr, Size);
50 TheStream->write(Ptr, Size);
5151 }
5252
5353 /// current_pos - Return the current position within the stream,
5555 virtual uint64_t current_pos() {
5656 // This has the same effect as calling TheStream.current_pos(),
5757 // but that interface is private.
58 return TheStream.tell() - TheStream.GetNumBytesInBuffer();
58 return TheStream->tell() - TheStream->GetNumBytesInBuffer();
5959 }
6060
6161 /// ComputeColumn - Examine the current output and figure out
7474 /// \param Binary - The file should be opened in binary mode on
7575 /// platforms that support this distinction.
7676 formatted_raw_ostream(raw_ostream &Stream, bool Delete = false)
77 : raw_ostream(), TheStream(Stream), DeleteStream(Delete), Column(0) {}
77 : raw_ostream(), TheStream(&Stream), DeleteStream(Delete), Column(0) {}
78 explicit formatted_raw_ostream()
79 : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {}
7880
7981 ~formatted_raw_ostream() {
8082 if (DeleteStream)
8183 delete &TheStream;
84 }
85
86 void setStream(raw_ostream &Stream, bool Delete = false) {
87 TheStream = &Stream;
88 DeleteStream = Delete;
8289 }
8390
8491 /// PadToColumn - Align the output to some column number.