xref: /freebsd/contrib/llvm-project/libcxx/include/strstream (revision cb14a3fe5122c879eae1fb480ed7ce82a699ddb6)
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
144*cb14a3feSDimitry Andricclass _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstreambuf : public streambuf {
1450b57cec5SDimitry Andricpublic:
146e8d8bef9SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
14706c3fb27SDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstreambuf() : strstreambuf(0) {}
148e8d8bef9SDimitry Andric  explicit strstreambuf(streamsize __alsize);
149e8d8bef9SDimitry Andric#else
1500b57cec5SDimitry Andric  explicit strstreambuf(streamsize __alsize = 0);
151e8d8bef9SDimitry Andric#endif
1520b57cec5SDimitry Andric  strstreambuf(void* (*__palloc)(size_t), void (*__pfree)(void*));
153e8d8bef9SDimitry Andric  strstreambuf(char* __gnext, streamsize __n, char* __pbeg = nullptr);
1540b57cec5SDimitry Andric  strstreambuf(const char* __gnext, streamsize __n);
1550b57cec5SDimitry Andric
156e8d8bef9SDimitry Andric  strstreambuf(signed char* __gnext, streamsize __n, signed char* __pbeg = nullptr);
1570b57cec5SDimitry Andric  strstreambuf(const signed char* __gnext, streamsize __n);
158e8d8bef9SDimitry Andric  strstreambuf(unsigned char* __gnext, streamsize __n, unsigned char* __pbeg = nullptr);
1590b57cec5SDimitry Andric  strstreambuf(const unsigned char* __gnext, streamsize __n);
1600b57cec5SDimitry Andric
1610b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
162*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstreambuf(strstreambuf&& __rhs);
163*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstreambuf& operator=(strstreambuf&& __rhs);
1640b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
1650b57cec5SDimitry Andric
166bdd1243dSDimitry Andric  ~strstreambuf() override;
1670b57cec5SDimitry Andric
1680b57cec5SDimitry Andric  void swap(strstreambuf& __rhs);
1690b57cec5SDimitry Andric
1700b57cec5SDimitry Andric  void freeze(bool __freezefl = true);
1710b57cec5SDimitry Andric  char* str();
1720b57cec5SDimitry Andric  int pcount() const;
1730b57cec5SDimitry Andric
1740b57cec5SDimitry Andricprotected:
175bdd1243dSDimitry Andric  int_type overflow(int_type __c = EOF) override;
176bdd1243dSDimitry Andric  int_type pbackfail(int_type __c = EOF) override;
177bdd1243dSDimitry Andric  int_type underflow() override;
178*cb14a3feSDimitry Andric  pos_type
179*cb14a3feSDimitry Andric  seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which = ios_base::in | ios_base::out) override;
180*cb14a3feSDimitry Andric  pos_type seekpos(pos_type __sp, ios_base::openmode __which = ios_base::in | ios_base::out) override;
1810b57cec5SDimitry Andric
1820b57cec5SDimitry Andricprivate:
1830b57cec5SDimitry Andric  typedef unsigned __mode_type;
1840b57cec5SDimitry Andric  static const __mode_type __allocated     = 0x01;
1850b57cec5SDimitry Andric  static const __mode_type __constant      = 0x02;
1860b57cec5SDimitry Andric  static const __mode_type __dynamic       = 0x04;
1870b57cec5SDimitry Andric  static const __mode_type __frozen        = 0x08;
1880b57cec5SDimitry Andric  static const streamsize __default_alsize = 4096;
1890b57cec5SDimitry Andric
1900b57cec5SDimitry Andric  __mode_type __strmode_;
1910b57cec5SDimitry Andric  streamsize __alsize_;
1920b57cec5SDimitry Andric  void* (*__palloc_)(size_t);
1930b57cec5SDimitry Andric  void (*__pfree_)(void*);
1940b57cec5SDimitry Andric
1950b57cec5SDimitry Andric  void __init(char* __gnext, streamsize __n, char* __pbeg);
1960b57cec5SDimitry Andric};
1970b57cec5SDimitry Andric
1980b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
1990b57cec5SDimitry Andric
200*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI strstreambuf::strstreambuf(strstreambuf&& __rhs)
2010b57cec5SDimitry Andric    : streambuf(__rhs),
2020b57cec5SDimitry Andric      __strmode_(__rhs.__strmode_),
2030b57cec5SDimitry Andric      __alsize_(__rhs.__alsize_),
2040b57cec5SDimitry Andric      __palloc_(__rhs.__palloc_),
205*cb14a3feSDimitry Andric      __pfree_(__rhs.__pfree_) {
2060b57cec5SDimitry Andric  __rhs.setg(nullptr, nullptr, nullptr);
2070b57cec5SDimitry Andric  __rhs.setp(nullptr, nullptr);
2080b57cec5SDimitry Andric}
2090b57cec5SDimitry Andric
210*cb14a3feSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI strstreambuf& strstreambuf::operator=(strstreambuf&& __rhs) {
211*cb14a3feSDimitry Andric  if (eback() && (__strmode_ & __allocated) != 0 && (__strmode_ & __frozen) == 0) {
2120b57cec5SDimitry Andric    if (__pfree_)
2130b57cec5SDimitry Andric      __pfree_(eback());
2140b57cec5SDimitry Andric    else
2150b57cec5SDimitry Andric      delete[] eback();
2160b57cec5SDimitry Andric  }
2170b57cec5SDimitry Andric  streambuf::operator=(__rhs);
2180b57cec5SDimitry Andric  __strmode_ = __rhs.__strmode_;
2190b57cec5SDimitry Andric  __alsize_  = __rhs.__alsize_;
2200b57cec5SDimitry Andric  __palloc_  = __rhs.__palloc_;
2210b57cec5SDimitry Andric  __pfree_   = __rhs.__pfree_;
2220b57cec5SDimitry Andric  __rhs.setg(nullptr, nullptr, nullptr);
2230b57cec5SDimitry Andric  __rhs.setp(nullptr, nullptr);
2240b57cec5SDimitry Andric  return *this;
2250b57cec5SDimitry Andric}
2260b57cec5SDimitry Andric
2270b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
2280b57cec5SDimitry Andric
229*cb14a3feSDimitry Andricclass _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI istrstream : public istream {
2300b57cec5SDimitry Andricpublic:
231*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit istrstream(const char* __s) : istream(&__sb_), __sb_(__s, 0) {}
232*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI explicit istrstream(char* __s) : istream(&__sb_), __sb_(__s, 0) {}
233*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI istrstream(const char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}
234*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI istrstream(char* __s, streamsize __n) : istream(&__sb_), __sb_(__s, __n) {}
2350b57cec5SDimitry Andric
2360b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
237*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI istrstream(istrstream&& __rhs) // extension
238*cb14a3feSDimitry Andric      : istream(std::move(static_cast<istream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
2390b57cec5SDimitry Andric    istream::set_rdbuf(&__sb_);
2400b57cec5SDimitry Andric  }
2410b57cec5SDimitry Andric
242*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI istrstream& operator=(istrstream&& __rhs) {
2435f757f3fSDimitry Andric    __sb_ = std::move(__rhs.__sb_);
2445f757f3fSDimitry Andric    istream::operator=(std::move(__rhs));
2450b57cec5SDimitry Andric    return *this;
2460b57cec5SDimitry Andric  }
2470b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
2480b57cec5SDimitry Andric
249bdd1243dSDimitry Andric  ~istrstream() override;
2500b57cec5SDimitry Andric
251*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(istrstream& __rhs) {
2520b57cec5SDimitry Andric    istream::swap(__rhs);
2530b57cec5SDimitry Andric    __sb_.swap(__rhs.__sb_);
2540b57cec5SDimitry Andric  }
2550b57cec5SDimitry Andric
256*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstreambuf* rdbuf() const { return const_cast<strstreambuf*>(&__sb_); }
257*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI char* str() { return __sb_.str(); }
2580b57cec5SDimitry Andric
2590b57cec5SDimitry Andricprivate:
2600b57cec5SDimitry Andric  strstreambuf __sb_;
2610b57cec5SDimitry Andric};
2620b57cec5SDimitry Andric
263*cb14a3feSDimitry Andricclass _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI ostrstream : public ostream {
2640b57cec5SDimitry Andricpublic:
265*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ostrstream() : ostream(&__sb_) {}
266*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ostrstream(char* __s, int __n, ios_base::openmode __mode = ios_base::out)
267*cb14a3feSDimitry Andric      : ostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}
2680b57cec5SDimitry Andric
2690b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
270*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ostrstream(ostrstream&& __rhs) // extension
271*cb14a3feSDimitry Andric      : ostream(std::move(static_cast<ostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
2720b57cec5SDimitry Andric    ostream::set_rdbuf(&__sb_);
2730b57cec5SDimitry Andric  }
2740b57cec5SDimitry Andric
275*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI ostrstream& operator=(ostrstream&& __rhs) {
2765f757f3fSDimitry Andric    __sb_ = std::move(__rhs.__sb_);
2775f757f3fSDimitry Andric    ostream::operator=(std::move(__rhs));
2780b57cec5SDimitry Andric    return *this;
2790b57cec5SDimitry Andric  }
2800b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
2810b57cec5SDimitry Andric
282bdd1243dSDimitry Andric  ~ostrstream() override;
2830b57cec5SDimitry Andric
284*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(ostrstream& __rhs) {
2850b57cec5SDimitry Andric    ostream::swap(__rhs);
2860b57cec5SDimitry Andric    __sb_.swap(__rhs.__sb_);
2870b57cec5SDimitry Andric  }
2880b57cec5SDimitry Andric
289*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstreambuf* rdbuf() const { return const_cast<strstreambuf*>(&__sb_); }
290*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void freeze(bool __freezefl = true) { __sb_.freeze(__freezefl); }
291*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI char* str() { return __sb_.str(); }
292*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI int pcount() const { return __sb_.pcount(); }
2930b57cec5SDimitry Andric
2940b57cec5SDimitry Andricprivate:
2950b57cec5SDimitry Andric  strstreambuf __sb_; // exposition only
2960b57cec5SDimitry Andric};
2970b57cec5SDimitry Andric
298*cb14a3feSDimitry Andricclass _LIBCPP_DEPRECATED _LIBCPP_EXPORTED_FROM_ABI strstream : public iostream {
2990b57cec5SDimitry Andricpublic:
3000b57cec5SDimitry Andric  // Types
3010b57cec5SDimitry Andric  typedef char char_type;
3020b57cec5SDimitry Andric  typedef char_traits<char>::int_type int_type;
3030b57cec5SDimitry Andric  typedef char_traits<char>::pos_type pos_type;
3040b57cec5SDimitry Andric  typedef char_traits<char>::off_type off_type;
3050b57cec5SDimitry Andric
3060b57cec5SDimitry Andric  // constructors/destructor
307*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstream() : iostream(&__sb_) {}
308*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstream(char* __s, int __n, ios_base::openmode __mode = ios_base::in | ios_base::out)
309*cb14a3feSDimitry Andric      : iostream(&__sb_), __sb_(__s, __n, __s + (__mode & ios::app ? std::strlen(__s) : 0)) {}
3100b57cec5SDimitry Andric
3110b57cec5SDimitry Andric#ifndef _LIBCPP_CXX03_LANG
312*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstream(strstream&& __rhs) // extension
313*cb14a3feSDimitry Andric      : iostream(std::move(static_cast<iostream&>(__rhs))), __sb_(std::move(__rhs.__sb_)) {
3140b57cec5SDimitry Andric    iostream::set_rdbuf(&__sb_);
3150b57cec5SDimitry Andric  }
3160b57cec5SDimitry Andric
317*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstream& operator=(strstream&& __rhs) {
3185f757f3fSDimitry Andric    __sb_ = std::move(__rhs.__sb_);
3195f757f3fSDimitry Andric    iostream::operator=(std::move(__rhs));
3200b57cec5SDimitry Andric    return *this;
3210b57cec5SDimitry Andric  }
3220b57cec5SDimitry Andric#endif // _LIBCPP_CXX03_LANG
3230b57cec5SDimitry Andric
324bdd1243dSDimitry Andric  ~strstream() override;
3250b57cec5SDimitry Andric
326*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void swap(strstream& __rhs) {
3270b57cec5SDimitry Andric    iostream::swap(__rhs);
3280b57cec5SDimitry Andric    __sb_.swap(__rhs.__sb_);
3290b57cec5SDimitry Andric  }
3300b57cec5SDimitry Andric
3310b57cec5SDimitry Andric  // Members:
332*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI strstreambuf* rdbuf() const { return const_cast<strstreambuf*>(&__sb_); }
333*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI void freeze(bool __freezefl = true) { __sb_.freeze(__freezefl); }
334*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI int pcount() const { return __sb_.pcount(); }
335*cb14a3feSDimitry Andric  _LIBCPP_HIDE_FROM_ABI char* str() { return __sb_.str(); }
3360b57cec5SDimitry Andric
3370b57cec5SDimitry Andricprivate:
3380b57cec5SDimitry Andric  strstreambuf __sb_; // exposition only
3390b57cec5SDimitry Andric};
3400b57cec5SDimitry Andric
3410b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
3420b57cec5SDimitry Andric
3430b57cec5SDimitry Andric#endif // _LIBCPP_STRSTREAM
344