33 #ifndef _GLIBCXX_FSTREAM 34 #define _GLIBCXX_FSTREAM 1 36 #pragma GCC system_header 43 #if __cplusplus >= 201103L 48 #ifndef _GLIBCXX_BUFSIZ 49 # define _GLIBCXX_BUFSIZ BUFSIZ 52 namespace std _GLIBCXX_VISIBILITY(default)
54 _GLIBCXX_BEGIN_NAMESPACE_VERSION
56 #if __cplusplus >= 201703L 58 template<
typename _Path,
typename _Result = _Path,
typename _Path2
59 = decltype(std::declval<_Path&>().make_preferred().filename())>
60 using _If_fs_path = enable_if_t<is_same_v<_Path, _Path2>, _Result>;
84 template<
typename _CharT,
typename _Traits>
87 #if __cplusplus >= 201103L 88 template<
typename _Tp>
89 using __chk_state = __and_<is_copy_assignable<_Tp>,
93 static_assert(__chk_state<typename _Traits::state_type>::value,
94 "state_type must be CopyAssignable, CopyConstructible" 95 " and DefaultConstructible");
97 static_assert(
is_same<
typename _Traits::pos_type,
99 "pos_type must be fpos<state_type>");
103 typedef _CharT char_type;
104 typedef _Traits traits_type;
105 typedef typename traits_type::int_type int_type;
106 typedef typename traits_type::pos_type pos_type;
107 typedef typename traits_type::off_type off_type;
111 typedef __basic_file<char> __file_type;
112 typedef typename traits_type::state_type __state_type;
129 __state_type _M_state_beg;
134 __state_type _M_state_cur;
138 __state_type _M_state_last;
151 bool _M_buf_allocated;
209 _M_pback_end_save = this->
egptr();
242 #if __cplusplus >= 201103L 259 #if __cplusplus >= 201103L 271 {
return _M_file.is_open(); }
315 open(
const char* __s, ios_base::openmode __mode);
317 #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T 325 open(
const wchar_t* __s, ios_base::openmode __mode);
328 #if __cplusplus >= 201103L 339 #if __cplusplus >= 201703L 346 template<
typename _Path>
347 _If_fs_path<_Path, __filebuf_type*>
348 open(
const _Path& __s, ios_base::openmode __mode)
349 {
return open(__s.c_str(), __mode); }
370 _M_allocate_internal_buffer();
373 _M_destroy_internal_buffer() throw();
388 pbackfail(int_type __c = _Traits::eof());
398 overflow(int_type __c = _Traits::eof());
403 _M_convert_to_external(char_type*,
streamsize);
417 virtual __streambuf_type*
430 _M_seek(off_type __off,
ios_base::seekdir __way, __state_type __state);
433 _M_get_ext_pos(__state_type &__state);
449 _M_terminate_output();
470 if (__testin && __off > 0)
496 template<
typename _CharT,
typename _Traits>
501 typedef _CharT char_type;
502 typedef _Traits traits_type;
503 typedef typename traits_type::int_type int_type;
504 typedef typename traits_type::pos_type pos_type;
505 typedef typename traits_type::off_type off_type;
524 { this->
init(&_M_filebuf); }
537 this->
init(&_M_filebuf);
538 this->
open(__s, __mode);
541 #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T 551 : __istream_type(), _M_filebuf()
553 this->
init(&_M_filebuf);
554 this->
open(__s, __mode);
558 #if __cplusplus >= 201103L 571 this->
init(&_M_filebuf);
572 this->
open(__s, __mode);
575 #if __cplusplus >= 201703L 583 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
593 : __istream_type(
std::move(__rhs)),
594 _M_filebuf(
std::move(__rhs._M_filebuf))
595 { __istream_type::set_rdbuf(&_M_filebuf); }
607 #if __cplusplus >= 201103L 616 __istream_type::operator=(
std::move(__rhs));
617 _M_filebuf =
std::move(__rhs._M_filebuf);
624 __istream_type::swap(__rhs);
625 _M_filebuf.swap(__rhs._M_filebuf);
646 {
return _M_filebuf.
is_open(); }
652 {
return _M_filebuf.
is_open(); }
673 #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T 692 #if __cplusplus >= 201103L 712 #if __cplusplus >= 201703L 721 template<
typename _Path>
722 _If_fs_path<_Path, void>
724 {
open(__s.c_str(), __mode); }
737 if (!_M_filebuf.
close())
757 template<
typename _CharT,
typename _Traits>
762 typedef _CharT char_type;
763 typedef _Traits traits_type;
764 typedef typename traits_type::int_type int_type;
765 typedef typename traits_type::pos_type pos_type;
766 typedef typename traits_type::off_type off_type;
785 { this->
init(&_M_filebuf); }
799 this->
init(&_M_filebuf);
800 this->
open(__s, __mode);
803 #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T 814 : __ostream_type(), _M_filebuf()
816 this->
init(&_M_filebuf);
817 this->
open(__s, __mode);
821 #if __cplusplus >= 201103L 834 this->
init(&_M_filebuf);
835 this->
open(__s, __mode);
838 #if __cplusplus >= 201703L 846 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
856 : __ostream_type(
std::move(__rhs)),
857 _M_filebuf(
std::move(__rhs._M_filebuf))
858 { __ostream_type::set_rdbuf(&_M_filebuf); }
870 #if __cplusplus >= 201103L 879 __ostream_type::operator=(
std::move(__rhs));
880 _M_filebuf =
std::move(__rhs._M_filebuf);
887 __ostream_type::swap(__rhs);
888 _M_filebuf.swap(__rhs._M_filebuf);
909 {
return _M_filebuf.
is_open(); }
915 {
return _M_filebuf.
is_open(); }
936 #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T 955 #if __cplusplus >= 201103L 975 #if __cplusplus >= 201703L 984 template<
typename _Path>
985 _If_fs_path<_Path, void>
987 {
open(__s.c_str(), __mode); }
1000 if (!_M_filebuf.
close())
1020 template<
typename _CharT,
typename _Traits>
1025 typedef _CharT char_type;
1026 typedef _Traits traits_type;
1027 typedef typename traits_type::int_type int_type;
1028 typedef typename traits_type::pos_type pos_type;
1029 typedef typename traits_type::off_type off_type;
1050 { this->
init(&_M_filebuf); }
1062 this->
init(&_M_filebuf);
1063 this->
open(__s, __mode);
1066 #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T 1074 : __iostream_type(0), _M_filebuf()
1076 this->
init(&_M_filebuf);
1077 this->
open(__s, __mode);
1081 #if __cplusplus >= 201103L 1092 this->
init(&_M_filebuf);
1093 this->
open(__s, __mode);
1096 #if __cplusplus >= 201703L 1102 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
1112 : __iostream_type(
std::move(__rhs)),
1113 _M_filebuf(
std::move(__rhs._M_filebuf))
1114 { __iostream_type::set_rdbuf(&_M_filebuf); }
1126 #if __cplusplus >= 201103L 1135 __iostream_type::operator=(
std::move(__rhs));
1136 _M_filebuf =
std::move(__rhs._M_filebuf);
1143 __iostream_type::swap(__rhs);
1144 _M_filebuf.swap(__rhs._M_filebuf);
1165 {
return _M_filebuf.
is_open(); }
1171 {
return _M_filebuf.
is_open(); }
1185 if (!_M_filebuf.
open(__s, __mode))
1193 #if _GLIBCXX_HAVE__WFOPEN && _GLIBCXX_USE_WCHAR_T 1203 open(
const wchar_t* __s,
1206 if (!_M_filebuf.
open(__s, __mode))
1213 #if __cplusplus >= 201103L 1226 if (!_M_filebuf.
open(__s, __mode))
1234 #if __cplusplus >= 201703L 1243 template<
typename _Path>
1244 _If_fs_path<_Path, void>
1247 {
open(__s.c_str(), __mode); }
1260 if (!_M_filebuf.
close())
1265 #if __cplusplus >= 201103L 1267 template <
class _CharT,
class _Traits>
1274 template <
class _CharT,
class _Traits>
1281 template <
class _CharT,
class _Traits>
1288 template <
class _CharT,
class _Traits>
1295 _GLIBCXX_END_NAMESPACE_VERSION
void _M_set_buffer(streamsize __off)
Template class basic_iostream.
virtual int_type pbackfail(int_type __c=_Traits::eof())
Tries to back up the input sequence.
__filebuf_type * open(const std::string &__s, ios_base::openmode __mode)
Opens an external file.
basic_fstream(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
basic_filebuf()
Does not open any files.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
void setstate(iostate __state)
Sets additional flags in the error state.
static const openmode app
Seek to end before each write.
char_type * egptr() const
Access to the get area.
bool is_open()
Wrapper to test for an open file.
void close()
Close the file.
_If_fs_path< _Path, __filebuf_type * > open(const _Path &__s, ios_base::openmode __mode)
Opens an external file.
_If_fs_path< _Path, void > open(const _Path &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
void open(const char *__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
void close()
Close the file.
char_type * eback() const
Access to the get area.
_If_fs_path< _Path, void > open(const _Path &__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
virtual int_type underflow()
Fetches more data from the controlled sequence.
_If_fs_path< _Path, void > open(const _Path &__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
void close()
Close the file.
~basic_ifstream()
The destructor does nothing.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
basic_ifstream(const char *__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
Primary class template codecvt.NB: Generic, mostly useless implementation.
char_type * _M_pback_end_save
basic_fstream(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
bool is_open() const
Returns true if the external file is open.
bool is_open()
Wrapper to test for an open file.
virtual ~basic_filebuf()
The destructor closes the file first.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
void clear(iostate __state=goodbit)
[Re]sets the error state.
basic_fstream(const _Path &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
char_type * _M_pback_cur_save
~basic_fstream()
The destructor does nothing.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
Class representing stream positions.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
Controlling output for files.
The actual work of input and output (interface).
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.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current filebuf.
static const openmode out
Open for output. Default for ofstream and fstream.
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
Template class basic_ostream.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
virtual int_type overflow(int_type __c=_Traits::eof())
Consumes data from the buffer; writes to the controlled sequence.
virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
streamsize _M_ext_buf_size
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
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.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
~basic_ofstream()
The destructor does nothing.
virtual streamsize showmanyc()
Investigating the data available.
virtual streamsize xsgetn(char_type *__s, streamsize __n)
Multiple character extraction.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
void swap(basic_fstream< _CharT, _Traits > &__x, basic_fstream< _CharT, _Traits > &__y)
Swap specialization for fstreams.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
static const openmode in
Open for input. Default for ifstream and fstream.
basic_ofstream(const char *__s, ios_base::openmode __mode=ios_base::out)
Create an output file stream.
virtual streamsize xsputn(const char_type *__s, streamsize __n)
Multiple character insertion.
virtual void imbue(const locale &__loc)
Changes translations.
Controlling input for files.
Template class basic_ios, virtual base class for all stream classes.
char_type * _M_buf
Pointer to the beginning of internal buffer.
basic_fstream()
Default constructor.
void setp(char_type *__pbeg, char_type *__pend)
Setting the three write area pointers.
void open(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
__filebuf_type * close()
Closes the currently associated file.
void open(const char *__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
__filebuf_type * open(const char *__s, ios_base::openmode __mode)
Opens an external file.
bool is_open()
Wrapper to test for an open file.
char_type * gptr() const
Access to the get area.
basic_ofstream(const std::string &__s, ios_base::openmode __mode=ios_base::out)
Create an output file stream.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
Controlling input and output for files.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
Template class basic_istream.
basic_ofstream()
Default constructor.
The actual work of input and output (for files).
ISO C++ entities toplevel namespace is std.
basic_ifstream()
Default constructor.
static const openmode trunc
Truncate an existing stream when opening. Default for ofstream.
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.