diff options
author | Chris Lattner <sabre@nondot.org> | 2008-08-23 22:43:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-08-23 22:43:04 +0000 |
commit | 78a2812538d871a62d90f53ed66d26198876d011 (patch) | |
tree | 297ba4550a141c420c6656e4c0c6580de7ad1892 /lib/Support/raw_ostream.cpp | |
parent | 944fac71e082cc2664cc71b4d3f6c72bab7143fb (diff) |
Add raw_stream adaptors that write into an std::string and SmallVector/SmallString.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55265 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/raw_ostream.cpp')
-rw-r--r-- | lib/Support/raw_ostream.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 9827ca776a..b9beac2869 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -268,3 +268,38 @@ void raw_os_ostream::flush_impl() { OS.write(OutBufStart, OutBufCur-OutBufStart); HandleFlush(); } + +//===----------------------------------------------------------------------===// +// raw_string_ostream +//===----------------------------------------------------------------------===// + +raw_string_ostream::~raw_string_ostream() { + flush(); +} + +/// flush_impl - The is the piece of the class that is implemented by +/// subclasses. This outputs the currently buffered data and resets the +/// buffer to empty. +void raw_string_ostream::flush_impl() { + if (OutBufCur-OutBufStart) + OS.append(OutBufStart, OutBufCur-OutBufStart); + HandleFlush(); +} + +//===----------------------------------------------------------------------===// +// raw_svector_ostream +//===----------------------------------------------------------------------===// + +raw_svector_ostream::~raw_svector_ostream() { + flush(); +} + +/// flush_impl - The is the piece of the class that is implemented by +/// subclasses. This outputs the currently buffered data and resets the +/// buffer to empty. +void raw_svector_ostream::flush_impl() { + if (OutBufCur-OutBufStart) + OS.append(OutBufStart, OutBufCur); + HandleFlush(); +} + |