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

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

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 months 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
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"
11 11
12 void* FX_OpenFolder(const FX_CHAR* path); 12 void* FX_OpenFolder(const FX_CHAR* path);
13 void* FX_OpenFolder(const FX_WCHAR* path); 13 void* FX_OpenFolder(const FX_WCHAR* path);
14 FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder) ; 14 FX_BOOL FX_GetNextFile(void* handle,
15 FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder) ; 15 CFX_ByteString& filename,
16 FX_BOOL& bFolder);
17 FX_BOOL FX_GetNextFile(void* handle,
18 CFX_WideString& filename,
19 FX_BOOL& bFolder);
16 void FX_CloseFolder(void* handle); 20 void FX_CloseFolder(void* handle);
17 FX_WCHAR FX_GetFolderSeparator(); 21 FX_WCHAR FX_GetFolderSeparator();
18 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 22 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
19 #define FX_FILESIZE» » » int32_t 23 #define FX_FILESIZE int32_t
20 #else 24 #else
21 #include <fcntl.h> 25 #include <fcntl.h>
22 #include <unistd.h> 26 #include <unistd.h>
23 #include <sys/stat.h> 27 #include <sys/stat.h>
24 #ifndef O_BINARY 28 #ifndef O_BINARY
25 #define O_BINARY » » 0 29 #define O_BINARY 0
26 #endif 30 #endif
27 #ifndef O_LARGEFILE 31 #ifndef O_LARGEFILE
28 #define O_LARGEFILE» » 0 32 #define O_LARGEFILE 0
29 #endif 33 #endif
30 #define FX_FILESIZE» » » off_t 34 #define FX_FILESIZE off_t
31 #endif 35 #endif
32 #define FX_GETBYTEOFFSET32(a)» 0 36 #define FX_GETBYTEOFFSET32(a) 0
33 #define FX_GETBYTEOFFSET40(a)» 0 37 #define FX_GETBYTEOFFSET40(a) 0
34 #define FX_GETBYTEOFFSET48(a)» 0 38 #define FX_GETBYTEOFFSET48(a) 0
35 #define FX_GETBYTEOFFSET56(a)» 0 39 #define FX_GETBYTEOFFSET56(a) 0
36 #define FX_GETBYTEOFFSET24(a) ((uint8_t)(a>>24)) 40 #define FX_GETBYTEOFFSET24(a) ((uint8_t)(a >> 24))
37 #define FX_GETBYTEOFFSET16(a) ((uint8_t)(a>>16)) 41 #define FX_GETBYTEOFFSET16(a) ((uint8_t)(a >> 16))
38 #define FX_GETBYTEOFFSET8(a) ((uint8_t)(a>>8)) 42 #define FX_GETBYTEOFFSET8(a) ((uint8_t)(a >> 8))
39 #define FX_GETBYTEOFFSET0(a) ((uint8_t)(a)) 43 #define FX_GETBYTEOFFSET0(a) ((uint8_t)(a))
40 #define FX_FILEMODE_Write» » 0 44 #define FX_FILEMODE_Write 0
41 #define FX_FILEMODE_ReadOnly» 1 45 #define FX_FILEMODE_ReadOnly 1
42 #define FX_FILEMODE_Truncate» 2 46 #define FX_FILEMODE_Truncate 2
43 FX_BOOL»» FX_File_Exist(const CFX_ByteStringC& fileName); 47 FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName);
44 FX_BOOL»» FX_File_Exist(const CFX_WideStringC& fileName); 48 FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName);
45 FX_BOOL»» FX_File_Delete(const CFX_ByteStringC& fileName); 49 FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName);
46 FX_BOOL»» FX_File_Delete(const CFX_WideStringC& fileName); 50 FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName);
47 FX_BOOL»» FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteS tringC& fileNameDst); 51 FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc,
48 FX_BOOL»» FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideS tringC& fileNameDst); 52 const CFX_ByteStringC& fileNameDst);
49 FX_BOOL»» FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteS tringC& fileNameDst); 53 FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc,
50 FX_BOOL»» FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideS tringC& fileNameDst); 54 const CFX_WideStringC& fileNameDst);
51 class IFX_StreamWrite 55 FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc,
52 { 56 const CFX_ByteStringC& fileNameDst);
53 public: 57 FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc,
54 virtual ~IFX_StreamWrite() { } 58 const CFX_WideStringC& fileNameDst);
55 virtual void» » Release() = 0; 59 class IFX_StreamWrite {
60 public:
61 virtual ~IFX_StreamWrite() {}
62 virtual void Release() = 0;
56 63
57 virtual» FX_BOOL»» WriteBlock(const void* pData, size_t size) = 0; 64 virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0;
58 }; 65 };
59 class IFX_FileWrite : public IFX_StreamWrite 66 class IFX_FileWrite : public IFX_StreamWrite {
60 { 67 public:
61 public: 68 virtual void Release() = 0;
62 69
63 virtual void» » » Release() = 0; 70 virtual FX_FILESIZE GetSize() = 0;
64 71
65 virtual FX_FILESIZE»» GetSize() = 0; 72 virtual FX_BOOL Flush() = 0;
66 73
67 virtual FX_BOOL» » » Flush() = 0; 74 virtual FX_BOOL WriteBlock(const void* pData,
68 75 FX_FILESIZE offset,
69 virtual» FX_BOOL»» » WriteBlock(const void* pData, FX_FILESIZ E offset, size_t size) = 0; 76 size_t size) = 0;
70 virtual» FX_BOOL»» » WriteBlock(const void* pData, size_t siz e) 77 virtual FX_BOOL WriteBlock(const void* pData, size_t size) {
71 { 78 return WriteBlock(pData, GetSize(), size);
72 return WriteBlock(pData, GetSize(), size); 79 }
73 }
74 }; 80 };
75 IFX_FileWrite* FX_CreateFileWrite(const FX_CHAR* filename); 81 IFX_FileWrite* FX_CreateFileWrite(const FX_CHAR* filename);
76 IFX_FileWrite* FX_CreateFileWrite(const FX_WCHAR* filename); 82 IFX_FileWrite* FX_CreateFileWrite(const FX_WCHAR* filename);
77 class IFX_StreamRead 83 class IFX_StreamRead {
78 { 84 public:
79 public: 85 virtual ~IFX_StreamRead() {}
80 virtual ~IFX_StreamRead() { }
81 86
82 virtual void» » » Release() = 0; 87 virtual void Release() = 0;
83 88
84 virtual FX_BOOL» » » IsEOF() = 0; 89 virtual FX_BOOL IsEOF() = 0;
85 90
86 virtual FX_FILESIZE»» GetPosition() = 0; 91 virtual FX_FILESIZE GetPosition() = 0;
87 92
88 virtual size_t» » » ReadBlock(void* buffer, size_t size) = 0 ; 93 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
89 }; 94 };
90 class IFX_FileRead : IFX_StreamRead 95 class IFX_FileRead : IFX_StreamRead {
91 { 96 public:
92 public: 97 virtual void Release() = 0;
93 virtual void» » » Release() = 0;
94 98
95 virtual FX_FILESIZE»» GetSize() = 0; 99 virtual FX_FILESIZE GetSize() = 0;
96 100
97 virtual FX_BOOL» » » IsEOF() 101 virtual FX_BOOL IsEOF() { return FALSE; }
98 {
99 return FALSE;
100 }
101 102
102 virtual FX_FILESIZE»» GetPosition() 103 virtual FX_FILESIZE GetPosition() { return 0; }
103 {
104 return 0;
105 }
106 104
107 virtual FX_BOOL» » » SetRange(FX_FILESIZE offset, FX_FILESIZE size) 105 virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) {
108 { 106 return FALSE;
109 return FALSE; 107 }
110 }
111 108
112 virtual void» » » ClearRange() {} 109 virtual void ClearRange() {}
113 110
114 virtual FX_BOOL» » » ReadBlock(void* buffer, FX_FILESIZE offs et, size_t size) = 0; 111 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
115 112
116 virtual size_t» » » ReadBlock(void* buffer, size_t size) 113 virtual size_t ReadBlock(void* buffer, size_t size) { return 0; }
117 {
118 return 0;
119 }
120 }; 114 };
121 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename); 115 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename);
122 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename); 116 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename);
123 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite 117 class IFX_FileStream : public IFX_FileRead, public IFX_FileWrite {
124 { 118 public:
125 public: 119 virtual IFX_FileStream* Retain() = 0;
126 120
127 virtual IFX_FileStream*» » Retain() = 0; 121 virtual void Release() = 0;
128 122
129 virtual void» » » » Release() = 0; 123 virtual FX_FILESIZE GetSize() = 0;
130 124
131 virtual FX_FILESIZE»» » GetSize() = 0; 125 virtual FX_BOOL IsEOF() = 0;
132 126
133 virtual FX_BOOL» » » » IsEOF() = 0; 127 virtual FX_FILESIZE GetPosition() = 0;
134 128
135 virtual FX_FILESIZE»» » GetPosition() = 0; 129 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0;
136 130
137 virtual FX_BOOL» » » » ReadBlock(void* buffer, FX_FILES IZE offset, size_t size) = 0; 131 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
138 132
139 virtual size_t» » » » ReadBlock(void* buffer, size_t s ize) = 0; 133 virtual FX_BOOL WriteBlock(const void* buffer,
134 FX_FILESIZE offset,
135 size_t size) = 0;
136 virtual FX_BOOL WriteBlock(const void* buffer, size_t size) {
137 return WriteBlock(buffer, GetSize(), size);
138 }
140 139
141 virtual» FX_BOOL»» » » WriteBlock(const void* buffer, F X_FILESIZE offset, size_t size) = 0; 140 virtual FX_BOOL Flush() = 0;
142 virtual» FX_BOOL»» » » WriteBlock(const void* buffer, s ize_t size) 141 };
143 { 142 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes);
144 return WriteBlock(buffer, GetSize(), size); 143 IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD dwModes);
145 } 144 class IFX_MemoryStream : public IFX_FileStream {
145 public:
146 virtual FX_BOOL IsConsecutive() const = 0;
146 147
147 virtual FX_BOOL» » » » Flush() = 0; 148 virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0;
149
150 virtual uint8_t* GetBuffer() const = 0;
151
152 virtual void AttachBuffer(uint8_t* pBuffer,
153 size_t nSize,
154 FX_BOOL bTakeOver = FALSE) = 0;
155
156 virtual void DetachBuffer() = 0;
148 }; 157 };
149 IFX_FileStream*»» FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dw Modes); 158 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
150 IFX_FileStream*»» FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD d wModes); 159 size_t nSize,
151 class IFX_MemoryStream : public IFX_FileStream 160 FX_BOOL bTakeOver = FALSE);
152 { 161 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
153 public: 162 class IFX_BufferRead : public IFX_StreamRead {
163 public:
164 virtual void Release() = 0;
154 165
155 virtual FX_BOOL» » » IsConsecutive() const = 0; 166 virtual FX_BOOL IsEOF() = 0;
156 167
157 virtual void» » » EstimateSize(size_t nInitSize, size_t nG rowSize) = 0; 168 virtual FX_FILESIZE GetPosition() = 0;
158 169
159 virtual uint8_t*» » GetBuffer() const = 0; 170 virtual size_t ReadBlock(void* buffer, size_t size) = 0;
160 171
161 virtual void» » » AttachBuffer(uint8_t* pBuffer, size_t nS ize, FX_BOOL bTakeOver = FALSE) = 0; 172 virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
162 173
163 virtual void» » » DetachBuffer() = 0; 174 virtual const uint8_t* GetBlockBuffer() = 0;
164 };
165 IFX_MemoryStream*» FX_CreateMemoryStream(uint8_t* pBuffer, size_t nSize, FX _BOOL bTakeOver = FALSE);
166 IFX_MemoryStream*» FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE);
167 class IFX_BufferRead : public IFX_StreamRead
168 {
169 public:
170 175
171 virtual void» » » Release() = 0; 176 virtual size_t GetBlockSize() = 0;
172 177
173 virtual FX_BOOL» » » IsEOF() = 0; 178 virtual FX_FILESIZE GetBlockOffset() = 0;
174
175 virtual FX_FILESIZE»» GetPosition() = 0;
176
177 virtual size_t» » » ReadBlock(void* buffer, size_t size) = 0 ;
178
179 virtual FX_BOOL» » » ReadNextBlock(FX_BOOL bRestart = FALSE) = 0;
180
181 virtual const uint8_t*» » GetBlockBuffer() = 0;
182
183 virtual size_t» » » GetBlockSize() = 0;
184
185 virtual FX_FILESIZE»» GetBlockOffset() = 0;
186 }; 179 };
187 180
188 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_ 181 #endif // CORE_INCLUDE_FXCRT_FX_STREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698