• 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 #include "testing/string_write_stream.h"
6 #include "core/fxcrt/bytestring.h"
7 #include "core/fxcrt/widestring.h"
8 
9 StringWriteStream::StringWriteStream() = default;
10 
11 StringWriteStream::~StringWriteStream() = default;
12 
GetSize()13 FX_FILESIZE StringWriteStream::GetSize() {
14   return stream_.tellp();
15 }
16 
Flush()17 bool StringWriteStream::Flush() {
18   return true;
19 }
20 
WriteBlockAtOffset(const void * pData,FX_FILESIZE offset,size_t size)21 bool StringWriteStream::WriteBlockAtOffset(const void* pData,
22                                            FX_FILESIZE offset,
23                                            size_t size) {
24   ASSERT(offset == 0);
25   stream_.write(static_cast<const char*>(pData), size);
26   return true;
27 }
28 
WriteString(ByteStringView str)29 bool StringWriteStream::WriteString(ByteStringView str) {
30   stream_.write(str.unterminated_c_str(), str.GetLength());
31   return true;
32 }
33