STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
basic_filebuf< _Elem, _Traits > Class Template Reference
Inheritance diagram for basic_filebuf< _Elem, _Traits >:
basic_streambuf< _Elem, _Traits >

Public Types

enum  _Initfl { _Newfl, _Openfl, _Closefl }
 
typedef basic_filebuf< _Elem, _Traits > _Myt
 
typedef basic_streambuf< _Elem, _Traits > _Mysb
 
typedef _Traits::state_type _Myst
 
typedef codecvt< _Elem, char, typename _Traits::state_type > _Cvt
 
typedef _Traits::int_type int_type
 
typedef _Traits::pos_type pos_type
 
typedef _Traits::off_type off_type
 
- Public Types inherited from basic_streambuf< _Elem, _Traits >
typedef _Elem char_type
 
typedef _Traits traits_type
 
typedef _Traits::int_type int_type
 
typedef _Traits::pos_type pos_type
 
typedef _Traits::off_type off_type
 

Public Member Functions

 basic_filebuf (_Filet *_File=0)
 
virtual __CLR_OR_THIS_CALL ~basic_filebuf () _NOEXCEPT
 
 basic_filebuf (_Uninitialized)
 
 basic_filebuf (_Myt &&_Right)
 
_Mytoperator= (_Myt &&_Right)
 
void _Assign_rv (_Myt &&_Right)
 
void swap (_Myt &_Right)
 
 basic_filebuf (const _Myt &)=delete
 
_Mytoperator= (const _Myt &)=delete
 
bool is_open () const
 
_Mytopen (const char *_Filename, ios_base::openmode _Mode, int _Prot=(int) ios_base::_Openprot)
 
_Mytopen (const string &_Str, ios_base::openmode _Mode, int _Prot=(int) ios_base::_Openprot)
 
_Mytopen (const wchar_t *_Filename, ios_base::openmode _Mode, int _Prot=(int) ios_base::_Openprot)
 
_Mytopen (const wstring &_Str, ios_base::openmode _Mode, int _Prot=(int) ios_base::_Openprot)
 
_Mytclose ()
 
virtual void __CLR_OR_THIS_CALL _Lock ()
 
virtual void __CLR_OR_THIS_CALL _Unlock ()
 
- Public Member Functions inherited from basic_streambuf< _Elem, _Traits >
virtual __CLR_OR_THIS_CALL ~basic_streambuf () _NOEXCEPT
 
pos_type __CLR_OR_THIS_CALL pubseekoff (off_type _Off, ios_base::seekdir _Way, ios_base::openmode _Mode=ios_base::in|ios_base::out)
 
pos_type __CLR_OR_THIS_CALL pubseekpos (pos_type _Pos, ios_base::openmode _Mode=ios_base::in|ios_base::out)
 
_Myt *__CLR_OR_THIS_CALL pubsetbuf (_Elem *_Buffer, streamsize _Count)
 
locale __CLR_OR_THIS_CALL pubimbue (const locale &_Newlocale)
 
locale __CLR_OR_THIS_CALL getloc () const
 
streamsize __CLR_OR_THIS_CALL in_avail ()
 
int __CLR_OR_THIS_CALL pubsync ()
 
int_type __CLR_OR_THIS_CALL sbumpc ()
 
int_type __CLR_OR_THIS_CALL sgetc ()
 
streamsize __CLR_OR_THIS_CALL sgetn (_Elem *_Ptr, streamsize _Count)
 
int_type __CLR_OR_THIS_CALL snextc ()
 
int_type __CLR_OR_THIS_CALL sputbackc (_Elem _Ch)
 
int_type __CLR_OR_THIS_CALL sungetc ()
 
int_type __CLR_OR_THIS_CALL sputc (_Elem _Ch)
 
streamsize __CLR_OR_THIS_CALL sputn (const _Elem *_Ptr, streamsize _Count)
 

Protected Member Functions

virtual int_type __CLR_OR_THIS_CALL overflow (int_type _Meta=_Traits::eof())
 
virtual int_type __CLR_OR_THIS_CALL pbackfail (int_type _Meta=_Traits::eof())
 
virtual int_type __CLR_OR_THIS_CALL underflow ()
 
virtual int_type __CLR_OR_THIS_CALL uflow ()
 
virtual pos_type __CLR_OR_THIS_CALL seekoff (off_type _Off, ios_base::seekdir _Way, ios_base::openmode=(ios_base::openmode)(ios_base::in|ios_base::out))
 
virtual pos_type __CLR_OR_THIS_CALL seekpos (pos_type _Pos, ios_base::openmode=(ios_base::openmode)(ios_base::in|ios_base::out))
 
virtual _Mysb *__CLR_OR_THIS_CALL setbuf (_Elem *_Buffer, streamsize _Count)
 
virtual int __CLR_OR_THIS_CALL sync ()
 
virtual void __CLR_OR_THIS_CALL imbue (const locale &_Loc)
 
void _Init (_Filet *_File, _Initfl _Which)
 
bool _Endwrite ()
 
void _Initcvt (const _Cvt *_Newpcvt)
 
- Protected Member Functions inherited from basic_streambuf< _Elem, _Traits >
__CLR_OR_THIS_CALL basic_streambuf ()
 
__CLR_OR_THIS_CALL basic_streambuf (_Uninitialized)
 
__CLR_OR_THIS_CALL basic_streambuf (const _Myt &_Right)
 
_Myt &__CLR_OR_THIS_CALL operator= (const _Myt &_Right)
 
void __CLR_OR_THIS_CALL swap (_Myt &_Right)
 
_Elem *__CLR_OR_THIS_CALL eback () const
 
_Elem *__CLR_OR_THIS_CALL gptr () const
 
_Elem *__CLR_OR_THIS_CALL pbase () const
 
