home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / cwin / c.exe / $INSTDIR / include / c++ / istream < prev    next >
Encoding:
Text File  |  2003-12-15  |  8.6 KB  |  301 lines

  1. // Input streams -*- C++ -*-
  2.  
  3. // Copyright (C) 1997, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
  4. //
  5. // This file is part of the GNU ISO C++ Library.  This library is free
  6. // software; you can redistribute it and/or modify it under the
  7. // terms of the GNU General Public License as published by the
  8. // Free Software Foundation; either version 2, or (at your option)
  9. // any later version.
  10.  
  11. // This library is distributed in the hope that it will be useful,
  12. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. // GNU General Public License for more details.
  15.  
  16. // You should have received a copy of the GNU General Public License along
  17. // with this library; see the file COPYING.  If not, write to the Free
  18. // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
  19. // USA.
  20.  
  21. // As a special exception, you may use this file as part of a free software
  22. // library without restriction.  Specifically, if other files instantiate
  23. // templates or use macros or inline functions from this file, or you compile
  24. // this file and link it with other files to produce an executable, this
  25. // file does not by itself cause the resulting executable to be covered by
  26. // the GNU General Public License.  This exception does not however
  27. // invalidate any other reasons why the executable file might be covered by
  28. // the GNU General Public License.
  29.  
  30. //
  31. // ISO C++ 14882: 27.6.1  Input streams
  32. //
  33.  
  34. /** @file istream
  35.  *  This is a Standard C++ Library header.  You should @c #include this header
  36.  *  in your programs, rather than any of the "st[dl]_*.h" implementation files.
  37.  */
  38.  
  39. #ifndef _CPP_ISTREAM
  40. #define _CPP_ISTREAM    1
  41.  
  42. #pragma GCC system_header
  43.  
  44. #include <ios>
  45. #include <limits> // For numeric_limits
  46.  
  47. namespace std
  48. {
  49.   // 27.6.1.1 Template class basic_istream
  50.   template<typename _CharT, typename _Traits>
  51.     class basic_istream : virtual public basic_ios<_CharT, _Traits>
  52.     {
  53.     public:
  54.       // Types (inherited from basic_ios (27.4.4)):
  55.       typedef _CharT                             char_type;
  56.       typedef typename _Traits::int_type         int_type;
  57.       typedef typename _Traits::pos_type         pos_type;
  58.       typedef typename _Traits::off_type         off_type;
  59.       typedef _Traits                            traits_type;
  60.       
  61.       // Non-standard Types:
  62.       typedef basic_streambuf<_CharT, _Traits>         __streambuf_type;
  63.       typedef basic_ios<_CharT, _Traits>        __ios_type;
  64.       typedef basic_istream<_CharT, _Traits>        __istream_type;
  65.       typedef istreambuf_iterator<_CharT, _Traits>    __istreambuf_iter;
  66.       typedef num_get<_CharT, __istreambuf_iter>        __numget_type;
  67.       typedef ctype<_CharT>                       __ctype_type;
  68.  
  69.     protected:
  70.       // Data Members:
  71.       streamsize         _M_gcount;
  72.  
  73.     public:
  74.       // 27.6.1.1.1 Constructor/destructor:
  75.       explicit 
  76.       basic_istream(__streambuf_type* __sb)
  77.       { 
  78.     this->init(__sb);
  79.     _M_gcount = streamsize(0);
  80.       }
  81.  
  82.       virtual 
  83.       ~basic_istream() 
  84.       { _M_gcount = streamsize(0); }
  85.  
  86.       // 27.6.1.1.2 Prefix/suffix:
  87.       class sentry;
  88.       friend class sentry;
  89.  
  90.       // 27.6.1.2 Formatted input:
  91.       // 27.6.1.2.3 basic_istream::operator>>
  92.       __istream_type&
  93.       operator>>(__istream_type& (*__pf)(__istream_type&));
  94.  
  95.       __istream_type&
  96.       operator>>(__ios_type& (*__pf)(__ios_type&));
  97.  
  98.       __istream_type&
  99.       operator>>(ios_base& (*__pf)(ios_base&));
  100.       
  101.       // 27.6.1.2.2 Arithmetic Extractors
  102.       __istream_type& 
  103.       operator>>(bool& __n);
  104.       
  105.       __istream_type& 
  106.       operator>>(short& __n);
  107.       
  108.       __istream_type& 
  109.       operator>>(unsigned short& __n);
  110.  
  111.       __istream_type& 
  112.       operator>>(int& __n);
  113.       
  114.       __istream_type& 
  115.       operator>>(unsigned int& __n);
  116.  
  117.       __istream_type& 
  118.       operator>>(long& __n);
  119.       
  120.       __istream_type& 
  121.       operator>>(unsigned long& __n);
  122.  
  123. #ifdef _GLIBCPP_USE_LONG_LONG
  124.       __istream_type& 
  125.       operator>>(long long& __n);
  126.  
  127.       __istream_type& 
  128.       operator>>(unsigned long long& __n);
  129. #endif
  130.  
  131.       __istream_type& 
  132.       operator>>(float& __f);
  133.  
  134.       __istream_type& 
  135.       operator>>(double& __f);
  136.  
  137.       __istream_type& 
  138.       operator>>(long double& __f);
  139.  
  140.       __istream_type& 
  141.       operator>>(void*& __p);
  142.  
  143.       __istream_type& 
  144.       operator>>(__streambuf_type* __sb);
  145.       
  146.       // 27.6.1.3 Unformatted input:
  147.       inline streamsize 
  148.       gcount(void) const 
  149.       { return _M_gcount; }
  150.       
  151.       int_type 
  152.       get(void);
  153.  
  154.       __istream_type& 
  155.       get(char_type& __c);
  156.  
  157.       __istream_type& 
  158.       get(char_type* __s, streamsize __n, char_type __delim);
  159.  
  160.       inline __istream_type& 
  161.       get(char_type* __s, streamsize __n)
  162.       { return this->get(__s, __n, this->widen('\n')); }
  163.  
  164.       __istream_type&
  165.       get(__streambuf_type& __sb, char_type __delim);
  166.  
  167.       inline __istream_type&
  168.       get(__streambuf_type& __sb)
  169.       { return this->get(__sb, this->widen('\n')); }
  170.  
  171.       __istream_type& 
  172.       getline(char_type* __s, streamsize __n, char_type __delim);
  173.  
  174.       inline __istream_type& 
  175.       getline(char_type* __s, streamsize __n)
  176.       { return this->getline(__s, __n, this->widen('\n')); }
  177.  
  178.       __istream_type& 
  179.       ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
  180.       
  181.       int_type 
  182.       peek(void);
  183.       
  184.       __istream_type& 
  185.       read(char_type* __s, streamsize __n);
  186.  
  187.       streamsize 
  188.       readsome(char_type* __s, streamsize __n);
  189.       
  190.       __istream_type& 
  191.       putback(char_type __c);
  192.  
  193.       __istream_type& 
  194.       unget(void);
  195.  
  196.       int 
  197.       sync(void);
  198.  
  199.       pos_type 
  200.       tellg(void);
  201.  
  202.       __istream_type& 
  203.       seekg(pos_type);
  204.  
  205.       __istream_type& 
  206.       seekg(off_type, ios_base::seekdir);
  207.     };
  208.   
  209.   template<typename _CharT, typename _Traits>
  210.     class basic_istream<_CharT, _Traits>::sentry
  211.     {
  212.     public:
  213.       typedef _Traits                     traits_type;
  214.       typedef basic_streambuf<_CharT, _Traits>         __streambuf_type;
  215.       typedef basic_istream<_CharT, _Traits>         __istream_type;
  216.       typedef typename __istream_type::__ctype_type     __ctype_type;
  217.       typedef typename _Traits::int_type        __int_type;
  218.  
  219.       explicit 
  220.       sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
  221.  
  222.       operator bool() { return _M_ok; }
  223.  
  224.     private:
  225.       bool _M_ok;
  226.     };
  227.  
  228.   // 27.6.1.2.3 Character extraction templates
  229.   template<typename _CharT, typename _Traits>
  230.     basic_istream<_CharT, _Traits>&
  231.     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
  232.  
  233.   template<class _Traits>
  234.     basic_istream<char, _Traits>&
  235.     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
  236.     { return (__in >> reinterpret_cast<char&>(__c)); }
  237.  
  238.   template<class _Traits>
  239.     basic_istream<char, _Traits>&
  240.     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
  241.     { return (__in >> reinterpret_cast<char&>(__c)); }
  242.  
  243.   template<typename _CharT, typename _Traits>
  244.     basic_istream<_CharT, _Traits>&
  245.     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
  246.   
  247.   template<class _Traits>
  248.     basic_istream<char,_Traits>&
  249.     operator>>(basic_istream<char,_Traits>& __in, unsigned char* __s)
  250.     { return (__in >> reinterpret_cast<char*>(__s)); }
  251.  
  252.   template<class _Traits>
  253.     basic_istream<char,_Traits>&
  254.     operator>>(basic_istream<char,_Traits>& __in, signed char* __s)
  255.     { return (__in >> reinterpret_cast<char*>(__s)); }
  256.  
  257.   // 27.6.1.5 Template class basic_iostream
  258.   template<typename _CharT, typename _Traits>
  259.     class basic_iostream
  260.     : public basic_istream<_CharT, _Traits>, 
  261.       public basic_ostream<_CharT, _Traits>
  262.     {
  263.     public:
  264. #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
  265. // 271. basic_iostream missing typedefs
  266.       // Types (inherited):
  267.       typedef _CharT                             char_type;
  268.       typedef typename _Traits::int_type         int_type;
  269.       typedef typename _Traits::pos_type         pos_type;
  270.       typedef typename _Traits::off_type         off_type;
  271.       typedef _Traits                            traits_type;
  272. #endif
  273.  
  274.       // Non-standard Types:
  275.       typedef basic_istream<_CharT, _Traits>        __istream_type;
  276.       typedef basic_ostream<_CharT, _Traits>        __ostream_type;
  277.  
  278.       explicit 
  279.       basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
  280.       : __istream_type(__sb), __ostream_type(__sb)
  281.       { }
  282.  
  283.       virtual 
  284.       ~basic_iostream() { }
  285.     };
  286.  
  287.   // 27.6.1.4 Standard basic_istream manipulators
  288.   template<typename _CharT, typename _Traits>
  289.     basic_istream<_CharT, _Traits>& 
  290.     ws(basic_istream<_CharT, _Traits>& __is);
  291. } // namespace std
  292.  
  293. #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
  294. # define export
  295. #endif
  296. #ifdef  _GLIBCPP_FULLY_COMPLIANT_HEADERS
  297. # include <bits/istream.tcc>
  298. #endif
  299.  
  300. #endif    /* _CPP_ISTREAM */
  301.