OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FGAS_CRT_FGAS_STREAM_H_ | 7 #ifndef XFA_FGAS_CRT_FGAS_STREAM_H_ |
8 #define XFA_FGAS_CRT_FGAS_STREAM_H_ | 8 #define XFA_FGAS_CRT_FGAS_STREAM_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_stream.h" | 10 #include "core/fxcrt/include/fx_stream.h" |
11 #include "core/fxcrt/include/fx_system.h" | 11 #include "core/fxcrt/include/fx_system.h" |
12 | 12 |
13 class IFX_Stream; | 13 class IFX_Stream; |
14 | 14 |
15 IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, | 15 IFX_FileRead* FX_CreateFileRead(IFX_Stream* pBaseStream, |
16 FX_BOOL bReleaseStream = FALSE); | 16 FX_BOOL bReleaseStream); |
17 | 17 |
18 enum FX_STREAMACCESS { | 18 enum FX_STREAMACCESS { |
19 FX_STREAMACCESS_Binary = 0x00, | 19 FX_STREAMACCESS_Binary = 0x00, |
20 FX_STREAMACCESS_Text = 0x01, | 20 FX_STREAMACCESS_Text = 0x01, |
21 FX_STREAMACCESS_Read = 0x02, | 21 FX_STREAMACCESS_Read = 0x02, |
22 FX_STREAMACCESS_Write = 0x04, | 22 FX_STREAMACCESS_Write = 0x04, |
23 FX_STREAMACCESS_Truncate = 0x10, | 23 FX_STREAMACCESS_Truncate = 0x10, |
24 FX_STREAMACCESS_Append = 0x20, | 24 FX_STREAMACCESS_Append = 0x20, |
25 FX_STREAMACCESS_Create = 0x80, | 25 FX_STREAMACCESS_Create = 0x80, |
26 }; | 26 }; |
27 | 27 |
28 enum FX_STREAMSEEK { | 28 enum FX_STREAMSEEK { |
29 FX_STREAMSEEK_Begin = 0, | 29 FX_STREAMSEEK_Begin = 0, |
30 FX_STREAMSEEK_Current, | 30 FX_STREAMSEEK_Current, |
31 FX_STREAMSEEK_End, | 31 FX_STREAMSEEK_End, |
32 }; | 32 }; |
33 | 33 |
34 class IFX_Stream { | 34 class IFX_Stream { |
35 public: | 35 public: |
36 static IFX_Stream* CreateStream(IFX_FileRead* pFileRead, uint32_t dwAccess); | 36 static IFX_Stream* CreateStream(IFX_FileRead* pFileRead, uint32_t dwAccess); |
37 static IFX_Stream* CreateStream(IFX_FileWrite* pFileWrite, uint32_t dwAccess); | 37 static IFX_Stream* CreateStream(IFX_FileWrite* pFileWrite, uint32_t dwAccess); |
38 static IFX_Stream* CreateStream(const FX_WCHAR* pszFileName, | |
39 uint32_t dwAccess); | |
40 static IFX_Stream* CreateStream(uint8_t* pData, | 38 static IFX_Stream* CreateStream(uint8_t* pData, |
41 int32_t length, | 39 int32_t length, |
42 uint32_t dwAccess); | 40 uint32_t dwAccess); |
43 static IFX_Stream* CreateStream(IFX_BufferRead* pBufferRead, | |
44 uint32_t dwAccess, | |
45 int32_t iFileSize = -1, | |
46 FX_BOOL bReleaseBufferRead = TRUE); | |
47 static IFX_Stream* CreateTextStream(IFX_Stream* pBaseStream, | 41 static IFX_Stream* CreateTextStream(IFX_Stream* pBaseStream, |
48 FX_BOOL bDeleteOnRelease); | 42 FX_BOOL bDeleteOnRelease); |
49 virtual ~IFX_Stream() {} | 43 virtual ~IFX_Stream() {} |
50 virtual void Release() = 0; | 44 virtual void Release() = 0; |
51 virtual IFX_Stream* Retain() = 0; | 45 virtual IFX_Stream* Retain() = 0; |
| 46 |
| 47 virtual IFX_Stream* CreateSharedStream(uint32_t dwAccess, |
| 48 int32_t iOffset, |
| 49 int32_t iLength) = 0; |
| 50 |
52 virtual uint32_t GetAccessModes() const = 0; | 51 virtual uint32_t GetAccessModes() const = 0; |
53 virtual int32_t GetLength() const = 0; | 52 virtual int32_t GetLength() const = 0; |
54 virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) = 0; | 53 virtual int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) = 0; |
55 virtual int32_t GetPosition() = 0; | 54 virtual int32_t GetPosition() = 0; |
56 virtual FX_BOOL IsEOF() const = 0; | 55 virtual FX_BOOL IsEOF() const = 0; |
57 virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) = 0; | 56 virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize) = 0; |
58 virtual int32_t ReadString(FX_WCHAR* pStr, | 57 virtual int32_t ReadString(FX_WCHAR* pStr, |
59 int32_t iMaxLength, | 58 int32_t iMaxLength, |
60 FX_BOOL& bEOS, | 59 FX_BOOL& bEOS) = 0; |
61 int32_t const* pByteSize = nullptr) = 0; | |
62 virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0; | 60 virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize) = 0; |
63 virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0; | 61 virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength) = 0; |
64 virtual void Flush() = 0; | 62 virtual void Flush() = 0; |
65 virtual FX_BOOL SetLength(int32_t iLength) = 0; | 63 virtual FX_BOOL SetLength(int32_t iLength) = 0; |
66 virtual int32_t GetBOM(uint8_t bom[4]) const = 0; | 64 virtual int32_t GetBOM(uint8_t bom[4]) const = 0; |
67 virtual uint16_t GetCodePage() const = 0; | 65 virtual uint16_t GetCodePage() const = 0; |
68 virtual uint16_t SetCodePage(uint16_t wCodePage) = 0; | 66 virtual uint16_t SetCodePage(uint16_t wCodePage) = 0; |
69 virtual IFX_Stream* CreateSharedStream(uint32_t dwAccess, | |
70 int32_t iOffset, | |
71 int32_t iLength) = 0; | |
72 }; | 67 }; |
73 | 68 |
74 #endif // XFA_FGAS_CRT_FGAS_STREAM_H_ | 69 #endif // XFA_FGAS_CRT_FGAS_STREAM_H_ |
OLD | NEW |