Update contrib.
3 * Silicon Graphics Computer Systems, Inc.
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
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.
19 // This header is an extension. It defines two streambufs:
20 // stdio_istreambuf, a read-only streambuf synchronized with a C stdio
21 // FILE object, and stdio_ostreambuf, a write-only streambuf
22 // synchronized with a C stdio FILE object. Note that neither
23 // stdio_istreambuf nor stdio_ostreambuf is a template; both classes
24 // are derived from basic_streambuf<char, char_traits<char> >.
26 // Note: the imbue() member function is a no-op. In particular, these
27 // classes assume that codecvt<char, char, mbstate_t> is always an identity
28 // transformation. This is true of the default locale, and of all locales
29 // defined for the C I/O library. If you need to use a locale where
30 // the codecvt<char, char, mbstate_t> facet performs a nontrivial
31 // conversion, then you should use basic_filebuf<> instead of stdio_istreambuf
32 // or stdio_ostreambuf. (If you don't understand what any of this means,
33 // then it's not a feature you need to worry about. Locales where
34 // codecvt<char, char, mbstate_t> does something nontrivial are a rare
38 #ifndef _STLP_STDIO_STREAMBUF
39 #define _STLP_STDIO_STREAMBUF
42 #include <cstdio> // For FILE.
45 _STLP_MOVE_TO_PRIV_NAMESPACE
47 // Base class for features common to stdio_istreambuf and stdio_ostreambuf
48 class stdio_streambuf_base :
49 public basic_streambuf<char, char_traits<char> > /* FILE_basic_streambuf */ {
50 public: // Constructor, destructor.
51 // The argument may not be null. It must be an open file pointer.
52 stdio_streambuf_base(FILE*);
54 // The destructor flushes the stream, but does not close it.
55 ~stdio_streambuf_base();
57 protected: // Virtual functions from basic_streambuf.
58 streambuf* setbuf(char*, streamsize);
60 pos_type seekoff(off_type, ios_base::seekdir,
62 = ios_base::in | ios_base::out);
63 pos_type seekpos(pos_type,
65 = ios_base::in | ios_base::out);
72 class stdio_istreambuf : public stdio_streambuf_base {
73 public: // Constructor, destructor.
74 stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
77 protected: // Virtual functions from basic_streambuf.
78 streamsize showmanyc();
81 virtual int_type pbackfail(int_type c = traits_type::eof());
84 class stdio_ostreambuf : public stdio_streambuf_base {
85 public: // Constructor, destructor.
86 stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
89 protected: // Virtual functions from basic_streambuf.
90 streamsize showmanyc();
91 int_type overflow(int_type c = traits_type::eof());
94 _STLP_MOVE_TO_STD_NAMESPACE
97 #endif /* _STLP_STDIO_STREAMBUF */