Dan Sinclair | 048afc6 | 2018-05-01 17:01:54 +0000 | [diff] [blame^] | 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 | |
| 13 | FX_FILESIZE StringWriteStream::GetSize() { |
| 14 | return stream_.tellp(); |
| 15 | } |
| 16 | |
| 17 | bool StringWriteStream::Flush() { |
| 18 | return true; |
| 19 | } |
| 20 | |
| 21 | bool StringWriteStream::WriteBlock(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 | |
| 29 | bool StringWriteStream::WriteString(const ByteStringView& str) { |
| 30 | stream_.write(str.unterminated_c_str(), str.GetLength()); |
| 31 | return true; |
| 32 | } |