33 #ifndef _GLIBCXX_FSTREAM
34 #define _GLIBCXX_FSTREAM 1
36 #pragma GCC system_header
43 #if __cplusplus >= 201103L
47 namespace std _GLIBCXX_VISIBILITY(default)
49 _GLIBCXX_BEGIN_NAMESPACE_VERSION
51 #if __cplusplus >= 201703L
53 template<
typename _Path,
typename _Result = _Path,
typename _Path2
54 = decltype(std::declval<_Path&>().make_preferred().filename())>
55 using _If_fs_path = enable_if_t<is_same_v<_Path, _Path2>, _Result>;
79 template<
typename _CharT,
typename _Traits>
82 #if __cplusplus >= 201103L
83 template<
typename _Tp>
84 using __chk_state = __and_<is_copy_assignable<_Tp>,
88 static_assert(__chk_state<typename _Traits::state_type>::value,
89 "state_type must be CopyAssignable, CopyConstructible"
90 " and DefaultConstructible");
92 static_assert(
is_same<
typename _Traits::pos_type,
94 "pos_type must be fpos<state_type>");
98 typedef _CharT char_type;
99 typedef _Traits traits_type;
100 typedef typename traits_type::int_type int_type;
101 typedef typename traits_type::pos_type pos_type;
102 typedef typename traits_type::off_type off_type;
106 typedef __basic_file<char> __file_type;
107 typedef typename traits_type::state_type __state_type;
124 __state_type _M_state_beg;
129 __state_type _M_state_cur;
133 __state_type _M_state_last;
146 bool _M_buf_allocated;
237 #if __cplusplus >= 201103L
249 #if __cplusplus >= 201103L
261 {
return _M_file.is_open(); }
305 open(
const char* __s, ios_base::openmode __mode);
307 #if __cplusplus >= 201103L
318 #if __cplusplus >= 201703L
325 template<
typename _Path>
326 _If_fs_path<_Path, __filebuf_type*>
327 open(
const _Path& __s, ios_base::openmode __mode)
328 {
return open(__s.c_str(), __mode); }
349 _M_allocate_internal_buffer();
352 _M_destroy_internal_buffer() throw();
367 pbackfail(int_type __c = _Traits::eof());
377 overflow(int_type __c = _Traits::eof());
382 _M_convert_to_external(char_type*,
streamsize);
396 virtual __streambuf_type*
397 setbuf(char_type* __s, streamsize __n);
400 seekoff(off_type __off, ios_base::seekdir __way,
401 ios_base::openmode __mode = ios_base::in | ios_base::out);
405 ios_base::openmode __mode = ios_base::in | ios_base::out);
409 _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state);
412 _M_get_ext_pos(__state_type &__state);
418 imbue(const locale& __loc);
421 xsgetn(char_type* __s, streamsize __n);
424 xsputn(const char_type* __s, streamsize __n);
428 _M_terminate_output();
449 if (__testin && __off > 0)
475 template<
typename _CharT,
typename _Traits>
480 typedef _CharT char_type;
481 typedef _Traits traits_type;
482 typedef typename traits_type::int_type int_type;
483 typedef typename traits_type::pos_type pos_type;
484 typedef typename traits_type::off_type off_type;
503 { this->
init(&_M_filebuf); }
516 this->
init(&_M_filebuf);
517 this->
open(__s, __mode);
520 #if __cplusplus >= 201103L
533 this->
init(&_M_filebuf);
534 this->
open(__s, __mode);
537 #if __cplusplus >= 201703L
545 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
555 : __istream_type(std::move(__rhs)),
556 _M_filebuf(std::move(__rhs._M_filebuf))
557 { __istream_type::set_rdbuf(&_M_filebuf); }
569 #if __cplusplus >= 201103L
578 __istream_type::operator=(std::move(__rhs));
579 _M_filebuf = std::move(__rhs._M_filebuf);
586 __istream_type::swap(__rhs);
587 _M_filebuf.swap(__rhs._M_filebuf);
608 {
return _M_filebuf.
is_open(); }
614 {
return _M_filebuf.
is_open(); }
635 #if __cplusplus >= 201103L
655 #if __cplusplus >= 201703L
664 template<
typename _Path>
665 _If_fs_path<_Path, void>
667 {
open(__s.c_str(), __mode); }
680 if (!_M_filebuf.
close())
700 template<
typename _CharT,
typename _Traits>
705 typedef _CharT char_type;
706 typedef _Traits traits_type;
707 typedef typename traits_type::int_type int_type;
708 typedef typename traits_type::pos_type pos_type;
709 typedef typename traits_type::off_type off_type;
728 { this->
init(&_M_filebuf); }
742 this->
init(&_M_filebuf);
743 this->
open(__s, __mode);
746 #if __cplusplus >= 201103L
759 this->
init(&_M_filebuf);
760 this->
open(__s, __mode);
763 #if __cplusplus >= 201703L
771 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
781 : __ostream_type(std::move(__rhs)),
782 _M_filebuf(std::move(__rhs._M_filebuf))
783 { __ostream_type::set_rdbuf(&_M_filebuf); }
795 #if __cplusplus >= 201103L
804 __ostream_type::operator=(std::move(__rhs));
805 _M_filebuf = std::move(__rhs._M_filebuf);
812 __ostream_type::swap(__rhs);
813 _M_filebuf.swap(__rhs._M_filebuf);
834 {
return _M_filebuf.
is_open(); }
840 {
return _M_filebuf.
is_open(); }
861 #if __cplusplus >= 201103L
881 #if __cplusplus >= 201703L
890 template<
typename _Path>
891 _If_fs_path<_Path, void>
893 {
open(__s.c_str(), __mode); }
906 if (!_M_filebuf.
close())
926 template<
typename _CharT,
typename _Traits>
931 typedef _CharT char_type;
932 typedef _Traits traits_type;
933 typedef typename traits_type::int_type int_type;
934 typedef typename traits_type::pos_type pos_type;
935 typedef typename traits_type::off_type off_type;
956 { this->
init(&_M_filebuf); }
968 this->
init(&_M_filebuf);
969 this->
open(__s, __mode);
972 #if __cplusplus >= 201103L
983 this->
init(&_M_filebuf);
984 this->
open(__s, __mode);
987 #if __cplusplus >= 201703L
993 template<
typename _Path,
typename _Require = _If_fs_path<_Path>>
1003 : __iostream_type(std::move(__rhs)),
1004 _M_filebuf(std::move(__rhs._M_filebuf))
1005 { __iostream_type::set_rdbuf(&_M_filebuf); }
1017 #if __cplusplus >= 201103L
1026 __iostream_type::operator=(std::move(__rhs));
1027 _M_filebuf = std::move(__rhs._M_filebuf);
1034 __iostream_type::swap(__rhs);
1035 _M_filebuf.swap(__rhs._M_filebuf);
1056 {
return _M_filebuf.
is_open(); }
1062 {
return _M_filebuf.
is_open(); }
1076 if (!_M_filebuf.
open(__s, __mode))
1084 #if __cplusplus >= 201103L
1097 if (!_M_filebuf.
open(__s, __mode))
1105 #if __cplusplus >= 201703L
1114 template<
typename _Path>
1115 _If_fs_path<_Path, void>
1116 open(
const _Path& __s,
1118 {
open(__s.c_str(), __mode); }
1131 if (!_M_filebuf.
close())
1136 #if __cplusplus >= 201103L
1138 template <
class _CharT,
class _Traits>
1145 template <
class _CharT,
class _Traits>
1152 template <
class _CharT,
class _Traits>
1159 template <
class _CharT,
class _Traits>
1166 _GLIBCXX_END_NAMESPACE_VERSION
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
__filebuf_type * close()
Closes the currently associated file.
void _M_set_buffer(streamsize __off)
The actual work of input and output (interface).
virtual int_type underflow()
Fetches more data from the controlled sequence.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current filebuf.
basic_fstream(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
Controlling input for files.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
void open(const char *__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
char_type * eback() const
Access to the get area.
Controlling output for files.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
Template class basic_ios, virtual base class for all stream classes.
~basic_ofstream()
The destructor does nothing.
virtual streamsize xsgetn(char_type *__s, streamsize __n)
Multiple character extraction.
virtual ~basic_filebuf()
The destructor closes the file first.
basic_fstream(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
basic_ifstream(const char *__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
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.
Template class basic_ostream.
void close()
Close the file.
Controlling input and output for files.
basic_filebuf()
Does not open any files.
virtual streamsize showmanyc()
Investigating the data available.
__filebuf_type * open(const std::string &__s, ios_base::openmode __mode)
Opens an external file.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
The actual work of input and output (for files).
void close()
Close the file.
basic_ifstream(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
void open(const char *__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() const
Returns true if the external file is open.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
char_type * _M_pback_cur_save
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
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.
static const openmode app
Seek to end before each write.
basic_fstream()
Default constructor.
basic_ifstream()
Default constructor.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
static const openmode out
Open for output. Default for ofstream and fstream.
__filebuf_type * open(const char *__s, ios_base::openmode __mode)
Opens an external file.
virtual streamsize xsputn(const char_type *__s, streamsize __n)
Multiple character insertion.
bool is_open()
Wrapper to test for an open file.
Template class basic_istream.
char_type * egptr() const
Access to the get area.
char_type * _M_pback_end_save
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
char_type * _M_buf
Pointer to the beginning of internal buffer.
void setp(char_type *__pbeg, char_type *__pend)
Setting the three write area pointers.
bool is_open()
Wrapper to test for an open file.
basic_ofstream()
Default constructor.
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.
Class representing stream positions.
char_type * gptr() const
Access to the get area.
void setstate(iostate __state)
Sets additional flags in the error state.
bool is_open()
Wrapper to test for an open file.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
Template class basic_iostream.
~basic_fstream()
The destructor does nothing.
virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
void open(const char *__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
void close()
Close the file.
streamsize _M_ext_buf_size
basic_ofstream(const std::string &__s, ios_base::openmode __mode=ios_base::out)
Create an output file stream.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
~basic_ifstream()
The destructor does nothing.
void clear(iostate __state=goodbit)
[Re]sets the error state.
Primary class template codecvt.NB: Generic, mostly useless implementation.