_Elem *__CLR_OR_THIS_CALL pptr () const
 
_Elem *__CLR_OR_THIS_CALL egptr () const
 
void __CLR_OR_THIS_CALL gbump (int _Off)
 
void __CLR_OR_THIS_CALL setg (_Elem *_First, _Elem *_Next, _Elem *_Last)
 
_Elem *__CLR_OR_THIS_CALL epptr () const
 
_Elem *__CLR_OR_THIS_CALL _Gndec ()
 
_Elem *__CLR_OR_THIS_CALL _Gninc ()
 
_Elem *__CLR_OR_THIS_CALL _Gnpreinc ()
 
streamsize __CLR_OR_THIS_CALL _Gnavail () const
 
void __CLR_OR_THIS_CALL pbump (int _Off)
 
void __CLR_OR_THIS_CALL setp (_Elem *_First, _Elem *_Last)
 
void __CLR_OR_THIS_CALL setp (_Elem *_First, _Elem *_Next, _Elem *_Last)
 
_Elem *__CLR_OR_THIS_CALL _Pninc ()
 
streamsize __CLR_OR_THIS_CALL _Pnavail () const
 
void __CLR_OR_THIS_CALL _Init ()
 
void __CLR_OR_THIS_CALL _Init (_Elem **_Gf, _Elem **_Gn, int *_Gc, _Elem **_Pf, _Elem **_Pn, int *_Pc)
 
virtual streamsize __CLR_OR_THIS_CALL showmanyc ()
 
virtual streamsize __CLR_OR_THIS_CALL xsgetn (_Elem *_Ptr, streamsize _Count)
 
virtual streamsize __CLR_OR_THIS_CALL xsputn (const _Elem *_Ptr, streamsize _Count)
 

Private Member Functions

void _Reset_back ()
 
void _Set_back ()
 

Private Attributes

const _Cvt_Pcvt
 
_Elem _Mychar
 
bool _Wrotesome
 
_Traits::state_type _State
 
bool _Closef
 
_Filet_Myfile
 
_Elem * _Set_eback
 
_Elem * _Set_egptr
 

Additional Inherited Members

- Protected Attributes inherited from basic_streambuf< _Elem, _Traits >
locale_Plocale
 

Member Typedef Documentation

template<class _Elem, class _Traits>
typedef codecvt<_Elem, char, typename _Traits::state_type> basic_filebuf< _Elem, _Traits >::_Cvt
template<class _Elem, class _Traits>
typedef basic_streambuf<_Elem, _Traits> basic_filebuf< _Elem, _Traits >::_Mysb
template<class _Elem, class _Traits>
typedef _Traits::state_type basic_filebuf< _Elem, _Traits >::_Myst
template<class _Elem, class _Traits>
typedef basic_filebuf<_Elem, _Traits> basic_filebuf< _Elem, _Traits >::_Myt
template<class _Elem, class _Traits>
typedef _Traits::int_type basic_filebuf< _Elem, _Traits >::int_type
template<class _Elem, class _Traits>
typedef _Traits::off_type basic_filebuf< _Elem, _Traits >::off_type
template<class _Elem, class _Traits>
typedef _Traits::pos_type basic_filebuf< _Elem, _Traits >::pos_type

Member Enumeration Documentation

