]> git.saurik.com Git - wxWidgets.git/blame - include/wx/stdstream.h
Somehow, setting a tint color makes gauge work :/.
[wxWidgets.git] / include / wx / stdstream.h
CommitLineData
72a7c559
VZ
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>
6// Created: 2009-05-02
72a7c559
VZ
7// Copyright: (c) 2009 Jonathan Liu
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_STDSTREAM_H_
12#define _WX_STDSTREAM_H_
13
14#include "wx/defs.h" // wxUSE_STD_IOSTREAM
15
e5805c0f 16#if wxUSE_STREAMS && wxUSE_STD_IOSTREAM
72a7c559 17
3c507ea6
SC
18#include "wx/defs.h"
19#include "wx/stream.h"
eb3a3cbb 20#include "wx/ioswrap.h"
72a7c559
VZ
21
22// ==========================================================================
23// wxStdInputStreamBuffer
24// ==========================================================================
25
26class WXDLLIMPEXP_BASE wxStdInputStreamBuffer : public std::streambuf
27{
28public:
29 wxStdInputStreamBuffer(wxInputStream& stream);
a0e55920 30 virtual ~wxStdInputStreamBuffer() { }
72a7c559
VZ
31
32protected:
33 virtual std::streambuf *setbuf(char *s, std::streamsize n);
34 virtual std::streampos seekoff(std::streamoff off,
35 std::ios_base::seekdir way,
36 std::ios_base::openmode which =
37 std::ios_base::in |
38 std::ios_base::out);
39 virtual std::streampos seekpos(std::streampos sp,
40 std::ios_base::openmode which =
41 std::ios_base::in |
42 std::ios_base::out);
43 virtual std::streamsize showmanyc();
44 virtual std::streamsize xsgetn(char *s, std::streamsize n);
45 virtual int underflow();
46 virtual int uflow();
47 virtual int pbackfail(int c = EOF);
48
0e3b10c5
VZ
49 // Special work around for VC8/9 (this bug was fixed in VC10 and later):
50 // these versions have non-standard _Xsgetn_s() that it being called from
51 // the stream code instead of xsgetn() and so our overridden implementation
52 // never actually gets used. To work around this, forward to it explicitly.
53#if defined(__VISUALC8__) || defined(__VISUALC9__)
54 virtual std::streamsize
55 _Xsgetn_s(char *s, size_t WXUNUSED(size), std::streamsize n)
56 {
57 return xsgetn(s, n);
58 }
59#endif // VC8 or VC9
60
72a7c559
VZ
61 wxInputStream& m_stream;
62 int m_lastChar;
63};
64
65// ==========================================================================
66// wxStdInputStream
67// ==========================================================================
68
69class WXDLLIMPEXP_BASE wxStdInputStream : public std::istream
70{
71public:
72 wxStdInputStream(wxInputStream& stream);
a0e55920 73 virtual ~wxStdInputStream() { }
72a7c559
VZ
74
75protected:
76 wxStdInputStreamBuffer m_streamBuffer;
77};
78
79// ==========================================================================
80// wxStdOutputStreamBuffer
81// ==========================================================================
82
83class WXDLLIMPEXP_BASE wxStdOutputStreamBuffer : public std::streambuf
84{
85public:
86 wxStdOutputStreamBuffer(wxOutputStream& stream);
a0e55920 87 virtual ~wxStdOutputStreamBuffer() { }
72a7c559
VZ
88
89protected:
90 virtual std::streambuf *setbuf(char *s, std::streamsize n);
91 virtual std::streampos seekoff(std::streamoff off,
92 std::ios_base::seekdir way,
93 std::ios_base::openmode which =
94 std::ios_base::in |
95 std::ios_base::out);
96 virtual std::streampos seekpos(std::streampos sp,
97 std::ios_base::openmode which =
98 std::ios_base::in |
99 std::ios_base::out);
100 virtual std::streamsize xsputn(const char *s, std::streamsize n);
101 virtual int overflow(int c);
102
103 wxOutputStream& m_stream;
104};
105
106// ==========================================================================
107// wxStdOutputStream
108// ==========================================================================
109
110class WXDLLIMPEXP_BASE wxStdOutputStream : public std::ostream
111{
112public:
113 wxStdOutputStream(wxOutputStream& stream);
a0e55920 114 virtual ~wxStdOutputStream() { }
72a7c559
VZ
115
116protected:
117 wxStdOutputStreamBuffer m_streamBuffer;
118};
119
e5805c0f 120#endif // wxUSE_STREAMS && wxUSE_STD_IOSTREAM
72a7c559
VZ
121
122#endif // _WX_STDSTREAM_H_