iostreamio.hpp
1: #ifndef IOSTREAMIO_HPP
2: #define IOSTREAMIO_HPP
3: /*------------------------------------------------------------------------------
4:
5: Author: Andy Rushton
6: Copyright: (c) Andy Rushton, 2004
7: License: BSD License, see ../docs/license.html
8:
9: TextIO devices layered on IOStream so that the two can be mixed in one application
10:
11: ------------------------------------------------------------------------------*/
12: #include "os_fixes.hpp"
13: #include "textio.hpp"
14: #include <iostream>
15:
16: ////////////////////////////////////////////////////////////////////////////////
17: // Stream Output
18: // oiotext = (o)utput (io)stream (text)io device
19:
20: class oiotext : public otext
21: {
22: public:
23: oiotext(std::ostream&);
24: void open(std::ostream&);
25:
26: std::ostream& get_stream(void);
27: const std::ostream& get_stream(void) const;
28: };
29:
30: ////////////////////////////////////////////////////////////////////////////////
31: // Stream Input
32: // iiotext = (i)nput (io)stream (text)io device
33:
34: class iiotext : public itext
35: {
36: public:
37: iiotext(std::istream&);
38: void open(std::istream&);
39:
40: std::istream& get_stream(void);
41: const std::istream& get_stream(void) const;
42: };
43:
44: ////////////////////////////////////////////////////////////////////////////////
45: // Internals
46:
47: class oiobuff : public obuff
48: {
49: friend class oiotext;
50: protected:
51: std::ostream& m_stream;
52: public:
53: oiobuff(std::ostream&);
54: ~oiobuff(void);
55: protected:
56: virtual unsigned put(unsigned char);
57: virtual void flush(void);
58: private:
59: // make this class uncopyable
60: oiobuff(const oiobuff&);
61: oiobuff& operator = (const oiobuff&);
62: };
63:
64: class iiobuff : public ibuff
65: {
66: friend class iiotext;
67: protected:
68: std::istream& m_stream;
69: public:
70: iiobuff(std::istream&);
71: ~iiobuff(void);
72: protected:
73: virtual int peek (void);
74: virtual int get (void);
75: private:
76: // make this class uncopyable
77: iiobuff(const iiobuff&);
78: iiobuff& operator = (const iiobuff&);
79: };
80:
81: ////////////////////////////////////////////////////////////////////////////////
82: #endif