1*0b57cec5SDimitry Andric// -*- C++ -*- 2*0b57cec5SDimitry Andric//===--------------------------- strstream --------------------------------===// 3*0b57cec5SDimitry Andric// 4*0b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*0b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6*0b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*0b57cec5SDimitry Andric// 8*0b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 9*0b57cec5SDimitry Andric 10*0b57cec5SDimitry Andric#ifndef _LIBCPP_STRSTREAM 11*0b57cec5SDimitry Andric#define _LIBCPP_STRSTREAM 12*0b57cec5SDimitry Andric 13*0b57cec5SDimitry Andric/* 14*0b57cec5SDimitry Andric strstream synopsis 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andricclass strstreambuf 17*0b57cec5SDimitry Andric : public basic_streambuf<char> 18*0b57cec5SDimitry Andric{ 19*0b57cec5SDimitry Andricpublic: 20*0b57cec5SDimitry Andric explicit strstreambuf(streamsize alsize_arg = 0); 21*0b57cec5SDimitry Andric strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*)); 22*0b57cec5SDimitry Andric strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0); 23*0b57cec5SDimitry Andric strstreambuf(const char* gnext_arg, streamsize n); 24*0b57cec5SDimitry Andric 25*0b57cec5SDimitry Andric strstreambuf(signed char* gnext_arg, streamsize n, signed char* pbeg_arg = 0); 26*0b57cec5SDimitry Andric strstreambuf(const signed char* gnext_arg, streamsize n); 27*0b57cec5SDimitry Andric strstreambuf(unsigned char* gnext_arg, streamsize n, unsigned char* pbeg_arg = 0); 28*0b57cec5SDimitry Andric strstreambuf(const unsigned char* gnext_arg, streamsize n); 29*0b57cec5SDimitry Andric 30*0b57cec5SDimitry Andric strstreambuf(strstreambuf&& rhs); 31*0b57cec5SDimitry Andric strstreambuf& operator=(strstreambuf&& rhs); 32*0b57cec5SDimitry Andric 33*0b57cec5SDimitry Andric virtual ~strstreambuf(); 34*0b57cec5SDimitry Andric 35*0b57cec5SDimitry Andric void swap(strstreambuf& rhs); 36*0b57cec5SDimitry Andric 37*0b57cec5SDimitry Andric void freeze(bool freezefl = true); 38*0b57cec5SDimitry Andric char* str(); 39*0b57cec5SDimitry Andric int pcount() const; 40*0b57cec5SDimitry Andric 41*0b57cec5SDimitry Andricprotected: 42*0b57cec5SDimitry Andric virtual int_type overflow (int_type c = EOF); 43*0b57cec5SDimitry Andric virtual int_type pbackfail(int_type c = EOF); 44*0b57cec5SDimitry Andric virtual int_type underflow(); 45*0b57cec5SDimitry Andric virtual pos_type seekoff(off_type off, ios_base::seekdir way, 46*0b57cec5SDimitry Andric ios_base::openmode which = ios_base::in | ios_base::out); 47*0b57cec5SDimitry Andric virtual pos_type seekpos(pos_type sp, 48*0b57cec5SDimitry Andric ios_base::openmode which = ios_base::in | ios_base::out); 49*0b57cec5SDimitry Andric virtual streambuf* setbuf(char* s, streamsize n); 50*0b57cec5SDimitry Andric 51*0b57cec5SDimitry Andricprivate: 52*0b57cec5SDimitry Andric typedef T1 strstate; // exposition only 53*0b57cec5SDimitry Andric static const strstate allocated; // exposition only 54*0b57cec5SDimitry Andric static const strstate constant; // exposition only 55*0b57cec5SDimitry Andric static const strstate dynamic; // exposition only 56*0b57cec5SDimitry Andric static const strstate frozen; // exposition only 57*0b57cec5SDimitry Andric strstate strmode; // exposition only 58*0b57cec5SDimitry Andric streamsize alsize; // exposition only 59*0b57cec5SDimitry Andric void* (*palloc)(size_t); // exposition only 60*0b57cec5SDimitry Andric void (*pfree)(void*); // exposition only 61*0b57cec5SDimitry Andric}; 62*0b57cec5SDimitry Andric 63*0b57cec5SDimitry Andricclass istrstream 64*0b57cec5SDimitry Andric : public basic_istream<char> 65*0b57cec5SDimitry Andric{ 66*0b57cec5SDimitry Andricpublic: 67*0b57cec5SDimitry Andric explicit istrstream(const char* s); 68*0b57cec5SDimitry Andric explicit istrstream(char* s); 69*0b57cec5SDimitry Andric istrstream(const char* s, streamsize n); 70*0b57cec5SDimitry Andric istrstream(char* s, streamsize n); 71*0b57cec5SDimitry Andric 72*0b57cec5SDimitry Andric virtual ~istrstream(); 73*0b57cec5SDimitry Andric 74*0b57cec5SDimitry Andric strstreambuf* rdbuf() const; 75*0b57cec5SDimitry Andric char *str(); 76*0b57cec5SDimitry Andric 77*0b57cec5SDimitry Andricprivate: 78*0b57cec5SDimitry Andric strstreambuf sb; // exposition only 79*0b57cec5SDimitry Andric}; 80*0b57cec5SDimitry Andric 81*0b57cec5SDimitry Andricclass ostrstream 82*0b57cec5SDimitry Andric : public basic_ostream<char> 83*0b57cec5SDimitry Andric{ 84*0b57cec5SDimitry Andricpublic: 85*0b57cec5SDimitry Andric ostrstream(); 86*0b57cec5SDimitry Andric ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out); 87*0b57cec5SDimitry Andric 88*0b57cec5SDimitry Andric virtual ~ostrstream(); 89*0b57cec5SDimitry Andric 90*0b57cec5SDimitry Andric strstreambuf* rdbuf() const; 91*0b57cec5SDimitry Andric void freeze(bool freezefl = true); 92*0b57cec5SDimitry Andric char* str(); 93*0b57cec5SDimitry Andric int pcount() const; 94*0b57cec5SDimitry Andric 95*0b57cec5SDimitry Andricprivate: 96*0b57cec5SDimitry Andric strstreambuf sb; // exposition only 97*0b57cec5SDimitry Andric}; 98*0b57cec5SDimitry Andric 99*0b57cec5SDimitry Andricclass strstream 100*0b57cec5SDimitry Andric : public basic_iostream<char> 101*0b57cec5SDimitry Andric{ 102*0b57cec5SDimitry Andricpublic: 103*0b57cec5SDimitry Andric // Types 104*0b57cec5SDimitry Andric typedef char char_type; 105*0b57cec5SDimitry Andric typedef char_traits<char>::int_type int_type; 106*0b57cec5SDimitry Andric typedef char_traits<char>::pos_type pos_type; 107*0b57cec5SDimitry Andric typedef char_traits<char>::off_type off_type; 108*0b57cec5SDimitry Andric 109*0b57cec5SDimitry Andric // constructors/destructor 110*0b57cec5SDimitry Andric strstream(); 111*0b57cec5SDimitry Andric strstream(char* s, int n, ios_base::openmode mode = ios_base::in | ios_base::out); 112*0b57cec5SDimitry Andric 113*0b57cec5SDimitry Andric virtual ~strstream(); 114*0b57cec5SDimitry Andric 115*0b57cec5SDimitry Andric // Members: 116*0b57cec5SDimitry Andric strstreambuf* rdbuf() const; 117*0b57cec5SDimitry Andric void freeze(bool freezefl = true); 118*0b57cec5SDimitry Andric int pcount() const; 119*0b57cec5SDimitry Andric char* str(); 120*0b57cec5SDimitry Andric 121*0b57cec5SDimitry Andricprivate: 122*0b57cec5SDimitry Andric strstreambuf sb; // exposition only 123*0b57cec5SDimitry Andric}; 124*0b57cec5SDimitry Andric 125*0b57cec5SDimitry Andric} // std 126*0b57cec5SDimitry Andric 127*0b57cec5SDimitry Andric*/ 128*0b57cec5SDimitry Andric 129*0b57cec5SDimitry Andric#include <__config> 130*0b57cec5SDimitry Andric#include <ostream> 131*0b57cec5SDimitry Andric#include <istream> 132*0b57cec5SDimitry Andric 133*0b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 134*0b57cec5SDimitry Andric#pragma GCC system_header 135*0b57cec5SDimitry Andric#endif 136*0b57cec5SDimitry Andric 137*0b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 138*0b57cec5SDimitry Andric 139*0b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS strstreambuf 140*0b57cec5SDimitry Andric : public streambuf 141*0b57cec5SDimitry Andric{ 142*0b57cec5SDimitry Andricpublic: 143*0b57cec5SDimitry Andric explicit strstreambuf(streamsize __alsize = 0); 144*0b57cec5SDimitry Andric strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*)); 145*0b57cec5SDimitry Andric strstreambuf(char* __gnext, streamsize __n, char* __pbeg = 0); 146*0b57cec5SDimitry Andric strstreambuf(const char* __gnext, streamsize __n); 147*0b57cec5SDimitry Andric 148*0b57cec5SDimitry Andric strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = 0); 149*0b57cec5SDimitry Andric strstreambuf(const signed char* __gnext, streamsize __n); 150*0b57cec5SDimitry Andric strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = 0); 151*0b57cec5SDimitry Andric strstreambuf(const unsigned char* __gnext, streamsize __n); 152*0b57cec5SDimitry Andric 153*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 154*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 155*0b57cec5SDimitry Andric strstreambuf(strstreambuf&& __rhs); 156*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 157*0b57cec5SDimitry Andric strstreambuf& operator=(strstreambuf&& __rhs); 158*0b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 159*0b57cec5SDimitry Andric 160*0b57cec5SDimitry Andric virtual ~strstreambuf(); 161*0b57cec5SDimitry Andric 162*0b57cec5SDimitry Andric void swap(strstreambuf& __rhs); 163*0b57cec5SDimitry Andric 164*0b57cec5SDimitry Andric void freeze(bool __freezefl = true); 165*0b57cec5SDimitry Andric char* str(); 166*0b57cec5SDimitry Andric int pcount() const; 167*0b57cec5SDimitry Andric 168*0b57cec5SDimitry Andricprotected: 169*0b57cec5SDimitry Andric virtual int_type overflow (int_type __c = EOF); 170*0b57cec5SDimitry Andric virtual int_type pbackfail(int_type __c = EOF); 171*0b57cec5SDimitry Andric virtual int_type underflow(); 172*0b57cec5SDimitry Andric virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, 173*0b57cec5SDimitry Andric ios_base::openmode __which = ios_base::in | ios_base::out); 174*0b57cec5SDimitry Andric virtual pos_type seekpos(pos_type __sp, 175*0b57cec5SDimitry Andric ios_base::openmode __which = ios_base::in | ios_base::out); 176*0b57cec5SDimitry Andric 177*0b57cec5SDimitry Andricprivate: 178*0b57cec5SDimitry Andric typedef unsigned __mode_type; 179*0b57cec5SDimitry Andric static const __mode_type __allocated = 0x01; 180*0b57cec5SDimitry Andric static const __mode_type __constant = 0x02; 181*0b57cec5SDimitry Andric static const __mode_type __dynamic = 0x04; 182*0b57cec5SDimitry Andric static const __mode_type __frozen = 0x08; 183*0b57cec5SDimitry Andric static const streamsize __default_alsize = 4096; 184*0b57cec5SDimitry Andric 185*0b57cec5SDimitry Andric __mode_type __strmode_; 186*0b57cec5SDimitry Andric streamsize __alsize_; 187*0b57cec5SDimitry Andric void* (*__palloc_)(size_t); 188*0b57cec5SDimitry Andric void (*__pfree_)(void*); 189*0b57cec5SDimitry Andric 190*0b57cec5SDimitry Andric void __init(char* __gnext, streamsize __n, char* __pbeg); 191*0b57cec5SDimitry Andric}; 192*0b57cec5SDimitry Andric 193*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 194*0b57cec5SDimitry Andric 195*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 196*0b57cec5SDimitry Andricstrstreambuf::strstreambuf(strstreambuf&& __rhs) 197*0b57cec5SDimitry Andric : streambuf(__rhs), 198*0b57cec5SDimitry Andric __strmode_(__rhs.__strmode_), 199*0b57cec5SDimitry Andric __alsize_(__rhs.__alsize_), 200*0b57cec5SDimitry Andric __palloc_(__rhs.__palloc_), 201*0b57cec5SDimitry Andric __pfree_(__rhs.__pfree_) 202*0b57cec5SDimitry Andric{ 203*0b57cec5SDimitry Andric __rhs.setg(nullptr, nullptr, nullptr); 204*0b57cec5SDimitry Andric __rhs.setp(nullptr, nullptr); 205*0b57cec5SDimitry Andric} 206*0b57cec5SDimitry Andric 207*0b57cec5SDimitry Andricinline _LIBCPP_INLINE_VISIBILITY 208*0b57cec5SDimitry Andricstrstreambuf& 209*0b57cec5SDimitry Andricstrstreambuf::operator=(strstreambuf&& __rhs) 210*0b57cec5SDimitry Andric{ 211*0b57cec5SDimitry Andric if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0) 212*0b57cec5SDimitry Andric { 213*0b57cec5SDimitry Andric if (__pfree_) 214*0b57cec5SDimitry Andric __pfree_(eback()); 215*0b57cec5SDimitry Andric else 216*0b57cec5SDimitry Andric delete [] eback(); 217*0b57cec5SDimitry Andric } 218*0b57cec5SDimitry Andric streambuf::operator=(__rhs); 219*0b57cec5SDimitry Andric __strmode_ = __rhs.__strmode_; 220*0b57cec5SDimitry Andric __alsize_ = __rhs.__alsize_; 221*0b57cec5SDimitry Andric __palloc_ = __rhs.__palloc_; 222*0b57cec5SDimitry Andric __pfree_ = __rhs.__pfree_; 223*0b57cec5SDimitry Andric __rhs.setg(nullptr, nullptr, nullptr); 224*0b57cec5SDimitry Andric __rhs.setp(nullptr, nullptr); 225*0b57cec5SDimitry Andric return *this; 226*0b57cec5SDimitry Andric} 227*0b57cec5SDimitry Andric 228*0b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 229*0b57cec5SDimitry Andric 230*0b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS istrstream 231*0b57cec5SDimitry Andric : public istream 232*0b57cec5SDimitry Andric{ 233*0b57cec5SDimitry Andricpublic: 234*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 235*0b57cec5SDimitry Andric explicit istrstream(const char* __s) 236*0b57cec5SDimitry Andric : istream(&__sb_), __sb_(__s, 0) {} 237*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 238*0b57cec5SDimitry Andric explicit istrstream(char* __s) 239*0b57cec5SDimitry Andric : istream(&__sb_), __sb_(__s, 0) {} 240*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 241*0b57cec5SDimitry Andric istrstream(const char* __s, streamsize __n) 242*0b57cec5SDimitry Andric : istream(&__sb_), __sb_(__s, __n) {} 243*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 244*0b57cec5SDimitry Andric istrstream(char* __s, streamsize __n) 245*0b57cec5SDimitry Andric : istream(&__sb_), __sb_(__s, __n) {} 246*0b57cec5SDimitry Andric 247*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 248*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 249*0b57cec5SDimitry Andric istrstream(istrstream&& __rhs) 250*0b57cec5SDimitry Andric : istream(_VSTD::move(__rhs)), 251*0b57cec5SDimitry Andric __sb_(_VSTD::move(__rhs.__sb_)) 252*0b57cec5SDimitry Andric { 253*0b57cec5SDimitry Andric istream::set_rdbuf(&__sb_); 254*0b57cec5SDimitry Andric } 255*0b57cec5SDimitry Andric 256*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 257*0b57cec5SDimitry Andric istrstream& operator=(istrstream&& __rhs) 258*0b57cec5SDimitry Andric { 259*0b57cec5SDimitry Andric istream::operator=(_VSTD::move(__rhs)); 260*0b57cec5SDimitry Andric __sb_ = _VSTD::move(__rhs.__sb_); 261*0b57cec5SDimitry Andric return *this; 262*0b57cec5SDimitry Andric } 263*0b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 264*0b57cec5SDimitry Andric 265*0b57cec5SDimitry Andric virtual ~istrstream(); 266*0b57cec5SDimitry Andric 267*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 268*0b57cec5SDimitry Andric void swap(istrstream& __rhs) 269*0b57cec5SDimitry Andric { 270*0b57cec5SDimitry Andric istream::swap(__rhs); 271*0b57cec5SDimitry Andric __sb_.swap(__rhs.__sb_); 272*0b57cec5SDimitry Andric } 273*0b57cec5SDimitry Andric 274*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 275*0b57cec5SDimitry Andric strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);} 276*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 277*0b57cec5SDimitry Andric char *str() {return __sb_.str();} 278*0b57cec5SDimitry Andric 279*0b57cec5SDimitry Andricprivate: 280*0b57cec5SDimitry Andric strstreambuf __sb_; 281*0b57cec5SDimitry Andric}; 282*0b57cec5SDimitry Andric 283*0b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS ostrstream 284*0b57cec5SDimitry Andric : public ostream 285*0b57cec5SDimitry Andric{ 286*0b57cec5SDimitry Andricpublic: 287*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 288*0b57cec5SDimitry Andric ostrstream() 289*0b57cec5SDimitry Andric : ostream(&__sb_) {} 290*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 291*0b57cec5SDimitry Andric ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out) 292*0b57cec5SDimitry Andric : ostream(&__sb_), 293*0b57cec5SDimitry Andric __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0)) 294*0b57cec5SDimitry Andric {} 295*0b57cec5SDimitry Andric 296*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 297*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 298*0b57cec5SDimitry Andric ostrstream(ostrstream&& __rhs) 299*0b57cec5SDimitry Andric : ostream(_VSTD::move(__rhs)), 300*0b57cec5SDimitry Andric __sb_(_VSTD::move(__rhs.__sb_)) 301*0b57cec5SDimitry Andric { 302*0b57cec5SDimitry Andric ostream::set_rdbuf(&__sb_); 303*0b57cec5SDimitry Andric } 304*0b57cec5SDimitry Andric 305*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 306*0b57cec5SDimitry Andric ostrstream& operator=(ostrstream&& __rhs) 307*0b57cec5SDimitry Andric { 308*0b57cec5SDimitry Andric ostream::operator=(_VSTD::move(__rhs)); 309*0b57cec5SDimitry Andric __sb_ = _VSTD::move(__rhs.__sb_); 310*0b57cec5SDimitry Andric return *this; 311*0b57cec5SDimitry Andric } 312*0b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 313*0b57cec5SDimitry Andric 314*0b57cec5SDimitry Andric virtual ~ostrstream(); 315*0b57cec5SDimitry Andric 316*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 317*0b57cec5SDimitry Andric void swap(ostrstream& __rhs) 318*0b57cec5SDimitry Andric { 319*0b57cec5SDimitry Andric ostream::swap(__rhs); 320*0b57cec5SDimitry Andric __sb_.swap(__rhs.__sb_); 321*0b57cec5SDimitry Andric } 322*0b57cec5SDimitry Andric 323*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 324*0b57cec5SDimitry Andric strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);} 325*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 326*0b57cec5SDimitry Andric void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);} 327*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 328*0b57cec5SDimitry Andric char* str() {return __sb_.str();} 329*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 330*0b57cec5SDimitry Andric int pcount() const {return __sb_.pcount();} 331*0b57cec5SDimitry Andric 332*0b57cec5SDimitry Andricprivate: 333*0b57cec5SDimitry Andric strstreambuf __sb_; // exposition only 334*0b57cec5SDimitry Andric}; 335*0b57cec5SDimitry Andric 336*0b57cec5SDimitry Andricclass _LIBCPP_TYPE_VIS strstream 337*0b57cec5SDimitry Andric : public iostream 338*0b57cec5SDimitry Andric{ 339*0b57cec5SDimitry Andricpublic: 340*0b57cec5SDimitry Andric // Types 341*0b57cec5SDimitry Andric typedef char char_type; 342*0b57cec5SDimitry Andric typedef char_traits<char>::int_type int_type; 343*0b57cec5SDimitry Andric typedef char_traits<char>::pos_type pos_type; 344*0b57cec5SDimitry Andric typedef char_traits<char>::off_type off_type; 345*0b57cec5SDimitry Andric 346*0b57cec5SDimitry Andric // constructors/destructor 347*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 348*0b57cec5SDimitry Andric strstream() 349*0b57cec5SDimitry Andric : iostream(&__sb_) {} 350*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 351*0b57cec5SDimitry Andric strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out) 352*0b57cec5SDimitry Andric : iostream(&__sb_), 353*0b57cec5SDimitry Andric __sb_(__s, __n, __s + (__mode & ios::app ? strlen(__s) : 0)) 354*0b57cec5SDimitry Andric {} 355*0b57cec5SDimitry Andric 356*0b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG 357*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 358*0b57cec5SDimitry Andric strstream(strstream&& __rhs) 359*0b57cec5SDimitry Andric : iostream(_VSTD::move(__rhs)), 360*0b57cec5SDimitry Andric __sb_(_VSTD::move(__rhs.__sb_)) 361*0b57cec5SDimitry Andric { 362*0b57cec5SDimitry Andric iostream::set_rdbuf(&__sb_); 363*0b57cec5SDimitry Andric } 364*0b57cec5SDimitry Andric 365*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 366*0b57cec5SDimitry Andric strstream& operator=(strstream&& __rhs) 367*0b57cec5SDimitry Andric { 368*0b57cec5SDimitry Andric iostream::operator=(_VSTD::move(__rhs)); 369*0b57cec5SDimitry Andric __sb_ = _VSTD::move(__rhs.__sb_); 370*0b57cec5SDimitry Andric return *this; 371*0b57cec5SDimitry Andric } 372*0b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG 373*0b57cec5SDimitry Andric 374*0b57cec5SDimitry Andric virtual ~strstream(); 375*0b57cec5SDimitry Andric 376*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 377*0b57cec5SDimitry Andric void swap(strstream& __rhs) 378*0b57cec5SDimitry Andric { 379*0b57cec5SDimitry Andric iostream::swap(__rhs); 380*0b57cec5SDimitry Andric __sb_.swap(__rhs.__sb_); 381*0b57cec5SDimitry Andric } 382*0b57cec5SDimitry Andric 383*0b57cec5SDimitry Andric // Members: 384*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 385*0b57cec5SDimitry Andric strstreambuf* rdbuf() const {return const_cast<strstreambuf*>(&__sb_);} 386*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 387*0b57cec5SDimitry Andric void freeze(bool __freezefl = true) {__sb_.freeze(__freezefl);} 388*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 389*0b57cec5SDimitry Andric int pcount() const {return __sb_.pcount();} 390*0b57cec5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 391*0b57cec5SDimitry Andric char* str() {return __sb_.str();} 392*0b57cec5SDimitry Andric 393*0b57cec5SDimitry Andricprivate: 394*0b57cec5SDimitry Andric strstreambuf __sb_; // exposition only 395*0b57cec5SDimitry Andric}; 396*0b57cec5SDimitry Andric 397*0b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 398*0b57cec5SDimitry Andric 399*0b57cec5SDimitry Andric#endif // _LIBCPP_STRSTREAM 400