mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-30 07:14:09 +08:00
std_streambuf.h (_S_pback_size, [...]): Move to basic_filebuf.
2003-04-22 Paolo Carlini <pcarlini@unitus.it> * include/std/std_streambuf.h (_S_pback_size, _M_pback, _M_pback_cur_save, _M_pback_end_save, _M_pback_init, _M_pback_create(), _M_pback_destroy()): Move to basic_filebuf. (basic_streambuf::basic_streambuf()): Adjust. * include/std/std_fstream.h (_S_pback_size, _M_pback, _M_pback_cur_save, _M_pback_end_save, _M_pback_init, _M_pback_create(), _M_pback_destroy()): Moved here from basic_streambuf. * include/bits/fstream.tcc (basic_filebuf::basic_filebuf()): Adjust. (basic_filebuf::_S_pback_size): Add declaration. * include/bits/streambuf.tcc (basic_streambuf::_S_pback_size): Remove declaration. From-SVN: r65950
This commit is contained in:
parent
77c915d879
commit
45aca21f40
@ -1,3 +1,19 @@
|
||||
2003-04-22 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
* include/std/std_streambuf.h (_S_pback_size, _M_pback,
|
||||
_M_pback_cur_save, _M_pback_end_save, _M_pback_init,
|
||||
_M_pback_create(), _M_pback_destroy()): Move to basic_filebuf.
|
||||
(basic_streambuf::basic_streambuf()): Adjust.
|
||||
* include/std/std_fstream.h (_S_pback_size, _M_pback,
|
||||
_M_pback_cur_save, _M_pback_end_save, _M_pback_init,
|
||||
_M_pback_create(), _M_pback_destroy()): Moved here
|
||||
from basic_streambuf.
|
||||
* include/bits/fstream.tcc (basic_filebuf::basic_filebuf()):
|
||||
Adjust.
|
||||
(basic_filebuf::_S_pback_size): Add declaration.
|
||||
* include/bits/streambuf.tcc (basic_streambuf::_S_pback_size):
|
||||
Remove declaration.
|
||||
|
||||
2003-04-21 Paolo Carlini <pcarlini@unitus.it>
|
||||
|
||||
Consistently use _M_in_beg instead of eback(), _M_in_cur
|
||||
|
@ -39,6 +39,10 @@
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<typename _CharT, typename _Traits>
|
||||
const size_t
|
||||
basic_filebuf<_CharT, _Traits>::_S_pback_size;
|
||||
|
||||
template<typename _CharT, typename _Traits>
|
||||
void
|
||||
basic_filebuf<_CharT, _Traits>::
|
||||
@ -72,7 +76,8 @@ namespace std
|
||||
basic_filebuf<_CharT, _Traits>::
|
||||
basic_filebuf() : __streambuf_type(), _M_file(&_M_lock),
|
||||
_M_state_cur(__state_type()), _M_state_beg(__state_type()),
|
||||
_M_buf_allocated(false), _M_last_overflowed(false)
|
||||
_M_buf_allocated(false), _M_last_overflowed(false),
|
||||
_M_pback_cur_save(0), _M_pback_end_save(0), _M_pback_init(false)
|
||||
{ this->_M_buf_unified = true; }
|
||||
|
||||
template<typename _CharT, typename _Traits>
|
||||
|
@ -39,10 +39,6 @@
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<typename _CharT, typename _Traits>
|
||||
const size_t
|
||||
basic_streambuf<_CharT, _Traits>::_S_pback_size;
|
||||
|
||||
template<typename _CharT, typename _Traits>
|
||||
typename basic_streambuf<_CharT, _Traits>::int_type
|
||||
basic_streambuf<_CharT, _Traits>::
|
||||
|
@ -134,6 +134,65 @@ namespace std
|
||||
*/
|
||||
char_type* _M_filepos;
|
||||
|
||||
//@{
|
||||
/**
|
||||
* @if maint
|
||||
* Necessary bits for putback buffer management.
|
||||
*
|
||||
* @note pbacks of over one character are not currently supported.
|
||||
* @endif
|
||||
*/
|
||||
static const size_t _S_pback_size = 1;
|
||||
char_type _M_pback[_S_pback_size];
|
||||
char_type* _M_pback_cur_save;
|
||||
char_type* _M_pback_end_save;
|
||||
bool _M_pback_init;
|
||||
//@}
|
||||
|
||||
// Initializes pback buffers, and moves normal buffers to safety.
|
||||
// Assumptions:
|
||||
// _M_in_cur has already been moved back
|
||||
void
|
||||
_M_pback_create()
|
||||
{
|
||||
if (!_M_pback_init)
|
||||
{
|
||||
size_t __dist = this->_M_in_end - this->_M_in_cur;
|
||||
size_t __len = std::min(_S_pback_size, __dist);
|
||||
traits_type::copy(_M_pback, this->_M_in_cur, __len);
|
||||
_M_pback_cur_save = this->_M_in_cur;
|
||||
_M_pback_end_save = this->_M_in_end;
|
||||
this->setg(_M_pback, _M_pback, _M_pback + __len);
|
||||
_M_pback_init = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Deactivates pback buffer contents, and restores normal buffer.
|
||||
// Assumptions:
|
||||
// The pback buffer has only moved forward.
|
||||
void
|
||||
_M_pback_destroy()
|
||||
{
|
||||
if (_M_pback_init)
|
||||
{
|
||||
// Length _M_in_cur moved in the pback buffer.
|
||||
size_t __off_cur = this->_M_in_cur - _M_pback;
|
||||
|
||||
// For in | out buffers, the end can be pushed back...
|
||||
size_t __off_end = 0;
|
||||
size_t __pback_len = this->_M_in_end - _M_pback;
|
||||
size_t __save_len = _M_pback_end_save - this->_M_buf;
|
||||
if (__pback_len > __save_len)
|
||||
__off_end = __pback_len - __save_len;
|
||||
|
||||
this->setg(this->_M_buf, _M_pback_cur_save + __off_cur,
|
||||
_M_pback_end_save + __off_end);
|
||||
_M_pback_cur_save = NULL;
|
||||
_M_pback_end_save = NULL;
|
||||
_M_pback_init = false;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
// Constructors/destructor:
|
||||
/**
|
||||
|
@ -229,23 +229,6 @@ namespace std
|
||||
*/
|
||||
locale _M_buf_locale;
|
||||
|
||||
//@{
|
||||
/**
|
||||
* @if maint
|
||||
* Necessary bits for putback buffer management. Only used in
|
||||
* the basic_filebuf class, as necessary for the standard
|
||||
* requirements.
|
||||
*
|
||||
* @note pbacks of over one character are not currently supported.
|
||||
* @endif
|
||||
*/
|
||||
static const size_t _S_pback_size = 1;
|
||||
char_type _M_pback[_S_pback_size];
|
||||
char_type* _M_pback_cur_save;
|
||||
char_type* _M_pback_end_save;
|
||||
bool _M_pback_init;
|
||||
//@}
|
||||
|
||||
/**
|
||||
* @if maint
|
||||
* Yet unused.
|
||||
@ -253,50 +236,6 @@ namespace std
|
||||
*/
|
||||
fpos<__state_type> _M_pos;
|
||||
|
||||
// Initializes pback buffers, and moves normal buffers to safety.
|
||||
// Assumptions:
|
||||
// _M_in_cur has already been moved back
|
||||
void
|
||||
_M_pback_create()
|
||||
{
|
||||
if (!_M_pback_init)
|
||||
{
|
||||
size_t __dist = _M_in_end - _M_in_cur;
|
||||
size_t __len = std::min(_S_pback_size, __dist);
|
||||
traits_type::copy(_M_pback, _M_in_cur, __len);
|
||||
_M_pback_cur_save = _M_in_cur;
|
||||
_M_pback_end_save = _M_in_end;
|
||||
this->setg(_M_pback, _M_pback, _M_pback + __len);
|
||||
_M_pback_init = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Deactivates pback buffer contents, and restores normal buffer.
|
||||
// Assumptions:
|
||||
// The pback buffer has only moved forward.
|
||||
void
|
||||
_M_pback_destroy()
|
||||
{
|
||||
if (_M_pback_init)
|
||||
{
|
||||
// Length _M_in_cur moved in the pback buffer.
|
||||
size_t __off_cur = _M_in_cur - _M_pback;
|
||||
|
||||
// For in | out buffers, the end can be pushed back...
|
||||
size_t __off_end = 0;
|
||||
size_t __pback_len = _M_in_end - _M_pback;
|
||||
size_t __save_len = _M_pback_end_save - _M_buf;
|
||||
if (__pback_len > __save_len)
|
||||
__off_end = __pback_len - __save_len;
|
||||
|
||||
this->setg(_M_buf, _M_pback_cur_save + __off_cur,
|
||||
_M_pback_end_save + __off_end);
|
||||
_M_pback_cur_save = NULL;
|
||||
_M_pback_end_save = NULL;
|
||||
_M_pback_init = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Correctly sets the _M_in_cur pointer, and bumps the
|
||||
// _M_out_cur pointer as well if necessary.
|
||||
void
|
||||
@ -541,9 +480,7 @@ namespace std
|
||||
: _M_buf(NULL), _M_buf_size(BUFSIZ), _M_buf_unified(false),
|
||||
_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_lim(0),
|
||||
_M_mode(ios_base::openmode(0)), _M_buf_locale(locale()),
|
||||
_M_pback_cur_save(0), _M_pback_end_save(0),
|
||||
_M_pback_init(false)
|
||||
_M_mode(ios_base::openmode(0)), _M_buf_locale(locale())
|
||||
{ }
|
||||
|
||||
// [27.5.2.3.1] get area access
|
||||
|
Loading…
Reference in New Issue
Block a user