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