]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fstream.h
Changes related to stream includes
[wxWidgets.git] / include / wx / fstream.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: fstream.h
3 // Purpose: File stream classes
4 // Author: Guilhem Lavaux
5 // Modified by:
6 // Created: 11/07/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Guilhem Lavaux
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WXFSTREAM_H__
13 #define _WX_WXFSTREAM_H__
14
15 #ifdef __GNUG__
16 #pragma interface "fstream.h"
17 #endif
18
19 #include <wx/object.h>
20 #include <wx/string.h>
21 #include <wx/stream.h>
22 #include <wx/file.h>
23
24 // Disable warnings such as
25 // 'wxFileStream' : inherits 'wxFileInputStream::Peek' via dominance
26
27 #ifdef _MSC_VER
28 #pragma warning(disable:4250)
29 #endif
30
31 class wxFileStreamBase {
32 protected:
33 wxFile *m_file;
34 bool m_file_destroy;
35 };
36
37 class wxFileInputStream: public virtual wxInputStream,
38 public virtual wxFileStreamBase {
39 public:
40 wxFileInputStream(const wxString& fileName);
41 virtual ~wxFileInputStream();
42
43 virtual char Peek();
44
45 bool Ok() const { return m_file->IsOpened(); }
46
47 protected:
48 wxFileInputStream();
49
50 size_t DoRead(void *buffer, size_t size);
51 off_t DoSeekInput(off_t pos, wxSeekMode mode);
52 off_t DoTellInput() const;
53 };
54
55 class wxFileOutputStream: public virtual wxOutputStream,
56 public virtual wxFileStreamBase {
57 public:
58 wxFileOutputStream(const wxString& fileName);
59 virtual ~wxFileOutputStream();
60
61 // To solve an ambiguity on GCC
62 inline wxOutputStream& Write(const void *buffer, size_t size)
63 { return wxOutputStream::Write(buffer, size); }
64
65 void Sync();
66
67 bool Ok() const { return m_file->IsOpened(); }
68
69 protected:
70 wxFileOutputStream();
71
72 size_t DoWrite(const void *buffer, size_t size);
73 off_t DoSeekOutput(off_t pos, wxSeekMode mode);
74 off_t DoTellOutput() const;
75 };
76
77 class wxFileStream: public wxStream,
78 public wxFileInputStream, public wxFileOutputStream {
79 public:
80 wxFileStream(const wxString& fileName);
81 virtual ~wxFileStream();
82 };
83
84 #ifdef _MSC_VER
85 #pragma warning(default:4250)
86 #endif
87
88 #endif