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 CORE_INCLUDE_FXCRT_FX_STREAM_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_STREAM_H_ |
8 #define CORE_INCLUDE_FXCRT_FX_STREAM_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_STREAM_H_ |
9 | 9 |
10 #include "fx_string.h" | 10 #include "fx_string.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, | 55 FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, |
56 const CFX_ByteStringC& fileNameDst); | 56 const CFX_ByteStringC& fileNameDst); |
57 FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, | 57 FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, |
58 const CFX_WideStringC& fileNameDst); | 58 const CFX_WideStringC& fileNameDst); |
59 class IFX_StreamWrite { | 59 class IFX_StreamWrite { |
60 public: | 60 public: |
61 virtual ~IFX_StreamWrite() {} | 61 virtual ~IFX_StreamWrite() {} |
62 virtual void Release() = 0; | 62 virtual void Release() = 0; |
63 virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0; | 63 virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0; |
64 }; | 64 }; |
65 | |
65 class IFX_FileWrite : public IFX_StreamWrite { | 66 class IFX_FileWrite : public IFX_StreamWrite { |
66 public: | 67 public: |
67 virtual void Release() = 0; | 68 // IFX_StreamWrite: |
69 FX_BOOL WriteBlock(const void* pData, size_t size) override { | |
70 return WriteBlock(pData, GetSize(), size); | |
71 } | |
68 | 72 |
69 virtual FX_FILESIZE GetSize() = 0; | 73 virtual FX_FILESIZE GetSize() = 0; |
70 | |
71 virtual FX_BOOL Flush() = 0; | 74 virtual FX_BOOL Flush() = 0; |
72 | |
73 virtual FX_BOOL WriteBlock(const void* pData, | 75 virtual FX_BOOL WriteBlock(const void* pData, |
74 FX_FILESIZE offset, | 76 FX_FILESIZE offset, |
75 size_t size) = 0; | 77 size_t size) = 0; |
76 virtual FX_BOOL WriteBlock(const void* pData, size_t size) { | |
77 return WriteBlock(pData, GetSize(), size); | |
78 } | |
79 }; | 78 }; |
79 | |
80 class IFX_StreamRead { | 80 class IFX_StreamRead { |
81 public: | 81 public: |
82 virtual ~IFX_StreamRead() {} | 82 virtual ~IFX_StreamRead() {} |
83 | 83 |
84 virtual void Release() = 0; | 84 virtual void Release() = 0; |
85 | |
86 virtual FX_BOOL IsEOF() = 0; | 85 virtual FX_BOOL IsEOF() = 0; |
87 | |
88 virtual FX_FILESIZE GetPosition() = 0; | 86 virtual FX_FILESIZE GetPosition() = 0; |
89 | |
90 virtual size_t ReadBlock(void* buffer, size_t size) = 0; | 87 virtual size_t ReadBlock(void* buffer, size_t size) = 0; |
91 }; | 88 }; |
89 | |
92 class IFX_FileRead : IFX_StreamRead { | 90 class IFX_FileRead : IFX_StreamRead { |
93 public: | 91 public: |
94 virtual void Release() = 0; | 92 // IFX_StreamRead: |
95 | 93 void Release() override = 0; |
96 virtual FX_FILESIZE GetSize() = 0; | 94 FX_BOOL IsEOF() override { return FALSE; } |
97 | 95 FX_FILESIZE GetPosition() override { return 0; } |
98 virtual FX_BOOL IsEOF() { return FALSE; } | 96 size_t ReadBlock(void* buffer, size_t size) override { return 0; } |
99 | |
100 virtual FX_FILESIZE GetPosition() { return 0; } | |
101 | 97 |
102 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; | 98 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; |
99 virtual FX_FILESIZE GetSize() = 0; | |
100 }; | |
103 | 101 |
104 virtual size_t ReadBlock(void* buffer, size_t size) { return 0; } | |
105 }; | |
106 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); | 102 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); |
107 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); | 103 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); |
104 | |
108 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { | 105 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { |
109 public: | 106 public: |
110 virtual IFX_FileStream* Retain() = 0; | 107 virtual IFX_FileStream* Retain() = 0; |
111 | 108 |
112 virtual void Release() = 0; | 109 // IFX_FileRead: |
110 void Release() override = 0; | |
111 FX_BOOL IsEOF() override = 0; | |
112 FX_FILESIZE GetPosition() override = 0; | |
113 size_t ReadBlock(void* buffer, size_t size) override = 0; | |
114 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override = 0; | |
115 FX_FILESIZE GetSize() override = 0; | |
113 | 116 |
114 virtual FX_FILESIZE GetSize() = 0; | 117 // IFX_FileWrite: |
115 | 118 FX_BOOL WriteBlock(const void* buffer, |
116 virtual FX_BOOL IsEOF() = 0; | 119 FX_FILESIZE offset, |
117 | 120 size_t size) override = 0; |
118 virtual FX_FILESIZE GetPosition() = 0; | 121 FX_BOOL WriteBlock(const void* buffer, size_t size) override { |
119 | |
120 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; | |
121 | |
122 virtual size_t ReadBlock(void* buffer, size_t size) = 0; | |
123 | |
124 virtual FX_BOOL WriteBlock(const void* buffer, | |
125 FX_FILESIZE offset, | |
126 size_t size) = 0; | |
127 virtual FX_BOOL WriteBlock(const void* buffer, size_t size) { | |
128 return WriteBlock(buffer, GetSize(), size); | 122 return WriteBlock(buffer, GetSize(), size); |
129 } | 123 } |
124 FX_BOOL Flush() override = 0; | |
125 }; | |
130 | 126 |
131 virtual FX_BOOL Flush() = 0; | |
132 }; | |
133 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes); | 127 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes); |
134 IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD dwModes); | 128 IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD dwModes); |
129 | |
135 class IFX_FileAccess { | 130 class IFX_FileAccess { |
Lei Zhang
2015/11/20 06:20:52
Conflict: XFA only.
| |
136 public: | 131 public: |
137 virtual ~IFX_FileAccess() {} | 132 virtual ~IFX_FileAccess() {} |
138 virtual void Release() = 0; | 133 virtual void Release() = 0; |
139 virtual IFX_FileAccess* Retain() = 0; | 134 virtual IFX_FileAccess* Retain() = 0; |
140 virtual void GetPath(CFX_WideString& wsPath) = 0; | 135 virtual void GetPath(CFX_WideString& wsPath) = 0; |
141 virtual IFX_FileStream* CreateFileStream(FX_DWORD dwModes) = 0; | 136 virtual IFX_FileStream* CreateFileStream(FX_DWORD dwModes) = 0; |
142 }; | 137 }; |
143 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath); | 138 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath); |
139 | |
144 class IFX_MemoryStream : public IFX_FileStream { | 140 class IFX_MemoryStream : public IFX_FileStream { |
145 public: | 141 public: |
146 virtual FX_BOOL IsConsecutive() const = 0; | 142 virtual FX_BOOL IsConsecutive() const = 0; |
147 | 143 |
148 virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0; | 144 virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0; |
149 | 145 |
150 virtual uint8_t* GetBuffer() const = 0; | 146 virtual uint8_t* GetBuffer() const = 0; |
151 | 147 |
152 virtual void AttachBuffer(uint8_t* pBuffer, | 148 virtual void AttachBuffer(uint8_t* pBuffer, |
153 size_t nSize, | 149 size_t nSize, |
154 FX_BOOL bTakeOver = FALSE) = 0; | 150 FX_BOOL bTakeOver = FALSE) = 0; |
155 | 151 |
156 virtual void DetachBuffer() = 0; | 152 virtual void DetachBuffer() = 0; |
157 }; | 153 }; |
158 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, | 154 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, |
159 size_t nSize, | 155 size_t nSize, |
160 FX_BOOL bTakeOver = FALSE); | 156 FX_BOOL bTakeOver = FALSE); |
161 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); | 157 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); |
162 class IFX_BufferRead : public IFX_StreamRead { | 158 class IFX_BufferRead : public IFX_StreamRead { |
163 public: | 159 public: |
164 virtual void Release() = 0; | 160 // IFX_StreamRead: |
165 | 161 void Release() override = 0; |
166 virtual FX_BOOL IsEOF() = 0; | 162 FX_BOOL IsEOF() override = 0; |
167 | 163 FX_FILESIZE GetPosition() override = 0; |
168 virtual FX_FILESIZE GetPosition() = 0; | 164 size_t ReadBlock(void* buffer, size_t size) override = 0; |
169 | |
170 virtual size_t ReadBlock(void* buffer, size_t size) = 0; | |
171 | 165 |
172 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0; | 166 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0; |
173 | |
174 virtual const uint8_t* GetBlockBuffer() = 0; | 167 virtual const uint8_t* GetBlockBuffer() = 0; |
175 | |
176 virtual size_t GetBlockSize() = 0; | 168 virtual size_t GetBlockSize() = 0; |
177 | |
178 virtual FX_FILESIZE GetBlockOffset() = 0; | 169 virtual FX_FILESIZE GetBlockOffset() = 0; |
179 }; | 170 }; |
180 | 171 |
181 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_ | 172 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_ |
OLD | NEW |