33#ifndef _GLIBCXX_FSTREAM
34#define _GLIBCXX_FSTREAM 1
37#pragma GCC system_header
48#if __cplusplus >= 201103L
52#define __glibcxx_want_fstream_native_handle
56#ifndef _GLIBCXX_BUFSIZ
57# define _GLIBCXX_BUFSIZ BUFSIZ
60namespace std _GLIBCXX_VISIBILITY(default)
62_GLIBCXX_BEGIN_NAMESPACE_VERSION
64#if __cplusplus >= 201703L
66 template<
typename _Path,
typename _Result = _Path,
typename _Path2
92 template<
typename _CharT,
typename _Traits>
95#if __cplusplus >= 201103L
96 template<
typename _Tp>
97 using __chk_state = __and_<is_copy_assignable<_Tp>,
101 static_assert(__chk_state<typename _Traits::state_type>::value,
102 "state_type must be CopyAssignable, CopyConstructible"
103 " and DefaultConstructible");
105 static_assert(
is_same<
typename _Traits::pos_type,
107 "pos_type must be fpos<state_type>");
111 typedef _CharT char_type;
112 typedef _Traits traits_type;
113 typedef typename traits_type::int_type int_type;
114 typedef typename traits_type::pos_type pos_type;
115 typedef typename traits_type::off_type off_type;
119 typedef __basic_file<char> __file_type;
120 typedef typename traits_type::state_type __state_type;
123 friend class ios_base;
137 __state_type _M_state_beg;
142 __state_type _M_state_cur;
146 __state_type _M_state_last;
159 bool _M_buf_allocated;
184 const __codecvt_type* _M_codecvt;
217 _M_pback_end_save = this->
egptr();
250#if __cplusplus >= 201103L
267#if __cplusplus >= 201103L
280 {
return _M_file.is_open(); }
326#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
337#if __cplusplus >= 201103L
348#if __cplusplus >= 201703L
355 template<
typename _Path>
356 _If_fs_path<_Path, __filebuf_type*>
358 {
return open(__s.c_str(), __mode); }
377#if __cpp_lib_fstream_native_handle
387 using native_handle_type =
typename __file_type::native_handle_type;
398 [[__gnu__::__always_inline__]]
400 native_handle() const noexcept
403 return _M_file.native_handle();
409 _M_allocate_internal_buffer();
412 _M_destroy_internal_buffer() throw();
442 _M_convert_to_external(char_type*,
streamsize);
456 virtual __streambuf_type*
460 seekoff(off_type __off, ios_base::seekdir __way,
461 ios_base::openmode __mode = ios_base::in | ios_base::out);
465 ios_base::openmode __mode = ios_base::in | ios_base::out);
469 _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state);
472 _M_get_ext_pos(__state_type &__state);
488 _M_terminate_output();
509 if (__testin && __off > 0)
535 template<
typename _CharT,
typename _Traits>
540 typedef _CharT char_type;
541 typedef _Traits traits_type;
542 typedef typename traits_type::int_type int_type;
543 typedef typename traits_type::pos_type pos_type;
544 typedef typename traits_type::off_type off_type;
551 __filebuf_type _M_filebuf;
563 { this->
init(&_M_filebuf); }
574 : __istream_type(), _M_filebuf()
576 this->
init(&_M_filebuf);
577 this->
open(__s, __mode);
580#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
590 : __istream_type(), _M_filebuf()
592 this->
init(&_M_filebuf);
593 this->
open(__s, __mode);
597#if __cplusplus >= 201103L
608 : __istream_type(), _M_filebuf()
610 this->
init(&_M_filebuf);
611 this->
open(__s, __mode);
614#if __cplusplus >= 201703L
622 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
632 : __istream_type(
std::
move(__rhs)),
633 _M_filebuf(
std::
move(__rhs._M_filebuf))
634 { __istream_type::set_rdbuf(&_M_filebuf); }
646#if __cplusplus >= 201103L
655 __istream_type::operator=(
std::move(__rhs));
656 _M_filebuf =
std::move(__rhs._M_filebuf);
663 __istream_type::swap(__rhs);
664 _M_filebuf.swap(__rhs._M_filebuf);
678 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
687 {
return _M_filebuf.is_open(); }
694 {
return _M_filebuf.
is_open(); }
715#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
734#if __cplusplus >= 201103L
754#if __cplusplus >= 201703L
763 template<
typename _Path>
764 _If_fs_path<_Path, void>
766 {
open(__s.c_str(), __mode); }
779 if (!_M_filebuf.close())
783#if __cpp_lib_fstream_native_handle
784 using native_handle_type =
typename __filebuf_type::native_handle_type;
786 [[__gnu__::__always_inline__]]
788 native_handle() const noexcept
789 {
return _M_filebuf.native_handle(); }
808 template<
typename _CharT,
typename _Traits>
813 typedef _CharT char_type;
814 typedef _Traits traits_type;
815 typedef typename traits_type::int_type int_type;
816 typedef typename traits_type::pos_type pos_type;
817 typedef typename traits_type::off_type off_type;
824 __filebuf_type _M_filebuf;
836 { this->
init(&_M_filebuf); }
848 : __ostream_type(), _M_filebuf()
850 this->
init(&_M_filebuf);
851 this->
open(__s, __mode);
854#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
865 : __ostream_type(), _M_filebuf()
867 this->
init(&_M_filebuf);
868 this->
open(__s, __mode);
872#if __cplusplus >= 201103L
883 : __ostream_type(), _M_filebuf()
885 this->
init(&_M_filebuf);
886 this->
open(__s, __mode);
889#if __cplusplus >= 201703L
897 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
907 : __ostream_type(
std::
move(__rhs)),
908 _M_filebuf(
std::
move(__rhs._M_filebuf))
909 { __ostream_type::set_rdbuf(&_M_filebuf); }
921#if __cplusplus >= 201103L
930 __ostream_type::operator=(
std::move(__rhs));
931 _M_filebuf =
std::move(__rhs._M_filebuf);
938 __ostream_type::swap(__rhs);
939 _M_filebuf.swap(__rhs._M_filebuf);
953 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
962 {
return _M_filebuf.is_open(); }
969 {
return _M_filebuf.
is_open(); }
990#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
1009#if __cplusplus >= 201103L
1029#if __cplusplus >= 201703L
1038 template<
typename _Path>
1039 _If_fs_path<_Path, void>
1041 {
open(__s.c_str(), __mode); }
1054 if (!_M_filebuf.close())
1058#if __cpp_lib_fstream_native_handle
1059 using native_handle_type =
typename __filebuf_type::native_handle_type;
1061 [[__gnu__::__always_inline__]]
1063 native_handle() const noexcept
1064 {
return _M_filebuf.native_handle(); }
1083 template<
typename _CharT,
typename _Traits>
1088 typedef _CharT char_type;
1089 typedef _Traits traits_type;
1090 typedef typename traits_type::int_type int_type;
1091 typedef typename traits_type::pos_type pos_type;
1092 typedef typename traits_type::off_type off_type;
1100 __filebuf_type _M_filebuf;
1112 : __iostream_type(), _M_filebuf()
1113 { this->
init(&_M_filebuf); }
1123 : __iostream_type(0), _M_filebuf()
1125 this->
init(&_M_filebuf);
1126 this->
open(__s, __mode);
1129#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
1137 : __iostream_type(0), _M_filebuf()
1139 this->
init(&_M_filebuf);
1140 this->
open(__s, __mode);
1144#if __cplusplus >= 201103L
1153 : __iostream_type(0), _M_filebuf()
1155 this->
init(&_M_filebuf);
1156 this->
open(__s, __mode);
1159#if __cplusplus >= 201703L
1165 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
1175 : __iostream_type(
std::
move(__rhs)),
1176 _M_filebuf(
std::
move(__rhs._M_filebuf))
1177 { __iostream_type::set_rdbuf(&_M_filebuf); }
1189#if __cplusplus >= 201103L
1198 __iostream_type::operator=(
std::move(__rhs));
1199 _M_filebuf =
std::move(__rhs._M_filebuf);
1206 __iostream_type::swap(__rhs);
1207 _M_filebuf.swap(__rhs._M_filebuf);
1221 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
1230 {
return _M_filebuf.is_open(); }
1237 {
return _M_filebuf.
is_open(); }
1251 if (!_M_filebuf.open(__s, __mode))
1259#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
1269 open(
const wchar_t* __s,
1272 if (!_M_filebuf.
open(__s, __mode))
1279#if __cplusplus >= 201103L
1292 if (!_M_filebuf.open(__s, __mode))
1300#if __cplusplus >= 201703L
1309 template<
typename _Path>
1310 _If_fs_path<_Path, void>
1313 {
open(__s.c_str(), __mode); }
1326 if (!_M_filebuf.close())
1330#if __cpp_lib_fstream_native_handle
1331 using native_handle_type =
typename __filebuf_type::native_handle_type;
1333 [[__gnu__::__always_inline__]]
1335 native_handle() const noexcept
1336 {
return _M_filebuf.native_handle(); }
1340#if __cplusplus >= 201103L
1342 template <
class _CharT,
class _Traits>
1349 template <
class _CharT,
class _Traits>
1356 template <
class _CharT,
class _Traits>
1363 template <
class _CharT,
class _Traits>
1370_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.
basic_istream(__streambuf_type *__sb)
Base constructor.
basic_iostream(basic_streambuf< _CharT, _Traits > *__sb)
Constructor does nothing.
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.
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.
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...
basic_ostream(__streambuf_type *__sb)
Base constructor.
Container class for localization functionality.
Class representing stream positions.