build/stlport/src/stdio_streambuf.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:7ede6f16df50
1 /*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18
19 // This header defines two streambufs:
20 // stdio_istreambuf, a read-only streambuf synchronized with a C stdio
21 // FILE object
22 // stdio_ostreambuf, a write-only streambuf synchronized with a C stdio
23 // FILE object.
24 // Note that neither stdio_istreambuf nor stdio_ostreambuf is a template;
25 // both classes are derived from basic_streambuf<char, char_traits<char> >.
26
27 // Note: the imbue() member function is a no-op. In particular, these
28 // classes assume that codecvt<char, char, mbstate_t> is always an identity
29 // transformation. This is true of the default locale, and of all locales
30 // defined for the C I/O library. If you need to use a locale where
31 // the codecvt<char, char, mbstate_t> facet performs a nontrivial
32 // conversion, then you should use basic_filebuf<> instead of stdio_istreambuf
33 // or stdio_ostreambuf. (If you don't understand what any of this means,
34 // then it's not a feature you need to worry about. Locales where
35 // codecvt<char, char, mbstate_t> does something nontrivial are a rare
36 // corner case.)
37
38
39 #ifndef _STLP_STDIO_STREAMBUF
40 #define _STLP_STDIO_STREAMBUF
41
42 #include <streambuf>
43 #include <cstdio> // For FILE.
44
45 _STLP_BEGIN_NAMESPACE
46 _STLP_MOVE_TO_PRIV_NAMESPACE
47
48 // Base class for features common to stdio_istreambuf and stdio_ostreambuf
49 class stdio_streambuf_base :
50 public basic_streambuf<char, char_traits<char> > /* FILE_basic_streambuf */ {
51 public: // Constructor, destructor.
52 // The argument may not be null. It must be an open file pointer.
53 stdio_streambuf_base(FILE*);
54
55 // The destructor flushes the stream, but does not close it.
56 ~stdio_streambuf_base();
57
58 protected: // Virtual functions from basic_streambuf.
59 streambuf* setbuf(char*, streamsize);
60
61 pos_type seekoff(off_type, ios_base::seekdir,
62 ios_base::openmode
63 = ios_base::in | ios_base::out);
64 pos_type seekpos(pos_type,
65 ios_base::openmode
66 = ios_base::in | ios_base::out);
67 int sync();
68
69 protected:
70 FILE* _M_file;
71 };
72
73 class stdio_istreambuf : public stdio_streambuf_base {
74 public: // Constructor, destructor.
75 stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
76 ~stdio_istreambuf();
77
78 protected: // Virtual functions from basic_streambuf.
79 streamsize showmanyc();
80 int_type underflow();
81 int_type uflow();
82 virtual int_type pbackfail(int_type c = traits_type::eof());
83 };
84
85 class stdio_ostreambuf : public stdio_streambuf_base {
86 public: // Constructor, destructor.
87 stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
88 ~stdio_ostreambuf();
89
90 protected: // Virtual functions from basic_streambuf.
91 streamsize showmanyc();
92 int_type overflow(int_type c = traits_type::eof());
93 };
94
95 _STLP_MOVE_TO_STD_NAMESPACE
96 _STLP_END_NAMESPACE
97
98 #endif /* _STLP_STDIO_STREAMBUF */
99
100 // Local Variables:
101 // mode:C++
102 // End:

mercurial