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

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: 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 63
64 virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0; 64 virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
65 }; 65 };
66
66 class IFX_FileWrite : public IFX_StreamWrite { 67 class IFX_FileWrite : public IFX_StreamWrite {
67 public: 68 public:
68 virtual void Release() = 0; 69 // IFX_StreamWrite:
Tom Sepez 2015/11/18 00:36:22 what happened to Release()?
Lei Zhang 2015/11/19 00:39:04 Doesn't it seem silly to override a pure virtual m
70 FX_BOOL WriteBlock(const void* pData, size_t size) override {
71 return WriteBlock(pData, GetSize(), size);
72 }
69 73
70 virtual FX_FILESIZE GetSize() = 0; 74 virtual FX_FILESIZE GetSize() = 0;
71
72 virtual FX_BOOL Flush() = 0; 75 virtual FX_BOOL Flush() = 0;
73
74 virtual FX_BOOL WriteBlock(const void* pData, 76 virtual FX_BOOL WriteBlock(const void* pData,
75 FX_FILESIZE offset, 77 FX_FILESIZE offset,
76 size_t size) = 0; 78 size_t size) = 0;
77 virtual FX_BOOL WriteBlock(const void* pData, size_t size) {
78 return WriteBlock(pData, GetSize(), size);
79 }
80 }; 79 };
80
81 class IFX_StreamRead { 81 class IFX_StreamRead {
82 public: 82 public:
83 virtual ~IFX_StreamRead() {} 83 virtual ~IFX_StreamRead() {}
84 84
85 virtual void Release() = 0; 85 virtual void Release() = 0;
86
87 virtual FX_BOOL IsEOF() = 0; 86 virtual FX_BOOL IsEOF() = 0;
88
89 virtual FX_FILESIZE GetPosition() = 0; 87 virtual FX_FILESIZE GetPosition() = 0;
90
91 virtual size_t ReadBlock(void* buffer, size_t size) = 0; 88 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
92 }; 89 };
90
93 class IFX_FileRead : IFX_StreamRead { 91 class IFX_FileRead : IFX_StreamRead {
94 public: 92 public:
95 virtual void Release() = 0; 93 // IFX_StreamRead:
96 94 void Release() override = 0;
Tom Sepez 2015/11/18 00:36:22 I'd not seen override = 0 before. Does that make
Lei Zhang 2015/11/19 00:39:04 I tried removing this, but then the compiler reali
97 virtual FX_FILESIZE GetSize() = 0; 95 FX_BOOL IsEOF() override { return FALSE; }
98 96 FX_FILESIZE GetPosition() override { return 0; }
99 virtual FX_BOOL IsEOF() { return FALSE; } 97 size_t ReadBlock(void* buffer, size_t size) override { return 0; }
100
101 virtual FX_FILESIZE GetPosition() { return 0; }
102 98
103 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; 99 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
100 virtual FX_FILESIZE GetSize() = 0;
101 };
104 102
105 virtual size_t ReadBlock(void* buffer, size_t size) { return 0; }
106 };
107 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); 103 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename);
108 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); 104 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename);
105
109 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite { 106 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite {
110 public: 107 public:
111 virtual IFX_FileStream* Retain() = 0; 108 virtual IFX_FileStream* Retain() = 0;
112 109
113 virtual void Release() = 0; 110 // IFX_FileRead:
111 void Release() override = 0;
Tom Sepez 2015/11/18 00:36:22 ditto
Lei Zhang 2015/11/19 00:39:04 ditto ditto
112 FX_BOOL IsEOF() override = 0;
113 FX_FILESIZE GetPosition() override = 0;
114 size_t ReadBlock(void* buffer, size_t size) override = 0;
115 FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override = 0;
116 FX_FILESIZE GetSize() override = 0;
114 117
115 virtual FX_FILESIZE GetSize() = 0; 118 // IFX_FileWrite:
116 119 FX_BOOL WriteBlock(const void* buffer,
117 virtual FX_BOOL IsEOF() = 0; 120 FX_FILESIZE offset,
118 121 size_t size) override = 0;
119 virtual FX_FILESIZE GetPosition() = 0; 122 FX_BOOL WriteBlock(const void* buffer, size_t size) override {
120
121 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
122
123 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
124
125 virtual FX_BOOL WriteBlock(const void* buffer,
126 FX_FILESIZE offset,
127 size_t size) = 0;
128 virtual FX_BOOL WriteBlock(const void* buffer, size_t size) {
129 return WriteBlock(buffer, GetSize(), size); 123 return WriteBlock(buffer, GetSize(), size);
130 } 124 }
125 FX_BOOL Flush() override = 0;
126 };
131 127
132 virtual FX_BOOL Flush() = 0;
133 };
134 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes); 128 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes);
135 IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD dwModes); 129 IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD dwModes);
130
136 class IFX_MemoryStream : public IFX_FileStream { 131 class IFX_MemoryStream : public IFX_FileStream {
137 public: 132 public:
138 virtual FX_BOOL IsConsecutive() const = 0; 133 virtual FX_BOOL IsConsecutive() const = 0;
139 134
140 virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0; 135 virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
141 136
142 virtual uint8_t* GetBuffer() const = 0; 137 virtual uint8_t* GetBuffer() const = 0;
143 138
144 virtual void AttachBuffer(uint8_t* pBuffer, 139 virtual void AttachBuffer(uint8_t* pBuffer,
145 size_t nSize, 140 size_t nSize,
146 FX_BOOL bTakeOver = FALSE) = 0; 141 FX_BOOL bTakeOver = FALSE) = 0;
147 142
148 virtual void DetachBuffer() = 0; 143 virtual void DetachBuffer() = 0;
149 }; 144 };
150 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, 145 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
151 size_t nSize, 146 size_t nSize,
152 FX_BOOL bTakeOver = FALSE); 147 FX_BOOL bTakeOver = FALSE);
153 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); 148 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
154 class IFX_BufferRead : public IFX_StreamRead { 149 class IFX_BufferRead : public IFX_StreamRead {
155 public: 150 public:
156 virtual void Release() = 0; 151 // IFX_StreamRead:
157 152 void Release() override = 0;
158 virtual FX_BOOL IsEOF() = 0; 153 FX_BOOL IsEOF() override = 0;
159 154 FX_FILESIZE GetPosition() override = 0;
160 virtual FX_FILESIZE GetPosition() = 0; 155 size_t ReadBlock(void* buffer, size_t size) override = 0;
161
162 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
163 156
164 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0; 157 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
165
166 virtual const uint8_t* GetBlockBuffer() = 0; 158 virtual const uint8_t* GetBlockBuffer() = 0;
167
168 virtual size_t GetBlockSize() = 0; 159 virtual size_t GetBlockSize() = 0;
169
170 virtual FX_FILESIZE GetBlockOffset() = 0; 160 virtual FX_FILESIZE GetBlockOffset() = 0;
171 }; 161 };
172 162
173 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_ 163 #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