]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wfstream.h | |
e54c96f1 | 3 | // Purpose: interface of wxTempFileOutputStream |
23324ae1 | 4 | // Author: wxWidgets team |
526954c5 | 5 | // Licence: wxWindows licence |
23324ae1 FM |
6 | ///////////////////////////////////////////////////////////////////////////// |
7 | ||
8 | /** | |
9 | @class wxTempFileOutputStream | |
7c913512 | 10 | |
e25cd775 FM |
11 | wxTempFileOutputStream is an output stream based on wxTempFile. |
12 | It provides a relatively safe way to replace the contents of the | |
23324ae1 | 13 | existing file. |
7c913512 | 14 | |
23324ae1 FM |
15 | @library{wxbase} |
16 | @category{streams} | |
7c913512 | 17 | |
e54c96f1 | 18 | @see wxTempFile |
23324ae1 FM |
19 | */ |
20 | class wxTempFileOutputStream : public wxOutputStream | |
21 | { | |
22 | public: | |
23 | /** | |
24 | Associates wxTempFileOutputStream with the file to be replaced and opens it. | |
9690b006 FM |
25 | |
26 | @warning | |
e25cd775 FM |
27 | You should use wxStreamBase::IsOk() to verify if the constructor succeeded. |
28 | ||
29 | Call Commit() or wxOutputStream::Close() to replace the old file and close | |
30 | this one. Calling Discard() (or allowing the destructor to do it) will | |
31 | discard the changes. | |
23324ae1 FM |
32 | */ |
33 | wxTempFileOutputStream(const wxString& fileName); | |
34 | ||
35 | /** | |
36 | Validate changes: deletes the old file of the given name and renames the new | |
e25cd775 FM |
37 | file to the old name. Returns @true if both actions succeeded. |
38 | ||
39 | If @false is returned it may unfortunately mean two quite different things: either that | |
23324ae1 FM |
40 | either the old file couldn't be deleted or that the new file couldn't be renamed |
41 | to the old name. | |
42 | */ | |
adaaa686 | 43 | virtual bool Commit(); |
23324ae1 FM |
44 | |
45 | /** | |
46 | Discard changes: the old file contents are not changed, the temporary file is | |
47 | deleted. | |
48 | */ | |
adaaa686 | 49 | virtual void Discard(); |
23324ae1 FM |
50 | }; |
51 | ||
52 | ||
e54c96f1 | 53 | |
23324ae1 FM |
54 | /** |
55 | @class wxFFileOutputStream | |
7c913512 | 56 | |
e25cd775 FM |
57 | This class represents data written to a file. |
58 | There are actually two such groups of classes: this one is based on wxFFile | |
e4d531ee | 59 | whereas wxFileOutputStream is based in the wxFile class. |
7c913512 | 60 | |
e25cd775 FM |
61 | Note that wxOutputStream::SeekO() can seek beyond the end of the stream |
62 | (file) and will thus not return ::wxInvalidOffset for that. | |
7c913512 | 63 | |
23324ae1 FM |
64 | @library{wxbase} |
65 | @category{streams} | |
7c913512 | 66 | |
e4d531ee | 67 | @see wxBufferedOutputStream, wxFFileInputStream, wxFileOutputStream, wxFileInputStream |
23324ae1 FM |
68 | */ |
69 | class wxFFileOutputStream : public wxOutputStream | |
70 | { | |
71 | public: | |
23324ae1 | 72 | /** |
9690b006 FM |
73 | Open the given file @a filename with mode @a mode. |
74 | ||
75 | @warning | |
76 | You should use wxStreamBase::IsOk() to verify if the constructor succeeded. | |
23324ae1 FM |
77 | */ |
78 | wxFFileOutputStream(const wxString& filename, | |
95b4a59e | 79 | const wxString& mode = "wb"); |
e25cd775 FM |
80 | |
81 | /** | |
82 | Initializes a file stream in write-only mode using the file I/O object file. | |
83 | */ | |
7c913512 | 84 | wxFFileOutputStream(wxFFile& file); |
e25cd775 FM |
85 | |
86 | /** | |
87 | Initializes a file stream in write-only mode using the file descriptor fp. | |
88 | */ | |
4cc4bfaf | 89 | wxFFileOutputStream(FILE* fp); |
23324ae1 FM |
90 | |
91 | /** | |
92 | Destructor. | |
93 | */ | |
adaaa686 | 94 | virtual ~wxFFileOutputStream(); |
23324ae1 FM |
95 | |
96 | /** | |
97 | Returns @true if the stream is initialized and ready. | |
98 | */ | |
328f5751 | 99 | bool IsOk() const; |
7f297193 VZ |
100 | |
101 | /** | |
102 | Returns the underlying file object. | |
103 | @since 2.9.5 | |
104 | */ | |
105 | wxFFile* GetFile() const; | |
23324ae1 FM |
106 | }; |
107 | ||
108 | ||
e54c96f1 | 109 | |
23324ae1 FM |
110 | /** |
111 | @class wxFileOutputStream | |
7c913512 | 112 | |
e25cd775 FM |
113 | This class represents data written to a file. |
114 | There are actually two such groups of classes: this one is based on wxFile | |
e4d531ee | 115 | whereas wxFFileOutputStream is based in the wxFFile class. |
7c913512 | 116 | |
e25cd775 FM |
117 | Note that wxOutputStream::SeekO() can seek beyond the end of the stream |
118 | (file) and will thus not return ::wxInvalidOffset for that. | |
7c913512 | 119 | |
23324ae1 FM |
120 | @library{wxbase} |
121 | @category{streams} | |
7c913512 | 122 | |
e4d531ee | 123 | @see wxBufferedOutputStream, wxFileInputStream, wxFFileOutputStream, wxFFileInputStream |
23324ae1 FM |
124 | */ |
125 | class wxFileOutputStream : public wxOutputStream | |
126 | { | |
127 | public: | |
23324ae1 | 128 | /** |
9690b006 | 129 | Creates a new file with @a ofileName name and initializes the stream in write-only mode. |
3e97b550 | 130 | |
9690b006 FM |
131 | @warning |
132 | You should use wxStreamBase::IsOk() to verify if the constructor succeeded. | |
23324ae1 FM |
133 | */ |
134 | wxFileOutputStream(const wxString& ofileName); | |
e25cd775 FM |
135 | |
136 | /** | |
137 | Initializes a file stream in write-only mode using the file I/O object file. | |
138 | */ | |
7c913512 | 139 | wxFileOutputStream(wxFile& file); |
e25cd775 FM |
140 | |
141 | /** | |
142 | Initializes a file stream in write-only mode using the file descriptor @e fd. | |
143 | */ | |
7c913512 | 144 | wxFileOutputStream(int fd); |
23324ae1 FM |
145 | |
146 | /** | |
147 | Destructor. | |
148 | */ | |
adaaa686 | 149 | virtual ~wxFileOutputStream(); |
23324ae1 FM |
150 | |
151 | /** | |
152 | Returns @true if the stream is initialized and ready. | |
153 | */ | |
328f5751 | 154 | bool IsOk() const; |
7f297193 VZ |
155 | |
156 | /** | |
157 | Returns the underlying file object. | |
158 | @since 2.9.5 | |
159 | */ | |
160 | wxFile* GetFile() const; | |
23324ae1 FM |
161 | }; |
162 | ||
163 | ||
e54c96f1 | 164 | |
23324ae1 FM |
165 | /** |
166 | @class wxFileInputStream | |
7c913512 | 167 | |
e25cd775 FM |
168 | This class represents data read in from a file. |
169 | There are actually two such groups of classes: this one is based on wxFile | |
170 | whereas wxFFileInputStream is based in the wxFFile class. | |
7c913512 | 171 | |
e25cd775 FM |
172 | Note that wxInputStream::SeekI() can seek beyond the end of the stream (file) |
173 | and will thus not return ::wxInvalidOffset for that. | |
7c913512 | 174 | |
23324ae1 FM |
175 | @library{wxbase} |
176 | @category{streams} | |
7c913512 | 177 | |
e54c96f1 | 178 | @see wxBufferedInputStream, wxFileOutputStream, wxFFileOutputStream |
23324ae1 FM |
179 | */ |
180 | class wxFileInputStream : public wxInputStream | |
181 | { | |
182 | public: | |
23324ae1 | 183 | /** |
9690b006 | 184 | Opens the specified file using its @a ifileName name in read-only mode. |
3e97b550 | 185 | |
9690b006 FM |
186 | @warning |
187 | You should use wxStreamBase::IsOk() to verify if the constructor succeeded. | |
23324ae1 FM |
188 | */ |
189 | wxFileInputStream(const wxString& ifileName); | |
e25cd775 FM |
190 | |
191 | /** | |
192 | Initializes a file stream in read-only mode using the file I/O object file. | |
193 | */ | |
7c913512 | 194 | wxFileInputStream(wxFile& file); |
e25cd775 FM |
195 | |
196 | /** | |
197 | Initializes a file stream in read-only mode using the specified file descriptor. | |
198 | */ | |
7c913512 | 199 | wxFileInputStream(int fd); |
23324ae1 FM |
200 | |
201 | /** | |
202 | Destructor. | |
203 | */ | |
adaaa686 | 204 | virtual ~wxFileInputStream(); |
23324ae1 FM |
205 | |
206 | /** | |
207 | Returns @true if the stream is initialized and ready. | |
208 | */ | |
328f5751 | 209 | bool IsOk() const; |
7f297193 VZ |
210 | |
211 | /** | |
212 | Returns the underlying file object. | |
213 | @since 2.9.5 | |
214 | */ | |
215 | wxFile* GetFile() const; | |
23324ae1 FM |
216 | }; |
217 | ||
218 | ||
e54c96f1 | 219 | |
23324ae1 FM |
220 | /** |
221 | @class wxFFileInputStream | |
7c913512 | 222 | |
e25cd775 FM |
223 | This class represents data read in from a file. |
224 | There are actually two such groups of classes: this one is based on wxFFile | |
225 | whereas wxFileInputStream is based in the wxFile class. | |
7c913512 | 226 | |
e25cd775 FM |
227 | Note that wxInputStream::SeekI() can seek beyond the end of the stream (file) |
228 | and will thus not return ::wxInvalidOffset for that. | |
7c913512 | 229 | |
23324ae1 FM |
230 | @library{wxbase} |
231 | @category{streams} | |
7c913512 | 232 | |
e54c96f1 | 233 | @see wxBufferedInputStream, wxFFileOutputStream, wxFileOutputStream |
23324ae1 FM |
234 | */ |
235 | class wxFFileInputStream : public wxInputStream | |
236 | { | |
237 | public: | |
23324ae1 | 238 | /** |
9690b006 FM |
239 | Opens the specified file using its @a filename name using the specified @a mode. |
240 | ||
241 | @warning | |
242 | You should use wxStreamBase::IsOk() to verify if the constructor succeeded. | |
23324ae1 FM |
243 | */ |
244 | wxFFileInputStream(const wxString& filename, | |
245 | const wxString& mode = "rb"); | |
e25cd775 FM |
246 | |
247 | /** | |
248 | Initializes a file stream in read-only mode using the file I/O object file. | |
249 | */ | |
7c913512 | 250 | wxFFileInputStream(wxFFile& file); |
e25cd775 FM |
251 | |
252 | /** | |
253 | Initializes a file stream in read-only mode using the specified file pointer @a fp. | |
254 | */ | |
4cc4bfaf | 255 | wxFFileInputStream(FILE* fp); |
23324ae1 FM |
256 | |
257 | /** | |
258 | Destructor. | |
259 | */ | |
adaaa686 | 260 | virtual ~wxFFileInputStream(); |
23324ae1 FM |
261 | |
262 | /** | |
263 | Returns @true if the stream is initialized and ready. | |
264 | */ | |
328f5751 | 265 | bool IsOk() const; |
7f297193 VZ |
266 | |
267 | /** | |
268 | Returns the underlying file object. | |
269 | @since 2.9.5 | |
270 | */ | |
271 | wxFFile* GetFile() const; | |
23324ae1 FM |
272 | }; |
273 | ||
274 | ||
e54c96f1 | 275 | |
23324ae1 FM |
276 | /** |
277 | @class wxFFileStream | |
7c913512 | 278 | |
3e97b550 VZ |
279 | This stream allows to both read from and write to a file using buffered |
280 | STDIO functions. | |
7c913512 | 281 | |
23324ae1 | 282 | @library{wxbase} |
e25cd775 | 283 | @category{streams} |
7c913512 | 284 | |
3e97b550 | 285 | @see wxFFileInputStream, wxFFileOutputStream, wxFileStream |
23324ae1 | 286 | */ |
3e97b550 VZ |
287 | class wxFFileStream : public wxFFileInputStream, |
288 | public wxFFileOutputStream | |
23324ae1 FM |
289 | { |
290 | public: | |
291 | /** | |
9690b006 FM |
292 | Initializes a new file stream in the given @a mode using the specified |
293 | @a iofileName name. | |
3e97b550 | 294 | |
9690b006 FM |
295 | @warning |
296 | You should use wxStreamBase::IsOk() to verify if the constructor succeeded. | |
23324ae1 | 297 | */ |
02e22828 | 298 | wxFFileStream(const wxString& iofileName, const wxString& mode = "w+b"); |
3e97b550 VZ |
299 | |
300 | /** | |
301 | Returns @true if the stream is initialized and ready. | |
302 | ||
303 | This method returns @true if the stream can be both read from and | |
304 | written to. | |
305 | */ | |
306 | bool IsOk() const; | |
23324ae1 FM |
307 | }; |
308 | ||
309 | ||
e54c96f1 | 310 | |
23324ae1 FM |
311 | /** |
312 | @class wxFileStream | |
7c913512 | 313 | |
3e97b550 VZ |
314 | This class represents data that can be both read from and written to a file. |
315 | There are actually two such groups of classes: this one is based on wxFile | |
316 | whereas wxFFileStream is based in the wxFFile class. | |
7c913512 | 317 | |
23324ae1 | 318 | @library{wxbase} |
e25cd775 | 319 | @category{streams} |
7c913512 | 320 | |
3e97b550 | 321 | @see wxFileInputStream, wxFileOutputStream, wxFFileStream |
23324ae1 | 322 | */ |
3e97b550 VZ |
323 | class wxFileStream : public wxFileOutputStream, |
324 | public wxFileInputStream | |
23324ae1 FM |
325 | { |
326 | public: | |
327 | /** | |
7c913512 | 328 | Initializes a new file stream in read-write mode using the specified |
9690b006 | 329 | @a iofileName name. |
3e97b550 | 330 | |
9690b006 | 331 | @warning |
3e97b550 | 332 | You should use IsOk() to verify if the constructor succeeded. |
23324ae1 FM |
333 | */ |
334 | wxFileStream(const wxString& iofileName); | |
3e97b550 VZ |
335 | |
336 | /** | |
337 | Returns @true if the stream is initialized and ready. | |
338 | ||
339 | This method returns @true if the stream can be both read from and | |
340 | written to. | |
341 | */ | |
342 | bool IsOk() const; | |
23324ae1 | 343 | }; |
e54c96f1 | 344 |