]>
Commit | Line | Data |
---|---|---|
c0a26060 BK |
1 | // Wrapper of C-language FILE struct -*- C++ -*- |
2 | ||
99dee823 | 3 | // Copyright (C) 2000-2021 Free Software Foundation, Inc. |
c0a26060 BK |
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 | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
c0a26060 BK |
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 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
c0a26060 BK |
24 | |
25 | // | |
26 | // ISO C++ 14882: 27.8 File-based streams | |
27 | // | |
28 | ||
f910786b | 29 | /** @file bits/basic_file.h |
00532602 | 30 | * This is an internal header file, included by other library headers. |
f910786b | 31 | * Do not attempt to use it directly. @headername{ios} |
00532602 | 32 | */ |
c0a26060 | 33 | |
311635d1 BK |
34 | #ifndef _GLIBCXX_BASIC_FILE_STDIO_H |
35 | #define _GLIBCXX_BASIC_FILE_STDIO_H 1 | |
c0a26060 | 36 | |
00532602 | 37 | #pragma GCC system_header |
c0a26060 | 38 | |
00532602 | 39 | #include <bits/c++config.h> |
bd91a8c4 | 40 | #include <bits/c++io.h> // for __c_lock and __c_file |
9b817548 | 41 | #include <bits/move.h> // for swap |
00532602 | 42 | #include <ios> |
ddf1e652 | 43 | |
12ffa228 BK |
44 | namespace std _GLIBCXX_VISIBILITY(default) |
45 | { | |
46 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
3cbc7af0 | 47 | |
00532602 | 48 | // Generic declaration. |
ddf1e652 | 49 | template<typename _CharT> |
f92ab29f | 50 | class __basic_file; |
ddf1e652 | 51 | |
00532602 BK |
52 | // Specialization. |
53 | template<> | |
54 | class __basic_file<char> | |
ddf1e652 | 55 | { |
00532602 | 56 | // Underlying data source/sink. |
d3a193e3 | 57 | __c_file* _M_cfile; |
51ff8149 | 58 | |
00532602 BK |
59 | // True iff we opened _M_cfile, and thus must close it ourselves. |
60 | bool _M_cfile_created; | |
c0a26060 | 61 | |
00532602 | 62 | public: |
b91cc3b9 | 63 | __basic_file(__c_lock* __lock = 0) throw (); |
6a734d61 | 64 | |
9b817548 | 65 | #if __cplusplus >= 201103L |
9ed83a33 | 66 | __basic_file(__basic_file&& __rv, __c_lock* = 0) noexcept |
9b817548 JW |
67 | : _M_cfile(__rv._M_cfile), _M_cfile_created(__rv._M_cfile_created) |
68 | { | |
69 | __rv._M_cfile = nullptr; | |
70 | __rv._M_cfile_created = false; | |
71 | } | |
72 | ||
73 | __basic_file& operator=(const __basic_file&) = delete; | |
74 | __basic_file& operator=(__basic_file&&) = delete; | |
75 | ||
76 | void | |
77 | swap(__basic_file& __f) noexcept | |
78 | { | |
79 | std::swap(_M_cfile, __f._M_cfile); | |
80 | std::swap(_M_cfile_created, __f._M_cfile_created); | |
81 | } | |
82 | #endif | |
83 | ||
f92ab29f | 84 | __basic_file* |
00532602 | 85 | open(const char* __name, ios_base::openmode __mode, int __prot = 0664); |
c0a26060 | 86 | |
b0292359 JW |
87 | #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T |
88 | __basic_file* | |
89 | open(const wchar_t* __name, ios_base::openmode __mode); | |
90 | #endif | |
91 | ||
00532602 | 92 | __basic_file* |
5cdd50a5 BK |
93 | sys_open(__c_file* __file, ios_base::openmode); |
94 | ||
95 | __basic_file* | |
b91cc3b9 | 96 | sys_open(int __fd, ios_base::openmode __mode) throw (); |
c0a26060 | 97 | |
f92ab29f CG |
98 | __basic_file* |
99 | close(); | |
c0a26060 | 100 | |
f92ab29f | 101 | _GLIBCXX_PURE bool |
b91cc3b9 | 102 | is_open() const throw (); |
c0a26060 | 103 | |
f92ab29f | 104 | _GLIBCXX_PURE int |
b91cc3b9 | 105 | fd() throw (); |
c0a26060 | 106 | |
b91cc3b9 JH |
107 | _GLIBCXX_PURE __c_file* |
108 | file() throw (); | |
803cb0b5 | 109 | |
00532602 | 110 | ~__basic_file(); |
c0a26060 | 111 | |
f92ab29f | 112 | streamsize |
51ff8149 | 113 | xsputn(const char* __s, streamsize __n); |
c0a26060 | 114 | |
f92ab29f | 115 | streamsize |
bda243ec PC |
116 | xsputn_2(const char* __s1, streamsize __n1, |
117 | const char* __s2, streamsize __n2); | |
118 | ||
f92ab29f | 119 | streamsize |
51ff8149 | 120 | xsgetn(char* __s, streamsize __n); |
c0a26060 | 121 | |
4c4809c1 | 122 | streamoff |
b91cc3b9 | 123 | seekoff(streamoff __off, ios_base::seekdir __way) throw (); |
c0a26060 | 124 | |
f92ab29f | 125 | int |
00532602 | 126 | sync(); |
bbacb998 PC |
127 | |
128 | streamsize | |
51ff8149 | 129 | showmanyc(); |
00532602 | 130 | }; |
3cbc7af0 | 131 | |
12ffa228 BK |
132 | _GLIBCXX_END_NAMESPACE_VERSION |
133 | } // namespace | |
00532602 | 134 | |
f92ab29f | 135 | #endif |