Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 1 | // Copyright 2017 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 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | 7d12532 | 2018-03-28 18:49:34 +0000 | [diff] [blame] | 7 | #ifndef FPDFSDK_CPDFSDK_FILEWRITEADAPTER_H_ |
| 8 | #define FPDFSDK_CPDFSDK_FILEWRITEADAPTER_H_ |
Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 9 | |
Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 10 | #include "core/fxcrt/fx_stream.h" |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 11 | #include "core/fxcrt/retain_ptr.h" |
Tom Sepez | 962c1bc | 2018-08-22 17:27:41 +0000 | [diff] [blame] | 12 | #include "core/fxcrt/unowned_ptr.h" |
Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 13 | #include "public/fpdf_save.h" |
| 14 | |
Lei Zhang | 5d84e2e | 2018-11-15 21:50:41 +0000 | [diff] [blame] | 15 | class CPDFSDK_FileWriteAdapter final : public IFX_RetainableWriteStream { |
Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 16 | public: |
| 17 | template <typename T, typename... Args> |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 18 | friend RetainPtr<T> pdfium::MakeRetain(Args&&... args); |
Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 19 | |
Lei Zhang | 86688de | 2018-05-22 22:06:49 +0000 | [diff] [blame] | 20 | // IFX_WriteStream: |
Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 21 | bool WriteBlock(const void* data, size_t size) override; |
Tom Sepez | c839ac7 | 2018-12-14 20:34:11 +0000 | [diff] [blame] | 22 | bool WriteString(ByteStringView str) override; |
Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 23 | |
| 24 | private: |
Tom Sepez | 962c1bc | 2018-08-22 17:27:41 +0000 | [diff] [blame] | 25 | explicit CPDFSDK_FileWriteAdapter(FPDF_FILEWRITE* file_write); |
Dan Sinclair | 7d12532 | 2018-03-28 18:49:34 +0000 | [diff] [blame] | 26 | ~CPDFSDK_FileWriteAdapter() override; |
Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 27 | |
Tom Sepez | 962c1bc | 2018-08-22 17:27:41 +0000 | [diff] [blame] | 28 | UnownedPtr<FPDF_FILEWRITE> file_write_; |
Dan Sinclair | ae4656e | 2017-05-09 12:36:41 -0400 | [diff] [blame] | 29 | }; |
| 30 | |
Dan Sinclair | 7d12532 | 2018-03-28 18:49:34 +0000 | [diff] [blame] | 31 | #endif // FPDFSDK_CPDFSDK_FILEWRITEADAPTER_H_ |