Whole document tree
    

Whole document tree

std_istream.h Source File
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   // 27.6.1.1 Template class basic_istream
00045   template<typename _CharT, typename _Traits>
00046     class basic_istream : virtual public basic_ios<_CharT, _Traits>
00047     {
00048     public:
00049       // Types (inherited from basic_ios (27.4.4)):
00050       typedef _CharT                            char_type;
00051       typedef typename _Traits::int_type        int_type;
00052       typedef typename _Traits::pos_type        pos_type;
00053       typedef typename _Traits::off_type        off_type;
00054       typedef _Traits                           traits_type;
00055       
00056       // Non-standard Types:
00057       typedef basic_streambuf<_CharT, _Traits>      __streambuf_type;
00058       typedef basic_ios<_CharT, _Traits>        __ios_type;
00059       typedef basic_istream<_CharT, _Traits>        __istream_type;
00060       typedef istreambuf_iterator<_CharT, _Traits>  __istreambuf_iter;
00061       typedef num_get<_CharT, __istreambuf_iter>        __numget_type;
00062       typedef ctype<_CharT>                     __ctype_type;
00063 
00064     protected:
00065       // Data Members:
00066       streamsize        _M_gcount;
00067 
00068     public:
00069       // 27.6.1.1.1 Constructor/destructor:
00070       explicit 
00071       basic_istream(__streambuf_type* __sb)
00072       { 
00073     this->init(__sb);
00074     _M_gcount = streamsize(0);
00075       }
00076 
00077       virtual 
00078       ~basic_istream() 
00079       { _M_gcount = streamsize(0); }
00080 
00081       // 27.6.1.1.2 Prefix/suffix:
00082       class sentry;
00083       friend class sentry;
00084 
00085       // 27.6.1.2 Formatted input:
00086       // 27.6.1.2.3 basic_istream::operator>>
00087       __istream_type&
00088       operator>>(__istream_type& (*__pf)(__istream_type&));
00089 
00090       __istream_type&
00091       operator>>(__ios_type& (*__pf)(__ios_type&));
00092 
00093       __istream_type&
00094       operator>>(ios_base& (*__pf)(ios_base&));
00095       
00096       // 27.6.1.2.2 Arithmetic Extractors
00097       __istream_type& 
00098       operator>>(bool& __n);
00099       
00100       __istream_type& 
00101       operator>>(short& __n);
00102       
00103       __istream_type& 
00104       operator>>(unsigned short& __n);
00105 
00106       __istream_type& 
00107       operator>>(int& __n);
00108       
00109       __istream_type& 
00110       operator>>(unsigned int& __n);
00111 
00112       __istream_type& 
00113       operator>>(long& __n);
00114       
00115       __istream_type& 
00116       operator>>(unsigned long& __n);
00117 
00118 #ifdef _GLIBCPP_USE_LONG_LONG
00119       __istream_type& 
00120       operator>>(long long& __n);
00121 
00122       __istream_type& 
00123       operator>>(unsigned long long& __n);
00124 #endif
00125 
00126       __istream_type& 
00127       operator>>(float& __f);
00128 
00129       __istream_type& 
00130       operator>>(double& __f);
00131 
00132       __istream_type& 
00133       operator>>(long double& __f);
00134 
00135       __istream_type& 
00136       operator>>(void*& __p);
00137 
00138       __istream_type& 
00139       operator>>(__streambuf_type* __sb);
00140       
00141       // 27.6.1.3 Unformatted input:
00142       inline streamsize 
00143       gcount(void) const 
00144       { return _M_gcount; }
00145       
00146       int_type 
00147       get(void);
00148 
00149       __istream_type& 
00150       get(char_type& __c);
00151 
00152       __istream_type& 
00153       get(char_type* __s, streamsize __n, char_type __delim);
00154 
00155       inline __istream_type& 
00156       get(char_type* __s, streamsize __n)
00157       { return get(__s, __n, this->widen('\n')); }
00158 
00159       __istream_type&
00160       get(__streambuf_type& __sb, char_type __delim);
00161 
00162       inline __istream_type&
00163       get(__streambuf_type& __sb)
00164       { return get(__sb, this->widen('\n')); }
00165 
00166       __istream_type& 
00167       getline(char_type* __s, streamsize __n, char_type __delim);
00168 
00169       inline __istream_type& 
00170       getline(char_type* __s, streamsize __n)
00171       { return getline(__s, __n, this->widen('\n')); }
00172 
00173       __istream_type& 
00174       ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
00175       
00176       int_type 
00177       peek(void);
00178       
00179       __istream_type& 
00180       read(char_type* __s, streamsize __n);
00181 
00182       streamsize 
00183       readsome(char_type* __s, streamsize __n);
00184       
00185       __istream_type& 
00186       putback(char_type __c);
00187 
00188       __istream_type& 
00189       unget(void);
00190 
00191       int 
00192       sync(void);
00193 
00194       pos_type 
00195       tellg(void);
00196 
00197       __istream_type& 
00198       seekg(pos_type);
00199 
00200       __istream_type& 
00201       seekg(off_type, ios_base::seekdir);
00202 
00203     private:
00204 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00205       // Not defined.
00206       __istream_type& 
00207       operator=(const __istream_type&);
00208 
00209       basic_istream(const __istream_type&);
00210 #endif
00211     };
00212   
00213   template<typename _CharT, typename _Traits>
00214     class basic_istream<_CharT, _Traits>::sentry
00215     {
00216     public:
00217       typedef _Traits                   traits_type;
00218       typedef basic_streambuf<_CharT, _Traits>      __streambuf_type;
00219       typedef basic_istream<_CharT, _Traits>        __istream_type;
00220       typedef typename __istream_type::__ctype_type     __ctype_type;
00221       typedef typename _Traits::int_type        __int_type;
00222 
00223       explicit 
00224       sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
00225 
00226       operator bool() { return _M_ok; }
00227 
00228     private:
00229       bool _M_ok;
00230     };
00231 
00232   // 27.6.1.2.3 Character extraction templates
00233   template<typename _CharT, typename _Traits>
00234     basic_istream<_CharT, _Traits>&
00235     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
00236 
00237   template<class _Traits>
00238     basic_istream<char, _Traits>&
00239     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
00240     { return (__in >> reinterpret_cast<char&>(__c)); }
00241 
00242   template<class _Traits>
00243     basic_istream<char, _Traits>&
00244     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
00245     { return (__in >> reinterpret_cast<char&>(__c)); }
00246 
00247   template<typename _CharT, typename _Traits>
00248     basic_istream<_CharT, _Traits>&
00249     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
00250   
00251   template<class _Traits>
00252     basic_istream<char,_Traits>&
00253     operator>>(basic_istream<char,_Traits>& __in, unsigned char* __s)
00254     { return (__in >> reinterpret_cast<char*>(__s)); }
00255 
00256   template<class _Traits>
00257     basic_istream<char,_Traits>&
00258     operator>>(basic_istream<char,_Traits>& __in, signed char* __s)
00259     { return (__in >> reinterpret_cast<char*>(__s)); }
00260 
00261   // 27.6.1.5 Template class basic_iostream
00262   template<typename _CharT, typename _Traits>
00263     class basic_iostream
00264     : public basic_istream<_CharT, _Traits>,
00265       public basic_ostream<_CharT, _Traits>
00266     {
00267     public:
00268       // Non-standard Types:
00269       typedef basic_istream<_CharT, _Traits>        __istream_type;
00270       typedef basic_ostream<_CharT, _Traits>        __ostream_type;
00271 
00272       explicit 
00273       basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
00274       : __istream_type(__sb), __ostream_type(__sb)
00275       { }
00276 
00277       virtual 
00278       ~basic_iostream() { }
00279     };
00280 
00281   // 27.6.1.4 Standard basic_istream manipulators
00282   template<typename _CharT, typename _Traits>
00283     basic_istream<_CharT, _Traits>& 
00284     ws(basic_istream<_CharT, _Traits>& __is);
00285 } // namespace std
00286 
00287 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
00288 # define export
00289 #ifdef  _GLIBCPP_FULLY_COMPLIANT_HEADERS
00290 # include <bits/istream.tcc>
00291 #endif
00292 #endif
00293 
00294 #endif  /* _CPP_ISTREAM */
00295 

Generated on Mon Apr 8 03:11:33 2002 for libstdc++-v3 Source by doxygen1.2.15