xref: /minix3/external/bsd/libc++/dist/libcxx/include/streambuf (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
14684ddb6SLionel Sambuc// -*- C++ -*-
24684ddb6SLionel Sambuc//===------------------------- streambuf ----------------------------------===//
34684ddb6SLionel Sambuc//
44684ddb6SLionel Sambuc//                     The LLVM Compiler Infrastructure
54684ddb6SLionel Sambuc//
64684ddb6SLionel Sambuc// This file is dual licensed under the MIT and the University of Illinois Open
74684ddb6SLionel Sambuc// Source Licenses. See LICENSE.TXT for details.
84684ddb6SLionel Sambuc//
94684ddb6SLionel Sambuc//===----------------------------------------------------------------------===//
104684ddb6SLionel Sambuc
114684ddb6SLionel Sambuc#ifndef _LIBCPP_STEAMBUF
124684ddb6SLionel Sambuc#define _LIBCPP_STEAMBUF
134684ddb6SLionel Sambuc
144684ddb6SLionel Sambuc/*
154684ddb6SLionel Sambuc    streambuf synopsis
164684ddb6SLionel Sambuc
174684ddb6SLionel Sambucnamespace std
184684ddb6SLionel Sambuc{
194684ddb6SLionel Sambuc
204684ddb6SLionel Sambuctemplate <class charT, class traits = char_traits<charT> >
214684ddb6SLionel Sambucclass basic_streambuf
224684ddb6SLionel Sambuc{
234684ddb6SLionel Sambucpublic:
244684ddb6SLionel Sambuc    // types:
254684ddb6SLionel Sambuc    typedef charT char_type;
264684ddb6SLionel Sambuc    typedef traits traits_type;
274684ddb6SLionel Sambuc    typedef typename traits_type::int_type int_type;
284684ddb6SLionel Sambuc    typedef typename traits_type::pos_type pos_type;
294684ddb6SLionel Sambuc    typedef typename traits_type::off_type off_type;
304684ddb6SLionel Sambuc
314684ddb6SLionel Sambuc    virtual ~basic_streambuf();
324684ddb6SLionel Sambuc
334684ddb6SLionel Sambuc    // 27.6.2.2.1 locales:
344684ddb6SLionel Sambuc    locale pubimbue(const locale& loc);
354684ddb6SLionel Sambuc    locale getloc() const;
364684ddb6SLionel Sambuc
374684ddb6SLionel Sambuc    // 27.6.2.2.2 buffer and positioning:
384684ddb6SLionel Sambuc    basic_streambuf* pubsetbuf(char_type* s, streamsize n);
394684ddb6SLionel Sambuc    pos_type pubseekoff(off_type off, ios_base::seekdir way,
404684ddb6SLionel Sambuc                        ios_base::openmode which = ios_base::in | ios_base::out);
414684ddb6SLionel Sambuc    pos_type pubseekpos(pos_type sp,
424684ddb6SLionel Sambuc                        ios_base::openmode which = ios_base::in | ios_base::out);
434684ddb6SLionel Sambuc    int pubsync();
444684ddb6SLionel Sambuc
454684ddb6SLionel Sambuc    // Get and put areas:
464684ddb6SLionel Sambuc    // 27.6.2.2.3 Get area:
474684ddb6SLionel Sambuc    streamsize in_avail();
484684ddb6SLionel Sambuc    int_type snextc();
494684ddb6SLionel Sambuc    int_type sbumpc();
504684ddb6SLionel Sambuc    int_type sgetc();
514684ddb6SLionel Sambuc    streamsize sgetn(char_type* s, streamsize n);
524684ddb6SLionel Sambuc
534684ddb6SLionel Sambuc    // 27.6.2.2.4 Putback:
544684ddb6SLionel Sambuc    int_type sputbackc(char_type c);
554684ddb6SLionel Sambuc    int_type sungetc();
564684ddb6SLionel Sambuc
574684ddb6SLionel Sambuc    // 27.6.2.2.5 Put area:
584684ddb6SLionel Sambuc    int_type sputc(char_type c);
594684ddb6SLionel Sambuc    streamsize sputn(const char_type* s, streamsize n);
604684ddb6SLionel Sambuc
614684ddb6SLionel Sambucprotected:
624684ddb6SLionel Sambuc    basic_streambuf();
634684ddb6SLionel Sambuc    basic_streambuf(const basic_streambuf& rhs);
644684ddb6SLionel Sambuc    basic_streambuf& operator=(const basic_streambuf& rhs);
654684ddb6SLionel Sambuc    void swap(basic_streambuf& rhs);
664684ddb6SLionel Sambuc
674684ddb6SLionel Sambuc    // 27.6.2.3.2 Get area:
684684ddb6SLionel Sambuc    char_type* eback() const;
694684ddb6SLionel Sambuc    char_type* gptr() const;
704684ddb6SLionel Sambuc    char_type* egptr() const;
714684ddb6SLionel Sambuc    void gbump(int n);
724684ddb6SLionel Sambuc    void setg(char_type* gbeg, char_type* gnext, char_type* gend);
734684ddb6SLionel Sambuc
744684ddb6SLionel Sambuc    // 27.6.2.3.3 Put area:
754684ddb6SLionel Sambuc    char_type* pbase() const;
764684ddb6SLionel Sambuc    char_type* pptr() const;
774684ddb6SLionel Sambuc    char_type* epptr() const;
784684ddb6SLionel Sambuc    void pbump(int n);
794684ddb6SLionel Sambuc    void setp(char_type* pbeg, char_type* pend);
804684ddb6SLionel Sambuc
814684ddb6SLionel Sambuc    // 27.6.2.4 virtual functions:
824684ddb6SLionel Sambuc    // 27.6.2.4.1 Locales:
834684ddb6SLionel Sambuc    virtual void imbue(const locale& loc);
844684ddb6SLionel Sambuc
854684ddb6SLionel Sambuc    // 27.6.2.4.2 Buffer management and positioning:
864684ddb6SLionel Sambuc    virtual basic_streambuf* setbuf(char_type* s, streamsize n);
874684ddb6SLionel Sambuc    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
884684ddb6SLionel Sambuc                             ios_base::openmode which = ios_base::in | ios_base::out);
894684ddb6SLionel Sambuc    virtual pos_type seekpos(pos_type sp,
904684ddb6SLionel Sambuc                             ios_base::openmode which = ios_base::in | ios_base::out);
914684ddb6SLionel Sambuc    virtual int sync();
924684ddb6SLionel Sambuc
934684ddb6SLionel Sambuc    // 27.6.2.4.3 Get area:
944684ddb6SLionel Sambuc    virtual streamsize showmanyc();
954684ddb6SLionel Sambuc    virtual streamsize xsgetn(char_type* s, streamsize n);
964684ddb6SLionel Sambuc    virtual int_type underflow();
974684ddb6SLionel Sambuc    virtual int_type uflow();
984684ddb6SLionel Sambuc
994684ddb6SLionel Sambuc    // 27.6.2.4.4 Putback:
1004684ddb6SLionel Sambuc    virtual int_type pbackfail(int_type c = traits_type::eof());
1014684ddb6SLionel Sambuc
1024684ddb6SLionel Sambuc    // 27.6.2.4.5 Put area:
1034684ddb6SLionel Sambuc    virtual streamsize xsputn(const char_type* s, streamsize n);
1044684ddb6SLionel Sambuc    virtual int_type overflow (int_type c = traits_type::eof());
1054684ddb6SLionel Sambuc};
1064684ddb6SLionel Sambuc
1074684ddb6SLionel Sambuc}  // std
1084684ddb6SLionel Sambuc
1094684ddb6SLionel Sambuc*/
1104684ddb6SLionel Sambuc
1114684ddb6SLionel Sambuc#include <__config>
1124684ddb6SLionel Sambuc#include <iosfwd>
1134684ddb6SLionel Sambuc#include <ios>
1144684ddb6SLionel Sambuc
1154684ddb6SLionel Sambuc#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1164684ddb6SLionel Sambuc#pragma GCC system_header
1174684ddb6SLionel Sambuc#endif
1184684ddb6SLionel Sambuc
1194684ddb6SLionel Sambuc_LIBCPP_BEGIN_NAMESPACE_STD
1204684ddb6SLionel Sambuc
1214684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
1224684ddb6SLionel Sambucclass _LIBCPP_TYPE_VIS_ONLY basic_streambuf
1234684ddb6SLionel Sambuc{
1244684ddb6SLionel Sambucpublic:
1254684ddb6SLionel Sambuc    // types:
1264684ddb6SLionel Sambuc    typedef _CharT                         char_type;
1274684ddb6SLionel Sambuc    typedef _Traits                        traits_type;
1284684ddb6SLionel Sambuc    typedef typename traits_type::int_type int_type;
1294684ddb6SLionel Sambuc    typedef typename traits_type::pos_type pos_type;
1304684ddb6SLionel Sambuc    typedef typename traits_type::off_type off_type;
1314684ddb6SLionel Sambuc
1324684ddb6SLionel Sambuc    virtual ~basic_streambuf();
1334684ddb6SLionel Sambuc
1344684ddb6SLionel Sambuc    // 27.6.2.2.1 locales:
1354684ddb6SLionel Sambuc    locale pubimbue(const locale& __loc);
1364684ddb6SLionel Sambuc    locale getloc() const;
1374684ddb6SLionel Sambuc
1384684ddb6SLionel Sambuc    // 27.6.2.2.2 buffer and positioning:
1394684ddb6SLionel Sambuc    basic_streambuf* pubsetbuf(char_type* __s, streamsize __n);
1404684ddb6SLionel Sambuc    pos_type pubseekoff(off_type __off, ios_base::seekdir __way,
1414684ddb6SLionel Sambuc                        ios_base::openmode __which = ios_base::in | ios_base::out);
1424684ddb6SLionel Sambuc    pos_type pubseekpos(pos_type __sp,
1434684ddb6SLionel Sambuc                        ios_base::openmode __which = ios_base::in | ios_base::out);
1444684ddb6SLionel Sambuc    int pubsync();
1454684ddb6SLionel Sambuc
1464684ddb6SLionel Sambuc    // Get and put areas:
1474684ddb6SLionel Sambuc    // 27.6.2.2.3 Get area:
1484684ddb6SLionel Sambuc    streamsize in_avail();
1494684ddb6SLionel Sambuc    int_type snextc();
1504684ddb6SLionel Sambuc    int_type sbumpc();
1514684ddb6SLionel Sambuc    int_type sgetc();
1524684ddb6SLionel Sambuc    streamsize sgetn(char_type* __s, streamsize __n);
1534684ddb6SLionel Sambuc
1544684ddb6SLionel Sambuc    // 27.6.2.2.4 Putback:
1554684ddb6SLionel Sambuc    int_type sputbackc(char_type __c);
1564684ddb6SLionel Sambuc    int_type sungetc();
1574684ddb6SLionel Sambuc
1584684ddb6SLionel Sambuc    // 27.6.2.2.5 Put area:
1594684ddb6SLionel Sambuc    int_type sputc(char_type __c);
1604684ddb6SLionel Sambuc    streamsize sputn(const char_type* __s, streamsize __n);
1614684ddb6SLionel Sambuc
1624684ddb6SLionel Sambucprotected:
1634684ddb6SLionel Sambuc    basic_streambuf();
1644684ddb6SLionel Sambuc    basic_streambuf(const basic_streambuf& __rhs);
1654684ddb6SLionel Sambuc    basic_streambuf& operator=(const basic_streambuf& __rhs);
1664684ddb6SLionel Sambuc    void swap(basic_streambuf& __rhs);
1674684ddb6SLionel Sambuc
1684684ddb6SLionel Sambuc    // 27.6.2.3.2 Get area:
1694684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE char_type* eback() const {return __binp_;}
1704684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE char_type* gptr()  const {return __ninp_;}
1714684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE char_type* egptr() const {return __einp_;}
1724684ddb6SLionel Sambuc    void gbump(int __n);
1734684ddb6SLionel Sambuc    void setg(char_type* __gbeg, char_type* __gnext, char_type* __gend);
1744684ddb6SLionel Sambuc
1754684ddb6SLionel Sambuc    // 27.6.2.3.3 Put area:
1764684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE char_type* pbase() const {return __bout_;}
1774684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE char_type* pptr()  const {return __nout_;}
1784684ddb6SLionel Sambuc    _LIBCPP_ALWAYS_INLINE char_type* epptr() const {return __eout_;}
1794684ddb6SLionel Sambuc    void pbump(int __n);
1804684ddb6SLionel Sambuc    void setp(char_type* __pbeg, char_type* __pend);
1814684ddb6SLionel Sambuc
1824684ddb6SLionel Sambuc    // 27.6.2.4 virtual functions:
1834684ddb6SLionel Sambuc    // 27.6.2.4.1 Locales:
1844684ddb6SLionel Sambuc    virtual void imbue(const locale& __loc);
1854684ddb6SLionel Sambuc
1864684ddb6SLionel Sambuc    // 27.6.2.4.2 Buffer management and positioning:
1874684ddb6SLionel Sambuc    virtual basic_streambuf* setbuf(char_type* __s, streamsize __n);
1884684ddb6SLionel Sambuc    virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
1894684ddb6SLionel Sambuc                             ios_base::openmode __which = ios_base::in | ios_base::out);
1904684ddb6SLionel Sambuc    virtual pos_type seekpos(pos_type __sp,
1914684ddb6SLionel Sambuc                             ios_base::openmode __which = ios_base::in | ios_base::out);
1924684ddb6SLionel Sambuc    virtual int sync();
1934684ddb6SLionel Sambuc
1944684ddb6SLionel Sambuc    // 27.6.2.4.3 Get area:
1954684ddb6SLionel Sambuc    virtual streamsize showmanyc();
1964684ddb6SLionel Sambuc    virtual streamsize xsgetn(char_type* __s, streamsize __n);
1974684ddb6SLionel Sambuc    virtual int_type underflow();
1984684ddb6SLionel Sambuc    virtual int_type uflow();
1994684ddb6SLionel Sambuc
2004684ddb6SLionel Sambuc    // 27.6.2.4.4 Putback:
2014684ddb6SLionel Sambuc    virtual int_type pbackfail(int_type __c = traits_type::eof());
2024684ddb6SLionel Sambuc
2034684ddb6SLionel Sambuc    // 27.6.2.4.5 Put area:
2044684ddb6SLionel Sambuc    virtual streamsize xsputn(const char_type* __s, streamsize __n);
2054684ddb6SLionel Sambuc    virtual int_type overflow(int_type __c = traits_type::eof());
2064684ddb6SLionel Sambuc
2074684ddb6SLionel Sambucprivate:
2084684ddb6SLionel Sambuc    locale __loc_;
2094684ddb6SLionel Sambuc    char_type* __binp_;
2104684ddb6SLionel Sambuc    char_type* __ninp_;
2114684ddb6SLionel Sambuc    char_type* __einp_;
2124684ddb6SLionel Sambuc    char_type* __bout_;
2134684ddb6SLionel Sambuc    char_type* __nout_;
2144684ddb6SLionel Sambuc    char_type* __eout_;
2154684ddb6SLionel Sambuc};
2164684ddb6SLionel Sambuc
2174684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2184684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::~basic_streambuf()
2194684ddb6SLionel Sambuc{
2204684ddb6SLionel Sambuc}
2214684ddb6SLionel Sambuc
2224684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2234684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2244684ddb6SLionel Sambuclocale
2254684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc)
2264684ddb6SLionel Sambuc{
2274684ddb6SLionel Sambuc    imbue(__loc);
2284684ddb6SLionel Sambuc    locale __r = __loc_;
2294684ddb6SLionel Sambuc    __loc_ = __loc;
2304684ddb6SLionel Sambuc    return __r;
2314684ddb6SLionel Sambuc}
2324684ddb6SLionel Sambuc
2334684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2344684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2354684ddb6SLionel Sambuclocale
2364684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::getloc() const
2374684ddb6SLionel Sambuc{
2384684ddb6SLionel Sambuc    return __loc_;
2394684ddb6SLionel Sambuc}
2404684ddb6SLionel Sambuc
2414684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2424684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2434684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>*
2444684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::pubsetbuf(char_type* __s, streamsize __n)
2454684ddb6SLionel Sambuc{
2464684ddb6SLionel Sambuc    return setbuf(__s, __n);
2474684ddb6SLionel Sambuc}
2484684ddb6SLionel Sambuc
2494684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2504684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2514684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::pos_type
2524684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::pubseekoff(off_type __off,
2534684ddb6SLionel Sambuc                                             ios_base::seekdir __way,
2544684ddb6SLionel Sambuc                                             ios_base::openmode __which)
2554684ddb6SLionel Sambuc{
2564684ddb6SLionel Sambuc    return seekoff(__off, __way, __which);
2574684ddb6SLionel Sambuc}
2584684ddb6SLionel Sambuc
2594684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2604684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2614684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::pos_type
2624684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::pubseekpos(pos_type __sp,
2634684ddb6SLionel Sambuc                                             ios_base::openmode __which)
2644684ddb6SLionel Sambuc{
2654684ddb6SLionel Sambuc    return seekpos(__sp, __which);
2664684ddb6SLionel Sambuc}
2674684ddb6SLionel Sambuc
2684684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2694684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2704684ddb6SLionel Sambucint
2714684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::pubsync()
2724684ddb6SLionel Sambuc{
2734684ddb6SLionel Sambuc    return sync();
2744684ddb6SLionel Sambuc}
2754684ddb6SLionel Sambuc
2764684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2774684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2784684ddb6SLionel Sambucstreamsize
2794684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::in_avail()
2804684ddb6SLionel Sambuc{
2814684ddb6SLionel Sambuc    if (__ninp_ < __einp_)
2824684ddb6SLionel Sambuc        return static_cast<streamsize>(__einp_ - __ninp_);
2834684ddb6SLionel Sambuc    return showmanyc();
2844684ddb6SLionel Sambuc}
2854684ddb6SLionel Sambuc
2864684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2874684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2884684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
2894684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::snextc()
2904684ddb6SLionel Sambuc{
2914684ddb6SLionel Sambuc    if (sbumpc() == traits_type::eof())
2924684ddb6SLionel Sambuc        return traits_type::eof();
2934684ddb6SLionel Sambuc    return sgetc();
2944684ddb6SLionel Sambuc}
2954684ddb6SLionel Sambuc
2964684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
2974684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
2984684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
2994684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::sbumpc()
3004684ddb6SLionel Sambuc{
3014684ddb6SLionel Sambuc    if (__ninp_ == __einp_)
3024684ddb6SLionel Sambuc        return uflow();
3034684ddb6SLionel Sambuc    return traits_type::to_int_type(*__ninp_++);
3044684ddb6SLionel Sambuc}
3054684ddb6SLionel Sambuc
3064684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
3074684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3084684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
3094684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::sgetc()
3104684ddb6SLionel Sambuc{
3114684ddb6SLionel Sambuc    if (__ninp_ == __einp_)
3124684ddb6SLionel Sambuc        return underflow();
3134684ddb6SLionel Sambuc    return traits_type::to_int_type(*__ninp_);
3144684ddb6SLionel Sambuc}
3154684ddb6SLionel Sambuc
3164684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
3174684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3184684ddb6SLionel Sambucstreamsize
3194684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::sgetn(char_type* __s, streamsize __n)
3204684ddb6SLionel Sambuc{
3214684ddb6SLionel Sambuc    return xsgetn(__s, __n);
3224684ddb6SLionel Sambuc}
3234684ddb6SLionel Sambuc
3244684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
3254684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3264684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
3274684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::sputbackc(char_type __c)
3284684ddb6SLionel Sambuc{
3294684ddb6SLionel Sambuc    if (__binp_ == __ninp_ || !traits_type::eq(__c, __ninp_[-1]))
3304684ddb6SLionel Sambuc        return pbackfail(traits_type::to_int_type(__c));
3314684ddb6SLionel Sambuc    return traits_type::to_int_type(*--__ninp_);
3324684ddb6SLionel Sambuc}
3334684ddb6SLionel Sambuc
3344684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
3354684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3364684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
3374684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::sungetc()
3384684ddb6SLionel Sambuc{
3394684ddb6SLionel Sambuc    if (__binp_ == __ninp_)
3404684ddb6SLionel Sambuc        return pbackfail();
3414684ddb6SLionel Sambuc    return traits_type::to_int_type(*--__ninp_);
3424684ddb6SLionel Sambuc}
3434684ddb6SLionel Sambuc
3444684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
3454684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3464684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
3474684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::sputc(char_type __c)
3484684ddb6SLionel Sambuc{
3494684ddb6SLionel Sambuc    if (__nout_ == __eout_)
3504684ddb6SLionel Sambuc        return overflow(traits_type::to_int_type(__c));
3514684ddb6SLionel Sambuc    *__nout_++ = __c;
3524684ddb6SLionel Sambuc    return traits_type::to_int_type(__c);
3534684ddb6SLionel Sambuc}
3544684ddb6SLionel Sambuc
3554684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
3564684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
3574684ddb6SLionel Sambucstreamsize
3584684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::sputn(const char_type* __s, streamsize __n)
3594684ddb6SLionel Sambuc{
3604684ddb6SLionel Sambuc    return xsputn(__s, __n);
3614684ddb6SLionel Sambuc}
3624684ddb6SLionel Sambuc
3634684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
3644684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::basic_streambuf()
3654684ddb6SLionel Sambuc    : __binp_(0),
3664684ddb6SLionel Sambuc      __ninp_(0),
3674684ddb6SLionel Sambuc      __einp_(0),
3684684ddb6SLionel Sambuc      __bout_(0),
3694684ddb6SLionel Sambuc      __nout_(0),
3704684ddb6SLionel Sambuc      __eout_(0)
3714684ddb6SLionel Sambuc{
3724684ddb6SLionel Sambuc}
3734684ddb6SLionel Sambuc
3744684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
3754684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::basic_streambuf(const basic_streambuf& __sb)
3764684ddb6SLionel Sambuc    : __loc_(__sb.__loc_),
3774684ddb6SLionel Sambuc      __binp_(__sb.__binp_),
3784684ddb6SLionel Sambuc      __ninp_(__sb.__ninp_),
3794684ddb6SLionel Sambuc      __einp_(__sb.__einp_),
3804684ddb6SLionel Sambuc      __bout_(__sb.__bout_),
3814684ddb6SLionel Sambuc      __nout_(__sb.__nout_),
3824684ddb6SLionel Sambuc      __eout_(__sb.__eout_)
3834684ddb6SLionel Sambuc{
3844684ddb6SLionel Sambuc}
3854684ddb6SLionel Sambuc
3864684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
3874684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>&
3884684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::operator=(const basic_streambuf& __sb)
3894684ddb6SLionel Sambuc{
3904684ddb6SLionel Sambuc    __loc_ = __sb.__loc_;
3914684ddb6SLionel Sambuc    __binp_ = __sb.__binp_;
3924684ddb6SLionel Sambuc    __ninp_ = __sb.__ninp_;
3934684ddb6SLionel Sambuc    __einp_ = __sb.__einp_;
3944684ddb6SLionel Sambuc    __bout_ = __sb.__bout_;
3954684ddb6SLionel Sambuc    __nout_ = __sb.__nout_;
3964684ddb6SLionel Sambuc    __eout_ = __sb.__eout_;
3974684ddb6SLionel Sambuc    return *this;
3984684ddb6SLionel Sambuc}
3994684ddb6SLionel Sambuc
4004684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4014684ddb6SLionel Sambucvoid
4024684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb)
4034684ddb6SLionel Sambuc{
4044684ddb6SLionel Sambuc    _VSTD::swap(__loc_, __sb.__loc_);
4054684ddb6SLionel Sambuc    _VSTD::swap(__binp_, __sb.__binp_);
4064684ddb6SLionel Sambuc    _VSTD::swap(__ninp_, __sb.__ninp_);
4074684ddb6SLionel Sambuc    _VSTD::swap(__einp_, __sb.__einp_);
4084684ddb6SLionel Sambuc    _VSTD::swap(__bout_, __sb.__bout_);
4094684ddb6SLionel Sambuc    _VSTD::swap(__nout_, __sb.__nout_);
4104684ddb6SLionel Sambuc    _VSTD::swap(__eout_, __sb.__eout_);
4114684ddb6SLionel Sambuc}
4124684ddb6SLionel Sambuc
4134684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4144684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4154684ddb6SLionel Sambucvoid
4164684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::gbump(int __n)
4174684ddb6SLionel Sambuc{
4184684ddb6SLionel Sambuc    __ninp_ += __n;
4194684ddb6SLionel Sambuc}
4204684ddb6SLionel Sambuc
4214684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4224684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4234684ddb6SLionel Sambucvoid
4244684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::setg(char_type* __gbeg, char_type* __gnext,
4254684ddb6SLionel Sambuc                                                          char_type* __gend)
4264684ddb6SLionel Sambuc{
4274684ddb6SLionel Sambuc    __binp_ = __gbeg;
4284684ddb6SLionel Sambuc    __ninp_ = __gnext;
4294684ddb6SLionel Sambuc    __einp_ = __gend;
4304684ddb6SLionel Sambuc}
4314684ddb6SLionel Sambuc
4324684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4334684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4344684ddb6SLionel Sambucvoid
4354684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::pbump(int __n)
4364684ddb6SLionel Sambuc{
4374684ddb6SLionel Sambuc    __nout_ += __n;
4384684ddb6SLionel Sambuc}
4394684ddb6SLionel Sambuc
4404684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4414684ddb6SLionel Sambucinline _LIBCPP_INLINE_VISIBILITY
4424684ddb6SLionel Sambucvoid
4434684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::setp(char_type* __pbeg, char_type* __pend)
4444684ddb6SLionel Sambuc{
4454684ddb6SLionel Sambuc    __bout_ = __nout_ = __pbeg;
4464684ddb6SLionel Sambuc    __eout_ = __pend;
4474684ddb6SLionel Sambuc}
4484684ddb6SLionel Sambuc
4494684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4504684ddb6SLionel Sambucvoid
4514684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::imbue(const locale&)
4524684ddb6SLionel Sambuc{
4534684ddb6SLionel Sambuc}
4544684ddb6SLionel Sambuc
4554684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4564684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>*
4574684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::setbuf(char_type*, streamsize)
4584684ddb6SLionel Sambuc{
4594684ddb6SLionel Sambuc    return this;
4604684ddb6SLionel Sambuc}
4614684ddb6SLionel Sambuc
4624684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4634684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::pos_type
4644684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::seekoff(off_type, ios_base::seekdir,
4654684ddb6SLionel Sambuc                                          ios_base::openmode)
4664684ddb6SLionel Sambuc{
4674684ddb6SLionel Sambuc    return pos_type(off_type(-1));
4684684ddb6SLionel Sambuc}
4694684ddb6SLionel Sambuc
4704684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4714684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::pos_type
4724684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::seekpos(pos_type, ios_base::openmode)
4734684ddb6SLionel Sambuc{
4744684ddb6SLionel Sambuc    return pos_type(off_type(-1));
4754684ddb6SLionel Sambuc}
4764684ddb6SLionel Sambuc
4774684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4784684ddb6SLionel Sambucint
4794684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::sync()
4804684ddb6SLionel Sambuc{
4814684ddb6SLionel Sambuc    return 0;
4824684ddb6SLionel Sambuc}
4834684ddb6SLionel Sambuc
4844684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4854684ddb6SLionel Sambucstreamsize
4864684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::showmanyc()
4874684ddb6SLionel Sambuc{
4884684ddb6SLionel Sambuc    return 0;
4894684ddb6SLionel Sambuc}
4904684ddb6SLionel Sambuc
4914684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
4924684ddb6SLionel Sambucstreamsize
4934684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::xsgetn(char_type* __s, streamsize __n)
4944684ddb6SLionel Sambuc{
4954684ddb6SLionel Sambuc    const int_type __eof = traits_type::eof();
4964684ddb6SLionel Sambuc    int_type __c;
4974684ddb6SLionel Sambuc    streamsize __i = 0;
4984684ddb6SLionel Sambuc    for (;__i < __n; ++__i, ++__s)
4994684ddb6SLionel Sambuc    {
5004684ddb6SLionel Sambuc        if (__ninp_ < __einp_)
5014684ddb6SLionel Sambuc            *__s = *__ninp_++;
5024684ddb6SLionel Sambuc        else if ((__c = uflow()) != __eof)
5034684ddb6SLionel Sambuc            *__s = traits_type::to_char_type(__c);
5044684ddb6SLionel Sambuc        else
5054684ddb6SLionel Sambuc            break;
5064684ddb6SLionel Sambuc    }
5074684ddb6SLionel Sambuc    return __i;
5084684ddb6SLionel Sambuc}
5094684ddb6SLionel Sambuc
5104684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
5114684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
5124684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::underflow()
5134684ddb6SLionel Sambuc{
5144684ddb6SLionel Sambuc    return traits_type::eof();
5154684ddb6SLionel Sambuc}
5164684ddb6SLionel Sambuc
5174684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
5184684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
5194684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::uflow()
5204684ddb6SLionel Sambuc{
5214684ddb6SLionel Sambuc    if (underflow() == traits_type::eof())
5224684ddb6SLionel Sambuc        return traits_type::eof();
5234684ddb6SLionel Sambuc    return traits_type::to_int_type(*__ninp_++);
5244684ddb6SLionel Sambuc}
5254684ddb6SLionel Sambuc
5264684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
5274684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
5284684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::pbackfail(int_type)
5294684ddb6SLionel Sambuc{
5304684ddb6SLionel Sambuc    return traits_type::eof();
5314684ddb6SLionel Sambuc}
5324684ddb6SLionel Sambuc
5334684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
5344684ddb6SLionel Sambucstreamsize
5354684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::xsputn(const char_type* __s, streamsize __n)
5364684ddb6SLionel Sambuc{
5374684ddb6SLionel Sambuc    streamsize __i = 0;
5384684ddb6SLionel Sambuc    int_type __eof = traits_type::eof();
539*0a6a1f1dSLionel Sambuc    while( __i < __n)
5404684ddb6SLionel Sambuc    {
541*0a6a1f1dSLionel Sambuc        if (__nout_ >= __eout_)
542*0a6a1f1dSLionel Sambuc        {
543*0a6a1f1dSLionel Sambuc            if (overflow(traits_type::to_int_type(*__s)) == __eof)
5444684ddb6SLionel Sambuc                break;
545*0a6a1f1dSLionel Sambuc            ++__s;
546*0a6a1f1dSLionel Sambuc            ++__i;
547*0a6a1f1dSLionel Sambuc        }
548*0a6a1f1dSLionel Sambuc        else
549*0a6a1f1dSLionel Sambuc        {
550*0a6a1f1dSLionel Sambuc            streamsize __chunk_size = _VSTD::min(__eout_ - __nout_, __n - __i);
551*0a6a1f1dSLionel Sambuc            traits_type::copy(__nout_, __s, __chunk_size);
552*0a6a1f1dSLionel Sambuc            __nout_ += __chunk_size;
553*0a6a1f1dSLionel Sambuc            __s     += __chunk_size;
554*0a6a1f1dSLionel Sambuc            __i     += __chunk_size;
555*0a6a1f1dSLionel Sambuc        }
5564684ddb6SLionel Sambuc    }
5574684ddb6SLionel Sambuc    return __i;
5584684ddb6SLionel Sambuc}
5594684ddb6SLionel Sambuc
5604684ddb6SLionel Sambuctemplate <class _CharT, class _Traits>
5614684ddb6SLionel Sambuctypename basic_streambuf<_CharT, _Traits>::int_type
5624684ddb6SLionel Sambucbasic_streambuf<_CharT, _Traits>::overflow(int_type)
5634684ddb6SLionel Sambuc{
5644684ddb6SLionel Sambuc    return traits_type::eof();
5654684ddb6SLionel Sambuc}
5664684ddb6SLionel Sambuc
5674684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<char>)
5684684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<wchar_t>)
5694684ddb6SLionel Sambuc
5704684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<char>)
5714684ddb6SLionel Sambuc_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<wchar_t>)
5724684ddb6SLionel Sambuc
5734684ddb6SLionel Sambuc_LIBCPP_END_NAMESPACE_STD
5744684ddb6SLionel Sambuc
5754684ddb6SLionel Sambuc#endif  // _LIBCPP_STEAMBUF
576