diff options
author | kan <kan@FreeBSD.org> | 2007-05-19 01:25:07 +0000 |
---|---|---|
committer | kan <kan@FreeBSD.org> | 2007-05-19 01:25:07 +0000 |
commit | 7865836f4b0f698454c31b4593effcb032c22c1e (patch) | |
tree | ea6c2718dc1e45ed535d194df808ef31f0ebac92 /contrib/libstdc++/include/std/std_sstream.h | |
parent | 1f9ea4d0a40cca64d60cf4dab152349da7b9dddf (diff) | |
download | FreeBSD-src-7865836f4b0f698454c31b4593effcb032c22c1e.zip FreeBSD-src-7865836f4b0f698454c31b4593effcb032c22c1e.tar.gz |
GCC 4.2.0 release C++ standard library and runtime support code.
Diffstat (limited to 'contrib/libstdc++/include/std/std_sstream.h')
-rw-r--r-- | contrib/libstdc++/include/std/std_sstream.h | 124 |
1 files changed, 36 insertions, 88 deletions
diff --git a/contrib/libstdc++/include/std/std_sstream.h b/contrib/libstdc++/include/std/std_sstream.h index 0a6738a..a09815c 100644 --- a/contrib/libstdc++/include/std/std_sstream.h +++ b/contrib/libstdc++/include/std/std_sstream.h @@ -1,6 +1,6 @@ // String based streams -*- C++ -*- -// Copyright (C) 1997, 1998, 1999, 2002, 2003, 2004 +// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -16,7 +16,7 @@ // 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, +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, // USA. // As a special exception, you may use this file as part of a free software @@ -28,15 +28,14 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. +/** @file sstream + * This is a Standard C++ Library header. + */ + // // ISO C++ 14882: 27.7 String-based streams // -/** @file sstream - * This is a Standard C++ Library header. You should @c #include this header - * in your programs, rather than any of the "st[dl]_*.h" implementation files. - */ - #ifndef _GLIBCXX_SSTREAM #define _GLIBCXX_SSTREAM 1 @@ -45,8 +44,8 @@ #include <istream> #include <ostream> -namespace std -{ +_GLIBCXX_BEGIN_NAMESPACE(std) + // [27.7.1] template class basic_stringbuf /** * @brief The actual work of input and output (for std::string). @@ -73,16 +72,9 @@ namespace std typedef typename traits_type::pos_type pos_type; typedef typename traits_type::off_type off_type; - //@{ - /** - * @if maint - * @doctodo - * @endif - */ typedef basic_streambuf<char_type, traits_type> __streambuf_type; typedef basic_string<char_type, _Traits, _Alloc> __string_type; typedef typename __string_type::size_type __size_type; - //@} protected: /** @@ -93,11 +85,6 @@ namespace std ios_base::openmode _M_mode; // Data Members: - /** - * @if maint - * @doctodo - * @endif - */ __string_type _M_string; public: @@ -140,16 +127,18 @@ namespace std __string_type str() const { + __string_type __ret; if (this->pptr()) { // The current egptr() may not be the actual string end. if (this->pptr() > this->egptr()) - return __string_type(this->pbase(), this->pptr()); + __ret = __string_type(this->pbase(), this->pptr()); else - return __string_type(this->pbase(), this->egptr()); + __ret = __string_type(this->pbase(), this->egptr()); } else - return _M_string; + __ret = _M_string; + return __ret; } /** @@ -164,36 +153,39 @@ namespace std { // Cannot use _M_string = __s, since v3 strings are COW. _M_string.assign(__s.data(), __s.size()); - _M_stringbuf_init(this->_M_mode); + _M_stringbuf_init(_M_mode); } protected: // Common initialization code goes here. - /** - * @if maint - * @doctodo - * @endif - */ void _M_stringbuf_init(ios_base::openmode __mode) { - this->_M_mode = __mode; - + _M_mode = __mode; __size_type __len = 0; - if (this->_M_mode & (ios_base::ate | ios_base::app)) + if (_M_mode & (ios_base::ate | ios_base::app)) __len = _M_string.size(); _M_sync(const_cast<char_type*>(_M_string.data()), 0, __len); } - // [documentation is inherited] + virtual streamsize + showmanyc() + { + streamsize __ret = -1; + if (_M_mode & ios_base::in) + { + _M_update_egptr(); + __ret = this->egptr() - this->gptr(); + } + return __ret; + } + virtual int_type underflow(); - // [documentation is inherited] virtual int_type pbackfail(int_type __c = traits_type::eof()); - // [documentation is inherited] virtual int_type overflow(int_type __c = traits_type::eof()); @@ -219,64 +211,34 @@ namespace std // things will quickly blow up. // Step 1: Destroy the current internal array. - _M_string = __string_type(__s, __n); + _M_string.clear(); // Step 2: Use the external array. - _M_sync(__s, 0, 0); + _M_sync(__s, __n, 0); } return this; } - // [documentation is inherited] virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode = ios_base::in | ios_base::out); - // [documentation is inherited] virtual pos_type seekpos(pos_type __sp, ios_base::openmode __mode = ios_base::in | ios_base::out); // Internal function for correctly updating the internal buffer - // for a particular _M_string, due to initialization or - // re-sizing of an existing _M_string. - // Assumes: contents of _M_string and internal buffer match exactly. - // __i == _M_in_cur - _M_in_beg - // __o == _M_out_cur - _M_out_beg - /** - * @if maint - * @doctodo - * @endif - */ + // for a particular _M_string, due to initialization or re-sizing + // of an existing _M_string. void - _M_sync(char_type* __base, __size_type __i, __size_type __o) - { - const bool __testin = this->_M_mode & ios_base::in; - const bool __testout = this->_M_mode & ios_base::out; - const __size_type __len = _M_string.size(); - - if (__testin) - this->setg(__base, __base + __i, __base + __len); - if (__testout) - { - this->setp(__base, __base + _M_string.capacity()); - this->pbump(__o); - // We need a pointer to the string end anyway, even when - // !__testin: in that case, however, for the correct - // functioning of the streambuf inlines all the get area - // pointers must be identical. - if (!__testin) - this->setg(__base + __len, __base + __len, __base + __len); - } - } + _M_sync(char_type* __base, __size_type __i, __size_type __o); // Internal function for correctly updating egptr() to the actual // string end. void _M_update_egptr() { - const bool __testin = this->_M_mode & ios_base::in; - + const bool __testin = _M_mode & ios_base::in; if (this->pptr() && this->pptr() > this->egptr()) if (__testin) this->setg(this->eback(), this->gptr(), this->pptr()); @@ -315,11 +277,6 @@ namespace std typedef basic_istream<char_type, traits_type> __istream_type; private: - /** - * @if maint - * @doctodo - * @endif - */ __stringbuf_type _M_stringbuf; public: @@ -433,11 +390,6 @@ namespace std typedef basic_ostream<char_type, traits_type> __ostream_type; private: - /** - * @if maint - * @doctodo - * @endif - */ __stringbuf_type _M_stringbuf; public: @@ -551,11 +503,6 @@ namespace std typedef basic_iostream<char_type, traits_type> __iostream_type; private: - /** - * @if maint - * @doctodo - * @endif - */ __stringbuf_type _M_stringbuf; public: @@ -634,7 +581,8 @@ namespace std str(const __string_type& __s) { _M_stringbuf.str(__s); } }; -} // namespace std + +_GLIBCXX_END_NAMESPACE #ifndef _GLIBCXX_EXPORT_TEMPLATE # include <bits/sstream.tcc> |