build/stlport/src/stdio_streambuf.h

Wed, 31 Dec 2014 07:16:47 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:16:47 +0100
branch
TOR_BUG_9701
changeset 3
141e0f1194b1
permissions
-rw-r--r--

Revert simplistic fix pending revisit of Mozilla integration attempt.

michael@0 1 /*
michael@0 2 * Copyright (c) 1999
michael@0 3 * Silicon Graphics Computer Systems, Inc.
michael@0 4 *
michael@0 5 * Copyright (c) 1999
michael@0 6 * Boris Fomitchev
michael@0 7 *
michael@0 8 * This material is provided "as is", with absolutely no warranty expressed
michael@0 9 * or implied. Any use is at your own risk.
michael@0 10 *
michael@0 11 * Permission to use or copy this software for any purpose is hereby granted
michael@0 12 * without fee, provided the above notices are retained on all copies.
michael@0 13 * Permission to modify the code and to distribute modified code is granted,
michael@0 14 * provided the above notices are retained, and a notice that the code was
michael@0 15 * modified is included with the above copyright notice.
michael@0 16 *
michael@0 17 */
michael@0 18
michael@0 19 // This header defines two streambufs:
michael@0 20 // stdio_istreambuf, a read-only streambuf synchronized with a C stdio
michael@0 21 // FILE object
michael@0 22 // stdio_ostreambuf, a write-only streambuf synchronized with a C stdio
michael@0 23 // FILE object.
michael@0 24 // Note that neither stdio_istreambuf nor stdio_ostreambuf is a template;
michael@0 25 // both classes are derived from basic_streambuf<char, char_traits<char> >.
michael@0 26
michael@0 27 // Note: the imbue() member function is a no-op. In particular, these
michael@0 28 // classes assume that codecvt<char, char, mbstate_t> is always an identity
michael@0 29 // transformation. This is true of the default locale, and of all locales
michael@0 30 // defined for the C I/O library. If you need to use a locale where
michael@0 31 // the codecvt<char, char, mbstate_t> facet performs a nontrivial
michael@0 32 // conversion, then you should use basic_filebuf<> instead of stdio_istreambuf
michael@0 33 // or stdio_ostreambuf. (If you don't understand what any of this means,
michael@0 34 // then it's not a feature you need to worry about. Locales where
michael@0 35 // codecvt<char, char, mbstate_t> does something nontrivial are a rare
michael@0 36 // corner case.)
michael@0 37
michael@0 38
michael@0 39 #ifndef _STLP_STDIO_STREAMBUF
michael@0 40 #define _STLP_STDIO_STREAMBUF
michael@0 41
michael@0 42 #include <streambuf>
michael@0 43 #include <cstdio> // For FILE.
michael@0 44
michael@0 45 _STLP_BEGIN_NAMESPACE
michael@0 46 _STLP_MOVE_TO_PRIV_NAMESPACE
michael@0 47
michael@0 48 // Base class for features common to stdio_istreambuf and stdio_ostreambuf
michael@0 49 class stdio_streambuf_base :
michael@0 50 public basic_streambuf<char, char_traits<char> > /* FILE_basic_streambuf */ {
michael@0 51 public: // Constructor, destructor.
michael@0 52 // The argument may not be null. It must be an open file pointer.
michael@0 53 stdio_streambuf_base(FILE*);
michael@0 54
michael@0 55 // The destructor flushes the stream, but does not close it.
michael@0 56 ~stdio_streambuf_base();
michael@0 57
michael@0 58 protected: // Virtual functions from basic_streambuf.
michael@0 59 streambuf* setbuf(char*, streamsize);
michael@0 60
michael@0 61 pos_type seekoff(off_type, ios_base::seekdir,
michael@0 62 ios_base::openmode
michael@0 63 = ios_base::in | ios_base::out);
michael@0 64 pos_type seekpos(pos_type,
michael@0 65 ios_base::openmode
michael@0 66 = ios_base::in | ios_base::out);
michael@0 67 int sync();
michael@0 68
michael@0 69 protected:
michael@0 70 FILE* _M_file;
michael@0 71 };
michael@0 72
michael@0 73 class stdio_istreambuf : public stdio_streambuf_base {
michael@0 74 public: // Constructor, destructor.
michael@0 75 stdio_istreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
michael@0 76 ~stdio_istreambuf();
michael@0 77
michael@0 78 protected: // Virtual functions from basic_streambuf.
michael@0 79 streamsize showmanyc();
michael@0 80 int_type underflow();
michael@0 81 int_type uflow();
michael@0 82 virtual int_type pbackfail(int_type c = traits_type::eof());
michael@0 83 };
michael@0 84
michael@0 85 class stdio_ostreambuf : public stdio_streambuf_base {
michael@0 86 public: // Constructor, destructor.
michael@0 87 stdio_ostreambuf(FILE* __f) : stdio_streambuf_base(__f) {}
michael@0 88 ~stdio_ostreambuf();
michael@0 89
michael@0 90 protected: // Virtual functions from basic_streambuf.
michael@0 91 streamsize showmanyc();
michael@0 92 int_type overflow(int_type c = traits_type::eof());
michael@0 93 };
michael@0 94
michael@0 95 _STLP_MOVE_TO_STD_NAMESPACE
michael@0 96 _STLP_END_NAMESPACE
michael@0 97
michael@0 98 #endif /* _STLP_STDIO_STREAMBUF */
michael@0 99
michael@0 100 // Local Variables:
michael@0 101 // mode:C++
michael@0 102 // End:

mercurial