Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

std_istream.h

Go to the documentation of this file.
00001 // Input streams -*- C++ -*-
00002 
00003 // Copyright (C) 1997-1999, 2001 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 //
00031 // ISO C++ 14882: 27.6.1  Input streams
00032 //
00033 
00034 #ifndef _CPP_ISTREAM
00035 #define _CPP_ISTREAM    1
00036 
00037 #pragma GCC system_header
00038 
00039 #include <bits/std_ios.h>
00040 #include <bits/std_limits.h> // For numeric_limits
00041 
00042 namespace std
00043 {
00044 
00045   // 27.6.1.1 Template class basic_istream
00046   template<typename _CharT, typename _Traits>
00047     class basic_istream : virtual public basic_ios<_CharT, _Traits>
00048     {
00049     public:
00050 
00051       // Types (inherited from basic_ios (27.4.4)):
00052       typedef _CharT                            char_type;
00053       typedef typename _Traits::int_type        int_type;
00054       typedef typename _Traits::pos_type        pos_type;
00055       typedef typename _Traits::off_type        off_type;
00056       typedef _Traits                           traits_type;
00057       
00058       // Non-standard Types:
00059       typedef basic_streambuf<_CharT, _Traits>      __streambuf_type;
00060       typedef basic_ios<_CharT, _Traits>        __ios_type;
00061       typedef basic_istream<_CharT, _Traits>        __istream_type;
00062       typedef istreambuf_iterator<_CharT>       __istreambuf_iter;
00063       typedef num_get<_CharT, __istreambuf_iter>        __numget_type;
00064       typedef ctype<_CharT>                     __ctype_type;
00065 
00066     protected:
00067       // Data Members:
00068       streamsize        _M_gcount;
00069 
00070     public:
00071       // 27.6.1.1.1 Constructor/destructor:
00072       explicit 
00073       basic_istream(__streambuf_type* __sb)
00074       { 
00075     this->init(__sb);
00076     _M_gcount = streamsize(0);
00077       }
00078 
00079       virtual 
00080       ~basic_istream() 
00081       {
00082     _M_gcount = streamsize(0);
00083     _M_fnumget = NULL; 
00084       }
00085 
00086       // 27.6.1.1.2 Prefix/suffix:
00087       class sentry;
00088       friend class sentry;
00089 
00090       // 27.6.1.2 Formatted input:
00091       // 27.6.1.2.3 basic_istream::operator>>
00092       __istream_type&
00093       operator>>(__istream_type& (*__pf)(__istream_type&));
00094 
00095       __istream_type&
00096       operator>>(__ios_type& (*__pf)(__ios_type&));
00097 
00098       __istream_type&
00099       operator>>(ios_base& (*__pf)(ios_base&));
00100       
00101       // 27.6.1.2.2 Arithmetic Extractors
00102       __istream_type& 
00103       operator>>(bool& __n);
00104       
00105       __istream_type& 
00106       operator>>(short& __n);
00107       
00108       __istream_type& 
00109       operator>>(unsigned short& __n);
00110 
00111       __istream_type& 
00112       operator>>(int& __n);
00113       
00114       __istream_type& 
00115       operator>>(unsigned int& __n);
00116 
00117       __istream_type& 
00118       operator>>(long& __n);
00119       
00120       __istream_type& 
00121       operator>>(unsigned long& __n);
00122 
00123 #ifdef _GLIBCPP_USE_LONG_LONG
00124       __istream_type& 
00125       operator>>(long long& __n);
00126 
00127       __istream_type& 
00128       operator>>(unsigned long long& __n);
00129 #endif
00130 
00131       __istream_type& 
00132       operator>>(float& __f);
00133 
00134       __istream_type& 
00135       operator>>(double& __f);
00136 
00137       __istream_type& 
00138       operator>>(long double& __f);
00139 
00140       __istream_type& 
00141       operator>>(void*& __p);
00142 
00143       __istream_type& 
00144       operator>>(__streambuf_type* __sb);
00145       
00146       // 27.6.1.3 Unformatted input:
00147       inline streamsize 
00148       gcount(void) const 
00149       { return _M_gcount; }
00150       
00151       int_type 
00152       get(void);
00153 
00154       __istream_type& 
00155       get(char_type& __c);
00156 
00157       __istream_type& 
00158       get(char_type* __s, streamsize __n, char_type __delim);
00159 
00160       inline __istream_type& 
00161       get(char_type* __s, streamsize __n)
00162       { return get(__s, __n, this->widen('\n')); }
00163 
00164       __istream_type&
00165       get(__streambuf_type& __sb, char_type __delim);
00166 
00167       inline __istream_type&
00168       get(__streambuf_type& __sb)
00169       { return get(__sb, this->widen('\n')); }
00170 
00171       __istream_type& 
00172       getline(char_type* __s, streamsize __n, char_type __delim);
00173 
00174       inline __istream_type& 
00175       getline(char_type* __s, streamsize __n)
00176       { return getline(__s, __n, this->widen('\n')); }
00177 
00178       __istream_type& 
00179       ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
00180       
00181       int_type 
00182       peek(void);
00183       
00184       __istream_type& 
00185       read(char_type* __s, streamsize __n);
00186 
00187       streamsize 
00188       readsome(char_type* __s, streamsize __n);
00189       
00190       __istream_type& 
00191       putback(char_type __c);
00192 
00193       __istream_type& 
00194       unget(void);
00195 
00196       int 
00197       sync(void);
00198 
00199       pos_type 
00200       tellg(void);
00201 
00202       __istream_type& 
00203       seekg(pos_type);
00204 
00205       __istream_type& 
00206       seekg(off_type, ios_base::seekdir);
00207 
00208     private:
00209 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00210       // Not defined.
00211       __istream_type& 
00212       operator=(const __istream_type&);
00213 
00214       basic_istream(const __istream_type&);
00215 #endif
00216     };
00217   
00218   template<typename _CharT, typename _Traits>
00219     class basic_istream<_CharT, _Traits>::sentry
00220     {
00221     public:
00222 
00223       typedef _Traits                   traits_type;
00224       typedef basic_streambuf<_CharT, _Traits>      __streambuf_type;
00225       typedef basic_istream<_CharT, _Traits>        __istream_type;
00226       typedef __istream_type::__ctype_type      __ctype_type;
00227       typedef typename _Traits::int_type        __int_type;
00228 
00229       explicit 
00230       sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
00231 
00232       operator bool() { return _M_ok; }
00233 
00234     private:
00235       bool _M_ok;
00236     };
00237 
00238   // 27.6.1.2.3 Character extraction templates
00239   template<typename _CharT, typename _Traits>
00240     basic_istream<_CharT, _Traits>&
00241     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
00242 
00243   template<class _Traits>
00244     basic_istream<char, _Traits>&
00245     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
00246     { return (__in >> reinterpret_cast<char&>(__c)); }
00247 
00248   template<class _Traits>
00249     basic_istream<char, _Traits>&
00250     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
00251     { return (__in >> reinterpret_cast<char&>(__c)); }
00252 
00253   template<typename _CharT, typename _Traits>
00254     basic_istream<_CharT, _Traits>&
00255     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
00256   
00257   template<class _Traits>
00258     basic_istream<char,_Traits>&
00259     operator>>(basic_istream<char,_Traits>& __in, unsigned char* __s)
00260     { return (__in >> reinterpret_cast<char*>(__s)); }
00261 
00262   template<class _Traits>
00263     basic_istream<char,_Traits>&
00264     operator>>(basic_istream<char,_Traits>& __in, signed char* __s)
00265     { return (__in >> reinterpret_cast<char*>(__s)); }
00266 
00267   // 27.6.1.5 Template class basic_iostream
00268   template<typename _CharT, typename _Traits>
00269     class basic_iostream
00270     : public basic_istream<_CharT, _Traits>,
00271       public basic_ostream<_CharT, _Traits>
00272     {
00273     public:
00274 
00275       // Non-standard Types:
00276       typedef basic_istream<_CharT, _Traits>        __istream_type;
00277       typedef basic_ostream<_CharT, _Traits>        __ostream_type;
00278 
00279       explicit 
00280       basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
00281       : __istream_type(__sb), __ostream_type(__sb)
00282       { }
00283 
00284       virtual 
00285       ~basic_iostream() { }
00286     };
00287 
00288   // 27.6.1.4 Standard basic_istream manipulators
00289   template<typename _CharT, typename _Traits>
00290     basic_istream<_CharT, _Traits>& 
00291     ws(basic_istream<_CharT, _Traits>& __is);
00292 
00293 } // namespace std
00294 
00295 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
00296 # define export
00297 #ifdef  _GLIBCPP_FULLY_COMPLIANT_HEADERS
00298 # include <bits/istream.tcc>
00299 #endif
00300 #endif
00301 
00302 #endif  /* _CPP_ISTREAM */
00303 

Generated at Tue May 1 16:28:38 2001 for libstdc++-v3 by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001