1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/build/stlport/src/stdio_streambuf.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,102 @@ 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 defines two streambufs: 1.23 +// stdio_istreambuf, a read-only streambuf synchronized with a C stdio 1.24 +// FILE object 1.25 +// stdio_ostreambuf, a write-only streambuf synchronized with a C stdio 1.26 +// FILE object. 1.27 +// Note that neither stdio_istreambuf nor stdio_ostreambuf is a template; 1.28 +// both classes are derived from basic_streambuf<char, char_traits<char> >. 1.29 + 1.30 +// Note: the imbue() member function is a no-op. In particular, these 1.31 +// classes assume that codecvt<char, char, mbstate_t> is always an identity 1.32 +// transformation. This is true of the default locale, and of all locales 1.33 +// defined for the C I/O library. If you need to use a locale where 1.34 +// the codecvt<char, char, mbstate_t> facet performs a nontrivial 1.35 +// conversion, then you should use basic_filebuf<> instead of stdio_istreambuf 1.36 +// or stdio_ostreambuf. (If you don't understand what any of this means, 1.37 +// then it's not a feature you need to worry about. Locales where 1.38 +// codecvt<char, char, mbstate_t> does something nontrivial are a rare 1.39 +// corner case.) 1.40 + 1.41 + 1.42 +#ifndef _STLP_STDIO_STREAMBUF 1.43 +#define _STLP_STDIO_STREAMBUF 1.44 + 1.45 +#include <streambuf> 1.46 +#include <cstdio> // For FILE. 1.47 + 1.48 +_STLP_BEGIN_NAMESPACE 1.49 +_STLP_MOVE_TO_PRIV_NAMESPACE 1.50 + 1.51 +// Base class for features common to stdio_istreambuf and stdio_ostreambuf 1.52 +class stdio_streambuf_base : 1.53 + public basic_streambuf<char, char_traits<char> > /* FILE_basic_streambuf */ { 1.54 +public: // Constructor, destructor. 1.55 + // The argument may not be null. It must be an open file pointer. 1.56 + stdio_streambuf_base(FILE*); 1.57 + 1.58 + // The destructor flushes the stream, but does not close it. 1.59 + ~stdio_streambuf_base(); 1.60 + 1.61 +protected: // Virtual functions from basic_streambuf. 1.62 + streambuf* setbuf(char*, streamsize); 1.63 + 1.64 + pos_type seekoff(off_type, ios_base::seekdir, 1.65 + ios_base::openmode 1.66 + = ios_base::in | ios_base::out); 1.67 + pos_type seekpos(pos_type, 1.68 + ios_base::openmode 1.69 + = ios_base::in | ios_base::out); 1.70 + int sync(); 1.71 + 1.72 +protected: 1.73 + FILE* _M_file; 1.74 +}; 1.75 + 1.76 +class stdio_istreambuf : public stdio_streambuf_base { 1.77 +public: // Constructor, destructor. 1.78 + stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {} 1.79 + ~stdio_istreambuf(); 1.80 + 1.81 +protected: // Virtual functions from basic_streambuf. 1.82 + streamsize showmanyc(); 1.83 + int_type underflow(); 1.84 + int_type uflow(); 1.85 + virtual int_type pbackfail(int_type c = traits_type::eof()); 1.86 +}; 1.87 + 1.88 +class stdio_ostreambuf : public stdio_streambuf_base { 1.89 +public: // Constructor, destructor. 1.90 + stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {} 1.91 + ~stdio_ostreambuf(); 1.92 + 1.93 +protected: // Virtual functions from basic_streambuf. 1.94 + streamsize showmanyc(); 1.95 + int_type overflow(int_type c = traits_type::eof()); 1.96 +}; 1.97 + 1.98 +_STLP_MOVE_TO_STD_NAMESPACE 1.99 +_STLP_END_NAMESPACE 1.100 + 1.101 +#endif /* _STLP_STDIO_STREAMBUF */ 1.102 + 1.103 +// Local Variables: 1.104 +// mode:C++ 1.105 +// End: