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