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
71 template<
typename _CharT,
typename _Traits>
74 #if __cplusplus >= 201103L 75 template<
typename _Tp>
76 using __chk_state = __and_<is_copy_assignable<_Tp>,
77 is_copy_constructible<_Tp>,
78 is_default_constructible<_Tp>>;
80 static_assert(__chk_state<typename _Traits::state_type>::value,
81 "state_type must be CopyAssignable, CopyConstructible" 82 " and DefaultConstructible");
84 static_assert(is_same<
typename _Traits::pos_type,
86 "pos_type must be fpos<state_type>");
90 typedef _CharT char_type;
91 typedef _Traits traits_type;
92 typedef typename traits_type::int_type int_type;
93 typedef typename traits_type::pos_type pos_type;
94 typedef typename traits_type::off_type off_type;
98 typedef __basic_file<char> __file_type;
99 typedef typename traits_type::state_type __state_type;
116 __state_type _M_state_beg;
121 __state_type _M_state_cur;
125 __state_type _M_state_last;
138 bool _M_buf_allocated;
163 const __codecvt_type* _M_codecvt;
195 _M_pback_cur_save = this->
gptr();
196 _M_pback_end_save = this->
egptr();
197 this->
setg(&_M_pback, &_M_pback, &_M_pback + 1);
198 _M_pback_init =
true;
213 _M_pback_cur_save += this->
gptr() != this->
eback();
214 this->
setg(_M_buf, _M_pback_cur_save, _M_pback_end_save);
215 _M_pback_init =
false;
229 #if __cplusplus >= 201103L 241 #if __cplusplus >= 201103L 253 {
return _M_file.is_open(); }
297 open(
const char* __s, ios_base::openmode __mode);
299 #if __cplusplus >= 201103L 328 _M_allocate_internal_buffer();
331 _M_destroy_internal_buffer()
throw();
346 pbackfail(int_type __c = _Traits::eof());
356 overflow(int_type __c = _Traits::eof());
361 _M_convert_to_external(char_type*,
streamsize);
375 virtual __streambuf_type*
379 seekoff(off_type __off, ios_base::seekdir __way,
388 _M_seek(off_type __off, ios_base::seekdir __way, __state_type __state);
391 _M_get_ext_pos(__state_type &__state);
407 _M_terminate_output();
428 if (__testin && __off > 0)
429 this->
setg(_M_buf, _M_buf, _M_buf + __off);
431 this->
setg(_M_buf, _M_buf, _M_buf);
433 if (__testout && __off == 0 && _M_buf_size > 1 )
434 this->
setp(_M_buf, _M_buf + _M_buf_size - 1);
454 template<
typename _CharT,
typename _Traits>
459 typedef _CharT char_type;
460 typedef _Traits traits_type;
461 typedef typename traits_type::int_type int_type;
462 typedef typename traits_type::pos_type pos_type;
463 typedef typename traits_type::off_type off_type;
470 __filebuf_type _M_filebuf;
482 { this->init(&_M_filebuf); }
496 : __istream_type(), _M_filebuf()
498 this->init(&_M_filebuf);
499 this->
open(__s, __mode);
502 #if __cplusplus >= 201103L 513 : __istream_type(), _M_filebuf()
515 this->init(&_M_filebuf);
516 this->
open(__s, __mode);
522 : __istream_type(std::move(__rhs)),
523 _M_filebuf(std::move(__rhs._M_filebuf))
524 { __istream_type::set_rdbuf(&_M_filebuf); }
536 #if __cplusplus >= 201103L 545 __istream_type::operator=(std::move(__rhs));
546 _M_filebuf = std::move(__rhs._M_filebuf);
554 _M_filebuf.swap(__rhs._M_filebuf);
567 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
575 {
return _M_filebuf.
is_open(); }
581 {
return _M_filebuf.
is_open(); }
605 #if __cplusplus >= 201103L 635 if (!_M_filebuf.
close())
655 template<
typename _CharT,
typename _Traits>
660 typedef _CharT char_type;
661 typedef _Traits traits_type;
662 typedef typename traits_type::int_type int_type;
663 typedef typename traits_type::pos_type pos_type;
664 typedef typename traits_type::off_type off_type;
671 __filebuf_type _M_filebuf;
683 { this->init(&_M_filebuf); }
699 : __ostream_type(), _M_filebuf()
701 this->init(&_M_filebuf);
702 this->
open(__s, __mode);
705 #if __cplusplus >= 201103L 717 : __ostream_type(), _M_filebuf()
719 this->init(&_M_filebuf);
720 this->
open(__s, __mode);
726 : __ostream_type(std::move(__rhs)),
727 _M_filebuf(std::move(__rhs._M_filebuf))
728 { __ostream_type::set_rdbuf(&_M_filebuf); }
740 #if __cplusplus >= 201103L 749 __ostream_type::operator=(std::move(__rhs));
750 _M_filebuf = std::move(__rhs._M_filebuf);
758 _M_filebuf.swap(__rhs._M_filebuf);
771 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
779 {
return _M_filebuf.
is_open(); }
785 {
return _M_filebuf.
is_open(); }
810 #if __cplusplus >= 201103L 841 if (!_M_filebuf.
close())
861 template<
typename _CharT,
typename _Traits>
866 typedef _CharT char_type;
867 typedef _Traits traits_type;
868 typedef typename traits_type::int_type int_type;
869 typedef typename traits_type::pos_type pos_type;
870 typedef typename traits_type::off_type off_type;
878 __filebuf_type _M_filebuf;
890 : __iostream_type(), _M_filebuf()
891 { this->init(&_M_filebuf); }
904 : __iostream_type(0), _M_filebuf()
906 this->init(&_M_filebuf);
907 this->
open(__s, __mode);
910 #if __cplusplus >= 201103L 919 : __iostream_type(0), _M_filebuf()
921 this->init(&_M_filebuf);
922 this->
open(__s, __mode);
928 : __iostream_type(std::move(__rhs)),
929 _M_filebuf(std::move(__rhs._M_filebuf))
930 { __iostream_type::set_rdbuf(&_M_filebuf); }
942 #if __cplusplus >= 201103L 951 __iostream_type::operator=(std::move(__rhs));
952 _M_filebuf = std::move(__rhs._M_filebuf);
960 _M_filebuf.swap(__rhs._M_filebuf);
973 {
return const_cast<__filebuf_type*
>(&_M_filebuf); }
981 {
return _M_filebuf.
is_open(); }
987 {
return _M_filebuf.
is_open(); }
1004 if (!_M_filebuf.
open(__s, __mode))
1012 #if __cplusplus >= 201103L 1025 if (!_M_filebuf.
open(__s, __mode))
1043 if (!_M_filebuf.
close())
1048 #if __cplusplus >= 201103L 1050 template <
class _CharT,
class _Traits>
1057 template <
class _CharT,
class _Traits>
1064 template <
class _CharT,
class _Traits>
1071 template <
class _CharT,
class _Traits>
1078 _GLIBCXX_END_NAMESPACE_VERSION
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
static const openmode out
Open for output. Default for ofstream and fstream.
char_type * egptr() const
Access to the get area.
Controlling output for files.
Template class basic_iostream.
static const openmode in
Open for input. Default for ifstream and fstream.
char_type * _M_pback_end_save
char_type * eback() const
Access to the get area.
char_type * _M_pback_cur_save
~basic_ofstream()
The destructor does nothing.
void close()
Close the file.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
char_type * _M_buf
Pointer to the beginning of internal buffer.
virtual void imbue(const locale &__loc)
Changes translations.
The actual work of input and output (interface).
bool is_open()
Wrapper to test for an open file.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Opens an external file.
ISO C++ entities toplevel namespace is std.
void open(const char *__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
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 open(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
basic_filebuf()
Does not open any files.
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
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 iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
Controlling input for files.
virtual streamsize xsputn(const char_type *__s, streamsize __n)
Multiple character insertion.
Template class basic_ostream.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
Template class basic_ios, virtual base class for all stream classes.
__filebuf_type * open(const std::string &__s, ios_base::openmode __mode)
Opens an external file.
~basic_fstream()
The destructor does nothing.
virtual int_type underflow()
Fetches more data from the controlled sequence.
Controlling input and output for files.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current filebuf.
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.
~basic_ifstream()
The destructor does nothing.
virtual int_type pbackfail(int_type __c=_Traits::eof())
Tries to back up the input sequence.
Primary class template codecvt.NB: Generic, mostly useless implementation.
void _M_set_buffer(streamsize __off)
basic_ofstream(const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Create an output file stream.
basic_ifstream(const char *__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
basic_ifstream()
Default constructor.
basic_fstream()
Default constructor.
void open(const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Opens an external file.
static const openmode trunc
Open for input. Default for ofstream.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
__filebuf_type * close()
Closes the currently associated file.
virtual int_type overflow(int_type __c=_Traits::eof())
Consumes data from the buffer; writes to the controlled sequence.
void swap(basic_fstream< _CharT, _Traits > &__x, basic_fstream< _CharT, _Traits > &__y)
Swap specialization for fstreams.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode=ios_base::in|ios_base::out)
Alters the stream positions.
bool is_open()
Wrapper to test for an open file.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
void close()
Close the file.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
bool is_open() const
Returns true if the external file is open.
streamsize _M_ext_buf_size
basic_ifstream(const std::string &__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.
void setp(char_type *__pbeg, char_type *__pend)
Setting the three write area pointers.
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
basic_ofstream(const std::string &__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Create an output file stream.
The actual work of input and output (for files).
virtual ~basic_filebuf()
The destructor closes the file first.
Class representing stream positions.
Template class basic_istream.
char_type * gptr() const
Access to the get area.
basic_fstream(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
basic_ofstream()
Default constructor.
bool is_open()
Wrapper to test for an open file.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
void close()
Close the file.
static const openmode app
Seek to end before each write.