1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/stdstream.h
3 // Purpose: Header of std::istream and std::ostream derived wrappers for
4 // wxInputStream and wxOutputStream
5 // Author: Jonathan Liu <net147@gmail.com>
8 // Copyright: (c) 2009 Jonathan Liu
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_STDSTREAM_H_
13 #define _WX_STDSTREAM_H_
15 #include "wx/defs.h" // wxUSE_STD_IOSTREAM
17 #if wxUSE_STREAMS && wxUSE_STD_IOSTREAM
20 #include "wx/stream.h"
21 #include "wx/ioswrap.h"
23 // ==========================================================================
24 // wxStdInputStreamBuffer
25 // ==========================================================================
27 class WXDLLIMPEXP_BASE wxStdInputStreamBuffer
: public std::streambuf
30 wxStdInputStreamBuffer(wxInputStream
& stream
);
31 virtual ~wxStdInputStreamBuffer() { }
34 virtual std::streambuf
*setbuf(char *s
, std::streamsize n
);
35 virtual std::streampos
seekoff(std::streamoff off
,
36 std::ios_base::seekdir way
,
37 std::ios_base::openmode which
=
40 virtual std::streampos
seekpos(std::streampos sp
,
41 std::ios_base::openmode which
=
44 virtual std::streamsize
showmanyc();
45 virtual std::streamsize
xsgetn(char *s
, std::streamsize n
);
46 virtual int underflow();
48 virtual int pbackfail(int c
= EOF
);
50 wxInputStream
& m_stream
;
54 // ==========================================================================
56 // ==========================================================================
58 class WXDLLIMPEXP_BASE wxStdInputStream
: public std::istream
61 wxStdInputStream(wxInputStream
& stream
);
62 virtual ~wxStdInputStream() { }
65 wxStdInputStreamBuffer m_streamBuffer
;
68 // ==========================================================================
69 // wxStdOutputStreamBuffer
70 // ==========================================================================
72 class WXDLLIMPEXP_BASE wxStdOutputStreamBuffer
: public std::streambuf
75 wxStdOutputStreamBuffer(wxOutputStream
& stream
);
76 virtual ~wxStdOutputStreamBuffer() { }
79 virtual std::streambuf
*setbuf(char *s
, std::streamsize n
);
80 virtual std::streampos
seekoff(std::streamoff off
,
81 std::ios_base::seekdir way
,
82 std::ios_base::openmode which
=
85 virtual std::streampos
seekpos(std::streampos sp
,
86 std::ios_base::openmode which
=
89 virtual std::streamsize
xsputn(const char *s
, std::streamsize n
);
90 virtual int overflow(int c
);
92 wxOutputStream
& m_stream
;
95 // ==========================================================================
97 // ==========================================================================
99 class WXDLLIMPEXP_BASE wxStdOutputStream
: public std::ostream
102 wxStdOutputStream(wxOutputStream
& stream
);
103 virtual ~wxStdOutputStream() { }
106 wxStdOutputStreamBuffer m_streamBuffer
;
109 #endif // wxUSE_STREAMS && wxUSE_STD_IOSTREAM
111 #endif // _WX_STDSTREAM_H_