Commit 497e42fd by Benjamin Kosnik

[multiple changes]


2002-06-08  Paolo Carlini  <pcarlini@unitus.it>

	* testsuite/backwards/strstream_members.cc: New.

2002-06-08  Benjamin Kosnik  <bkoz@redhat.com>

	* include/backwards/strstream: Format.
	* src/strstream.cc: Format.

2002-06-08  Andreas Schwab  <schwab@suse.de>

	* src/strstream.cc (strstreambuf::overflow): Set _M_buf,
	_M_buf_size and _M_buf_size_opt to the new buffer and size.

From-SVN: r54375
parent e3623158
2002-06-08 Paolo Carlini <pcarlini@unitus.it>
* testsuite/backwards/strstream_members.cc: New.
2002-06-08 Benjamin Kosnik <bkoz@redhat.com>
* include/backwards/strstream: Format.
* src/strstream.cc: Format.
2002-06-08 Andreas Schwab <schwab@suse.de>
* src/strstream.cc (strstreambuf::overflow): Set _M_buf,
_M_buf_size and _M_buf_size_opt to the new buffer and size.
2002-06-08 Benjamin Kosnik <bkoz@redhat.com> 2002-06-08 Benjamin Kosnik <bkoz@redhat.com>
* config/os/generic/bits/ctype_noninline.h: Tweak format. * config/os/generic/bits/ctype_noninline.h: Tweak format.
......
// Backward-compat support -*- C++ -*- // Backward-compat support -*- C++ -*-
// Copyright (C) 2001 Free Software Foundation, Inc. // Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -57,132 +57,118 @@ ...@@ -57,132 +57,118 @@
namespace std namespace std
{ {
// Class strstreambuf, a streambuf class that manages an array of char.
//---------------------------------------------------------------------- // Note that this class is not a template.
// Class strstreambuf, a streambuf class that manages an array of char. class strstreambuf : public basic_streambuf<char, char_traits<char> >
// Note that this class is not a template. {
public:
class strstreambuf : public basic_streambuf<char, char_traits<char> > // Types.
{ typedef char_traits<char> _Traits;
public: // Types. typedef basic_streambuf<char, _Traits> _Base;
typedef char_traits<char> _Traits;
typedef basic_streambuf<char, _Traits> _Base; public:
// Constructor, destructor
public: // Constructor, destructor explicit strstreambuf(streamsize __initial_capacity = 0);
explicit strstreambuf(streamsize __initial_capacity = 0); strstreambuf(void* (*__alloc)(size_t), void (*__free)(void*));
strstreambuf(void* (*__alloc)(size_t), void (*__free)(void*));
strstreambuf(char* __get, streamsize __n, char* __put = 0);
strstreambuf(char* __get, streamsize __n, char* __put = 0); strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0);
strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0); strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0);
strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0);
strstreambuf(const char* __get, streamsize __n);
strstreambuf(const char* __get, streamsize __n); strstreambuf(const signed char* __get, streamsize __n);
strstreambuf(const signed char* __get, streamsize __n); strstreambuf(const unsigned char* __get, streamsize __n);
strstreambuf(const unsigned char* __get, streamsize __n);
virtual ~strstreambuf();
virtual ~strstreambuf();
public:
public: // strstreambuf operations. void freeze(bool = true);
void freeze(bool = true); char* str();
char* str(); int pcount() const;
int pcount() const;
protected:
protected: // Overridden virtual member functions. virtual int_type overflow(int_type __c = _Traits::eof());
virtual int_type overflow(int_type __c = _Traits::eof()); virtual int_type pbackfail(int_type __c = _Traits::eof());
virtual int_type pbackfail(int_type __c = _Traits::eof()); virtual int_type underflow();
virtual int_type underflow(); virtual _Base* setbuf(char* __buf, streamsize __n);
virtual _Base* setbuf(char* __buf, streamsize __n); virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir,
virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, ios_base::openmode __mode
ios_base::openmode __mode = ios_base::in | ios_base::out);
= ios_base::in | ios_base::out); virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode = ios_base::in | ios_base::out);
= ios_base::in | ios_base::out);
private:
private: // Helper functions. // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun.
// Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun. char* _M_alloc(size_t);
char* _M_alloc(size_t); void _M_free(char*);
void _M_free(char*);
// Helper function used in constructors.
// Helper function used in constructors. void _M_setup(char* __get, char* __put, streamsize __n);
void _M_setup(char* __get, char* __put, streamsize __n);
private:
private: // Data members. // Data members.
void* (*_M_alloc_fun)(size_t); void* (*_M_alloc_fun)(size_t);
void (*_M_free_fun)(void*); void (*_M_free_fun)(void*);
bool _M_dynamic : 1; bool _M_dynamic : 1;
bool _M_frozen : 1; bool _M_frozen : 1;
bool _M_constant : 1; bool _M_constant : 1;
}; };
//---------------------------------------------------------------------- // Class istrstream, an istream that manages a strstreambuf.
// Class istrstream, an istream that manages a strstreambuf. class istrstream : public basic_istream<char>
{
class istrstream : public basic_istream<char> public:
{ explicit istrstream(char*);
public: explicit istrstream(const char*);
explicit istrstream(char*); istrstream(char* , streamsize);
explicit istrstream(const char*); istrstream(const char*, streamsize);
istrstream(char* , streamsize); virtual ~istrstream();
istrstream(const char*, streamsize);
virtual ~istrstream(); strstreambuf* rdbuf() const;
char* str();
strstreambuf* rdbuf() const;
char* str(); private:
strstreambuf _M_buf;
private: };
strstreambuf _M_buf;
}; // Class ostrstream
class ostrstream : public basic_ostream<char>
//---------------------------------------------------------------------- {
// Class ostrstream public:
ostrstream();
class ostrstream : public basic_ostream<char> ostrstream(char*, int, ios_base::openmode = ios_base::out);
{ virtual ~ostrstream();
public:
ostrstream(); strstreambuf* rdbuf() const;
ostrstream(char*, int, ios_base::openmode = ios_base::out); void freeze(bool = true);
virtual ~ostrstream(); char* str();
int pcount() const;
strstreambuf* rdbuf() const;
void freeze(bool = true); private:
char* str(); strstreambuf _M_buf;
int pcount() const; };
private: // Class strstream
strstreambuf _M_buf; class strstream : public basic_iostream<char>
}; {
public:
//---------------------------------------------------------------------- typedef char char_type;
// Class strstream typedef char_traits<char>::int_type int_type;
typedef char_traits<char>::pos_type pos_type;
class strstream : public basic_iostream<char> typedef char_traits<char>::off_type off_type;
{
public: strstream();
typedef char char_type; strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out);
typedef char_traits<char>::int_type int_type; virtual ~strstream();
typedef char_traits<char>::pos_type pos_type;
typedef char_traits<char>::off_type off_type; strstreambuf* rdbuf() const;
void freeze(bool = true);
strstream(); int pcount() const;
strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out); char* str();
virtual ~strstream();
private:
strstreambuf* rdbuf() const; strstreambuf _M_buf;
void freeze(bool = true); };
int pcount() const;
char* str();
private:
strstreambuf _M_buf;
};
} // namespace std } // namespace std
#endif
#endif /* __SGI_STL_STRSTREAM */
// Local Variables:
// mode:C++
// End:
// Copyright (C) 2002 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License along
// with this library; see the file COPYING. If not, write to the Free
// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
// backward strstream members
#include <strstream.h>
#include <testsuite_hooks.h>
// { dg-options "-Wno-deprecated" }
int test01()
{
strstream s;
for (unsigned i=0 ; i!= 1000 ; ++i)
s << i << std::endl;
s << std::ends;
return 0;
}
int main()
{
test01();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment