xref: /dflybsd-src/contrib/gcc-4.7/libstdc++-v3/include/std/streambuf (revision 81fc95a5293ee307c688a350a3feb4734aaddbb4)
1e4b17023SJohn Marino// Stream buffer classes -*- C++ -*-
2e4b17023SJohn Marino
3e4b17023SJohn Marino// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4*5ce9237cSJohn Marino// 2006, 2007, 2008, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
5e4b17023SJohn Marino//
6e4b17023SJohn Marino// This file is part of the GNU ISO C++ Library.  This library is free
7e4b17023SJohn Marino// software; you can redistribute it and/or modify it under the
8e4b17023SJohn Marino// terms of the GNU General Public License as published by the
9e4b17023SJohn Marino// Free Software Foundation; either version 3, or (at your option)
10e4b17023SJohn Marino// any later version.
11e4b17023SJohn Marino
12e4b17023SJohn Marino// This library is distributed in the hope that it will be useful,
13e4b17023SJohn Marino// but WITHOUT ANY WARRANTY; without even the implied warranty of
14e4b17023SJohn Marino// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15e4b17023SJohn Marino// GNU General Public License for more details.
16e4b17023SJohn Marino
17e4b17023SJohn Marino// Under Section 7 of GPL version 3, you are granted additional
18e4b17023SJohn Marino// permissions described in the GCC Runtime Library Exception, version
19e4b17023SJohn Marino// 3.1, as published by the Free Software Foundation.
20e4b17023SJohn Marino
21e4b17023SJohn Marino// You should have received a copy of the GNU General Public License and
22e4b17023SJohn Marino// a copy of the GCC Runtime Library Exception along with this program;
23e4b17023SJohn Marino// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24e4b17023SJohn Marino// <http://www.gnu.org/licenses/>.
25e4b17023SJohn Marino
26e4b17023SJohn Marino/** @file include/streambuf
27e4b17023SJohn Marino *  This is a Standard C++ Library header.
28e4b17023SJohn Marino */
29e4b17023SJohn Marino
30e4b17023SJohn Marino//
31e4b17023SJohn Marino// ISO C++ 14882: 27.5  Stream buffers
32e4b17023SJohn Marino//
33e4b17023SJohn Marino
34e4b17023SJohn Marino#ifndef _GLIBXX_STREAMBUF
35e4b17023SJohn Marino#define _GLIBXX_STREAMBUF 1
36e4b17023SJohn Marino
37e4b17023SJohn Marino#pragma GCC system_header
38e4b17023SJohn Marino
39e4b17023SJohn Marino#include <bits/c++config.h>
40e4b17023SJohn Marino#include <iosfwd>
41e4b17023SJohn Marino#include <bits/localefwd.h>
42e4b17023SJohn Marino#include <bits/ios_base.h>
43e4b17023SJohn Marino#include <bits/cpp_type_traits.h>
44e4b17023SJohn Marino#include <ext/type_traits.h>
45e4b17023SJohn Marino
46e4b17023SJohn Marinonamespace std _GLIBCXX_VISIBILITY(default)
47e4b17023SJohn Marino{
48e4b17023SJohn Marino_GLIBCXX_BEGIN_NAMESPACE_VERSION
49e4b17023SJohn Marino
50e4b17023SJohn Marino  template<typename _CharT, typename _Traits>
51e4b17023SJohn Marino    streamsize
52e4b17023SJohn Marino    __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>*,
53e4b17023SJohn Marino			  basic_streambuf<_CharT, _Traits>*, bool&);
54e4b17023SJohn Marino
55e4b17023SJohn Marino  /**
56e4b17023SJohn Marino   *  @brief  The actual work of input and output (interface).
57e4b17023SJohn Marino   *  @ingroup io
58e4b17023SJohn Marino   *
59e4b17023SJohn Marino   *  This is a base class.  Derived stream buffers each control a
60e4b17023SJohn Marino   *  pair of character sequences:  one for input, and one for output.
61e4b17023SJohn Marino   *
62e4b17023SJohn Marino   *  Section [27.5.1] of the standard describes the requirements and
63e4b17023SJohn Marino   *  behavior of stream buffer classes.  That section (three paragraphs)
64e4b17023SJohn Marino   *  is reproduced here, for simplicity and accuracy.
65e4b17023SJohn Marino   *
66e4b17023SJohn Marino   *  -# Stream buffers can impose various constraints on the sequences
67e4b17023SJohn Marino   *     they control.  Some constraints are:
68e4b17023SJohn Marino   *     - The controlled input sequence can be not readable.
69e4b17023SJohn Marino   *     - The controlled output sequence can be not writable.
70e4b17023SJohn Marino   *     - The controlled sequences can be associated with the contents of
71e4b17023SJohn Marino   *       other representations for character sequences, such as external
72e4b17023SJohn Marino   *       files.
73e4b17023SJohn Marino   *     - The controlled sequences can support operations @e directly to or
74e4b17023SJohn Marino   *       from associated sequences.
75e4b17023SJohn Marino   *     - The controlled sequences can impose limitations on how the
76e4b17023SJohn Marino   *       program can read characters from a sequence, write characters to
77e4b17023SJohn Marino   *       a sequence, put characters back into an input sequence, or alter
78e4b17023SJohn Marino   *       the stream position.
79e4b17023SJohn Marino   *     .
80e4b17023SJohn Marino   *  -# Each sequence is characterized by three pointers which, if non-null,
81e4b17023SJohn Marino   *     all point into the same @c charT array object.  The array object
82e4b17023SJohn Marino   *     represents, at any moment, a (sub)sequence of characters from the
83e4b17023SJohn Marino   *     sequence.  Operations performed on a sequence alter the values
84e4b17023SJohn Marino   *     stored in these pointers, perform reads and writes directly to or
85e4b17023SJohn Marino   *     from associated sequences, and alter <em>the stream position</em> and
86e4b17023SJohn Marino   *     conversion state as needed to maintain this subsequence relationship.
87e4b17023SJohn Marino   *     The three pointers are:
88e4b17023SJohn Marino   *     - the <em>beginning pointer</em>, or lowest element address in the
89e4b17023SJohn Marino   *       array (called @e xbeg here);
90e4b17023SJohn Marino   *     - the <em>next pointer</em>, or next element address that is a
91e4b17023SJohn Marino   *       current candidate for reading or writing (called @e xnext here);
92e4b17023SJohn Marino   *     - the <em>end pointer</em>, or first element address beyond the
93e4b17023SJohn Marino   *       end of the array (called @e xend here).
94e4b17023SJohn Marino   *     .
95e4b17023SJohn Marino   *  -# The following semantic constraints shall always apply for any set
96e4b17023SJohn Marino   *     of three pointers for a sequence, using the pointer names given
97e4b17023SJohn Marino   *     immediately above:
98e4b17023SJohn Marino   *     - If @e xnext is not a null pointer, then @e xbeg and @e xend shall
99e4b17023SJohn Marino   *       also be non-null pointers into the same @c charT array, as
100e4b17023SJohn Marino   *       described above; otherwise, @e xbeg and @e xend shall also be null.
101e4b17023SJohn Marino   *     - If @e xnext is not a null pointer and @e xnext < @e xend for an
102e4b17023SJohn Marino   *       output sequence, then a <em>write position</em> is available.
103e4b17023SJohn Marino   *       In this case, @e *xnext shall be assignable as the next element
104e4b17023SJohn Marino   *       to write (to put, or to store a character value, into the sequence).
105e4b17023SJohn Marino   *     - If @e xnext is not a null pointer and @e xbeg < @e xnext for an
106e4b17023SJohn Marino   *       input sequence, then a <em>putback position</em> is available.
107e4b17023SJohn Marino   *       In this case, @e xnext[-1] shall have a defined value and is the
108e4b17023SJohn Marino   *       next (preceding) element to store a character that is put back
109e4b17023SJohn Marino   *       into the input sequence.
110e4b17023SJohn Marino   *     - If @e xnext is not a null pointer and @e xnext< @e xend for an
111e4b17023SJohn Marino   *       input sequence, then a <em>read position</em> is available.
112e4b17023SJohn Marino   *       In this case, @e *xnext shall have a defined value and is the
113e4b17023SJohn Marino   *       next element to read (to get, or to obtain a character value,
114e4b17023SJohn Marino   *       from the sequence).
115e4b17023SJohn Marino  */
116e4b17023SJohn Marino  template<typename _CharT, typename _Traits>
117e4b17023SJohn Marino    class basic_streambuf
118e4b17023SJohn Marino    {
119e4b17023SJohn Marino    public:
120e4b17023SJohn Marino      //@{
121e4b17023SJohn Marino      /**
122e4b17023SJohn Marino       *  These are standard types.  They permit a standardized way of
123e4b17023SJohn Marino       *  referring to names of (or names dependant on) the template
124e4b17023SJohn Marino       *  parameters, which are specific to the implementation.
125e4b17023SJohn Marino      */
126e4b17023SJohn Marino      typedef _CharT 					char_type;
127e4b17023SJohn Marino      typedef _Traits 					traits_type;
128e4b17023SJohn Marino      typedef typename traits_type::int_type 		int_type;
129e4b17023SJohn Marino      typedef typename traits_type::pos_type 		pos_type;
130e4b17023SJohn Marino      typedef typename traits_type::off_type 		off_type;
131e4b17023SJohn Marino      //@}
132e4b17023SJohn Marino
133e4b17023SJohn Marino      //@{
134e4b17023SJohn Marino      /// This is a non-standard type.
135e4b17023SJohn Marino      typedef basic_streambuf<char_type, traits_type>  	__streambuf_type;
136e4b17023SJohn Marino      //@}
137e4b17023SJohn Marino
138e4b17023SJohn Marino      friend class basic_ios<char_type, traits_type>;
139e4b17023SJohn Marino      friend class basic_istream<char_type, traits_type>;
140e4b17023SJohn Marino      friend class basic_ostream<char_type, traits_type>;
141e4b17023SJohn Marino      friend class istreambuf_iterator<char_type, traits_type>;
142e4b17023SJohn Marino      friend class ostreambuf_iterator<char_type, traits_type>;
143e4b17023SJohn Marino
144e4b17023SJohn Marino      friend streamsize
145e4b17023SJohn Marino      __copy_streambufs_eof<>(__streambuf_type*, __streambuf_type*, bool&);
146e4b17023SJohn Marino
147e4b17023SJohn Marino      template<bool _IsMove, typename _CharT2>
148e4b17023SJohn Marino        friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
149e4b17023SJohn Marino					       _CharT2*>::__type
150e4b17023SJohn Marino        __copy_move_a2(istreambuf_iterator<_CharT2>,
151e4b17023SJohn Marino		       istreambuf_iterator<_CharT2>, _CharT2*);
152e4b17023SJohn Marino
153e4b17023SJohn Marino      template<typename _CharT2>
154e4b17023SJohn Marino        friend typename __gnu_cxx::__enable_if<__is_char<_CharT2>::__value,
155e4b17023SJohn Marino				  istreambuf_iterator<_CharT2> >::__type
156e4b17023SJohn Marino        find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>,
157e4b17023SJohn Marino	     const _CharT2&);
158e4b17023SJohn Marino
159e4b17023SJohn Marino      template<typename _CharT2, typename _Traits2>
160e4b17023SJohn Marino        friend basic_istream<_CharT2, _Traits2>&
161e4b17023SJohn Marino        operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
162e4b17023SJohn Marino
163e4b17023SJohn Marino      template<typename _CharT2, typename _Traits2, typename _Alloc>
164e4b17023SJohn Marino        friend basic_istream<_CharT2, _Traits2>&
165e4b17023SJohn Marino        operator>>(basic_istream<_CharT2, _Traits2>&,
166e4b17023SJohn Marino		   basic_string<_CharT2, _Traits2, _Alloc>&);
167e4b17023SJohn Marino
168e4b17023SJohn Marino      template<typename _CharT2, typename _Traits2, typename _Alloc>
169e4b17023SJohn Marino        friend basic_istream<_CharT2, _Traits2>&
170e4b17023SJohn Marino        getline(basic_istream<_CharT2, _Traits2>&,
171e4b17023SJohn Marino		basic_string<_CharT2, _Traits2, _Alloc>&, _CharT2);
172e4b17023SJohn Marino
173e4b17023SJohn Marino    protected:
174*5ce9237cSJohn Marino      /*
175e4b17023SJohn Marino       *  This is based on _IO_FILE, just reordered to be more consistent,
176e4b17023SJohn Marino       *  and is intended to be the most minimal abstraction for an
177e4b17023SJohn Marino       *  internal buffer.
178e4b17023SJohn Marino       *  -  get == input == read
179e4b17023SJohn Marino       *  -  put == output == write
180e4b17023SJohn Marino      */
181*5ce9237cSJohn Marino      char_type* 		_M_in_beg;     ///< Start of get area.
182*5ce9237cSJohn Marino      char_type* 		_M_in_cur;     ///< Current read area.
183*5ce9237cSJohn Marino      char_type* 		_M_in_end;     ///< End of get area.
184*5ce9237cSJohn Marino      char_type* 		_M_out_beg;    ///< Start of put area.
185*5ce9237cSJohn Marino      char_type* 		_M_out_cur;    ///< Current put area.
186*5ce9237cSJohn Marino      char_type* 		_M_out_end;    ///< End of put area.
187e4b17023SJohn Marino
188e4b17023SJohn Marino      /// Current locale setting.
189e4b17023SJohn Marino      locale 			_M_buf_locale;
190e4b17023SJohn Marino
191e4b17023SJohn Marino  public:
192e4b17023SJohn Marino      /// Destructor deallocates no buffer space.
193e4b17023SJohn Marino      virtual
194e4b17023SJohn Marino      ~basic_streambuf()
195e4b17023SJohn Marino      { }
196e4b17023SJohn Marino
197e4b17023SJohn Marino      // [27.5.2.2.1] locales
198e4b17023SJohn Marino      /**
199e4b17023SJohn Marino       *  @brief  Entry point for imbue().
200e4b17023SJohn Marino       *  @param  __loc  The new locale.
201e4b17023SJohn Marino       *  @return  The previous locale.
202e4b17023SJohn Marino       *
203e4b17023SJohn Marino       *  Calls the derived imbue(__loc).
204e4b17023SJohn Marino      */
205e4b17023SJohn Marino      locale
206e4b17023SJohn Marino      pubimbue(const locale& __loc)
207e4b17023SJohn Marino      {
208e4b17023SJohn Marino	locale __tmp(this->getloc());
209e4b17023SJohn Marino	this->imbue(__loc);
210e4b17023SJohn Marino	_M_buf_locale = __loc;
211e4b17023SJohn Marino	return __tmp;
212e4b17023SJohn Marino      }
213e4b17023SJohn Marino
214e4b17023SJohn Marino      /**
215e4b17023SJohn Marino       *  @brief  Locale access.
216e4b17023SJohn Marino       *  @return  The current locale in effect.
217e4b17023SJohn Marino       *
218e4b17023SJohn Marino       *  If pubimbue(loc) has been called, then the most recent @c loc
219e4b17023SJohn Marino       *  is returned.  Otherwise the global locale in effect at the time
220e4b17023SJohn Marino       *  of construction is returned.
221e4b17023SJohn Marino      */
222e4b17023SJohn Marino      locale
223e4b17023SJohn Marino      getloc() const
224e4b17023SJohn Marino      { return _M_buf_locale; }
225e4b17023SJohn Marino
226e4b17023SJohn Marino      // [27.5.2.2.2] buffer management and positioning
227e4b17023SJohn Marino      //@{
228e4b17023SJohn Marino      /**
229e4b17023SJohn Marino       *  @brief  Entry points for derived buffer functions.
230e4b17023SJohn Marino       *
231e4b17023SJohn Marino       *  The public versions of @c pubfoo dispatch to the protected
232e4b17023SJohn Marino       *  derived @c foo member functions, passing the arguments (if any)
233e4b17023SJohn Marino       *  and returning the result unchanged.
234e4b17023SJohn Marino      */
235e4b17023SJohn Marino      __streambuf_type*
236e4b17023SJohn Marino      pubsetbuf(char_type* __s, streamsize __n)
237e4b17023SJohn Marino      { return this->setbuf(__s, __n); }
238e4b17023SJohn Marino
239e4b17023SJohn Marino      /**
240e4b17023SJohn Marino       *  @brief  Alters the stream position.
241e4b17023SJohn Marino       *  @param  __off  Offset.
242e4b17023SJohn Marino       *  @param  __way  Value for ios_base::seekdir.
243e4b17023SJohn Marino       *  @param  __mode Value for ios_base::openmode.
244e4b17023SJohn Marino       *
245e4b17023SJohn Marino       *  Calls virtual seekoff function.
246e4b17023SJohn Marino      */
247e4b17023SJohn Marino      pos_type
248e4b17023SJohn Marino      pubseekoff(off_type __off, ios_base::seekdir __way,
249e4b17023SJohn Marino		 ios_base::openmode __mode = ios_base::in | ios_base::out)
250e4b17023SJohn Marino      { return this->seekoff(__off, __way, __mode); }
251e4b17023SJohn Marino
252e4b17023SJohn Marino      /**
253e4b17023SJohn Marino       *  @brief  Alters the stream position.
254e4b17023SJohn Marino       *  @param  __sp  Position
255e4b17023SJohn Marino       *  @param  __mode Value for ios_base::openmode.
256e4b17023SJohn Marino       *
257e4b17023SJohn Marino       *  Calls virtual seekpos function.
258e4b17023SJohn Marino      */
259e4b17023SJohn Marino      pos_type
260e4b17023SJohn Marino      pubseekpos(pos_type __sp,
261e4b17023SJohn Marino		 ios_base::openmode __mode = ios_base::in | ios_base::out)
262e4b17023SJohn Marino      { return this->seekpos(__sp, __mode); }
263e4b17023SJohn Marino
264e4b17023SJohn Marino      /**
265e4b17023SJohn Marino       *  @brief  Calls virtual sync function.
266e4b17023SJohn Marino      */
267e4b17023SJohn Marino      int
268e4b17023SJohn Marino      pubsync() { return this->sync(); }
269e4b17023SJohn Marino      //@}
270e4b17023SJohn Marino
271e4b17023SJohn Marino      // [27.5.2.2.3] get area
272e4b17023SJohn Marino      /**
273e4b17023SJohn Marino       *  @brief  Looking ahead into the stream.
274e4b17023SJohn Marino       *  @return  The number of characters available.
275e4b17023SJohn Marino       *
276e4b17023SJohn Marino       *  If a read position is available, returns the number of characters
277e4b17023SJohn Marino       *  available for reading before the buffer must be refilled.
278e4b17023SJohn Marino       *  Otherwise returns the derived @c showmanyc().
279e4b17023SJohn Marino      */
280e4b17023SJohn Marino      streamsize
281e4b17023SJohn Marino      in_avail()
282e4b17023SJohn Marino      {
283e4b17023SJohn Marino	const streamsize __ret = this->egptr() - this->gptr();
284e4b17023SJohn Marino	return __ret ? __ret : this->showmanyc();
285e4b17023SJohn Marino      }
286e4b17023SJohn Marino
287e4b17023SJohn Marino      /**
288e4b17023SJohn Marino       *  @brief  Getting the next character.
289e4b17023SJohn Marino       *  @return  The next character, or eof.
290e4b17023SJohn Marino       *
291e4b17023SJohn Marino       *  Calls @c sbumpc(), and if that function returns
292e4b17023SJohn Marino       *  @c traits::eof(), so does this function.  Otherwise, @c sgetc().
293e4b17023SJohn Marino      */
294e4b17023SJohn Marino      int_type
295e4b17023SJohn Marino      snextc()
296e4b17023SJohn Marino      {
297e4b17023SJohn Marino	int_type __ret = traits_type::eof();
298e4b17023SJohn Marino	if (__builtin_expect(!traits_type::eq_int_type(this->sbumpc(),
299e4b17023SJohn Marino						       __ret), true))
300e4b17023SJohn Marino	  __ret = this->sgetc();
301e4b17023SJohn Marino	return __ret;
302e4b17023SJohn Marino      }
303e4b17023SJohn Marino
304e4b17023SJohn Marino      /**
305e4b17023SJohn Marino       *  @brief  Getting the next character.
306e4b17023SJohn Marino       *  @return  The next character, or eof.
307e4b17023SJohn Marino       *
308e4b17023SJohn Marino       *  If the input read position is available, returns that character
309e4b17023SJohn Marino       *  and increments the read pointer, otherwise calls and returns
310e4b17023SJohn Marino       *  @c uflow().
311e4b17023SJohn Marino      */
312e4b17023SJohn Marino      int_type
313e4b17023SJohn Marino      sbumpc()
314e4b17023SJohn Marino      {
315e4b17023SJohn Marino	int_type __ret;
316e4b17023SJohn Marino	if (__builtin_expect(this->gptr() < this->egptr(), true))
317e4b17023SJohn Marino	  {
318e4b17023SJohn Marino	    __ret = traits_type::to_int_type(*this->gptr());
319e4b17023SJohn Marino	    this->gbump(1);
320e4b17023SJohn Marino	  }
321e4b17023SJohn Marino	else
322e4b17023SJohn Marino	  __ret = this->uflow();
323e4b17023SJohn Marino	return __ret;
324e4b17023SJohn Marino      }
325e4b17023SJohn Marino
326e4b17023SJohn Marino      /**
327e4b17023SJohn Marino       *  @brief  Getting the next character.
328e4b17023SJohn Marino       *  @return  The next character, or eof.
329e4b17023SJohn Marino       *
330e4b17023SJohn Marino       *  If the input read position is available, returns that character,
331e4b17023SJohn Marino       *  otherwise calls and returns @c underflow().  Does not move the
332e4b17023SJohn Marino       *  read position after fetching the character.
333e4b17023SJohn Marino      */
334e4b17023SJohn Marino      int_type
335e4b17023SJohn Marino      sgetc()
336e4b17023SJohn Marino      {
337e4b17023SJohn Marino	int_type __ret;
338e4b17023SJohn Marino	if (__builtin_expect(this->gptr() < this->egptr(), true))
339e4b17023SJohn Marino	  __ret = traits_type::to_int_type(*this->gptr());
340e4b17023SJohn Marino	else
341e4b17023SJohn Marino	  __ret = this->underflow();
342e4b17023SJohn Marino	return __ret;
343e4b17023SJohn Marino      }
344e4b17023SJohn Marino
345e4b17023SJohn Marino      /**
346e4b17023SJohn Marino       *  @brief  Entry point for xsgetn.
347e4b17023SJohn Marino       *  @param  __s  A buffer area.
348e4b17023SJohn Marino       *  @param  __n  A count.
349e4b17023SJohn Marino       *
350e4b17023SJohn Marino       *  Returns xsgetn(__s,__n).  The effect is to fill @a __s[0] through
351e4b17023SJohn Marino       *  @a __s[__n-1] with characters from the input sequence, if possible.
352e4b17023SJohn Marino      */
353e4b17023SJohn Marino      streamsize
354e4b17023SJohn Marino      sgetn(char_type* __s, streamsize __n)
355e4b17023SJohn Marino      { return this->xsgetn(__s, __n); }
356e4b17023SJohn Marino
357e4b17023SJohn Marino      // [27.5.2.2.4] putback
358e4b17023SJohn Marino      /**
359e4b17023SJohn Marino       *  @brief  Pushing characters back into the input stream.
360e4b17023SJohn Marino       *  @param  __c  The character to push back.
361e4b17023SJohn Marino       *  @return  The previous character, if possible.
362e4b17023SJohn Marino       *
363e4b17023SJohn Marino       *  Similar to sungetc(), but @a __c is pushed onto the stream
364e4b17023SJohn Marino       *  instead of <em>the previous character.</em> If successful,
365e4b17023SJohn Marino       *  the next character fetched from the input stream will be @a
366e4b17023SJohn Marino       *  __c.
367e4b17023SJohn Marino      */
368e4b17023SJohn Marino      int_type
369e4b17023SJohn Marino      sputbackc(char_type __c)
370e4b17023SJohn Marino      {
371e4b17023SJohn Marino	int_type __ret;
372e4b17023SJohn Marino	const bool __testpos = this->eback() < this->gptr();
373e4b17023SJohn Marino	if (__builtin_expect(!__testpos ||
374e4b17023SJohn Marino			     !traits_type::eq(__c, this->gptr()[-1]), false))
375e4b17023SJohn Marino	  __ret = this->pbackfail(traits_type::to_int_type(__c));
376e4b17023SJohn Marino	else
377e4b17023SJohn Marino	  {
378e4b17023SJohn Marino	    this->gbump(-1);
379e4b17023SJohn Marino	    __ret = traits_type::to_int_type(*this->gptr());
380e4b17023SJohn Marino	  }
381e4b17023SJohn Marino	return __ret;
382e4b17023SJohn Marino      }
383e4b17023SJohn Marino
384e4b17023SJohn Marino      /**
385e4b17023SJohn Marino       *  @brief  Moving backwards in the input stream.
386e4b17023SJohn Marino       *  @return  The previous character, if possible.
387e4b17023SJohn Marino       *
388e4b17023SJohn Marino       *  If a putback position is available, this function decrements
389e4b17023SJohn Marino       *  the input pointer and returns that character.  Otherwise,
390e4b17023SJohn Marino       *  calls and returns pbackfail().  The effect is to @a unget
391e4b17023SJohn Marino       *  the last character @a gotten.
392e4b17023SJohn Marino      */
393e4b17023SJohn Marino      int_type
394e4b17023SJohn Marino      sungetc()
395e4b17023SJohn Marino      {
396e4b17023SJohn Marino	int_type __ret;
397e4b17023SJohn Marino	if (__builtin_expect(this->eback() < this->gptr(), true))
398e4b17023SJohn Marino	  {
399e4b17023SJohn Marino	    this->gbump(-1);
400e4b17023SJohn Marino	    __ret = traits_type::to_int_type(*this->gptr());
401e4b17023SJohn Marino	  }
402e4b17023SJohn Marino	else
403e4b17023SJohn Marino	  __ret = this->pbackfail();
404e4b17023SJohn Marino	return __ret;
405e4b17023SJohn Marino      }
406e4b17023SJohn Marino
407e4b17023SJohn Marino      // [27.5.2.2.5] put area
408e4b17023SJohn Marino      /**
409e4b17023SJohn Marino       *  @brief  Entry point for all single-character output functions.
410e4b17023SJohn Marino       *  @param  __c  A character to output.
411e4b17023SJohn Marino       *  @return  @a __c, if possible.
412e4b17023SJohn Marino       *
413e4b17023SJohn Marino       *  One of two public output functions.
414e4b17023SJohn Marino       *
415e4b17023SJohn Marino       *  If a write position is available for the output sequence (i.e.,
416e4b17023SJohn Marino       *  the buffer is not full), stores @a __c in that position, increments
417e4b17023SJohn Marino       *  the position, and returns @c traits::to_int_type(__c).  If a write
418e4b17023SJohn Marino       *  position is not available, returns @c overflow(__c).
419e4b17023SJohn Marino      */
420e4b17023SJohn Marino      int_type
421e4b17023SJohn Marino      sputc(char_type __c)
422e4b17023SJohn Marino      {
423e4b17023SJohn Marino	int_type __ret;
424e4b17023SJohn Marino	if (__builtin_expect(this->pptr() < this->epptr(), true))
425e4b17023SJohn Marino	  {
426e4b17023SJohn Marino	    *this->pptr() = __c;
427e4b17023SJohn Marino	    this->pbump(1);
428e4b17023SJohn Marino	    __ret = traits_type::to_int_type(__c);
429e4b17023SJohn Marino	  }
430e4b17023SJohn Marino	else
431e4b17023SJohn Marino	  __ret = this->overflow(traits_type::to_int_type(__c));
432e4b17023SJohn Marino	return __ret;
433e4b17023SJohn Marino      }
434e4b17023SJohn Marino
435e4b17023SJohn Marino      /**
436e4b17023SJohn Marino       *  @brief  Entry point for all single-character output functions.
437e4b17023SJohn Marino       *  @param  __s  A buffer read area.
438e4b17023SJohn Marino       *  @param  __n  A count.
439e4b17023SJohn Marino       *
440e4b17023SJohn Marino       *  One of two public output functions.
441e4b17023SJohn Marino       *
442e4b17023SJohn Marino       *
443e4b17023SJohn Marino       *  Returns xsputn(__s,__n).  The effect is to write @a __s[0] through
444e4b17023SJohn Marino       *  @a __s[__n-1] to the output sequence, if possible.
445e4b17023SJohn Marino      */
446e4b17023SJohn Marino      streamsize
447e4b17023SJohn Marino      sputn(const char_type* __s, streamsize __n)
448e4b17023SJohn Marino      { return this->xsputn(__s, __n); }
449e4b17023SJohn Marino
450e4b17023SJohn Marino    protected:
451e4b17023SJohn Marino      /**
452e4b17023SJohn Marino       *  @brief  Base constructor.
453e4b17023SJohn Marino       *
454e4b17023SJohn Marino       *  Only called from derived constructors, and sets up all the
455e4b17023SJohn Marino       *  buffer data to zero, including the pointers described in the
456e4b17023SJohn Marino       *  basic_streambuf class description.  Note that, as a result,
457e4b17023SJohn Marino       *  - the class starts with no read nor write positions available,
458e4b17023SJohn Marino       *  - this is not an error
459e4b17023SJohn Marino      */
460e4b17023SJohn Marino      basic_streambuf()
461e4b17023SJohn Marino      : _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
462e4b17023SJohn Marino      _M_out_beg(0), _M_out_cur(0), _M_out_end(0),
463e4b17023SJohn Marino      _M_buf_locale(locale())
464e4b17023SJohn Marino      { }
465e4b17023SJohn Marino
466e4b17023SJohn Marino      // [27.5.2.3.1] get area access
467e4b17023SJohn Marino      //@{
468e4b17023SJohn Marino      /**
469e4b17023SJohn Marino       *  @brief  Access to the get area.
470e4b17023SJohn Marino       *
471e4b17023SJohn Marino       *  These functions are only available to other protected functions,
472e4b17023SJohn Marino       *  including derived classes.
473e4b17023SJohn Marino       *
474e4b17023SJohn Marino       *  - eback() returns the beginning pointer for the input sequence
475e4b17023SJohn Marino       *  - gptr() returns the next pointer for the input sequence
476e4b17023SJohn Marino       *  - egptr() returns the end pointer for the input sequence
477e4b17023SJohn Marino      */
478e4b17023SJohn Marino      char_type*
479e4b17023SJohn Marino      eback() const { return _M_in_beg; }
480e4b17023SJohn Marino
481e4b17023SJohn Marino      char_type*
482e4b17023SJohn Marino      gptr()  const { return _M_in_cur;  }
483e4b17023SJohn Marino
484e4b17023SJohn Marino      char_type*
485e4b17023SJohn Marino      egptr() const { return _M_in_end; }
486e4b17023SJohn Marino      //@}
487e4b17023SJohn Marino
488e4b17023SJohn Marino      /**
489e4b17023SJohn Marino       *  @brief  Moving the read position.
490e4b17023SJohn Marino       *  @param  __n  The delta by which to move.
491e4b17023SJohn Marino       *
492e4b17023SJohn Marino       *  This just advances the read position without returning any data.
493e4b17023SJohn Marino      */
494e4b17023SJohn Marino      void
495e4b17023SJohn Marino      gbump(int __n) { _M_in_cur += __n; }
496e4b17023SJohn Marino
497e4b17023SJohn Marino      /**
498e4b17023SJohn Marino       *  @brief  Setting the three read area pointers.
499e4b17023SJohn Marino       *  @param  __gbeg  A pointer.
500e4b17023SJohn Marino       *  @param  __gnext  A pointer.
501e4b17023SJohn Marino       *  @param  __gend  A pointer.
502e4b17023SJohn Marino       *  @post  @a __gbeg == @c eback(), @a __gnext == @c gptr(), and
503e4b17023SJohn Marino       *         @a __gend == @c egptr()
504e4b17023SJohn Marino      */
505e4b17023SJohn Marino      void
506e4b17023SJohn Marino      setg(char_type* __gbeg, char_type* __gnext, char_type* __gend)
507e4b17023SJohn Marino      {
508e4b17023SJohn Marino	_M_in_beg = __gbeg;
509e4b17023SJohn Marino	_M_in_cur = __gnext;
510e4b17023SJohn Marino	_M_in_end = __gend;
511e4b17023SJohn Marino      }
512e4b17023SJohn Marino
513e4b17023SJohn Marino      // [27.5.2.3.2] put area access
514e4b17023SJohn Marino      //@{
515e4b17023SJohn Marino      /**
516e4b17023SJohn Marino       *  @brief  Access to the put area.
517e4b17023SJohn Marino       *
518e4b17023SJohn Marino       *  These functions are only available to other protected functions,
519e4b17023SJohn Marino       *  including derived classes.
520e4b17023SJohn Marino       *
521e4b17023SJohn Marino       *  - pbase() returns the beginning pointer for the output sequence
522e4b17023SJohn Marino       *  - pptr() returns the next pointer for the output sequence
523e4b17023SJohn Marino       *  - epptr() returns the end pointer for the output sequence
524e4b17023SJohn Marino      */
525e4b17023SJohn Marino      char_type*
526e4b17023SJohn Marino      pbase() const { return _M_out_beg; }
527e4b17023SJohn Marino
528e4b17023SJohn Marino      char_type*
529e4b17023SJohn Marino      pptr() const { return _M_out_cur; }
530e4b17023SJohn Marino
531e4b17023SJohn Marino      char_type*
532e4b17023SJohn Marino      epptr() const { return _M_out_end; }
533e4b17023SJohn Marino      //@}
534e4b17023SJohn Marino
535e4b17023SJohn Marino      /**
536e4b17023SJohn Marino       *  @brief  Moving the write position.
537e4b17023SJohn Marino       *  @param  __n  The delta by which to move.
538e4b17023SJohn Marino       *
539e4b17023SJohn Marino       *  This just advances the write position without returning any data.
540e4b17023SJohn Marino      */
541e4b17023SJohn Marino      void
542e4b17023SJohn Marino      pbump(int __n) { _M_out_cur += __n; }
543e4b17023SJohn Marino
544e4b17023SJohn Marino      /**
545e4b17023SJohn Marino       *  @brief  Setting the three write area pointers.
546e4b17023SJohn Marino       *  @param  __pbeg  A pointer.
547e4b17023SJohn Marino       *  @param  __pend  A pointer.
548e4b17023SJohn Marino       *  @post  @a __pbeg == @c pbase(), @a __pbeg == @c pptr(), and
549e4b17023SJohn Marino       *         @a __pend == @c epptr()
550e4b17023SJohn Marino      */
551e4b17023SJohn Marino      void
552e4b17023SJohn Marino      setp(char_type* __pbeg, char_type* __pend)
553e4b17023SJohn Marino      {
554e4b17023SJohn Marino	_M_out_beg = _M_out_cur = __pbeg;
555e4b17023SJohn Marino	_M_out_end = __pend;
556e4b17023SJohn Marino      }
557e4b17023SJohn Marino
558e4b17023SJohn Marino      // [27.5.2.4] virtual functions
559e4b17023SJohn Marino      // [27.5.2.4.1] locales
560e4b17023SJohn Marino      /**
561e4b17023SJohn Marino       *  @brief  Changes translations.
562e4b17023SJohn Marino       *  @param  __loc  A new locale.
563e4b17023SJohn Marino       *
564e4b17023SJohn Marino       *  Translations done during I/O which depend on the current
565e4b17023SJohn Marino       *  locale are changed by this call.  The standard adds,
566e4b17023SJohn Marino       *  <em>Between invocations of this function a class derived
567e4b17023SJohn Marino       *  from streambuf can safely cache results of calls to locale
568e4b17023SJohn Marino       *  functions and to members of facets so obtained.</em>
569e4b17023SJohn Marino       *
570e4b17023SJohn Marino       *  @note  Base class version does nothing.
571e4b17023SJohn Marino      */
572e4b17023SJohn Marino      virtual void
573e4b17023SJohn Marino      imbue(const locale& __loc)
574e4b17023SJohn Marino      { }
575e4b17023SJohn Marino
576e4b17023SJohn Marino      // [27.5.2.4.2] buffer management and positioning
577e4b17023SJohn Marino      /**
578e4b17023SJohn Marino       *  @brief  Manipulates the buffer.
579e4b17023SJohn Marino       *
580e4b17023SJohn Marino       *  Each derived class provides its own appropriate behavior.  See
581e4b17023SJohn Marino       *  the next-to-last paragraph of
582e4b17023SJohn Marino       *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25s02.html
583e4b17023SJohn Marino       *  for more on this function.
584e4b17023SJohn Marino       *
585e4b17023SJohn Marino       *  @note  Base class version does nothing, returns @c this.
586e4b17023SJohn Marino      */
587e4b17023SJohn Marino      virtual basic_streambuf<char_type,_Traits>*
588e4b17023SJohn Marino      setbuf(char_type*, streamsize)
589e4b17023SJohn Marino      {	return this; }
590e4b17023SJohn Marino
591e4b17023SJohn Marino      /**
592e4b17023SJohn Marino       *  @brief  Alters the stream positions.
593e4b17023SJohn Marino       *
594e4b17023SJohn Marino       *  Each derived class provides its own appropriate behavior.
595e4b17023SJohn Marino       *  @note  Base class version does nothing, returns a @c pos_type
596e4b17023SJohn Marino       *         that represents an invalid stream position.
597e4b17023SJohn Marino      */
598e4b17023SJohn Marino      virtual pos_type
599e4b17023SJohn Marino      seekoff(off_type, ios_base::seekdir,
600e4b17023SJohn Marino	      ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
601e4b17023SJohn Marino      { return pos_type(off_type(-1)); }
602e4b17023SJohn Marino
603e4b17023SJohn Marino      /**
604e4b17023SJohn Marino       *  @brief  Alters the stream positions.
605e4b17023SJohn Marino       *
606e4b17023SJohn Marino       *  Each derived class provides its own appropriate behavior.
607e4b17023SJohn Marino       *  @note  Base class version does nothing, returns a @c pos_type
608e4b17023SJohn Marino       *         that represents an invalid stream position.
609e4b17023SJohn Marino      */
610e4b17023SJohn Marino      virtual pos_type
611e4b17023SJohn Marino      seekpos(pos_type,
612e4b17023SJohn Marino	      ios_base::openmode /*__mode*/ = ios_base::in | ios_base::out)
613e4b17023SJohn Marino      { return pos_type(off_type(-1)); }
614e4b17023SJohn Marino
615e4b17023SJohn Marino      /**
616e4b17023SJohn Marino       *  @brief  Synchronizes the buffer arrays with the controlled sequences.
617e4b17023SJohn Marino       *  @return  -1 on failure.
618e4b17023SJohn Marino       *
619e4b17023SJohn Marino       *  Each derived class provides its own appropriate behavior,
620e4b17023SJohn Marino       *  including the definition of @a failure.
621e4b17023SJohn Marino       *  @note  Base class version does nothing, returns zero.
622e4b17023SJohn Marino      */
623e4b17023SJohn Marino      virtual int
624e4b17023SJohn Marino      sync() { return 0; }
625e4b17023SJohn Marino
626e4b17023SJohn Marino      // [27.5.2.4.3] get area
627e4b17023SJohn Marino      /**
628e4b17023SJohn Marino       *  @brief  Investigating the data available.
629e4b17023SJohn Marino       *  @return  An estimate of the number of characters available in the
630e4b17023SJohn Marino       *           input sequence, or -1.
631e4b17023SJohn Marino       *
632e4b17023SJohn Marino       *  <em>If it returns a positive value, then successive calls to
633e4b17023SJohn Marino       *  @c underflow() will not return @c traits::eof() until at
634e4b17023SJohn Marino       *  least that number of characters have been supplied.  If @c
635e4b17023SJohn Marino       *  showmanyc() returns -1, then calls to @c underflow() or @c
636e4b17023SJohn Marino       *  uflow() will fail.</em> [27.5.2.4.3]/1
637e4b17023SJohn Marino       *
638e4b17023SJohn Marino       *  @note  Base class version does nothing, returns zero.
639e4b17023SJohn Marino       *  @note  The standard adds that <em>the intention is not only that the
640e4b17023SJohn Marino       *         calls [to underflow or uflow] will not return @c eof() but
641e4b17023SJohn Marino       *         that they will return immediately.</em>
642e4b17023SJohn Marino       *  @note  The standard adds that <em>the morphemes of @c showmanyc are
643e4b17023SJohn Marino       *         @b es-how-many-see, not @b show-manic.</em>
644e4b17023SJohn Marino      */
645e4b17023SJohn Marino      virtual streamsize
646e4b17023SJohn Marino      showmanyc() { return 0; }
647e4b17023SJohn Marino
648e4b17023SJohn Marino      /**
649e4b17023SJohn Marino       *  @brief  Multiple character extraction.
650e4b17023SJohn Marino       *  @param  __s  A buffer area.
651e4b17023SJohn Marino       *  @param  __n  Maximum number of characters to assign.
652e4b17023SJohn Marino       *  @return  The number of characters assigned.
653e4b17023SJohn Marino       *
654e4b17023SJohn Marino       *  Fills @a __s[0] through @a __s[__n-1] with characters from the input
655e4b17023SJohn Marino       *  sequence, as if by @c sbumpc().  Stops when either @a __n characters
656e4b17023SJohn Marino       *  have been copied, or when @c traits::eof() would be copied.
657e4b17023SJohn Marino       *
658e4b17023SJohn Marino       *  It is expected that derived classes provide a more efficient
659e4b17023SJohn Marino       *  implementation by overriding this definition.
660e4b17023SJohn Marino      */
661e4b17023SJohn Marino      virtual streamsize
662e4b17023SJohn Marino      xsgetn(char_type* __s, streamsize __n);
663e4b17023SJohn Marino
664e4b17023SJohn Marino      /**
665e4b17023SJohn Marino       *  @brief  Fetches more data from the controlled sequence.
666e4b17023SJohn Marino       *  @return  The first character from the <em>pending sequence</em>.
667e4b17023SJohn Marino       *
668e4b17023SJohn Marino       *  Informally, this function is called when the input buffer is
669e4b17023SJohn Marino       *  exhausted (or does not exist, as buffering need not actually be
670e4b17023SJohn Marino       *  done).  If a buffer exists, it is @a refilled.  In either case, the
671e4b17023SJohn Marino       *  next available character is returned, or @c traits::eof() to
672e4b17023SJohn Marino       *  indicate a null pending sequence.
673e4b17023SJohn Marino       *
674e4b17023SJohn Marino       *  For a formal definition of the pending sequence, see a good text
675e4b17023SJohn Marino       *  such as Langer & Kreft, or [27.5.2.4.3]/7-14.
676e4b17023SJohn Marino       *
677e4b17023SJohn Marino       *  A functioning input streambuf can be created by overriding only
678e4b17023SJohn Marino       *  this function (no buffer area will be used).  For an example, see
679e4b17023SJohn Marino       *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch25.html
680e4b17023SJohn Marino       *
681e4b17023SJohn Marino       *  @note  Base class version does nothing, returns eof().
682e4b17023SJohn Marino      */
683e4b17023SJohn Marino      virtual int_type
684e4b17023SJohn Marino      underflow()
685e4b17023SJohn Marino      { return traits_type::eof(); }
686e4b17023SJohn Marino
687e4b17023SJohn Marino      /**
688e4b17023SJohn Marino       *  @brief  Fetches more data from the controlled sequence.
689e4b17023SJohn Marino       *  @return  The first character from the <em>pending sequence</em>.
690e4b17023SJohn Marino       *
691e4b17023SJohn Marino       *  Informally, this function does the same thing as @c underflow(),
692e4b17023SJohn Marino       *  and in fact is required to call that function.  It also returns
693e4b17023SJohn Marino       *  the new character, like @c underflow() does.  However, this
694e4b17023SJohn Marino       *  function also moves the read position forward by one.
695e4b17023SJohn Marino      */
696e4b17023SJohn Marino      virtual int_type
697e4b17023SJohn Marino      uflow()
698e4b17023SJohn Marino      {
699e4b17023SJohn Marino	int_type __ret = traits_type::eof();
700e4b17023SJohn Marino	const bool __testeof = traits_type::eq_int_type(this->underflow(),
701e4b17023SJohn Marino							__ret);
702e4b17023SJohn Marino	if (!__testeof)
703e4b17023SJohn Marino	  {
704e4b17023SJohn Marino	    __ret = traits_type::to_int_type(*this->gptr());
705e4b17023SJohn Marino	    this->gbump(1);
706e4b17023SJohn Marino	  }
707e4b17023SJohn Marino	return __ret;
708e4b17023SJohn Marino      }
709e4b17023SJohn Marino
710e4b17023SJohn Marino      // [27.5.2.4.4] putback
711e4b17023SJohn Marino      /**
712e4b17023SJohn Marino       *  @brief  Tries to back up the input sequence.
713e4b17023SJohn Marino       *  @param  __c  The character to be inserted back into the sequence.
714e4b17023SJohn Marino       *  @return  eof() on failure, <em>some other value</em> on success
715e4b17023SJohn Marino       *  @post  The constraints of @c gptr(), @c eback(), and @c pptr()
716e4b17023SJohn Marino       *         are the same as for @c underflow().
717e4b17023SJohn Marino       *
718e4b17023SJohn Marino       *  @note  Base class version does nothing, returns eof().
719e4b17023SJohn Marino      */
720e4b17023SJohn Marino      virtual int_type
721e4b17023SJohn Marino      pbackfail(int_type __c  = traits_type::eof())
722e4b17023SJohn Marino      { return traits_type::eof(); }
723e4b17023SJohn Marino
724e4b17023SJohn Marino      // Put area:
725e4b17023SJohn Marino      /**
726e4b17023SJohn Marino       *  @brief  Multiple character insertion.
727e4b17023SJohn Marino       *  @param  __s  A buffer area.
728e4b17023SJohn Marino       *  @param  __n  Maximum number of characters to write.
729e4b17023SJohn Marino       *  @return  The number of characters written.
730e4b17023SJohn Marino       *
731e4b17023SJohn Marino       *  Writes @a __s[0] through @a __s[__n-1] to the output sequence, as if
732e4b17023SJohn Marino       *  by @c sputc().  Stops when either @a n characters have been
733e4b17023SJohn Marino       *  copied, or when @c sputc() would return @c traits::eof().
734e4b17023SJohn Marino       *
735e4b17023SJohn Marino       *  It is expected that derived classes provide a more efficient
736e4b17023SJohn Marino       *  implementation by overriding this definition.
737e4b17023SJohn Marino      */
738e4b17023SJohn Marino      virtual streamsize
739e4b17023SJohn Marino      xsputn(const char_type* __s, streamsize __n);
740e4b17023SJohn Marino
741e4b17023SJohn Marino      /**
742e4b17023SJohn Marino       *  @brief  Consumes data from the buffer; writes to the
743e4b17023SJohn Marino       *          controlled sequence.
744e4b17023SJohn Marino       *  @param  __c  An additional character to consume.
745e4b17023SJohn Marino       *  @return  eof() to indicate failure, something else (usually
746e4b17023SJohn Marino       *           @a __c, or not_eof())
747e4b17023SJohn Marino       *
748e4b17023SJohn Marino       *  Informally, this function is called when the output buffer
749e4b17023SJohn Marino       *  is full (or does not exist, as buffering need not actually
750e4b17023SJohn Marino       *  be done).  If a buffer exists, it is @a consumed, with
751e4b17023SJohn Marino       *  <em>some effect</em> on the controlled sequence.
752e4b17023SJohn Marino       *  (Typically, the buffer is written out to the sequence
753e4b17023SJohn Marino       *  verbatim.)  In either case, the character @a c is also
754e4b17023SJohn Marino       *  written out, if @a __c is not @c eof().
755e4b17023SJohn Marino       *
756e4b17023SJohn Marino       *  For a formal definition of this function, see a good text
757e4b17023SJohn Marino       *  such as Langer & Kreft, or [27.5.2.4.5]/3-7.
758e4b17023SJohn Marino       *
759e4b17023SJohn Marino       *  A functioning output streambuf can be created by overriding only
760e4b17023SJohn Marino       *  this function (no buffer area will be used).
761e4b17023SJohn Marino       *
762e4b17023SJohn Marino       *  @note  Base class version does nothing, returns eof().
763e4b17023SJohn Marino      */
764e4b17023SJohn Marino      virtual int_type
765e4b17023SJohn Marino      overflow(int_type __c  = traits_type::eof())
766e4b17023SJohn Marino      { return traits_type::eof(); }
767e4b17023SJohn Marino
768e4b17023SJohn Marino#if _GLIBCXX_USE_DEPRECATED
769e4b17023SJohn Marino    // Annex D.6
770e4b17023SJohn Marino    public:
771e4b17023SJohn Marino      /**
772e4b17023SJohn Marino       *  @brief  Tosses a character.
773e4b17023SJohn Marino       *
774e4b17023SJohn Marino       *  Advances the read pointer, ignoring the character that would have
775e4b17023SJohn Marino       *  been read.
776e4b17023SJohn Marino       *
777e4b17023SJohn Marino       *  See http://gcc.gnu.org/ml/libstdc++/2002-05/msg00168.html
778e4b17023SJohn Marino       */
779e4b17023SJohn Marino      void
780e4b17023SJohn Marino      stossc()
781e4b17023SJohn Marino      {
782e4b17023SJohn Marino	if (this->gptr() < this->egptr())
783e4b17023SJohn Marino	  this->gbump(1);
784e4b17023SJohn Marino	else
785e4b17023SJohn Marino	  this->uflow();
786e4b17023SJohn Marino      }
787e4b17023SJohn Marino#endif
788e4b17023SJohn Marino
789e4b17023SJohn Marino      // Also used by specializations for char and wchar_t in src.
790e4b17023SJohn Marino      void
791e4b17023SJohn Marino      __safe_gbump(streamsize __n) { _M_in_cur += __n; }
792e4b17023SJohn Marino
793e4b17023SJohn Marino      void
794e4b17023SJohn Marino      __safe_pbump(streamsize __n) { _M_out_cur += __n; }
795e4b17023SJohn Marino
796e4b17023SJohn Marino    private:
797e4b17023SJohn Marino      // _GLIBCXX_RESOLVE_LIB_DEFECTS
798e4b17023SJohn Marino      // Side effect of DR 50.
799e4b17023SJohn Marino      basic_streambuf(const __streambuf_type& __sb)
800e4b17023SJohn Marino      : _M_in_beg(__sb._M_in_beg), _M_in_cur(__sb._M_in_cur),
801e4b17023SJohn Marino      _M_in_end(__sb._M_in_end), _M_out_beg(__sb._M_out_beg),
802e4b17023SJohn Marino      _M_out_cur(__sb._M_out_cur), _M_out_end(__sb._M_out_cur),
803e4b17023SJohn Marino      _M_buf_locale(__sb._M_buf_locale)
804e4b17023SJohn Marino      { }
805e4b17023SJohn Marino
806e4b17023SJohn Marino      __streambuf_type&
807e4b17023SJohn Marino      operator=(const __streambuf_type&) { return *this; };
808e4b17023SJohn Marino    };
809e4b17023SJohn Marino
810e4b17023SJohn Marino  // Explicit specialization declarations, defined in src/streambuf.cc.
811e4b17023SJohn Marino  template<>
812e4b17023SJohn Marino    streamsize
813e4b17023SJohn Marino    __copy_streambufs_eof(basic_streambuf<char>* __sbin,
814e4b17023SJohn Marino			  basic_streambuf<char>* __sbout, bool& __ineof);
815e4b17023SJohn Marino#ifdef _GLIBCXX_USE_WCHAR_T
816e4b17023SJohn Marino  template<>
817e4b17023SJohn Marino    streamsize
818e4b17023SJohn Marino    __copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin,
819e4b17023SJohn Marino			  basic_streambuf<wchar_t>* __sbout, bool& __ineof);
820e4b17023SJohn Marino#endif
821e4b17023SJohn Marino
822e4b17023SJohn Marino_GLIBCXX_END_NAMESPACE_VERSION
823e4b17023SJohn Marino} // namespace
824e4b17023SJohn Marino
825e4b17023SJohn Marino#include <bits/streambuf.tcc>
826e4b17023SJohn Marino
827e4b17023SJohn Marino#endif /* _GLIBCXX_STREAMBUF */
828