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;
171 const __codecvt_type* _M_codecvt;
203 _M_pback_cur_save = this->
gptr();
204 _M_pback_end_save = this->
egptr();
205 this->
setg(&_M_pback, &_M_pback, &_M_pback + 1);
206 _M_pback_init =
true;
221 _M_pback_cur_save += this->
gptr() != this->
eback();
222 this->
setg(_M_buf, _M_pback_cur_save, _M_pback_end_save);
223 _M_pback_init =
false;
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*
400 seekoff(off_type __off, ios_base::seekdir __way,
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);
428 _M_terminate_output();
449 if (__testin && __off > 0)
450 this->
setg(_M_buf, _M_buf, _M_buf + __off);
452 this->
setg(_M_buf, _M_buf, _M_buf);
454 if (__testout && __off == 0 && _M_buf_size > 1 )
455 this->
setp(_M_buf, _M_buf + _M_buf_size - 1);
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;
491 __filebuf_type _M_filebuf;
503 { this->init(&_M_filebuf); }
514 : __istream_type(), _M_filebuf()
516 this->init(&_M_filebuf);
517 this->
open(__s, __mode);
520 #if __cplusplus >= 201103L 531 : __istream_type(), _M_filebuf()
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);
587 _M_filebuf.swap(__rhs._M_filebuf);
600 {
return const_cast<__filebuf_type*
>(&_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;
716 __filebuf_type _M_filebuf;
728 { this->init(&_M_filebuf); }
740 : __ostream_type(), _M_filebuf()
742 this->init(&_M_filebuf);
743 this->
open(__s, __mode);
746 #if __cplusplus >= 201103L 757 : __ostream_type(), _M_filebuf()
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);
813 _M_filebuf.swap(__rhs._M_filebuf);
826 {
return const_cast<__filebuf_type*
>(&_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;
943 __filebuf_type _M_filebuf;
955 : __iostream_type(), _M_filebuf()
956 { this->init(&_M_filebuf); }
966 : __iostream_type(0), _M_filebuf()
968 this->init(&_M_filebuf);
969 this->
open(__s, __mode);
972 #if __cplusplus >= 201103L 981 : __iostream_type(0), _M_filebuf()
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);
1035 _M_filebuf.swap(__rhs._M_filebuf);
1048 {
return const_cast<__filebuf_type*
>(&_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
void open(const char *__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
char_type * _M_buf
Pointer to the beginning of internal buffer.
Class representing stream positions.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
bool is_open()
Wrapper to test for an open file.
__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.
virtual ~basic_filebuf()
The destructor closes the file first.
Template class basic_ios, virtual base class for all stream classes.
virtual streamsize xsputn(const char_type *__s, streamsize __n)
Multiple character insertion.
basic_ifstream(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
virtual streamsize showmanyc()
Investigating the data available.
Controlling output for files.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
basic_fstream(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
Template class basic_istream.
void close()
Close the file.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current filebuf.
Controlling input for files.
Template class basic_iostream.
char_type * _M_pback_cur_save
basic_fstream()
Default constructor.
char_type * gptr() const
Access to the get area.
basic_ifstream()
Default constructor.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in)
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.
void open(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
streamsize _M_ext_buf_size
basic_ifstream(const char *__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
__filebuf_type * open(const char *__s, ios_base::openmode __mode)
Opens an external file.
basic_ofstream(const std::string &__s, ios_base::openmode __mode=ios_base::out)
Create an output file stream.
virtual streamsize xsgetn(char_type *__s, streamsize __n)
Multiple character extraction.
~basic_fstream()
The destructor does nothing.
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
~basic_ofstream()
The destructor does nothing.
ISO C++ entities toplevel namespace is std.
__filebuf_type * close()
Closes the currently associated file.
void close()
Close the file.
basic_ofstream()
Default constructor.
virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
char_type * egptr() const
Access to the get area.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
virtual int_type underflow()
Fetches more data from the controlled sequence.
static const openmode app
Seek to end before each write.
void close()
Close the file.
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
void setp(char_type *__pbeg, char_type *__pend)
Setting the three write area pointers.
basic_filebuf()
Does not open any files.
char_type * eback() const
Access to the get area.
void swap(basic_fstream< _CharT, _Traits > &__x, basic_fstream< _CharT, _Traits > &__y)
Swap specialization for fstreams.
void _M_set_buffer(streamsize __off)
~basic_ifstream()
The destructor does nothing.
The actual work of input and output (interface).
Container class for localization functionality.The locale class is first a class wrapper for C librar...
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.
static const openmode out
Open for output. Default for ofstream and fstream.
__filebuf_type * open(const std::string &__s, ios_base::openmode __mode)
Opens an external file.
basic_ofstream(const char *__s, ios_base::openmode __mode=ios_base::out)
Create an output file stream.
bool is_open()
Wrapper to test for an open file.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
bool is_open()
Wrapper to test for an open file.
bool is_open() const
Returns true if the external file is open.
Controlling input and output for files.
Primary class template codecvt.NB: Generic, mostly useless implementation.
The actual work of input and output (for files).
void open(const char *__s, ios_base::openmode __mode=ios_base::out)
Opens an external file.
Template class basic_ostream.
char_type * _M_pback_end_save
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.