STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Macros | Functions
streambuf.tcc File Reference

Macros

#define _STREAMBUF_TCC   1
 

Functions

namespace std _GLIBCXX_VISIBILITY (default)
 

Detailed Description

This is an internal header file, included by other library headers. Do not attempt to use it directly. {streambuf}

Macro Definition Documentation

#define _STREAMBUF_TCC   1

Function Documentation

namespace std _GLIBCXX_VISIBILITY ( default  )
40 {
41 _GLIBCXX_BEGIN_NAMESPACE_VERSION
42 
43  template<typename _CharT, typename _Traits>
44  streamsize
45  basic_streambuf<_CharT, _Traits>::
46  xsgetn(char_type* __s, streamsize __n)
47  {
48  streamsize __ret = 0;
49  while (__ret < __n)
50  {
51  const streamsize __buf_len = this->egptr() - this->gptr();
52  if (__buf_len)
53  {
54  const streamsize __remaining = __n - __ret;
55  const streamsize __len = std::min(__buf_len, __remaining);
56  traits_type::copy(__s, this->gptr(), __len);
57  __ret += __len;
58  __s += __len;
59  this->__safe_gbump(__len);
60  }
61 
62  if (__ret < __n)
63  {
64  const int_type __c = this->uflow();
65  if (!traits_type::eq_int_type(__c, traits_type::eof()))
66  {
67  traits_type::assign(*__s++, traits_type::to_char_type(__c));
68  ++__ret;
69  }
70  else
71  break;
72  }
73  }
74  return __ret;
75  }
76 
77  template<typename _CharT, typename _Traits>
78  streamsize
79  basic_streambuf<_CharT, _Traits>::
80  xsputn(const char_type* __s, streamsize __n)
81  {
82  streamsize __ret = 0;
83  while (__ret < __n)
84  {
85  const streamsize __buf_len = this->epptr() - this->pptr();
86  if (__buf_len)
87  {
88  const streamsize __remaining = __n - __ret;
89  const streamsize __len = std::min(__buf_len, __remaining);
90  traits_type::copy(this->pptr(), __s, __len);
91  __ret += __len;
92  __s += __len;
93  this->__safe_pbump(__len);
94  }
95 
96  if (__ret < __n)
97  {
98  int_type __c = this->overflow(traits_type::to_int_type(*__s));
99  if (!traits_type::eq_int_type(__c, traits_type::eof()))
100  {
101  ++__ret;
102  ++__s;
103  }
104  else
105  break;
106  }
107  }
108  return __ret;
109  }
110 
111  // Conceivably, this could be used to implement buffer-to-buffer
112  // copies, if this was ever desired in an un-ambiguous way by the
113  // standard.
114  template<typename _CharT, typename _Traits>
115  streamsize
116  __copy_streambufs_eof(basic_streambuf<_CharT, _Traits>* __sbin,
117  basic_streambuf<_CharT, _Traits>* __sbout,
118  bool& __ineof)
119  {
120  streamsize __ret = 0;
121  __ineof = true;
122  typename _Traits::int_type __c = __sbin->sgetc();
123  while (!_Traits::eq_int_type(__c, _Traits::eof()))
124  {
125  __c = __sbout->sputc(_Traits::to_char_type(__c));
126  if (_Traits::eq_int_type(__c, _Traits::eof()))
127  {
128  __ineof = false;
129  break;
130  }
131  ++__ret;
132  __c = __sbin->snextc();
133  }
134  return __ret;
135  }
136 
137  template<typename _CharT, typename _Traits>
138  inline streamsize
139  __copy_streambufs(basic_streambuf<_CharT, _Traits>* __sbin,
140  basic_streambuf<_CharT, _Traits>* __sbout)
141  {
142  bool __ineof;
143  return __copy_streambufs_eof(__sbin, __sbout, __ineof);
144  }
145 
146  // Inhibit implicit instantiations for required instantiations,
147  // which are defined via explicit instantiations elsewhere.
148 #if _GLIBCXX_EXTERN_TEMPLATE
149  extern template class basic_streambuf<char>;
150  extern template
151  streamsize
152  __copy_streambufs(basic_streambuf<char>*,
153  basic_streambuf<char>*);
154  extern template
155  streamsize
156  __copy_streambufs_eof(basic_streambuf<char>*,
157  basic_streambuf<char>*, bool&);
158 
159 #ifdef _GLIBCXX_USE_WCHAR_T
160  extern template class basic_streambuf<wchar_t>;
161  extern template
162  streamsize
163  __copy_streambufs(basic_streambuf<wchar_t>*,
164  basic_streambuf<wchar_t>*);
165  extern template
166  streamsize
167  __copy_streambufs_eof(basic_streambuf<wchar_t>*,
168  basic_streambuf<wchar_t>*, bool&);
169 #endif
170 #endif
171 
172 _GLIBCXX_END_NAMESPACE_VERSION
173 } // namespace std
const _Tp & min(const _Tp &__a, const _Tp &__b)
Equivalent to std::min.
Definition: base.h:144