1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/cppstdlib/stl/src/stdio_streambuf.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,101 @@
1.4 +/*
1.5 + * Copyright (c) 1999
1.6 + * Silicon Graphics Computer Systems, Inc.
1.7 + *
1.8 + * Copyright (c) 1999
1.9 + * Boris Fomitchev
1.10 + *
1.11 + * This material is provided "as is", with absolutely no warranty expressed
1.12 + * or implied. Any use is at your own risk.
1.13 + *
1.14 + * Permission to use or copy this software for any purpose is hereby granted
1.15 + * without fee, provided the above notices are retained on all copies.
1.16 + * Permission to modify the code and to distribute modified code is granted,
1.17 + * provided the above notices are retained, and a notice that the code was
1.18 + * modified is included with the above copyright notice.
1.19 + *
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 +#include <streambuf>
1.45 +#include <cstdio> // For FILE.
1.46 +
1.47 +_STLP_BEGIN_NAMESPACE
1.48 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.49 +
1.50 +// Base class for features common to stdio_istreambuf and stdio_ostreambuf
1.51 +class stdio_streambuf_base :
1.52 + public basic_streambuf<char, char_traits<char> > /* FILE_basic_streambuf */ {
1.53 +public: // Constructor, destructor.
1.54 + // The argument may not be null. It must be an open file pointer.
1.55 + stdio_streambuf_base(FILE*);
1.56 +
1.57 + // The destructor flushes the stream, but does not close it.
1.58 + ~stdio_streambuf_base();
1.59 +
1.60 +protected: // Virtual functions from basic_streambuf.
1.61 + streambuf* setbuf(char*, streamsize);
1.62 +
1.63 + pos_type seekoff(off_type, ios_base::seekdir,
1.64 + ios_base::openmode
1.65 + = ios_base::in | ios_base::out);
1.66 + pos_type seekpos(pos_type,
1.67 + ios_base::openmode
1.68 + = ios_base::in | ios_base::out);
1.69 + int sync();
1.70 +
1.71 +protected:
1.72 + FILE* _M_file;
1.73 +};
1.74 +
1.75 +class stdio_istreambuf : public stdio_streambuf_base {
1.76 +public: // Constructor, destructor.
1.77 + stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
1.78 + ~stdio_istreambuf();
1.79 +
1.80 +protected: // Virtual functions from basic_streambuf.
1.81 + streamsize showmanyc();
1.82 + int_type underflow();
1.83 + int_type uflow();
1.84 + virtual int_type pbackfail(int_type c = traits_type::eof());
1.85 +};
1.86 +
1.87 +class stdio_ostreambuf : public stdio_streambuf_base {
1.88 +public: // Constructor, destructor.
1.89 + stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
1.90 + ~stdio_ostreambuf();
1.91 +
1.92 +protected: // Virtual functions from basic_streambuf.
1.93 + streamsize showmanyc();
1.94 + int_type overflow(int_type c = traits_type::eof());
1.95 +};
1.96 +
1.97 +_STLP_MOVE_TO_STD_NAMESPACE
1.98 +_STLP_END_NAMESPACE
1.99 +
1.100 +#endif /* _STLP_STDIO_STREAMBUF */
1.101 +
1.102 +// Local Variables:
1.103 +// mode:C++
1.104 +// End: