stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r630250 - in /stdcxx/trunk: include/istream include/istream.cc include/ostream include/rw/_stringio.c include/rw/_stringio.cc include/rw/_stringio.h include/string src/export.cpp
Date Fri, 22 Feb 2008 17:00:00 GMT
Author: faridz
Date: Fri Feb 22 08:59:56 2008
New Revision: 630250

URL: http://svn.apache.org/viewvc?rev=630250&view=rev
Log:
2008-02-22  Farid Zaripov  <farid_zaripov@epam.com>

	STDCXX-375
	* include/string: Declarations of the string inserter's and extractor's
	are moved to  #included <rw/_stringio.h>.
	* include/ostream: Definition of the inline string inserter moved to
	#included <rw/_stringio.h>.
	* include/istream: Definition of the inline std::getline() moved to
	#included <rw/_stringio.h>.
	* include/istream.cc: Definitions of the string extractor's are moved
	to rw/_stringio.cc file.
	* include/rw/_stringio.h: New header file with declarations of the
	string inserter's and extractor's.
	* include/rw/_stringio.cc: New file with definitions of the string extractors.
	* include/rw/_stringio.c: New file for compilers with implicit
	inclusion feature.
	* src/export/cpp: #included <rw/_stringio.h> and <rw/_stringio.cc>.

Added:
    stdcxx/trunk/include/rw/_stringio.c   (with props)
    stdcxx/trunk/include/rw/_stringio.cc   (with props)
    stdcxx/trunk/include/rw/_stringio.h   (with props)
Modified:
    stdcxx/trunk/include/istream
    stdcxx/trunk/include/istream.cc
    stdcxx/trunk/include/ostream
    stdcxx/trunk/include/string
    stdcxx/trunk/src/export.cpp

Modified: stdcxx/trunk/include/istream
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/istream?rev=630250&r1=630249&r2=630250&view=diff
==============================================================================
--- stdcxx/trunk/include/istream (original)
+++ stdcxx/trunk/include/istream Fri Feb 22 08:59:56 2008
@@ -522,16 +522,6 @@
 }
 
 
-// 21.3.7.9 - defined here, declared inline in <string>
-template<class _CharT, class _Traits, class _Allocator>
-inline basic_istream<_CharT, _Traits>& 
-getline (basic_istream<_CharT, _Traits>&            __is,
-         basic_string<_CharT, _Traits, _Allocator>& __str)
-{
-    return getline (__is, __str, __is.widen ('\n'));
-}
-
-
 // 27.6.1.5
 template<class _CharT, class _Traits /* = char_traits<_CharT> */>
 class basic_iostream
@@ -570,12 +560,6 @@
 _RWSTD_INSTANTIATE_2 (class _RWSTD_TI_EXPORT
                       basic_istream<char, char_traits<char> >);
 
-_RWSTD_INSTANTIATE_FUN_1 (_RWSTD_TI_EXPORT istream&
-                          operator>> (istream&, string&));
-
-_RWSTD_INSTANTIATE_FUN_1 (_RWSTD_TI_EXPORT istream&
-                          getline (istream&, string&, char));
-
 #endif   // _RWSTD_INSTANTIATE (_BASIC_ISTREAM, _CHAR)
 
 #if _RWSTD_INSTANTIATE (_BASIC_ISTREAM, _WCHAR_T)
@@ -583,11 +567,6 @@
 _RWSTD_INSTANTIATE_2 (class _RWSTD_TI_EXPORT
                       basic_istream<wchar_t, char_traits<wchar_t> >);
 
-_RWSTD_INSTANTIATE_FUN_1 (_RWSTD_TI_EXPORT wistream&
-                          operator>> (wistream&, wstring&));
-
-_RWSTD_INSTANTIATE_FUN_1 (_RWSTD_TI_EXPORT wistream&
-                          getline (wistream&, wstring&, wchar_t));
 #endif   // _RWSTD_INSTANTIATE (_BASIC_ISTREAM, _WCHAR_T)
 
 }   // namespace std
@@ -596,5 +575,12 @@
 #if _RWSTD_DEFINE_TEMPLATE_LAST (_BASIC_ISTREAM)
 #  include <istream.cc>
 #endif   // _RWSTD_DEFINE_TEMPLATE_LAST (_BASIC_ISTREAM)
+
+
+#ifndef _RWSTD_STRING_EXTRACTORS_INCLUDED
+#  define _RWSTD_INCLUDE_STRING_EXTRACTORS
+#  include <rw/_stringio.h>
+#endif   // _RWSTD_STRING_EXTRACTORS_INCLUDED
+
 
 #endif   // _RWSTD_ISTREAM_INCLUDED

Modified: stdcxx/trunk/include/istream.cc
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/istream.cc?rev=630250&r1=630249&r2=630250&view=diff
==============================================================================
--- stdcxx/trunk/include/istream.cc (original)
+++ stdcxx/trunk/include/istream.cc Fri Feb 22 08:59:56 2008
@@ -780,374 +780,6 @@
 }
 
 
