xref: /aosp_15_r20/external/pdfium/testing/string_write_stream.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2018 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef TESTING_STRING_WRITE_STREAM_H_
6 #define TESTING_STRING_WRITE_STREAM_H_
7 
8 #include <sstream>
9 #include <string>
10 
11 #include "core/fxcrt/fx_stream.h"
12 
13 class StringWriteStream final : public IFX_RetainableWriteStream {
14  public:
15   StringWriteStream();
16   ~StringWriteStream() override;
17 
18   // IFX_WriteStream:
19   bool WriteBlock(pdfium::span<const uint8_t> buffer) override;
20 
ToString()21   std::string ToString() const { return stream_.str(); }
22 
23  private:
24   std::ostringstream stream_;
25 };
26 
27 #endif  // TESTING_STRING_WRITE_STREAM_H_
28