1.1 --- a/epoc32/include/stdapis/stlport/stdio_streambuf Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stdio_streambuf Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,121 @@
1.4 -stdio_streambuf
1.5 +/*
1.6 + * Copyright (c) 1999
1.7 + * Silicon Graphics Computer Systems, Inc.
1.8 + *
1.9 + * Copyright (c) 1999
1.10 + * Boris Fomitchev
1.11 + *
1.12 + * This material is provided "as is", with absolutely no warranty expressed
1.13 + * or implied. Any use is at your own risk.
1.14 + *
1.15 + * Permission to use or copy this software for any purpose is hereby granted
1.16 + * without fee, provided the above notices are retained on all copies.
1.17 + * Permission to modify the code and to distribute modified code is granted,
1.18 + * provided the above notices are retained, and a notice that the code was
1.19 + * modified is included with the above copyright notice.
1.20 + *
1.21 + */
1.22 +// This header is an extension. It defines two streambufs:
1.23 +// stdio_istreambuf, a read-only streambuf synchronized with a C stdio
1.24 +// FILE object, and stdio_ostreambuf, a write-only streambuf
1.25 +// synchronized with a C stdio FILE object. Note that neither
1.26 +// stdio_istreambuf nor stdio_ostreambuf is a template; both classes
1.27 +// are derived from basic_streambuf<char, char_traits<char> >.
1.28 +
1.29 +// Note: the imbue() member function is a no-op. In particular, these
1.30 +// classes assume that codecvt<char, char, mbstate_t> is always an identity
1.31 +// transformation. This is true of the default locale, and of all locales
1.32 +// defined for the C I/O library. If you need to use a locale where
1.33 +// the codecvt<char, char, mbstate_t> facet performs a nontrivial
1.34 +// conversion, then you should use basic_filebuf<> instead of stdio_istreambuf
1.35 +// or stdio_ostreambuf. (If you don't understand what any of this means,
1.36 +// then it's not a feature you need to worry about. Locales where
1.37 +// codecvt<char, char, mbstate_t> does something nontrivial are a rare
1.38 +// corner case.)
1.39 +
1.40 +
1.41 +#ifndef _STLP_STDIO_STREAMBUF
1.42 +#define _STLP_STDIO_STREAMBUF
1.43 +
1.44 +#if !defined(STLP_WINCE)
1.45 +
1.46 +#include <streambuf> // For basic_streambuf<>
1.47 +#include <cstdio> // For FILE.
1.48 +
1.49 +# ifndef _STLP_HAS_NO_NAMESPACES
1.50 +// This is an extension. It is in namespace SGI, not namespace std
1.51 +namespace _SgI {
1.52 +
1.53 +# ifdef _STLP_USE_NAMESPACES
1.54 +using namespace _STLP_STD;
1.55 + // MSVC needs this
1.56 +using _STLP_STD::streamsize;
1.57 +using _STLP_STD::streambuf;
1.58 +using _STLP_STD::basic_streambuf;
1.59 +using _STLP_STD::ios_base;
1.60 + // using _STLP_STD::ios_base::openmode;
1.61 +# endif
1.62 +# endif
1.63 +
1.64 +// Base class for features common to stdio_istreambuf and stdio_ostreambuf
1.65 +class stdio_streambuf_base : public basic_streambuf<char, _STLP_STD::char_traits<char> >
1.66 +{
1.67 +public: // Constructor, destructor.
1.68 + // The argument may not be null. It must be an open file pointer.
1.69 + stdio_streambuf_base(FILE*);
1.70 +
1.71 + // The destructor flushes the stream, but does not close it.
1.72 + ~stdio_streambuf_base();
1.73 +
1.74 +protected: // Virtual functions from basic_streambuf.
1.75 + streambuf* setbuf(char*, streamsize);
1.76 +
1.77 + pos_type seekoff(off_type, ios_base::seekdir,
1.78 + ios_base::openmode
1.79 + = ios_base::in | ios_base::out);
1.80 + pos_type seekpos(pos_type,
1.81 + ios_base::openmode
1.82 + = ios_base::in | ios_base::out);
1.83 + int sync();
1.84 +
1.85 +protected:
1.86 + FILE* _M_file;
1.87 +};
1.88 +
1.89 +class stdio_istreambuf : public stdio_streambuf_base
1.90 +{
1.91 +public: // Constructor, destructor.
1.92 + stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
1.93 +
1.94 + ~stdio_istreambuf();
1.95 +
1.96 +protected: // Virtual functions from basic_streambuf.
1.97 + streamsize showmanyc();
1.98 + int_type underflow();
1.99 + int_type uflow();
1.100 + virtual int_type pbackfail(int_type c = traits_type::eof());
1.101 +};
1.102 +
1.103 +class stdio_ostreambuf : public stdio_streambuf_base
1.104 +{
1.105 +public: // Constructor, destructor.
1.106 + stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
1.107 + ~stdio_ostreambuf();
1.108 +
1.109 +protected: // Virtual functions from basic_streambuf.
1.110 + streamsize showmanyc();
1.111 + int_type overflow(int_type c = traits_type::eof());
1.112 +};
1.113 +
1.114 +# ifndef _STLP_HAS_NO_NAMESPACES
1.115 +} // Close namespace _SgI.
1.116 +# endif
1.117 +
1.118 +#endif /* _STLP_STDIO_STREAMBUF */
1.119 +
1.120 +#endif /* _STLP_WINCE */
1.121 +
1.122 +// Local Variables:
1.123 +// mode:C++
1.124 +// End:
1.125 +