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