35 #ifndef _GLIBCXX_FSTREAM
36 #define _GLIBCXX_FSTREAM 1
38 #pragma GCC system_header
45 #ifdef __GXX_EXPERIMENTAL_CXX0X__
49 _GLIBCXX_BEGIN_NAMESPACE(std)
66 template<typename _CharT, typename _Traits>
71 typedef _CharT char_type;
72 typedef _Traits traits_type;
73 typedef typename traits_type::int_type int_type;
74 typedef typename traits_type::pos_type pos_type;
75 typedef typename traits_type::off_type off_type;
79 typedef __basic_file<char> __file_type;
80 typedef typename traits_type::state_type __state_type;
97 __state_type _M_state_beg;
102 __state_type _M_state_cur;
106 __state_type _M_state_last;
119 bool _M_buf_allocated;
144 const __codecvt_type* _M_codecvt;
176 _M_pback_cur_save = this->gptr();
177 _M_pback_end_save = this->egptr();
178 this->setg(&_M_pback, &_M_pback, &_M_pback + 1);
179 _M_pback_init =
true;
194 _M_pback_cur_save += this->gptr() != this->eback();
195 this->setg(_M_buf, _M_pback_cur_save, _M_pback_end_save);
196 _M_pback_init =
false;
223 {
return _M_file.is_open(); }
265 open(
const char* __s, ios_base::openmode __mode);
267 #ifdef __GXX_EXPERIMENTAL_CXX0X__
276 {
return open(__s.
c_str(), __mode); }
295 _M_allocate_internal_buffer();
298 _M_destroy_internal_buffer() throw();
313 pbackfail(int_type __c = _Traits::eof());
323 overflow(int_type __c = _Traits::eof());
328 _M_convert_to_external(char_type*,
streamsize);
342 virtual __streambuf_type*
343 setbuf(char_type* __s, streamsize __n);
346 seekoff(off_type __off,
ios_base::seekdir __way,
350 seekpos(pos_type __pos,
355 _M_seek(off_type __off,
ios_base::seekdir __way, __state_type __state);
361 imbue(const
locale& __loc);
364 xsgetn(char_type* __s, streamsize __n);
367 xsputn(const char_type* __s, streamsize __n);
371 _M_terminate_output();
386 _M_set_buffer(streamsize __off)
388 const bool __testin = _M_mode & ios_base::in;
389 const bool __testout = _M_mode & ios_base::out;
391 if (__testin && __off > 0)
392 this->setg(_M_buf, _M_buf, _M_buf + __off);
394 this->setg(_M_buf, _M_buf, _M_buf);
396 if (__testout && __off == 0 && _M_buf_size > 1 )
397 this->setp(_M_buf, _M_buf + _M_buf_size - 1);
399 this->setp(NULL, NULL);
413 template<
typename _CharT,
typename _Traits>
418 typedef _CharT char_type;
419 typedef _Traits traits_type;
420 typedef typename traits_type::int_type int_type;
421 typedef typename traits_type::pos_type pos_type;
422 typedef typename traits_type::off_type off_type;
441 { this->init(&_M_filebuf); }
457 this->init(&_M_filebuf);
458 this->open(__s, __mode);
461 #ifdef __GXX_EXPERIMENTAL_CXX0X__
471 ios_base::openmode __mode = ios_base::in)
474 this->init(&_M_filebuf);
475 this->open(__s, __mode);
505 {
return _M_filebuf.is_open(); }
511 {
return _M_filebuf.is_open(); }
525 open(
const char* __s, ios_base::openmode __mode = ios_base::in)
527 if (!_M_filebuf.open(__s, __mode | ios_base::in))
528 this->setstate(ios_base::failbit);
535 #ifdef __GXX_EXPERIMENTAL_CXX0X__
547 if (!_M_filebuf.open(__s, __mode | ios_base::in))
548 this->setstate(ios_base::failbit);
565 if (!_M_filebuf.close())
566 this->setstate(ios_base::failbit);
581 template<
typename _CharT,
typename _Traits>
586 typedef _CharT char_type;
587 typedef _Traits traits_type;
588 typedef typename traits_type::int_type int_type;
589 typedef typename traits_type::pos_type pos_type;
590 typedef typename traits_type::off_type off_type;
609 { this->init(&_M_filebuf); }
624 ios_base::openmode __mode = ios_base::out|ios_base::trunc)
627 this->init(&_M_filebuf);
628 this->open(__s, __mode);
631 #ifdef __GXX_EXPERIMENTAL_CXX0X__
642 ios_base::openmode __mode = ios_base::out|ios_base::trunc)
645 this->init(&_M_filebuf);
646 this->open(__s, __mode);
676 {
return _M_filebuf.is_open(); }
682 {
return _M_filebuf.is_open(); }
697 ios_base::openmode __mode = ios_base::out | ios_base::trunc)
699 if (!_M_filebuf.open(__s, __mode | ios_base::out))
700 this->setstate(ios_base::failbit);
707 #ifdef __GXX_EXPERIMENTAL_CXX0X__
718 ios_base::openmode __mode = ios_base::out | ios_base::trunc)
720 if (!_M_filebuf.open(__s, __mode | ios_base::out))
721 this->setstate(ios_base::failbit);
738 if (!_M_filebuf.close())
739 this->setstate(ios_base::failbit);
754 template<
typename _CharT,
typename _Traits>
759 typedef _CharT char_type;
760 typedef _Traits traits_type;
761 typedef typename traits_type::int_type int_type;
762 typedef typename traits_type::pos_type pos_type;
763 typedef typename traits_type::off_type off_type;
784 { this->init(&_M_filebuf); }
796 ios_base::openmode __mode = ios_base::in | ios_base::out)
799 this->init(&_M_filebuf);
800 this->open(__s, __mode);
803 #ifdef __GXX_EXPERIMENTAL_CXX0X__
811 ios_base::openmode __mode = ios_base::in | ios_base::out)
814 this->init(&_M_filebuf);
815 this->open(__s, __mode);
845 {
return _M_filebuf.is_open(); }
851 {
return _M_filebuf.is_open(); }
866 ios_base::openmode __mode = ios_base::in | ios_base::out)
868 if (!_M_filebuf.open(__s, __mode))
869 this->setstate(ios_base::failbit);
876 #ifdef __GXX_EXPERIMENTAL_CXX0X__
887 ios_base::openmode __mode = ios_base::in | ios_base::out)
889 if (!_M_filebuf.open(__s, __mode))
890 this->setstate(ios_base::failbit);
907 if (!_M_filebuf.close())
908 this->setstate(ios_base::failbit);
912 _GLIBCXX_END_NAMESPACE
914 #ifndef _GLIBCXX_EXPORT_TEMPLATE
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.
basic_fstream(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Create an input/output file stream.
ptrdiff_t streamsize
Integral type for I/O operation counts and buffer sizes.
Merging istream and ostream capabilities.This class multiply inherits from the input and output strea...
streamsize _M_ext_buf_size
bool is_open() const
Returns true if the external file is open.
char_type * _M_pback_end_save
__filebuf_type * rdbuf() const
Accessing the underlying buffer.
Controlling output for files.This class supports reading from named files, using the inherited functi...
const _CharT * c_str() const
Return const pointer to null-terminated contents.
bool is_open()
Wrapper to test for an open file.
void open(const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Opens an external file.
The actual work of input and output (interface).
~basic_ifstream()
The destructor does nothing.
void open(const char *__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
The base of the I/O class hierarchy.This class defines everything that can be defined about I/O that ...
char_type * _M_buf
Pointer to the beginning of internal buffer.
~basic_ofstream()
The destructor does nothing.
basic_fstream()
Default constructor.
__filebuf_type * open(const std::string &__s, ios_base::openmode __mode)
Opens an external file.
~basic_fstream()
The destructor does nothing.
Virtual base class for all stream classes.Most of the member functions called dispatched on stream ob...
__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.
Controlling output.This is the base class for all output streams. It provides text formatting of all ...
basic_ofstream(const char *__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Create an output file stream.
Controlling input for files.This class supports reading from named files, using the inherited functio...
void open(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Opens an external file.
bool is_open()
Wrapper to test for an open file.
basic_ifstream(const std::string &__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
void open(const std::string &__s, ios_base::openmode __mode=ios_base::out|ios_base::trunc)
Opens an external file.
The actual work of input and output (for files).This class associates both its input and output seque...
Container class for localization functionality.
__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.
basic_ifstream()
Default constructor.
bool is_open()
Wrapper to test for an open file.
void close()
Close the file.
basic_ifstream(const char *__s, ios_base::openmode __mode=ios_base::in)
Create an input file stream.
ios_base::openmode _M_mode
Place to stash in || out || in | out settings for current filebuf.
class codecvt [22.2.1.5]. NB: Generic, mostly useless implementation.
void open(const char *__s, ios_base::openmode __mode=ios_base::in|ios_base::out)
Opens an external file.
basic_ofstream()
Default constructor.
virtual ~basic_filebuf()
The destructor closes the file first.
Controlling input.This is the base class for all input streams. It provides text formatting of all bu...
char_type * _M_pback_cur_save
Controlling input and output for files.This class supports reading from and writing to named files...
void close()
Close the file.