OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [libstdc++-v3/] [include/] [bits/] [streambuf.tcc] - Blame information for rev 17

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 17 jlechner
// Stream buffer classes -*- C++ -*-
2
 
3
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
4
// 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 2, 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
// You should have received a copy of the GNU General Public License along
18
// with this library; see the file COPYING.  If not, write to the Free
19
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
// USA.
21
 
22
// As a special exception, you may use this file as part of a free software
23
// library without restriction.  Specifically, if other files instantiate
24
// templates or use macros or inline functions from this file, or you compile
25
// this file and link it with other files to produce an executable, this
26
// file does not by itself cause the resulting executable to be covered by
27
// the GNU General Public License.  This exception does not however
28
// invalidate any other reasons why the executable file might be covered by
29
// the GNU General Public License.
30
 
31
/** @file streambuf.tcc
32
 *  This is an internal header file, included by other library headers.
33
 *  You should not attempt to use it directly.
34
 */
35
 
36
//
37
// ISO C++ 14882: 27.5  Stream buffers
38
//
39
 
40
#ifndef _STREAMBUF_TCC
41
#define _STREAMBUF_TCC 1
42
 
43
#pragma GCC system_header
44
 
45
namespace std
46
{
47
  template
48
    streamsize
49
    basic_streambuf<_CharT, _Traits>::
50
    xsgetn(char_type* __s, streamsize __n)
51
    {
52
      streamsize __ret = 0;
53
      while (__ret < __n)
54
        {
55
          const streamsize __buf_len = this->egptr() - this->gptr();
56
          if (__buf_len)
57
            {
58
              const streamsize __remaining = __n - __ret;
59
              const streamsize __len = std::min(__buf_len, __remaining);
60
              traits_type::copy(__s, this->gptr(), __len);
61
              __ret += __len;
62
              __s += __len;
63
              this->gbump(__len);
64
            }
65
 
66
          if (__ret < __n)
67
            {
68
              const int_type __c = this->uflow();
69
              if (!traits_type::eq_int_type(__c, traits_type::eof()))
70
                {
71
                  traits_type::assign(*__s++, traits_type::to_char_type(__c));
72
                  ++__ret;
73
                }
74
              else
75
                break;
76
            }
77
        }
78
      return __ret;
79
    }
80
 
81
  template
82
    streamsize
83
    basic_streambuf<_CharT, _Traits>::
84
    xsputn(const char_type* __s, streamsize __n)
85
    {
86
      streamsize __ret = 0;
87
      while (__ret < __n)
88
        {
89
          const streamsize __buf_len = this->epptr() - this->pptr();
90
          if (__buf_len)
91
            {
92
              const streamsize __remaining = __n - __ret;
93
              const streamsize __len = std::min(__buf_len, __remaining);
94
              traits_type::copy(this->pptr(), __s, __len);
95
              __ret += __len;
96
              __s += __len;
97
              this->pbump(__len);
98
            }
99
 
100
          if (__ret < __n)
101
            {
102
              int_type __c = this->overflow(traits_type::to_int_type(*__s));
103
              if (!traits_type::eq_int_type(__c, traits_type::eof()))
104
                {
105
                  ++__ret;
106
                  ++__s;
107
                }
108
              else
109
                break;
110
            }
111
        }
112
      return __ret;
113
    }
114
 
115
  // Conceivably, this could be used to implement buffer-to-buffer
116
  // copies, if this was ever desired in an un-ambiguous way by the
117
  // standard.
118
  template
119
    streamsize
120
    __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin,
121
                      basic_streambuf<_CharT, _Traits>* __sbout)
122
    {
123
      streamsize __ret = 0;
124
      typename _Traits::int_type __c = __sbin->sgetc();
125
      while (!_Traits::eq_int_type(__c, _Traits::eof()))
126
        {
127
          __c = __sbout->sputc(_Traits::to_char_type(__c));
128
          if (_Traits::eq_int_type(__c, _Traits::eof()))
129
            break;
130
          ++__ret;
131
          __c = __sbin->snextc();
132
        }
133
      return __ret;
134
    }
135
 
136
  // Inhibit implicit instantiations for required instantiations,
137
  // which are defined via explicit instantiations elsewhere.
138
  // NB:  This syntax is a GNU extension.
139
#if _GLIBCXX_EXTERN_TEMPLATE
140
  extern template class basic_streambuf;
141
  extern template
142
    streamsize
143
    __copy_streambufs(basic_streambuf*, basic_streambuf*);
144
 
145
#ifdef _GLIBCXX_USE_WCHAR_T
146
  extern template class basic_streambuf;
147
  extern template
148
    streamsize
149
    __copy_streambufs(basic_streambuf*, basic_streambuf*);
150
#endif
151
#endif
152
} // namespace std
153
 
154
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.