libstdc++
basic_file.h
Go to the documentation of this file.
00001 // Wrapper of C-language FILE struct -*- C++ -*-
00002 
00003 // Copyright (C) 2000-2015 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 3, 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 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 //
00026 // ISO C++ 14882: 27.8  File-based streams
00027 //
00028 
00029 /** @file bits/basic_file.h
00030  *  This is an internal header file, included by other library headers.
00031  *  Do not attempt to use it directly. @headername{ios}
00032  */
00033 
00034 #ifndef _GLIBCXX_BASIC_FILE_STDIO_H
00035 #define _GLIBCXX_BASIC_FILE_STDIO_H 1
00036 
00037 #pragma GCC system_header
00038 
00039 #include <bits/c++config.h>
00040 #include <bits/c++io.h>  // for __c_lock and __c_file
00041 #include <bits/move.h>   // for swap
00042 #include <ios>
00043 
00044 namespace std _GLIBCXX_VISIBILITY(default)
00045 {
00046 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00047 
00048   // Generic declaration.
00049   template<typename _CharT>
00050     class __basic_file; 
00051 
00052   // Specialization.
00053   template<>
00054     class __basic_file<char>
00055     {
00056       // Underlying data source/sink.
00057       __c_file*         _M_cfile;
00058 
00059       // True iff we opened _M_cfile, and thus must close it ourselves.
00060       bool              _M_cfile_created;
00061 
00062     public:
00063       __basic_file(__c_lock* __lock = 0) throw ();
00064 
00065 #if __cplusplus >= 201103L
00066       __basic_file(__basic_file&& __rv, __c_lock* __lock = 0) noexcept
00067       : _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created)
00068       {
00069         __rv._M_cfile = nullptr;
00070         __rv._M_cfile_created = false;
00071       }
00072 
00073       __basic_file& operator=(const __basic_file&) = delete;
00074       __basic_file& operator=(__basic_file&&) = delete;
00075 
00076       void
00077       swap(__basic_file& __f) noexcept
00078       {
00079         std::swap(_M_cfile, __f._M_cfile);
00080         std::swap(_M_cfile_created, __f._M_cfile_created);
00081       }
00082 #endif
00083 
00084       __basic_file* 
00085       open(const char* __name, ios_base::openmode __mode, int __prot = 0664);
00086 
00087       __basic_file*
00088       sys_open(__c_file* __file, ios_base::openmode);
00089 
00090       __basic_file*
00091       sys_open(int __fd, ios_base::openmode __mode) throw ();
00092 
00093       __basic_file* 
00094       close(); 
00095 
00096       _GLIBCXX_PURE bool 
00097       is_open() const throw ();
00098 
00099       _GLIBCXX_PURE int 
00100       fd() throw ();
00101 
00102       _GLIBCXX_PURE __c_file*
00103       file() throw ();
00104 
00105       ~__basic_file();
00106 
00107       streamsize 
00108       xsputn(const char* __s, streamsize __n);
00109 
00110       streamsize 
00111       xsputn_2(const char* __s1, streamsize __n1,
00112                const char* __s2, streamsize __n2);
00113 
00114       streamsize 
00115       xsgetn(char* __s, streamsize __n);
00116 
00117       streamoff
00118       seekoff(streamoff __off, ios_base::seekdir __way) throw ();
00119 
00120       int 
00121       sync();
00122 
00123       streamsize
00124       showmanyc();
00125     };
00126 
00127 _GLIBCXX_END_NAMESPACE_VERSION
00128 } // namespace
00129 
00130 #endif