-// 21.3.7.9 - defined here, declared in <string>
-_EXPORT
-template<class _CharT, class _Traits, class _Allocator>
-basic_istream<_CharT, _Traits>&
-operator>> (basic_istream<_CharT, _Traits>&            __is, 
-            basic_string<_CharT, _Traits, _Allocator>& __str)
-{
-    _RWSTD_ASSERT (0 != __is.rdbuf ());
-
-    const _TYPENAME basic_istream<_CharT, _Traits>::sentry
-        __ipfx (__is /* , noskipws = false */);
-
-    ios_base::iostate __err = ios_base::goodbit;
-
-    typedef _RWSTD_SIZE_T _SizeT;
-
-    // count of characters read from stream
-    _SizeT __gcount = 0;
-
-    _TRY {
-
-        if (__ipfx) {
-
-            __str.clear ();
-
-            // maximum number of characters we can read
-            _RWSTD_SIZE_T __n =
-                __is.width () ? __is.width () : __str.max_size ();
-
-            basic_streambuf<_CharT, _Traits>* const __rdbuf = __is.rdbuf ();
-
-            const ctype<_CharT> &__ctp =
-                _USE_FACET (ctype<_CharT>, __is.getloc ());
-
-#ifndef _RWSTD_NO_FRIEND_TEMPLATE
-
-            while (__n != 0) {
-
-                const _CharT* const __gptr  = __rdbuf->gptr ();
-                const _CharT* const __egptr = __rdbuf->egptr ();
-
-                // maximum number of characters would want to extract
-                _SizeT __navail = __egptr - __gptr;
-                if (__n < __navail)
-                    __navail = __n;
-
-                if (__navail) {
-
-                    // find the delimeter in the squence if it exists, or
-                    // get pointer to end of sequence
-                    const _CharT* __pdel = __gptr;
-                    for (/**/; __pdel != __egptr; ++__pdel) {
-
-                        const _TYPENAME _Traits::int_type
-                            __c = _Traits::to_int_type(*__pdel);
-
-                        if (_Traits::eq_int_type (__c, _Traits::eof ())) {
-                            __err = ios_base::eofbit;
-                            break;
-                        }
-
-                        if (__ctp.is (__ctp.space, *__pdel))
-                            break;
-                    }
-
-                    // __pdel is either pointing to a delimiter or one past
-                    // the end of the input stream get area. if it is past
-                    // the end, then set it to null.
-                    if (__pdel == __egptr) {
-                        __pdel = 0;
-                    }
-
-                    if (__pdel) {
-                        __navail = __pdel - __gptr + 1;
-                        __n     -= __navail - 1;
-                    }
-                    else if (__n == __navail)
-                        __n -= --__navail;
-                    else
-                        __n -= __navail;
-
-                    // store characters excluding the delimiter
-                    __str.append (__gptr, __navail - !!__pdel);
-
-                    __gcount += __navail;
-
-                    // advance gptr() by the number of extracted
-                    // characters, including the delimiter
-                    __rdbuf->gbump (__navail);
-
-                    // we found a delimiter before the end of the get area,
-                    // break out of outer loop
-                    if (__pdel) {
-                        break;
-                    }
-
-                    if (2 > __n && _SizeT (__egptr - __gptr) != __navail) {
-                        __err = ios_base::failbit;
-                        break;
-                    }
-                }
-                else {
-
-                    // n data in buffer, trigger underflow()
-                    // note that streambuf may be unbuffered
-                    const _TYPENAME _Traits::int_type
-                        __c = __rdbuf->sgetc ();
-
-                    if (_Traits::eq_int_type (__c, _Traits::eof ())) {
-                        __err = ios_base::eofbit;
-                        break;
-                    }
-
-                    // convert to char_type so that isspace works correctly
-                    const _TYPENAME _Traits::char_type
-                        __ch = _Traits::to_char_type (__c);
-
-                    if (__ctp.is (__ctp.space, __ch))
-                        break;
-
-                    __str.push_back (__ch);
-                    --__n;
-
-                    __rdbuf->sbumpc ();
-
-                    // increment gcount only _after_ sbumpc() but _before_
-                    // the subsequent call to sgetc() to correctly reflect
-                    // the number of extracted characters in the presence
-                    // of exceptions thrown from streambuf virtuals
-                    ++__gcount;
-                }
-            }
-
-#else   // if defined (_RWSTD_NO_FRIEND_TEMPLATE)
-
-            for ( ; __n != 0; ) {
-
-                const _TYPENAME _Traits::int_type
-                    __c (__rdbuf->sgetc ());
-
-                if (_Traits::eq_int_type (__c, _Traits::eof ())) {
-                    __err = ios_base::eofbit;
-                    break;
-                }
-
-                // convert to char_type so that isspace works correctly
-                const _TYPENAME _Traits::char_type
-                    __ch = _Traits::to_char_type (__c);
-
-                if (__ctp.is (__ctp.space, __ch))
-                    break;
-
-                __str.push_back (__ch);
-                --__n;
-
-                __rdbuf->sbumpc ();
-
-                // increment gcount only _after_ sbumpc() but _before_
-                // the subsequent call to sgetc() to correctly reflect
-                // the number of extracted characters in the presence
-                // of exceptions thrown from streambuf virtuals
-                ++__gcount;
-            }
-
-#endif   // if defined (_RWSTD_NO_FRIEND_TEMPLATE)
-
-            __is.width (0);
-        }
-    }
-    _CATCH (...) {
-        __is.setstate (ios_base::badbit | _RW::__rw_rethrow);
-    }
-
-    if (!__gcount)
-        __err |= ios_base::failbit;
-
-    if (__err)
-        __is.setstate (__err);
-
-    return __is;
-}
-
-
-// 21.3.7.9 - defined here, declared in <string>
-_EXPORT
-template<class _CharT, class _Traits, class _Allocator>
-basic_istream<_CharT, _Traits>&
-getline (basic_istream<_CharT, _Traits>&            __is, 
-         basic_string<_CharT, _Traits, _Allocator>& __str, 
-         _CharT                                     __delim)
-{
-    _RWSTD_ASSERT (0 != __is.rdbuf ());
-
-    const _TYPENAME basic_istream<_CharT, _Traits>::sentry
-        __ipfx (__is, true /* noskipws */);
-
-#ifndef _RWSTD_NO_FRIEND_TEMPLATE
-
-    ios_base::iostate __err = ios_base::goodbit;
-
-    typedef _RWSTD_SIZE_T _SizeT;
-
-    _SizeT __gcount = 0;
-
-    if (__ipfx) { 
-
-        __str.clear ();
-
-        // carefuly handle arithmetic overflow
-        _SizeT __n = __str.max_size ();
-        if (__n + _SizeT (1))
-            ++__n;
-
-        basic_streambuf<_CharT, _Traits>* const __rdbuf = __is.rdbuf ();
-
-        _TRY {
-
-            for ( ; ; ) {
-
-                typedef _TYPENAME _Traits::int_type int_type;
-
-                const _CharT* const __gptr  = __rdbuf->gptr ();
-                const _CharT* const __egptr = __rdbuf->egptr ();
-
-                // compute the lesser of the number of characters in the
-                // stream buffer and the size of the destination buffer
-                _SizeT __navail = __egptr - __gptr;
-                if (__n < __navail)
-                    __navail = __n;
-
-                if (__navail) {
-
-                    // find the delimiter in the sequence if it exists
-                    const _CharT* const __pdel =
-                        _Traits::find (__gptr, __navail, __delim);
-
-                    if (__pdel) {
-                        __navail = __pdel - __gptr + 1;
-                        __n     -= __navail - 1;
-                    }
-                    else if (__n == __navail)
-                        __n -= --__navail;
-                    else
-                        __n -= __navail;
-
-                    // store characters excluding the delimiter
-                    __str.append (__gptr, __navail - !!__pdel);
-
-                    __gcount += __navail;
-
-                    // advance gptr() by the number of extracted
-                    // characters, including the delimiter
-                    __rdbuf->gbump (__navail);
-
-                    if (__pdel) {
-                        break;
-                    }
-
-                    if (2 > __n && _SizeT (__egptr - __gptr) != __navail) {
-                        __err = ios_base::failbit;
-                        break;
-                    }
-                }
-                else {
-
-                    // no data in buffer, trigger underflow()
-                    // note that streambuf may be unbuffered
-                    const int_type __c (__rdbuf->sgetc ());
-
-                    if (_Traits::eq_int_type (__c, _Traits::eof ())) {
-                        __err = ios_base::eofbit;
-                        break;
-                    }
-
-                    const _CharT __ch = _Traits::to_char_type (__c);
-                    if (_Traits::eq (__ch, __delim)) {
-                        __rdbuf->sbumpc ();
-                        __gcount++;
-                        break;
-                    }
-
-                    if (2 > __n) {
-                        __err = ios_base::failbit;
-                        break;
-                    }
-
-                    __str += __ch;
-                    --__n;
-
-                    __rdbuf->sbumpc ();
-
-                    // increment gcount only _after_ sbumpc() but _before_
-                    // the subsequent call to sgetc() to correctly reflect
-                    // the number of extracted characters in the presence
-                    // of exceptions thrown from streambuf virtuals
-                    ++__gcount;
-                }
-            }
-        }
-        _CATCH (...) {
-            __is.setstate (ios_base::badbit | _RW::__rw_rethrow);
-        }
-    }
-
-    if (!__gcount)
-        __err |= ios_base::failbit;
-
-#else   // if defined (_RWSTD_NO_FRIEND_TEMPLATE)
-
-    ios_base::iostate __err = ios_base::failbit;
-
-    if (__ipfx) { 
-
-        _TRY {
-
-            __str.clear ();
-
-            const _RWSTD_SIZE_T __max_size = __str.max_size ();
-
-            // FIXME: code commented out to work around an HP aCC 3.14.10
-            // bug #JAGac86264
-
-            // typedef _TYPENAME
-            //     basic_string<_CharT, _Traits, _Allocator>::size_type
-
-            for ( ; ; ) {
-
-                const _TYPENAME _Traits::int_type
-                    __c (__is.rdbuf ()->sgetc ());
-
-                if (_Traits::eq_int_type (__c, _Traits::eof ())) {
-                    // 21.3.7.9, p7
-                    if (__str.size ())
-                        __err = ios_base::eofbit;
-                    else
-                        __err = ios_base::eofbit | ios_base::failbit;
-
-                    break;
-                }
-
-                if (_Traits::eq (_Traits::to_char_type (__c), __delim)) {
-                    __is.rdbuf ()->sbumpc ();
-                    __err = ios_base::goodbit;
-                    break;
-                }
-
-                if (__max_size <= __str.size ())
-                    break;
-
-                __str.push_back (_Traits::to_char_type (__c));
-
-                __is.rdbuf ()->sbumpc ();
-            }
-        }
-        _CATCH (...) {
-            __is.setstate (ios_base::badbit | _RW::__rw_rethrow);
-        }
-    }
-
-#endif   // _RWSTD_NO_FRIEND_TEMPLATE
-
-    if (__err)
-        __is.setstate (__err);
-
-    return __is;
-}  
-
-
 #ifdef _RWSTD_NO_UNDEFINED_TEMPLATES
 
 template <class _CharT, class _Traits>

