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>");
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;
113 ios_base::openmode _M_mode;
116 __state_type _M_state_beg;
121 __state_type _M_state_cur;
125 __state_type _M_state_last;
138 bool _M_buf_allocated;
157 char_type* _M_pback_cur_save;
158 char_type* _M_pback_end_save;
163 const __codecvt_type* _M_codecvt;
182 const char* _M_ext_next;
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;
208 _M_destroy_pback()
throw()
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
252 is_open()
const throw()
253 {
return _M_file.is_open(); }
297 open(
const char* __s, ios_base::openmode __mode);
299 #if __cplusplus >= 201103L
307 open(
const std::string& __s, ios_base::openmode __mode)
308 {
return open(__s.
c_str(), __mode); }
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);
553 __istream_type::swap(__rhs);
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);
757 __ostream_type::swap(__rhs);
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);
959 __iostream_type::swap(__rhs);
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
bool is_open()
Wrapper to test for an open file.
char_type * gptr() const
Access to the get area.
basic_fstream(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
virtual streamsize showmanyc()
Investigating the data available.
basic_ofstream(const std::string &__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Create an output file stream.
void close()
Close the file.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Opens an external file.
Template class basic_ios, virtual base class for all stream classes.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
~basic_fstream()
The destructor does nothing.
void open(const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Opens an external file.
Controlling input and output for files.
traits_type::off_type off_type
Template class basic_ostream.
~basic_ofstream()
The destructor does nothing.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
static const openmode in
Open for input. Default for ifstream and fstream.
basic_ifstream(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
virtual int_type overflow(int_type __c=traits_type::eof())
Consumes data from the buffer; writes to the controlled sequence.
traits_type::int_type int_type
bool is_open()
Wrapper to test for an open file.
bool is_open()
Wrapper to test for an open file.
The actual work of input and output (for files).
static const openmode trunc
Open for input. Default for ofstream.
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
basic_ofstream(const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Create an output file stream.
basic_fstream()
Default constructor.
void open(const char *__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
void close()
Close the file.
Primary class template codecvt.NB: Generic, mostly useless implementation.
void clear(iostate __state=goodbit)
[Re]sets the error state.
void swap(basic_fstream< _CharT, _Traits > &__x, basic_fstream< _CharT, _Traits > &__y)
Swap specialization for fstreams.
ISO C++ entities toplevel namespace is std.
Template class basic_istream.
Controlling output for files.
basic_ifstream(const char *__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
Class representing stream positions.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
static const openmode out
Open for output. Default for ofstream and fstream.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode=ios_base::in|ios_base::out)
Alters the stream positions.
basic_streambuf< char_type, traits_type > __streambuf_type
This is a non-standard type.
virtual streamsize xsputn(const char_type *__s, streamsize __n)
Multiple character insertion.
Template class basic_iostream.
~basic_ifstream()
The destructor does nothing.
virtual pos_type seekpos(pos_type, ios_base::openmode=ios_base::in|ios_base::out)
Alters the stream positions.
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
virtual int_type underflow()
Fetches more data from the controlled sequence.
virtual streamsize xsgetn(char_type *__s, streamsize __n)
Multiple character extraction.
The actual work of input and output (interface).
void setstate(iostate __state)
Sets additional flags in the error state.
Controlling input for files.
basic_ifstream()
Default constructor.
basic_ofstream()
Default constructor.
char_type * eback() 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.
virtual basic_streambuf< char_type, _Traits > * setbuf(char_type *, streamsize)
Manipulates the buffer.
void open(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
static const openmode app
Seek to end before each write.
virtual void imbue(const locale &__loc)
Changes translations.
void close()
Close the file.
traits_type::pos_type pos_type
char_type * egptr() const
Access to the get area.
virtual int_type pbackfail(int_type __c=traits_type::eof())
Tries to back up the input sequence.
void setg(char_type *__gbeg, char_type *__gnext, char_type *__gend)
Setting the three read area pointers.
void setp(char_type *__pbeg, char_type *__pend)
Setting the three write area pointers.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.