Bug 2645770: Missing getline implementation for flex_string

Implement both getline overloads. The implementation is from the SGI STL (http://www.sgi.com/tech/stl/) and comes with the following copyright:

Permission to use, copy, modify, distribute and sell this software and its documentation for any purpose is hereby granted without fee, provided that the below copyright notice appears in all copies and that both the copyright notice and this permission notice appear in supporting documentation. Silicon Graphics makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty.

Copyright © 1997-1999
Silicon Graphics Computer Systems, Inc.

Copyright © 1994
Hewlett-Packard Company 

git-svn-id: svn://svn.code.sf.net/p/loki-lib/code/trunk@989 7ec92016-0320-0410-acc4-a06ded1c099a
This commit is contained in:
jfbastien 2009-03-02 14:54:16 +00:00
parent 56225861f7
commit c776744629

View file

@ -1284,7 +1284,37 @@ getline(
std::basic_istream<typename flex_string<E, T, A, S>::value_type,
typename flex_string<E, T, A, S>::traits_type>& is,
flex_string<E, T, A, S>& str,
typename flex_string<E, T, A, S>::value_type delim);
typename flex_string<E, T, A, S>::value_type delim)
{
size_t nread = 0;
typename basic_istream<typename flex_string<E, T, A, S>::value_type,
typename flex_string<E, T, A, S>::traits_type>::sentry sentry(is, true);
if (sentry) {
basic_streambuf<typename flex_string<E, T, A, S>::value_type,
typename flex_string<E, T, A, S>::traits_type>* buf = is.rdbuf();
str.clear();
while (nread < str.max_size()) {
int c1 = buf->sbumpc();
if (flex_string<E, T, A, S>::traits_type::eq_int_type(c1, flex_string<E, T, A, S>::traits_type::eof())) {
is.setstate(ios_base::eofbit);
break;
}
else {
++nread;
typename flex_string<E, T, A, S>::value_type c = flex_string<E, T, A, S>::traits_type::to_char_type(c1);
if (!flex_string<E, T, A, S>::traits_type::eq(c, delim))
str.push_back(c);
else
break; // Character is extracted but not appended.
}
}
}
if (nread == 0 || nread >= str.max_size())
is.setstate(ios_base::failbit);
return is;
}
template <typename E, class T, class A, class S>
std::basic_istream<typename flex_string<E, T, A, S>::value_type,
@ -1292,7 +1322,10 @@ std::basic_istream<typename flex_string<E, T, A, S>::value_type,
getline(
std::basic_istream<typename flex_string<E, T, A, S>::value_type,
typename flex_string<E, T, A, S>::traits_type>& is,
flex_string<E, T, A, S>& str);
flex_string<E, T, A, S>& str)
{
return getline(is, str, is.widen('\n'));
}
template <typename E1, class T, class A, class S>
const typename flex_string<E1, T, A, S>::size_type