• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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 
7 #ifndef XFA_FGAS_CRT_FGAS_STREAM_H_
8 #define XFA_FGAS_CRT_FGAS_STREAM_H_
9 
10 #include "core/fxcrt/cfx_retain_ptr.h"
11 #include "core/fxcrt/fx_stream.h"
12 #include "core/fxcrt/fx_system.h"
13 
14 enum FX_STREAMACCESS {
15   FX_STREAMACCESS_Binary = 0x00,
16   FX_STREAMACCESS_Text = 0x01,
17   FX_STREAMACCESS_Read = 0x02,
18   FX_STREAMACCESS_Write = 0x04,
19   FX_STREAMACCESS_Truncate = 0x10,
20   FX_STREAMACCESS_Append = 0x20,
21   FX_STREAMACCESS_Create = 0x80,
22 };
23 
24 enum FX_STREAMSEEK {
25   FX_STREAMSEEK_Begin = 0,
26   FX_STREAMSEEK_Current,
27   FX_STREAMSEEK_End,
28 };
29 
30 class IFGAS_Stream : public CFX_Retainable {
31  public:
32   static CFX_RetainPtr<IFGAS_Stream> CreateStream(
33       const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead,
34       uint32_t dwAccess);
35   static CFX_RetainPtr<IFGAS_Stream> CreateStream(
36       const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite,
37       uint32_t dwAccess);
38   static CFX_RetainPtr<IFGAS_Stream> CreateStream(uint8_t* pData,
39                                                   int32_t length,
40                                                   uint32_t dwAccess);
41   static CFX_RetainPtr<IFGAS_Stream> CreateTextStream(
42       const CFX_RetainPtr<IFGAS_Stream>& pBaseStream);
43 
44   virtual CFX_RetainPtr<IFGAS_Stream> CreateSharedStream(uint32_t dwAccess,
45                                                          int32_t iOffset,
46                                                          int32_t iLength) = 0;
47 
48   virtual uint32_t GetAccessModes() const = 0;
49   virtual int32_t GetLength() const = 0;
50   virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) = 0;
51   virtual int32_t GetPosition() = 0;
52   virtual bool IsEOF() const = 0;
53   virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) = 0;
54   virtual int32_t ReadString(FX_WCHAR* pStr,
55                              int32_t iMaxLength,
56                              bool& bEOS) = 0;
57   virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0;
58   virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0;
59   virtual void Flush() = 0;
60   virtual bool SetLength(int32_t iLength) = 0;
61   virtual int32_t GetBOM(uint8_t bom[4]) const = 0;
62   virtual uint16_t GetCodePage() const = 0;
63   virtual uint16_t SetCodePage(uint16_t wCodePage) = 0;
64 
65   CFX_RetainPtr<IFX_SeekableReadStream> MakeSeekableReadStream();
66 };
67 
68 
69 #endif  // XFA_FGAS_CRT_FGAS_STREAM_H_
70