Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(679)

Side by Side Diff: core/include/fxcrt/fx_stream.h

Issue 1453643002: Add more overrides. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/include/fpdfapi/fpdf_resource.h ('k') | core/src/fpdfapi/fpdf_font/ttgsubtable.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_MemoryStream : public IFX_FileStream { 130 class IFX_MemoryStream : public IFX_FileStream {
136 public: 131 public:
137 virtual FX_BOOL IsConsecutive() const = 0; 132 virtual FX_BOOL IsConsecutive() const = 0;
138 133
139 virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0; 134 virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
140 135
141 virtual uint8_t* GetBuffer() const = 0; 136 virtual uint8_t* GetBuffer() const = 0;
142 137
143 virtual void AttachBuffer(uint8_t* pBuffer, 138 virtual void AttachBuffer(uint8_t* pBuffer,
144 size_t nSize, 139 size_t nSize,
145 FX_BOOL bTakeOver = FALSE) = 0; 140 FX_BOOL bTakeOver = FALSE) = 0;
146 141
147 virtual void DetachBuffer() = 0; 142 virtual void DetachBuffer() = 0;
148 }; 143 };
149 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, 144 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
150 size_t nSize, 145 size_t nSize,
151 FX_BOOL bTakeOver = FALSE); 146 FX_BOOL bTakeOver = FALSE);
152 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); 147 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
153 class IFX_BufferRead : public IFX_StreamRead { 148 class IFX_BufferRead : public IFX_StreamRead {
154 public: 149 public:
155 virtual void Release() = 0; 150 // IFX_StreamRead:
156 151 void Release() override = 0;
157 virtual FX_BOOL IsEOF() = 0; 152 FX_BOOL IsEOF() override = 0;
158 153 FX_FILESIZE GetPosition() override = 0;
159 virtual FX_FILESIZE GetPosition() = 0; 154 size_t ReadBlock(void* buffer, size_t size) override = 0;
160
161 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
162 155
163 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0; 156 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
164
165 virtual const uint8_t* GetBlockBuffer() = 0; 157 virtual const uint8_t* GetBlockBuffer() = 0;
166
167 virtual size_t GetBlockSize() = 0; 158 virtual size_t GetBlockSize() = 0;
168
169 virtual FX_FILESIZE GetBlockOffset() = 0; 159 virtual FX_FILESIZE GetBlockOffset() = 0;
170 }; 160 };
171 161
172 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_ 162 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_
OLDNEW
« no previous file with comments | « core/include/fpdfapi/fpdf_resource.h ('k') | core/src/fpdfapi/fpdf_font/ttgsubtable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698