template<class _Elem, class _Traits>
enum basic_filebuf::_Initfl
Enumerator
_Newfl 
_Openfl 
_Closefl 
254  { // reasons for a call to _Init
Definition: fstream:255
Definition: fstream:255
Definition: fstream:255

Constructor & Destructor Documentation

template<class _Elem, class _Traits>
basic_filebuf< _Elem, _Traits >::basic_filebuf ( _Filet _File = 0)
inline
145  : _Mysb()
146  { // construct from pointer to C stream
147  _Init(_File, _Newfl);
148  }
Definition: fstream:255
basic_streambuf< _Elem, _Traits > _Mysb
Definition: fstream:140
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:316
template<class _Elem, class _Traits>
virtual __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::~basic_filebuf ( )
inlinevirtual
151  { // destroy the object
152  if (_Myfile != 0)
153  _Reset_back(); // revert from _Mychar buffer
154  if (_Closef)
155  close();
156  }
void _Reset_back()
Definition: fstream:698
_Myt * close()
Definition: fstream:340
bool _Closef
Definition: fstream:695
_Filet * _Myfile
Definition: fstream:696
template<class _Elem, class _Traits>
basic_filebuf< _Elem, _Traits >::basic_filebuf ( _Uninitialized  )
inline
163  : _Mysb(_Noinit)
164  { // construct uninitialized
165  }
basic_streambuf< _Elem, _Traits > _Mysb
Definition: fstream:140
template<class _Elem, class _Traits>
basic_filebuf< _Elem, _Traits >::basic_filebuf ( _Myt &&  _Right)
inline
168  { // construct by copying _Right
169  _Init(_Right._Myfile, _Newfl); // match buffering styles
170  _Init((_Filet *)0, _Closefl); // then make *this look closed
172  }
Definition: fstream:255
void _Assign_rv(_Myt &&_Right)
Definition: fstream:180
Definition: corecrt_wstdio.h:25
Definition: fstream:255
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:316
constexpr remove_reference< _Ty >::type && move(_Ty &&_Arg) _NOEXCEPT
Definition: type_traits:1349
constexpr const _Ty &() _Right
Definition: algorithm:3723
template<class _Elem, class _Traits>
basic_filebuf< _Elem, _Traits >::basic_filebuf ( const _Myt )
delete

Member Function Documentation

template<class _Elem, class _Traits>
void basic_filebuf< _Elem, _Traits >::_Assign_rv ( _Myt &&  _Right)
inline
181  { // assign by moving _Right
182  if (this != _STD addressof(_Right))
183  { // different, worth moving
184  close();
185  this->swap(_Right);
186  }
187  }
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
_Myt * close()
Definition: fstream:340
void swap(_Myt &_Right)
Definition: fstream:189
constexpr const _Ty &() _Right
Definition: algorithm:3723
template<class _Elem, class _Traits>
bool basic_filebuf< _Elem, _Traits >::_Endwrite ( )
inlineprotected
639  { // put shift to initial conversion state, as needed
640  if (_Pcvt == 0 || !_Wrotesome)
641  return (true);
642  else
643  { // may have to put
644  const int _STRING_INC = 8;
645  char *_Dest;
646  if (_Traits::eq_int_type(_Traits::eof(), overflow()))
647  return (false);
648 
649  string _Str(_STRING_INC, '\0');
650  for (; ; )
651  switch (_Pcvt->unshift(_State,
652  &*_Str.begin(), &*_Str.begin() + _Str.size(), _Dest))
653  { // test result of homing conversion
654  case codecvt_base::ok:
655  _Wrotesome = false; // homed successfully
656 
657  case codecvt_base::partial: // fall through
658  { // put any generated bytes
659  size_t _Count = _Dest - &*_Str.begin();
660  if (0 < _Count && _Count !=
661  fwrite(&*_Str.begin(), 1, _Count, _Myfile))
662  return (false); // write failed
663  if (!_Wrotesome)
664  return (true);
665  if (_Count == 0)
666  _Str.append(_STRING_INC, '\0'); // try with more space
667  break;
668  }
669 
671  return (true); // nothing to do
672 
673  default:
674  return (false); // conversion failed
675  }
676  }
677  }
const _Cvt * _Pcvt
Definition: fstream:691
unsigned _Dest
Definition: mbstring.h:107
bool _Wrotesome
Definition: fstream:693
_Filet * _Myfile
Definition: fstream:696
virtual int_type __CLR_OR_THIS_CALL overflow(int_type _Meta=_Traits::eof())
Definition: fstream:369
_Traits::state_type _State
Definition: fstream:694
_Diff _Count
Definition: algorithm:1941
Definition: xlocale:759
result __CLR_OR_THIS_CALL unshift(_Statype &_State, _Byte *_First2, _Byte *_Last2, _Byte *&_Mid2) const
Definition: xlocale:831
_Check_return_opt_ _ACRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_ElementSize *_ElementCount) void const *_Buffer, _In_ size_t _ElementSize, _In_ size_t _ElementCount, _Inout_ FILE *_Stream)
Definition: xlocale:759
Definition: xlocale:759
template<class _Elem, class _Traits>
void basic_filebuf< _Elem, _Traits >::_Init ( _Filet _File,
_Initfl  _Which 
)
inlineprotected
604  { // initialize to C stream _File after {new, open, close}
605  __PURE_APPDOMAIN_GLOBAL static _Myst _Stinit; // initial state
606 
607  _Closef = _Which == _Openfl;
608  _Wrotesome = false;
609 
610  _Mysb::_Init(); // initialize stream buffer base object
611 
612  #ifndef _IORCNT
613  #define _IORCNT _IOCNT /* read and write counts are the same */
614  #define _IOWCNT _IOCNT
615  #endif /* _IORCNT */
616 
617  if (_File != 0 && sizeof (_Elem) == 1)
618  { // point inside C stream with [first, first + count) buffer
619  _Elem **_Pb = 0;
620  _Elem **_Pn = 0;
621  int *_Nr = 0;
622 
624  _File,
625  reinterpret_cast<char***>(&_Pb),
626  reinterpret_cast<char***>(&_Pn),
627  &_Nr);
628  int *_Nw = _Nr;
629 
630  _Mysb::_Init(_Pb, _Pn, _Nr, _Pb, _Pn, _Nw);
631  }
632 
633  _Myfile = _File;
634  _State = _Stinit;
635  _Pcvt = 0; // pointer to codecvt facet
636  }
#define __PURE_APPDOMAIN_GLOBAL
Definition: yvals.h:207
const _Cvt * _Pcvt
Definition: fstream:691
bool _Wrotesome
Definition: fstream:693
bool _Closef
Definition: fstream:695
_Filet * _Myfile
Definition: fstream:696
_Check_return_opt_ _ACRTIMP errno_t __cdecl _get_stream_buffer_pointers(_In_ FILE *_Stream, _Out_opt_ char ***_Base, _Out_opt_ char ***_Pointer, _Out_opt_ int **_Count)
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:316
Definition: fstream:255
_Traits::state_type _State
Definition: fstream:694
_Traits::state_type _Myst
Definition: fstream:141
template<class _Elem, class _Traits>
void basic_filebuf< _Elem, _Traits >::_Initcvt ( const _Cvt _Newpcvt)
inlineprotected
680  { // initialize codecvt pointer
681  if (_Newpcvt->always_noconv())
682  _Pcvt = 0; // nothing to do
683  else
684  { // set up for nontrivial codecvt facet
685  _Pcvt = _Newpcvt;
686  _Mysb::_Init(); // reset any buffering
687  }
688  }
const _Cvt * _Pcvt
Definition: fstream:691
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:316
template<class _Elem, class _Traits>
virtual void __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::_Lock ( )
inlinevirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