Modified: stdcxx/trunk/include/ostream
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/ostream?rev=630250&r1=630249&r2=630250&view=diff
==============================================================================
--- stdcxx/trunk/include/ostream (original)
+++ stdcxx/trunk/include/ostream Fri Feb 22 08:59:56 2008
@@ -484,18 +484,6 @@
 }
  
 
-// 21.3.7.9, p3 - defined here, declared inline in <string>
-template<class _CharT, class _Traits, class _Allocator>
-inline basic_ostream<_CharT, _Traits>&
-operator<< (basic_ostream<_CharT, _Traits>                  & __strm,
-            const basic_string<_CharT, _Traits, _Allocator> &__str)
-{
-    _RW::__rw_insert (__strm, __str.data (), __str.length (),
-                      __strm.width ());
-    return __strm;
-}
-
-
 #if defined (_MSC_VER) && _MSC_VER < 1310
 
 // working around an MSVC bug that causes it to pick the member
@@ -573,6 +561,12 @@
 #if _RWSTD_DEFINE_TEMPLATE_LAST (_BASIC_OSTREAM)
 #  include <ostream.cc>
 #endif   // _RWSTD_DEFINE_TEMPLATE_LAST (_BASIC_OSTREAM)
+
+
+#ifndef _RWSTD_STRING_INSERTER_INCLUDED
+#  define _RWSTD_INCLUDE_STRING_INSERTER
+#  include <rw/_stringio.h>
+#endif   // _RWSTD_STRING_INSERTER_INCLUDED
 
 
 #endif   // _RWSTD_OSTREAM_INCLUDED

