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(const char_type*,
streamsize);
444#if ! _GLIBCXX_INLINE_VERSION
445 __attribute__((__always_inline__))
447 _M_convert_to_external(char_type* __ibuf,
streamsize __ilen)
449 const char_type* __cibuf = __ibuf;
450 return _M_convert_to_external(__cibuf, __ilen);
482 _M_get_ext_pos(__state_type &__state);
498 _M_terminate_output();
519 if (__testin && __off > 0)
545 template<
typename _CharT,
typename _Traits>
550 typedef _CharT char_type;
551 typedef _Traits traits_type;
552 typedef typename traits_type::int_type int_type;
553 typedef typename traits_type::pos_type pos_type;
554 typedef typename traits_type::off_type off_type;
561 __filebuf_type _M_filebuf;
573 { this->
init(&_M_filebuf); }
584 : __istream_type(), _M_filebuf()
586 this->
init(&_M_filebuf);
587 this->
open(__s, __mode);
590#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
600 : __istream_type(), _M_filebuf()
602 this->
init(&_M_filebuf);
603 this->
open(__s, __mode);
607#if __cplusplus >= 201103L
618 : __istream_type(), _M_filebuf()
620 this->
init(&_M_filebuf);
621 this->
open(__s, __mode);
624#if __cplusplus >= 201703L
632 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
642 : __istream_type(
std::
move(__rhs)),
643 _M_filebuf(
std::
move(__rhs._M_filebuf))
644 { __istream_type::set_rdbuf(&_M_filebuf); }
656#if __cplusplus >= 201103L
665 __istream_type::operator=(
std::move(__rhs));
666 _M_filebuf =
std::move(__rhs._M_filebuf);
673 __istream_type::swap(__rhs);
674 _M_filebuf.swap(__rhs._M_filebuf);
688 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
697 {
return _M_filebuf.is_open(); }
704 {
return _M_filebuf.
is_open(); }
725#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
744#if __cplusplus >= 201103L
764#if __cplusplus >= 201703L
773 template<
typename _Path>
774 _If_fs_path<_Path, void>
776 {
open(__s.c_str(), __mode); }
789 if (!_M_filebuf.close())
793#if __cpp_lib_fstream_native_handle
794 using native_handle_type =
typename __filebuf_type::native_handle_type;
796 [[__gnu__::__always_inline__]]
798 native_handle() const noexcept
799 {
return _M_filebuf.native_handle(); }
818 template<
typename _CharT,
typename _Traits>
823 typedef _CharT char_type;
824 typedef _Traits traits_type;
825 typedef typename traits_type::int_type int_type;
826 typedef typename traits_type::pos_type pos_type;
827 typedef typename traits_type::off_type off_type;
834 __filebuf_type _M_filebuf;
846 { this->
init(&_M_filebuf); }
858 : __ostream_type(), _M_filebuf()
860 this->
init(&_M_filebuf);
861 this->
open(__s, __mode);
864#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
875 : __ostream_type(), _M_filebuf()
877 this->
init(&_M_filebuf);
878 this->
open(__s, __mode);
882#if __cplusplus >= 201103L
893 : __ostream_type(), _M_filebuf()
895 this->
init(&_M_filebuf);
896 this->
open(__s, __mode);
899#if __cplusplus >= 201703L
907 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
917 : __ostream_type(
std::
move(__rhs)),
918 _M_filebuf(
std::
move(__rhs._M_filebuf))
919 { __ostream_type::set_rdbuf(&_M_filebuf); }
931#if __cplusplus >= 201103L
940 __ostream_type::operator=(
std::move(__rhs));
941 _M_filebuf =
std::move(__rhs._M_filebuf);
948 __ostream_type::swap(__rhs);
949 _M_filebuf.swap(__rhs._M_filebuf);
963 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
972 {
return _M_filebuf.is_open(); }
979 {
return _M_filebuf.
is_open(); }
1000#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
1019#if __cplusplus >= 201103L
1039#if __cplusplus >= 201703L
1048 template<
typename _Path>
1049 _If_fs_path<_Path, void>
1051 {
open(__s.c_str(), __mode); }
1064 if (!_M_filebuf.close())
1068#if __cpp_lib_fstream_native_handle
1069 using native_handle_type =
typename __filebuf_type::native_handle_type;
1071 [[__gnu__::__always_inline__]]
1073 native_handle() const noexcept
1074 {
return _M_filebuf.native_handle(); }
1093 template<
typename _CharT,
typename _Traits>
1098 typedef _CharT char_type;
1099 typedef _Traits traits_type;
1100 typedef typename traits_type::int_type int_type;
1101 typedef typename traits_type::pos_type pos_type;
1102 typedef typename traits_type::off_type off_type;
1110 __filebuf_type _M_filebuf;
1122 : __iostream_type(), _M_filebuf()
1123 { this->
init(&_M_filebuf); }
1133 : __iostream_type(0), _M_filebuf()
1135 this->
init(&_M_filebuf);
1136 this->
open(__s, __mode);
1139#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
1147 : __iostream_type(0), _M_filebuf()
1149 this->
init(&_M_filebuf);
1150 this->
open(__s, __mode);
1154#if __cplusplus >= 201103L
1163 : __iostream_type(0), _M_filebuf()
1165 this->
init(&_M_filebuf);
1166 this->
open(__s, __mode);
1169#if __cplusplus >= 201703L
1175 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
1185 : __iostream_type(
std::
move(__rhs)),
1186 _M_filebuf(
std::
move(__rhs._M_filebuf))
1187 { __iostream_type::set_rdbuf(&_M_filebuf); }
1199#if __cplusplus >= 201103L
1208 __iostream_type::operator=(
std::move(__rhs));
1209 _M_filebuf =
std::move(__rhs._M_filebuf);
1216 __iostream_type::swap(__rhs);
1217 _M_filebuf.swap(__rhs._M_filebuf);
1231 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
1240 {
return _M_filebuf.is_open(); }
1247 {
return _M_filebuf.
is_open(); }
1261 if (!_M_filebuf.open(__s, __mode))
1269#if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T
1279 open(
const wchar_t* __s,
1282 if (!_M_filebuf.
open(__s, __mode))
1289#if __cplusplus >= 201103L
1302 if (!_M_filebuf.open(__s, __mode))
1310#if __cplusplus >= 201703L
1319 template<
typename _Path>
1320 _If_fs_path<_Path, void>
1323 {
open(__s.c_str(), __mode); }
1336 if (!_M_filebuf.close())
1340#if __cpp_lib_fstream_native_handle
1341 using native_handle_type =
typename __filebuf_type::native_handle_type;
1343 [[__gnu__::__always_inline__]]
1345 native_handle() const noexcept
1346 {
return _M_filebuf.native_handle(); }
1350#if __cplusplus >= 201103L
1352 template <
class _CharT,
class _Traits>
1359 template <
class _CharT,
class _Traits>
1366 template <
class _CharT,
class _Traits>
1373 template <
class _CharT,
class _Traits>
1380_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)
Alters the stream positions.
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)
Changes translations.
virtual streamsize xsgetn(char_type *__s, streamsize __n)
Multiple character extraction.
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)
Alters the stream positions.
virtual int_type pbackfail(int_type __c=traits_type::eof())
virtual streamsize xsputn(const char_type *__s, streamsize __n)
Multiple character insertion.
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 int sync()
Synchronizes the buffer arrays with the controlled sequences.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
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.
basic_streambuf< char_type, traits_type > __streambuf_type
This is a non-standard type.
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.
_Ios_Seekdir seekdir
This is an enumerated type.
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.