sl@0: /* sl@0: * Copyright (c) 1999 sl@0: * Silicon Graphics Computer Systems, Inc. sl@0: * sl@0: * Copyright (c) 1999 sl@0: * Boris Fomitchev sl@0: * sl@0: * This material is provided "as is", with absolutely no warranty expressed sl@0: * or implied. Any use is at your own risk. sl@0: * sl@0: * Permission to use or copy this software for any purpose is hereby granted sl@0: * without fee, provided the above notices are retained on all copies. sl@0: * Permission to modify the code and to distribute modified code is granted, sl@0: * provided the above notices are retained, and a notice that the code was sl@0: * modified is included with the above copyright notice. sl@0: * sl@0: */ sl@0: sl@0: // This header is an extension. It defines two streambufs: sl@0: // stdio_istreambuf, a read-only streambuf synchronized with a C stdio sl@0: // FILE object, and stdio_ostreambuf, a write-only streambuf sl@0: // synchronized with a C stdio FILE object. Note that neither sl@0: // stdio_istreambuf nor stdio_ostreambuf is a template; both classes sl@0: // are derived from basic_streambuf >. sl@0: sl@0: // Note: the imbue() member function is a no-op. In particular, these sl@0: // classes assume that codecvt is always an identity sl@0: // transformation. This is true of the default locale, and of all locales sl@0: // defined for the C I/O library. If you need to use a locale where sl@0: // the codecvt facet performs a nontrivial sl@0: // conversion, then you should use basic_filebuf<> instead of stdio_istreambuf sl@0: // or stdio_ostreambuf. (If you don't understand what any of this means, sl@0: // then it's not a feature you need to worry about. Locales where sl@0: // codecvt does something nontrivial are a rare sl@0: // corner case.) sl@0: sl@0: sl@0: #ifndef _STLP_STDIO_STREAMBUF sl@0: #define _STLP_STDIO_STREAMBUF sl@0: sl@0: #include sl@0: #include // For FILE. sl@0: sl@0: _STLP_BEGIN_NAMESPACE sl@0: _STLP_MOVE_TO_PRIV_NAMESPACE sl@0: sl@0: // Base class for features common to stdio_istreambuf and stdio_ostreambuf sl@0: class stdio_streambuf_base : sl@0: public basic_streambuf > /* FILE_basic_streambuf */ { sl@0: public: // Constructor, destructor. sl@0: // The argument may not be null. It must be an open file pointer. sl@0: stdio_streambuf_base(FILE*); sl@0: sl@0: // The destructor flushes the stream, but does not close it. sl@0: ~stdio_streambuf_base(); sl@0: sl@0: protected: // Virtual functions from basic_streambuf. sl@0: streambuf* setbuf(char*, streamsize); sl@0: sl@0: pos_type seekoff(off_type, ios_base::seekdir, sl@0: ios_base::openmode sl@0: = ios_base::in | ios_base::out); sl@0: pos_type seekpos(pos_type, sl@0: ios_base::openmode sl@0: = ios_base::in | ios_base::out); sl@0: int sync(); sl@0: sl@0: protected: sl@0: FILE* _M_file; sl@0: }; sl@0: sl@0: class stdio_istreambuf : public stdio_streambuf_base { sl@0: public: // Constructor, destructor. sl@0: stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {} sl@0: ~stdio_istreambuf(); sl@0: sl@0: protected: // Virtual functions from basic_streambuf. sl@0: streamsize showmanyc(); sl@0: int_type underflow(); sl@0: int_type uflow(); sl@0: virtual int_type pbackfail(int_type c = traits_type::eof()); sl@0: }; sl@0: sl@0: class stdio_ostreambuf : public stdio_streambuf_base { sl@0: public: // Constructor, destructor. sl@0: stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {} sl@0: ~stdio_ostreambuf(); sl@0: sl@0: protected: // Virtual functions from basic_streambuf. sl@0: streamsize showmanyc(); sl@0: int_type overflow(int_type c = traits_type::eof()); sl@0: }; sl@0: sl@0: _STLP_MOVE_TO_STD_NAMESPACE sl@0: _STLP_END_NAMESPACE sl@0: sl@0: #endif /* _STLP_STDIO_STREAMBUF */ sl@0: sl@0: // Local Variables: sl@0: // mode:C++ sl@0: // End: