1 // Copyright 2022 The PDFium Authors 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 7 #ifndef CORE_FXCRT_CFX_READ_ONLY_SPAN_STREAM_H_ 8 #define CORE_FXCRT_CFX_READ_ONLY_SPAN_STREAM_H_ 9 10 #include "core/fxcrt/fx_stream.h" 11 #include "core/fxcrt/retain_ptr.h" 12 #include "third_party/base/containers/span.h" 13 14 class CFX_ReadOnlySpanStream final : public IFX_SeekableReadStream { 15 public: 16 CONSTRUCT_VIA_MAKE_RETAIN; 17 18 // IFX_SeekableReadStream: 19 FX_FILESIZE GetSize() override; 20 bool ReadBlockAtOffset(pdfium::span<uint8_t> buffer, 21 FX_FILESIZE offset) override; 22 23 private: 24 explicit CFX_ReadOnlySpanStream(pdfium::span<const uint8_t> span); 25 ~CFX_ReadOnlySpanStream() override; 26 27 const pdfium::span<const uint8_t> span_; 28 }; 29 30 #endif // CORE_FXCRT_CFX_READ_ONLY_SPAN_STREAM_H_ 31