+ explicit raw_string_ostream(std::string &O) : OS(O) {}
+ ~raw_string_ostream();
+
+ /// str - Flushes the stream contents to the target string and returns
+ /// the string's reference.
+ std::string& str() {
+ flush();
+ return OS;
+ }
+};
+
+/// raw_svector_ostream - A raw_ostream that writes to an SmallVector or
+/// SmallString. This is a simple adaptor class. This class does not
+/// encounter output errors.
+class raw_svector_ostream : public raw_ostream {
+ SmallVectorImpl<char> &OS;
+
+ /// write_impl - See raw_ostream::write_impl.
+ virtual void write_impl(const char *Ptr, size_t Size);
+
+ /// current_pos - Return the current position within the stream, not
+ /// counting the bytes currently in the buffer.
+ virtual uint64_t current_pos() const;
+public:
+ /// Construct a new raw_svector_ostream.
+ ///
+ /// \arg O - The vector to write to; this should generally have at least 128
+ /// bytes free to avoid any extraneous memory overhead.
+ explicit raw_svector_ostream(SmallVectorImpl<char> &O);
+ ~raw_svector_ostream();
+
+ /// resync - This is called when the SmallVector we're appending to is changed
+ /// outside of the raw_svector_ostream's control. It is only safe to do this
+ /// if the raw_svector_ostream has previously been flushed.
+ void resync();
+
+ /// str - Flushes the stream contents to the target vector and return a
+ /// StringRef for the vector contents.
+ StringRef str();
+};
+
+/// raw_null_ostream - A raw_ostream that discards all output.
+class raw_null_ostream : public raw_ostream {
+ /// write_impl - See raw_ostream::write_impl.
+ virtual void write_impl(const char *Ptr, size_t size);
+
+ /// current_pos - Return the current position within the stream, not
+ /// counting the bytes currently in the buffer.
+ virtual uint64_t current_pos() const;
+
+public:
+ explicit raw_null_ostream() {}
+ ~raw_null_ostream();