Added: stdcxx/trunk/include/rw/_stringio.c
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_stringio.c?rev=630250&view=auto
==============================================================================
--- stdcxx/trunk/include/rw/_stringio.c (added)
+++ stdcxx/trunk/include/rw/_stringio.c Fri Feb 22 08:59:56 2008
@@ -0,0 +1,29 @@
+/***************************************************************************
+ *
+ * rw/_stringio.c
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Licensed to the Apache Software  Foundation (ASF) under one or more
+ * contributor  license agreements.  See  the NOTICE  file distributed
+ * with  this  work  for  additional information  regarding  copyright
+ * ownership.   The ASF  licenses this  file to  you under  the Apache
+ * License, Version  2.0 (the  "License"); you may  not use  this file
+ * except in  compliance with the License.   You may obtain  a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the  License is distributed on an  "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
+ * implied.   See  the License  for  the  specific language  governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1994-2008 Rogue Wave Software.
+ * 
+ **************************************************************************/
+
+#include <rw/_stringio.cc>

Propchange: stdcxx/trunk/include/rw/_stringio.c
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: stdcxx/trunk/include/rw/_stringio.c
------------------------------------------------------------------------------
    svn:keywords = Id

Added: stdcxx/trunk/include/rw/_stringio.cc
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_stringio.cc?rev=630250&view=auto
==============================================================================
--- stdcxx/trunk/include/rw/_stringio.cc (added)
+++ stdcxx/trunk/include/rw/_stringio.cc Fri Feb 22 08:59:56 2008
@@ -0,0 +1,399 @@
+/***************************************************************************
+ *
+ * _stringio.cc - definitions of the string extractors
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Licensed to the Apache Software  Foundation (ASF) under one or more
+ * contributor  license agreements.  See  the NOTICE  file distributed
+ * with  this  work  for  additional information  regarding  copyright
+ * ownership.   The ASF  licenses this  file to  you under  the Apache
+ * License, Version  2.0 (the  "License"); you may  not use  this file
+ * except in  compliance with the License.   You may obtain  a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the  License is distributed on an  "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
+ * implied.   See  the License  for  the  specific language  governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 1994-2008 Rogue Wave Software.
+ * 
+ **************************************************************************/
+
+
+_RWSTD_NAMESPACE (std) { 
+
+
+_EXPORT
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+operator>> (basic_istream<_CharT, _Traits>&            __is, 
+            basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+    _RWSTD_ASSERT (0 != __is.rdbuf ());
+
+    const _TYPENAME basic_istream<_CharT, _Traits>::sentry
+        __ipfx (__is /* , noskipws = false */);
+
+    ios_base::iostate __err = ios_base::goodbit;
+
+    typedef _RWSTD_SIZE_T _SizeT;
+
+    // count of characters read from stream
+    _SizeT __gcount = 0;
+
+    _TRY {
+
+        if (__ipfx) {
+
+            __str.clear ();
+
+            // maximum number of characters we can read
+            _RWSTD_SIZE_T __n =
+                __is.width () ? __is.width () : __str.max_size ();
+
+            basic_streambuf<_CharT, _Traits>* const __rdbuf = __is.rdbuf ();
+
+            const ctype<_CharT> &__ctp =
+                _USE_FACET (ctype<_CharT>, __is.getloc ());
+
+#ifndef _RWSTD_NO_FRIEND_TEMPLATE
+
+            while (__n != 0) {
+
+                const _CharT* const __gptr  = __rdbuf->gptr ();
+                const _CharT* const __egptr = __rdbuf->egptr ();
+
+                // maximum number of characters would want to extract
+                _SizeT __navail = __egptr - __gptr;
+                if (__n < __navail)
+                    __navail = __n;
+
+                if (__navail) {
+
+                    // find the delimeter in the squence if it exists, or
+                    // get pointer to end of sequence
+                    const _CharT* __pdel = __gptr;
+                    for (/**/; __pdel != __egptr; ++__pdel) {
+
+                        const _TYPENAME _Traits::int_type
+                            __c = _Traits::to_int_type(*__pdel);
+
+                        if (_Traits::eq_int_type (__c, _Traits::eof ())) {
+                            __err = ios_base::eofbit;
+                            break;
+                        }
+
+                        if (__ctp.is (__ctp.space, *__pdel))
+                            break;
+                    }
+
+                    // __pdel is either pointing to a delimiter or one past
+                    // the end of the input stream get area. if it is past
+                    // the end, then set it to null.
+                    if (__pdel == __egptr) {
+                        __pdel = 0;
+                    }
+
+                    if (__pdel) {
+                        __navail = __pdel - __gptr + 1;
+                        __n     -= __navail - 1;
+                    }
+                    else if (__n == __navail)
+                        __n -= --__navail;
+                    else
+                        __n -= __navail;
+
+                    // store characters excluding the delimiter
+                    __str.append (__gptr, __navail - !!__pdel);
+
+                    __gcount += __navail;
+
+                    // advance gptr() by the number of extracted
+                    // characters, including the delimiter
+                    __rdbuf->gbump (__navail);
+
+                    // we found a delimiter before the end of the get area,
+                    // break out of outer loop
+                    if (__pdel) {
+                        break;
+                    }
+
+                    if (2 > __n && _SizeT (__egptr - __gptr) != __navail) {
+                        __err = ios_base::failbit;
+                        break;
+                    }
+                }
+                else {
+
+                    // n data in buffer, trigger underflow()
+                    // note that streambuf may be unbuffered
+                    const _TYPENAME _Traits::int_type
+                        __c = __rdbuf->sgetc ();
+
+                    if (_Traits::eq_int_type (__c, _Traits::eof ())) {
+                        __err = ios_base::eofbit;
+                        break;
+                    }
+
+                    // convert to char_type so that isspace works correctly
+                    const _TYPENAME _Traits::char_type
+                        __ch = _Traits::to_char_type (__c);
+
+                    if (__ctp.is (__ctp.space, __ch))
+                        break;
+
+                    __str.push_back (__ch);
+                    --__n;
+
+                    __rdbuf->sbumpc ();
+
+                    // increment gcount only _after_ sbumpc() but _before_
+                    // the subsequent call to sgetc() to correctly reflect
+                    // the number of extracted characters in the presence
+                    // of exceptions thrown from streambuf virtuals
+                    ++__gcount;
+                }
+            }
+
+#else   // if defined (_RWSTD_NO_FRIEND_TEMPLATE)
+
+            for ( ; __n != 0; ) {
+
+                const _TYPENAME _Traits::int_type
+                    __c (__rdbuf->sgetc ());
+
+                if (_Traits::eq_int_type (__c, _Traits::eof ())) {
+                    __err = ios_base::eofbit;
+                    break;
+                }
+
+                // convert to char_type so that isspace works correctly
+                const _TYPENAME _Traits::char_type
+                    __ch = _Traits::to_char_type (__c);
+
+                if (__ctp.is (__ctp.space, __ch))
+                    break;
+
+                __str.push_back (__ch);
+                --__n;
+
+                __rdbuf->sbumpc ();
+
+                // increment gcount only _after_ sbumpc() but _before_
+                // the subsequent call to sgetc() to correctly reflect
+                // the number of extracted characters in the presence
+                // of exceptions thrown from streambuf virtuals
+                ++__gcount;
+            }
+
+#endif   // if defined (_RWSTD_NO_FRIEND_TEMPLATE)
+
+            __is.width (0);
+        }
+    }
+    _CATCH (...) {
+        __is.setstate (ios_base::badbit | _RW::__rw_rethrow);
+    }
+
+    if (!__gcount)
+        __err |= ios_base::failbit;
+
+    if (__err)
+        __is.setstate (__err);
+
+    return __is;
+}
+
+
+_EXPORT
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+getline (basic_istream<_CharT, _Traits>&            __is, 
+         basic_string<_CharT, _Traits, _Allocator>& __str, 
+         _CharT                                     __delim)
+{
+    _RWSTD_ASSERT (0 != __is.rdbuf ());
+
+    const _TYPENAME basic_istream<_CharT, _Traits>::sentry
+        __ipfx (__is, true /* noskipws */);
+
+#ifndef _RWSTD_NO_FRIEND_TEMPLATE
+
+    ios_base::iostate __err = ios_base::goodbit;
+
+    typedef _RWSTD_SIZE_T _SizeT;
+
+    _SizeT __gcount = 0;
+
+    if (__ipfx) { 
+
+        __str.clear ();
+
+        // carefuly handle arithmetic overflow
+        _SizeT __n = __str.max_size ();
+        if (__n + _SizeT (1))
+            ++__n;
+
+        basic_streambuf<_CharT, _Traits>* const __rdbuf = __is.rdbuf ();
+
+        _TRY {
+
+            for ( ; ; ) {
+
+                typedef _TYPENAME _Traits::int_type int_type;
+
+                const _CharT* const __gptr  = __rdbuf->gptr ();
+                const _CharT* const __egptr = __rdbuf->egptr ();
+
+                // compute the lesser of the number of characters in the
+                // stream buffer and the size of the destination buffer
+                _SizeT __navail = __egptr - __gptr;
+                if (__n < __navail)
+                    __navail = __n;
+
+                if (__navail) {
+
+                    // find the delimiter in the sequence if it exists
+                    const _CharT* const __pdel =
+                        _Traits::find (__gptr, __navail, __delim);
+
+                    if (__pdel) {
+                        __navail = __pdel - __gptr + 1;
+                        __n     -= __navail - 1;
+                    }
+                    else if (__n == __navail)
+                        __n -= --__navail;
+                    else
+                        __n -= __navail;
+
+                    // store characters excluding the delimiter
+                    __str.append (__gptr, __navail - !!__pdel);
+
+                    __gcount += __navail;
+
+                    // advance gptr() by the number of extracted
+                    // characters, including the delimiter
+                    __rdbuf->gbump (__navail);
+
+                    if (__pdel) {
+                        break;
+                    }
+
+                    if (2 > __n && _SizeT (__egptr - __gptr) != __navail) {
+                        __err = ios_base::failbit;
+                        break;
+                    }
+                }
+                else {
+
+                    // no data in buffer, trigger underflow()
+                    // note that streambuf may be unbuffered
+                    const int_type __c (__rdbuf->sgetc ());
+
+                    if (_Traits::eq_int_type (__c, _Traits::eof ())) {
+                        __err = ios_base::eofbit;
+                        break;
+                    }
+
+                    const _CharT __ch = _Traits::to_char_type (__c);
+                    if (_Traits::eq (__ch, __delim)) {
+                        __rdbuf->sbumpc ();
+                        __gcount++;
+                        break;
+                    }
+
+                    if (2 > __n) {
+                        __err = ios_base::failbit;
+                        break;
+                    }
+
+                    __str += __ch;
+                    --__n;
+
+                    __rdbuf->sbumpc ();
+
+                    // increment gcount only _after_ sbumpc() but _before_
+                    // the subsequent call to sgetc() to correctly reflect
+                    // the number of extracted characters in the presence
+                    // of exceptions thrown from streambuf virtuals
+                    ++__gcount;
+                }
+            }
+        }
+        _CATCH (...) {
+            __is.setstate (ios_base::badbit | _RW::__rw_rethrow);
+        }
+    }
+
+    if (!__gcount)
+        __err |= ios_base::failbit;
+
+#else   // if defined (_RWSTD_NO_FRIEND_TEMPLATE)
+
+    ios_base::iostate __err = ios_base::failbit;
+
+    if (__ipfx) { 
+
+        _TRY {
+
+            __str.clear ();
+
+            const _RWSTD_SIZE_T __max_size = __str.max_size ();
+
+            // FIXME: code commented out to work around an HP aCC 3.14.10
+            // bug #JAGac86264
+
+            // typedef _TYPENAME
+            //     basic_string<_CharT, _Traits, _Allocator>::size_type
+
+            for ( ; ; ) {
+
+                const _TYPENAME _Traits::int_type
+                    __c (__is.rdbuf ()->sgetc ());
+
+                if (_Traits::eq_int_type (__c, _Traits::eof ())) {
+                    // 21.3.7.9, p7
+                    if (__str.size ())
+                        __err = ios_base::eofbit;
+                    else
+                        __err = ios_base::eofbit | ios_base::failbit;
+
+                    break;
+                }
+
+                if (_Traits::eq (_Traits::to_char_type (__c), __delim)) {
+                    __is.rdbuf ()->sbumpc ();
+                    __err = ios_base::goodbit;
+                    break;
+                }
+
+                if (__max_size <= __str.size ())
+                    break;
+
+                __str.push_back (_Traits::to_char_type (__c));
+
+                __is.rdbuf ()->sbumpc ();
+            }
+        }
+        _CATCH (...) {
+            __is.setstate (ios_base::badbit | _RW::__rw_rethrow);
+        }
+    }
+
+#endif   // _RWSTD_NO_FRIEND_TEMPLATE
+
+    if (__err)
+        __is.setstate (__err);
+
+    return __is;
+}  
+
+
+}   // namespace std

