17a984708SDavid Chisnall// -*- C++ -*- 27a984708SDavid Chisnall//===--------------------------- sstream ----------------------------------===// 37a984708SDavid Chisnall// 47a984708SDavid Chisnall// The LLVM Compiler Infrastructure 57a984708SDavid Chisnall// 67a984708SDavid Chisnall// This file is dual licensed under the MIT and the University of Illinois Open 77a984708SDavid Chisnall// Source Licenses. See LICENSE.TXT for details. 87a984708SDavid Chisnall// 97a984708SDavid Chisnall//===----------------------------------------------------------------------===// 107a984708SDavid Chisnall 117a984708SDavid Chisnall#ifndef _LIBCPP_SSTREAM 127a984708SDavid Chisnall#define _LIBCPP_SSTREAM 137a984708SDavid Chisnall 147a984708SDavid Chisnall/* 157a984708SDavid Chisnall sstream synopsis 167a984708SDavid Chisnall 177a984708SDavid Chisnalltemplate <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 187a984708SDavid Chisnallclass basic_stringbuf 197a984708SDavid Chisnall : public basic_streambuf<charT, traits> 207a984708SDavid Chisnall{ 217a984708SDavid Chisnallpublic: 227a984708SDavid Chisnall typedef charT char_type; 237a984708SDavid Chisnall typedef traits traits_type; 247a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 257a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 267a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 277a984708SDavid Chisnall typedef Allocator allocator_type; 287a984708SDavid Chisnall 297a984708SDavid Chisnall // 27.8.1.1 Constructors: 307a984708SDavid Chisnall explicit basic_stringbuf(ios_base::openmode which = ios_base::in | ios_base::out); 317a984708SDavid Chisnall explicit basic_stringbuf(const basic_string<char_type, traits_type, allocator_type>& str, 327a984708SDavid Chisnall ios_base::openmode which = ios_base::in | ios_base::out); 337a984708SDavid Chisnall basic_stringbuf(basic_stringbuf&& rhs); 347a984708SDavid Chisnall 357a984708SDavid Chisnall // 27.8.1.2 Assign and swap: 367a984708SDavid Chisnall basic_stringbuf& operator=(basic_stringbuf&& rhs); 377a984708SDavid Chisnall void swap(basic_stringbuf& rhs); 387a984708SDavid Chisnall 397a984708SDavid Chisnall // 27.8.1.3 Get and set: 407a984708SDavid Chisnall basic_string<char_type, traits_type, allocator_type> str() const; 417a984708SDavid Chisnall void str(const basic_string<char_type, traits_type, allocator_type>& s); 427a984708SDavid Chisnall 437a984708SDavid Chisnallprotected: 447a984708SDavid Chisnall // 27.8.1.4 Overridden virtual functions: 457a984708SDavid Chisnall virtual int_type underflow(); 467a984708SDavid Chisnall virtual int_type pbackfail(int_type c = traits_type::eof()); 477a984708SDavid Chisnall virtual int_type overflow (int_type c = traits_type::eof()); 487a984708SDavid Chisnall virtual basic_streambuf<char_type, traits_type>* setbuf(char_type*, streamsize); 497a984708SDavid Chisnall virtual pos_type seekoff(off_type off, ios_base::seekdir way, 507a984708SDavid Chisnall ios_base::openmode which = ios_base::in | ios_base::out); 517a984708SDavid Chisnall virtual pos_type seekpos(pos_type sp, 527a984708SDavid Chisnall ios_base::openmode which = ios_base::in | ios_base::out); 537a984708SDavid Chisnall}; 547a984708SDavid Chisnall 557a984708SDavid Chisnalltemplate <class charT, class traits, class Allocator> 567a984708SDavid Chisnall void swap(basic_stringbuf<charT, traits, Allocator>& x, 577a984708SDavid Chisnall basic_stringbuf<charT, traits, Allocator>& y); 587a984708SDavid Chisnall 597a984708SDavid Chisnalltypedef basic_stringbuf<char> stringbuf; 607a984708SDavid Chisnalltypedef basic_stringbuf<wchar_t> wstringbuf; 617a984708SDavid Chisnall 627a984708SDavid Chisnalltemplate <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 637a984708SDavid Chisnallclass basic_istringstream 647a984708SDavid Chisnall : public basic_istream<charT, traits> 657a984708SDavid Chisnall{ 667a984708SDavid Chisnallpublic: 677a984708SDavid Chisnall typedef charT char_type; 687a984708SDavid Chisnall typedef traits traits_type; 697a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 707a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 717a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 727a984708SDavid Chisnall typedef Allocator allocator_type; 737a984708SDavid Chisnall 747a984708SDavid Chisnall // 27.8.2.1 Constructors: 757a984708SDavid Chisnall explicit basic_istringstream(ios_base::openmode which = ios_base::in); 767a984708SDavid Chisnall explicit basic_istringstream(const basic_string<char_type, traits_type,allocator_type>& str, 777a984708SDavid Chisnall ios_base::openmode which = ios_base::in); 787a984708SDavid Chisnall basic_istringstream(basic_istringstream&& rhs); 797a984708SDavid Chisnall 807a984708SDavid Chisnall // 27.8.2.2 Assign and swap: 817a984708SDavid Chisnall basic_istringstream& operator=(basic_istringstream&& rhs); 827a984708SDavid Chisnall void swap(basic_istringstream& rhs); 837a984708SDavid Chisnall 847a984708SDavid Chisnall // 27.8.2.3 Members: 857a984708SDavid Chisnall basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const; 867a984708SDavid Chisnall basic_string<char_type, traits_type, allocator_type> str() const; 877a984708SDavid Chisnall void str(const basic_string<char_type, traits_type, allocator_type>& s); 887a984708SDavid Chisnall}; 897a984708SDavid Chisnall 907a984708SDavid Chisnalltemplate <class charT, class traits, class Allocator> 917a984708SDavid Chisnall void swap(basic_istringstream<charT, traits, Allocator>& x, 927a984708SDavid Chisnall basic_istringstream<charT, traits, Allocator>& y); 937a984708SDavid Chisnall 947a984708SDavid Chisnalltypedef basic_istringstream<char> istringstream; 957a984708SDavid Chisnalltypedef basic_istringstream<wchar_t> wistringstream; 967a984708SDavid Chisnall 977a984708SDavid Chisnalltemplate <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 987a984708SDavid Chisnallclass basic_ostringstream 997a984708SDavid Chisnall : public basic_ostream<charT, traits> 1007a984708SDavid Chisnall{ 1017a984708SDavid Chisnallpublic: 1027a984708SDavid Chisnall // types: 1037a984708SDavid Chisnall typedef charT char_type; 1047a984708SDavid Chisnall typedef traits traits_type; 1057a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 1067a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 1077a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 1087a984708SDavid Chisnall typedef Allocator allocator_type; 1097a984708SDavid Chisnall 1107a984708SDavid Chisnall // 27.8.3.1 Constructors/destructor: 1117a984708SDavid Chisnall explicit basic_ostringstream(ios_base::openmode which = ios_base::out); 1127a984708SDavid Chisnall explicit basic_ostringstream(const basic_string<char_type, traits_type, allocator_type>& str, 1137a984708SDavid Chisnall ios_base::openmode which = ios_base::out); 1147a984708SDavid Chisnall basic_ostringstream(basic_ostringstream&& rhs); 1157a984708SDavid Chisnall 1167a984708SDavid Chisnall // 27.8.3.2 Assign/swap: 1177a984708SDavid Chisnall basic_ostringstream& operator=(basic_ostringstream&& rhs); 1187a984708SDavid Chisnall void swap(basic_ostringstream& rhs); 1197a984708SDavid Chisnall 1207a984708SDavid Chisnall // 27.8.3.3 Members: 1217a984708SDavid Chisnall basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const; 1227a984708SDavid Chisnall basic_string<char_type, traits_type, allocator_type> str() const; 1237a984708SDavid Chisnall void str(const basic_string<char_type, traits_type, allocator_type>& s); 1247a984708SDavid Chisnall}; 1257a984708SDavid Chisnall 1267a984708SDavid Chisnalltemplate <class charT, class traits, class Allocator> 1277a984708SDavid Chisnall void swap(basic_ostringstream<charT, traits, Allocator>& x, 1287a984708SDavid Chisnall basic_ostringstream<charT, traits, Allocator>& y); 1297a984708SDavid Chisnall 1307a984708SDavid Chisnalltypedef basic_ostringstream<char> ostringstream; 1317a984708SDavid Chisnalltypedef basic_ostringstream<wchar_t> wostringstream; 1327a984708SDavid Chisnall 1337a984708SDavid Chisnalltemplate <class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > 1347a984708SDavid Chisnallclass basic_stringstream 1357a984708SDavid Chisnall : public basic_iostream<charT, traits> 1367a984708SDavid Chisnall{ 1377a984708SDavid Chisnallpublic: 1387a984708SDavid Chisnall // types: 1397a984708SDavid Chisnall typedef charT char_type; 1407a984708SDavid Chisnall typedef traits traits_type; 1417a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 1427a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 1437a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 1447a984708SDavid Chisnall typedef Allocator allocator_type; 1457a984708SDavid Chisnall 1467a984708SDavid Chisnall // constructors/destructor 1477a984708SDavid Chisnall explicit basic_stringstream(ios_base::openmode which = ios_base::out|ios_base::in); 1487a984708SDavid Chisnall explicit basic_stringstream(const basic_string<char_type, traits_type, allocator_type>& str, 1497a984708SDavid Chisnall ios_base::openmode which = ios_base::out|ios_base::in); 1507a984708SDavid Chisnall basic_stringstream(basic_stringstream&& rhs); 1517a984708SDavid Chisnall 1527a984708SDavid Chisnall // 27.8.5.1 Assign/swap: 1537a984708SDavid Chisnall basic_stringstream& operator=(basic_stringstream&& rhs); 1547a984708SDavid Chisnall void swap(basic_stringstream& rhs); 1557a984708SDavid Chisnall 1567a984708SDavid Chisnall // Members: 1577a984708SDavid Chisnall basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const; 1587a984708SDavid Chisnall basic_string<char_type, traits_type, allocator_type> str() const; 1597a984708SDavid Chisnall void str(const basic_string<char_type, traits_type, allocator_type>& str); 1607a984708SDavid Chisnall}; 1617a984708SDavid Chisnall 1627a984708SDavid Chisnalltemplate <class charT, class traits, class Allocator> 1637a984708SDavid Chisnall void swap(basic_stringstream<charT, traits, Allocator>& x, 1647a984708SDavid Chisnall basic_stringstream<charT, traits, Allocator>& y); 1657a984708SDavid Chisnall 1667a984708SDavid Chisnalltypedef basic_stringstream<char> stringstream; 1677a984708SDavid Chisnalltypedef basic_stringstream<wchar_t> wstringstream; 1687a984708SDavid Chisnall 1697a984708SDavid Chisnall} // std 1707a984708SDavid Chisnall 1717a984708SDavid Chisnall*/ 1727a984708SDavid Chisnall 1737a984708SDavid Chisnall#include <__config> 1747a984708SDavid Chisnall#include <ostream> 1757a984708SDavid Chisnall#include <istream> 1767a984708SDavid Chisnall#include <string> 1777a984708SDavid Chisnall 1787a984708SDavid Chisnall#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1797a984708SDavid Chisnall#pragma GCC system_header 1807a984708SDavid Chisnall#endif 1817a984708SDavid Chisnall 182f9448bf3SDimitry Andric_LIBCPP_PUSH_MACROS 183f9448bf3SDimitry Andric#include <__undef_macros> 184f9448bf3SDimitry Andric 185f9448bf3SDimitry Andric 1867a984708SDavid Chisnall_LIBCPP_BEGIN_NAMESPACE_STD 1877a984708SDavid Chisnall 1887a984708SDavid Chisnall// basic_stringbuf 1897a984708SDavid Chisnall 1907a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 191aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS basic_stringbuf 1927a984708SDavid Chisnall : public basic_streambuf<_CharT, _Traits> 1937a984708SDavid Chisnall{ 1947a984708SDavid Chisnallpublic: 1957a984708SDavid Chisnall typedef _CharT char_type; 1967a984708SDavid Chisnall typedef _Traits traits_type; 1977a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 1987a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 1997a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 2007a984708SDavid Chisnall typedef _Allocator allocator_type; 2017a984708SDavid Chisnall 2027a984708SDavid Chisnall typedef basic_string<char_type, traits_type, allocator_type> string_type; 2037a984708SDavid Chisnall 2047a984708SDavid Chisnallprivate: 2057a984708SDavid Chisnall 2067a984708SDavid Chisnall string_type __str_; 2077a984708SDavid Chisnall mutable char_type* __hm_; 2087a984708SDavid Chisnall ios_base::openmode __mode_; 2097a984708SDavid Chisnall 2107a984708SDavid Chisnallpublic: 2117a984708SDavid Chisnall // 27.8.1.1 Constructors: 212aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 2137a984708SDavid Chisnall explicit basic_stringbuf(ios_base::openmode __wch = ios_base::in | ios_base::out); 214aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 2157a984708SDavid Chisnall explicit basic_stringbuf(const string_type& __s, 2167a984708SDavid Chisnall ios_base::openmode __wch = ios_base::in | ios_base::out); 217540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 2187a984708SDavid Chisnall basic_stringbuf(basic_stringbuf&& __rhs); 2197a984708SDavid Chisnall 2207a984708SDavid Chisnall // 27.8.1.2 Assign and swap: 2217a984708SDavid Chisnall basic_stringbuf& operator=(basic_stringbuf&& __rhs); 2227a984708SDavid Chisnall#endif 2237a984708SDavid Chisnall void swap(basic_stringbuf& __rhs); 2247a984708SDavid Chisnall 2257a984708SDavid Chisnall // 27.8.1.3 Get and set: 2267a984708SDavid Chisnall string_type str() const; 2277a984708SDavid Chisnall void str(const string_type& __s); 2287a984708SDavid Chisnall 2297a984708SDavid Chisnallprotected: 2307a984708SDavid Chisnall // 27.8.1.4 Overridden virtual functions: 2317a984708SDavid Chisnall virtual int_type underflow(); 2327a984708SDavid Chisnall virtual int_type pbackfail(int_type __c = traits_type::eof()); 2337a984708SDavid Chisnall virtual int_type overflow (int_type __c = traits_type::eof()); 2347a984708SDavid Chisnall virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, 2357a984708SDavid Chisnall ios_base::openmode __wch = ios_base::in | ios_base::out); 236aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 2377a984708SDavid Chisnall virtual pos_type seekpos(pos_type __sp, 2387a984708SDavid Chisnall ios_base::openmode __wch = ios_base::in | ios_base::out); 2397a984708SDavid Chisnall}; 2407a984708SDavid Chisnall 2417a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2427a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch) 2437a984708SDavid Chisnall : __hm_(0), 2447a984708SDavid Chisnall __mode_(__wch) 2457a984708SDavid Chisnall{ 2467a984708SDavid Chisnall} 2477a984708SDavid Chisnall 2487a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2497a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s, 2507a984708SDavid Chisnall ios_base::openmode __wch) 2519dc417c3SDimitry Andric : __str_(__s.get_allocator()), 2529dc417c3SDimitry Andric __hm_(0), 2537a984708SDavid Chisnall __mode_(__wch) 2547a984708SDavid Chisnall{ 2557a984708SDavid Chisnall str(__s); 2567a984708SDavid Chisnall} 2577a984708SDavid Chisnall 258540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 2597a984708SDavid Chisnall 2607a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 2617a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(basic_stringbuf&& __rhs) 2627a984708SDavid Chisnall : __mode_(__rhs.__mode_) 2637a984708SDavid Chisnall{ 2641bf9f7c1SDimitry Andric char_type* __p = const_cast<char_type*>(__rhs.__str_.data()); 2651bf9f7c1SDimitry Andric ptrdiff_t __binp = -1; 2661bf9f7c1SDimitry Andric ptrdiff_t __ninp = -1; 2671bf9f7c1SDimitry Andric ptrdiff_t __einp = -1; 2681bf9f7c1SDimitry Andric if (__rhs.eback() != nullptr) 2691bf9f7c1SDimitry Andric { 2701bf9f7c1SDimitry Andric __binp = __rhs.eback() - __p; 2711bf9f7c1SDimitry Andric __ninp = __rhs.gptr() - __p; 2721bf9f7c1SDimitry Andric __einp = __rhs.egptr() - __p; 2731bf9f7c1SDimitry Andric } 2741bf9f7c1SDimitry Andric ptrdiff_t __bout = -1; 2751bf9f7c1SDimitry Andric ptrdiff_t __nout = -1; 2761bf9f7c1SDimitry Andric ptrdiff_t __eout = -1; 2771bf9f7c1SDimitry Andric if (__rhs.pbase() != nullptr) 2781bf9f7c1SDimitry Andric { 2791bf9f7c1SDimitry Andric __bout = __rhs.pbase() - __p; 2801bf9f7c1SDimitry Andric __nout = __rhs.pptr() - __p; 2811bf9f7c1SDimitry Andric __eout = __rhs.epptr() - __p; 2821bf9f7c1SDimitry Andric } 2831bf9f7c1SDimitry Andric ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p; 2847a984708SDavid Chisnall __str_ = _VSTD::move(__rhs.__str_); 2851bf9f7c1SDimitry Andric __p = const_cast<char_type*>(__str_.data()); 2861bf9f7c1SDimitry Andric if (__binp != -1) 2871bf9f7c1SDimitry Andric this->setg(__p + __binp, __p + __ninp, __p + __einp); 2881bf9f7c1SDimitry Andric if (__bout != -1) 2891bf9f7c1SDimitry Andric { 2901bf9f7c1SDimitry Andric this->setp(__p + __bout, __p + __eout); 291b2c7081bSDimitry Andric this->__pbump(__nout); 2921bf9f7c1SDimitry Andric } 2931bf9f7c1SDimitry Andric __hm_ = __hm == -1 ? nullptr : __p + __hm; 2947a984708SDavid Chisnall __p = const_cast<char_type*>(__rhs.__str_.data()); 2957a984708SDavid Chisnall __rhs.setg(__p, __p, __p); 2967a984708SDavid Chisnall __rhs.setp(__p, __p); 2977a984708SDavid Chisnall __rhs.__hm_ = __p; 2987a984708SDavid Chisnall this->pubimbue(__rhs.getloc()); 2997a984708SDavid Chisnall} 3007a984708SDavid Chisnall 3017a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3027a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>& 3037a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::operator=(basic_stringbuf&& __rhs) 3047a984708SDavid Chisnall{ 3051bf9f7c1SDimitry Andric char_type* __p = const_cast<char_type*>(__rhs.__str_.data()); 3061bf9f7c1SDimitry Andric ptrdiff_t __binp = -1; 3071bf9f7c1SDimitry Andric ptrdiff_t __ninp = -1; 3081bf9f7c1SDimitry Andric ptrdiff_t __einp = -1; 3091bf9f7c1SDimitry Andric if (__rhs.eback() != nullptr) 3101bf9f7c1SDimitry Andric { 3111bf9f7c1SDimitry Andric __binp = __rhs.eback() - __p; 3121bf9f7c1SDimitry Andric __ninp = __rhs.gptr() - __p; 3131bf9f7c1SDimitry Andric __einp = __rhs.egptr() - __p; 3141bf9f7c1SDimitry Andric } 3151bf9f7c1SDimitry Andric ptrdiff_t __bout = -1; 3161bf9f7c1SDimitry Andric ptrdiff_t __nout = -1; 3171bf9f7c1SDimitry Andric ptrdiff_t __eout = -1; 3181bf9f7c1SDimitry Andric if (__rhs.pbase() != nullptr) 3191bf9f7c1SDimitry Andric { 3201bf9f7c1SDimitry Andric __bout = __rhs.pbase() - __p; 3211bf9f7c1SDimitry Andric __nout = __rhs.pptr() - __p; 3221bf9f7c1SDimitry Andric __eout = __rhs.epptr() - __p; 3231bf9f7c1SDimitry Andric } 3241bf9f7c1SDimitry Andric ptrdiff_t __hm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p; 3257a984708SDavid Chisnall __str_ = _VSTD::move(__rhs.__str_); 3261bf9f7c1SDimitry Andric __p = const_cast<char_type*>(__str_.data()); 3271bf9f7c1SDimitry Andric if (__binp != -1) 3281bf9f7c1SDimitry Andric this->setg(__p + __binp, __p + __ninp, __p + __einp); 329d72607e9SDimitry Andric else 330d72607e9SDimitry Andric this->setg(nullptr, nullptr, nullptr); 3311bf9f7c1SDimitry Andric if (__bout != -1) 3321bf9f7c1SDimitry Andric { 3331bf9f7c1SDimitry Andric this->setp(__p + __bout, __p + __eout); 334b2c7081bSDimitry Andric this->__pbump(__nout); 3351bf9f7c1SDimitry Andric } 336d72607e9SDimitry Andric else 337d72607e9SDimitry Andric this->setp(nullptr, nullptr); 338d72607e9SDimitry Andric 3391bf9f7c1SDimitry Andric __hm_ = __hm == -1 ? nullptr : __p + __hm; 3401bf9f7c1SDimitry Andric __mode_ = __rhs.__mode_; 3417a984708SDavid Chisnall __p = const_cast<char_type*>(__rhs.__str_.data()); 3427a984708SDavid Chisnall __rhs.setg(__p, __p, __p); 3437a984708SDavid Chisnall __rhs.setp(__p, __p); 3447a984708SDavid Chisnall __rhs.__hm_ = __p; 3457a984708SDavid Chisnall this->pubimbue(__rhs.getloc()); 3467a984708SDavid Chisnall return *this; 3477a984708SDavid Chisnall} 3487a984708SDavid Chisnall 349540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 3507a984708SDavid Chisnall 3517a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 3527a984708SDavid Chisnallvoid 3537a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) 3547a984708SDavid Chisnall{ 3551bf9f7c1SDimitry Andric char_type* __p = const_cast<char_type*>(__rhs.__str_.data()); 3561bf9f7c1SDimitry Andric ptrdiff_t __rbinp = -1; 3571bf9f7c1SDimitry Andric ptrdiff_t __rninp = -1; 3581bf9f7c1SDimitry Andric ptrdiff_t __reinp = -1; 3591bf9f7c1SDimitry Andric if (__rhs.eback() != nullptr) 3601bf9f7c1SDimitry Andric { 3611bf9f7c1SDimitry Andric __rbinp = __rhs.eback() - __p; 3621bf9f7c1SDimitry Andric __rninp = __rhs.gptr() - __p; 3631bf9f7c1SDimitry Andric __reinp = __rhs.egptr() - __p; 3641bf9f7c1SDimitry Andric } 3651bf9f7c1SDimitry Andric ptrdiff_t __rbout = -1; 3661bf9f7c1SDimitry Andric ptrdiff_t __rnout = -1; 3671bf9f7c1SDimitry Andric ptrdiff_t __reout = -1; 3681bf9f7c1SDimitry Andric if (__rhs.pbase() != nullptr) 3691bf9f7c1SDimitry Andric { 3701bf9f7c1SDimitry Andric __rbout = __rhs.pbase() - __p; 3711bf9f7c1SDimitry Andric __rnout = __rhs.pptr() - __p; 3721bf9f7c1SDimitry Andric __reout = __rhs.epptr() - __p; 3731bf9f7c1SDimitry Andric } 3741bf9f7c1SDimitry Andric ptrdiff_t __rhm = __rhs.__hm_ == nullptr ? -1 : __rhs.__hm_ - __p; 3751bf9f7c1SDimitry Andric __p = const_cast<char_type*>(__str_.data()); 3761bf9f7c1SDimitry Andric ptrdiff_t __lbinp = -1; 3771bf9f7c1SDimitry Andric ptrdiff_t __lninp = -1; 3781bf9f7c1SDimitry Andric ptrdiff_t __leinp = -1; 3791bf9f7c1SDimitry Andric if (this->eback() != nullptr) 3801bf9f7c1SDimitry Andric { 3811bf9f7c1SDimitry Andric __lbinp = this->eback() - __p; 3821bf9f7c1SDimitry Andric __lninp = this->gptr() - __p; 3831bf9f7c1SDimitry Andric __leinp = this->egptr() - __p; 3841bf9f7c1SDimitry Andric } 3851bf9f7c1SDimitry Andric ptrdiff_t __lbout = -1; 3861bf9f7c1SDimitry Andric ptrdiff_t __lnout = -1; 3871bf9f7c1SDimitry Andric ptrdiff_t __leout = -1; 3881bf9f7c1SDimitry Andric if (this->pbase() != nullptr) 3891bf9f7c1SDimitry Andric { 3901bf9f7c1SDimitry Andric __lbout = this->pbase() - __p; 3911bf9f7c1SDimitry Andric __lnout = this->pptr() - __p; 3921bf9f7c1SDimitry Andric __leout = this->epptr() - __p; 3931bf9f7c1SDimitry Andric } 3941bf9f7c1SDimitry Andric ptrdiff_t __lhm = __hm_ == nullptr ? -1 : __hm_ - __p; 3957a984708SDavid Chisnall _VSTD::swap(__mode_, __rhs.__mode_); 3967a984708SDavid Chisnall __str_.swap(__rhs.__str_); 3971bf9f7c1SDimitry Andric __p = const_cast<char_type*>(__str_.data()); 3981bf9f7c1SDimitry Andric if (__rbinp != -1) 3991bf9f7c1SDimitry Andric this->setg(__p + __rbinp, __p + __rninp, __p + __reinp); 4001bf9f7c1SDimitry Andric else 4011bf9f7c1SDimitry Andric this->setg(nullptr, nullptr, nullptr); 4021bf9f7c1SDimitry Andric if (__rbout != -1) 4031bf9f7c1SDimitry Andric { 4041bf9f7c1SDimitry Andric this->setp(__p + __rbout, __p + __reout); 405b2c7081bSDimitry Andric this->__pbump(__rnout); 4061bf9f7c1SDimitry Andric } 4071bf9f7c1SDimitry Andric else 4081bf9f7c1SDimitry Andric this->setp(nullptr, nullptr); 4091bf9f7c1SDimitry Andric __hm_ = __rhm == -1 ? nullptr : __p + __rhm; 4107a984708SDavid Chisnall __p = const_cast<char_type*>(__rhs.__str_.data()); 4111bf9f7c1SDimitry Andric if (__lbinp != -1) 4121bf9f7c1SDimitry Andric __rhs.setg(__p + __lbinp, __p + __lninp, __p + __leinp); 4131bf9f7c1SDimitry Andric else 4141bf9f7c1SDimitry Andric __rhs.setg(nullptr, nullptr, nullptr); 4151bf9f7c1SDimitry Andric if (__lbout != -1) 4161bf9f7c1SDimitry Andric { 4171bf9f7c1SDimitry Andric __rhs.setp(__p + __lbout, __p + __leout); 418b2c7081bSDimitry Andric __rhs.__pbump(__lnout); 4191bf9f7c1SDimitry Andric } 4201bf9f7c1SDimitry Andric else 4211bf9f7c1SDimitry Andric __rhs.setp(nullptr, nullptr); 4221bf9f7c1SDimitry Andric __rhs.__hm_ = __lhm == -1 ? nullptr : __p + __lhm; 4237a984708SDavid Chisnall locale __tl = __rhs.getloc(); 4247a984708SDavid Chisnall __rhs.pubimbue(this->getloc()); 4257a984708SDavid Chisnall this->pubimbue(__tl); 4267a984708SDavid Chisnall} 4277a984708SDavid Chisnall 4287a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 4297a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4307a984708SDavid Chisnallvoid 4317a984708SDavid Chisnallswap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, 4327a984708SDavid Chisnall basic_stringbuf<_CharT, _Traits, _Allocator>& __y) 4337a984708SDavid Chisnall{ 4347a984708SDavid Chisnall __x.swap(__y); 4357a984708SDavid Chisnall} 4367a984708SDavid Chisnall 4377a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 4387a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 4397a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::str() const 4407a984708SDavid Chisnall{ 4417a984708SDavid Chisnall if (__mode_ & ios_base::out) 4427a984708SDavid Chisnall { 4437a984708SDavid Chisnall if (__hm_ < this->pptr()) 4447a984708SDavid Chisnall __hm_ = this->pptr(); 4457a984708SDavid Chisnall return string_type(this->pbase(), __hm_, __str_.get_allocator()); 4467a984708SDavid Chisnall } 4477a984708SDavid Chisnall else if (__mode_ & ios_base::in) 4487a984708SDavid Chisnall return string_type(this->eback(), this->egptr(), __str_.get_allocator()); 4497a984708SDavid Chisnall return string_type(__str_.get_allocator()); 4507a984708SDavid Chisnall} 4517a984708SDavid Chisnall 4527a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 4537a984708SDavid Chisnallvoid 4547a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::str(const string_type& __s) 4557a984708SDavid Chisnall{ 4567a984708SDavid Chisnall __str_ = __s; 4577a984708SDavid Chisnall __hm_ = 0; 4587a984708SDavid Chisnall if (__mode_ & ios_base::in) 4597a984708SDavid Chisnall { 4607a984708SDavid Chisnall __hm_ = const_cast<char_type*>(__str_.data()) + __str_.size(); 4617a984708SDavid Chisnall this->setg(const_cast<char_type*>(__str_.data()), 4627a984708SDavid Chisnall const_cast<char_type*>(__str_.data()), 4637a984708SDavid Chisnall __hm_); 4647a984708SDavid Chisnall } 4657a984708SDavid Chisnall if (__mode_ & ios_base::out) 4667a984708SDavid Chisnall { 4677a984708SDavid Chisnall typename string_type::size_type __sz = __str_.size(); 4687a984708SDavid Chisnall __hm_ = const_cast<char_type*>(__str_.data()) + __sz; 4697a984708SDavid Chisnall __str_.resize(__str_.capacity()); 4707a984708SDavid Chisnall this->setp(const_cast<char_type*>(__str_.data()), 4717a984708SDavid Chisnall const_cast<char_type*>(__str_.data()) + __str_.size()); 4727a984708SDavid Chisnall if (__mode_ & (ios_base::app | ios_base::ate)) 473b2c7081bSDimitry Andric { 474b2c7081bSDimitry Andric while (__sz > INT_MAX) 475b2c7081bSDimitry Andric { 476b2c7081bSDimitry Andric this->pbump(INT_MAX); 477b2c7081bSDimitry Andric __sz -= INT_MAX; 478b2c7081bSDimitry Andric } 479b2c7081bSDimitry Andric if (__sz > 0) 4807a984708SDavid Chisnall this->pbump(__sz); 4817a984708SDavid Chisnall } 4827a984708SDavid Chisnall } 483b2c7081bSDimitry Andric} 4847a984708SDavid Chisnall 4857a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 4867a984708SDavid Chisnalltypename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type 4877a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::underflow() 4887a984708SDavid Chisnall{ 4897a984708SDavid Chisnall if (__hm_ < this->pptr()) 4907a984708SDavid Chisnall __hm_ = this->pptr(); 4917a984708SDavid Chisnall if (__mode_ & ios_base::in) 4927a984708SDavid Chisnall { 4937a984708SDavid Chisnall if (this->egptr() < __hm_) 4947a984708SDavid Chisnall this->setg(this->eback(), this->gptr(), __hm_); 4957a984708SDavid Chisnall if (this->gptr() < this->egptr()) 4967a984708SDavid Chisnall return traits_type::to_int_type(*this->gptr()); 4977a984708SDavid Chisnall } 4987a984708SDavid Chisnall return traits_type::eof(); 4997a984708SDavid Chisnall} 5007a984708SDavid Chisnall 5017a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 5027a984708SDavid Chisnalltypename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type 5037a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::pbackfail(int_type __c) 5047a984708SDavid Chisnall{ 5057a984708SDavid Chisnall if (__hm_ < this->pptr()) 5067a984708SDavid Chisnall __hm_ = this->pptr(); 5077a984708SDavid Chisnall if (this->eback() < this->gptr()) 5087a984708SDavid Chisnall { 5097a984708SDavid Chisnall if (traits_type::eq_int_type(__c, traits_type::eof())) 5107a984708SDavid Chisnall { 5117a984708SDavid Chisnall this->setg(this->eback(), this->gptr()-1, __hm_); 5127a984708SDavid Chisnall return traits_type::not_eof(__c); 5137a984708SDavid Chisnall } 5147a984708SDavid Chisnall if ((__mode_ & ios_base::out) || 5157a984708SDavid Chisnall traits_type::eq(traits_type::to_char_type(__c), this->gptr()[-1])) 5167a984708SDavid Chisnall { 5177a984708SDavid Chisnall this->setg(this->eback(), this->gptr()-1, __hm_); 5187a984708SDavid Chisnall *this->gptr() = traits_type::to_char_type(__c); 5197a984708SDavid Chisnall return __c; 5207a984708SDavid Chisnall } 5217a984708SDavid Chisnall } 5227a984708SDavid Chisnall return traits_type::eof(); 5237a984708SDavid Chisnall} 5247a984708SDavid Chisnall 5257a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 5267a984708SDavid Chisnalltypename basic_stringbuf<_CharT, _Traits, _Allocator>::int_type 5277a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) 5287a984708SDavid Chisnall{ 5297a984708SDavid Chisnall if (!traits_type::eq_int_type(__c, traits_type::eof())) 5307a984708SDavid Chisnall { 5317a984708SDavid Chisnall ptrdiff_t __ninp = this->gptr() - this->eback(); 5327a984708SDavid Chisnall if (this->pptr() == this->epptr()) 5337a984708SDavid Chisnall { 5347a984708SDavid Chisnall if (!(__mode_ & ios_base::out)) 5357a984708SDavid Chisnall return traits_type::eof(); 5367a984708SDavid Chisnall#ifndef _LIBCPP_NO_EXCEPTIONS 5377a984708SDavid Chisnall try 5387a984708SDavid Chisnall { 5397a984708SDavid Chisnall#endif // _LIBCPP_NO_EXCEPTIONS 5407a984708SDavid Chisnall ptrdiff_t __nout = this->pptr() - this->pbase(); 5417a984708SDavid Chisnall ptrdiff_t __hm = __hm_ - this->pbase(); 5427a984708SDavid Chisnall __str_.push_back(char_type()); 5437a984708SDavid Chisnall __str_.resize(__str_.capacity()); 5447a984708SDavid Chisnall char_type* __p = const_cast<char_type*>(__str_.data()); 5457a984708SDavid Chisnall this->setp(__p, __p + __str_.size()); 546b2c7081bSDimitry Andric this->__pbump(__nout); 5477a984708SDavid Chisnall __hm_ = this->pbase() + __hm; 5487a984708SDavid Chisnall#ifndef _LIBCPP_NO_EXCEPTIONS 5497a984708SDavid Chisnall } 5507a984708SDavid Chisnall catch (...) 5517a984708SDavid Chisnall { 5527a984708SDavid Chisnall return traits_type::eof(); 5537a984708SDavid Chisnall } 5547a984708SDavid Chisnall#endif // _LIBCPP_NO_EXCEPTIONS 5557a984708SDavid Chisnall } 5567a984708SDavid Chisnall __hm_ = _VSTD::max(this->pptr() + 1, __hm_); 5577a984708SDavid Chisnall if (__mode_ & ios_base::in) 5587a984708SDavid Chisnall { 5597a984708SDavid Chisnall char_type* __p = const_cast<char_type*>(__str_.data()); 5607a984708SDavid Chisnall this->setg(__p, __p + __ninp, __hm_); 5617a984708SDavid Chisnall } 5627a984708SDavid Chisnall return this->sputc(__c); 5637a984708SDavid Chisnall } 5647a984708SDavid Chisnall return traits_type::not_eof(__c); 5657a984708SDavid Chisnall} 5667a984708SDavid Chisnall 5677a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 5687a984708SDavid Chisnalltypename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type 5697a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off, 5707a984708SDavid Chisnall ios_base::seekdir __way, 5717a984708SDavid Chisnall ios_base::openmode __wch) 5727a984708SDavid Chisnall{ 5737a984708SDavid Chisnall if (__hm_ < this->pptr()) 5747a984708SDavid Chisnall __hm_ = this->pptr(); 5757a984708SDavid Chisnall if ((__wch & (ios_base::in | ios_base::out)) == 0) 5767a984708SDavid Chisnall return pos_type(-1); 5777a984708SDavid Chisnall if ((__wch & (ios_base::in | ios_base::out)) == (ios_base::in | ios_base::out) 5787a984708SDavid Chisnall && __way == ios_base::cur) 5797a984708SDavid Chisnall return pos_type(-1); 58039f349c2SDimitry Andric const ptrdiff_t __hm = __hm_ == nullptr ? 0 : __hm_ - __str_.data(); 5817a984708SDavid Chisnall off_type __noff; 5827a984708SDavid Chisnall switch (__way) 5837a984708SDavid Chisnall { 5847a984708SDavid Chisnall case ios_base::beg: 5857a984708SDavid Chisnall __noff = 0; 5867a984708SDavid Chisnall break; 5877a984708SDavid Chisnall case ios_base::cur: 5887a984708SDavid Chisnall if (__wch & ios_base::in) 5897a984708SDavid Chisnall __noff = this->gptr() - this->eback(); 5907a984708SDavid Chisnall else 5917a984708SDavid Chisnall __noff = this->pptr() - this->pbase(); 5927a984708SDavid Chisnall break; 5937a984708SDavid Chisnall case ios_base::end: 59439f349c2SDimitry Andric __noff = __hm; 5957a984708SDavid Chisnall break; 5967a984708SDavid Chisnall default: 5977a984708SDavid Chisnall return pos_type(-1); 5987a984708SDavid Chisnall } 5997a984708SDavid Chisnall __noff += __off; 60039f349c2SDimitry Andric if (__noff < 0 || __hm < __noff) 6017a984708SDavid Chisnall return pos_type(-1); 6027a984708SDavid Chisnall if (__noff != 0) 6037a984708SDavid Chisnall { 6047a984708SDavid Chisnall if ((__wch & ios_base::in) && this->gptr() == 0) 6057a984708SDavid Chisnall return pos_type(-1); 6067a984708SDavid Chisnall if ((__wch & ios_base::out) && this->pptr() == 0) 6077a984708SDavid Chisnall return pos_type(-1); 6087a984708SDavid Chisnall } 6097a984708SDavid Chisnall if (__wch & ios_base::in) 6107a984708SDavid Chisnall this->setg(this->eback(), this->eback() + __noff, __hm_); 6117a984708SDavid Chisnall if (__wch & ios_base::out) 6127a984708SDavid Chisnall { 6137a984708SDavid Chisnall this->setp(this->pbase(), this->epptr()); 6147a984708SDavid Chisnall this->pbump(__noff); 6157a984708SDavid Chisnall } 6167a984708SDavid Chisnall return pos_type(__noff); 6177a984708SDavid Chisnall} 6187a984708SDavid Chisnall 6197a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 6207a984708SDavid Chisnalltypename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type 6217a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp, 6227a984708SDavid Chisnall ios_base::openmode __wch) 6237a984708SDavid Chisnall{ 6247a984708SDavid Chisnall return seekoff(__sp, ios_base::beg, __wch); 6257a984708SDavid Chisnall} 6267a984708SDavid Chisnall 6277a984708SDavid Chisnall// basic_istringstream 6287a984708SDavid Chisnall 6297a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 630aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS basic_istringstream 6317a984708SDavid Chisnall : public basic_istream<_CharT, _Traits> 6327a984708SDavid Chisnall{ 6337a984708SDavid Chisnallpublic: 6347a984708SDavid Chisnall typedef _CharT char_type; 6357a984708SDavid Chisnall typedef _Traits traits_type; 6367a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 6377a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 6387a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 6397a984708SDavid Chisnall typedef _Allocator allocator_type; 6407a984708SDavid Chisnall 6417a984708SDavid Chisnall typedef basic_string<char_type, traits_type, allocator_type> string_type; 6427a984708SDavid Chisnall 6437a984708SDavid Chisnallprivate: 6447a984708SDavid Chisnall basic_stringbuf<char_type, traits_type, allocator_type> __sb_; 6457a984708SDavid Chisnall 6467a984708SDavid Chisnallpublic: 6477a984708SDavid Chisnall // 27.8.2.1 Constructors: 648aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6497a984708SDavid Chisnall explicit basic_istringstream(ios_base::openmode __wch = ios_base::in); 650aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6517a984708SDavid Chisnall explicit basic_istringstream(const string_type& __s, 6527a984708SDavid Chisnall ios_base::openmode __wch = ios_base::in); 653540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 654aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6557a984708SDavid Chisnall basic_istringstream(basic_istringstream&& __rhs); 6567a984708SDavid Chisnall 6577a984708SDavid Chisnall // 27.8.2.2 Assign and swap: 6587a984708SDavid Chisnall basic_istringstream& operator=(basic_istringstream&& __rhs); 659540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 660aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6617a984708SDavid Chisnall void swap(basic_istringstream& __rhs); 6627a984708SDavid Chisnall 6637a984708SDavid Chisnall // 27.8.2.3 Members: 664aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6657a984708SDavid Chisnall basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const; 666aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6677a984708SDavid Chisnall string_type str() const; 668aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 6697a984708SDavid Chisnall void str(const string_type& __s); 6707a984708SDavid Chisnall}; 6717a984708SDavid Chisnall 6727a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 6737a984708SDavid Chisnallbasic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch) 6747a984708SDavid Chisnall : basic_istream<_CharT, _Traits>(&__sb_), 6757a984708SDavid Chisnall __sb_(__wch | ios_base::in) 6767a984708SDavid Chisnall{ 6777a984708SDavid Chisnall} 6787a984708SDavid Chisnall 6797a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 6807a984708SDavid Chisnallbasic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s, 6817a984708SDavid Chisnall ios_base::openmode __wch) 6827a984708SDavid Chisnall : basic_istream<_CharT, _Traits>(&__sb_), 6837a984708SDavid Chisnall __sb_(__s, __wch | ios_base::in) 6847a984708SDavid Chisnall{ 6857a984708SDavid Chisnall} 6867a984708SDavid Chisnall 687540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 6887a984708SDavid Chisnall 6897a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 6907a984708SDavid Chisnallbasic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs) 6917a984708SDavid Chisnall : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)), 6927a984708SDavid Chisnall __sb_(_VSTD::move(__rhs.__sb_)) 6937a984708SDavid Chisnall{ 6947a984708SDavid Chisnall basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); 6957a984708SDavid Chisnall} 6967a984708SDavid Chisnall 6977a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 6987a984708SDavid Chisnallbasic_istringstream<_CharT, _Traits, _Allocator>& 6997a984708SDavid Chisnallbasic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream&& __rhs) 7007a984708SDavid Chisnall{ 7017a984708SDavid Chisnall basic_istream<char_type, traits_type>::operator=(_VSTD::move(__rhs)); 7027a984708SDavid Chisnall __sb_ = _VSTD::move(__rhs.__sb_); 7037a984708SDavid Chisnall return *this; 7047a984708SDavid Chisnall} 7057a984708SDavid Chisnall 706540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 7077a984708SDavid Chisnall 7087a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 709aed8d94eSDimitry Andricvoid basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs) 7107a984708SDavid Chisnall{ 7117a984708SDavid Chisnall basic_istream<char_type, traits_type>::swap(__rhs); 7127a984708SDavid Chisnall __sb_.swap(__rhs.__sb_); 7137a984708SDavid Chisnall} 7147a984708SDavid Chisnall 7157a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 7167a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7177a984708SDavid Chisnallvoid 7187a984708SDavid Chisnallswap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, 7197a984708SDavid Chisnall basic_istringstream<_CharT, _Traits, _Allocator>& __y) 7207a984708SDavid Chisnall{ 7217a984708SDavid Chisnall __x.swap(__y); 7227a984708SDavid Chisnall} 7237a984708SDavid Chisnall 7247a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 7257a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>* 7267a984708SDavid Chisnallbasic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const 7277a984708SDavid Chisnall{ 7287a984708SDavid Chisnall return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_); 7297a984708SDavid Chisnall} 7307a984708SDavid Chisnall 7317a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 7327a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 7337a984708SDavid Chisnallbasic_istringstream<_CharT, _Traits, _Allocator>::str() const 7347a984708SDavid Chisnall{ 7357a984708SDavid Chisnall return __sb_.str(); 7367a984708SDavid Chisnall} 7377a984708SDavid Chisnall 7387a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 739aed8d94eSDimitry Andricvoid basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) 7407a984708SDavid Chisnall{ 7417a984708SDavid Chisnall __sb_.str(__s); 7427a984708SDavid Chisnall} 7437a984708SDavid Chisnall 7447a984708SDavid Chisnall// basic_ostringstream 7457a984708SDavid Chisnall 7467a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 747aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS basic_ostringstream 7487a984708SDavid Chisnall : public basic_ostream<_CharT, _Traits> 7497a984708SDavid Chisnall{ 7507a984708SDavid Chisnallpublic: 7517a984708SDavid Chisnall typedef _CharT char_type; 7527a984708SDavid Chisnall typedef _Traits traits_type; 7537a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 7547a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 7557a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 7567a984708SDavid Chisnall typedef _Allocator allocator_type; 7577a984708SDavid Chisnall 7587a984708SDavid Chisnall typedef basic_string<char_type, traits_type, allocator_type> string_type; 7597a984708SDavid Chisnall 7607a984708SDavid Chisnallprivate: 7617a984708SDavid Chisnall basic_stringbuf<char_type, traits_type, allocator_type> __sb_; 7627a984708SDavid Chisnall 7637a984708SDavid Chisnallpublic: 7647a984708SDavid Chisnall // 27.8.2.1 Constructors: 765aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 7667a984708SDavid Chisnall explicit basic_ostringstream(ios_base::openmode __wch = ios_base::out); 767aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 7687a984708SDavid Chisnall explicit basic_ostringstream(const string_type& __s, 7697a984708SDavid Chisnall ios_base::openmode __wch = ios_base::out); 770540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 771aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 7727a984708SDavid Chisnall basic_ostringstream(basic_ostringstream&& __rhs); 7737a984708SDavid Chisnall 7747a984708SDavid Chisnall // 27.8.2.2 Assign and swap: 7757a984708SDavid Chisnall basic_ostringstream& operator=(basic_ostringstream&& __rhs); 776540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 777aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 7787a984708SDavid Chisnall void swap(basic_ostringstream& __rhs); 7797a984708SDavid Chisnall 7807a984708SDavid Chisnall // 27.8.2.3 Members: 781aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 7827a984708SDavid Chisnall basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const; 783aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 7847a984708SDavid Chisnall string_type str() const; 785aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 7867a984708SDavid Chisnall void str(const string_type& __s); 7877a984708SDavid Chisnall}; 7887a984708SDavid Chisnall 7897a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 7907a984708SDavid Chisnallbasic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch) 7917a984708SDavid Chisnall : basic_ostream<_CharT, _Traits>(&__sb_), 7927a984708SDavid Chisnall __sb_(__wch | ios_base::out) 7937a984708SDavid Chisnall{ 7947a984708SDavid Chisnall} 7957a984708SDavid Chisnall 7967a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 7977a984708SDavid Chisnallbasic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s, 7987a984708SDavid Chisnall ios_base::openmode __wch) 7997a984708SDavid Chisnall : basic_ostream<_CharT, _Traits>(&__sb_), 8007a984708SDavid Chisnall __sb_(__s, __wch | ios_base::out) 8017a984708SDavid Chisnall{ 8027a984708SDavid Chisnall} 8037a984708SDavid Chisnall 804540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 8057a984708SDavid Chisnall 8067a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 8077a984708SDavid Chisnallbasic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs) 8087a984708SDavid Chisnall : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)), 8097a984708SDavid Chisnall __sb_(_VSTD::move(__rhs.__sb_)) 8107a984708SDavid Chisnall{ 8117a984708SDavid Chisnall basic_ostream<_CharT, _Traits>::set_rdbuf(&__sb_); 8127a984708SDavid Chisnall} 8137a984708SDavid Chisnall 8147a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 8157a984708SDavid Chisnallbasic_ostringstream<_CharT, _Traits, _Allocator>& 8167a984708SDavid Chisnallbasic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream&& __rhs) 8177a984708SDavid Chisnall{ 8187a984708SDavid Chisnall basic_ostream<char_type, traits_type>::operator=(_VSTD::move(__rhs)); 8197a984708SDavid Chisnall __sb_ = _VSTD::move(__rhs.__sb_); 8207a984708SDavid Chisnall return *this; 8217a984708SDavid Chisnall} 8227a984708SDavid Chisnall 823540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 8247a984708SDavid Chisnall 8257a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 8267a984708SDavid Chisnallvoid 8277a984708SDavid Chisnallbasic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs) 8287a984708SDavid Chisnall{ 8297a984708SDavid Chisnall basic_ostream<char_type, traits_type>::swap(__rhs); 8307a984708SDavid Chisnall __sb_.swap(__rhs.__sb_); 8317a984708SDavid Chisnall} 8327a984708SDavid Chisnall 8337a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 8347a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8357a984708SDavid Chisnallvoid 8367a984708SDavid Chisnallswap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, 8377a984708SDavid Chisnall basic_ostringstream<_CharT, _Traits, _Allocator>& __y) 8387a984708SDavid Chisnall{ 8397a984708SDavid Chisnall __x.swap(__y); 8407a984708SDavid Chisnall} 8417a984708SDavid Chisnall 8427a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 8437a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>* 8447a984708SDavid Chisnallbasic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const 8457a984708SDavid Chisnall{ 8467a984708SDavid Chisnall return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_); 8477a984708SDavid Chisnall} 8487a984708SDavid Chisnall 8497a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 8507a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 8517a984708SDavid Chisnallbasic_ostringstream<_CharT, _Traits, _Allocator>::str() const 8527a984708SDavid Chisnall{ 8537a984708SDavid Chisnall return __sb_.str(); 8547a984708SDavid Chisnall} 8557a984708SDavid Chisnall 8567a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 8577a984708SDavid Chisnallvoid 8587a984708SDavid Chisnallbasic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) 8597a984708SDavid Chisnall{ 8607a984708SDavid Chisnall __sb_.str(__s); 8617a984708SDavid Chisnall} 8627a984708SDavid Chisnall 8637a984708SDavid Chisnall// basic_stringstream 8647a984708SDavid Chisnall 8657a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 866aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS basic_stringstream 8677a984708SDavid Chisnall : public basic_iostream<_CharT, _Traits> 8687a984708SDavid Chisnall{ 8697a984708SDavid Chisnallpublic: 8707a984708SDavid Chisnall typedef _CharT char_type; 8717a984708SDavid Chisnall typedef _Traits traits_type; 8727a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 8737a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 8747a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 8757a984708SDavid Chisnall typedef _Allocator allocator_type; 8767a984708SDavid Chisnall 8777a984708SDavid Chisnall typedef basic_string<char_type, traits_type, allocator_type> string_type; 8787a984708SDavid Chisnall 8797a984708SDavid Chisnallprivate: 8807a984708SDavid Chisnall basic_stringbuf<char_type, traits_type, allocator_type> __sb_; 8817a984708SDavid Chisnall 8827a984708SDavid Chisnallpublic: 8837a984708SDavid Chisnall // 27.8.2.1 Constructors: 884aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 8857a984708SDavid Chisnall explicit basic_stringstream(ios_base::openmode __wch = ios_base::in | ios_base::out); 886aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 8877a984708SDavid Chisnall explicit basic_stringstream(const string_type& __s, 8887a984708SDavid Chisnall ios_base::openmode __wch = ios_base::in | ios_base::out); 889540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 890aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 8917a984708SDavid Chisnall basic_stringstream(basic_stringstream&& __rhs); 8927a984708SDavid Chisnall 8937a984708SDavid Chisnall // 27.8.2.2 Assign and swap: 8947a984708SDavid Chisnall basic_stringstream& operator=(basic_stringstream&& __rhs); 895540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 896aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 8977a984708SDavid Chisnall void swap(basic_stringstream& __rhs); 8987a984708SDavid Chisnall 8997a984708SDavid Chisnall // 27.8.2.3 Members: 900aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 9017a984708SDavid Chisnall basic_stringbuf<char_type, traits_type, allocator_type>* rdbuf() const; 902aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 9037a984708SDavid Chisnall string_type str() const; 904aed8d94eSDimitry Andric inline _LIBCPP_INLINE_VISIBILITY 9057a984708SDavid Chisnall void str(const string_type& __s); 9067a984708SDavid Chisnall}; 9077a984708SDavid Chisnall 9087a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 9097a984708SDavid Chisnallbasic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch) 9107a984708SDavid Chisnall : basic_iostream<_CharT, _Traits>(&__sb_), 9117a984708SDavid Chisnall __sb_(__wch) 9127a984708SDavid Chisnall{ 9137a984708SDavid Chisnall} 9147a984708SDavid Chisnall 9157a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 9167a984708SDavid Chisnallbasic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s, 9177a984708SDavid Chisnall ios_base::openmode __wch) 9187a984708SDavid Chisnall : basic_iostream<_CharT, _Traits>(&__sb_), 9197a984708SDavid Chisnall __sb_(__s, __wch) 9207a984708SDavid Chisnall{ 9217a984708SDavid Chisnall} 9227a984708SDavid Chisnall 923540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 9247a984708SDavid Chisnall 9257a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 9267a984708SDavid Chisnallbasic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs) 9277a984708SDavid Chisnall : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)), 9287a984708SDavid Chisnall __sb_(_VSTD::move(__rhs.__sb_)) 9297a984708SDavid Chisnall{ 9307a984708SDavid Chisnall basic_istream<_CharT, _Traits>::set_rdbuf(&__sb_); 9317a984708SDavid Chisnall} 9327a984708SDavid Chisnall 9337a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 9347a984708SDavid Chisnallbasic_stringstream<_CharT, _Traits, _Allocator>& 9357a984708SDavid Chisnallbasic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& __rhs) 9367a984708SDavid Chisnall{ 9377a984708SDavid Chisnall basic_iostream<char_type, traits_type>::operator=(_VSTD::move(__rhs)); 9387a984708SDavid Chisnall __sb_ = _VSTD::move(__rhs.__sb_); 9397a984708SDavid Chisnall return *this; 9407a984708SDavid Chisnall} 9417a984708SDavid Chisnall 942540d2a8bSDimitry Andric#endif // _LIBCPP_CXX03_LANG 9437a984708SDavid Chisnall 9447a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 9457a984708SDavid Chisnallvoid 9467a984708SDavid Chisnallbasic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs) 9477a984708SDavid Chisnall{ 9487a984708SDavid Chisnall basic_iostream<char_type, traits_type>::swap(__rhs); 9497a984708SDavid Chisnall __sb_.swap(__rhs.__sb_); 9507a984708SDavid Chisnall} 9517a984708SDavid Chisnall 9527a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 9537a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9547a984708SDavid Chisnallvoid 9557a984708SDavid Chisnallswap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, 9567a984708SDavid Chisnall basic_stringstream<_CharT, _Traits, _Allocator>& __y) 9577a984708SDavid Chisnall{ 9587a984708SDavid Chisnall __x.swap(__y); 9597a984708SDavid Chisnall} 9607a984708SDavid Chisnall 9617a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 9627a984708SDavid Chisnallbasic_stringbuf<_CharT, _Traits, _Allocator>* 9637a984708SDavid Chisnallbasic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const 9647a984708SDavid Chisnall{ 9657a984708SDavid Chisnall return const_cast<basic_stringbuf<char_type, traits_type, allocator_type>*>(&__sb_); 9667a984708SDavid Chisnall} 9677a984708SDavid Chisnall 9687a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 9697a984708SDavid Chisnallbasic_string<_CharT, _Traits, _Allocator> 9707a984708SDavid Chisnallbasic_stringstream<_CharT, _Traits, _Allocator>::str() const 9717a984708SDavid Chisnall{ 9727a984708SDavid Chisnall return __sb_.str(); 9737a984708SDavid Chisnall} 9747a984708SDavid Chisnall 9757a984708SDavid Chisnalltemplate <class _CharT, class _Traits, class _Allocator> 9767a984708SDavid Chisnallvoid 9777a984708SDavid Chisnallbasic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) 9787a984708SDavid Chisnall{ 9797a984708SDavid Chisnall __sb_.str(__s); 9807a984708SDavid Chisnall} 9817a984708SDavid Chisnall 9827a984708SDavid Chisnall_LIBCPP_END_NAMESPACE_STD 9837a984708SDavid Chisnall 984f9448bf3SDimitry Andric_LIBCPP_POP_MACROS 985f9448bf3SDimitry Andric 9867a984708SDavid Chisnall#endif // _LIBCPP_SSTREAM 987