357  { // lock file instead of stream buffer
358  if (_Myfile)
360  }
_ACRTIMP void __cdecl _lock_file(_Inout_ FILE *_Stream)
_Filet * _Myfile
Definition: fstream:696
#define _CSTD
Definition: yvals.h:570
template<class _Elem, class _Traits>
void basic_filebuf< _Elem, _Traits >::_Reset_back ( )
inlineprivate
699  { // restore buffer after putback
700  if (_Mysb::eback() == &_Mychar)
702  }
void __CLR_OR_THIS_CALL setg(_Elem *_First, _Elem *_Next, _Elem *_Last)
Definition: streambuf:250
_Elem * _Set_egptr
Definition: fstream:715
_Elem * _Set_eback
Definition: fstream:714
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:219
_Elem _Mychar
Definition: fstream:692
template<class _Elem, class _Traits>
void basic_filebuf< _Elem, _Traits >::_Set_back ( )
inlineprivate
705  { // set up putback area
706  if (_Mysb::eback() != &_Mychar)
707  { // save current get buffer
710  }
712  }
_Elem *__CLR_OR_THIS_CALL egptr() const
Definition: streambuf:239
void __CLR_OR_THIS_CALL setg(_Elem *_First, _Elem *_Next, _Elem *_Last)
Definition: streambuf:250
_Elem * _Set_egptr
Definition: fstream:715
_Elem * _Set_eback
Definition: fstream:714
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:219
_Elem _Mychar
Definition: fstream:692
template<class _Elem, class _Traits>
virtual void __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::_Unlock ( )
inlinevirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

363  { // unlock file instead of stream buffer
364  if (_Myfile)
366  }
_Filet * _Myfile
Definition: fstream:696
_ACRTIMP void __cdecl _unlock_file(_Inout_ FILE *_Stream)
#define _CSTD
Definition: yvals.h:570
template<class _Elem, class _Traits>
_Myt* basic_filebuf< _Elem, _Traits >::close ( )
inline
341  { // close the C stream
342  _Myt *_Ans = this;
343  if (_Myfile == 0)
344  _Ans = 0;
345  else
346  { // put any homing sequence and close file
347  if (!_Endwrite())
348  _Ans = 0;
349  if (fclose(_Myfile) != 0)
350  _Ans = 0;
351  }
352  _Init(0, _Closefl);
353  return (_Ans);
354  }
bool _Endwrite()
Definition: fstream:638
_Filet * _Myfile
Definition: fstream:696
basic_filebuf< _Elem, _Traits > _Myt
Definition: fstream:139
Definition: fstream:255
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:316
template<class _Elem, class _Traits>
virtual void __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::imbue ( const locale _Loc)
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

599  { // set locale to argument (capture nontrivial codecvt facet)
600  _Initcvt(&_USE(_Loc, _Cvt));
601  }
void _Initcvt(const _Cvt *_Newpcvt)
Definition: fstream:679
#define _USE(loc, fac)
Definition: xlocale:499
codecvt< _Elem, char, typename _Traits::state_type > _Cvt
Definition: fstream:142
template<class _Elem, class _Traits>
bool basic_filebuf< _Elem, _Traits >::is_open ( ) const
inline
258  { // test if C stream has been opened
259  return (_Myfile != 0);
260  }
_Filet * _Myfile
Definition: fstream:696
template<class _Elem, class _Traits>
_Myt* basic_filebuf< _Elem, _Traits >::open ( const char _Filename,
ios_base::openmode  _Mode,
int  _Prot = (int)ios_base::_Openprot 
)
inline
265  { // open a C stream with specified mode
266  _Filet *_File;
267  if (_Myfile != 0 || (_File = _Fiopen(_Filename, _Mode, _Prot)) == 0)
268  return (0); // open failed
269 
270  _Init(_File, _Openfl);
272  return (this); // open succeeded
273  }
void _Initcvt(const _Cvt *_Newpcvt)
Definition: fstream:679
#define _USE(loc, fac)
Definition: xlocale:499
locale __CLR_OR_THIS_CALL getloc() const
Definition: streambuf:131
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
_Pre_notnull_ _In_opt_z_ wchar_t const _In_opt_z_ wchar_t const _In_opt_z_ wchar_t const _Filename
Definition: corecrt_wstdlib.h:366
Definition: corecrt_wstdio.h:25
_Filet * _Myfile
Definition: fstream:696
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:316
Definition: fstream:255
_STD_BEGIN _CRTIMP2_PURE _Filet *__CLRCALL_PURE_OR_CDECL _Fiopen(const char *, ios_base::openmode, int)
codecvt< _Elem, char, typename _Traits::state_type > _Cvt
Definition: fstream:142
template<class _Elem, class _Traits>
_Myt* basic_filebuf< _Elem, _Traits >::open ( const string _Str,
ios_base::openmode  _Mode,
int  _Prot = (int)ios_base::_Openprot 
)
inline
278  { // open a C stream with specified mode
279  return (open(_Str.c_str(), _Mode, _Prot));
280  }
_Ret_z_ const _Elem * c_str() const _NOEXCEPT
Definition: xstring:3001
_Myt * open(const char *_Filename, ios_base::openmode _Mode, int _Prot=(int) ios_base::_Openprot)
Definition: fstream:262
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
template<class _Elem, class _Traits>
_Myt* basic_filebuf< _Elem, _Traits >::open ( const wchar_t _Filename,
ios_base::openmode  _Mode,
int  _Prot = (int)ios_base::_Openprot 
)
inline
292  { // open a wide-named C stream -- EXTENSION
293  _Filet *_File;
294  if (_Myfile != 0 || (_File = _Fiopen(_Filename, _Mode, _Prot)) == 0)
295  return (0); // open failed
296 
297  _Init(_File, _Openfl);
299  return (this); // open succeeded
300  }
void _Initcvt(const _Cvt *_Newpcvt)
Definition: fstream:679
#define _USE(loc, fac)
Definition: xlocale:499
locale __CLR_OR_THIS_CALL getloc() const
Definition: streambuf:131
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
_Pre_notnull_ _In_opt_z_ wchar_t const _In_opt_z_ wchar_t const _In_opt_z_ wchar_t const _Filename
Definition: corecrt_wstdlib.h:366
Definition: corecrt_wstdio.h:25
_Filet * _Myfile
Definition: fstream:696
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:316
Definition: fstream:255
_STD_BEGIN _CRTIMP2_PURE _Filet *__CLRCALL_PURE_OR_CDECL _Fiopen(const char *, ios_base::openmode, int)
codecvt< _Elem, char, typename _Traits::state_type > _Cvt
Definition: fstream:142
template<class _Elem, class _Traits>
_Myt* basic_filebuf< _Elem, _Traits >::open ( const wstring _Str,
ios_base::openmode  _Mode,
int  _Prot = (int)ios_base::_Openprot 
)
inline
305  { // open a wide-named C stream -- EXTENSION
306  return (open(_Str.c_str(), _Mode, _Prot));
307  }
_Ret_z_ const _Elem * c_str() const _NOEXCEPT
Definition: xstring:3001
_Myt * open(const char *_Filename, ios_base::openmode _Mode, int _Prot=(int) ios_base::_Openprot)
Definition: fstream:262
_Check_return_ _In_z_ wchar_t const * _Mode
Definition: corecrt_wstdio.h:133
template<class _Elem, class _Traits>
_Myt& basic_filebuf< _Elem, _Traits >::operator= ( _Myt &&  _Right)
inline
175  { // assign from _Right
177  return (*this);
178  }
void _Assign_rv(_Myt &&_Right)
Definition: fstream:180
constexpr remove_reference< _Ty >::type && move(_Ty &&_Arg) _NOEXCEPT
Definition: type_traits:1349
constexpr const _Ty &() _Right
Definition: algorithm:3723
template<class _Elem, class _Traits>
_Myt& basic_filebuf< _Elem, _Traits >::operator= ( const _Myt )
delete
template<class _Elem, class _Traits>
virtual int_type __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::overflow ( int_type  _Meta = _Traits::eof())
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

