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 100b57cec5SDimitry Andric#ifndef _LIBCPP_STRSTREAM 110b57cec5SDimitry Andric#define _LIBCPP_STRSTREAM 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric strstream synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry Andricclass strstreambuf 170b57cec5SDimitry Andric : public basic_streambuf<char> 180b57cec5SDimitry Andric{ 190b57cec5SDimitry Andricpublic: 20e8d8bef9SDimitry Andric explicit strstreambuf(streamsize alsize_arg = 0); // before C++20 21e8d8bef9SDimitry Andric strstreambuf() : strstreambuf(0) {} // C++20 22e8d8bef9SDimitry Andric explicit strstreambuf(streamsize alsize_arg); // C++20 23e8d8bef9SDimitry Andric 240b57cec5SDimitry Andric strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*)); 25e8d8bef9SDimitry Andric strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = nullptr); 260b57cec5SDimitry Andric strstreambuf(const char* gnext_arg, streamsize n); 270b57cec5SDimitry Andric 28e8d8bef9SDimitry Andric strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = nullptr); 290b57cec5SDimitry Andric strstreambuf(const signed char* gnext_arg, streamsize n); 30e8d8bef9SDimitry Andric strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = nullptr); 310b57cec5SDimitry Andric strstreambuf(const unsigned char* gnext_arg, streamsize n); 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric strstreambuf(strstreambuf&& rhs); 340b57cec5SDimitry Andric strstreambuf& operator=(strstreambuf&& rhs); 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric virtual ~strstreambuf(); 370b57cec5SDimitry Andric 380b57cec5SDimitry Andric void swap(strstreambuf& rhs); 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric void freeze(bool freezefl = true); 410b57cec5SDimitry Andric char* str(); 420b57cec5SDimitry Andric int pcount() const; 430b57cec5SDimitry Andric 440b57cec5SDimitry Andricprotected: 450b57cec5SDimitry Andric virtual int_type overflow (int_type c = EOF); 460b57cec5SDimitry Andric virtual int_type pbackfail(int_type c = EOF); 470b57cec5SDimitry Andric virtual int_type underflow(); 480b57cec5SDimitry Andric virtual pos_type seekoff(off_type off, ios_base::seekdir way, 490b57cec5SDimitry Andric ios_base::openmode which = ios_base::in | ios_base::out); 500b57cec5SDimitry Andric virtual pos_type seekpos(pos_type sp, 510b57cec5SDimitry Andric ios_base::openmode which = ios_base::in | ios_base::out); 520b57cec5SDimitry Andric virtual streambuf* setbuf(char* s, streamsize n); 530b57cec5SDimitry Andric 540b57cec5SDimitry Andricprivate: 550b57cec5SDimitry Andric typedef T1 strstate; // exposition only 560b57cec5SDimitry Andric static const strstate allocated; // exposition only 570b57cec5SDimitry Andric static const strstate constant; // exposition only 580b57cec5SDimitry Andric static const strstate dynamic; // exposition only 590b57cec5SDimitry Andric static const strstate frozen; // exposition only 600b57cec5SDimitry Andric strstate strmode; // exposition only 610b57cec5SDimitry Andric streamsize alsize; // exposition only 620b57cec5SDimitry Andric void* (*palloc)(size_t); // exposition only 630b57cec5SDimitry Andric void (*pfree)(void*); // exposition only 640b57cec5SDimitry Andric}; 650b57cec5SDimitry Andric 660b57cec5SDimitry Andricclass istrstream 670b57cec5SDimitry Andric : public basic_istream<char> 680b57cec5SDimitry Andric{ 690b57cec5SDimitry Andricpublic: 700b57cec5SDimitry Andric explicit istrstream(const char* s); 710b57cec5SDimitry Andric explicit istrstream(char* s); 720b57cec5SDimitry Andric istrstream(const char* s, streamsize n); 730b57cec5SDimitry Andric istrstream(char* s, streamsize n); 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric virtual ~istrstream(); 760b57cec5SDimitry Andric 770b57cec5SDimitry Andric strstreambuf* rdbuf() const; 780b57cec5SDimitry Andric char *str(); 790b57cec5SDimitry Andric 800b57cec5SDimitry Andricprivate: 810b57cec5SDimitry Andric strstreambuf sb; // exposition only 820b57cec5SDimitry Andric}; 830b57cec5SDimitry Andric 840b57cec5SDimitry Andricclass ostrstream 850b57cec5SDimitry Andric : public basic_ostream<char> 860b57cec5SDimitry Andric{ 870b57cec5SDimitry Andricpublic: 880b57cec5SDimitry Andric ostrstream(); 890b57cec5SDimitry Andric ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out); 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric virtual ~ostrstream(); 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric strstreambuf* rdbuf() const; 940b57cec5SDimitry Andric void freeze(bool freezefl = true); 950b57cec5SDimitry Andric char* str(); 960b57cec5SDimitry Andric int pcount() const; 970b57cec5SDimitry Andric 980b57cec5SDimitry Andricprivate: 990b57cec5SDimitry Andric strstreambuf sb; // exposition only 1000b57cec5SDimitry Andric}; 1010b57cec5SDimitry Andric 1020b57cec5SDimitry Andricclass strstream 1030b57cec5SDimitry Andric : public basic_iostream<char> 1040b57cec5SDimitry Andric{ 1050b57cec5SDimitry Andricpublic: 1060b57cec5SDimitry Andric // Types 1070b57cec5SDimitry Andric typedef char char_type; 1080b57cec5SDimitry Andric typedef char_traits<char>::int_type int_type; 1090b57cec5SDimitry Andric typedef char_traits<char>::pos_type pos_type; 1100b57cec5SDimitry Andric typedef char_traits<char>::off_type off_type; 1110b57cec5SDimitry Andric 1120b57cec5SDimitry Andric // constructors/destructor 1130b57cec5SDimitry Andric strstream(); 1140b57cec5SDimitry Andric strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out); 1150b57cec5SDimitry Andric 1160b57cec5SDimitry Andric virtual ~strstream(); 1170b57cec5SDimitry Andric 1180b57cec5SDimitry Andric // Members: 1190b57cec5SDimitry Andric strstreambuf* rdbuf() const; 1200b57cec5SDimitry Andric void freeze(bool freezefl = true); 1210b57cec5SDimitry Andric int pcount() const; 1220b57cec5SDimitry Andric char* str(); 1230b57cec5SDimitry Andric 1240b57cec5SDimitry Andricprivate: 1250b57cec5SDimitry Andric strstreambuf sb; // exposition only 1260b57cec5SDimitry Andric}; 1270b57cec5SDimitry Andric 1280b57cec5SDimitry Andric} // std 1290b57cec5SDimitry Andric 1300b57cec5SDimitry Andric*/ 1310b57cec5SDimitry Andric 13281ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 1330b57cec5SDimitry Andric#include <__config> 1340b57cec5SDimitry Andric#include <istream> 135fe6060f1SDimitry Andric#include <ostream> 13604eeddc0SDimitry Andric#include <version> 1370b57cec5SDimitry Andric 1380b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1390b57cec5SDimitry Andric# pragma GCC system_header 1400b57cec5SDimitry Andric#endif 1410b57cec5SDimitry Andric 1420b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 1430b57cec5SDimitry Andric 1440b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS strstreambuf 1450b57cec5SDimitry Andric : public streambuf 1460b57cec5SDimitry Andric{ 1470b57cec5SDimitry Andricpublic: 148e8d8bef9SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 149e8d8bef9SDimitry Andric strstreambuf() : strstreambuf(0) {} 150e8d8bef9SDimitry Andric explicit strstreambuf(streamsize __alsize); 151e8d8bef9SDimitry Andric#else 1520b57cec5SDimitry Andric explicit strstreambuf(streamsize __alsize = 0); 153e8d8bef9SDimitry Andric#endif 1540b57cec5SDimitry Andric strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)); 155e8d8bef9SDimitry Andric strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr); 1560b57cec5SDimitry Andric strstreambuf(const char* __gnext, streamsize __n); 1570b57cec5SDimitry Andric 158e8d8bef9SDimitry Andric strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = nullptr); 1590b57cec5SDimitry Andric strstreambuf(const signed char* __gnext, streamsize __n); 160e8d8bef9SDimitry Andric strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr); 1610b57cec5SDimitry Andric strstreambuf(const unsigned char* __gnext, streamsize __n); 1620b57cec5SDimitry Andric 1630b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 1640b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1650b57cec5SDimitry Andric strstreambuf(strstreambuf&& __rhs); 1660b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 1670b57cec5SDimitry Andric strstreambuf& operator=(strstreambuf&& __rhs); 1680b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 1690b57cec5SDimitry Andric 170*bdd1243dSDimitry Andric ~strstreambuf() override; 1710b57cec5SDimitry Andric 1720b57cec5SDimitry Andric void swap(strstreambuf& __rhs); 1730b57cec5SDimitry Andric 1740b57cec5SDimitry Andric void freeze(bool __freezefl = true); 1750b57cec5SDimitry Andric char* str(); 1760b57cec5SDimitry Andric int pcount() const; 1770b57cec5SDimitry Andric 1780b57cec5SDimitry Andricprotected: 179*bdd1243dSDimitry Andric int_type overflow (int_type __c = EOF) override; 180*bdd1243dSDimitry Andric int_type pbackfail(int_type __c = EOF) override; 181*bdd1243dSDimitry Andric int_type underflow() override; 182*bdd1243dSDimitry Andric pos_type seekoff(off_type __off, ios_base::seekdir __way, 183*bdd1243dSDimitry Andric ios_base::openmode __which = ios_base::in | ios_base::out) override; 184*bdd1243dSDimitry Andric pos_type seekpos(pos_type __sp, 185*bdd1243dSDimitry Andric ios_base::openmode __which = ios_base::in | ios_base::out) override; 1860b57cec5SDimitry Andric 1870b57cec5SDimitry Andricprivate: 1880b57cec5SDimitry Andric typedef unsigned __mode_type; 1890b57cec5SDimitry Andric static const __mode_type __allocated = 0x01; 1900b57cec5SDimitry Andric static const __mode_type __constant = 0x02; 1910b57cec5SDimitry Andric static const __mode_type __dynamic = 0x04; 1920b57cec5SDimitry Andric static const __mode_type __frozen = 0x08; 1930b57cec5SDimitry Andric static const streamsize __default_alsize = 4096; 1940b57cec5SDimitry Andric 1950b57cec5SDimitry Andric __mode_type __strmode_; 1960b57cec5SDimitry Andric streamsize __alsize_; 1970b57cec5SDimitry Andric void* (*__palloc_)(size_t); 1980b57cec5SDimitry Andric void (*__pfree_)(void*); 1990b57cec5SDimitry Andric 2000b57cec5SDimitry Andric void __init(char* __gnext, streamsize __n, char* __pbeg); 2010b57cec5SDimitry Andric}; 2020b57cec5SDimitry Andric 2030b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 2040b57cec5SDimitry Andric 2050b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 2060b57cec5SDimitry Andricstrstreambuf::strstreambuf(strstreambuf&& __rhs) 2070b57cec5SDimitry Andric : streambuf(__rhs), 2080b57cec5SDimitry Andric __strmode_(__rhs.__strmode_), 2090b57cec5SDimitry Andric __alsize_(__rhs.__alsize_), 2100b57cec5SDimitry Andric __palloc_(__rhs.__palloc_), 2110b57cec5SDimitry Andric __pfree_(__rhs.__pfree_) 2120b57cec5SDimitry Andric{ 2130b57cec5SDimitry Andric __rhs.setg(nullptr, nullptr, nullptr); 2140b57cec5SDimitry Andric __rhs.setp(nullptr, nullptr); 2150b57cec5SDimitry Andric} 2160b57cec5SDimitry Andric 2170b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 2180b57cec5SDimitry Andricstrstreambuf& 2190b57cec5SDimitry Andricstrstreambuf::operator=(strstreambuf&& __rhs) 2200b57cec5SDimitry Andric{ 2210b57cec5SDimitry Andric if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0) 2220b57cec5SDimitry Andric { 2230b57cec5SDimitry Andric if (__pfree_) 2240b57cec5SDimitry Andric __pfree_(eback()); 2250b57cec5SDimitry Andric else 2260b57cec5SDimitry Andric delete [] eback(); 2270b57cec5SDimitry Andric } 2280b57cec5SDimitry Andric streambuf::operator=(__rhs); 2290b57cec5SDimitry Andric __strmode_ = __rhs.__strmode_; 2300b57cec5SDimitry Andric __alsize_ = __rhs.__alsize_; 2310b57cec5SDimitry Andric __palloc_ = __rhs.__palloc_; 2320b57cec5SDimitry Andric __pfree_ = __rhs.__pfree_; 2330b57cec5SDimitry Andric __rhs.setg(nullptr, nullptr, nullptr); 2340b57cec5SDimitry Andric __rhs.setp(nullptr, nullptr); 2350b57cec5SDimitry Andric return *this; 2360b57cec5SDimitry Andric} 2370b57cec5SDimitry Andric 2380b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 2390b57cec5SDimitry Andric 2400b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS istrstream 2410b57cec5SDimitry Andric : public istream 2420b57cec5SDimitry Andric{ 2430b57cec5SDimitry Andricpublic: 2440b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2450b57cec5SDimitry Andric explicit istrstream(const char* __s) 2460b57cec5SDimitry Andric : istream(&__sb_), __sb_(__s, 0) {} 2470b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2480b57cec5SDimitry Andric explicit istrstream(char* __s) 2490b57cec5SDimitry Andric : istream(&__sb_), __sb_(__s, 0) {} 2500b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2510b57cec5SDimitry Andric istrstream(const char* __s, streamsize __n) 2520b57cec5SDimitry Andric : istream(&__sb_), __sb_(__s, __n) {} 2530b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2540b57cec5SDimitry Andric istrstream(char* __s, streamsize __n) 2550b57cec5SDimitry Andric : istream(&__sb_), __sb_(__s, __n) {} 2560b57cec5SDimitry Andric 2570b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 2580b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2590b57cec5SDimitry Andric istrstream(istrstream&& __rhs) 2600b57cec5SDimitry Andric : istream(_VSTD::move(__rhs)), 2610b57cec5SDimitry Andric __sb_(_VSTD::move(__rhs.__sb_)) 2620b57cec5SDimitry Andric { 2630b57cec5SDimitry Andric istream::set_rdbuf(&__sb_); 2640b57cec5SDimitry Andric } 2650b57cec5SDimitry Andric 2660b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2670b57cec5SDimitry Andric istrstream& operator=(istrstream&& __rhs) 2680b57cec5SDimitry Andric { 2690b57cec5SDimitry Andric __sb_ = _VSTD::move(__rhs.__sb_); 27081ad6265SDimitry Andric istream::operator=(_VSTD::move(__rhs)); 2710b57cec5SDimitry Andric return *this; 2720b57cec5SDimitry Andric } 2730b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 2740b57cec5SDimitry Andric 275*bdd1243dSDimitry Andric ~istrstream() override; 2760b57cec5SDimitry Andric 2770b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2780b57cec5SDimitry Andric void swap(istrstream& __rhs) 2790b57cec5SDimitry Andric { 2800b57cec5SDimitry Andric istream::swap(__rhs); 2810b57cec5SDimitry Andric __sb_.swap(__rhs.__sb_); 2820b57cec5SDimitry Andric } 2830b57cec5SDimitry Andric 2840b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2850b57cec5SDimitry Andric strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);} 2860b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2870b57cec5SDimitry Andric char *str() {return __sb_.str();} 2880b57cec5SDimitry Andric 2890b57cec5SDimitry Andricprivate: 2900b57cec5SDimitry Andric strstreambuf __sb_; 2910b57cec5SDimitry Andric}; 2920b57cec5SDimitry Andric 2930b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS ostrstream 2940b57cec5SDimitry Andric : public ostream 2950b57cec5SDimitry Andric{ 2960b57cec5SDimitry Andricpublic: 2970b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 2980b57cec5SDimitry Andric ostrstream() 2990b57cec5SDimitry Andric : ostream(&__sb_) {} 3000b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3010b57cec5SDimitry Andric ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) 3020b57cec5SDimitry Andric : ostream(&__sb_), 303e8d8bef9SDimitry Andric __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0)) 3040b57cec5SDimitry Andric {} 3050b57cec5SDimitry Andric 3060b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 3070b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3080b57cec5SDimitry Andric ostrstream(ostrstream&& __rhs) 3090b57cec5SDimitry Andric : ostream(_VSTD::move(__rhs)), 3100b57cec5SDimitry Andric __sb_(_VSTD::move(__rhs.__sb_)) 3110b57cec5SDimitry Andric { 3120b57cec5SDimitry Andric ostream::set_rdbuf(&__sb_); 3130b57cec5SDimitry Andric } 3140b57cec5SDimitry Andric 3150b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3160b57cec5SDimitry Andric ostrstream& operator=(ostrstream&& __rhs) 3170b57cec5SDimitry Andric { 3180b57cec5SDimitry Andric __sb_ = _VSTD::move(__rhs.__sb_); 31981ad6265SDimitry Andric ostream::operator=(_VSTD::move(__rhs)); 3200b57cec5SDimitry Andric return *this; 3210b57cec5SDimitry Andric } 3220b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3230b57cec5SDimitry Andric 324*bdd1243dSDimitry Andric ~ostrstream() override; 3250b57cec5SDimitry Andric 3260b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3270b57cec5SDimitry Andric void swap(ostrstream& __rhs) 3280b57cec5SDimitry Andric { 3290b57cec5SDimitry Andric ostream::swap(__rhs); 3300b57cec5SDimitry Andric __sb_.swap(__rhs.__sb_); 3310b57cec5SDimitry Andric } 3320b57cec5SDimitry Andric 3330b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3340b57cec5SDimitry Andric strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);} 3350b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3360b57cec5SDimitry Andric void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);} 3370b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3380b57cec5SDimitry Andric char* str() {return __sb_.str();} 3390b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3400b57cec5SDimitry Andric int pcount() const {return __sb_.pcount();} 3410b57cec5SDimitry Andric 3420b57cec5SDimitry Andricprivate: 3430b57cec5SDimitry Andric strstreambuf __sb_; // exposition only 3440b57cec5SDimitry Andric}; 3450b57cec5SDimitry Andric 3460b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS strstream 3470b57cec5SDimitry Andric : public iostream 3480b57cec5SDimitry Andric{ 3490b57cec5SDimitry Andricpublic: 3500b57cec5SDimitry Andric // Types 3510b57cec5SDimitry Andric typedef char char_type; 3520b57cec5SDimitry Andric typedef char_traits<char>::int_type int_type; 3530b57cec5SDimitry Andric typedef char_traits<char>::pos_type pos_type; 3540b57cec5SDimitry Andric typedef char_traits<char>::off_type off_type; 3550b57cec5SDimitry Andric 3560b57cec5SDimitry Andric // constructors/destructor 3570b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3580b57cec5SDimitry Andric strstream() 3590b57cec5SDimitry Andric : iostream(&__sb_) {} 3600b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3610b57cec5SDimitry Andric strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) 3620b57cec5SDimitry Andric : iostream(&__sb_), 363e8d8bef9SDimitry Andric __sb_(__s, __n, __s + (__mode & ios::app ? _VSTD::strlen(__s) : 0)) 3640b57cec5SDimitry Andric {} 3650b57cec5SDimitry Andric 3660b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 3670b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3680b57cec5SDimitry Andric strstream(strstream&& __rhs) 3690b57cec5SDimitry Andric : iostream(_VSTD::move(__rhs)), 3700b57cec5SDimitry Andric __sb_(_VSTD::move(__rhs.__sb_)) 3710b57cec5SDimitry Andric { 3720b57cec5SDimitry Andric iostream::set_rdbuf(&__sb_); 3730b57cec5SDimitry Andric } 3740b57cec5SDimitry Andric 3750b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3760b57cec5SDimitry Andric strstream& operator=(strstream&& __rhs) 3770b57cec5SDimitry Andric { 3780b57cec5SDimitry Andric __sb_ = _VSTD::move(__rhs.__sb_); 37981ad6265SDimitry Andric iostream::operator=(_VSTD::move(__rhs)); 3800b57cec5SDimitry Andric return *this; 3810b57cec5SDimitry Andric } 3820b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 3830b57cec5SDimitry Andric 384*bdd1243dSDimitry Andric ~strstream() override; 3850b57cec5SDimitry Andric 3860b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3870b57cec5SDimitry Andric void swap(strstream& __rhs) 3880b57cec5SDimitry Andric { 3890b57cec5SDimitry Andric iostream::swap(__rhs); 3900b57cec5SDimitry Andric __sb_.swap(__rhs.__sb_); 3910b57cec5SDimitry Andric } 3920b57cec5SDimitry Andric 3930b57cec5SDimitry Andric // Members: 3940b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3950b57cec5SDimitry Andric strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);} 3960b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3970b57cec5SDimitry Andric void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);} 3980b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3990b57cec5SDimitry Andric int pcount() const {return __sb_.pcount();} 4000b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 4010b57cec5SDimitry Andric char* str() {return __sb_.str();} 4020b57cec5SDimitry Andric 4030b57cec5SDimitry Andricprivate: 4040b57cec5SDimitry Andric strstreambuf __sb_; // exposition only 4050b57cec5SDimitry Andric}; 4060b57cec5SDimitry Andric 4070b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 4080b57cec5SDimitry Andric 4090b57cec5SDimitry Andric#endif // _LIBCPP_STRSTREAM 410