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