+
+/// raw_string_ostream - A raw_ostream that writes to an std::string. This is a
+/// simple adaptor class.
+class raw_string_ostream : public raw_ostream {
+ std::string &OS;
+
+ /// write_impl - See raw_ostream::write_impl.
+ virtual void write_impl(const char *Ptr, unsigned Size);
+
+ /// current_pos - Return the current position within the stream, not
+ /// counting the bytes currently in the buffer.
+ virtual uint64_t current_pos() { return OS.size(); }
+public:
+ raw_string_ostream(std::string &O) : OS(O) {}
+ ~raw_string_ostream();
+
+ /// tell - Return the current offset with the stream.
+ uint64_t tell() { return OS.size() + GetNumBytesInBuffer(); }
+
+ /// 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.
+class raw_svector_ostream : public raw_ostream {
+ SmallVectorImpl<char> &OS;
+
+ /// write_impl - See raw_ostream::write_impl.
+ virtual void write_impl(const char *Ptr, unsigned Size);
+
+ /// current_pos - Return the current position within the stream, not
+ /// counting the bytes currently in the buffer.
+ virtual uint64_t current_pos();
+public:
+ raw_svector_ostream(SmallVectorImpl<char> &O) : OS(O) {}
+ ~raw_svector_ostream();
+
+ /// tell - Return the current offset with the stream.
+ uint64_t tell();
+};
+