]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
std_streambuf.h (_S_pback_size, [...]): Move to basic_filebuf.
authorPaolo Carlini <pcarlini@unitus.it>
Tue, 22 Apr 2003 17:32:25 +0000 (19:32 +0200)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 22 Apr 2003 17:32:25 +0000 (17:32 +0000)
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

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/fstream.tcc
libstdc++-v3/include/bits/streambuf.tcc
libstdc++-v3/include/std/std_fstream.h
libstdc++-v3/include/std/std_streambuf.h

index de76c79196d7ac46ab5655765dccefc3ef413b00..c5441ba491b4de483a4b93a3fc27f9f000d655ae 100644 (file)
@@ -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
index fc8ca7ab3644fdd346e6b0f200cd647a200b5d8c..b68e5a6710a1ffebe514002c9d28508887d5f30a 100644 (file)
 
 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>
index 06e2f504704e1df78fc3e1ed2d37b24b7baee673..dff48d25dfc79121329666784933a00ab9d996aa 100644 (file)
 
 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>::
index c341aaa6ce18bb4de46fd302e2673597a71e8b69..6be39c69395865d14d9136094d1ef1ed345fc0af 100644 (file)
@@ -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:
       /**
index 5409b7515c395951f24550d291f4313fdf6f1116..9065fd17cbaf9d5f80bc3e0dc750d14105a17603 100644 (file)
@@ -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