10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 10fe6060f1SDimitry Andric#ifndef _LIBCPP_STREAMBUF 11fe6060f1SDimitry Andric#define _LIBCPP_STREAMBUF 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric streambuf synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricnamespace std 170b57cec5SDimitry Andric{ 180b57cec5SDimitry Andric 190b57cec5SDimitry Andrictemplate <class charT, class traits = char_traits<charT> > 200b57cec5SDimitry Andricclass basic_streambuf 210b57cec5SDimitry Andric{ 220b57cec5SDimitry Andricpublic: 230b57cec5SDimitry Andric // types: 240b57cec5SDimitry Andric typedef charT char_type; 250b57cec5SDimitry Andric typedef traits traits_type; 260b57cec5SDimitry Andric typedef typename traits_type::int_type int_type; 270b57cec5SDimitry Andric typedef typename traits_type::pos_type pos_type; 280b57cec5SDimitry Andric typedef typename traits_type::off_type off_type; 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric virtual ~basic_streambuf(); 310b57cec5SDimitry Andric 320b57cec5SDimitry Andric // 27.6.2.2.1 locales: 330b57cec5SDimitry Andric locale pubimbue(const locale& loc); 340b57cec5SDimitry Andric locale getloc() const; 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric // 27.6.2.2.2 buffer and positioning: 370b57cec5SDimitry Andric basic_streambuf* pubsetbuf(char_type* s, streamsize n); 380b57cec5SDimitry Andric pos_type pubseekoff(off_type off, ios_base::seekdir way, 390b57cec5SDimitry Andric ios_base::openmode which = ios_base::in | ios_base::out); 400b57cec5SDimitry Andric pos_type pubseekpos(pos_type sp, 410b57cec5SDimitry Andric ios_base::openmode which = ios_base::in | ios_base::out); 420b57cec5SDimitry Andric int pubsync(); 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric // Get and put areas: 450b57cec5SDimitry Andric // 27.6.2.2.3 Get area: 460b57cec5SDimitry Andric streamsize in_avail(); 470b57cec5SDimitry Andric int_type snextc(); 480b57cec5SDimitry Andric int_type sbumpc(); 490b57cec5SDimitry Andric int_type sgetc(); 500b57cec5SDimitry Andric streamsize sgetn(char_type* s, streamsize n); 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric // 27.6.2.2.4 Putback: 530b57cec5SDimitry Andric int_type sputbackc(char_type c); 540b57cec5SDimitry Andric int_type sungetc(); 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric // 27.6.2.2.5 Put area: 570b57cec5SDimitry Andric int_type sputc(char_type c); 580b57cec5SDimitry Andric streamsize sputn(const char_type* s, streamsize n); 590b57cec5SDimitry Andric 600b57cec5SDimitry Andricprotected: 610b57cec5SDimitry Andric basic_streambuf(); 620b57cec5SDimitry Andric basic_streambuf(const basic_streambuf& rhs); 630b57cec5SDimitry Andric basic_streambuf& operator=(const basic_streambuf& rhs); 640b57cec5SDimitry Andric void swap(basic_streambuf& rhs); 650b57cec5SDimitry Andric 660b57cec5SDimitry Andric // 27.6.2.3.2 Get area: 670b57cec5SDimitry Andric char_type* eback() const; 680b57cec5SDimitry Andric char_type* gptr() const; 690b57cec5SDimitry Andric char_type* egptr() const; 700b57cec5SDimitry Andric void gbump(int n); 710b57cec5SDimitry Andric void setg(char_type* gbeg, char_type* gnext, char_type* gend); 720b57cec5SDimitry Andric 730b57cec5SDimitry Andric // 27.6.2.3.3 Put area: 740b57cec5SDimitry Andric char_type* pbase() const; 750b57cec5SDimitry Andric char_type* pptr() const; 760b57cec5SDimitry Andric char_type* epptr() const; 770b57cec5SDimitry Andric void pbump(int n); 780b57cec5SDimitry Andric void setp(char_type* pbeg, char_type* pend); 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric // 27.6.2.4 virtual functions: 810b57cec5SDimitry Andric // 27.6.2.4.1 Locales: 820b57cec5SDimitry Andric virtual void imbue(const locale& loc); 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric // 27.6.2.4.2 Buffer management and positioning: 850b57cec5SDimitry Andric virtual basic_streambuf* setbuf(char_type* s, streamsize n); 860b57cec5SDimitry Andric virtual pos_type seekoff(off_type off, ios_base::seekdir way, 870b57cec5SDimitry Andric ios_base::openmode which = ios_base::in | ios_base::out); 880b57cec5SDimitry Andric virtual pos_type seekpos(pos_type sp, 890b57cec5SDimitry Andric ios_base::openmode which = ios_base::in | ios_base::out); 900b57cec5SDimitry Andric virtual int sync(); 910b57cec5SDimitry Andric 920b57cec5SDimitry Andric // 27.6.2.4.3 Get area: 930b57cec5SDimitry Andric virtual streamsize showmanyc(); 940b57cec5SDimitry Andric virtual streamsize xsgetn(char_type* s, streamsize n); 950b57cec5SDimitry Andric virtual int_type underflow(); 960b57cec5SDimitry Andric virtual int_type uflow(); 970b57cec5SDimitry Andric 980b57cec5SDimitry Andric // 27.6.2.4.4 Putback: 990b57cec5SDimitry Andric virtual int_type pbackfail(int_type c = traits_type::eof()); 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andric // 27.6.2.4.5 Put area: 1020b57cec5SDimitry Andric virtual streamsize xsputn(const char_type* s, streamsize n); 1030b57cec5SDimitry Andric virtual int_type overflow (int_type c = traits_type::eof()); 1040b57cec5SDimitry Andric}; 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric} // std 1070b57cec5SDimitry Andric 1080b57cec5SDimitry Andric*/ 1090b57cec5SDimitry Andric 11081ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 1110b57cec5SDimitry Andric#include <__config> 112fe013be4SDimitry Andric#include <__fwd/streambuf.h> 113c9157d92SDimitry Andric#include <climits> 1140b57cec5SDimitry Andric#include <ios> 115fe6060f1SDimitry Andric#include <iosfwd> 11604eeddc0SDimitry Andric#include <version> 1170b57cec5SDimitry Andric 1180b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1190b57cec5SDimitry Andric# pragma GCC system_header 1200b57cec5SDimitry Andric#endif 1210b57cec5SDimitry Andric 1220b57cec5SDimitry Andric_LIBCPP_PUSH_MACROS 1230b57cec5SDimitry Andric#include <__undef_macros> 1240b57cec5SDimitry Andric 1250b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 128*e710425bSDimitry Andricclass _LIBCPP_TEMPLATE_VIS basic_streambuf { 1290b57cec5SDimitry Andricpublic: 1300b57cec5SDimitry Andric // types: 1310b57cec5SDimitry Andric typedef _CharT char_type; 1320b57cec5SDimitry Andric typedef _Traits traits_type; 1330b57cec5SDimitry Andric typedef typename traits_type::int_type int_type; 1340b57cec5SDimitry Andric typedef typename traits_type::pos_type pos_type; 1350b57cec5SDimitry Andric typedef typename traits_type::off_type off_type; 1360b57cec5SDimitry Andric 1370b57cec5SDimitry Andric static_assert((is_same<_CharT, typename traits_type::char_type>::value), 1380b57cec5SDimitry Andric "traits_type::char_type must be the same type as CharT"); 1390b57cec5SDimitry Andric 1400b57cec5SDimitry Andric virtual ~basic_streambuf(); 1410b57cec5SDimitry Andric 1420b57cec5SDimitry Andric // 27.6.2.2.1 locales: 143*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 locale pubimbue(const locale& __loc) { 1440b57cec5SDimitry Andric imbue(__loc); 1450b57cec5SDimitry Andric locale __r = __loc_; 1460b57cec5SDimitry Andric __loc_ = __loc; 1470b57cec5SDimitry Andric return __r; 1480b57cec5SDimitry Andric } 1490b57cec5SDimitry Andric 150*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 locale getloc() const { return __loc_; } 1510b57cec5SDimitry Andric 1520b57cec5SDimitry Andric // 27.6.2.2.2 buffer and positioning: 153*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 basic_streambuf* pubsetbuf(char_type* __s, streamsize __n) { 154*e710425bSDimitry Andric return setbuf(__s, __n); 155*e710425bSDimitry Andric } 1560b57cec5SDimitry Andric 157*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type 158*e710425bSDimitry Andric pubseekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out) { 159*e710425bSDimitry Andric return seekoff(__off, __way, __which); 160*e710425bSDimitry Andric } 1610b57cec5SDimitry Andric 162*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 pos_type 163*e710425bSDimitry Andric pubseekpos(pos_type __sp, ios_base::openmode __which = ios_base::in | ios_base::out) { 164*e710425bSDimitry Andric return seekpos(__sp, __which); 165*e710425bSDimitry Andric } 1660b57cec5SDimitry Andric 167*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int pubsync() { return sync(); } 1680b57cec5SDimitry Andric 1690b57cec5SDimitry Andric // Get and put areas: 1700b57cec5SDimitry Andric // 27.6.2.2.3 Get area: 171*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize in_avail() { 1720b57cec5SDimitry Andric if (__ninp_ < __einp_) 1730b57cec5SDimitry Andric return static_cast<streamsize>(__einp_ - __ninp_); 1740b57cec5SDimitry Andric return showmanyc(); 1750b57cec5SDimitry Andric } 1760b57cec5SDimitry Andric 177*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type snextc() { 1780b57cec5SDimitry Andric if (sbumpc() == traits_type::eof()) 1790b57cec5SDimitry Andric return traits_type::eof(); 1800b57cec5SDimitry Andric return sgetc(); 1810b57cec5SDimitry Andric } 1820b57cec5SDimitry Andric 183*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sbumpc() { 1840b57cec5SDimitry Andric if (__ninp_ == __einp_) 1850b57cec5SDimitry Andric return uflow(); 1860b57cec5SDimitry Andric return traits_type::to_int_type(*__ninp_++); 1870b57cec5SDimitry Andric } 1880b57cec5SDimitry Andric 189*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sgetc() { 1900b57cec5SDimitry Andric if (__ninp_ == __einp_) 1910b57cec5SDimitry Andric return underflow(); 1920b57cec5SDimitry Andric return traits_type::to_int_type(*__ninp_); 1930b57cec5SDimitry Andric } 1940b57cec5SDimitry Andric 195*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize sgetn(char_type* __s, streamsize __n) { return xsgetn(__s, __n); } 1960b57cec5SDimitry Andric 1970b57cec5SDimitry Andric // 27.6.2.2.4 Putback: 198*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputbackc(char_type __c) { 1990b57cec5SDimitry Andric if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1])) 2000b57cec5SDimitry Andric return pbackfail(traits_type::to_int_type(__c)); 2010b57cec5SDimitry Andric return traits_type::to_int_type(*--__ninp_); 2020b57cec5SDimitry Andric } 2030b57cec5SDimitry Andric 204*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sungetc() { 2050b57cec5SDimitry Andric if (__binp_ == __ninp_) 2060b57cec5SDimitry Andric return pbackfail(); 2070b57cec5SDimitry Andric return traits_type::to_int_type(*--__ninp_); 2080b57cec5SDimitry Andric } 2090b57cec5SDimitry Andric 2100b57cec5SDimitry Andric // 27.6.2.2.5 Put area: 211*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 int_type sputc(char_type __c) { 2120b57cec5SDimitry Andric if (__nout_ == __eout_) 2130b57cec5SDimitry Andric return overflow(traits_type::to_int_type(__c)); 2140b57cec5SDimitry Andric *__nout_++ = __c; 2150b57cec5SDimitry Andric return traits_type::to_int_type(__c); 2160b57cec5SDimitry Andric } 2170b57cec5SDimitry Andric 218*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 streamsize sputn(const char_type* __s, streamsize __n) { 219*e710425bSDimitry Andric return xsputn(__s, __n); 220*e710425bSDimitry Andric } 2210b57cec5SDimitry Andric 2220b57cec5SDimitry Andricprotected: 2230b57cec5SDimitry Andric basic_streambuf(); 2240b57cec5SDimitry Andric basic_streambuf(const basic_streambuf& __rhs); 2250b57cec5SDimitry Andric basic_streambuf& operator=(const basic_streambuf& __rhs); 2260b57cec5SDimitry Andric void swap(basic_streambuf& __rhs); 2270b57cec5SDimitry Andric 2280b57cec5SDimitry Andric // 27.6.2.3.2 Get area: 229c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type* eback() const { return __binp_; } 230c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type* gptr() const { return __ninp_; } 231c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type* egptr() const { return __einp_; } 2320b57cec5SDimitry Andric 233*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void gbump(int __n) { __ninp_ += __n; } 2340b57cec5SDimitry Andric 235*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) { 2360b57cec5SDimitry Andric __binp_ = __gbeg; 2370b57cec5SDimitry Andric __ninp_ = __gnext; 2380b57cec5SDimitry Andric __einp_ = __gend; 2390b57cec5SDimitry Andric } 2400b57cec5SDimitry Andric 2410b57cec5SDimitry Andric // 27.6.2.3.3 Put area: 242c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type* pbase() const { return __bout_; } 243c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type* pptr() const { return __nout_; } 244c9157d92SDimitry Andric _LIBCPP_HIDE_FROM_ABI char_type* epptr() const { return __eout_; } 2450b57cec5SDimitry Andric 246*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void pbump(int __n) { __nout_ += __n; } 2470b57cec5SDimitry Andric 248*e710425bSDimitry Andric _LIBCPP_HIDE_FROM_ABI void __pbump(streamsize __n) { __nout_ += __n; } 2490b57cec5SDimitry Andric 250*e710425bSDimitry Andric inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1 void setp(char_type* __pbeg, char_type* __pend) { 2510b57cec5SDimitry Andric __bout_ = __nout_ = __pbeg; 2520b57cec5SDimitry Andric __eout_ = __pend; 2530b57cec5SDimitry Andric } 2540b57cec5SDimitry Andric 2550b57cec5SDimitry Andric // 27.6.2.4 virtual functions: 2560b57cec5SDimitry Andric // 27.6.2.4.1 Locales: 2570b57cec5SDimitry Andric virtual void imbue(const locale& __loc); 2580b57cec5SDimitry Andric 2590b57cec5SDimitry Andric // 27.6.2.4.2 Buffer management and positioning: 2600b57cec5SDimitry Andric virtual basic_streambuf* setbuf(char_type* __s, streamsize __n); 261*e710425bSDimitry Andric virtual pos_type 262*e710425bSDimitry Andric seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out); 263*e710425bSDimitry Andric virtual pos_type seekpos(pos_type __sp, ios_base::openmode __which = ios_base::in | ios_base::out); 2640b57cec5SDimitry Andric virtual int sync(); 2650b57cec5SDimitry Andric 2660b57cec5SDimitry Andric // 27.6.2.4.3 Get area: 2670b57cec5SDimitry Andric virtual streamsize showmanyc(); 2680b57cec5SDimitry Andric virtual streamsize xsgetn(char_type* __s, streamsize __n); 2690b57cec5SDimitry Andric virtual int_type underflow(); 2700b57cec5SDimitry Andric virtual int_type uflow(); 2710b57cec5SDimitry Andric 2720b57cec5SDimitry Andric // 27.6.2.4.4 Putback: 2730b57cec5SDimitry Andric virtual int_type pbackfail(int_type __c = traits_type::eof()); 2740b57cec5SDimitry Andric 2750b57cec5SDimitry Andric // 27.6.2.4.5 Put area: 2760b57cec5SDimitry Andric virtual streamsize xsputn(const char_type* __s, streamsize __n); 2770b57cec5SDimitry Andric virtual int_type overflow(int_type __c = traits_type::eof()); 2780b57cec5SDimitry Andric 2790b57cec5SDimitry Andricprivate: 2800b57cec5SDimitry Andric locale __loc_; 2810b57cec5SDimitry Andric char_type* __binp_; 2820b57cec5SDimitry Andric char_type* __ninp_; 2830b57cec5SDimitry Andric char_type* __einp_; 2840b57cec5SDimitry Andric char_type* __bout_; 2850b57cec5SDimitry Andric char_type* __nout_; 2860b57cec5SDimitry Andric char_type* __eout_; 2870b57cec5SDimitry Andric}; 2880b57cec5SDimitry Andric 2890b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 290*e710425bSDimitry Andricbasic_streambuf<_CharT, _Traits>::~basic_streambuf() {} 2910b57cec5SDimitry Andric 2920b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 2930b57cec5SDimitry Andricbasic_streambuf<_CharT, _Traits>::basic_streambuf() 294*e710425bSDimitry Andric : __binp_(nullptr), __ninp_(nullptr), __einp_(nullptr), __bout_(nullptr), __nout_(nullptr), __eout_(nullptr) {} 2950b57cec5SDimitry Andric 2960b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 2970b57cec5SDimitry Andricbasic_streambuf<_CharT, _Traits>::basic_streambuf(const basic_streambuf& __sb) 2980b57cec5SDimitry Andric : __loc_(__sb.__loc_), 2990b57cec5SDimitry Andric __binp_(__sb.__binp_), 3000b57cec5SDimitry Andric __ninp_(__sb.__ninp_), 3010b57cec5SDimitry Andric __einp_(__sb.__einp_), 3020b57cec5SDimitry Andric __bout_(__sb.__bout_), 3030b57cec5SDimitry Andric __nout_(__sb.__nout_), 304*e710425bSDimitry Andric __eout_(__sb.__eout_) {} 3050b57cec5SDimitry Andric 3060b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 307*e710425bSDimitry Andricbasic_streambuf<_CharT, _Traits>& basic_streambuf<_CharT, _Traits>::operator=(const basic_streambuf& __sb) { 3080b57cec5SDimitry Andric __loc_ = __sb.__loc_; 3090b57cec5SDimitry Andric __binp_ = __sb.__binp_; 3100b57cec5SDimitry Andric __ninp_ = __sb.__ninp_; 3110b57cec5SDimitry Andric __einp_ = __sb.__einp_; 3120b57cec5SDimitry Andric __bout_ = __sb.__bout_; 3130b57cec5SDimitry Andric __nout_ = __sb.__nout_; 3140b57cec5SDimitry Andric __eout_ = __sb.__eout_; 3150b57cec5SDimitry Andric return *this; 3160b57cec5SDimitry Andric} 3170b57cec5SDimitry Andric 3180b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 319*e710425bSDimitry Andricvoid basic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb) { 320c9157d92SDimitry Andric std::swap(__loc_, __sb.__loc_); 321c9157d92SDimitry Andric std::swap(__binp_, __sb.__binp_); 322c9157d92SDimitry Andric std::swap(__ninp_, __sb.__ninp_); 323c9157d92SDimitry Andric std::swap(__einp_, __sb.__einp_); 324c9157d92SDimitry Andric std::swap(__bout_, __sb.__bout_); 325c9157d92SDimitry Andric std::swap(__nout_, __sb.__nout_); 326c9157d92SDimitry Andric std::swap(__eout_, __sb.__eout_); 3270b57cec5SDimitry Andric} 3280b57cec5SDimitry Andric 3290b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 330*e710425bSDimitry Andricvoid basic_streambuf<_CharT, _Traits>::imbue(const locale&) {} 3310b57cec5SDimitry Andric 3320b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 333*e710425bSDimitry Andricbasic_streambuf<_CharT, _Traits>* basic_streambuf<_CharT, _Traits>::setbuf(char_type*, streamsize) { 3340b57cec5SDimitry Andric return this; 3350b57cec5SDimitry Andric} 3360b57cec5SDimitry Andric 3370b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 3380b57cec5SDimitry Andrictypename basic_streambuf<_CharT, _Traits>::pos_type 339*e710425bSDimitry Andricbasic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir, ios_base::openmode) { 3400b57cec5SDimitry Andric return pos_type(off_type(-1)); 3410b57cec5SDimitry Andric} 3420b57cec5SDimitry Andric 3430b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 3440b57cec5SDimitry Andrictypename basic_streambuf<_CharT, _Traits>::pos_type 345*e710425bSDimitry Andricbasic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode) { 3460b57cec5SDimitry Andric return pos_type(off_type(-1)); 3470b57cec5SDimitry Andric} 3480b57cec5SDimitry Andric 3490b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 350*e710425bSDimitry Andricint basic_streambuf<_CharT, _Traits>::sync() { 3510b57cec5SDimitry Andric return 0; 3520b57cec5SDimitry Andric} 3530b57cec5SDimitry Andric 3540b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 355*e710425bSDimitry Andricstreamsize basic_streambuf<_CharT, _Traits>::showmanyc() { 3560b57cec5SDimitry Andric return 0; 3570b57cec5SDimitry Andric} 3580b57cec5SDimitry Andric 3590b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 360*e710425bSDimitry Andricstreamsize basic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n) { 3610b57cec5SDimitry Andric const int_type __eof = traits_type::eof(); 3620b57cec5SDimitry Andric int_type __c; 3630b57cec5SDimitry Andric streamsize __i = 0; 364*e710425bSDimitry Andric while (__i < __n) { 365*e710425bSDimitry Andric if (__ninp_ < __einp_) { 366*e710425bSDimitry Andric const streamsize __len = std::min(static_cast<streamsize>(INT_MAX), std::min(__einp_ - __ninp_, __n - __i)); 3670b57cec5SDimitry Andric traits_type::copy(__s, __ninp_, __len); 3680b57cec5SDimitry Andric __s += __len; 3690b57cec5SDimitry Andric __i += __len; 3700b57cec5SDimitry Andric this->gbump(__len); 371*e710425bSDimitry Andric } else if ((__c = uflow()) != __eof) { 3720b57cec5SDimitry Andric *__s = traits_type::to_char_type(__c); 3730b57cec5SDimitry Andric ++__s; 3740b57cec5SDimitry Andric ++__i; 375*e710425bSDimitry Andric } else 3760b57cec5SDimitry Andric break; 3770b57cec5SDimitry Andric } 3780b57cec5SDimitry Andric return __i; 3790b57cec5SDimitry Andric} 3800b57cec5SDimitry Andric 3810b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 382*e710425bSDimitry Andrictypename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::underflow() { 3830b57cec5SDimitry Andric return traits_type::eof(); 3840b57cec5SDimitry Andric} 3850b57cec5SDimitry Andric 3860b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 387*e710425bSDimitry Andrictypename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::uflow() { 3880b57cec5SDimitry Andric if (underflow() == traits_type::eof()) 3890b57cec5SDimitry Andric return traits_type::eof(); 3900b57cec5SDimitry Andric return traits_type::to_int_type(*__ninp_++); 3910b57cec5SDimitry Andric} 3920b57cec5SDimitry Andric 3930b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 394*e710425bSDimitry Andrictypename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::pbackfail(int_type) { 3950b57cec5SDimitry Andric return traits_type::eof(); 3960b57cec5SDimitry Andric} 3970b57cec5SDimitry Andric 3980b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 399*e710425bSDimitry Andricstreamsize basic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n) { 4000b57cec5SDimitry Andric streamsize __i = 0; 4010b57cec5SDimitry Andric int_type __eof = traits_type::eof(); 402*e710425bSDimitry Andric while (__i < __n) { 403*e710425bSDimitry Andric if (__nout_ >= __eout_) { 4040b57cec5SDimitry Andric if (overflow(traits_type::to_int_type(*__s)) == __eof) 4050b57cec5SDimitry Andric break; 4060b57cec5SDimitry Andric ++__s; 4070b57cec5SDimitry Andric ++__i; 408*e710425bSDimitry Andric } else { 409c9157d92SDimitry Andric streamsize __chunk_size = std::min(__eout_ - __nout_, __n - __i); 4100b57cec5SDimitry Andric traits_type::copy(__nout_, __s, __chunk_size); 4110b57cec5SDimitry Andric __nout_ += __chunk_size; 4120b57cec5SDimitry Andric __s += __chunk_size; 4130b57cec5SDimitry Andric __i += __chunk_size; 4140b57cec5SDimitry Andric } 4150b57cec5SDimitry Andric } 4160b57cec5SDimitry Andric return __i; 4170b57cec5SDimitry Andric} 4180b57cec5SDimitry Andric 4190b57cec5SDimitry Andrictemplate <class _CharT, class _Traits> 420*e710425bSDimitry Andrictypename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::overflow(int_type) { 4210b57cec5SDimitry Andric return traits_type::eof(); 4220b57cec5SDimitry Andric} 4230b57cec5SDimitry Andric 42481ad6265SDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>; 425bdd1243dSDimitry Andric 426bdd1243dSDimitry Andric#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS 427bdd1243dSDimitry Andricextern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>; 428bdd1243dSDimitry Andric#endif 4290b57cec5SDimitry Andric 4300b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 4310b57cec5SDimitry Andric 4320b57cec5SDimitry Andric_LIBCPP_POP_MACROS 4330b57cec5SDimitry Andric 434c9157d92SDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 435c9157d92SDimitry Andric# include <cstdint> 436c9157d92SDimitry Andric#endif 437c9157d92SDimitry Andric 438fe6060f1SDimitry Andric#endif // _LIBCPP_STREAMBUF 439