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