xref: /aosp_15_r20/external/pdfium/core/fxcrt/cfx_read_only_string_stream.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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 #ifndef CORE_FXCRT_CFX_READ_ONLY_STRING_STREAM_H_
6 #define CORE_FXCRT_CFX_READ_ONLY_STRING_STREAM_H_
7 
8 #include "core/fxcrt/bytestring.h"
9 #include "core/fxcrt/fx_stream.h"
10 #include "core/fxcrt/retain_ptr.h"
11 
12 class CFX_ReadOnlySpanStream;
13 
14 class CFX_ReadOnlyStringStream 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_ReadOnlyStringStream(ByteString data);
25   ~CFX_ReadOnlyStringStream() override;
26 
27   const ByteString data_;
28   const RetainPtr<CFX_ReadOnlySpanStream> stream_;
29 };
30 
31 #endif  // CORE_FXCRT_CFX_READ_ONLY_STRING_STREAM_H_
32