Propchange: stdcxx/trunk/include/rw/_stringio.cc
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: stdcxx/trunk/include/rw/_stringio.cc
------------------------------------------------------------------------------
    svn:keywords = Id

Added: stdcxx/trunk/include/rw/_stringio.h
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/rw/_stringio.h?rev=630250&view=auto
==============================================================================
--- stdcxx/trunk/include/rw/_stringio.h (added)
+++ stdcxx/trunk/include/rw/_stringio.h Fri Feb 22 08:59:56 2008
@@ -0,0 +1,149 @@
+// -*- C++ -*-
+/***************************************************************************
+ *
+ * _stringio.h - declarations of the string extractors
+ *
+ * This is an internal header file used to implement the C++ Standard
+ * Library. It should never be #included directly by a program.
+ *
+ * $Id$
+ *
+ ***************************************************************************
+ *
+ * Licensed to the Apache Software  Foundation (ASF) under one or more
+ * contributor  license agreements.  See  the NOTICE  file distributed
+ * with  this  work  for  additional information  regarding  copyright
+ * ownership.   The ASF  licenses this  file to  you under  the Apache
+ * License, Version  2.0 (the  "License"); you may  not use  this file
+ * except in  compliance with the License.   You may obtain  a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the  License is distributed on an  "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY  KIND, either  express or
+ * implied.   See  the License  for  the  specific language  governing
+ * permissions and limitations under the License.
+ *
+ * Copyright 2003-2006 Rogue Wave Software.
+ * 
+ **************************************************************************/
+
+#if __GNUG__ >= 3
+#  pragma GCC system_header
+#endif   // gcc >= 3
+
+#ifndef _RWSTD_RW_STRINGIO_H_INCLUDED
+#define _RWSTD_RW_STRINGIO_H_INCLUDED
+
+
+_RWSTD_NAMESPACE (std) {
+
+
+_EXPORT
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+operator>> (basic_istream<_CharT, _Traits>&,
+            basic_string<_CharT, _Traits, _Allocator>&);
+
+
+_EXPORT
+template<class _CharT, class _Traits, class _Allocator>
+basic_istream<_CharT, _Traits>&
+getline (basic_istream<_CharT, _Traits>&,
+         basic_string<_CharT, _Traits, _Allocator>&,
+         _CharT);
+
+
+template<class _CharT, class _Traits, class _Allocator>
+inline basic_istream<_CharT, _Traits>& 
+getline (basic_istream<_CharT, _Traits>&            __is,
+         basic_string<_CharT, _Traits, _Allocator>& __str);
+
+
+template<class _CharT, class _Traits, class _Allocator>
+inline basic_ostream<_CharT, _Traits>&
+operator<< (basic_ostream<_CharT, _Traits>&,
+            const basic_string<_CharT, _Traits, _Allocator>&);
+
+
+}   // namespace std
+
+
+#endif   // _RWSTD_RW_STRINGIO_H_INCLUDED
+
+
+#if   !defined (_RWSTD_STRING_INSERTER_INCLUDED) \
+    && defined (_RWSTD_INCLUDE_STRING_INSERTER)
+#  define _RWSTD_STRING_INSERTER_INCLUDED
+
+_RWSTD_NAMESPACE (std) {
+
+template<class _CharT, class _Traits, class _Allocator>
+inline basic_ostream<_CharT, _Traits>&
+operator<< (basic_ostream<_CharT, _Traits>&                  __os,
+            const basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+    return _RW::__rw_insert (__os, __str.data (), __str.length (),
+                             __os.width ());
+}
+
+}   // namespace std
+
+#endif   // !_RWSTD_STRING_INSERTER_INCLUDED
+
+
+#if   !defined (_RWSTD_STRING_EXTRACTORS_INCLUDED) \
+    && defined (_RWSTD_INCLUDE_STRING_EXTRACTORS)
+#  define _RWSTD_STRING_EXTRACTORS_INCLUDED
+
+
+_RWSTD_NAMESPACE (std) {
+
+template<class _CharT, class _Traits, class _Allocator>
+inline basic_istream<_CharT, _Traits>& 
+getline (basic_istream<_CharT, _Traits>&            __is,
+         basic_string<_CharT, _Traits, _Allocator>& __str)
+{
+    return getline (__is, __str, __is.widen ('\n'));
+}
+
+}   // namespace std
+
+
+#  if _RWSTD_DEFINE_TEMPLATE_FIRST (_BASIC_ISTREAM)
+#    include <rw/_stringio.cc>
+#  endif   // _RWSTD_DEFINE_TEMPLATE_FIRST (_BASIC_ISTREAM)
+
+
+_RWSTD_NAMESPACE (std) {
+
+#if _RWSTD_INSTANTIATE (_BASIC_ISTREAM, _CHAR)
+
+_RWSTD_INSTANTIATE_FUN_1 (_RWSTD_TI_EXPORT istream&
+                          operator>> (istream&, string&));
+
+_RWSTD_INSTANTIATE_FUN_1 (_RWSTD_TI_EXPORT istream&
+                          getline (istream&, string&, char));
+
+#endif   // _RWSTD_INSTANTIATE (_BASIC_ISTREAM, _CHAR)
+
+#if _RWSTD_INSTANTIATE (_BASIC_ISTREAM, _WCHAR_T)
+
+_RWSTD_INSTANTIATE_FUN_1 (_RWSTD_TI_EXPORT wistream&
+                          operator>> (wistream&, wstring&));
+
+_RWSTD_INSTANTIATE_FUN_1 (_RWSTD_TI_EXPORT wistream&
+                          getline (wistream&, wstring&, wchar_t));
+#endif   // _RWSTD_INSTANTIATE (_BASIC_ISTREAM, _WCHAR_T)
+
+}   // namespace std
+
+
+#  if _RWSTD_DEFINE_TEMPLATE_LAST (_BASIC_ISTREAM)
+#    include <rw/_stringio.cc>
+#  endif   // _RWSTD_DEFINE_TEMPLATE_LAST (_BASIC_ISTREAM)
+
+
+#endif   // !_RWSTD_STRING_EXTRACTORS_INCLUDED