371  { // put an element to stream
372  if (_Traits::eq_int_type(_Traits::eof(), _Meta))
373  return (_Traits::not_eof(_Meta)); // EOF, return success code
374  else if (_Mysb::pptr() != 0
375  && _Mysb::pptr() < _Mysb::epptr())
376  { // room in buffer, store it
377  *_Mysb::_Pninc() = _Traits::to_char_type(_Meta);
378  return (_Meta);
379  }
380  else if (_Myfile == 0)
381  return (_Traits::eof()); // no open C stream, fail
382  _Reset_back(); // revert from _Mychar buffer
383  if (_Pcvt == 0)
384  return (_Fputc(_Traits::to_char_type(_Meta), _Myfile)
385  ? _Meta : _Traits::eof()); // no codecvt facet, put as is
386  else
387  { // put using codecvt facet
388  const int _STRING_INC = 8;
389  const _Elem _Ch = _Traits::to_char_type(_Meta);
390  const _Elem *_Src;
391  char *_Dest;
392 
393  string _Str(_STRING_INC, '\0');
394  for (; ; )
395  switch (_Pcvt->out(_State,
396  &_Ch, &_Ch + 1, _Src,
397  &*_Str.begin(), &*_Str.begin() + _Str.size(), _Dest))
398  { // test result of converting one element
400  case codecvt_base::ok:
401  { // converted something, try to put it out
402  size_t _Count = _Dest - &*_Str.begin();
403  if (0 < _Count && _Count !=
404  fwrite(&*_Str.begin(), 1, _Count, _Myfile))
405  return (_Traits::eof()); // write failed
406 
407  _Wrotesome = true; // write succeeded
408  if (_Src != &_Ch)
409  return (_Meta); // converted whole element
410 
411  if (0 < _Count)
412  ;
413  else if (_Str.size() < 4 * _STRING_INC)
414  _Str.append(_STRING_INC, '\0'); // try with more space
415  else
416  return (_Traits::eof()); // conversion failed
417  break;
418  }
419 
421  return (_Fputc(_Ch, _Myfile) ? _Meta
422  : _Traits::eof()); // no conversion, put as is
423 
424  default:
425  return (_Traits::eof()); // conversion failed
426  }
427  }
428  }
const _Cvt * _Pcvt
Definition: fstream:691
unsigned _Dest
Definition: mbstring.h:107
_Elem *__CLR_OR_THIS_CALL epptr() const
Definition: streambuf:257
void _Reset_back()
Definition: fstream:698
bool _Wrotesome
Definition: fstream:693
_Elem *__CLR_OR_THIS_CALL pptr() const
Definition: streambuf:234
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
_In_ size_t _Out_opt_ int _In_z_ unsigned char const * _Src
Definition: mbstring.h:1039
_Filet * _Myfile
Definition: fstream:696
_Traits::state_type _State
Definition: fstream:694
_Diff _Count
Definition: algorithm:1941
_Elem *__CLR_OR_THIS_CALL _Pninc()
Definition: streambuf:305
Definition: xlocale:759
_Check_return_opt_ _ACRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_ElementSize *_ElementCount) void const *_Buffer, _In_ size_t _ElementSize, _In_ size_t _ElementCount, _Inout_ FILE *_Stream)
Definition: xlocale:759
result __CLR_OR_THIS_CALL out(_Statype &_State, const _Elem *_First1, const _Elem *_Last1, const _Elem *&_Mid1, _Byte *_First2, _Byte *_Last2, _Byte *&_Mid2) const
Definition: xlocale:823
Definition: xlocale:759
bool _Fputc(_Elem _Ch, _Filet *_File)
Definition: fstream:76
template<class _Elem, class _Traits>
virtual int_type __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::pbackfail ( int_type  _Meta = _Traits::eof())
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

