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