Commit cd16e04b by Paolo Carlini Committed by Paolo Carlini

std_streambuf.h (_M_mode): Move from here to filebuf and stringbuf.

2003-06-30  Paolo Carlini  <pcarlini@unitus.it>

	* include/std/std_streambuf.h (_M_mode): Move from here to
	filebuf and stringbuf.
	(~basic_streambuf()): Don't set _M_mode.
	(basic_streambuf()): Don't set _M_mode.
	* include/std/std_fstream.h (_M_mode): Move here, from streambuf.
	(~basic_filebuf()): Clean up.
	* include/bits/fstream.tcc (basic_filebuf()): Set _M_mode.
	* include/std/std_sstream.h (_M_mode): Move here, from streambuf.
	* testsuite/27_io/basic_streambuf/cons/char/1.cc: Don't set _M_mode.
	* testsuite/27_io/basic_streambuf/overflow/char/1.cc: Likewise.
	* testsuite/27_io/basic_streambuf/sgetc/char/1.cc: Likewise.
	* testsuite/27_io/basic_streambuf/sgetn/char/1.cc: Likewise.
	* testsuite/27_io/basic_streambuf/sputn/char/1.cc: Likewise.

2003-06-30  Paolo Carlini  <pcarlini@unitus.it>

	* include/std/std_fstream.h (_M_underflow): Remove.
	(uflow): Remove, inherited from streambuf.
	(underflow): Only declare.
	* include/bits/fstream.tcc (_M_underflow): Rename to
	underflow, to which is equivalent for __bump == false,
	simplify.
	* include/std/std_sstream.h (_M_underflow): Remove.
	(uflow): Remove, inherited from streambuf.
	(underflow): Only declare.
	* include/bits/sstream.tcc (_M_underflow): Rename to
	underflow, to which is equivalent for __bump == false,
	simplify.

