1 // Stream buffer classes -*- C++ -*-
3 // Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
4 // Free Software Foundation, Inc.
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)
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.
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.
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/>.
27 // ISO C++ 14882: 27.5 Stream buffers
32 namespace std _GLIBCXX_VISIBILITY(default)
34 _GLIBCXX_BEGIN_NAMESPACE_VERSION
38 __copy_streambufs_eof(basic_streambuf<char>* __sbin,
39 basic_streambuf<char>* __sbout, bool& __ineof)
41 typedef basic_streambuf<char>::traits_type traits_type;
44 traits_type::int_type __c = __sbin->sgetc();
45 while (!traits_type::eq_int_type(__c, traits_type::eof()))
47 const streamsize __n = __sbin->egptr() - __sbin->gptr();
50 const streamsize __wrote = __sbout->sputn(__sbin->gptr(), __n);
51 __sbin->__safe_gbump(__wrote);
58 __c = __sbin->underflow();
62 __c = __sbout->sputc(traits_type::to_char_type(__c));
63 if (traits_type::eq_int_type(__c, traits_type::eof()))
69 __c = __sbin->snextc();
75 #ifdef _GLIBCXX_USE_WCHAR_T
78 __copy_streambufs_eof(basic_streambuf<wchar_t>* __sbin,
79 basic_streambuf<wchar_t>* __sbout, bool& __ineof)
81 typedef basic_streambuf<wchar_t>::traits_type traits_type;
84 traits_type::int_type __c = __sbin->sgetc();
85 while (!traits_type::eq_int_type(__c, traits_type::eof()))
87 const streamsize __n = __sbin->egptr() - __sbin->gptr();
90 const streamsize __wrote = __sbout->sputn(__sbin->gptr(), __n);
91 __sbin->__safe_gbump(__wrote);
98 __c = __sbin->underflow();
102 __c = __sbout->sputc(traits_type::to_char_type(__c));
103 if (traits_type::eq_int_type(__c, traits_type::eof()))
109 __c = __sbin->snextc();
116 _GLIBCXX_END_NAMESPACE_VERSION