blob: fc42b7f416d0a5221be7e81f062267acf2f94c4a [file] [log] [blame]
Dan Sinclairae4656e2017-05-09 12:36:41 -04001// 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 Sinclair7d125322018-03-28 18:49:34 +00007#ifndef FPDFSDK_CPDFSDK_FILEWRITEADAPTER_H_
8#define FPDFSDK_CPDFSDK_FILEWRITEADAPTER_H_
Dan Sinclairae4656e2017-05-09 12:36:41 -04009
Dan Sinclairae4656e2017-05-09 12:36:41 -040010#include "core/fxcrt/fx_stream.h"
Dan Sinclair0b950422017-09-21 15:49:49 -040011#include "core/fxcrt/retain_ptr.h"
Tom Sepez962c1bc2018-08-22 17:27:41 +000012#include "core/fxcrt/unowned_ptr.h"
Dan Sinclairae4656e2017-05-09 12:36:41 -040013#include "public/fpdf_save.h"
14
Lei Zhang5d84e2e2018-11-15 21:50:41 +000015class CPDFSDK_FileWriteAdapter final : public IFX_RetainableWriteStream {
Dan Sinclairae4656e2017-05-09 12:36:41 -040016 public:
17 template <typename T, typename... Args>
Dan Sinclair0b950422017-09-21 15:49:49 -040018 friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
Dan Sinclairae4656e2017-05-09 12:36:41 -040019
Lei Zhang86688de2018-05-22 22:06:49 +000020 // IFX_WriteStream:
Dan Sinclairae4656e2017-05-09 12:36:41 -040021 bool WriteBlock(const void* data, size_t size) override;
Tom Sepezc839ac72018-12-14 20:34:11 +000022 bool WriteString(ByteStringView str) override;
Dan Sinclairae4656e2017-05-09 12:36:41 -040023
24 private:
Tom Sepez962c1bc2018-08-22 17:27:41 +000025 explicit CPDFSDK_FileWriteAdapter(FPDF_FILEWRITE* file_write);
Dan Sinclair7d125322018-03-28 18:49:34 +000026 ~CPDFSDK_FileWriteAdapter() override;
Dan Sinclairae4656e2017-05-09 12:36:41 -040027
Tom Sepez962c1bc2018-08-22 17:27:41 +000028 UnownedPtr<FPDF_FILEWRITE> file_write_;
Dan Sinclairae4656e2017-05-09 12:36:41 -040029};
30
Dan Sinclair7d125322018-03-28 18:49:34 +000031#endif // FPDFSDK_CPDFSDK_FILEWRITEADAPTER_H_