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;
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*
376 setbuf(char_type* __s, streamsize __n);
388 _M_seek(off_type __off,
ios_base::seekdir __way, __state_type __state);
391 _M_get_ext_pos(__state_type &__state);
400 xsgetn(char_type* __s, streamsize __n);
403 xsputn(const char_type* __s, streamsize __n);
407 _M_terminate_output();
428 if (__testin && __off > 0)
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;
482 { this->
init(&_M_filebuf); }
498 this->
init(&_M_filebuf);
499 this->
open(__s, __mode);
502 #if __cplusplus >= 201103L
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);
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;
683 { this->
init(&_M_filebuf); }
701 this->
init(&_M_filebuf);
702 this->
open(__s, __mode);
705 #if __cplusplus >= 201103L
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);
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;
891 { this->
init(&_M_filebuf); }
906 this->
init(&_M_filebuf);
907 this->
open(__s, __mode);
910 #if __cplusplus >= 201103L
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);
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
~basic_fstream()
The destructor does nothing.
basic_ofstream(const std::string &__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Create an output file stream.
Controlling input for files.
void swap(basic_filebuf< _CharT, _Traits > &__x, basic_filebuf< _CharT, _Traits > &__y)
Swap specialization for filebufs.
__filebuf_type * open(const std::string &__s, ios_base::openmode __mode)
Opens an external file.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
char_type * _M_buf
Pointer to the beginning of internal buffer.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
char_type * egptr() const
Access to the get area.
void _M_set_buffer(streamsize __off)
static const openmode in
Open for input. Default for ifstream and fstream.
Template class basic_ostream.
static const openmode out
Open for output. Default for ofstream and fstream.
virtual void imbue(const locale &__loc)
Changes translations.
Controlling output for files.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Opens an external file.
~basic_ofstream()
The destructor does nothing.
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
~basic_ifstream()
The destructor does nothing.
static const openmode trunc
Open for input. Default for ofstream.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
basic_ifstream(const char *__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
__filebuf_type * close()
Closes the currently associated file.
void setstate(iostate __state)
Sets additional flags in the error state.
virtual streamsize showmanyc()
Investigating the data available.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current filebuf.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
Controlling input and output for files.
char_type * _M_pback_end_save
basic_fstream()
Default constructor.
Template class basic_istream.
Primary class template codecvt.NB: Generic, mostly useless implementation.
basic_fstream(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
streamsize _M_ext_buf_size
void setp(char_type *__pbeg, char_type *__pend)
Setting the three write area pointers.
virtual streamsize xsputn(const char_type *__s, streamsize __n)
Multiple character insertion.
basic_ifstream()
Default constructor.
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
bool is_open()
Wrapper to test for an open file.
char_type * eback() const
Access to the get area.
void close()
Close the file.
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
void close()
Close the 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.
basic_ofstream(const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Create an output file stream.
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 app
Seek to end before each write.
basic_ifstream(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
bool is_open() const
Returns true if the external file is open.
Template class basic_iostream.
The actual work of input and output (for files).
basic_ofstream()
Default constructor.
bool is_open()
Wrapper to test for an open file.
void close()
Close the file.
bool is_open()
Wrapper to test for an open file.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
The actual work of input and output (interface).
virtual int sync()
Synchronizes the buffer arrays with the controlled sequences.
void open(const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Opens an external file.
void open(const char *__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
virtual streamsize xsgetn(char_type *__s, streamsize __n)
Multiple character extraction.
basic_filebuf()
Does not open any files.
__filebuf_type * open(const char *__s, ios_base::openmode __mode)
Opens an external file.
virtual ~basic_filebuf()
The destructor closes the file first.
void clear(iostate __state=goodbit)
[Re]sets the error state.
Template class basic_ios, virtual base class for all stream classes.
virtual pos_type seekpos(pos_type __pos, 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.
Container class for localization functionality.The locale class is first a class wrapper for C librar...
Class representing stream positions.
char_type * _M_pback_cur_save
virtual int_type underflow()
Fetches more data from the controlled sequence.
virtual __streambuf_type * setbuf(char_type *__s, streamsize __n)
Manipulates the buffer.
char_type * gptr() const
Access to the get area.