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