432  { // put an element back to stream
433  if (_Mysb::gptr() != 0
434  && _Mysb::eback() < _Mysb::gptr()
435  && (_Traits::eq_int_type(_Traits::eof(), _Meta)
436  || _Traits::eq_int_type(_Traits::to_int_type(_Mysb::gptr()[-1]),
437  _Meta)))
438  { // just back up position
439  _Mysb::_Gndec();
440  return (_Traits::not_eof(_Meta));
441  }
442  else if (_Myfile == 0 || _Traits::eq_int_type(_Traits::eof(), _Meta))
443  return (_Traits::eof()); // no open C stream or EOF, fail
444  else if (_Pcvt == 0 && _Ungetc(_Traits::to_char_type(_Meta), _Myfile))
445  return (_Meta); // no facet and unget succeeded, return
446  else if (_Mysb::gptr() != &_Mychar)
447  { // putback to _Mychar
448  _Mychar = _Traits::to_char_type(_Meta);
449  _Set_back(); // switch to _Mychar buffer
450  return (_Meta);
451  }
452  else
453  return (_Traits::eof()); // nowhere to put back
454  }
const _Cvt * _Pcvt
Definition: fstream:691
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:224
void _Set_back()
Definition: fstream:704
_Elem *__CLR_OR_THIS_CALL _Gndec()
Definition: streambuf:262
bool _Ungetc(const _Elem &_Ch, _Filet *_File)
Definition: fstream:100
_Filet * _Myfile
Definition: fstream:696
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:219
_Elem _Mychar
Definition: fstream:692
template<class _Elem, class _Traits>
virtual pos_type __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::seekoff ( off_type  _Off,
ios_base::seekdir  _Way,
ios_base::openmode  = (ios_base::openmode)(ios_base::in | ios_base::out) 
)
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

539  { // change position by _Off
540  fpos_t _Fileposition;
541 
542  if (_Mysb::gptr() == &_Mychar // something putback
543  && _Way == ios_base::cur // a relative seek
544  && _Pcvt == 0) // not converting
545  _Off -= (off_type)sizeof (_Elem); // back up over _Elem bytes
546 
547  if (_Myfile == 0 || !_Endwrite()
548  || ((_Off != 0 || _Way != ios_base::cur)
549  && _fseeki64(_Myfile, _Off, _Way) != 0)
550  || fgetpos(_Myfile, &_Fileposition) != 0)
551  return (pos_type(_BADOFF)); // report failure
552 
553  _Reset_back(); // revert from _Mychar buffer, discarding any putback
555  _Fileposition)); // return new position
556  }
static constexpr _Seekdir cur
Definition: xiosbase:112
const _Cvt * _Pcvt
Definition: fstream:691
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:224
#define _POS_TYPE_FROM_STATE(postype, state, position)
Definition: iosfwd:119
bool _Endwrite()
Definition: fstream:638
void _Reset_back()
Definition: fstream:698
_Traits::pos_type pos_type
Definition: fstream:159
__int64 fpos_t
Definition: stdio.h:68
_Filet * _Myfile
Definition: fstream:696
_CRTDATA2 _PGLOBAL const streamoff _BADOFF
_Traits::state_type _State
Definition: fstream:694
_Traits::off_type off_type
Definition: fstream:160
_Elem _Mychar
Definition: fstream:692
template<class _Elem, class _Traits>
virtual pos_type __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::seekpos ( pos_type  _Pos,
ios_base::openmode  = (ios_base::openmode)(ios_base::in | ios_base::out) 
)
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

561  { // change position to _Pos
562  fpos_t _Fileposition = _POS_TYPE_TO_FPOS_T(_Pos);
563  off_type _Off = static_cast<off_type>(_Pos) - static_cast<off_type>(_Fileposition);
564 
565  if (_Myfile == 0 || !_Endwrite()
566  || fsetpos(_Myfile, &_Fileposition) != 0
567  || (_Off != 0 && _fseeki64(_Myfile, _Off, SEEK_CUR) != 0)
568  || fgetpos(_Myfile, &_Fileposition) != 0)
569  return (pos_type(_BADOFF)); // report failure
570 
571  _State = _POS_TYPE_TO_STATE(_Pos);
572 
573  _Reset_back(); // revert from _Mychar buffer, discarding any putback
575  _Fileposition)); // return new position
576  }
#define _POS_TYPE_FROM_STATE(postype, state, position)
Definition: iosfwd:119
bool _Endwrite()
Definition: fstream:638
void _Reset_back()
Definition: fstream:698
_Traits::pos_type pos_type
Definition: fstream:159
__int64 fpos_t
Definition: stdio.h:68
#define SEEK_CUR
Definition: stdio.h:53
#define _POS_TYPE_TO_STATE(pos)
Definition: iosfwd:122
_Filet * _Myfile
Definition: fstream:696
_CRTDATA2 _PGLOBAL const streamoff _BADOFF
_Traits::state_type _State
Definition: fstream:694
_Traits::off_type off_type
Definition: fstream:160
#define _POS_TYPE_TO_FPOS_T(pos)
Definition: iosfwd:121
template<class _Elem, class _Traits>
virtual _Mysb* __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::setbuf ( _Elem *  _Buffer,
streamsize  _Count 
)
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

