33#ifndef _GLIBCXX_FSTREAM
34#define _GLIBCXX_FSTREAM 1
36#pragma GCC system_header
45#if __cplusplus >= 201103L
49#define __glibcxx_want_fstream_native_handle
53#ifndef _GLIBCXX_BUFSIZ
54# define _GLIBCXX_BUFSIZ BUFSIZ
57namespace std _GLIBCXX_VISIBILITY(default)
59_GLIBCXX_BEGIN_NAMESPACE_VERSION
61#if __cplusplus >= 201703L
63 template<
typename _Path,
typename _Result = _Path,
typename _Path2
89 template<
typename _CharT,
typename _Traits>
92#if __cplusplus >= 201103L
93 template<
typename _Tp>
94 using __chk_state = __and_<is_copy_assignable<_Tp>,
98 static_assert(__chk_state<typename _Traits::state_type>::value,
99 "state_type must be CopyAssignable, CopyConstructible"
100 " and DefaultConstructible");
102 static_assert(
is_same<
typename _Traits::pos_type,
104 "pos_type must be fpos<state_type>");
108 typedef _CharT char_type;
109 typedef _Traits traits_type;
110 typedef typename traits_type::int_type int_type;
111 typedef typename traits_type::pos_type pos_type;
112 typedef typename traits_type::off_type off_type;
116 typedef __basic_file<char> __file_type;
117 typedef typename traits_type::state_type __state_type;
120 friend class ios_base;
134 __state_type _M_state_beg;
139 __state_type _M_state_cur;
143 __state_type _M_state_last;
156 bool _M_buf_allocated;
181 const __codecvt_type* _M_codecvt;
214 _M_pback_end_save = this->
egptr();
247#if __cplusplus >= 201103L
264#if __cplusplus >= 201103L
276 {
return _M_file.is_open(); }
322#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
333#if __cplusplus >= 201103L
344#if __cplusplus >= 201703L
351 template<
typename _Path>
352 _If_fs_path<_Path, __filebuf_type*>
354 {
return open(__s.c_str(), __mode); }
373#if __cpp_lib_fstream_native_handle
383 using native_handle_type =
typename __file_type::native_handle_type;
394 [[__gnu__::__always_inline__]]
396 native_handle() const noexcept
399 return _M_file.native_handle();
405 _M_allocate_internal_buffer();
408 _M_destroy_internal_buffer() throw();
438 _M_convert_to_external(char_type*,
streamsize);
452 virtual __streambuf_type*
456 seekoff(off_type __off, ios_base::seekdir __way,
457 ios_base::openmode __mode = ios_base::in | ios_base::out);
461 ios_base::openmode __mode = ios_base::in | ios_base::out);
465 _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state);
468 _M_get_ext_pos(__state_type &__state);
484 _M_terminate_output();
505 if (__testin && __off > 0)
531 template<
typename _CharT,
typename _Traits>
536 typedef _CharT char_type;
537 typedef _Traits traits_type;
538 typedef typename traits_type::int_type int_type;
539 typedef typename traits_type::pos_type pos_type;
540 typedef typename traits_type::off_type off_type;
547 __filebuf_type _M_filebuf;
559 { this->
init(&_M_filebuf); }
570 : __istream_type(), _M_filebuf()
572 this->
init(&_M_filebuf);
573 this->
open(__s, __mode);
576#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
586 : __istream_type(), _M_filebuf()
588 this->
init(&_M_filebuf);
589 this->
open(__s, __mode);
593#if __cplusplus >= 201103L
604 : __istream_type(), _M_filebuf()
606 this->
init(&_M_filebuf);
607 this->
open(__s, __mode);
610#if __cplusplus >= 201703L
618 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
628 : __istream_type(
std::
move(__rhs)),
629 _M_filebuf(
std::
move(__rhs._M_filebuf))
630 { __istream_type::set_rdbuf(&_M_filebuf); }
642#if __cplusplus >= 201103L
651 __istream_type::operator=(
std::move(__rhs));
652 _M_filebuf =
std::move(__rhs._M_filebuf);
659 __istream_type::swap(__rhs);
660 _M_filebuf.swap(__rhs._M_filebuf);
673 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
681 {
return _M_filebuf.is_open(); }
687 {
return _M_filebuf.
is_open(); }
708#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
727#if __cplusplus >= 201103L
747#if __cplusplus >= 201703L
756 template<
typename _Path>
757 _If_fs_path<_Path, void>
759 {
open(__s.c_str(), __mode); }
772 if (!_M_filebuf.close())
776#if __cpp_lib_fstream_native_handle
777 using native_handle_type =
typename __filebuf_type::native_handle_type;
779 [[__gnu__::__always_inline__]]
781 native_handle() const noexcept
782 {
return _M_filebuf.native_handle(); }
801 template<
typename _CharT,
typename _Traits>
806 typedef _CharT char_type;
807 typedef _Traits traits_type;
808 typedef typename traits_type::int_type int_type;
809 typedef typename traits_type::pos_type pos_type;
810 typedef typename traits_type::off_type off_type;
817 __filebuf_type _M_filebuf;
829 { this->
init(&_M_filebuf); }
841 : __ostream_type(), _M_filebuf()
843 this->
init(&_M_filebuf);
844 this->
open(__s, __mode);
847#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
858 : __ostream_type(), _M_filebuf()
860 this->
init(&_M_filebuf);
861 this->
open(__s, __mode);
865#if __cplusplus >= 201103L
876 : __ostream_type(), _M_filebuf()
878 this->
init(&_M_filebuf);
879 this->
open(__s, __mode);
882#if __cplusplus >= 201703L
890 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
900 : __ostream_type(
std::
move(__rhs)),
901 _M_filebuf(
std::
move(__rhs._M_filebuf))
902 { __ostream_type::set_rdbuf(&_M_filebuf); }
914#if __cplusplus >= 201103L
923 __ostream_type::operator=(
std::move(__rhs));
924 _M_filebuf =
std::move(__rhs._M_filebuf);
931 __ostream_type::swap(__rhs);
932 _M_filebuf.swap(__rhs._M_filebuf);
945 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
953 {
return _M_filebuf.is_open(); }
959 {
return _M_filebuf.
is_open(); }
980#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
999#if __cplusplus >= 201103L
1019#if __cplusplus >= 201703L
1028 template<
typename _Path>
1029 _If_fs_path<_Path, void>
1031 {
open(__s.c_str(), __mode); }
1044 if (!_M_filebuf.close())
1048#if __cpp_lib_fstream_native_handle
1049 using native_handle_type =
typename __filebuf_type::native_handle_type;
1051 [[__gnu__::__always_inline__]]
1053 native_handle() const noexcept
1054 {
return _M_filebuf.native_handle(); }
1073 template<
typename _CharT,
typename _Traits>
1078 typedef _CharT char_type;
1079 typedef _Traits traits_type;
1080 typedef typename traits_type::int_type int_type;
1081 typedef typename traits_type::pos_type pos_type;
1082 typedef typename traits_type::off_type off_type;
1090 __filebuf_type _M_filebuf;
1102 : __iostream_type(), _M_filebuf()
1103 { this->
init(&_M_filebuf); }
1113 : __iostream_type(0), _M_filebuf()
1115 this->
init(&_M_filebuf);
1116 this->
open(__s, __mode);
1119#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
1127 : __iostream_type(0), _M_filebuf()
1129 this->
init(&_M_filebuf);
1130 this->
open(__s, __mode);
1134#if __cplusplus >= 201103L
1143 : __iostream_type(0), _M_filebuf()
1145 this->
init(&_M_filebuf);
1146 this->
open(__s, __mode);
1149#if __cplusplus >= 201703L
1155 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
1165 : __iostream_type(
std::
move(__rhs)),
1166 _M_filebuf(
std::
move(__rhs._M_filebuf))
1167 { __iostream_type::set_rdbuf(&_M_filebuf); }
1179#if __cplusplus >= 201103L
1188 __iostream_type::operator=(
std::move(__rhs));
1189 _M_filebuf =
std::move(__rhs._M_filebuf);
1196 __iostream_type::swap(__rhs);
1197 _M_filebuf.swap(__rhs._M_filebuf);
1210 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
1218 {
return _M_filebuf.is_open(); }
1224 {
return _M_filebuf.
is_open(); }
1238 if (!_M_filebuf.open(__s, __mode))
1246#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
1256 open(
const wchar_t* __s,
1259 if (!_M_filebuf.
open(__s, __mode))
1266#if __cplusplus >= 201103L
1279 if (!_M_filebuf.open(__s, __mode))
1287#if __cplusplus >= 201703L
1296 template<
typename _Path>
1297 _If_fs_path<_Path, void>
1300 {
open(__s.c_str(), __mode); }
1313 if (!_M_filebuf.close())
1317#if __cpp_lib_fstream_native_handle
1318 using native_handle_type =
typename __filebuf_type::native_handle_type;
1320 [[__gnu__::__always_inline__]]
1322 native_handle() const noexcept
1323 {
return _M_filebuf.native_handle(); }
1327#if __cplusplus >= 201103L
1329 template <
class _CharT,
class _Traits>
1336 template <
class _CharT,
class _Traits>
1343 template <
class _CharT,
class _Traits>
1350 template <
class _CharT,
class _Traits>
1357_GLIBCXX_END_NAMESPACE_VERSION
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
auto declval() noexcept -> decltype(__declval< _Tp >(0))
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
basic_string< char > string
A string of char.
ISO C++ entities toplevel namespace is std.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
The actual work of input and output (for files).
virtual pos_type seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __mode=ios_base::in|ios_base::out)
virtual int_type underflow()
virtual streamsize showmanyc()
ios_base::openmode _M_mode
virtual ~basic_filebuf()
The destructor closes the file first.
streamsize _M_ext_buf_size
char_type * _M_pback_cur_save
_If_fs_path< _Path, __filebuf_type * > open(const _Path &__s, ios_base::openmode __mode)
Opens an external file.
__filebuf_type * open(const std::string &__s, ios_base::openmode __mode)
Opens an external file.
virtual void imbue(const locale &__loc)
virtual streamsize xsgetn(char_type *__s, streamsize __n)
bool is_open() const
Returns true if the external file is open.
__filebuf_type * close()
Closes the currently associated file.
char_type * _M_pback_end_save
virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode=ios_base::in|ios_base::out)
virtual int_type pbackfail(int_type __c=traits_type::eof())
virtual streamsize xsputn(const char_type *__s, streamsize __n)
virtual int_type overflow(int_type __c=traits_type::eof())
__filebuf_type * open(const char *__s, ios_base::openmode __mode)
Opens an external file.
basic_filebuf()
Does not open any files.
void _M_set_buffer(streamsize __off)
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Controlling input for files.
basic_ifstream()
Default constructor.
~basic_ifstream()
The destructor does nothing.
_If_fs_path< _Path, void > open(const _Path &__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
void open(const char *__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
basic_ifstream(const char *__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
basic_ifstream(const _Path &__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
basic_ifstream(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
void close()
Close the file.
bool is_open()
Wrapper to test for an open file.
Controlling output for files.
basic_ofstream()
Default constructor.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
basic_ofstream(const char *__s, ios_base::openmode __mode=ios_base::out)
Create an output file stream.
void close()
Close the file.
basic_ofstream(const _Path &__s, ios_base::openmode __mode=ios_base::out)
Create an output file stream.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
void open(const char *__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
basic_ofstream(const std::string &__s, ios_base::openmode __mode=ios_base::out)
Create an output file stream.
~basic_ofstream()
The destructor does nothing.
_If_fs_path< _Path, void > open(const _Path &__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
bool is_open()
Wrapper to test for an open file.
Controlling input and output for files.
_If_fs_path< _Path, void > open(const _Path &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
~basic_fstream()
The destructor does nothing.
basic_fstream(const _Path &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
void open(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
basic_fstream(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
bool is_open()
Wrapper to test for an open file.
void close()
Close the file.
basic_fstream(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
basic_fstream()
Default constructor.
Template class basic_ios, virtual base class for all stream classes.
void clear(iostate __state=goodbit)
[Re]sets the error state.
void setstate(iostate __state)
Sets additional flags in the error state.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
char_type * eback() const
Access to the get area.
char_type * egptr() const
Access to the get area.
char_type * gptr() const
Access to the get area.
void setp(char_type *__pbeg, char_type *__pend)
Setting the three write area pointers.
basic_streambuf()
Base constructor.
basic_istream(__streambuf_type *__sb)
Base constructor.
basic_ostream(__streambuf_type *__sb)
Base constructor.
basic_iostream(basic_streambuf< _CharT, _Traits > *__sb)
Constructor does nothing.
constexpr const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
Primary class template codecvt.
static const openmode in
Open for input. Default for ifstream and fstream.
static const openmode out
Open for output. Default for ofstream and fstream.
_Ios_Openmode openmode
This is a bitmask type.
static const openmode app
Seek to end before each write.
static const openmode trunc
Truncate an existing stream when opening. Default for ofstream.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
Container class for localization functionality.
Class representing stream positions.