• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 PDFium Authors. All rights reserved.
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_SeekableWriteStream {
14  public:
15   StringWriteStream();
16   ~StringWriteStream() override;
17 
18   // IFX_SeekableWriteStream
19   FX_FILESIZE GetSize() override;
20   bool Flush() override;
21   bool WriteBlockAtOffset(const void* pData,
22                           FX_FILESIZE offset,
23                           size_t size) override;
24   bool WriteString(ByteStringView str) override;
25 
ToString()26   std::string ToString() const { return stream_.str(); }
27 
28  private:
29   std::ostringstream stream_;
30 };
31 
32 #endif  // TESTING_STRING_WRITE_STREAM_H_
33