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