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.
18 // This header is an extension. It defines two streambufs:
19 // stdio_istreambuf, a read-only streambuf synchronized with a C stdio
20 // FILE object, and stdio_ostreambuf, a write-only streambuf
21 // synchronized with a C stdio FILE object. Note that neither
22 // stdio_istreambuf nor stdio_ostreambuf is a template; both classes
23 // are derived from basic_streambuf<char, char_traits<char> >.
25 // Note: the imbue() member function is a no-op. In particular, these
26 // classes assume that codecvt<char, char, mbstate_t> is always an identity
27 // transformation. This is true of the default locale, and of all locales
28 // defined for the C I/O library. If you need to use a locale where
29 // the codecvt<char, char, mbstate_t> facet performs a nontrivial
30 // conversion, then you should use basic_filebuf<> instead of stdio_istreambuf
31 // or stdio_ostreambuf. (If you don't understand what any of this means,
32 // then it's not a feature you need to worry about. Locales where
33 // codecvt<char, char, mbstate_t> does something nontrivial are a rare
37 #ifndef _STLP_STDIO_STREAMBUF
38 #define _STLP_STDIO_STREAMBUF
40 #if !defined(STLP_WINCE)
42 #include <streambuf> // For basic_streambuf<>
43 #include <cstdio> // For FILE.
45 # ifndef _STLP_HAS_NO_NAMESPACES
46 // This is an extension. It is in namespace SGI, not namespace std
49 # ifdef _STLP_USE_NAMESPACES
50 using namespace _STLP_STD;
52 using _STLP_STD::streamsize;
53 using _STLP_STD::streambuf;
54 using _STLP_STD::basic_streambuf;
55 using _STLP_STD::ios_base;
56 // using _STLP_STD::ios_base::openmode;
60 // Base class for features common to stdio_istreambuf and stdio_ostreambuf
61 class stdio_streambuf_base : public basic_streambuf<char, _STLP_STD::char_traits<char> >
63 public: // Constructor, destructor.
64 // The argument may not be null. It must be an open file pointer.
65 stdio_streambuf_base(FILE*);
67 // The destructor flushes the stream, but does not close it.
68 ~stdio_streambuf_base();
70 protected: // Virtual functions from basic_streambuf.
71 streambuf* setbuf(char*, streamsize);
73 pos_type seekoff(off_type, ios_base::seekdir,
75 = ios_base::in | ios_base::out);
76 pos_type seekpos(pos_type,
78 = ios_base::in | ios_base::out);
85 class stdio_istreambuf : public stdio_streambuf_base
87 public: // Constructor, destructor.
88 stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
92 protected: // Virtual functions from basic_streambuf.
93 streamsize showmanyc();
96 virtual int_type pbackfail(int_type c = traits_type::eof());
99 class stdio_ostreambuf : public stdio_streambuf_base
101 public: // Constructor, destructor.
102 stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
105 protected: // Virtual functions from basic_streambuf.
106 streamsize showmanyc();
107 int_type overflow(int_type c = traits_type::eof());
110 # ifndef _STLP_HAS_NO_NAMESPACES
111 } // Close namespace _SgI.
114 #endif /* _STLP_STDIO_STREAMBUF */
116 #endif /* _STLP_WINCE */