]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/wfstream.h
change generic ints to enums in wxDC (closes #9959)
[wxWidgets.git] / interface / wx / wfstream.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wfstream.h
3 // Purpose: interface of wxTempFileOutputStream
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxTempFileOutputStream
11
12 wxTempFileOutputStream is an output stream based on wxTempFile.
13 It provides a relatively safe way to replace the contents of the
14 existing file.
15
16 @library{wxbase}
17 @category{streams}
18
19 @see wxTempFile
20 */
21 class wxTempFileOutputStream : public wxOutputStream
22 {
23 public:
24 /**
25 Associates wxTempFileOutputStream with the file to be replaced and opens it.
26 You should use wxStreamBase::IsOk() to verify if the constructor succeeded.
27
28 Call Commit() or wxOutputStream::Close() to replace the old file and close
29 this one. Calling Discard() (or allowing the destructor to do it) will
30 discard the changes.
31 */
32 wxTempFileOutputStream(const wxString& fileName);
33
34 /**
35 Validate changes: deletes the old file of the given name and renames the new
36 file to the old name. Returns @true if both actions succeeded.
37
38 If @false is returned it may unfortunately mean two quite different things: either that
39 either the old file couldn't be deleted or that the new file couldn't be renamed
40 to the old name.
41 */
42 virtual bool Commit();
43
44 /**
45 Discard changes: the old file contents are not changed, the temporary file is
46 deleted.
47 */
48 virtual void Discard();
49 };
50
51
52
53 /**
54 @class wxFFileOutputStream
55
56 This class represents data written to a file.
57 There are actually two such groups of classes: this one is based on wxFFile
58 whereas wxFileInputStream is based in the wxFile class.
59
60 Note that wxOutputStream::SeekO() can seek beyond the end of the stream
61 (file) and will thus not return ::wxInvalidOffset for that.
62
63 @library{wxbase}
64 @category{streams}
65
66 @see wxBufferedOutputStream, wxFFileInputStream, wxFileInputStream
67 */
68 class wxFFileOutputStream : public wxOutputStream
69 {
70 public:
71 /**
72 Initializes a file stream in write-only mode using the file descriptor @e fp.
73 */
74 wxFFileOutputStream(const wxString& filename,
75 const wxString& mode = "wb");
76
77 /**
78 Initializes a file stream in write-only mode using the file I/O object file.
79 */
80 wxFFileOutputStream(wxFFile& file);
81
82 /**
83 Initializes a file stream in write-only mode using the file descriptor fp.
84 */
85 wxFFileOutputStream(FILE* fp);
86
87 /**
88 Destructor.
89 */
90 virtual ~wxFFileOutputStream();
91
92 /**
93 Returns @true if the stream is initialized and ready.
94 */
95 bool IsOk() const;
96 };
97
98
99
100 /**
101 @class wxFileOutputStream
102
103 This class represents data written to a file.
104 There are actually two such groups of classes: this one is based on wxFile
105 whereas wxFFileInputStream is based in the wxFFile class.
106
107 Note that wxOutputStream::SeekO() can seek beyond the end of the stream
108 (file) and will thus not return ::wxInvalidOffset for that.
109
110 @library{wxbase}
111 @category{streams}
112
113 @see wxBufferedOutputStream, wxFileInputStream, wxFFileInputStream
114 */
115 class wxFileOutputStream : public wxOutputStream
116 {
117 public:
118 /**
119 Creates a new file with ofilename name and initializes the stream in write-only mode.
120 */
121 wxFileOutputStream(const wxString& ofileName);
122
123 /**
124 Initializes a file stream in write-only mode using the file I/O object file.
125 */
126 wxFileOutputStream(wxFile& file);
127
128 /**
129 Initializes a file stream in write-only mode using the file descriptor @e fd.
130 */
131 wxFileOutputStream(int fd);
132
133 /**
134 Destructor.
135 */
136 virtual ~wxFileOutputStream();
137
138 /**
139 Returns @true if the stream is initialized and ready.
140 */
141 bool IsOk() const;
142 };
143
144
145
146 /**
147 @class wxFileInputStream
148
149 This class represents data read in from a file.
150 There are actually two such groups of classes: this one is based on wxFile
151 whereas wxFFileInputStream is based in the wxFFile class.
152
153 Note that wxInputStream::SeekI() can seek beyond the end of the stream (file)
154 and will thus not return ::wxInvalidOffset for that.
155
156 @library{wxbase}
157 @category{streams}
158
159 @see wxBufferedInputStream, wxFileOutputStream, wxFFileOutputStream
160 */
161 class wxFileInputStream : public wxInputStream
162 {
163 public:
164 /**
165 Opens the specified file using its ifilename name in read-only mode.
166 */
167 wxFileInputStream(const wxString& ifileName);
168
169 /**
170 Initializes a file stream in read-only mode using the file I/O object file.
171 */
172 wxFileInputStream(wxFile& file);
173
174 /**
175 Initializes a file stream in read-only mode using the specified file descriptor.
176 */
177 wxFileInputStream(int fd);
178
179 /**
180 Destructor.
181 */
182 virtual ~wxFileInputStream();
183
184 /**
185 Returns @true if the stream is initialized and ready.
186 */
187 bool IsOk() const;
188 };
189
190
191
192 /**
193 @class wxFFileInputStream
194
195 This class represents data read in from a file.
196 There are actually two such groups of classes: this one is based on wxFFile
197 whereas wxFileInputStream is based in the wxFile class.
198
199 Note that wxInputStream::SeekI() can seek beyond the end of the stream (file)
200 and will thus not return ::wxInvalidOffset for that.
201
202 @library{wxbase}
203 @category{streams}
204
205 @see wxBufferedInputStream, wxFFileOutputStream, wxFileOutputStream
206 */
207 class wxFFileInputStream : public wxInputStream
208 {
209 public:
210 /**
211 Opens the specified file using its filename name using the specified mode.
212 */
213 wxFFileInputStream(const wxString& filename,
214 const wxString& mode = "rb");
215
216 /**
217 Initializes a file stream in read-only mode using the file I/O object file.
218 */
219 wxFFileInputStream(wxFFile& file);
220
221 /**
222 Initializes a file stream in read-only mode using the specified file pointer @a fp.
223 */
224 wxFFileInputStream(FILE* fp);
225
226 /**
227 Destructor.
228 */
229 virtual ~wxFFileInputStream();
230
231 /**
232 Returns @true if the stream is initialized and ready.
233 */
234 bool IsOk() const;
235 };
236
237
238
239 /**
240 @class wxFFileStream
241
242 @todo describe this class.
243
244 @library{wxbase}
245 @category{streams}
246
247 @see wxStreamBuffer
248 */
249 class wxFFileStream : public wxFFileOutputStream
250 {
251 public:
252 /**
253 Initializes a new file stream in read-write mode using the specified
254 @a iofilename name.
255 */
256 wxFFileStream(const wxString& iofileName, const wxString& mode = "w+b");
257 };
258
259
260
261 /**
262 @class wxFileStream
263
264 @todo describe this class.
265
266 @library{wxbase}
267 @category{streams}
268
269 @see wxStreamBuffer
270 */
271 class wxFileStream : public wxFileOutputStream
272 {
273 public:
274 /**
275 Initializes a new file stream in read-write mode using the specified
276 @a iofilename name.
277 */
278 wxFileStream(const wxString& iofileName);
279 };
280