From-SVN: r68695
parent 3cf54412
2003-06-30 Paolo Carlini <pcarlini@unitus.it>
* include/std/std_streambuf.h (_M_mode): Move from here to
filebuf and stringbuf.
(~basic_streambuf()): Don't set _M_mode.
(basic_streambuf()): Don't set _M_mode.
* include/std/std_fstream.h (_M_mode): Move here, from streambuf.
(~basic_filebuf()): Clean up.
* include/bits/fstream.tcc (basic_filebuf()): Set _M_mode.
* include/std/std_sstream.h (_M_mode): Move here, from streambuf.
* testsuite/27_io/basic_streambuf/cons/char/1.cc: Don't set _M_mode.
* testsuite/27_io/basic_streambuf/overflow/char/1.cc: Likewise.
* testsuite/27_io/basic_streambuf/sgetc/char/1.cc: Likewise.
* testsuite/27_io/basic_streambuf/sgetn/char/1.cc: Likewise.
* testsuite/27_io/basic_streambuf/sputn/char/1.cc: Likewise.
2003-06-30 Paolo Carlini <pcarlini@unitus.it>
* include/std/std_fstream.h (_M_underflow): Remove.
(uflow): Remove, inherited from streambuf.
(underflow): Only declare.
* include/bits/fstream.tcc (_M_underflow): Rename to
underflow, to which is equivalent for __bump == false,
simplify.
* include/std/std_sstream.h (_M_underflow): Remove.
(uflow): Remove, inherited from streambuf.
(underflow): Only declare.
* include/bits/sstream.tcc (_M_underflow): Rename to
underflow, to which is equivalent for __bump == false,
simplify.
2003-06-29 Paolo Carlini <pcarlini@unitus.it> 2003-06-29 Paolo Carlini <pcarlini@unitus.it>
* include/bits/stl_algo.h (LOTS): Fully qualify standard * include/bits/stl_algo.h (LOTS): Fully qualify standard
......
...@@ -69,11 +69,11 @@ namespace std ...@@ -69,11 +69,11 @@ namespace std
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
basic_filebuf<_CharT, _Traits>:: basic_filebuf<_CharT, _Traits>::
basic_filebuf() : __streambuf_type(), _M_file(&_M_lock), basic_filebuf() : __streambuf_type(), _M_file(&_M_lock),
_M_state_cur(__state_type()), _M_state_beg(__state_type()), _M_mode(ios_base::openmode(0)), _M_state_cur(__state_type()),
_M_buf(NULL), _M_buf_size(BUFSIZ), _M_buf_allocated(false), _M_state_beg(__state_type()), _M_buf(NULL), _M_buf_size(BUFSIZ),
_M_reading(false), _M_writing(false), _M_last_overflowed(false), _M_buf_allocated(false), _M_reading(false), _M_writing(false),
_M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false), _M_last_overflowed(false), _M_pback_cur_save(0), _M_pback_end_save(0),
_M_codecvt(0) _M_pback_init(false), _M_codecvt(0)
{ {
if (has_facet<__codecvt_type>(this->_M_buf_locale)) if (has_facet<__codecvt_type>(this->_M_buf_locale))
_M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale); _M_codecvt = &use_facet<__codecvt_type>(this->_M_buf_locale);
...@@ -180,7 +180,7 @@ namespace std ...@@ -180,7 +180,7 @@ namespace std
template<typename _CharT, typename _Traits> template<typename _CharT, typename _Traits>
typename basic_filebuf<_CharT, _Traits>::int_type typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>:: basic_filebuf<_CharT, _Traits>::
_M_underflow(bool __bump) underflow()
{ {
int_type __ret = traits_type::eof(); int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in; const bool __testin = this->_M_mode & ios_base::in;
...@@ -194,12 +194,7 @@ namespace std ...@@ -194,12 +194,7 @@ namespace std
_M_destroy_pback(); _M_destroy_pback();
if (this->gptr() < this->egptr()) if (this->gptr() < this->egptr())
{ return traits_type::to_int_type(*this->gptr());
__ret = traits_type::to_int_type(*this->gptr());
if (__bump)
this->gbump(1);
return __ret;
}
// Get and convert input sequence. // Get and convert input sequence.
const size_t __buflen = this->_M_buf_size > 1 const size_t __buflen = this->_M_buf_size > 1
...@@ -247,8 +242,6 @@ namespace std ...@@ -247,8 +242,6 @@ namespace std
_M_set_buffer(__ilen); _M_set_buffer(__ilen);
_M_reading = true; _M_reading = true;
__ret = traits_type::to_int_type(*this->gptr()); __ret = traits_type::to_int_type(*this->gptr());
if (__bump)
this->gbump(1);
} }
else if (__elen == 0) else if (__elen == 0)
{ {
......
...@@ -115,7 +115,7 @@ namespace std ...@@ -115,7 +115,7 @@ namespace std
template <class _CharT, class _Traits, class _Alloc> template <class _CharT, class _Traits, class _Alloc>
typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type typename basic_stringbuf<_CharT, _Traits, _Alloc>::int_type
basic_stringbuf<_CharT, _Traits, _Alloc>:: basic_stringbuf<_CharT, _Traits, _Alloc>::
_M_underflow(bool __bump) underflow()
{ {
int_type __ret = traits_type::eof(); int_type __ret = traits_type::eof();
const bool __testin = this->_M_mode & ios_base::in; const bool __testin = this->_M_mode & ios_base::in;
...@@ -125,11 +125,7 @@ namespace std ...@@ -125,11 +125,7 @@ namespace std
_M_update_egptr(); _M_update_egptr();
if (this->gptr() < this->egptr()) if (this->gptr() < this->egptr())
{
__ret = traits_type::to_int_type(*this->gptr()); __ret = traits_type::to_int_type(*this->gptr());
if (__bump)
this->gbump(1);
}
} }
return __ret; return __ret;
} }
......
...@@ -105,6 +105,13 @@ namespace std ...@@ -105,6 +105,13 @@ namespace std
*/ */
__file_type _M_file; __file_type _M_file;
/**
* @if maint
* Place to stash in || out || in | out settings for current filebuf.
* @endif
*/
ios_base::openmode _M_mode;
// Current and beginning state type for codecvt. // Current and beginning state type for codecvt.
/** /**
* @if maint * @if maint
...@@ -213,8 +220,6 @@ namespace std ...@@ -213,8 +220,6 @@ namespace std
~basic_filebuf() ~basic_filebuf()
{ {
this->close(); this->close();
_M_buf_size = 0;
_M_last_overflowed = false;
} }
// Members: // Members:
...@@ -281,29 +286,9 @@ namespace std ...@@ -281,29 +286,9 @@ namespace std
// charater from the real input source when the buffer is empty. // charater from the real input source when the buffer is empty.
// Buffered input uses underflow() // Buffered input uses underflow()
// The only difference between underflow() and uflow() is that the
// latter bumps _M_in_cur after the read. In the sync_with_stdio
// case, this is important, as we need to unget the read character in
// the underflow() case in order to maintain synchronization. So
// instead of calling underflow() from uflow(), we create a common
// subroutine to do the real work.
/**
* @if maint
* @doctodo
* @endif
*/
int_type
_M_underflow(bool __bump);
// [documentation is inherited]
virtual int_type
underflow()
{ return _M_underflow(false); }
// [documentation is inherited] // [documentation is inherited]
virtual int_type virtual int_type
uflow() underflow();
{ return _M_underflow(true); }
// [documentation is inherited] // [documentation is inherited]
virtual int_type virtual int_type
......
...@@ -85,6 +85,13 @@ namespace std ...@@ -85,6 +85,13 @@ namespace std
//@} //@}
protected: protected:
/**
* @if maint
* Place to stash in || out || in | out settings for current stringbuf.
* @endif
*/
ios_base::openmode _M_mode;
// Data Members: // Data Members:
/** /**
* @if maint * @if maint
...@@ -179,18 +186,9 @@ namespace std ...@@ -179,18 +186,9 @@ namespace std
_M_sync(const_cast<char_type*>(_M_string.data()), 0, __len); _M_sync(const_cast<char_type*>(_M_string.data()), 0, __len);
} }
int_type
_M_underflow(bool __bump);
// [documentation is inherited]
virtual int_type
underflow()
{ return _M_underflow(false); }
// [documentation is inherited] // [documentation is inherited]
virtual int_type virtual int_type
uflow() underflow();
{ return _M_underflow(true); }
// [documentation is inherited] // [documentation is inherited]
virtual int_type virtual int_type
......
...@@ -178,13 +178,6 @@ namespace std ...@@ -178,13 +178,6 @@ namespace std
/** /**
* @if maint * @if maint
* Place to stash in || out || in | out settings for current streambuf.
* @endif
*/
ios_base::openmode _M_mode;
/**
* @if maint
* Current locale setting. * Current locale setting.
* @endif * @endif
*/ */
...@@ -201,9 +194,7 @@ namespace std ...@@ -201,9 +194,7 @@ namespace std
/// Destructor deallocates no buffer space. /// Destructor deallocates no buffer space.
virtual virtual
~basic_streambuf() ~basic_streambuf()
{ { }
_M_mode = ios_base::openmode(0);
}
// [27.5.2.2.1] locales // [27.5.2.2.1] locales
/** /**
...@@ -451,7 +442,7 @@ namespace std ...@@ -451,7 +442,7 @@ namespace std
basic_streambuf() basic_streambuf()
: _M_in_beg(0), _M_in_cur(0), _M_in_end(0), : _M_in_beg(0), _M_in_cur(0), _M_in_end(0),
_M_out_beg(0), _M_out_cur(0), _M_out_end(0), _M_out_beg(0), _M_out_cur(0), _M_out_end(0),
_M_mode(ios_base::openmode(0)),_M_buf_locale(locale()) _M_buf_locale(locale())
{ } { }
// [27.5.2.3.1] get area access // [27.5.2.3.1] get area access
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
typedef std::streambuf::char_type char_type; typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf() testbuf(): std::streambuf()
{ _M_mode = (std::ios_base::in | std::ios_base::out); } { }
bool bool
check_pointers() check_pointers()
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
typedef std::streambuf::char_type char_type; typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf() testbuf(): std::streambuf()
{ _M_mode = (std::ios_base::in | std::ios_base::out); } { }
bool bool
check_pointers() check_pointers()
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
typedef std::streambuf::char_type char_type; typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf() testbuf(): std::streambuf()
{ _M_mode = (std::ios_base::in | std::ios_base::out); } { }
bool bool
check_pointers() check_pointers()
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
typedef std::streambuf::char_type char_type; typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf() testbuf(): std::streambuf()
{ _M_mode = (std::ios_base::in | std::ios_base::out); } { }
bool bool
check_pointers() check_pointers()
......
...@@ -41,7 +41,7 @@ public: ...@@ -41,7 +41,7 @@ public:
typedef std::streambuf::char_type char_type; typedef std::streambuf::char_type char_type;
testbuf(): std::streambuf() testbuf(): std::streambuf()
{ _M_mode = (std::ios_base::in | std::ios_base::out); } { }
bool bool
check_pointers() check_pointers()
......
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