xref: /dflybsd-src/contrib/gcc-4.7/libstdc++-v3/src/c++98/strstream.cc (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino // strstream definitions -*- C++ -*-
2*e4b17023SJohn Marino 
3*e4b17023SJohn Marino // Copyright (C) 2001, 2002, 2003, 2005, 2009, 2010, 2011
4*e4b17023SJohn Marino // Free Software Foundation
5*e4b17023SJohn Marino //
6*e4b17023SJohn Marino // This file is part of the GNU ISO C++ Library.  This library is free
7*e4b17023SJohn Marino // software; you can redistribute it and/or modify it under the
8*e4b17023SJohn Marino // terms of the GNU General Public License as published by the
9*e4b17023SJohn Marino // Free Software Foundation; either version 3, or (at your option)
10*e4b17023SJohn Marino // any later version.
11*e4b17023SJohn Marino 
12*e4b17023SJohn Marino // This library is distributed in the hope that it will be useful,
13*e4b17023SJohn Marino // but WITHOUT ANY WARRANTY; without even the implied warranty of
14*e4b17023SJohn Marino // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15*e4b17023SJohn Marino // GNU General Public License for more details.
16*e4b17023SJohn Marino 
17*e4b17023SJohn Marino // Under Section 7 of GPL version 3, you are granted additional
18*e4b17023SJohn Marino // permissions described in the GCC Runtime Library Exception, version
19*e4b17023SJohn Marino // 3.1, as published by the Free Software Foundation.
20*e4b17023SJohn Marino 
21*e4b17023SJohn Marino // You should have received a copy of the GNU General Public License and
22*e4b17023SJohn Marino // a copy of the GCC Runtime Library Exception along with this program;
23*e4b17023SJohn Marino // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24*e4b17023SJohn Marino // <http://www.gnu.org/licenses/>.
25*e4b17023SJohn Marino 
26*e4b17023SJohn Marino /*
27*e4b17023SJohn Marino  * Copyright (c) 1998
28*e4b17023SJohn Marino  * Silicon Graphics Computer Systems, Inc.
29*e4b17023SJohn Marino  *
30*e4b17023SJohn Marino  * Permission to use, copy, modify, distribute and sell this software
31*e4b17023SJohn Marino  * and its documentation for any purpose is hereby granted without fee,
32*e4b17023SJohn Marino  * provided that the above copyright notice appear in all copies and
33*e4b17023SJohn Marino  * that both that copyright notice and this permission notice appear
34*e4b17023SJohn Marino  * in supporting documentation.  Silicon Graphics makes no
35*e4b17023SJohn Marino  * representations about the suitability of this software for any
36*e4b17023SJohn Marino  * purpose.  It is provided "as is" without express or implied warranty.
37*e4b17023SJohn Marino  */
38*e4b17023SJohn Marino 
39*e4b17023SJohn Marino // Implementation of the classes in header <strstream>.
40*e4b17023SJohn Marino // WARNING: The classes defined in <strstream> are DEPRECATED.  This
41*e4b17023SJohn Marino // header is defined in section D.7.1 of the C++ standard, and it
42*e4b17023SJohn Marino // MAY BE REMOVED in a future standard revision.  You should use the
43*e4b17023SJohn Marino // header <sstream> instead.
44*e4b17023SJohn Marino 
45*e4b17023SJohn Marino #include <strstream>
46*e4b17023SJohn Marino #include <algorithm>
47*e4b17023SJohn Marino #include <new>
48*e4b17023SJohn Marino #include <stdlib.h>
49*e4b17023SJohn Marino #include <string.h>
50*e4b17023SJohn Marino #include <limits.h>
51*e4b17023SJohn Marino 
52*e4b17023SJohn Marino namespace std _GLIBCXX_VISIBILITY(default)
53*e4b17023SJohn Marino {
54*e4b17023SJohn Marino _GLIBCXX_BEGIN_NAMESPACE_VERSION
55*e4b17023SJohn Marino 
strstreambuf(streamsize initial_capacity)56*e4b17023SJohn Marino   strstreambuf::strstreambuf(streamsize initial_capacity)
57*e4b17023SJohn Marino   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(true),
58*e4b17023SJohn Marino     _M_frozen(false), _M_constant(false)
59*e4b17023SJohn Marino   {
60*e4b17023SJohn Marino     streamsize n = std::max(initial_capacity, streamsize(16));
61*e4b17023SJohn Marino 
62*e4b17023SJohn Marino     char* buf = _M_alloc(n);
63*e4b17023SJohn Marino     if (buf)
64*e4b17023SJohn Marino       {
65*e4b17023SJohn Marino 	setp(buf, buf + n);
66*e4b17023SJohn Marino 	setg(buf, buf, buf);
67*e4b17023SJohn Marino       }
68*e4b17023SJohn Marino   }
69*e4b17023SJohn Marino 
strstreambuf(void * (* alloc_f)(size_t),void (* free_f)(void *))70*e4b17023SJohn Marino   strstreambuf::strstreambuf(void* (*alloc_f)(size_t), void (*free_f)(void*))
71*e4b17023SJohn Marino   : _Base(), _M_alloc_fun(alloc_f), _M_free_fun(free_f), _M_dynamic(true),
72*e4b17023SJohn Marino     _M_frozen(false), _M_constant(false)
73*e4b17023SJohn Marino   {
74*e4b17023SJohn Marino     streamsize n = 16;
75*e4b17023SJohn Marino 
76*e4b17023SJohn Marino     char* buf = _M_alloc(n);
77*e4b17023SJohn Marino     if (buf)
78*e4b17023SJohn Marino       {
79*e4b17023SJohn Marino 	setp(buf, buf + n);
80*e4b17023SJohn Marino 	setg(buf, buf, buf);
81*e4b17023SJohn Marino       }
82*e4b17023SJohn Marino   }
83*e4b17023SJohn Marino 
strstreambuf(char * get,streamsize n,char * put)84*e4b17023SJohn Marino   strstreambuf::strstreambuf(char* get, streamsize n, char* put) throw ()
85*e4b17023SJohn Marino   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
86*e4b17023SJohn Marino     _M_frozen(false), _M_constant(false)
87*e4b17023SJohn Marino   { _M_setup(get, put, n); }
88*e4b17023SJohn Marino 
strstreambuf(signed char * get,streamsize n,signed char * put)89*e4b17023SJohn Marino   strstreambuf::strstreambuf(signed char* get, streamsize n, signed char* put) throw ()
90*e4b17023SJohn Marino   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
91*e4b17023SJohn Marino   _M_frozen(false), _M_constant(false)
92*e4b17023SJohn Marino   { _M_setup(reinterpret_cast<char*>(get), reinterpret_cast<char*>(put), n); }
93*e4b17023SJohn Marino 
strstreambuf(unsigned char * get,streamsize n,unsigned char * put)94*e4b17023SJohn Marino   strstreambuf::strstreambuf(unsigned char* get, streamsize n,
95*e4b17023SJohn Marino 			     unsigned char* put) throw ()
96*e4b17023SJohn Marino   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
97*e4b17023SJohn Marino     _M_frozen(false), _M_constant(false)
98*e4b17023SJohn Marino   { _M_setup(reinterpret_cast<char*>(get), reinterpret_cast<char*>(put), n); }
99*e4b17023SJohn Marino 
strstreambuf(const char * get,streamsize n)100*e4b17023SJohn Marino   strstreambuf::strstreambuf(const char* get, streamsize n) throw ()
101*e4b17023SJohn Marino   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
102*e4b17023SJohn Marino     _M_frozen(false), _M_constant(true)
103*e4b17023SJohn Marino   { _M_setup(const_cast<char*>(get), 0, n); }
104*e4b17023SJohn Marino 
strstreambuf(const signed char * get,streamsize n)105*e4b17023SJohn Marino   strstreambuf::strstreambuf(const signed char* get, streamsize n) throw ()
106*e4b17023SJohn Marino   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
107*e4b17023SJohn Marino     _M_frozen(false), _M_constant(true)
108*e4b17023SJohn Marino   { _M_setup(reinterpret_cast<char*>(const_cast<signed char*>(get)), 0, n); }
109*e4b17023SJohn Marino 
strstreambuf(const unsigned char * get,streamsize n)110*e4b17023SJohn Marino   strstreambuf::strstreambuf(const unsigned char* get, streamsize n) throw ()
111*e4b17023SJohn Marino   : _Base(), _M_alloc_fun(0), _M_free_fun(0), _M_dynamic(false),
112*e4b17023SJohn Marino     _M_frozen(false), _M_constant(true)
113*e4b17023SJohn Marino   { _M_setup(reinterpret_cast<char*>(const_cast<unsigned char*>(get)), 0, n); }
114*e4b17023SJohn Marino 
~strstreambuf()115*e4b17023SJohn Marino   strstreambuf::~strstreambuf()
116*e4b17023SJohn Marino   {
117*e4b17023SJohn Marino     if (_M_dynamic && !_M_frozen)
118*e4b17023SJohn Marino       _M_free(eback());
119*e4b17023SJohn Marino   }
120*e4b17023SJohn Marino 
121*e4b17023SJohn Marino   void
freeze(bool frozenflag)122*e4b17023SJohn Marino   strstreambuf::freeze(bool frozenflag) throw ()
123*e4b17023SJohn Marino   {
124*e4b17023SJohn Marino     if (_M_dynamic)
125*e4b17023SJohn Marino       _M_frozen = frozenflag;
126*e4b17023SJohn Marino   }
127*e4b17023SJohn Marino 
128*e4b17023SJohn Marino   char*
str()129*e4b17023SJohn Marino   strstreambuf::str() throw ()
130*e4b17023SJohn Marino   {
131*e4b17023SJohn Marino     freeze(true);
132*e4b17023SJohn Marino     return eback();
133*e4b17023SJohn Marino   }
134*e4b17023SJohn Marino 
135*e4b17023SJohn Marino   int
pcount() const136*e4b17023SJohn Marino   strstreambuf::pcount() const throw ()
137*e4b17023SJohn Marino   { return pptr() ? pptr() - pbase() : 0; }
138*e4b17023SJohn Marino 
139*e4b17023SJohn Marino   strstreambuf::int_type
overflow(int_type c)140*e4b17023SJohn Marino   strstreambuf::overflow(int_type c)
141*e4b17023SJohn Marino   {
142*e4b17023SJohn Marino     if (c == traits_type::eof())
143*e4b17023SJohn Marino       return traits_type::not_eof(c);
144*e4b17023SJohn Marino 
145*e4b17023SJohn Marino     // Try to expand the buffer.
146*e4b17023SJohn Marino     if (pptr() == epptr() && _M_dynamic && !_M_frozen && !_M_constant)
147*e4b17023SJohn Marino       {
148*e4b17023SJohn Marino 	ptrdiff_t old_size = epptr() - pbase();
149*e4b17023SJohn Marino 	ptrdiff_t new_size = std::max(ptrdiff_t(2 * old_size), ptrdiff_t(1));
150*e4b17023SJohn Marino 
151*e4b17023SJohn Marino 	char* buf = _M_alloc(new_size);
152*e4b17023SJohn Marino 	if (buf)
153*e4b17023SJohn Marino 	  {
154*e4b17023SJohn Marino 	    memcpy(buf, pbase(), old_size);
155*e4b17023SJohn Marino 	    char* old_buffer = pbase();
156*e4b17023SJohn Marino 	    bool reposition_get = false;
157*e4b17023SJohn Marino 	    ptrdiff_t old_get_offset;
158*e4b17023SJohn Marino 	    if (gptr() != 0)
159*e4b17023SJohn Marino 	      {
160*e4b17023SJohn Marino 		reposition_get = true;
161*e4b17023SJohn Marino 		old_get_offset = gptr() - eback();
162*e4b17023SJohn Marino 	      }
163*e4b17023SJohn Marino 
164*e4b17023SJohn Marino 	    setp(buf, buf + new_size);
165*e4b17023SJohn Marino 	    __safe_pbump(old_size);
166*e4b17023SJohn Marino 
167*e4b17023SJohn Marino 	    if (reposition_get)
168*e4b17023SJohn Marino 	      setg(buf, buf + old_get_offset, buf +
169*e4b17023SJohn Marino 		   std::max(old_get_offset, old_size));
170*e4b17023SJohn Marino 
171*e4b17023SJohn Marino 	    _M_free(old_buffer);
172*e4b17023SJohn Marino 	  }
173*e4b17023SJohn Marino       }
174*e4b17023SJohn Marino 
175*e4b17023SJohn Marino     if (pptr() != epptr())
176*e4b17023SJohn Marino       {
177*e4b17023SJohn Marino 	*pptr() = c;
178*e4b17023SJohn Marino 	pbump(1);
179*e4b17023SJohn Marino 	return c;
180*e4b17023SJohn Marino       }
181*e4b17023SJohn Marino     else
182*e4b17023SJohn Marino       return traits_type::eof();
183*e4b17023SJohn Marino   }
184*e4b17023SJohn Marino 
185*e4b17023SJohn Marino   strstreambuf::int_type
pbackfail(int_type c)186*e4b17023SJohn Marino   strstreambuf::pbackfail(int_type c)
187*e4b17023SJohn Marino   {
188*e4b17023SJohn Marino     if (gptr() != eback())
189*e4b17023SJohn Marino       {
190*e4b17023SJohn Marino       if (c == _Traits::eof())
191*e4b17023SJohn Marino 	{
192*e4b17023SJohn Marino 	  gbump(-1);
193*e4b17023SJohn Marino 	  return _Traits::not_eof(c);
194*e4b17023SJohn Marino 	}
195*e4b17023SJohn Marino       else if (c == _Traits::to_int_type(gptr()[-1]))
196*e4b17023SJohn Marino 	{  // KLUDGE
197*e4b17023SJohn Marino 	  gbump(-1);
198*e4b17023SJohn Marino 	  return c;
199*e4b17023SJohn Marino 	}
200*e4b17023SJohn Marino       else if (!_M_constant)
201*e4b17023SJohn Marino 	{
202*e4b17023SJohn Marino 	  gbump(-1);
203*e4b17023SJohn Marino 	  *gptr() = c;
204*e4b17023SJohn Marino 	  return c;
205*e4b17023SJohn Marino 	}
206*e4b17023SJohn Marino     }
207*e4b17023SJohn Marino     return _Traits::eof();
208*e4b17023SJohn Marino   }
209*e4b17023SJohn Marino 
210*e4b17023SJohn Marino   strstreambuf::int_type
underflow()211*e4b17023SJohn Marino   strstreambuf::underflow()
212*e4b17023SJohn Marino   {
213*e4b17023SJohn Marino     if (gptr() == egptr() && pptr() && pptr() > egptr())
214*e4b17023SJohn Marino       setg(eback(), gptr(), pptr());
215*e4b17023SJohn Marino 
216*e4b17023SJohn Marino     if (gptr() != egptr())
217*e4b17023SJohn Marino       return (unsigned char) *gptr();
218*e4b17023SJohn Marino     else
219*e4b17023SJohn Marino       return _Traits::eof();
220*e4b17023SJohn Marino   }
221*e4b17023SJohn Marino 
222*e4b17023SJohn Marino   basic_streambuf<char, char_traits<char> >*
setbuf(char *,streamsize)223*e4b17023SJohn Marino   strstreambuf::setbuf(char*, streamsize)
224*e4b17023SJohn Marino   { return this; }
225*e4b17023SJohn Marino 
226*e4b17023SJohn Marino   strstreambuf::pos_type
seekoff(off_type off,ios_base::seekdir dir,ios_base::openmode mode)227*e4b17023SJohn Marino   strstreambuf::seekoff(off_type off, ios_base::seekdir dir,
228*e4b17023SJohn Marino 			ios_base::openmode mode)
229*e4b17023SJohn Marino   {
230*e4b17023SJohn Marino     bool do_get = false;
231*e4b17023SJohn Marino     bool do_put = false;
232*e4b17023SJohn Marino 
233*e4b17023SJohn Marino     if ((mode & (ios_base::in | ios_base::out))
234*e4b17023SJohn Marino 	== (ios_base::in | ios_base::out) &&
235*e4b17023SJohn Marino 	(dir == ios_base::beg || dir == ios_base::end))
236*e4b17023SJohn Marino       do_get = do_put = true;
237*e4b17023SJohn Marino     else if (mode & ios_base::in)
238*e4b17023SJohn Marino       do_get = true;
239*e4b17023SJohn Marino     else if (mode & ios_base::out)
240*e4b17023SJohn Marino       do_put = true;
241*e4b17023SJohn Marino 
242*e4b17023SJohn Marino     // !gptr() is here because, according to D.7.1 paragraph 4, the seekable
243*e4b17023SJohn Marino     // area is undefined if there is no get area.
244*e4b17023SJohn Marino     if ((!do_get && !do_put) || (do_put && !pptr()) || !gptr())
245*e4b17023SJohn Marino       return pos_type(off_type(-1));
246*e4b17023SJohn Marino 
247*e4b17023SJohn Marino     char* seeklow  = eback();
248*e4b17023SJohn Marino     char* seekhigh = epptr() ? epptr() : egptr();
249*e4b17023SJohn Marino 
250*e4b17023SJohn Marino     off_type newoff;
251*e4b17023SJohn Marino     switch (dir)
252*e4b17023SJohn Marino       {
253*e4b17023SJohn Marino       case ios_base::beg:
254*e4b17023SJohn Marino 	newoff = 0;
255*e4b17023SJohn Marino 	break;
256*e4b17023SJohn Marino       case ios_base::end:
257*e4b17023SJohn Marino 	newoff = seekhigh - seeklow;
258*e4b17023SJohn Marino 	break;
259*e4b17023SJohn Marino       case ios_base::cur:
260*e4b17023SJohn Marino 	newoff = do_put ? pptr() - seeklow : gptr() - seeklow;
261*e4b17023SJohn Marino 	break;
262*e4b17023SJohn Marino       default:
263*e4b17023SJohn Marino 	return pos_type(off_type(-1));
264*e4b17023SJohn Marino       }
265*e4b17023SJohn Marino 
266*e4b17023SJohn Marino     off += newoff;
267*e4b17023SJohn Marino     if (off < 0 || off > seekhigh - seeklow)
268*e4b17023SJohn Marino       return pos_type(off_type(-1));
269*e4b17023SJohn Marino 
270*e4b17023SJohn Marino     if (do_put)
271*e4b17023SJohn Marino       {
272*e4b17023SJohn Marino 	if (seeklow + off < pbase())
273*e4b17023SJohn Marino 	  {
274*e4b17023SJohn Marino 	    setp(seeklow, epptr());
275*e4b17023SJohn Marino 	    __safe_pbump(off);
276*e4b17023SJohn Marino 	  }
277*e4b17023SJohn Marino 	else
278*e4b17023SJohn Marino 	  {
279*e4b17023SJohn Marino 	    setp(pbase(), epptr());
280*e4b17023SJohn Marino 	    __safe_pbump(off - (pbase() - seeklow));
281*e4b17023SJohn Marino 	  }
282*e4b17023SJohn Marino       }
283*e4b17023SJohn Marino     if (do_get)
284*e4b17023SJohn Marino       {
285*e4b17023SJohn Marino 	if (off <= egptr() - seeklow)
286*e4b17023SJohn Marino 	  setg(seeklow, seeklow + off, egptr());
287*e4b17023SJohn Marino 	else if (off <= pptr() - seeklow)
288*e4b17023SJohn Marino 	  setg(seeklow, seeklow + off, pptr());
289*e4b17023SJohn Marino 	else
290*e4b17023SJohn Marino 	  setg(seeklow, seeklow + off, epptr());
291*e4b17023SJohn Marino       }
292*e4b17023SJohn Marino     return pos_type(newoff);
293*e4b17023SJohn Marino   }
294*e4b17023SJohn Marino 
295*e4b17023SJohn Marino   strstreambuf::pos_type
seekpos(pos_type pos,ios_base::openmode mode)296*e4b17023SJohn Marino   strstreambuf::seekpos(pos_type pos, ios_base::openmode mode)
297*e4b17023SJohn Marino   { return seekoff(pos - pos_type(off_type(0)), ios_base::beg, mode); }
298*e4b17023SJohn Marino 
299*e4b17023SJohn Marino   char*
_M_alloc(size_t n)300*e4b17023SJohn Marino   strstreambuf::_M_alloc(size_t n)
301*e4b17023SJohn Marino   {
302*e4b17023SJohn Marino     if (_M_alloc_fun)
303*e4b17023SJohn Marino       return static_cast<char*>(_M_alloc_fun(n));
304*e4b17023SJohn Marino     else
305*e4b17023SJohn Marino       return new char[n];
306*e4b17023SJohn Marino   }
307*e4b17023SJohn Marino 
308*e4b17023SJohn Marino   void
_M_free(char * p)309*e4b17023SJohn Marino   strstreambuf::_M_free(char* p)
310*e4b17023SJohn Marino   {
311*e4b17023SJohn Marino     if (p)
312*e4b17023SJohn Marino       {
313*e4b17023SJohn Marino 	if (_M_free_fun)
314*e4b17023SJohn Marino 	  _M_free_fun(p);
315*e4b17023SJohn Marino 	else
316*e4b17023SJohn Marino 	  delete[] p;
317*e4b17023SJohn Marino       }
318*e4b17023SJohn Marino   }
319*e4b17023SJohn Marino 
320*e4b17023SJohn Marino   void
_M_setup(char * get,char * put,streamsize n)321*e4b17023SJohn Marino   strstreambuf::_M_setup(char* get, char* put, streamsize n) throw ()
322*e4b17023SJohn Marino   {
323*e4b17023SJohn Marino     if (get)
324*e4b17023SJohn Marino       {
325*e4b17023SJohn Marino 	size_t N = n > 0 ? size_t(n) : n == 0 ? strlen(get) : size_t(INT_MAX);
326*e4b17023SJohn Marino 
327*e4b17023SJohn Marino 	if (put)
328*e4b17023SJohn Marino 	  {
329*e4b17023SJohn Marino 	    setg(get, get, put);
330*e4b17023SJohn Marino 	    setp(put, put + N);
331*e4b17023SJohn Marino 	  }
332*e4b17023SJohn Marino 	else
333*e4b17023SJohn Marino 	  setg(get, get, get + N);
334*e4b17023SJohn Marino       }
335*e4b17023SJohn Marino   }
336*e4b17023SJohn Marino 
istrstream(char * s)337*e4b17023SJohn Marino   istrstream::istrstream(char* s)
338*e4b17023SJohn Marino   : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, 0)
339*e4b17023SJohn Marino   { basic_ios<char>::init(&_M_buf); }
340*e4b17023SJohn Marino 
istrstream(const char * s)341*e4b17023SJohn Marino   istrstream::istrstream(const char* s)
342*e4b17023SJohn Marino   : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, 0)
343*e4b17023SJohn Marino   { basic_ios<char>::init(&_M_buf); }
344*e4b17023SJohn Marino 
istrstream(char * s,streamsize n)345*e4b17023SJohn Marino   istrstream::istrstream(char* s, streamsize n)
346*e4b17023SJohn Marino   : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n)
347*e4b17023SJohn Marino   { basic_ios<char>::init(&_M_buf); }
348*e4b17023SJohn Marino 
istrstream(const char * s,streamsize n)349*e4b17023SJohn Marino   istrstream::istrstream(const char* s, streamsize n)
350*e4b17023SJohn Marino   : basic_ios<char>(), basic_istream<char>(0), _M_buf(s, n)
351*e4b17023SJohn Marino   { basic_ios<char>::init(&_M_buf); }
352*e4b17023SJohn Marino 
~istrstream()353*e4b17023SJohn Marino   istrstream::~istrstream() { }
354*e4b17023SJohn Marino 
355*e4b17023SJohn Marino   strstreambuf*
rdbuf() const356*e4b17023SJohn Marino   istrstream::rdbuf() const throw ()
357*e4b17023SJohn Marino   { return const_cast<strstreambuf*>(&_M_buf); }
358*e4b17023SJohn Marino 
359*e4b17023SJohn Marino   char*
str()360*e4b17023SJohn Marino   istrstream::str() throw ()
361*e4b17023SJohn Marino   { return _M_buf.str(); }
362*e4b17023SJohn Marino 
ostrstream()363*e4b17023SJohn Marino   ostrstream::ostrstream()
364*e4b17023SJohn Marino   : basic_ios<char>(), basic_ostream<char>(0), _M_buf()
365*e4b17023SJohn Marino   { basic_ios<char>::init(&_M_buf); }
366*e4b17023SJohn Marino 
ostrstream(char * s,int n,ios_base::openmode mode)367*e4b17023SJohn Marino   ostrstream::ostrstream(char* s, int n, ios_base::openmode mode)
368*e4b17023SJohn Marino   : basic_ios<char>(), basic_ostream<char>(0),
369*e4b17023SJohn Marino     _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s)
370*e4b17023SJohn Marino   { basic_ios<char>::init(&_M_buf); }
371*e4b17023SJohn Marino 
~ostrstream()372*e4b17023SJohn Marino   ostrstream::~ostrstream() {}
373*e4b17023SJohn Marino 
374*e4b17023SJohn Marino   strstreambuf*
rdbuf() const375*e4b17023SJohn Marino   ostrstream::rdbuf() const throw ()
376*e4b17023SJohn Marino   { return const_cast<strstreambuf*>(&_M_buf); }
377*e4b17023SJohn Marino 
378*e4b17023SJohn Marino   void
freeze(bool freezeflag)379*e4b17023SJohn Marino   ostrstream::freeze(bool freezeflag) throw ()
380*e4b17023SJohn Marino   { _M_buf.freeze(freezeflag); }
381*e4b17023SJohn Marino 
382*e4b17023SJohn Marino   char*
str()383*e4b17023SJohn Marino   ostrstream::str() throw ()
384*e4b17023SJohn Marino   { return _M_buf.str(); }
385*e4b17023SJohn Marino 
386*e4b17023SJohn Marino   int
pcount() const387*e4b17023SJohn Marino   ostrstream::pcount() const throw ()
388*e4b17023SJohn Marino   { return _M_buf.pcount(); }
389*e4b17023SJohn Marino 
strstream()390*e4b17023SJohn Marino   strstream::strstream()
391*e4b17023SJohn Marino   : basic_ios<char>(), basic_iostream<char>(0), _M_buf()
392*e4b17023SJohn Marino   { basic_ios<char>::init(&_M_buf); }
393*e4b17023SJohn Marino 
strstream(char * s,int n,ios_base::openmode mode)394*e4b17023SJohn Marino   strstream::strstream(char* s, int n, ios_base::openmode mode)
395*e4b17023SJohn Marino   : basic_ios<char>(), basic_iostream<char>(0),
396*e4b17023SJohn Marino     _M_buf(s, n, mode & ios_base::app ? s + strlen(s) : s)
397*e4b17023SJohn Marino   { basic_ios<char>::init(&_M_buf); }
398*e4b17023SJohn Marino 
~strstream()399*e4b17023SJohn Marino   strstream::~strstream() { }
400*e4b17023SJohn Marino 
401*e4b17023SJohn Marino   strstreambuf*
rdbuf() const402*e4b17023SJohn Marino   strstream::rdbuf() const throw ()
403*e4b17023SJohn Marino   { return const_cast<strstreambuf*>(&_M_buf); }
404*e4b17023SJohn Marino 
405*e4b17023SJohn Marino   void
freeze(bool freezeflag)406*e4b17023SJohn Marino   strstream::freeze(bool freezeflag) throw ()
407*e4b17023SJohn Marino   { _M_buf.freeze(freezeflag); }
408*e4b17023SJohn Marino 
409*e4b17023SJohn Marino   int
pcount() const410*e4b17023SJohn Marino   strstream::pcount() const throw ()
411*e4b17023SJohn Marino   { return _M_buf.pcount(); }
412*e4b17023SJohn Marino 
413*e4b17023SJohn Marino   char*
str()414*e4b17023SJohn Marino   strstream::str() throw ()
415*e4b17023SJohn Marino   { return _M_buf.str(); }
416*e4b17023SJohn Marino 
417*e4b17023SJohn Marino _GLIBCXX_END_NAMESPACE_VERSION
418*e4b17023SJohn Marino } // namespace
419