2
//===--------------------------- sstream ----------------------------------===//
4
// The LLVM Compiler Infrastructure
6
// This file is dual licensed under the MIT and the University of Illinois Open
7
// Source Licenses. See LICENSE.TXT for details.
9
//===----------------------------------------------------------------------===//
11
#ifndef _LIBCPP_SSTREAM
12
#define _LIBCPP_SSTREAM
17
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
19
: public basic_streambuf<charT, traits>
22
typedef charT char_type;
23
typedef traits traits_type;
24
typedef typename traits_type::int_type int_type;
25
typedef typename traits_type::pos_type pos_type;
26
typedef typename traits_type::off_type off_type;
27
typedef Allocator allocator_type;
29
// 27.8.1.1 Constructors:
30
explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out);
31
explicit basic_stringbuf(const basic_string<char_type, traits_type, allocator_type>& str,
32
ios_base::openmode which = ios_base::in | ios_base::out);
33
basic_stringbuf(basic_stringbuf&& rhs);
35
// 27.8.1.2 Assign and swap:
36
basic_stringbuf& operator=(basic_stringbuf&& rhs);
37
void swap(basic_stringbuf& rhs);
39
// 27.8.1.3 Get and set:
40
basic_string<char_type, traits_type, allocator_type> str() const;
41
void str(const basic_string<char_type, traits_type, allocator_type>& s);
44
// 27.8.1.4 Overridden virtual functions:
45
virtual int_type underflow();
46
virtual int_type pbackfail(int_type c = traits_type::eof());
47
virtual int_type overflow (int_type c = traits_type::eof());
48
virtual basic_streambuf<char_type, traits_type>* setbuf(char_type*, streamsize);
49
virtual pos_type seekoff(off_type off, ios_base::seekdir way,
50
ios_base::openmode which = ios_base::in | ios_base::out);
51
virtual pos_type seekpos(pos_type sp,
52
ios_base::openmode which = ios_base::in | ios_base::out);
55
template <class charT, class traits, class Allocator>
56
void swap(basic_stringbuf<charT, traits, Allocator>& x,
57
basic_stringbuf<charT, traits, Allocator>& y);
59
typedef basic_stringbuf<char> stringbuf;
60
typedef basic_stringbuf<wchar_t> wstringbuf;
62
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
63
class basic_istringstream
64
: public basic_istream<charT, traits>
67
typedef charT char_type;
68
typedef traits traits_type;
69
typedef typename traits_type::int_type int_type;
70
typedef typename traits_type::pos_type pos_type;
71
typedef typename traits_type::off_type off_type;
72
typedef Allocator allocator_type;
74
// 27.8.2.1 Constructors:
75
explicit basic_istringstream(ios_base::openmode which = ios_base::in);
76
explicit basic_istringstream(const basic_string<char_type, traits_type,allocator_type>& str,
77
ios_base::openmode which = ios_base::in);
78
basic_istringstream(basic_istringstream&& rhs);
80
// 27.8.2.2 Assign and swap:
81
basic_istringstream& operator=(basic_istringstream&& rhs);
82
void swap(basic_istringstream& rhs);
85
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
86
basic_string<char_type, traits_type, allocator_type> str() const;
87
void str(const basic_string<char_type, traits_type, allocator_type>& s);
90
template <class charT, class traits, class Allocator>
91
void swap(basic_istringstream<charT, traits, Allocator>& x,
92
basic_istringstream<charT, traits, Allocator>& y);
94
typedef basic_istringstream<char> istringstream;
95
typedef basic_istringstream<wchar_t> wistringstream;
97
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
98
class basic_ostringstream
99
: public basic_ostream<charT, traits>
103
typedef charT char_type;
104
typedef traits traits_type;
105
typedef typename traits_type::int_type int_type;
106
typedef typename traits_type::pos_type pos_type;
107
typedef typename traits_type::off_type off_type;
108
typedef Allocator allocator_type;
110
// 27.8.3.1 Constructors/destructor:
111
explicit basic_ostringstream(ios_base::openmode which = ios_base::out);
112
explicit basic_ostringstream(const basic_string<char_type, traits_type, allocator_type>& str,
113
ios_base::openmode which = ios_base::out);
114
basic_ostringstream(basic_ostringstream&& rhs);
116
// 27.8.3.2 Assign/swap:
117
basic_ostringstream& operator=(basic_ostringstream&& rhs);
118
void swap(basic_ostringstream& rhs);
121
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
122
basic_string<char_type, traits_type, allocator_type> str() const;
123
void str(const basic_string<char_type, traits_type, allocator_type>& s);
126
template <class charT, class traits, class Allocator>
127
void swap(basic_ostringstream<charT, traits, Allocator>& x,
128
basic_ostringstream<charT, traits, Allocator>& y);
130
typedef basic_ostringstream<char> ostringstream;
131
typedef basic_ostringstream<wchar_t> wostringstream;
133
template <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> >
134
class basic_stringstream
135
: public basic_iostream<charT, traits>
139
typedef charT char_type;
140
typedef traits traits_type;
141
typedef typename traits_type::int_type int_type;
142
typedef typename traits_type::pos_type pos_type;
143
typedef typename traits_type::off_type off_type;
144
typedef Allocator allocator_type;
146
// constructors/destructor
147
explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in);
148
explicit basic_stringstream(const basic_string<char_type, traits_type, allocator_type>& str,
149
ios_base::openmode which = ios_base::out|ios_base::in);
150
basic_stringstream(basic_stringstream&& rhs);
152
// 27.8.5.1 Assign/swap:
153
basic_stringstream& operator=(basic_stringstream&& rhs);
154
void swap(basic_stringstream& rhs);
157
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
158
basic_string<char_type, traits_type, allocator_type> str() const;
159
void str(const basic_string<char_type, traits_type, allocator_type>& str);
162
template <class charT, class traits, class Allocator>
163
void swap(basic_stringstream<charT, traits, Allocator>& x,
164
basic_stringstream<charT, traits, Allocator>& y);
166
typedef basic_stringstream<char> stringstream;
167
typedef basic_stringstream<wchar_t> wstringstream;
178
#include <__undef_min_max>
180
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
181
#pragma GCC system_header
184
_LIBCPP_BEGIN_NAMESPACE_STD
188
template <class _CharT, class _Traits, class _Allocator>
189
class _LIBCPP_TYPE_VIS basic_stringbuf
190
: public basic_streambuf<_CharT, _Traits>
193
typedef _CharT char_type;
194
typedef _Traits traits_type;
195
typedef typename traits_type::int_type int_type;
196
typedef typename traits_type::pos_type pos_type;
197
typedef typename traits_type::off_type off_type;
198
typedef _Allocator allocator_type;
200
typedef basic_string<char_type, traits_type, allocator_type> string_type;
205
mutable char_type* __hm_;
206
ios_base::openmode __mode_;
209
// 27.8.1.1 Constructors:
210
explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out);
211
explicit basic_stringbuf(const string_type& __s,
212
ios_base::openmode __wch = ios_base::in | ios_base::out);
213
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
214
basic_stringbuf(basic_stringbuf&& __rhs);
217
// 27.8.1.2 Assign and swap:
218
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
219
basic_stringbuf& operator=(basic_stringbuf&& __rhs);
221
void swap(basic_stringbuf& __rhs);
223
// 27.8.1.3 Get and set:
224
string_type str() const;
225
void str(const string_type& __s);
228
// 27.8.1.4 Overridden virtual functions:
229
virtual int_type underflow();
230
virtual int_type pbackfail(int_type __c = traits_type::eof());
231
virtual int_type overflow (int_type __c = traits_type::eof());
232
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way,
233
ios_base::openmode __wch = ios_base::in | ios_base::out);
234
virtual pos_type seekpos(pos_type __sp,
235
ios_base::openmode __wch = ios_base::in | ios_base::out);
238
template <class _CharT, class _Traits, class _Allocator>
239
inline _LIBCPP_INLINE_VISIBILITY
240
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch)
247
template <class _CharT, class _Traits, class _Allocator>
248
inline _LIBCPP_INLINE_VISIBILITY
249
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s,
250
ios_base::openmode __wch)
257
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
259
template <class _CharT, class _Traits, class _Allocator>
260
basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs)
261
: __mode_(__rhs.__mode_)
263
ptrdiff_t __ninp = __rhs.gptr() - __rhs.eback();
264
ptrdiff_t __einp = __rhs.egptr() - __rhs.eback();
265
ptrdiff_t __nout = __rhs.pptr() - __rhs.pbase();
266
ptrdiff_t __eout = __rhs.epptr() - __rhs.pbase();
267
ptrdiff_t __hm = __rhs.__hm_ - __rhs.pbase();
268
__str_ = _VSTD::move(__rhs.__str_);
269
char_type* __p = const_cast<char_type*>(__str_.data());
270
this->setg(__p, __p + __ninp, __p + __einp);
271
this->setp(__p, __p + __eout);
274
__p = const_cast<char_type*>(__rhs.__str_.data());
275
__rhs.setg(__p, __p, __p);
276
__rhs.setp(__p, __p);
278
this->pubimbue(__rhs.getloc());
281
template <class _CharT, class _Traits, class _Allocator>
282
basic_stringbuf<_CharT, _Traits, _Allocator>&
283
basic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs)
285
ptrdiff_t __ninp = __rhs.gptr() - __rhs.eback();
286
ptrdiff_t __einp = __rhs.egptr() - __rhs.eback();
287
ptrdiff_t __nout = __rhs.pptr() - __rhs.pbase();
288
ptrdiff_t __eout = __rhs.epptr() - __rhs.pbase();
289
ptrdiff_t __hm = __rhs.__hm_ - __rhs.pbase();
290
__mode_ = __rhs.__mode_;
291
__str_ = _VSTD::move(__rhs.__str_);
292
char_type* __p = const_cast<char_type*>(__str_.data());
293
this->setg(__p, __p + __ninp, __p + __einp);
294
this->setp(__p, __p + __eout);
297
__p = const_cast<char_type*>(__rhs.__str_.data());
298
__rhs.setg(__p, __p, __p);
299
__rhs.setp(__p, __p);
301
this->pubimbue(__rhs.getloc());
305
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
307
template <class _CharT, class _Traits, class _Allocator>
309
basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs)
311
ptrdiff_t __rninp = __rhs.gptr() - __rhs.eback();
312
ptrdiff_t __reinp = __rhs.egptr() - __rhs.eback();
313
ptrdiff_t __rnout = __rhs.pptr() - __rhs.pbase();
314
ptrdiff_t __reout = __rhs.epptr() - __rhs.pbase();
315
ptrdiff_t __rhm = __rhs.__hm_ - __rhs.pbase();
316
ptrdiff_t __lninp = this->gptr() - this->eback();
317
ptrdiff_t __leinp = this->egptr() - this->eback();
318
ptrdiff_t __lnout = this->pptr() - this->pbase();
319
ptrdiff_t __leout = this->epptr() - this->pbase();
320
ptrdiff_t __lhm = this->__hm_ - this->pbase();
321
_VSTD::swap(__mode_, __rhs.__mode_);
322
__str_.swap(__rhs.__str_);
323
char_type* __p = const_cast<char_type*>(__str_.data());
324
this->setg(__p, __p + __rninp, __p + __reinp);
325
this->setp(__p, __p + __reout);
326
this->pbump(__rnout);
328
__p = const_cast<char_type*>(__rhs.__str_.data());
329
__rhs.setg(__p, __p + __lninp, __p + __leinp);
330
__rhs.setp(__p, __p + __leout);
331
__rhs.pbump(__lnout);
332
__rhs.__hm_ = __p + __lhm;
333
locale __tl = __rhs.getloc();
334
__rhs.pubimbue(this->getloc());
335
this->pubimbue(__tl);
338
template <class _CharT, class _Traits, class _Allocator>
339
inline _LIBCPP_INLINE_VISIBILITY
341
swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
342
basic_stringbuf<_CharT, _Traits, _Allocator>& __y)
347
template <class _CharT, class _Traits, class _Allocator>
348
basic_string<_CharT, _Traits, _Allocator>
349
basic_stringbuf<_CharT, _Traits, _Allocator>::str() const
351
if (__mode_ & ios_base::out)
353
if (__hm_ < this->pptr())
354
__hm_ = this->pptr();
355
return string_type(this->pbase(), __hm_, __str_.get_allocator());
357
else if (__mode_ & ios_base::in)
358
return string_type(this->eback(), this->egptr(), __str_.get_allocator());
359
return string_type(__str_.get_allocator());
362
template <class _CharT, class _Traits, class _Allocator>
364
basic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s)
368
if (__mode_ & ios_base::in)
370
__hm_ = const_cast<char_type*>(__str_.data()) + __str_.size();
371
this->setg(const_cast<char_type*>(__str_.data()),
372
const_cast<char_type*>(__str_.data()),
375
if (__mode_ & ios_base::out)
377
typename string_type::size_type __sz = __str_.size();
378
__hm_ = const_cast<char_type*>(__str_.data()) + __sz;
379
__str_.resize(__str_.capacity());
380
this->setp(const_cast<char_type*>(__str_.data()),
381
const_cast<char_type*>(__str_.data()) + __str_.size());
382
if (__mode_ & (ios_base::app | ios_base::ate))
387
template <class _CharT, class _Traits, class _Allocator>
388
typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
389
basic_stringbuf<_CharT, _Traits, _Allocator>::underflow()
391
if (__hm_ < this->pptr())
392
__hm_ = this->pptr();
393
if (__mode_ & ios_base::in)
395
if (this->egptr() < __hm_)
396
this->setg(this->eback(), this->gptr(), __hm_);
397
if (this->gptr() < this->egptr())
398
return traits_type::to_int_type(*this->gptr());
400
return traits_type::eof();
403
template <class _CharT, class _Traits, class _Allocator>
404
typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
405
basic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c)
407
if (__hm_ < this->pptr())
408
__hm_ = this->pptr();
409
if (this->eback() < this->gptr())
411
if (traits_type::eq_int_type(__c, traits_type::eof()))
413
this->setg(this->eback(), this->gptr()-1, __hm_);
414
return traits_type::not_eof(__c);
416
if ((__mode_ & ios_base::out) ||
417
traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1]))
419
this->setg(this->eback(), this->gptr()-1, __hm_);
420
*this->gptr() = traits_type::to_char_type(__c);
424
return traits_type::eof();
427
template <class _CharT, class _Traits, class _Allocator>
428
typename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type
429
basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c)
431
if (!traits_type::eq_int_type(__c, traits_type::eof()))
433
ptrdiff_t __ninp = this->gptr() - this->eback();
434
if (this->pptr() == this->epptr())
436
if (!(__mode_ & ios_base::out))
437
return traits_type::eof();
438
#ifndef _LIBCPP_NO_EXCEPTIONS
441
#endif // _LIBCPP_NO_EXCEPTIONS
442
ptrdiff_t __nout = this->pptr() - this->pbase();
443
ptrdiff_t __hm = __hm_ - this->pbase();
444
__str_.push_back(char_type());
445
__str_.resize(__str_.capacity());
446
char_type* __p = const_cast<char_type*>(__str_.data());
447
this->setp(__p, __p + __str_.size());
449
__hm_ = this->pbase() + __hm;
450
#ifndef _LIBCPP_NO_EXCEPTIONS
454
return traits_type::eof();
456
#endif // _LIBCPP_NO_EXCEPTIONS
458
__hm_ = _VSTD::max(this->pptr() + 1, __hm_);
459
if (__mode_ & ios_base::in)
461
char_type* __p = const_cast<char_type*>(__str_.data());
462
this->setg(__p, __p + __ninp, __hm_);
464
return this->sputc(__c);
466
return traits_type::not_eof(__c);
469
template <class _CharT, class _Traits, class _Allocator>
470
typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
471
basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off,
472
ios_base::seekdir __way,
473
ios_base::openmode __wch)
475
if (__hm_ < this->pptr())
476
__hm_ = this->pptr();
477
if ((__wch & (ios_base::in | ios_base::out)) == 0)
479
if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out)
480
&& __way == ios_base::cur)
489
if (__wch & ios_base::in)
490
__noff = this->gptr() - this->eback();
492
__noff = this->pptr() - this->pbase();
495
__noff = __hm_ - __str_.data();
501
if (__noff < 0 || __hm_ - __str_.data() < __noff)
505
if ((__wch & ios_base::in) && this->gptr() == 0)
507
if ((__wch & ios_base::out) && this->pptr() == 0)
510
if (__wch & ios_base::in)
511
this->setg(this->eback(), this->eback() + __noff, __hm_);
512
if (__wch & ios_base::out)
514
this->setp(this->pbase(), this->epptr());
517
return pos_type(__noff);
520
template <class _CharT, class _Traits, class _Allocator>
521
inline _LIBCPP_INLINE_VISIBILITY
522
typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type
523
basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp,
524
ios_base::openmode __wch)
526
return seekoff(__sp, ios_base::beg, __wch);
529
// basic_istringstream
531
template <class _CharT, class _Traits, class _Allocator>
532
class _LIBCPP_TYPE_VIS basic_istringstream
533
: public basic_istream<_CharT, _Traits>
536
typedef _CharT char_type;
537
typedef _Traits traits_type;
538
typedef typename traits_type::int_type int_type;
539
typedef typename traits_type::pos_type pos_type;
540
typedef typename traits_type::off_type off_type;
541
typedef _Allocator allocator_type;
543
typedef basic_string<char_type, traits_type, allocator_type> string_type;
546
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
549
// 27.8.2.1 Constructors:
550
explicit basic_istringstream(ios_base::openmode __wch = ios_base::in);
551
explicit basic_istringstream(const string_type& __s,
552
ios_base::openmode __wch = ios_base::in);
553
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
554
basic_istringstream(basic_istringstream&& __rhs);
556
// 27.8.2.2 Assign and swap:
557
basic_istringstream& operator=(basic_istringstream&& __rhs);
558
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
559
void swap(basic_istringstream& __rhs);
562
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
563
string_type str() const;
564
void str(const string_type& __s);
567
template <class _CharT, class _Traits, class _Allocator>
568
inline _LIBCPP_INLINE_VISIBILITY
569
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch)
570
: basic_istream<_CharT, _Traits>(&__sb_),
571
__sb_(__wch | ios_base::in)
575
template <class _CharT, class _Traits, class _Allocator>
576
inline _LIBCPP_INLINE_VISIBILITY
577
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s,
578
ios_base::openmode __wch)
579
: basic_istream<_CharT, _Traits>(&__sb_),
580
__sb_(__s, __wch | ios_base::in)
584
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
586
template <class _CharT, class _Traits, class _Allocator>
587
inline _LIBCPP_INLINE_VISIBILITY
588
basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs)
589
: basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)),
590
__sb_(_VSTD::move(__rhs.__sb_))
592
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
595
template <class _CharT, class _Traits, class _Allocator>
596
basic_istringstream<_CharT, _Traits, _Allocator>&
597
basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs)
599
basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
600
__sb_ = _VSTD::move(__rhs.__sb_);
604
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
606
template <class _CharT, class _Traits, class _Allocator>
607
inline _LIBCPP_INLINE_VISIBILITY
609
basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs)
611
basic_istream<char_type, traits_type>::swap(__rhs);
612
__sb_.swap(__rhs.__sb_);
615
template <class _CharT, class _Traits, class _Allocator>
616
inline _LIBCPP_INLINE_VISIBILITY
618
swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
619
basic_istringstream<_CharT, _Traits, _Allocator>& __y)
624
template <class _CharT, class _Traits, class _Allocator>
625
inline _LIBCPP_INLINE_VISIBILITY
626
basic_stringbuf<_CharT, _Traits, _Allocator>*
627
basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const
629
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
632
template <class _CharT, class _Traits, class _Allocator>
633
inline _LIBCPP_INLINE_VISIBILITY
634
basic_string<_CharT, _Traits, _Allocator>
635
basic_istringstream<_CharT, _Traits, _Allocator>::str() const
640
template <class _CharT, class _Traits, class _Allocator>
641
inline _LIBCPP_INLINE_VISIBILITY
643
basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
648
// basic_ostringstream
650
template <class _CharT, class _Traits, class _Allocator>
651
class _LIBCPP_TYPE_VIS basic_ostringstream
652
: public basic_ostream<_CharT, _Traits>
655
typedef _CharT char_type;
656
typedef _Traits traits_type;
657
typedef typename traits_type::int_type int_type;
658
typedef typename traits_type::pos_type pos_type;
659
typedef typename traits_type::off_type off_type;
660
typedef _Allocator allocator_type;
662
typedef basic_string<char_type, traits_type, allocator_type> string_type;
665
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
668
// 27.8.2.1 Constructors:
669
explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out);
670
explicit basic_ostringstream(const string_type& __s,
671
ios_base::openmode __wch = ios_base::out);
672
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
673
basic_ostringstream(basic_ostringstream&& __rhs);
675
// 27.8.2.2 Assign and swap:
676
basic_ostringstream& operator=(basic_ostringstream&& __rhs);
677
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
678
void swap(basic_ostringstream& __rhs);
681
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
682
string_type str() const;
683
void str(const string_type& __s);
686
template <class _CharT, class _Traits, class _Allocator>
687
inline _LIBCPP_INLINE_VISIBILITY
688
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch)
689
: basic_ostream<_CharT, _Traits>(&__sb_),
690
__sb_(__wch | ios_base::out)
694
template <class _CharT, class _Traits, class _Allocator>
695
inline _LIBCPP_INLINE_VISIBILITY
696
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s,
697
ios_base::openmode __wch)
698
: basic_ostream<_CharT, _Traits>(&__sb_),
699
__sb_(__s, __wch | ios_base::out)
703
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
705
template <class _CharT, class _Traits, class _Allocator>
706
inline _LIBCPP_INLINE_VISIBILITY
707
basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs)
708
: basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)),
709
__sb_(_VSTD::move(__rhs.__sb_))
711
basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_);
714
template <class _CharT, class _Traits, class _Allocator>
715
basic_ostringstream<_CharT, _Traits, _Allocator>&
716
basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs)
718
basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
719
__sb_ = _VSTD::move(__rhs.__sb_);
723
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
725
template <class _CharT, class _Traits, class _Allocator>
726
inline _LIBCPP_INLINE_VISIBILITY
728
basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs)
730
basic_ostream<char_type, traits_type>::swap(__rhs);
731
__sb_.swap(__rhs.__sb_);
734
template <class _CharT, class _Traits, class _Allocator>
735
inline _LIBCPP_INLINE_VISIBILITY
737
swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
738
basic_ostringstream<_CharT, _Traits, _Allocator>& __y)
743
template <class _CharT, class _Traits, class _Allocator>
744
inline _LIBCPP_INLINE_VISIBILITY
745
basic_stringbuf<_CharT, _Traits, _Allocator>*
746
basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const
748
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
751
template <class _CharT, class _Traits, class _Allocator>
752
inline _LIBCPP_INLINE_VISIBILITY
753
basic_string<_CharT, _Traits, _Allocator>
754
basic_ostringstream<_CharT, _Traits, _Allocator>::str() const
759
template <class _CharT, class _Traits, class _Allocator>
760
inline _LIBCPP_INLINE_VISIBILITY
762
basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
767
// basic_stringstream
769
template <class _CharT, class _Traits, class _Allocator>
770
class _LIBCPP_TYPE_VIS basic_stringstream
771
: public basic_iostream<_CharT, _Traits>
774
typedef _CharT char_type;
775
typedef _Traits traits_type;
776
typedef typename traits_type::int_type int_type;
777
typedef typename traits_type::pos_type pos_type;
778
typedef typename traits_type::off_type off_type;
779
typedef _Allocator allocator_type;
781
typedef basic_string<char_type, traits_type, allocator_type> string_type;
784
basic_stringbuf<char_type, traits_type, allocator_type> __sb_;
787
// 27.8.2.1 Constructors:
788
explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out);
789
explicit basic_stringstream(const string_type& __s,
790
ios_base::openmode __wch = ios_base::in | ios_base::out);
791
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
792
basic_stringstream(basic_stringstream&& __rhs);
794
// 27.8.2.2 Assign and swap:
795
basic_stringstream& operator=(basic_stringstream&& __rhs);
796
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
797
void swap(basic_stringstream& __rhs);
800
basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const;
801
string_type str() const;
802
void str(const string_type& __s);
805
template <class _CharT, class _Traits, class _Allocator>
806
inline _LIBCPP_INLINE_VISIBILITY
807
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch)
808
: basic_iostream<_CharT, _Traits>(&__sb_),
813
template <class _CharT, class _Traits, class _Allocator>
814
inline _LIBCPP_INLINE_VISIBILITY
815
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s,
816
ios_base::openmode __wch)
817
: basic_iostream<_CharT, _Traits>(&__sb_),
822
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
824
template <class _CharT, class _Traits, class _Allocator>
825
inline _LIBCPP_INLINE_VISIBILITY
826
basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs)
827
: basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)),
828
__sb_(_VSTD::move(__rhs.__sb_))
830
basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_);
833
template <class _CharT, class _Traits, class _Allocator>
834
basic_stringstream<_CharT, _Traits, _Allocator>&
835
basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs)
837
basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs));
838
__sb_ = _VSTD::move(__rhs.__sb_);
842
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
844
template <class _CharT, class _Traits, class _Allocator>
845
inline _LIBCPP_INLINE_VISIBILITY
847
basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs)
849
basic_iostream<char_type, traits_type>::swap(__rhs);
850
__sb_.swap(__rhs.__sb_);
853
template <class _CharT, class _Traits, class _Allocator>
854
inline _LIBCPP_INLINE_VISIBILITY
856
swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
857
basic_stringstream<_CharT, _Traits, _Allocator>& __y)
862
template <class _CharT, class _Traits, class _Allocator>
863
inline _LIBCPP_INLINE_VISIBILITY
864
basic_stringbuf<_CharT, _Traits, _Allocator>*
865
basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const
867
return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_);
870
template <class _CharT, class _Traits, class _Allocator>
871
inline _LIBCPP_INLINE_VISIBILITY
872
basic_string<_CharT, _Traits, _Allocator>
873
basic_stringstream<_CharT, _Traits, _Allocator>::str() const
878
template <class _CharT, class _Traits, class _Allocator>
879
inline _LIBCPP_INLINE_VISIBILITY
881
basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s)
886
_LIBCPP_END_NAMESPACE_STD
888
#endif // _LIBCPP_SSTREAM