⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 std_fstream.h

📁 俄罗斯高人Mamaich的Pocket gcc编译器(运行在PocketPC上)的全部源代码。
💻 H
📖 第 1 页 / 共 2 页
字号:
      bool      _M_is_indeterminate(void)      { 	bool __ret = false;	// Don't return true if unbuffered.	if (_M_buf)	  {	    if (_M_mode & ios_base::in)	      __ret = _M_in_beg == _M_in_cur && _M_in_cur == _M_in_end;	    if (_M_mode & ios_base::out)	      __ret = _M_out_beg == _M_out_cur && _M_out_cur == _M_out_end;	  }	return __ret;      }    };  // Explicit specialization declarations, defined in src/fstream.cc.  template<>     basic_filebuf<char>::int_type     basic_filebuf<char>::_M_underflow_common(bool __bump); #ifdef _GLIBCPP_USE_WCHAR_T  template<>     basic_filebuf<wchar_t>::int_type     basic_filebuf<wchar_t>::_M_underflow_common(bool __bump); #endif  // Generic definitions.  template <typename _CharT, typename _Traits>    typename basic_filebuf<_CharT, _Traits>::int_type    basic_filebuf<_CharT, _Traits>::underflow()     { return _M_underflow_common(false); }  template <typename _CharT, typename _Traits>    typename basic_filebuf<_CharT, _Traits>::int_type    basic_filebuf<_CharT, _Traits>::uflow()     { return _M_underflow_common(true); }  // [27.8.1.5] Template class basic_ifstream  /**   *  @brief  Controlling input for files.   *   *  This class supports reading from named files, using the inherited   *  functions from std::basic_istream.  To control the associated   *  sequence, an instance of std::basic_filebuf is used, which this page   *  refers to as @c sb.  */  template<typename _CharT, typename _Traits>    class basic_ifstream : public basic_istream<_CharT, _Traits>    {    public:      // Types:      typedef _CharT 					char_type;      typedef _Traits 					traits_type;      typedef typename traits_type::int_type 		int_type;      typedef typename traits_type::pos_type 		pos_type;      typedef typename traits_type::off_type 		off_type;      // Non-standard types:      typedef basic_filebuf<char_type, traits_type> 	__filebuf_type;      typedef basic_istream<char_type, traits_type>	__istream_type;    private:      /**       *  @if maint       *  @doctodo       *  @endif      */      __filebuf_type	_M_filebuf;    public:      // Constructors/Destructors:      /**       *  @brief  Default constructor.       *       *  Initializes @c sb using its default constructor, and passes       *  @c &sb to the base class initializer.  Does not open any files       *  (you haven't given it a filename to open).      */      basic_ifstream()      : __istream_type(NULL), _M_filebuf()      { this->init(&_M_filebuf); }      /**       *  @brief  Create an input file stream.       *  @param  s  Null terminated string specifying the filename.       *  @param  mode  Open file in specified mode (see std::ios_base).       *       *  @c ios_base::in is automatically included in @a mode.       *       *  Tip:  When using std::string to hold the filename, you must use       *  .c_str() before passing it to this constructor.      */      explicit      basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in)      : __istream_type(NULL), _M_filebuf()      {	this->init(&_M_filebuf);	this->open(__s, __mode);      }      /**       *  @brief  The destructor does nothing.       *       *  The file is closed by the filebuf object, not the formatting       *  stream.      */      ~basic_ifstream()      { }      // Members:      /**       *  @brief  Accessing the underlying buffer.       *  @return  The current basic_filebuf buffer.       *       *  This hides both signatures of std::basic_ios::rdbuf().      */      __filebuf_type*      rdbuf() const      { return const_cast<__filebuf_type*>(&_M_filebuf); }      /**       *  @brief  Wrapper to test for an open file.       *  @return  @c rdbuf()->is_open()      */      bool      is_open() { return _M_filebuf.is_open(); }      /**       *  @brief  Opens an external file.       *  @param  s  The name of the file.       *  @param  mode  The open mode flags.       *       *  Calls @c std::basic_filebuf::open(s,mode|in).  If that function       *  fails, @c failbit is set in the stream's error state.       *       *  Tip:  When using std::string to hold the filename, you must use       *  .c_str() before passing it to this constructor.      */      void      open(const char* __s, ios_base::openmode __mode = ios_base::in)      {	if (!_M_filebuf.open(__s, __mode | ios_base::in))	  this->setstate(ios_base::failbit);      }      /**       *  @brief  Close the file.       *       *  Calls @c std::basic_filebuf::close().  If that function       *  fails, @c failbit is set in the stream's error state.      */      void      close()      {	if (!_M_filebuf.close())	  this->setstate(ios_base::failbit);      }    };  // [27.8.1.8] Template class basic_ofstream  /**   *  @brief  Controlling output for files.   *   *  This class supports reading from named files, using the inherited   *  functions from std::basic_ostream.  To control the associated   *  sequence, an instance of std::basic_filebuf is used, which this page   *  refers to as @c sb.  */  template<typename _CharT, typename _Traits>    class basic_ofstream : public basic_ostream<_CharT,_Traits>    {    public:      // Types:      typedef _CharT 					char_type;      typedef _Traits 					traits_type;      typedef typename traits_type::int_type 		int_type;      typedef typename traits_type::pos_type 		pos_type;      typedef typename traits_type::off_type 		off_type;      // Non-standard types:      typedef basic_filebuf<char_type, traits_type> 	__filebuf_type;      typedef basic_ostream<char_type, traits_type>	__ostream_type;    private:      /**       *  @if maint       *  @doctodo       *  @endif      */      __filebuf_type	_M_filebuf;    public:      // Constructors:      /**       *  @brief  Default constructor.       *       *  Initializes @c sb using its default constructor, and passes       *  @c &sb to the base class initializer.  Does not open any files       *  (you haven't given it a filename to open).      */      basic_ofstream()      : __ostream_type(NULL), _M_filebuf()      { this->init(&_M_filebuf); }      /**       *  @brief  Create an output file stream.       *  @param  s  Null terminated string specifying the filename.       *  @param  mode  Open file in specified mode (see std::ios_base).       *       *  @c ios_base::out|ios_base::trunc is automatically included in       *  @a mode.       *       *  Tip:  When using std::string to hold the filename, you must use       *  .c_str() before passing it to this constructor.      */      explicit      basic_ofstream(const char* __s,		     ios_base::openmode __mode = ios_base::out|ios_base::trunc)      : __ostream_type(NULL), _M_filebuf()      {	this->init(&_M_filebuf);	this->open(__s, __mode);      }      /**       *  @brief  The destructor does nothing.       *       *  The file is closed by the filebuf object, not the formatting       *  stream.      */      ~basic_ofstream()      { }      // Members:      /**       *  @brief  Accessing the underlying buffer.       *  @return  The current basic_filebuf buffer.       *       *  This hides both signatures of std::basic_ios::rdbuf().      */      __filebuf_type*      rdbuf() const      { return const_cast<__filebuf_type*>(&_M_filebuf); }      /**       *  @brief  Wrapper to test for an open file.       *  @return  @c rdbuf()->is_open()      */      bool      is_open() { return _M_filebuf.is_open(); }      /**       *  @brief  Opens an external file.       *  @param  s  The name of the file.       *  @param  mode  The open mode flags.       *       *  Calls @c std::basic_filebuf::open(s,mode|out|trunc).  If that       *  function fails, @c failbit is set in the stream's error state.       *       *  Tip:  When using std::string to hold the filename, you must use       *  .c_str() before passing it to this constructor.      */      void      open(const char* __s,	   ios_base::openmode __mode = ios_base::out | ios_base::trunc)      {	if (!_M_filebuf.open(__s, __mode | ios_base::out))	  this->setstate(ios_base::failbit);      }      /**       *  @brief  Close the file.       *       *  Calls @c std::basic_filebuf::close().  If that function       *  fails, @c failbit is set in the stream's error state.      */      void      close()      {	if (!_M_filebuf.close())	  this->setstate(ios_base::failbit);      }    };  // [27.8.1.11] Template class basic_fstream  /**   *  @brief  Controlling intput and output for files.   *   *  This class supports reading from and writing to named files, using   *  the inherited functions from std::basic_iostream.  To control the   *  associated sequence, an instance of std::basic_filebuf is used, which   *  this page refers to as @c sb.  */  template<typename _CharT, typename _Traits>    class basic_fstream : public basic_iostream<_CharT, _Traits>    {    public:      // Types:      typedef _CharT 					char_type;      typedef _Traits 					traits_type;      typedef typename traits_type::int_type 		int_type;      typedef typename traits_type::pos_type 		pos_type;      typedef typename traits_type::off_type 		off_type;      // Non-standard types:      typedef basic_filebuf<char_type, traits_type> 	__filebuf_type;      typedef basic_ios<char_type, traits_type>		__ios_type;      typedef basic_iostream<char_type, traits_type>	__iostream_type;    private:      /**       *  @if maint       *  @doctodo       *  @endif      */      __filebuf_type	_M_filebuf;    public:      // Constructors/destructor:      /**       *  @brief  Default constructor.       *       *  Initializes @c sb using its default constructor, and passes       *  @c &sb to the base class initializer.  Does not open any files       *  (you haven't given it a filename to open).      */      basic_fstream()      : __iostream_type(NULL), _M_filebuf()      { this->init(&_M_filebuf); }      /**       *  @brief  Create an input/output file stream.       *  @param  s  Null terminated string specifying the filename.       *  @param  mode  Open file in specified mode (see std::ios_base).       *       *  Tip:  When using std::string to hold the filename, you must use       *  .c_str() before passing it to this constructor.      */      explicit      basic_fstream(const char* __s,		    ios_base::openmode __mode = ios_base::in | ios_base::out)      : __iostream_type(NULL), _M_filebuf()      {	this->init(&_M_filebuf);	this->open(__s, __mode);      }      /**       *  @brief  The destructor does nothing.       *       *  The file is closed by the filebuf object, not the formatting       *  stream.      */      ~basic_fstream()      { }      // Members:      /**       *  @brief  Accessing the underlying buffer.       *  @return  The current basic_filebuf buffer.       *       *  This hides both signatures of std::basic_ios::rdbuf().      */      __filebuf_type*      rdbuf() const      { return const_cast<__filebuf_type*>(&_M_filebuf); }      /**       *  @brief  Wrapper to test for an open file.       *  @return  @c rdbuf()->is_open()      */      bool      is_open() { return _M_filebuf.is_open(); }      /**       *  @brief  Opens an external file.       *  @param  s  The name of the file.       *  @param  mode  The open mode flags.       *       *  Calls @c std::basic_filebuf::open(s,mode).  If that       *  function fails, @c failbit is set in the stream's error state.       *       *  Tip:  When using std::string to hold the filename, you must use       *  .c_str() before passing it to this constructor.      */      void      open(const char* __s,	   ios_base::openmode __mode = ios_base::in | ios_base::out)      {	if (!_M_filebuf.open(__s, __mode))	  setstate(ios_base::failbit);      }      /**       *  @brief  Close the file.       *       *  Calls @c std::basic_filebuf::close().  If that function       *  fails, @c failbit is set in the stream's error state.      */      void      close()      {	if (!_M_filebuf.close())	  setstate(ios_base::failbit);      }    };} // namespace std#ifdef _GLIBCPP_NO_TEMPLATE_EXPORT# define export#endif#ifdef  _GLIBCPP_FULLY_COMPLIANT_HEADERS# include <bits/fstream.tcc>#endif#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -