17a984708SDavid Chisnall// -*- C++ -*- 27a984708SDavid Chisnall//===------------------------- streambuf ----------------------------------===// 37a984708SDavid Chisnall// 47a984708SDavid Chisnall// The LLVM Compiler Infrastructure 57a984708SDavid Chisnall// 67a984708SDavid Chisnall// This file is dual licensed under the MIT and the University of Illinois Open 77a984708SDavid Chisnall// Source Licenses. See LICENSE.TXT for details. 87a984708SDavid Chisnall// 97a984708SDavid Chisnall//===----------------------------------------------------------------------===// 107a984708SDavid Chisnall 117a984708SDavid Chisnall#ifndef _LIBCPP_STEAMBUF 127a984708SDavid Chisnall#define _LIBCPP_STEAMBUF 137a984708SDavid Chisnall 147a984708SDavid Chisnall/* 157a984708SDavid Chisnall streambuf synopsis 167a984708SDavid Chisnall 177a984708SDavid Chisnallnamespace std 187a984708SDavid Chisnall{ 197a984708SDavid Chisnall 207a984708SDavid Chisnalltemplate <class charT, class traits = char_traits<charT> > 217a984708SDavid Chisnallclass basic_streambuf 227a984708SDavid Chisnall{ 237a984708SDavid Chisnallpublic: 247a984708SDavid Chisnall // types: 257a984708SDavid Chisnall typedef charT char_type; 267a984708SDavid Chisnall typedef traits traits_type; 277a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 287a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 297a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 307a984708SDavid Chisnall 317a984708SDavid Chisnall virtual ~basic_streambuf(); 327a984708SDavid Chisnall 337a984708SDavid Chisnall // 27.6.2.2.1 locales: 347a984708SDavid Chisnall locale pubimbue(const locale& loc); 357a984708SDavid Chisnall locale getloc() const; 367a984708SDavid Chisnall 377a984708SDavid Chisnall // 27.6.2.2.2 buffer and positioning: 387a984708SDavid Chisnall basic_streambuf* pubsetbuf(char_type* s, streamsize n); 397a984708SDavid Chisnall pos_type pubseekoff(off_type off, ios_base::seekdir way, 407a984708SDavid Chisnall ios_base::openmode which = ios_base::in | ios_base::out); 417a984708SDavid Chisnall pos_type pubseekpos(pos_type sp, 427a984708SDavid Chisnall ios_base::openmode which = ios_base::in | ios_base::out); 437a984708SDavid Chisnall int pubsync(); 447a984708SDavid Chisnall 457a984708SDavid Chisnall // Get and put areas: 467a984708SDavid Chisnall // 27.6.2.2.3 Get area: 477a984708SDavid Chisnall streamsize in_avail(); 487a984708SDavid Chisnall int_type snextc(); 497a984708SDavid Chisnall int_type sbumpc(); 507a984708SDavid Chisnall int_type sgetc(); 517a984708SDavid Chisnall streamsize sgetn(char_type* s, streamsize n); 527a984708SDavid Chisnall 537a984708SDavid Chisnall // 27.6.2.2.4 Putback: 547a984708SDavid Chisnall int_type sputbackc(char_type c); 557a984708SDavid Chisnall int_type sungetc(); 567a984708SDavid Chisnall 577a984708SDavid Chisnall // 27.6.2.2.5 Put area: 587a984708SDavid Chisnall int_type sputc(char_type c); 597a984708SDavid Chisnall streamsize sputn(const char_type* s, streamsize n); 607a984708SDavid Chisnall 617a984708SDavid Chisnallprotected: 627a984708SDavid Chisnall basic_streambuf(); 637a984708SDavid Chisnall basic_streambuf(const basic_streambuf& rhs); 647a984708SDavid Chisnall basic_streambuf& operator=(const basic_streambuf& rhs); 657a984708SDavid Chisnall void swap(basic_streambuf& rhs); 667a984708SDavid Chisnall 677a984708SDavid Chisnall // 27.6.2.3.2 Get area: 687a984708SDavid Chisnall char_type* eback() const; 697a984708SDavid Chisnall char_type* gptr() const; 707a984708SDavid Chisnall char_type* egptr() const; 717a984708SDavid Chisnall void gbump(int n); 727a984708SDavid Chisnall void setg(char_type* gbeg, char_type* gnext, char_type* gend); 737a984708SDavid Chisnall 747a984708SDavid Chisnall // 27.6.2.3.3 Put area: 757a984708SDavid Chisnall char_type* pbase() const; 767a984708SDavid Chisnall char_type* pptr() const; 777a984708SDavid Chisnall char_type* epptr() const; 787a984708SDavid Chisnall void pbump(int n); 797a984708SDavid Chisnall void setp(char_type* pbeg, char_type* pend); 807a984708SDavid Chisnall 817a984708SDavid Chisnall // 27.6.2.4 virtual functions: 827a984708SDavid Chisnall // 27.6.2.4.1 Locales: 837a984708SDavid Chisnall virtual void imbue(const locale& loc); 847a984708SDavid Chisnall 857a984708SDavid Chisnall // 27.6.2.4.2 Buffer management and positioning: 867a984708SDavid Chisnall virtual basic_streambuf* setbuf(char_type* s, streamsize n); 877a984708SDavid Chisnall virtual pos_type seekoff(off_type off, ios_base::seekdir way, 887a984708SDavid Chisnall ios_base::openmode which = ios_base::in | ios_base::out); 897a984708SDavid Chisnall virtual pos_type seekpos(pos_type sp, 907a984708SDavid Chisnall ios_base::openmode which = ios_base::in | ios_base::out); 917a984708SDavid Chisnall virtual int sync(); 927a984708SDavid Chisnall 937a984708SDavid Chisnall // 27.6.2.4.3 Get area: 947a984708SDavid Chisnall virtual streamsize showmanyc(); 957a984708SDavid Chisnall virtual streamsize xsgetn(char_type* s, streamsize n); 967a984708SDavid Chisnall virtual int_type underflow(); 977a984708SDavid Chisnall virtual int_type uflow(); 987a984708SDavid Chisnall 997a984708SDavid Chisnall // 27.6.2.4.4 Putback: 1007a984708SDavid Chisnall virtual int_type pbackfail(int_type c = traits_type::eof()); 1017a984708SDavid Chisnall 1027a984708SDavid Chisnall // 27.6.2.4.5 Put area: 1037a984708SDavid Chisnall virtual streamsize xsputn(const char_type* s, streamsize n); 1047a984708SDavid Chisnall virtual int_type overflow (int_type c = traits_type::eof()); 1057a984708SDavid Chisnall}; 1067a984708SDavid Chisnall 1077a984708SDavid Chisnall} // std 1087a984708SDavid Chisnall 1097a984708SDavid Chisnall*/ 1107a984708SDavid Chisnall 1117a984708SDavid Chisnall#include <__config> 1127a984708SDavid Chisnall#include <iosfwd> 1137a984708SDavid Chisnall#include <ios> 1147a984708SDavid Chisnall 1157a984708SDavid Chisnall#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1167a984708SDavid Chisnall#pragma GCC system_header 1177a984708SDavid Chisnall#endif 1187a984708SDavid Chisnall 119f9448bf3SDimitry Andric_LIBCPP_PUSH_MACROS 120f9448bf3SDimitry Andric#include <__undef_macros> 121f9448bf3SDimitry Andric 1227a984708SDavid Chisnall_LIBCPP_BEGIN_NAMESPACE_STD 1237a984708SDavid Chisnall 1247a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 125aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS basic_streambuf 1267a984708SDavid Chisnall{ 1277a984708SDavid Chisnallpublic: 1287a984708SDavid Chisnall // types: 1297a984708SDavid Chisnall typedef _CharT char_type; 1307a984708SDavid Chisnall typedef _Traits traits_type; 1317a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 1327a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 1337a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 1347a984708SDavid Chisnall 1354ba319b5SDimitry Andric static_assert((is_same<_CharT, typename traits_type::char_type>::value), 1364ba319b5SDimitry Andric "traits_type::char_type must be the same type as CharT"); 1374ba319b5SDimitry Andric 1387a984708SDavid Chisnall virtual ~basic_streambuf(); 1397a984708SDavid Chisnall 1407a984708SDavid Chisnall // 27.6.2.2.1 locales: 141*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 142aed8d94eSDimitry Andric locale pubimbue(const locale& __loc) { 143aed8d94eSDimitry Andric imbue(__loc); 144aed8d94eSDimitry Andric locale __r = __loc_; 145aed8d94eSDimitry Andric __loc_ = __loc; 146aed8d94eSDimitry Andric return __r; 147aed8d94eSDimitry Andric } 148aed8d94eSDimitry Andric 149*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 150aed8d94eSDimitry Andric locale getloc() const { return __loc_; } 1517a984708SDavid Chisnall 1527a984708SDavid Chisnall // 27.6.2.2.2 buffer and positioning: 153*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 154aed8d94eSDimitry Andric basic_streambuf* pubsetbuf(char_type* __s, streamsize __n) 155aed8d94eSDimitry Andric { return setbuf(__s, __n); } 156aed8d94eSDimitry Andric 157*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 1587a984708SDavid Chisnall pos_type pubseekoff(off_type __off, ios_base::seekdir __way, 159aed8d94eSDimitry Andric ios_base::openmode __which = ios_base::in | ios_base::out) 160aed8d94eSDimitry Andric { return seekoff(__off, __way, __which); } 161aed8d94eSDimitry Andric 162*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 1637a984708SDavid Chisnall pos_type pubseekpos(pos_type __sp, 164aed8d94eSDimitry Andric ios_base::openmode __which = ios_base::in | ios_base::out) 165aed8d94eSDimitry Andric { return seekpos(__sp, __which); } 166aed8d94eSDimitry Andric 167*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 168aed8d94eSDimitry Andric int pubsync() { return sync(); } 1697a984708SDavid Chisnall 1707a984708SDavid Chisnall // Get and put areas: 1717a984708SDavid Chisnall // 27.6.2.2.3 Get area: 172*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 173aed8d94eSDimitry Andric streamsize in_avail() { 174aed8d94eSDimitry Andric if (__ninp_ < __einp_) 175aed8d94eSDimitry Andric return static_cast<streamsize>(__einp_ - __ninp_); 176aed8d94eSDimitry Andric return showmanyc(); 177aed8d94eSDimitry Andric } 178aed8d94eSDimitry Andric 179*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 180aed8d94eSDimitry Andric int_type snextc() { 181aed8d94eSDimitry Andric if (sbumpc() == traits_type::eof()) 182aed8d94eSDimitry Andric return traits_type::eof(); 183aed8d94eSDimitry Andric return sgetc(); 184aed8d94eSDimitry Andric } 185aed8d94eSDimitry Andric 186*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 187aed8d94eSDimitry Andric int_type sbumpc() { 188aed8d94eSDimitry Andric if (__ninp_ == __einp_) 189aed8d94eSDimitry Andric return uflow(); 190aed8d94eSDimitry Andric return traits_type::to_int_type(*__ninp_++); 191aed8d94eSDimitry Andric } 192aed8d94eSDimitry Andric 193*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 194aed8d94eSDimitry Andric int_type sgetc() { 195aed8d94eSDimitry Andric if (__ninp_ == __einp_) 196aed8d94eSDimitry Andric return underflow(); 197aed8d94eSDimitry Andric return traits_type::to_int_type(*__ninp_); 198aed8d94eSDimitry Andric } 199aed8d94eSDimitry Andric 200*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 201aed8d94eSDimitry Andric streamsize sgetn(char_type* __s, streamsize __n) 202aed8d94eSDimitry Andric { return xsgetn(__s, __n); } 2037a984708SDavid Chisnall 2047a984708SDavid Chisnall // 27.6.2.2.4 Putback: 205*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 206aed8d94eSDimitry Andric int_type sputbackc(char_type __c) { 207aed8d94eSDimitry Andric if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1])) 208aed8d94eSDimitry Andric return pbackfail(traits_type::to_int_type(__c)); 209aed8d94eSDimitry Andric return traits_type::to_int_type(*--__ninp_); 210aed8d94eSDimitry Andric } 211aed8d94eSDimitry Andric 212*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 213aed8d94eSDimitry Andric int_type sungetc() { 214aed8d94eSDimitry Andric if (__binp_ == __ninp_) 215aed8d94eSDimitry Andric return pbackfail(); 216aed8d94eSDimitry Andric return traits_type::to_int_type(*--__ninp_); 217aed8d94eSDimitry Andric } 2187a984708SDavid Chisnall 2197a984708SDavid Chisnall // 27.6.2.2.5 Put area: 220*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 221aed8d94eSDimitry Andric int_type sputc(char_type __c) { 222aed8d94eSDimitry Andric if (__nout_ == __eout_) 223aed8d94eSDimitry Andric return overflow(traits_type::to_int_type(__c)); 224aed8d94eSDimitry Andric *__nout_++ = __c; 225aed8d94eSDimitry Andric return traits_type::to_int_type(__c); 226aed8d94eSDimitry Andric } 227aed8d94eSDimitry Andric 228*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 229aed8d94eSDimitry Andric streamsize sputn(const char_type* __s, streamsize __n) 230aed8d94eSDimitry Andric { return xsputn(__s, __n); } 2317a984708SDavid Chisnall 2327a984708SDavid Chisnallprotected: 2337a984708SDavid Chisnall basic_streambuf(); 2347a984708SDavid Chisnall basic_streambuf(const basic_streambuf& __rhs); 2357a984708SDavid Chisnall basic_streambuf& operator=(const basic_streambuf& __rhs); 2367a984708SDavid Chisnall void swap(basic_streambuf& __rhs); 2377a984708SDavid Chisnall 2387a984708SDavid Chisnall // 27.6.2.3.2 Get area: 2394ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type* eback() const {return __binp_;} 2404ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type* gptr() const {return __ninp_;} 2414ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type* egptr() const {return __einp_;} 242aed8d94eSDimitry Andric 243*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 244aed8d94eSDimitry Andric void gbump(int __n) { __ninp_ += __n; } 245aed8d94eSDimitry Andric 246*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 247aed8d94eSDimitry Andric void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { 248aed8d94eSDimitry Andric __binp_ = __gbeg; 249aed8d94eSDimitry Andric __ninp_ = __gnext; 250aed8d94eSDimitry Andric __einp_ = __gend; 251aed8d94eSDimitry Andric } 2527a984708SDavid Chisnall 2537a984708SDavid Chisnall // 27.6.2.3.3 Put area: 2544ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type* pbase() const {return __bout_;} 2554ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type* pptr() const {return __nout_;} 2564ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY char_type* epptr() const {return __eout_;} 257aed8d94eSDimitry Andric 258*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 259aed8d94eSDimitry Andric void pbump(int __n) { __nout_ += __n; } 260aed8d94eSDimitry Andric 2614ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 262b2c7081bSDimitry Andric void __pbump(streamsize __n) { __nout_ += __n; } 263b2c7081bSDimitry Andric 264*b5893f02SDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 265aed8d94eSDimitry Andric void setp(char_type* __pbeg, char_type* __pend) { 266aed8d94eSDimitry Andric __bout_ = __nout_ = __pbeg; 267aed8d94eSDimitry Andric __eout_ = __pend; 268aed8d94eSDimitry Andric } 2697a984708SDavid Chisnall 2707a984708SDavid Chisnall // 27.6.2.4 virtual functions: 2717a984708SDavid Chisnall // 27.6.2.4.1 Locales: 2727a984708SDavid Chisnall virtual void imbue(const locale& __loc); 2737a984708SDavid Chisnall 2747a984708SDavid Chisnall // 27.6.2.4.2 Buffer management and positioning: 2757a984708SDavid Chisnall virtual basic_streambuf* setbuf(char_type* __s, streamsize __n); 2767a984708SDavid Chisnall virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, 2777a984708SDavid Chisnall ios_base::openmode __which = ios_base::in | ios_base::out); 2787a984708SDavid Chisnall virtual pos_type seekpos(pos_type __sp, 2797a984708SDavid Chisnall ios_base::openmode __which = ios_base::in | ios_base::out); 2807a984708SDavid Chisnall virtual int sync(); 2817a984708SDavid Chisnall 2827a984708SDavid Chisnall // 27.6.2.4.3 Get area: 2837a984708SDavid Chisnall virtual streamsize showmanyc(); 2847a984708SDavid Chisnall virtual streamsize xsgetn(char_type* __s, streamsize __n); 2857a984708SDavid Chisnall virtual int_type underflow(); 2867a984708SDavid Chisnall virtual int_type uflow(); 2877a984708SDavid Chisnall 2887a984708SDavid Chisnall // 27.6.2.4.4 Putback: 2897a984708SDavid Chisnall virtual int_type pbackfail(int_type __c = traits_type::eof()); 2907a984708SDavid Chisnall 2917a984708SDavid Chisnall // 27.6.2.4.5 Put area: 2927a984708SDavid Chisnall virtual streamsize xsputn(const char_type* __s, streamsize __n); 2937a984708SDavid Chisnall virtual int_type overflow(int_type __c = traits_type::eof()); 2947a984708SDavid Chisnall 2957a984708SDavid Chisnallprivate: 2967a984708SDavid Chisnall locale __loc_; 2977a984708SDavid Chisnall char_type* __binp_; 2987a984708SDavid Chisnall char_type* __ninp_; 2997a984708SDavid Chisnall char_type* __einp_; 3007a984708SDavid Chisnall char_type* __bout_; 3017a984708SDavid Chisnall char_type* __nout_; 3027a984708SDavid Chisnall char_type* __eout_; 3037a984708SDavid Chisnall}; 3047a984708SDavid Chisnall 3057a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3067a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::~basic_streambuf() 3077a984708SDavid Chisnall{ 3087a984708SDavid Chisnall} 3097a984708SDavid Chisnall 3107a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3117a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::basic_streambuf() 3127a984708SDavid Chisnall : __binp_(0), 3137a984708SDavid Chisnall __ninp_(0), 3147a984708SDavid Chisnall __einp_(0), 3157a984708SDavid Chisnall __bout_(0), 3167a984708SDavid Chisnall __nout_(0), 3177a984708SDavid Chisnall __eout_(0) 3187a984708SDavid Chisnall{ 3197a984708SDavid Chisnall} 3207a984708SDavid Chisnall 3217a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3227a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::basic_streambuf(const basic_streambuf& __sb) 3237a984708SDavid Chisnall : __loc_(__sb.__loc_), 3247a984708SDavid Chisnall __binp_(__sb.__binp_), 3257a984708SDavid Chisnall __ninp_(__sb.__ninp_), 3267a984708SDavid Chisnall __einp_(__sb.__einp_), 3277a984708SDavid Chisnall __bout_(__sb.__bout_), 3287a984708SDavid Chisnall __nout_(__sb.__nout_), 3297a984708SDavid Chisnall __eout_(__sb.__eout_) 3307a984708SDavid Chisnall{ 3317a984708SDavid Chisnall} 3327a984708SDavid Chisnall 3337a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3347a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>& 3357a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::operator=(const basic_streambuf& __sb) 3367a984708SDavid Chisnall{ 3377a984708SDavid Chisnall __loc_ = __sb.__loc_; 3387a984708SDavid Chisnall __binp_ = __sb.__binp_; 3397a984708SDavid Chisnall __ninp_ = __sb.__ninp_; 3407a984708SDavid Chisnall __einp_ = __sb.__einp_; 3417a984708SDavid Chisnall __bout_ = __sb.__bout_; 3427a984708SDavid Chisnall __nout_ = __sb.__nout_; 3437a984708SDavid Chisnall __eout_ = __sb.__eout_; 3447a984708SDavid Chisnall return *this; 3457a984708SDavid Chisnall} 3467a984708SDavid Chisnall 3477a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3487a984708SDavid Chisnallvoid 3497a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb) 3507a984708SDavid Chisnall{ 3517a984708SDavid Chisnall _VSTD::swap(__loc_, __sb.__loc_); 3527a984708SDavid Chisnall _VSTD::swap(__binp_, __sb.__binp_); 3537a984708SDavid Chisnall _VSTD::swap(__ninp_, __sb.__ninp_); 3547a984708SDavid Chisnall _VSTD::swap(__einp_, __sb.__einp_); 3557a984708SDavid Chisnall _VSTD::swap(__bout_, __sb.__bout_); 3567a984708SDavid Chisnall _VSTD::swap(__nout_, __sb.__nout_); 3577a984708SDavid Chisnall _VSTD::swap(__eout_, __sb.__eout_); 3587a984708SDavid Chisnall} 3597a984708SDavid Chisnall 3607a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3617a984708SDavid Chisnallvoid 3627a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::imbue(const locale&) 3637a984708SDavid Chisnall{ 3647a984708SDavid Chisnall} 3657a984708SDavid Chisnall 3667a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3677a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>* 3687a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::setbuf(char_type*, streamsize) 3697a984708SDavid Chisnall{ 3707a984708SDavid Chisnall return this; 3717a984708SDavid Chisnall} 3727a984708SDavid Chisnall 3737a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3747a984708SDavid Chisnalltypename basic_streambuf<_CharT, _Traits>::pos_type 37594e3ee44SDavid Chisnallbasic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir, 37694e3ee44SDavid Chisnall ios_base::openmode) 3777a984708SDavid Chisnall{ 3787a984708SDavid Chisnall return pos_type(off_type(-1)); 3797a984708SDavid Chisnall} 3807a984708SDavid Chisnall 3817a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3827a984708SDavid Chisnalltypename basic_streambuf<_CharT, _Traits>::pos_type 38394e3ee44SDavid Chisnallbasic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode) 3847a984708SDavid Chisnall{ 3857a984708SDavid Chisnall return pos_type(off_type(-1)); 3867a984708SDavid Chisnall} 3877a984708SDavid Chisnall 3887a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3897a984708SDavid Chisnallint 3907a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::sync() 3917a984708SDavid Chisnall{ 3927a984708SDavid Chisnall return 0; 3937a984708SDavid Chisnall} 3947a984708SDavid Chisnall 3957a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 3967a984708SDavid Chisnallstreamsize 3977a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::showmanyc() 3987a984708SDavid Chisnall{ 3997a984708SDavid Chisnall return 0; 4007a984708SDavid Chisnall} 4017a984708SDavid Chisnall 4027a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 4037a984708SDavid Chisnallstreamsize 4047a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n) 4057a984708SDavid Chisnall{ 4067a984708SDavid Chisnall const int_type __eof = traits_type::eof(); 4077a984708SDavid Chisnall int_type __c; 4087a984708SDavid Chisnall streamsize __i = 0; 4097c82a1ecSDimitry Andric while(__i < __n) 4107a984708SDavid Chisnall { 4117a984708SDavid Chisnall if (__ninp_ < __einp_) 4127c82a1ecSDimitry Andric { 413b2c7081bSDimitry Andric const streamsize __len = _VSTD::min(static_cast<streamsize>(INT_MAX), 414b2c7081bSDimitry Andric _VSTD::min(__einp_ - __ninp_, __n - __i)); 4157c82a1ecSDimitry Andric traits_type::copy(__s, __ninp_, __len); 4167c82a1ecSDimitry Andric __s += __len; 4177c82a1ecSDimitry Andric __i += __len; 4187c82a1ecSDimitry Andric this->gbump(__len); 4197c82a1ecSDimitry Andric } 4207a984708SDavid Chisnall else if ((__c = uflow()) != __eof) 4217c82a1ecSDimitry Andric { 4227a984708SDavid Chisnall *__s = traits_type::to_char_type(__c); 4237c82a1ecSDimitry Andric ++__s; 4247c82a1ecSDimitry Andric ++__i; 4257c82a1ecSDimitry Andric } 4267a984708SDavid Chisnall else 4277a984708SDavid Chisnall break; 4287a984708SDavid Chisnall } 4297a984708SDavid Chisnall return __i; 4307a984708SDavid Chisnall} 4317a984708SDavid Chisnall 4327a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 4337a984708SDavid Chisnalltypename basic_streambuf<_CharT, _Traits>::int_type 4347a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::underflow() 4357a984708SDavid Chisnall{ 4367a984708SDavid Chisnall return traits_type::eof(); 4377a984708SDavid Chisnall} 4387a984708SDavid Chisnall 4397a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 4407a984708SDavid Chisnalltypename basic_streambuf<_CharT, _Traits>::int_type 4417a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::uflow() 4427a984708SDavid Chisnall{ 4437a984708SDavid Chisnall if (underflow() == traits_type::eof()) 4447a984708SDavid Chisnall return traits_type::eof(); 4457a984708SDavid Chisnall return traits_type::to_int_type(*__ninp_++); 4467a984708SDavid Chisnall} 4477a984708SDavid Chisnall 4487a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 4497a984708SDavid Chisnalltypename basic_streambuf<_CharT, _Traits>::int_type 4507a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::pbackfail(int_type) 4517a984708SDavid Chisnall{ 4527a984708SDavid Chisnall return traits_type::eof(); 4537a984708SDavid Chisnall} 4547a984708SDavid Chisnall 4557a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 4567a984708SDavid Chisnallstreamsize 4577a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n) 4587a984708SDavid Chisnall{ 4597a984708SDavid Chisnall streamsize __i = 0; 4607a984708SDavid Chisnall int_type __eof = traits_type::eof(); 461854fa44bSDimitry Andric while( __i < __n) 4627a984708SDavid Chisnall { 463854fa44bSDimitry Andric if (__nout_ >= __eout_) 464854fa44bSDimitry Andric { 465854fa44bSDimitry Andric if (overflow(traits_type::to_int_type(*__s)) == __eof) 4667a984708SDavid Chisnall break; 467854fa44bSDimitry Andric ++__s; 468854fa44bSDimitry Andric ++__i; 469854fa44bSDimitry Andric } 470854fa44bSDimitry Andric else 471854fa44bSDimitry Andric { 472854fa44bSDimitry Andric streamsize __chunk_size = _VSTD::min(__eout_ - __nout_, __n - __i); 473854fa44bSDimitry Andric traits_type::copy(__nout_, __s, __chunk_size); 474854fa44bSDimitry Andric __nout_ += __chunk_size; 475854fa44bSDimitry Andric __s += __chunk_size; 476854fa44bSDimitry Andric __i += __chunk_size; 477854fa44bSDimitry Andric } 4787a984708SDavid Chisnall } 4797a984708SDavid Chisnall return __i; 4807a984708SDavid Chisnall} 4817a984708SDavid Chisnall 4827a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 4837a984708SDavid Chisnalltypename basic_streambuf<_CharT, _Traits>::int_type 48494e3ee44SDavid Chisnallbasic_streambuf<_CharT, _Traits>::overflow(int_type) 4857a984708SDavid Chisnall{ 4867a984708SDavid Chisnall return traits_type::eof(); 4877a984708SDavid Chisnall} 4887a984708SDavid Chisnall 489*b5893f02SDimitry Andric#ifndef _LIBCPP_DO_NOT_ASSUME_STREAMS_EXPLICIT_INSTANTIATION_IN_DYLIB 490aed8d94eSDimitry Andric_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>) 491aed8d94eSDimitry Andric_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>) 4927a984708SDavid Chisnall 493aed8d94eSDimitry Andric_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>) 494aed8d94eSDimitry Andric_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>) 4950f5676f4SDimitry Andric#endif 4967a984708SDavid Chisnall 4977a984708SDavid Chisnall_LIBCPP_END_NAMESPACE_STD 4987a984708SDavid Chisnall 499f9448bf3SDimitry Andric_LIBCPP_POP_MACROS 500f9448bf3SDimitry Andric 5017a984708SDavid Chisnall#endif // _LIBCPP_STEAMBUF 502