1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
// First, the basic_filebuf constructor is called (with _File = 0, so no file associated)
basic_filebuf(_Filet *_File = 0)
: _Mysb()
{ // construct from pointer to C stream
_Init(_File, _Newfl);
}
// Second, the base classs constructor (basic_streambuf) is called
__CLR_OR_THIS_CALL basic_streambuf()
: _Plocale(_NEW_CRT locale)
{ // construct with no buffers
_Init();
}
// Third, the _Init() method is called (which not set any buffers)
void __CLR_OR_THIS_CALL _Init()
{ // initialize buffer parameters for no buffers
_IGfirst = &_Gfirst;
_IPfirst = &_Pfirst;
_IGnext = &_Gnext;
_IPnext = &_Pnext;
_IGcount = &_Gcount;
_IPcount = &_Pcount;
setp(0, 0);
setg(0, 0, 0);
}
// Fourth, the second _Init() method is called (with _File = 0 again)
void _Init(_Filet *_File, _Initfl _Which)
{ // initialize to C stream _File after {new, open, close}
__PURE_APPDOMAIN_GLOBAL static _Myst _Stinit; // initial state
_Closef = _Which == _Openfl;
_Wrotesome = false;
_Mysb::_Init(); // initialize stream buffer base object
#ifndef _IORCNT
#define _IORCNT _IOCNT /* read and write counts are the same */
#define _IOWCNT _IOCNT
#endif /* _IORCNT */
#pragma warning(push)
#pragma warning(disable: 6240) /* prefast noise VSW 489858 */
if (_File != 0 && sizeof (_Elem) == 1)
#pragma warning(pop)
{ // point inside C stream with [first, first + count) buffer
_Elem **_Pb = (_Elem **)&_File->_IOBASE;
_Elem **_Pn = (_Elem **)&_File->_IOPTR;
int *_Nr = (int *)&_File->_IORCNT;
int *_Nw = (int *)&_File->_IOWCNT;
_Mysb::_Init(_Pb, _Pn, _Nr, _Pb, _Pn, _Nw);
}
_Myfile = _File;
_State = _Stinit;
_Pcvt = 0; // pointer to codecvt facet
}
|