summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/raw_ostream.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-08-23 22:43:04 +0000
committerChris Lattner <sabre@nondot.org>2008-08-23 22:43:04 +0000
commit205af9643d76e05c26c4ffae9703679bf04d97a9 (patch)
tree305fb0c94e17fe154cf0d31693c6d81476ba0a48 /llvm/lib/Support/raw_ostream.cpp
parenta2e25e5e72002a6c5b24f609c9375952cdcb7368 (diff)
downloadbcm5719-llvm-205af9643d76e05c26c4ffae9703679bf04d97a9.tar.gz
bcm5719-llvm-205af9643d76e05c26c4ffae9703679bf04d97a9.zip
Add raw_stream adaptors that write into an std::string and SmallVector/SmallString.
llvm-svn: 55265
Diffstat (limited to 'llvm/lib/Support/raw_ostream.cpp')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 9827ca776ad..b9beac2869a 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/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();
+}
+
OpenPOWER on IntegriCloud