Propchange: stdcxx/trunk/include/rw/_stringio.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: stdcxx/trunk/include/rw/_stringio.h
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: stdcxx/trunk/include/string
URL: http://svn.apache.org/viewvc/stdcxx/trunk/include/string?rev=630250&r1=630249&r2=630250&view=diff
==============================================================================
--- stdcxx/trunk/include/string (original)
+++ stdcxx/trunk/include/string Fri Feb 22 08:59:56 2008
@@ -1509,38 +1509,12 @@
 }
 
 
-// 21.3.7.9 - declared here, defined in <istream.cc>
-_EXPORT
-template<class _CharT, class _Traits, class _Allocator>
-basic_istream<_CharT, _Traits>&
-operator>> (basic_istream<_CharT, _Traits>&,
-            basic_string<_CharT, _Traits, _Allocator>&);
-
-
-// 21.3.7.9 - declared here, defined in <istream.cc>
-_EXPORT
-template<class _CharT, class _Traits, class _Allocator>
-basic_istream<_CharT, _Traits>&
-getline (basic_istream<_CharT, _Traits>&,
-         basic_string<_CharT, _Traits, _Allocator>&,
-         _CharT);
-
-
-// 21.3.7.9 - declared here, defined inline in <istream>
-template<class _CharT, class _Traits, class _Allocator>
-inline basic_istream<_CharT, _Traits>& 
-getline (basic_istream<_CharT, _Traits>&,
-         basic_string<_CharT, _Traits, _Allocator>&);
-
-
-// 21.3.7.9, p3 - declared here, defined inline in <ostream>
-template<class _CharT, class _Traits, class _Allocator>
-inline basic_ostream<_CharT, _Traits>&
-operator<< (basic_ostream<_CharT, _Traits>&,
-            const basic_string<_CharT, _Traits, _Allocator>&);
+}   // namespace std
 
 
-}   // namespace std
+#ifndef _RWSTD_RW_STRINGIO_H_INCLUDED
+#  include <rw/_stringio.h>
+#endif   // _RWSTD_RW_STRINGIO_H_INCLUDED
 
 
 _RWSTD_NAMESPACE (__rw) { 

Modified: stdcxx/trunk/src/export.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/src/export.cpp?rev=630250&r1=630249&r2=630250&view=diff
==============================================================================
--- stdcxx/trunk/src/export.cpp (original)
+++ stdcxx/trunk/src/export.cpp Fri Feb 22 08:59:56 2008
@@ -114,6 +114,9 @@
 #include <rw/_basic_ios.h>
 #include <rw/_basic_ios.cc>
 
+#include <rw/_stringio.h>
+#include <rw/_stringio.cc>
+
 #include <rw/_heap.h>
 #include <rw/_heap.cc>
 



Mime
View raw message