579  { // offer _Buffer to C stream
580  if (_Myfile == 0 || setvbuf(_Myfile, (char *)_Buffer,
581  _Buffer == 0 && _Count == 0 ? _IONBF : _IOFBF,
582  (size_t)_Count * sizeof (_Elem)) != 0)
583  return (0); // failed
584  else
585  { // new buffer, reinitialize pointers
587  return (this);
588  }
589  }
#define _IONBF
Definition: stdio.h:40
_Check_return_wat_ *_SizeRead wchar_t * _Buffer
Definition: corecrt_wconio.h:27
_Filet * _Myfile
Definition: fstream:696
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:316
Definition: fstream:255
_Diff _Count
Definition: algorithm:1941
#define _IOFBF
Definition: stdio.h:38
template<class _Elem, class _Traits>
void basic_filebuf< _Elem, _Traits >::swap ( _Myt _Right)
inline
190  { // swap with _Right
191  if (this != _STD addressof(_Right))
192  { // different, worth swapping
193  // save values altered by _Init
194  _Filet *_Myfile_sav = _Myfile;
195  const _Cvt *_Pcvt_sav = _Pcvt;
196  typename _Traits::state_type _State_sav = _State;
197  bool _Wrotesome_sav = _Wrotesome;
198  bool _Closef_sav = _Closef;
199  bool _Set_eback_sav = _Mysb::eback() == &_Mychar;
200  bool _Set_eback_live = _Mysb::gptr() == &_Mychar;
201 
202  _Elem *_Pfirst0 = _Mysb::pbase();
203  _Elem *_Pnext0 = _Mysb::pptr();
204  _Elem *_Pend = _Mysb::epptr();
205  _Elem *_Gfirst0 = _Mysb::eback();
206  _Elem *_Gnext0 = _Mysb::gptr();
207  _Elem *_Gend = _Mysb::egptr();
208 
209  // reinitialize *this
210  _Init(_Right._Myfile, _Right._Myfile != 0 ? _Openfl : _Newfl);
211  _Mysb::setp(_Right.pbase(), _Right.pptr(), _Right.epptr());
212  if (_Right.eback() != &_Right._Mychar)
213  _Mysb::setg(_Right.eback(), _Right.gptr(), _Right.egptr());
214  else if (_Right.gptr() != &_Right._Mychar)
215  _Mysb::setg(&_Mychar, &_Mychar + 1, &_Mychar + 1);
216  else
218 
219  _Pcvt = _Right._Pcvt;
220  _State = _Right._State;
221  _Wrotesome = _Right._Wrotesome;
222  _Closef = _Right._Closef;
223 
224  // reinitialize _Right
225  _Right._Init(_Myfile_sav, _Myfile_sav != 0 ? _Openfl : _Newfl);
226  _Right.setp(_Pfirst0, _Pnext0, _Pend);
227  if (!_Set_eback_sav)
228  _Right.setg(_Gfirst0, _Gnext0, _Gend);
229  else if (!_Set_eback_live)
230  _Right.setg(&_Right._Mychar, &_Right._Mychar + 1,
231  &_Right._Mychar + 1);
232  else
233  _Right.setg(&_Right._Mychar, &_Right._Mychar,
234  &_Right._Mychar + 1);
235 
236  _Right._Pcvt = _Pcvt_sav;
237  _Right._State = _State_sav;
238  _Right._Wrotesome = _Wrotesome_sav;
239  _Right._Closef = _Closef_sav;
240 
241  // swap ancillary data
242  _STD swap(_Set_eback, _Right._Set_eback);
243  _STD swap(_Set_egptr, _Right._Set_egptr);
244 
245  _STD swap(_Mychar, _Right._Mychar);
246  _STD swap(_Mysb::_Plocale, _Right._Plocale);
247  }
248  }
_Elem *__CLR_OR_THIS_CALL egptr() const
Definition: streambuf:239
const _Cvt * _Pcvt
Definition: fstream:691
void __CLR_OR_THIS_CALL setg(_Elem *_First, _Elem *_Next, _Elem *_Last)
Definition: streambuf:250
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:224
_STD_BEGIN constexpr _Ty * addressof(_Ty &_Val) _NOEXCEPT
Definition: xstddef:628
_Elem * _Set_egptr
Definition: fstream:715
_Elem *__CLR_OR_THIS_CALL epptr() const
Definition: streambuf:257
bool _Wrotesome
Definition: fstream:693
Definition: fstream:255
_Elem *__CLR_OR_THIS_CALL pptr() const
Definition: streambuf:234
void __CLR_OR_THIS_CALL setp(_Elem *_First, _Elem *_Last)
Definition: streambuf:291
locale * _Plocale
Definition: streambuf:466
bool _Closef
Definition: fstream:695
_Elem *__CLR_OR_THIS_CALL pbase() const
Definition: streambuf:229
_Elem * _Set_eback
Definition: fstream:714
Definition: corecrt_wstdio.h:25
_Filet * _Myfile
Definition: fstream:696
void swap(_Myt &_Right)
Definition: fstream:189
void __CLR_OR_THIS_CALL _Init()
Definition: streambuf:316
Definition: fstream:255
_Traits::state_type _State
Definition: fstream:694
_Elem *__CLR_OR_THIS_CALL eback() const
Definition: streambuf:219
codecvt< _Elem, char, typename _Traits::state_type > _Cvt
Definition: fstream:142
_Elem _Mychar
Definition: fstream:692
constexpr const _Ty &() _Right
Definition: algorithm:3723
template<class _Elem, class _Traits>
virtual int __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::sync ( )
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

592  { // synchronize C stream with external file
593  return (_Myfile == 0
594  || _Traits::eq_int_type(_Traits::eof(), overflow())
595  || 0 <= fflush(_Myfile) ? 0 : -1);
596  }
_Filet * _Myfile
Definition: fstream:696
_Check_return_opt_ _ACRTIMP int __cdecl fflush(_Inout_opt_ FILE *_Stream)
virtual int_type __CLR_OR_THIS_CALL overflow(int_type _Meta=_Traits::eof())
Definition: fstream:369
template<class _Elem, class _Traits>
virtual int_type __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::uflow ( )
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

