// Input streams -*- C++ -*-
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-// 2006, 2007
+// 2006, 2007, 2008, 2009, 2010, 2011
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
+// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-// 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, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02110-1301, USA.
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
-// As a special exception, you may use this file as part of a free software
-// library without restriction. Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License. This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
//
// ISO C++ 14882: 27.6.1 Input streams
//
-/** @file istream
+/** @file include/istream
* This is a Standard C++ Library header.
*/
#pragma GCC system_header
#include <ios>
-#include <locale>
#include <ostream>
-#include <limits> // For numeric_limits
-_GLIBCXX_BEGIN_NAMESPACE(std)
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
// [27.6.1.1] Template class basic_istream
/**
* @brief Controlling input.
+ * @ingroup io
*
* This is the base class for all input streams. It provides text
* formatting of all builtin types, and communicates with any class
protected:
// Data Members:
/**
- * @if maint
* The number of characters extracted in the previous unformatted
* function; see gcount().
- * @endif
*/
streamsize _M_gcount;
* derived classes' initialization lists, which pass a pointer to
* their own stream buffer.
*/
- explicit
- basic_istream(__streambuf_type* __sb): _M_gcount(streamsize(0))
+ explicit
+ basic_istream(__streambuf_type* __sb)
+ : _M_gcount(streamsize(0))
{ this->init(__sb); }
/**
/**
* @brief Interface for manipulators.
*
- * Manuipulators such as @c std::ws and @c std::dec use these
- * functions in constructs like "std::cin >> std::ws". For more
- * information, see the iomanip header.
+ * Manipulators such as @c std::ws and @c std::dec use these
+ * functions in constructs like
+ * <code>std::cin >> std::ws</code>.
+ * For more information, see the iomanip header.
*/
__istream_type&
operator>>(__istream_type& (*__pf)(__istream_type&))
* @param n Maximum number of characters to store in @a s.
* @return *this
*
- * Returns @c get(s,n,widen('\n')).
+ * Returns @c get(s,n,widen('\\n')).
*/
__istream_type&
get(char_type* __s, streamsize __n)
* @param sb A streambuf in which to store data.
* @return *this
*
- * Returns @c get(sb,widen('\n')).
+ * Returns @c get(sb,widen('\\n')).
*/
__istream_type&
get(__streambuf_type& __sb)
* @param n Maximum number of characters to extract.
* @return *this
*
- * Returns @c getline(s,n,widen('\n')).
+ * Returns @c getline(s,n,widen('\\n')).
*/
__istream_type&
getline(char_type* __s, streamsize __n)
* If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
* the error state.
*
- * @note Since no characters are extracted, the next call to
- * @c gcount() will return 0, as required by DR 60.
+ * @note This function first clears eofbit. Since no characters
+ * are extracted, the next call to @c gcount() will return 0,
+ * as required by DR 60.
*/
__istream_type&
putback(char_type __c);
* If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
* the error state.
*
- * @note Since no characters are extracted, the next call to
- * @c gcount() will return 0, as required by DR 60.
+ * @note This function first clears eofbit. Since no characters
+ * are extracted, the next call to @c gcount() will return 0,
+ * as required by DR 60.
*/
__istream_type&
unget();
*
* @note This function does not count the number of characters
* extracted, if any, and therefore does not affect the next
- * call to @c gcount().
+ * call to @c gcount(). At variance with putback, unget and
+ * seekg, eofbit is not cleared first.
*/
- pos_type
+ pos_type
tellg();
/**
* If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If
* that function fails, sets failbit.
*
- * @note This function does not count the number of characters
- * extracted, if any, and therefore does not affect the next
- * call to @c gcount().
+ * @note This function first clears eofbit. It does not count the
+ * number of characters extracted, if any, and therefore does
+ * not affect the next call to @c gcount().
*/
- __istream_type&
+ __istream_type&
seekg(pos_type);
/**
* If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
* If that function fails, sets failbit.
*
- * @note This function does not count the number of characters
- * extracted, if any, and therefore does not affect the next
- * call to @c gcount().
+ * @note This function first clears eofbit. It does not count the
+ * number of characters extracted, if any, and therefore does
+ * not affect the next call to @c gcount().
*/
__istream_type&
seekg(off_type, ios_base::seekdir);
//@}
protected:
- explicit
- basic_istream(): _M_gcount(streamsize(0)) { }
+ basic_istream()
+ : _M_gcount(streamsize(0))
+ { this->init(0); }
template<typename _ValueT>
__istream_type&
* @brief Performs setup work for input streams.
*
* Objects of this class are created before all of the standard
- * extractors are run. It is responsible for "exception-safe prefix and
- * suffix operations," although only prefix actions are currently required
- * by the standard. Additional actions may be added by the
- * implementation, and we list them in
- * http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5
- * under [27.6] notes.
+ * extractors are run. It is responsible for <em>exception-safe
+ * prefix and suffix operations,</em> although only prefix actions
+ * are currently required by the standard.
*/
template<typename _CharT, typename _Traits>
class basic_istream<_CharT, _Traits>::sentry
{
+ // Data Members.
+ bool _M_ok;
+
public:
/// Easy access to dependant types.
typedef _Traits traits_type;
* @param noskipws Whether to consume whitespace or not.
*
* If the stream state is good (@a is.good() is true), then the
- * following actions are performed, otherwise the sentry state is
- * false ("not okay") and failbit is set in the stream state.
+ * following actions are performed, otherwise the sentry state
+ * is false (<em>not okay</em>) and failbit is set in the
+ * stream state.
*
* The sentry's preparatory actions are:
*
* used to determine whether each character is whitespace.
*
* If the stream state is still good, then the sentry state becomes
- * true ("okay").
+ * true (@a okay).
*/
- explicit
+ explicit
sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
/**
* For ease of use, sentries may be converted to booleans. The
* return value is that of the sentry state (true == okay).
*/
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ explicit
+#endif
operator bool() const
{ return _M_ok; }
-
- private:
- bool _M_ok;
};
// [27.6.1.2.3] character extraction templates
* status, this function extracts up to @c n characters and stores them
* into the array starting at @a s. @c n is defined as:
*
- * - if @c width() is greater than zero, @c n is width()
- * - otherwise @c n is "the number of elements of the largest array of
- * @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6
+ * - if @c width() is greater than zero, @c n is width() otherwise
+ * - @c n is <em>the number of elements of the largest array of *
+ * - @c char_type that can store a terminating @c eos.</em>
+ * - [27.6.1.2.3]/6
*
* Characters are extracted and stored until one of the following happens:
* - @c n-1 characters are stored
// 27.6.1.5 Template class basic_iostream
/**
* @brief Merging istream and ostream capabilities.
+ * @ingroup io
*
* This class multiply inherits from the input and output stream classes
* simply to provide a single interface.
* Both of the parent classes are initialized with the same
* streambuf pointer passed to this constructor.
*/
- explicit
+ explicit
basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
- : __istream_type(), __ostream_type()
- { this->init(__sb); }
+ : __istream_type(__sb), __ostream_type(__sb) { }
/**
* @brief Destructor does nothing.
~basic_iostream() { }
protected:
- explicit
- basic_iostream() : __istream_type(), __ostream_type()
- { }
+ basic_iostream()
+ : __istream_type(), __ostream_type() { }
};
// [27.6.1.4] standard basic_istream manipulators
basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __is);
-_GLIBCXX_END_NAMESPACE
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ // [27.7.1.6] Rvalue stream extraction
+ /**
+ * @brief Generic extractor for rvalue stream
+ * @param is An input stream.
+ * @param x A reference to the extraction target.
+ * @return is
+ *
+ * This is just a forwarding function to allow extraction from
+ * rvalue streams since they won't bind to the extractor functions
+ * that take an lvalue reference.
+ */
+ template<typename _CharT, typename _Traits, typename _Tp>
+ inline basic_istream<_CharT, _Traits>&
+ operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
+ { return (__is >> __x); }
+#endif // __GXX_EXPERIMENTAL_CXX0X__
-#ifndef _GLIBCXX_EXPORT_TEMPLATE
-# include <bits/istream.tcc>
-#endif
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+
+#include <bits/istream.tcc>
#endif /* _GLIBCXX_ISTREAM */