1 : // xiosbase internal header (from <ios>)
2 : #pragma once
3 : #ifndef _XIOSBASE_
4 : #define _XIOSBASE_
5 : #ifndef RC_INVOKED
6 : #include <xlocale>
7 : #include <share.h>
8 :
9 : #ifdef _MSC_VER
10 : #pragma pack(push,_CRT_PACKING)
11 : #pragma warning(push,3)
12 : #pragma warning(disable:4412)
13 : #endif /* _MSC_VER */
14 :
15 : _STD_BEGIN
16 :
17 : #define _IOSskipws 0x0001
18 : #define _IOSunitbuf 0x0002
19 : #define _IOSuppercase 0x0004
20 : #define _IOSshowbase 0x0008
21 : #define _IOSshowpoint 0x0010
22 : #define _IOSshowpos 0x0020
23 : #define _IOSleft 0x0040
24 : #define _IOSright 0x0080
25 : #define _IOSinternal 0x0100
26 : #define _IOSdec 0x0200
27 : #define _IOSoct 0x0400
28 : #define _IOShex 0x0800
29 : #define _IOSscientific 0x1000
30 : #define _IOSfixed 0x2000
31 :
32 : #define _IOShexfloat 0x3000 // added with TR1/
33 :
34 : #define _IOSboolalpha 0x4000
35 : #define _IOS_Stdio 0x8000
36 :
37 : #define _IOS_Nocreate 0x40
38 : #define _IOS_Noreplace 0x80
39 : #define _IOSbinary 0x20
40 :
41 : // TEMPLATE CLASS _Iosb
42 : template<class _Dummy>
43 : class _Iosb
44 : { // define templatized bitmask/enumerated types, instantiate on demand
45 : public:
46 : enum _Dummy_enum {_Dummy_enum_val = 1}; // don't ask
47 :
48 : enum _Fmtflags
49 : { // constants for formatting options
50 : _Fmtmask = 0xffff, _Fmtzero = 0};
51 :
52 : static const _Fmtflags skipws = (_Fmtflags)_IOSskipws;
53 : static const _Fmtflags unitbuf = (_Fmtflags)_IOSunitbuf;
54 : static const _Fmtflags uppercase = (_Fmtflags)_IOSuppercase;
55 : static const _Fmtflags showbase = (_Fmtflags)_IOSshowbase;
56 : static const _Fmtflags showpoint = (_Fmtflags)_IOSshowpoint;
57 : static const _Fmtflags showpos = (_Fmtflags)_IOSshowpos;
58 : static const _Fmtflags left = (_Fmtflags)_IOSleft;
59 : static const _Fmtflags right = (_Fmtflags)_IOSright;
60 : static const _Fmtflags internal = (_Fmtflags)_IOSinternal;
61 : static const _Fmtflags dec = (_Fmtflags)_IOSdec;
62 : static const _Fmtflags oct = (_Fmtflags)_IOSoct;
63 : static const _Fmtflags hex = (_Fmtflags)_IOShex;
64 : static const _Fmtflags scientific = (_Fmtflags)_IOSscientific;
65 : static const _Fmtflags fixed = (_Fmtflags)_IOSfixed;
66 :
67 : static const _Fmtflags hexfloat =
68 : (_Fmtflags)_IOShexfloat; // added with TR1/
69 :
70 : static const _Fmtflags boolalpha = (_Fmtflags)_IOSboolalpha;
71 : static const _Fmtflags _Stdio = (_Fmtflags)_IOS_Stdio;
72 : static const _Fmtflags adjustfield = (_Fmtflags)(_IOSleft
73 : | _IOSright | _IOSinternal);
74 : static const _Fmtflags basefield = (_Fmtflags)(_IOSdec
75 : | _IOSoct | _IOShex);
76 : static const _Fmtflags floatfield = (_Fmtflags)(_IOSscientific
77 : | _IOSfixed);
78 :
79 : enum _Iostate
80 : { // constants for stream states
81 : _Statmask = 0x17};
82 :
83 : static const _Iostate goodbit = (_Iostate)0x0;
84 : static const _Iostate eofbit = (_Iostate)0x1;
85 : static const _Iostate failbit = (_Iostate)0x2;
86 : static const _Iostate badbit = (_Iostate)0x4;
87 : static const _Iostate _Hardfail = (_Iostate)0x10;
88 :
89 : enum _Openmode
90 : { // constants for file opening options
91 : _Openmask = 0xff};
92 :
93 : static const _Openmode in = (_Openmode)0x01;
94 : static const _Openmode out = (_Openmode)0x02;
95 : static const _Openmode ate = (_Openmode)0x04;
96 : static const _Openmode app = (_Openmode)0x08;
97 : static const _Openmode trunc = (_Openmode)0x10;
98 : static const _Openmode _Nocreate = (_Openmode)_IOS_Nocreate;
99 : static const _Openmode _Noreplace = (_Openmode)_IOS_Noreplace;
100 : static const _Openmode binary = (_Openmode)_IOSbinary;
101 :
102 : enum _Seekdir
103 : { // constants for file positioning options
104 : _Seekmask = 0x3};
105 : static const _Seekdir beg = (_Seekdir)0;
106 : static const _Seekdir cur = (_Seekdir)1;
107 : static const _Seekdir end = (_Seekdir)2;
108 :
109 : enum
110 : { // constant for default file opening protection
111 : _Openprot = _SH_DENYNO};
112 : };
113 :
114 : template<class _Dummy>
115 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::skipws;
116 : template<class _Dummy>
117 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::unitbuf;
118 : template<class _Dummy>
119 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::uppercase;
120 : template<class _Dummy>
121 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::showbase;
122 : template<class _Dummy>
123 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::showpoint;
124 : template<class _Dummy>
125 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::showpos;
126 : template<class _Dummy>
127 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::left;
128 : template<class _Dummy>
129 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::right;
130 : template<class _Dummy>
131 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::internal;
132 : template<class _Dummy>
133 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::dec;
134 : template<class _Dummy>
135 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::oct;
136 : template<class _Dummy>
137 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::hex;
138 : template<class _Dummy>
139 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::scientific;
140 : template<class _Dummy>
141 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::fixed;
142 :
143 : template<class _Dummy>
144 : const typename _Iosb<_Dummy>::_Fmtflags
145 : _Iosb<_Dummy>::hexfloat; // added with TR1
146 :
147 : template<class _Dummy>
148 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::boolalpha;
149 : template<class _Dummy>
150 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::_Stdio;
151 : template<class _Dummy>
152 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::adjustfield;
153 : template<class _Dummy>
154 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::basefield;
155 : template<class _Dummy>
156 : const typename _Iosb<_Dummy>::_Fmtflags _Iosb<_Dummy>::floatfield;
157 :
158 : template<class _Dummy>
159 : const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::goodbit;
160 : template<class _Dummy>
161 : const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::eofbit;
162 : template<class _Dummy>
163 : const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::failbit;
164 : template<class _Dummy>
165 : const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::badbit;
166 : template<class _Dummy>
167 : const typename _Iosb<_Dummy>::_Iostate _Iosb<_Dummy>::_Hardfail;
168 :
169 : template<class _Dummy>
170 : const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::in;
171 : template<class _Dummy>
172 : const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::out;
173 : template<class _Dummy>
174 : const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::ate;
175 : template<class _Dummy>
176 : const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::app;
177 : template<class _Dummy>
178 : const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::trunc;
179 : template<class _Dummy>
180 : const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::_Nocreate;
181 : template<class _Dummy>
182 : const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::_Noreplace;
183 : template<class _Dummy>
184 : const typename _Iosb<_Dummy>::_Openmode _Iosb<_Dummy>::binary;
185 :
186 : template<class _Dummy>
187 : const typename _Iosb<_Dummy>::_Seekdir _Iosb<_Dummy>::beg;
188 : template<class _Dummy>
189 : const typename _Iosb<_Dummy>::_Seekdir _Iosb<_Dummy>::cur;
190 : template<class _Dummy>
191 : const typename _Iosb<_Dummy>::_Seekdir _Iosb<_Dummy>::end;
192 :
193 : // CLASS ios_base
194 : class _CRTIMP2_PURE ios_base
195 : : public _Iosb<int>
196 : { // base class for ios
197 : public:
198 : _BITMASK(_Fmtflags, fmtflags);
199 : _BITMASK(_Iostate, iostate);
200 : _BITMASK(_Openmode, openmode);
201 : _BITMASK(_Seekdir, seekdir);
202 :
203 : typedef std::streamoff streamoff;
204 : typedef std::streampos streampos;
205 :
206 : enum event
207 : { // constants for ios events
208 : erase_event, imbue_event, copyfmt_event};
209 :
210 : typedef void (__CLRCALL_OR_CDECL *event_callback)(event, ios_base&, int);
211 : typedef unsigned int io_state, open_mode, seek_dir;
212 :
213 : // CLASS failure
214 : class failure
215 : : public runtime_error
216 : { // base of all iostreams exceptions
217 : public:
218 : explicit __CLR_OR_THIS_CALL failure(const string &_Message)
219 : : runtime_error(_Message)
220 0 : { // construct with message
221 0 : }
222 :
223 : virtual __CLR_OR_THIS_CALL ~failure() _THROW0()
224 0 : { // destroy the object
225 0 : }
226 :
227 : #if !_HAS_EXCEPTIONS
228 :
229 : protected:
230 : virtual void __CLR_OR_THIS_CALL _Doraise() const
231 : { // report the exception
232 : _RAISE(*this);
233 : }
234 : #endif /* _HAS_EXCEPTIONS */
235 :
236 : };
237 :
238 : // CLASS Init
239 : class _CRTIMP2_PURE Init
240 : { // controller for standard-stream initialization
241 : public:
242 : __CLR_OR_THIS_CALL Init()
243 : {
244 : _Init_ctor(this);
245 : }
246 :
247 : __CLR_OR_THIS_CALL ~Init()
248 : {
249 : _Init_dtor(this);
250 : }
251 :
252 : private:
253 : static _MRTIMP2_NPURE void __cdecl _Init_ctor(Init *);
254 : static _MRTIMP2_NPURE void __cdecl _Init_dtor(Init *);
255 :
256 : _MRTIMP2_NPURE static int& __cdecl _Init_cnt_func(); // net constructions - destructions
257 : #ifdef _M_CEE_PURE
258 : static int& _Init_cnt; // net constructions - destructions
259 : #else
260 : __PURE_APPDOMAIN_GLOBAL static int _Init_cnt; // net constructions - destructions
261 : #endif
262 : };
263 :
264 : ios_base& __CLR_OR_THIS_CALL operator=(const ios_base& _Right)
265 : { // assign state and format stuff from _Right
266 : if (this != &_Right)
267 : { // worth doing
268 : _Mystate = _Right._Mystate;
269 : copyfmt(_Right);
270 : }
271 : return (*this);
272 : }
273 :
274 : __CLR_OR_THIS_CALL operator void *() const
275 : { // test if any stream operation has failed
276 : return (fail() ? 0 : (void *)this);
277 : }
278 :
279 : bool __CLR_OR_THIS_CALL operator!() const
280 : { // test if no stream operation has failed
281 : return (fail());
282 : }
283 :
284 : void __CLR_OR_THIS_CALL clear(iostate _State, bool _Reraise)
285 10 : { // set state, possibly reraise exception
286 10 : _Mystate = (iostate)(_State & _Statmask);
287 10 : if ((_Mystate & _Except) == 0)
288 : ;
289 0 : else if (_Reraise)
290 0 : _RERAISE;
291 0 : else if (_Mystate & _Except & badbit)
292 0 : _THROW_NCEE(failure, "ios_base::badbit set");
293 0 : else if (_Mystate & _Except & failbit)
294 0 : _THROW_NCEE(failure, "ios_base::failbit set");
295 0 : else
296 0 : _THROW_NCEE(failure, "ios_base::eofbit set");
297 10 : }
298 :
299 : void __CLR_OR_THIS_CALL clear(iostate _State = goodbit)
300 10 : { // set state to argument
301 10 : clear(_State, false);
302 10 : }
303 :
304 : void __CLR_OR_THIS_CALL clear(io_state _State)
305 : { // set state to argument, old-style
306 : clear((iostate)_State);
307 : }
308 :
309 : iostate __CLR_OR_THIS_CALL rdstate() const
310 10 : { // return stream state
311 10 : return (_Mystate);
312 10 : }
313 :
314 :
315 : void __CLR_OR_THIS_CALL setstate(iostate _State, bool _Exreraise)
316 : { // merge in state argument, possibly reraise exception
317 : if (_State != goodbit)
318 : clear((iostate)((int)rdstate() | (int)_State), _Exreraise);
319 : }
320 :
321 : void __CLR_OR_THIS_CALL setstate(iostate _State)
322 : { // merge in state argument
323 : if (_State != goodbit)
324 : clear((iostate)((int)rdstate() | (int)_State), false);
325 : }
326 :
327 : void __CLR_OR_THIS_CALL setstate(io_state _State)
328 : { // merge in state argument, old style
329 : setstate((iostate)_State);
330 : }
331 :
332 : bool __CLR_OR_THIS_CALL good() const
333 10 : { // test if no state bits are set
334 10 : return (rdstate() == goodbit);
335 10 : }
336 :
337 : bool __CLR_OR_THIS_CALL eof() const
338 : { // test if eofbit is set in stream state
339 : return ((int)rdstate() & (int)eofbit);
340 : }
341 :
342 : bool __CLR_OR_THIS_CALL fail() const
343 0 : { // test if badbit or failbit is set in stream state
344 : return (((int)rdstate()
345 0 : & ((int)badbit | (int)failbit)) != 0);
346 0 : }
347 :
348 : bool __CLR_OR_THIS_CALL bad() const
349 : { // test if badbit is set in stream state
350 : return (((int)rdstate() & (int)badbit) != 0);
351 : }
352 :
353 : // This method is not used in msvcm80.dll, so we do not need to compile it.
354 : // Also, if we never change the exception mask, we ensure the clear() method
355 : // will never throw any exception. See VSW#476338 for details.
356 : iostate __CLR_OR_THIS_CALL exceptions() const
357 : { // return exception mask
358 : return (_Except);
359 : }
360 :
361 : void __CLR_OR_THIS_CALL exceptions(iostate _Newexcept)
362 : { // set exception mask to argument
363 : _Except = (iostate)((int)_Newexcept & (int)_Statmask);
364 : clear(_Mystate);
365 : }
366 :
367 : void __CLR_OR_THIS_CALL exceptions(io_state _State)
368 : { // set exception mask to argument, old style
369 : exceptions((iostate)_State);
370 : }
371 :
372 : fmtflags __CLR_OR_THIS_CALL flags() const
373 10 : { // return format flags
374 10 : return (_Fmtfl);
375 10 : }
376 :
377 : fmtflags __CLR_OR_THIS_CALL flags(fmtflags _Newfmtflags)
378 : { // set format flags to argument
379 : fmtflags _Oldfmtflags = _Fmtfl;
380 : _Fmtfl = (fmtflags)((int)_Newfmtflags & (int)_Fmtmask);
381 : return (_Oldfmtflags);
382 : }
383 :
384 : fmtflags __CLR_OR_THIS_CALL setf(fmtflags _Newfmtflags)
385 9 : { // merge in format flags argument
386 9 : ios_base::fmtflags _Oldfmtflags = _Fmtfl;
387 : _Fmtfl = (fmtflags)((int)_Fmtfl
388 9 : | (int)_Newfmtflags & (int)_Fmtmask);
389 9 : return (_Oldfmtflags);
390 9 : }
391 :
392 : fmtflags __CLR_OR_THIS_CALL setf(fmtflags _Newfmtflags, fmtflags _Mask)
393 0 : { // merge in format flags argument under mask argument
394 0 : ios_base::fmtflags _Oldfmtflags = _Fmtfl;
395 : _Fmtfl = (fmtflags)(((int)_Fmtfl & (int)~_Mask)
396 0 : | ((int)_Newfmtflags & (int)_Mask & (int)_Fmtmask));
397 0 : return (_Oldfmtflags);
398 0 : }
399 :
400 : void __CLR_OR_THIS_CALL unsetf(fmtflags _Mask)
401 : { // clear format flags under mask argument
402 : _Fmtfl = (fmtflags)((int)_Fmtfl & (int)~_Mask);
403 : }
404 :
405 : streamsize __CLR_OR_THIS_CALL precision() const
406 3 : { // return precision
407 3 : return (_Prec);
408 3 : }
409 :
410 : streamsize __CLR_OR_THIS_CALL precision(streamsize _Newprecision)
411 : { // set precision to argument
412 : streamsize _Oldprecision = _Prec;
413 : _Prec = _Newprecision;
414 : return (_Oldprecision);
415 : }
416 :
417 : streamsize __CLR_OR_THIS_CALL width() const
418 10 : { // return width
419 10 : return (_Wide);
420 10 : }
421 :
422 : streamsize __CLR_OR_THIS_CALL width(streamsize _Newwidth)
423 10 : { // set width to argument
424 10 : streamsize _Oldwidth = _Wide;
425 10 : _Wide = _Newwidth;
426 10 : return (_Oldwidth);
427 10 : }
428 :
429 : locale __CLR_OR_THIS_CALL getloc() const
430 10 : { // get locale
431 10 : return (*_Ploc);
432 10 : }
433 :
434 : locale __CLR_OR_THIS_CALL imbue(const locale& _Loc)
435 : { // set locale to argument
436 : locale _Oldlocale = *_Ploc;
437 : *_Ploc = _Loc;
438 : _Callfns(imbue_event);
439 : return (_Oldlocale);
440 : }
441 :
442 : static int __CLRCALL_OR_CDECL xalloc()
443 : { // allocate new iword/pword index
444 : _BEGIN_LOCK(_LOCK_STREAM) // lock thread to ensure atomicity
445 : return (_Index++);
446 : _END_LOCK()
447 : }
448 :
449 : long& __CLR_OR_THIS_CALL iword(int _Idx)
450 : { // return reference to long element
451 : return (_Findarr(_Idx)._Lo);
452 : }
453 :
454 : void *& __CLR_OR_THIS_CALL pword(int _Idx)
455 : { // return reference to pointer element
456 : return (_Findarr(_Idx)._Vp);
457 : }
458 :
459 : void __CLR_OR_THIS_CALL register_callback(event_callback _Pfn, int _Idx)
460 : { // register event handler
461 : _Calls = _NEW_CRT _Fnarray(_Idx, _Pfn, _Calls);
462 : }
463 :
464 : ios_base& __CLR_OR_THIS_CALL copyfmt(const ios_base& _Other)
465 : { // copy format stuff
466 : if (this != &_Other)
467 : { // copy all but _Mystate
468 : _Tidy();
469 : *_Ploc = *_Other._Ploc;
470 : _Fmtfl = _Other._Fmtfl;
471 : _Prec = _Other._Prec;
472 : _Wide = _Other._Wide;
473 : _Iosarray *_Ptr = _Other._Arr;
474 :
475 : for (_Arr = 0; _Ptr != 0; _Ptr = _Ptr->_Next)
476 : if (_Ptr->_Lo != 0 || _Ptr->_Vp != 0)
477 : { // copy over nonzero array values
478 : iword(_Ptr->_Index) = _Ptr->_Lo;
479 : pword(_Ptr->_Index) = _Ptr->_Vp;
480 : }
481 :
482 : for (_Fnarray *_Q = _Other._Calls; _Q != 0; _Q = _Q->_Next)
483 : register_callback(_Q->_Pfn, _Q->_Index); // copy callbacks
484 :
485 : _Callfns(copyfmt_event); // call callbacks
486 : exceptions(_Other._Except); // cause any throw at end
487 : }
488 : return (*this);
489 : }
490 :
491 :
492 : virtual __CLR_OR_THIS_CALL ~ios_base()
493 10 : {
494 10 : _Ios_base_dtor(this);
495 10 : }
496 :
497 : static bool __CLRCALL_OR_CDECL sync_with_stdio(bool _Newsync = true)
498 : { // set C/C++ synchronization flag from argument
499 : _BEGIN_LOCK(_LOCK_STREAM) // lock thread to ensure atomicity
500 : const bool _Oldsync = _Sync;
501 : _Sync = _Newsync;
502 : return (_Oldsync);
503 : _END_LOCK()
504 : }
505 :
506 : static _MRTIMP2_NPURE void __cdecl _Addstd(ios_base *);
507 : size_t _Stdstr; // if > 0 index of standard stream to suppress destruction
508 :
509 : protected:
510 10 : __CLR_OR_THIS_CALL ios_base()
511 : { // default constructor
512 10 : }
513 :
514 : void __CLR_OR_THIS_CALL _Init()
515 10 : { // initialize a new ios_base
516 10 : _Ploc = 0;
517 10 : _Stdstr = 0;
518 10 : _Except = goodbit;
519 10 : _Fmtfl = skipws | dec;
520 10 : _Prec = 6;
521 10 : _Wide = 0;
522 10 : _Arr = 0;
523 10 : _Calls = 0;
524 10 : clear(goodbit);
525 10 : _Ploc = _NEW_CRT locale;
526 10 : }
527 :
528 : private:
529 : // STRUCT _Iosarray
530 : struct _Iosarray
531 : { // list element for open-ended sparse array of longs/pointers
532 : public:
533 : __CLR_OR_THIS_CALL _Iosarray(int _Idx, _Iosarray *_Link)
534 : : _Next(_Link), _Index(_Idx), _Lo(0), _Vp(0)
535 : { // construct node for index _Idx and link it in
536 : }
537 :
538 : _Iosarray *_Next; // pointer to next node
539 : int _Index; // index of this node
540 : long _Lo; // stored long value
541 : void *_Vp; // stored pointer value
542 : };
543 :
544 : // STRUCT _Fnarray
545 : struct _Fnarray
546 : { // list element for open-ended sparse array of event handlers
547 : __CLR_OR_THIS_CALL _Fnarray(int _Idx, event_callback _Pnew, _Fnarray *_Link)
548 : : _Next(_Link), _Index(_Idx), _Pfn(_Pnew)
549 : { // construct node for index _Idx and link it in
550 : }
551 :
552 : _Fnarray *_Next; // pointer to next node
553 : int _Index; // index of this node
554 : event_callback _Pfn; // pointer to event handler
555 : };
556 :
557 : void __CLR_OR_THIS_CALL _Callfns(event _Ev)
558 : { // call all event handlers, reporting event
559 : for (_Fnarray *_Ptr = _Calls; _Ptr != 0; _Ptr = _Ptr->_Next)
560 : (*_Ptr->_Pfn)(_Ev, *this, _Ptr->_Index);
561 : }
562 :
563 : _Iosarray& __CLR_OR_THIS_CALL _Findarr(int _Idx)
564 : { // locate or make a variable array element
565 : _Iosarray *_Ptr, *_Q;
566 :
567 : for (_Ptr = _Arr, _Q = 0; _Ptr != 0; _Ptr = _Ptr->_Next)
568 : if (_Ptr->_Index == _Idx)
569 : return (*_Ptr); // found element, return it
570 : else if (_Q == 0 && _Ptr->_Lo == 0 && _Ptr->_Vp == 0)
571 : _Q = _Ptr; // found recycling candidate
572 :
573 : if (_Q != 0)
574 : { // recycle existing element
575 : _Q->_Index = _Idx;
576 : return (*_Q);
577 : }
578 :
579 : _Arr = _NEW_CRT _Iosarray(_Idx, _Arr); // make a new element
580 : return (*_Arr);
581 : }
582 :
583 : void __CLRCALL_OR_CDECL _Tidy()
584 : { // discard storage for an ios_base
585 : _Callfns(erase_event);
586 : _Iosarray *_Q1, *_Q2;
587 :
588 : for (_Q1 = _Arr; _Q1 != 0; _Q1 = _Q2)
589 : _Q2 = _Q1->_Next, _DELETE_CRT(_Q1); // delete array elements
590 : _Arr = 0;
591 :
592 : _Fnarray *_Q3, *_Q4;
593 : for (_Q3 = _Calls; _Q3 != 0; _Q3 = _Q4)
594 : _Q4 = _Q3->_Next, _DELETE_CRT(_Q3); // delete callback elements
595 : _Calls = 0;
596 : }
597 :
598 : static _MRTIMP2_NPURE void __cdecl _Ios_base_dtor(ios_base *);
599 :
600 : iostate _Mystate; // stream state
601 : iostate _Except; // exception mask
602 : fmtflags _Fmtfl; // format flags
603 : streamsize _Prec; // field precision
604 : streamsize _Wide; // field width
605 : _Iosarray *_Arr; // pointer to first node of long/pointer array
606 : _Fnarray *_Calls; // pointer to first node of call list
607 : locale *_Ploc; // pointer to locale
608 :
609 : #if defined(_M_CEE_PURE)
610 : static int& _Index; // source of unique indexes for long/pointer array
611 : static bool& _Sync; // C/C++ synchronization flag (ignored)
612 : #else
613 : __PURE_APPDOMAIN_GLOBAL static int _Index; // source of unique indexes for long/pointer array
614 : __PURE_APPDOMAIN_GLOBAL static bool _Sync; // C/C++ synchronization flag (ignored)
615 : #endif
616 : static _MRTIMP2_NPURE int& __cdecl _Index_func();
617 : static _MRTIMP2_NPURE bool& __cdecl _Sync_func();
618 : };
619 :
620 : _BITMASK_OPS(ios_base::_Fmtflags)
621 : _BITMASK_OPS(ios_base::_Iostate)
622 : _BITMASK_OPS(ios_base::_Openmode)
623 : _BITMASK_OPS(ios_base::_Seekdir)
624 : _STD_END
625 : #ifdef _MSC_VER
626 : #pragma warning(pop)
627 : #pragma pack(pop)
628 : #endif /* _MSC_VER */
629 :
630 : #endif /* RC_INVOKED */
631 : #endif /* _XIOSBASE_ */
632 :
633 : /*
634 : * Copyright (c) 1992-2006 by P.J. Plauger. ALL RIGHTS RESERVED.
635 : * Consult your license regarding permissions and restrictions.
636 : V5.02:0009 */
|