472  { // get an element from stream, point past it
473  if (_Mysb::gptr() != 0
474  && _Mysb::gptr() < _Mysb::egptr())
475  return (_Traits::to_int_type(
476  *_Mysb::_Gninc())); // return buffered
477  else if (_Myfile == 0)
478  return (_Traits::eof()); // no open C stream, fail
479  _Reset_back(); // revert from _Mychar buffer
480  if (_Pcvt == 0)
481  { // no codecvt facet, just get it
482  _Elem _Ch = 0;
483  return (_Fgetc(_Ch, _Myfile) ? _Traits::to_int_type(_Ch)
484  : _Traits::eof());
485  }
486  else
487  { // build string until codecvt succeeds
488  string _Str;
489 
490  for (; ; )
491  { // get using codecvt facet
492  _Elem _Ch, *_Dest;
493  const char *_Src;
494  int _Nleft;
495  int _Meta = fgetc(_Myfile);
496 
497  if (_Meta == EOF)
498  return (_Traits::eof()); // partial char?
499 
500  _Str.append(1, (char)_Meta); // append byte and convert
501  switch (_Pcvt->in(_State,
502  &*_Str.begin(), &*_Str.begin() + _Str.size(), _Src,
503  &_Ch, &_Ch + 1, _Dest))
504  { // test result of converting one element
506  case codecvt_base::ok:
507  if (_Dest != &_Ch)
508  { // got an element, put back excess and deliver it
509  _Nleft = (int)(&*_Str.begin() + _Str.size() - _Src);
510  for (; 0 < _Nleft; )
511  ungetc(_Src[--_Nleft], _Myfile);
512  return (_Traits::to_int_type(_Ch));
513  }
514  else
515  _Str.erase((size_t)0, // partial, discard used input
516  (size_t)(_Src - &*_Str.begin()));
517  break;
518 
520  if (_Str.size() < sizeof (_Elem))
521  break; // no conversion, but need more chars
522 
523  _CRT_SECURE_MEMCPY(&_Ch, sizeof (_Elem), &*_Str.begin(),
524  sizeof (_Elem)); // copy raw bytes to element
525 
526  return (_Traits::to_int_type(_Ch)); // return result
527 
528  default:
529  return (_Traits::eof()); // conversion failed
530  }
531  }
532  }
533  }
_Elem *__CLR_OR_THIS_CALL egptr() const
Definition: streambuf:239
const _Cvt * _Pcvt
Definition: fstream:691
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:224
unsigned _Dest
Definition: mbstring.h:107
void _Reset_back()
Definition: fstream:698
#define EOF
Definition: stdio.h:36
_Check_return_ _In_ wchar_t _Ch
Definition: vcruntime_string.h:89
result __CLR_OR_THIS_CALL in(_Statype &_State, const _Byte *_First1, const _Byte *_Last1, const _Byte *&_Mid1, _Elem *_First2, _Elem *_Last2, _Elem *&_Mid2) const
Definition: xlocale:815
_Myt & append(initializer_list< _Elem > _Ilist)
Definition: xstring:2199
_In_ size_t _Out_opt_ int _In_z_ unsigned char const * _Src
Definition: mbstring.h:1039
_Filet * _Myfile
Definition: fstream:696
char int *typedef int(__CRTDECL *_CRT_REPORT_HOOKW)(int
Definition: crtdbg.h:45
_Myt & erase(const size_type _Off=0)
Definition: xstring:2584
#define _CRT_SECURE_MEMCPY(dest, destsize, source, count)
Definition: yvals.h:438
iterator begin() _NOEXCEPT
Definition: xstring:2857
_Elem *__CLR_OR_THIS_CALL _Gninc()
Definition: streambuf:268
_Traits::state_type _State
Definition: fstream:694
size_type size() const _NOEXCEPT
Definition: xstring:3023
bool _Fgetc(_Elem &_Ch, _Filet *_File)
Definition: fstream:31
Definition: xlocale:759
Definition: xlocale:759
Definition: xlocale:759
template<class _Elem, class _Traits>
virtual int_type __CLR_OR_THIS_CALL basic_filebuf< _Elem, _Traits >::underflow ( )
inlineprotectedvirtual

Reimplemented from basic_streambuf< _Elem, _Traits >.

457  { // get an element from stream, but don't point past it
458  int_type _Meta;
459  if (_Mysb::gptr() != 0
460  && _Mysb::gptr() < _Mysb::egptr())
461  return (_Traits::to_int_type(*_Mysb::gptr())); // return buffered
462  else if (_Traits::eq_int_type(_Traits::eof(), _Meta = uflow()))
463  return (_Meta); // uflow failed, return EOF
464  else
465  { // get a char, don't point past it
466  pbackfail(_Meta);
467  return (_Meta);
468  }
469  }
_Elem *__CLR_OR_THIS_CALL egptr() const
Definition: streambuf:239
_Elem *__CLR_OR_THIS_CALL gptr() const
Definition: streambuf:224
virtual int_type __CLR_OR_THIS_CALL uflow()
Definition: fstream:471
_Traits::int_type int_type
Definition: fstream:158
virtual int_type __CLR_OR_THIS_CALL pbackfail(int_type _Meta=_Traits::eof())
Definition: fstream:430

Member Data Documentation

template<class _Elem, class _Traits>
bool basic_filebuf< _Elem, _Traits >::_Closef
private
template<class _Elem, class _Traits>
_Elem basic_filebuf< _Elem, _Traits >::_Mychar
private
template<class _Elem, class _Traits>
_Filet* basic_filebuf< _Elem, _Traits >::_Myfile
private
template<class _Elem, class _Traits>
const _Cvt* basic_filebuf< _Elem, _Traits >::_Pcvt
private
template<class _Elem, class _Traits>
_Elem* basic_filebuf< _Elem, _Traits >::_Set_eback
private
template<class _Elem, class _Traits>
_Elem* basic_filebuf< _Elem, _Traits >::_Set_egptr
private
template<class _Elem, class _Traits>
_Traits::state_type basic_filebuf< _Elem, _Traits >::_State
private
template<class _Elem, class _Traits>
bool basic_filebuf< _Elem, _Traits >::_Wrotesome
private

The documentation for this class was generated from the following file: