2 * Copyright (C) 2007 Alexandre Julliard
3 * Copyright (C) 2015-2016 Iván Matellanes
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msvcirt
);
38 #define RESERVE_SIZE 512
39 #define STATEBUF_SIZE 8
41 /* ?sh_none@filebuf@@2HB */
42 const int filebuf_sh_none
= 0x800;
43 /* ?sh_read@filebuf@@2HB */
44 const int filebuf_sh_read
= 0xa00;
45 /* ?sh_write@filebuf@@2HB */
46 const int filebuf_sh_write
= 0xc00;
47 /* ?openprot@filebuf@@2HB */
48 const int filebuf_openprot
= 420;
49 /* ?binary@filebuf@@2HB */
50 const int filebuf_binary
= _O_BINARY
;
51 /* ?text@filebuf@@2HB */
52 const int filebuf_text
= _O_TEXT
;
54 /* ?adjustfield@ios@@2JB */
55 const LONG ios_adjustfield
= FLAGS_left
| FLAGS_right
| FLAGS_internal
;
56 /* ?basefield@ios@@2JB */
57 const LONG ios_basefield
= FLAGS_dec
| FLAGS_oct
| FLAGS_hex
;
58 /* ?floatfield@ios@@2JB */
59 const LONG ios_floatfield
= FLAGS_scientific
| FLAGS_fixed
;
60 /* ?fLockcInit@ios@@0HA */
61 int ios_fLockcInit
= 0;
62 /* ?sunk_with_stdio@ios@@0HA */
63 int ios_sunk_with_stdio
= 0;
64 /* ?x_lockc@ios@@0U_CRT_CRITICAL_SECTION@@A */
65 extern CRITICAL_SECTION ios_static_lock
;
66 CRITICAL_SECTION_DEBUG ios_static_lock_debug
=
68 0, 0, &ios_static_lock
,
69 { &ios_static_lock_debug
.ProcessLocksList
, &ios_static_lock_debug
.ProcessLocksList
},
70 0, 0, { (DWORD_PTR
)(__FILE__
": ios_static_lock") }
72 CRITICAL_SECTION ios_static_lock
= { &ios_static_lock_debug
, -1, 0, 0, 0, 0 };
73 /* ?x_maxbit@ios@@0JA */
74 LONG ios_maxbit
= 0x8000;
75 /* ?x_curindex@ios@@0HA */
76 int ios_curindex
= -1;
77 /* ?x_statebuf@ios@@0PAJA */
78 LONG ios_statebuf
[STATEBUF_SIZE
] = {0};
82 const vtable_ptr
*vtable
;
95 CRITICAL_SECTION lock
;
98 void __thiscall
streambuf_setb(streambuf
*, char*, char*, int);
99 streambuf
* __thiscall
streambuf_setbuf(streambuf
*, char*, int);
100 void __thiscall
streambuf_setg(streambuf
*, char*, char*, char*);
101 void __thiscall
streambuf_setp(streambuf
*, char*, char*);
110 filebuf
* __thiscall
filebuf_close(filebuf
*);
112 /* class strstreambuf */
119 allocFunction f_alloc
;
132 const vtable_ptr
*vtable
;
137 struct _ostream
*tie
;
143 CRITICAL_SECTION lock
;
146 ios
* __thiscall
ios_assign(ios
*, const ios
*);
147 int __thiscall
ios_fail(const ios
*);
148 void __cdecl
ios_lock(ios
*);
149 void __cdecl
ios_lockc(void);
150 LONG __thiscall
ios_setf_mask(ios
*, LONG
, LONG
);
151 void __cdecl
ios_unlock(ios
*);
152 void __cdecl
ios_unlockc(void);
155 typedef struct _ostream
{
173 /* ??_7streambuf@@6B@ */
174 extern const vtable_ptr streambuf_vtable
;
175 /* ??_7filebuf@@6B@ */
176 extern const vtable_ptr filebuf_vtable
;
177 /* ??_7strstreambuf@@6B@ */
178 extern const vtable_ptr strstreambuf_vtable
;
179 /* ??_7stdiobuf@@6B@ */
180 extern const vtable_ptr stdiobuf_vtable
;
182 extern const vtable_ptr ios_vtable
;
183 /* ??_7ostream@@6B@ */
184 extern const vtable_ptr ostream_vtable
;
185 /* ??_7ostream_withassign@@6B@ */
186 extern const vtable_ptr ostream_withassign_vtable
;
187 /* ??_7ostrstream@@6B@ */
188 extern const vtable_ptr ostrstream_vtable
;
189 /* ??_7ofstream@@6B@ */
190 extern const vtable_ptr ofstream_vtable
;
191 /* ??_7istream@@6B@ */
192 extern const vtable_ptr istream_vtable
;
193 /* ??_7istream_withassign@@6B@ */
194 extern const vtable_ptr istream_withassign_vtable
;
195 /* ??_7istrstream@@6B@ */
196 extern const vtable_ptr istrstream_vtable
;
197 /* ??_7ifstream@@6B@ */
198 extern const vtable_ptr ifstream_vtable
;
199 /* ??_7iostream@@6B@ */
200 extern const vtable_ptr iostream_vtable
;
201 /* ??_7strstream@@6B@ */
202 extern const vtable_ptr strstream_vtable
;
203 /* ??_7stdiostream@@6B@ */
204 extern const vtable_ptr stdiostream_vtable
;
205 /* ??_7fstream@@6B@ */
206 extern const vtable_ptr fstream_vtable
;
208 __ASM_BLOCK_BEGIN(vtables
)
209 __ASM_VTABLE(streambuf
,
210 VTABLE_ADD_FUNC(streambuf_vector_dtor
)
211 VTABLE_ADD_FUNC(streambuf_sync
)
212 VTABLE_ADD_FUNC(streambuf_setbuf
)
213 VTABLE_ADD_FUNC(streambuf_seekoff
)
214 VTABLE_ADD_FUNC(streambuf_seekpos
)
215 VTABLE_ADD_FUNC(streambuf_xsputn
)
216 VTABLE_ADD_FUNC(streambuf_xsgetn
)
217 VTABLE_ADD_FUNC(streambuf_overflow
)
218 VTABLE_ADD_FUNC(streambuf_underflow
)
219 VTABLE_ADD_FUNC(streambuf_pbackfail
)
220 VTABLE_ADD_FUNC(streambuf_doallocate
));
221 __ASM_VTABLE(filebuf
,
222 VTABLE_ADD_FUNC(filebuf_vector_dtor
)
223 VTABLE_ADD_FUNC(filebuf_sync
)
224 VTABLE_ADD_FUNC(filebuf_setbuf
)
225 VTABLE_ADD_FUNC(filebuf_seekoff
)
226 VTABLE_ADD_FUNC(streambuf_seekpos
)
227 VTABLE_ADD_FUNC(streambuf_xsputn
)
228 VTABLE_ADD_FUNC(streambuf_xsgetn
)
229 VTABLE_ADD_FUNC(filebuf_overflow
)
230 VTABLE_ADD_FUNC(filebuf_underflow
)
231 VTABLE_ADD_FUNC(streambuf_pbackfail
)
232 VTABLE_ADD_FUNC(streambuf_doallocate
));
233 __ASM_VTABLE(strstreambuf
,
234 VTABLE_ADD_FUNC(strstreambuf_vector_dtor
)
235 VTABLE_ADD_FUNC(strstreambuf_sync
)
236 VTABLE_ADD_FUNC(strstreambuf_setbuf
)
237 VTABLE_ADD_FUNC(strstreambuf_seekoff
)
238 VTABLE_ADD_FUNC(streambuf_seekpos
)
239 VTABLE_ADD_FUNC(streambuf_xsputn
)
240 VTABLE_ADD_FUNC(streambuf_xsgetn
)
241 VTABLE_ADD_FUNC(strstreambuf_overflow
)
242 VTABLE_ADD_FUNC(strstreambuf_underflow
)
243 VTABLE_ADD_FUNC(streambuf_pbackfail
)
244 VTABLE_ADD_FUNC(strstreambuf_doallocate
));
245 __ASM_VTABLE(stdiobuf
,
246 VTABLE_ADD_FUNC(stdiobuf_vector_dtor
)
247 VTABLE_ADD_FUNC(stdiobuf_sync
)
248 VTABLE_ADD_FUNC(streambuf_setbuf
)
249 VTABLE_ADD_FUNC(stdiobuf_seekoff
)
250 VTABLE_ADD_FUNC(streambuf_seekpos
)
251 VTABLE_ADD_FUNC(streambuf_xsputn
)
252 VTABLE_ADD_FUNC(streambuf_xsgetn
)
253 VTABLE_ADD_FUNC(stdiobuf_overflow
)
254 VTABLE_ADD_FUNC(stdiobuf_underflow
)
255 VTABLE_ADD_FUNC(stdiobuf_pbackfail
)
256 VTABLE_ADD_FUNC(streambuf_doallocate
));
258 VTABLE_ADD_FUNC(ios_vector_dtor
));
259 __ASM_VTABLE(ostream
,
260 VTABLE_ADD_FUNC(ostream_vector_dtor
));
261 __ASM_VTABLE(ostream_withassign
,
262 VTABLE_ADD_FUNC(ostream_vector_dtor
));
263 __ASM_VTABLE(ostrstream
,
264 VTABLE_ADD_FUNC(ostream_vector_dtor
));
265 __ASM_VTABLE(ofstream
,
266 VTABLE_ADD_FUNC(ostream_vector_dtor
));
267 __ASM_VTABLE(istream
,
268 VTABLE_ADD_FUNC(istream_vector_dtor
));
269 __ASM_VTABLE(istream_withassign
,
270 VTABLE_ADD_FUNC(istream_vector_dtor
));
271 __ASM_VTABLE(istrstream
,
272 VTABLE_ADD_FUNC(istream_vector_dtor
));
273 __ASM_VTABLE(ifstream
,
274 VTABLE_ADD_FUNC(istream_vector_dtor
));
275 __ASM_VTABLE(iostream
,
276 VTABLE_ADD_FUNC(iostream_vector_dtor
));
277 __ASM_VTABLE(strstream
,
278 VTABLE_ADD_FUNC(iostream_vector_dtor
));
279 __ASM_VTABLE(stdiostream
,
280 VTABLE_ADD_FUNC(iostream_vector_dtor
));
281 __ASM_VTABLE(fstream
,
282 VTABLE_ADD_FUNC(iostream_vector_dtor
));
285 #define ALIGNED_SIZE(size, alignment) (((size)+((alignment)-1))/(alignment)*(alignment))
286 #define VBTABLE_ENTRY(class, offset, vbase) ALIGNED_SIZE(sizeof(class), TYPE_ALIGNMENT(vbase))-offset
288 /* ??_8ostream@@7B@ */
289 /* ??_8ostream_withassign@@7B@ */
290 /* ??_8ostrstream@@7B@ */
291 /* ??_8ofstream@@7B@ */
292 const int ostream_vbtable
[] = {0, VBTABLE_ENTRY(ostream
, FIELD_OFFSET(ostream
, vbtable
), ios
)};
293 /* ??_8istream@@7B@ */
294 /* ??_8istream_withassign@@7B@ */
295 /* ??_8istrstream@@7B@ */
296 /* ??_8ifstream@@7B@ */
297 const int istream_vbtable
[] = {0, VBTABLE_ENTRY(istream
, FIELD_OFFSET(istream
, vbtable
), ios
)};
298 /* ??_8iostream@@7Bistream@@@ */
299 /* ??_8stdiostream@@7Bistream@@@ */
300 /* ??_8strstream@@7Bistream@@@ */
301 const int iostream_vbtable_istream
[] = {0, VBTABLE_ENTRY(iostream
, FIELD_OFFSET(iostream
, base1
), ios
)};
302 /* ??_8iostream@@7Bostream@@@ */
303 /* ??_8stdiostream@@7Bostream@@@ */
304 /* ??_8strstream@@7Bostream@@@ */
305 const int iostream_vbtable_ostream
[] = {0, VBTABLE_ENTRY(iostream
, FIELD_OFFSET(iostream
, base2
), ios
)};
307 DEFINE_RTTI_DATA0(streambuf
, 0, ".?AVstreambuf@@")
308 DEFINE_RTTI_DATA1(filebuf
, 0, &streambuf_rtti_base_descriptor
, ".?AVfilebuf@@")
309 DEFINE_RTTI_DATA1(strstreambuf
, 0, &streambuf_rtti_base_descriptor
, ".?AVstrstreambuf@@")
310 DEFINE_RTTI_DATA1(stdiobuf
, 0, &streambuf_rtti_base_descriptor
, ".?AVstdiobuf@@")
311 DEFINE_RTTI_DATA0(ios
, 0, ".?AVios@@")
312 DEFINE_RTTI_DATA1(ostream
, sizeof(ostream
), &ios_rtti_base_descriptor
, ".?AVostream@@")
313 DEFINE_RTTI_DATA2(ostream_withassign
, sizeof(ostream
),
314 &ostream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AVostream_withassign@@")
315 DEFINE_RTTI_DATA2(ostrstream
, sizeof(ostream
),
316 &ostream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AVostrstream@@")
317 DEFINE_RTTI_DATA2(ofstream
, sizeof(ostream
),
318 &ostream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AVofstream@@")
319 DEFINE_RTTI_DATA1(istream
, sizeof(istream
), &ios_rtti_base_descriptor
, ".?AVistream@@")
320 DEFINE_RTTI_DATA2(istream_withassign
, sizeof(istream
),
321 &istream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AVistream_withassign@@")
322 DEFINE_RTTI_DATA2(istrstream
, sizeof(istream
),
323 &istream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AVistrstream@@")
324 DEFINE_RTTI_DATA2(ifstream
, sizeof(istream
),
325 &istream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AVifstream@@")
326 DEFINE_RTTI_DATA4(iostream
, sizeof(iostream
),
327 &istream_rtti_base_descriptor
, &ios_rtti_base_descriptor
,
328 &ostream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AViostream@@")
329 DEFINE_RTTI_DATA5(strstream
, sizeof(iostream
), &iostream_rtti_base_descriptor
,
330 &istream_rtti_base_descriptor
, &ios_rtti_base_descriptor
,
331 &ostream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AVstrstream@@")
332 DEFINE_RTTI_DATA5(stdiostream
, sizeof(iostream
), &iostream_rtti_base_descriptor
,
333 &istream_rtti_base_descriptor
, &ios_rtti_base_descriptor
,
334 &ostream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AVstdiostream@@")
335 DEFINE_RTTI_DATA5(fstream
, sizeof(iostream
), &iostream_rtti_base_descriptor
,
336 &istream_rtti_base_descriptor
, &ios_rtti_base_descriptor
,
337 &ostream_rtti_base_descriptor
, &ios_rtti_base_descriptor
, ".?AVfstream@@")
339 /* ?cin@@3Vistream_withassign@@A */
345 /* ?cout@@3Vostream_withassign@@A */
346 /* ?cerr@@3Vostream_withassign@@A */
347 /* ?clog@@3Vostream_withassign@@A */
351 } cout
= { { 0 } }, cerr
= { { 0 } }, MSVCP_clog
= { { 0 } };
354 /* ??0streambuf@@IAE@PADH@Z */
355 /* ??0streambuf@@IEAA@PEADH@Z */
356 DEFINE_THISCALL_WRAPPER(streambuf_reserve_ctor
, 12)
357 streambuf
* __thiscall
streambuf_reserve_ctor(streambuf
*this, char *buffer
, int length
)
359 TRACE("(%p %p %d)\n", this, buffer
, length
);
360 this->vtable
= &streambuf_vtable
;
362 this->stored_char
= EOF
;
365 streambuf_setbuf(this, buffer
, length
);
366 streambuf_setg(this, NULL
, NULL
, NULL
);
367 streambuf_setp(this, NULL
, NULL
);
368 InitializeCriticalSection(&this->lock
);
372 /* ??0streambuf@@IAE@XZ */
373 /* ??0streambuf@@IEAA@XZ */
374 DEFINE_THISCALL_WRAPPER(streambuf_ctor
, 4)
375 streambuf
* __thiscall
streambuf_ctor(streambuf
*this)
377 streambuf_reserve_ctor(this, NULL
, 0);
378 this->unbuffered
= 0;
382 /* ??0streambuf@@QAE@ABV0@@Z */
383 /* ??0streambuf@@QEAA@AEBV0@@Z */
384 DEFINE_THISCALL_WRAPPER(streambuf_copy_ctor
, 8)
385 streambuf
* __thiscall
streambuf_copy_ctor(streambuf
*this, const streambuf
*copy
)
387 TRACE("(%p %p)\n", this, copy
);
389 this->vtable
= &streambuf_vtable
;
393 /* ??1streambuf@@UAE@XZ */
394 /* ??1streambuf@@UEAA@XZ */
395 DEFINE_THISCALL_WRAPPER(streambuf_dtor
, 4)
396 void __thiscall
streambuf_dtor(streambuf
*this)
398 TRACE("(%p)\n", this);
400 operator_delete(this->base
);
401 DeleteCriticalSection(&this->lock
);
404 /* ??4streambuf@@QAEAAV0@ABV0@@Z */
405 /* ??4streambuf@@QEAAAEAV0@AEBV0@@Z */
406 DEFINE_THISCALL_WRAPPER(streambuf_assign
, 8)
407 streambuf
* __thiscall
streambuf_assign(streambuf
*this, const streambuf
*rhs
)
409 streambuf_dtor(this);
410 return streambuf_copy_ctor(this, rhs
);
413 /* ??_Estreambuf@@UAEPAXI@Z */
414 DEFINE_THISCALL_WRAPPER(streambuf_vector_dtor
, 8)
415 #define call_streambuf_vector_dtor(this, flags) CALL_VTBL_FUNC(this, 0,\
416 streambuf*, (streambuf*, unsigned int), (this, flags))
417 streambuf
* __thiscall
streambuf_vector_dtor(streambuf
*this, unsigned int flags
)
419 TRACE("(%p %x)\n", this, flags
);
421 /* we have an array, with the number of elements stored before the first object */
422 INT_PTR i
, *ptr
= (INT_PTR
*)this-1;
424 for (i
= *ptr
-1; i
>= 0; i
--)
425 streambuf_dtor(this+i
);
426 operator_delete(ptr
);
428 streambuf_dtor(this);
430 operator_delete(this);
435 /* ??_Gstreambuf@@UAEPAXI@Z */
436 DEFINE_THISCALL_WRAPPER(streambuf_scalar_dtor
, 8)
437 streambuf
* __thiscall
streambuf_scalar_dtor(streambuf
*this, unsigned int flags
)
439 TRACE("(%p %x)\n", this, flags
);
440 streambuf_dtor(this);
441 if (flags
& 1) operator_delete(this);
445 /* ?doallocate@streambuf@@MAEHXZ */
446 /* ?doallocate@streambuf@@MEAAHXZ */
447 DEFINE_THISCALL_WRAPPER(streambuf_doallocate
, 4)
448 #define call_streambuf_doallocate(this) CALL_VTBL_FUNC(this, 40, int, (streambuf*), (this))
449 int __thiscall
streambuf_doallocate(streambuf
*this)
453 TRACE("(%p)\n", this);
454 reserve
= operator_new(RESERVE_SIZE
);
458 streambuf_setb(this, reserve
, reserve
+ RESERVE_SIZE
, 1);
462 /* ?allocate@streambuf@@IAEHXZ */
463 /* ?allocate@streambuf@@IEAAHXZ */
464 DEFINE_THISCALL_WRAPPER(streambuf_allocate
, 4)
465 int __thiscall
streambuf_allocate(streambuf
*this)
467 TRACE("(%p)\n", this);
468 if (this->base
!= NULL
|| this->unbuffered
)
470 return call_streambuf_doallocate(this);
473 /* ?base@streambuf@@IBEPADXZ */
474 /* ?base@streambuf@@IEBAPEADXZ */
475 DEFINE_THISCALL_WRAPPER(streambuf_base
, 4)
476 char* __thiscall
streambuf_base(const streambuf
*this)
478 TRACE("(%p)\n", this);
482 /* ?blen@streambuf@@IBEHXZ */
483 /* ?blen@streambuf@@IEBAHXZ */
484 DEFINE_THISCALL_WRAPPER(streambuf_blen
, 4)
485 int __thiscall
streambuf_blen(const streambuf
*this)
487 TRACE("(%p)\n", this);
488 return this->ebuf
- this->base
;
491 /* ?eback@streambuf@@IBEPADXZ */
492 /* ?eback@streambuf@@IEBAPEADXZ */
493 DEFINE_THISCALL_WRAPPER(streambuf_eback
, 4)
494 char* __thiscall
streambuf_eback(const streambuf
*this)
496 TRACE("(%p)\n", this);
500 /* ?ebuf@streambuf@@IBEPADXZ */
501 /* ?ebuf@streambuf@@IEBAPEADXZ */
502 DEFINE_THISCALL_WRAPPER(streambuf_ebuf
, 4)
503 char* __thiscall
streambuf_ebuf(const streambuf
*this)
505 TRACE("(%p)\n", this);
509 /* ?egptr@streambuf@@IBEPADXZ */
510 /* ?egptr@streambuf@@IEBAPEADXZ */
511 DEFINE_THISCALL_WRAPPER(streambuf_egptr
, 4)
512 char* __thiscall
streambuf_egptr(const streambuf
*this)
514 TRACE("(%p)\n", this);
518 /* ?epptr@streambuf@@IBEPADXZ */
519 /* ?epptr@streambuf@@IEBAPEADXZ */
520 DEFINE_THISCALL_WRAPPER(streambuf_epptr
, 4)
521 char* __thiscall
streambuf_epptr(const streambuf
*this)
523 TRACE("(%p)\n", this);
527 /* ?gptr@streambuf@@IBEPADXZ */
528 /* ?gptr@streambuf@@IEBAPEADXZ */
529 DEFINE_THISCALL_WRAPPER(streambuf_gptr
, 4)
530 char* __thiscall
streambuf_gptr(const streambuf
*this)
532 TRACE("(%p)\n", this);
536 /* ?pbase@streambuf@@IBEPADXZ */
537 /* ?pbase@streambuf@@IEBAPEADXZ */
538 DEFINE_THISCALL_WRAPPER(streambuf_pbase
, 4)
539 char* __thiscall
streambuf_pbase(const streambuf
*this)
541 TRACE("(%p)\n", this);
545 /* ?pptr@streambuf@@IBEPADXZ */
546 /* ?pptr@streambuf@@IEBAPEADXZ */
547 DEFINE_THISCALL_WRAPPER(streambuf_pptr
, 4)
548 char* __thiscall
streambuf_pptr(const streambuf
*this)
550 TRACE("(%p)\n", this);
554 /* ?clrlock@streambuf@@QAEXXZ */
555 /* ?clrlock@streambuf@@QEAAXXZ */
556 DEFINE_THISCALL_WRAPPER(streambuf_clrlock
, 4)
557 void __thiscall
streambuf_clrlock(streambuf
*this)
559 TRACE("(%p)\n", this);
560 if (this->do_lock
<= 0)
564 /* ?lock@streambuf@@QAEXXZ */
565 /* ?lock@streambuf@@QEAAXXZ */
566 DEFINE_THISCALL_WRAPPER(streambuf_lock
, 4)
567 void __thiscall
streambuf_lock(streambuf
*this)
569 TRACE("(%p)\n", this);
570 if (this->do_lock
< 0)
571 EnterCriticalSection(&this->lock
);
574 /* ?lockptr@streambuf@@IAEPAU_CRT_CRITICAL_SECTION@@XZ */
575 /* ?lockptr@streambuf@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ */
576 DEFINE_THISCALL_WRAPPER(streambuf_lockptr
, 4)
577 CRITICAL_SECTION
* __thiscall
streambuf_lockptr(streambuf
*this)
579 TRACE("(%p)\n", this);
583 /* ?gbump@streambuf@@IAEXH@Z */
584 /* ?gbump@streambuf@@IEAAXH@Z */
585 DEFINE_THISCALL_WRAPPER(streambuf_gbump
, 8)
586 void __thiscall
streambuf_gbump(streambuf
*this, int count
)
588 TRACE("(%p %d)\n", this, count
);
592 /* ?pbump@streambuf@@IAEXH@Z */
593 /* ?pbump@streambuf@@IEAAXH@Z */
594 DEFINE_THISCALL_WRAPPER(streambuf_pbump
, 8)
595 void __thiscall
streambuf_pbump(streambuf
*this, int count
)
597 TRACE("(%p %d)\n", this, count
);
601 /* ?in_avail@streambuf@@QBEHXZ */
602 /* ?in_avail@streambuf@@QEBAHXZ */
603 DEFINE_THISCALL_WRAPPER(streambuf_in_avail
, 4)
604 int __thiscall
streambuf_in_avail(const streambuf
*this)
606 TRACE("(%p)\n", this);
607 return (this->egptr
- this->gptr
> 0) ? this->egptr
- this->gptr
: 0;
610 /* ?out_waiting@streambuf@@QBEHXZ */
611 /* ?out_waiting@streambuf@@QEBAHXZ */
612 DEFINE_THISCALL_WRAPPER(streambuf_out_waiting
, 4)
613 int __thiscall
streambuf_out_waiting(const streambuf
*this)
615 TRACE("(%p)\n", this);
616 return (this->pptr
- this->pbase
> 0) ? this->pptr
- this->pbase
: 0;
620 DEFINE_THISCALL_WRAPPER(streambuf_overflow
, 8)
621 #define call_streambuf_overflow(this, c) CALL_VTBL_FUNC(this, 28, int, (streambuf*, int), (this, c))
622 int __thiscall
streambuf_overflow(streambuf
*this, int c
)
624 ERR("overflow is not implemented in streambuf\n");
628 /* ?seekoff@streambuf@@UAEJJW4seek_dir@ios@@H@Z */
629 /* ?seekoff@streambuf@@UEAAJJW4seek_dir@ios@@H@Z */
630 DEFINE_THISCALL_WRAPPER(streambuf_seekoff
, 16)
631 #define call_streambuf_seekoff(this, off, dir, mode) CALL_VTBL_FUNC(this, 12, streampos, (streambuf*, streamoff, ios_seek_dir, int), (this, off, dir, mode))
632 streampos __thiscall
streambuf_seekoff(streambuf
*this, streamoff offset
, ios_seek_dir dir
, int mode
)
634 TRACE("(%p %ld %d %d)\n", this, offset
, dir
, mode
);
638 /* ?seekpos@streambuf@@UAEJJH@Z */
639 /* ?seekpos@streambuf@@UEAAJJH@Z */
640 DEFINE_THISCALL_WRAPPER(streambuf_seekpos
, 12)
641 streampos __thiscall
streambuf_seekpos(streambuf
*this, streampos pos
, int mode
)
643 TRACE("(%p %ld %d)\n", this, pos
, mode
);
644 return call_streambuf_seekoff(this, pos
, SEEKDIR_beg
, mode
);
647 /* ?pbackfail@streambuf@@UAEHH@Z */
648 /* ?pbackfail@streambuf@@UEAAHH@Z */
649 DEFINE_THISCALL_WRAPPER(streambuf_pbackfail
, 8)
650 #define call_streambuf_pbackfail(this, c) CALL_VTBL_FUNC(this, 36, int, (streambuf*, int), (this, c))
651 int __thiscall
streambuf_pbackfail(streambuf
*this, int c
)
653 TRACE("(%p %d)\n", this, c
);
654 if (this->gptr
> this->eback
)
655 return *--this->gptr
= c
;
656 if (call_streambuf_seekoff(this, -1, SEEKDIR_cur
, OPENMODE_in
) == EOF
)
658 if (!this->unbuffered
&& this->egptr
) {
659 /* 'c' should be the next character read */
660 memmove(this->gptr
+ 1, this->gptr
, this->egptr
- this->gptr
- 1);
666 /* ?setb@streambuf@@IAEXPAD0H@Z */
667 /* ?setb@streambuf@@IEAAXPEAD0H@Z */
668 DEFINE_THISCALL_WRAPPER(streambuf_setb
, 16)
669 void __thiscall
streambuf_setb(streambuf
*this, char *ba
, char *eb
, int delete)
671 TRACE("(%p %p %p %d)\n", this, ba
, eb
, delete);
673 operator_delete(this->base
);
674 this->allocated
= delete;
679 /* ?setbuf@streambuf@@UAEPAV1@PADH@Z */
680 /* ?setbuf@streambuf@@UEAAPEAV1@PEADH@Z */
681 DEFINE_THISCALL_WRAPPER(streambuf_setbuf
, 12)
682 streambuf
* __thiscall
streambuf_setbuf(streambuf
*this, char *buffer
, int length
)
684 TRACE("(%p %p %d)\n", this, buffer
, length
);
685 if (this->base
!= NULL
)
688 if (buffer
== NULL
|| !length
) {
689 this->unbuffered
= 1;
690 this->base
= this->ebuf
= NULL
;
692 this->unbuffered
= 0;
694 this->ebuf
= buffer
+ length
;
699 /* ?setg@streambuf@@IAEXPAD00@Z */
700 /* ?setg@streambuf@@IEAAXPEAD00@Z */
701 DEFINE_THISCALL_WRAPPER(streambuf_setg
, 16)
702 void __thiscall
streambuf_setg(streambuf
*this, char *ek
, char *gp
, char *eg
)
704 TRACE("(%p %p %p %p)\n", this, ek
, gp
, eg
);
710 /* ?setlock@streambuf@@QAEXXZ */
711 /* ?setlock@streambuf@@QEAAXXZ */
712 DEFINE_THISCALL_WRAPPER(streambuf_setlock
, 4)
713 void __thiscall
streambuf_setlock(streambuf
*this)
715 TRACE("(%p)\n", this);
719 /* ?setp@streambuf@@IAEXPAD0@Z */
720 /* ?setp@streambuf@@IEAAXPEAD0@Z */
721 DEFINE_THISCALL_WRAPPER(streambuf_setp
, 12)
722 void __thiscall
streambuf_setp(streambuf
*this, char *pb
, char *ep
)
724 TRACE("(%p %p %p)\n", this, pb
, ep
);
725 this->pbase
= this->pptr
= pb
;
729 /* ?sync@streambuf@@UAEHXZ */
730 /* ?sync@streambuf@@UEAAHXZ */
731 DEFINE_THISCALL_WRAPPER(streambuf_sync
, 4)
732 #define call_streambuf_sync(this) CALL_VTBL_FUNC(this, 4, int, (streambuf*), (this))
733 int __thiscall
streambuf_sync(streambuf
*this)
735 TRACE("(%p)\n", this);
736 return (this->gptr
>= this->egptr
&& this->pbase
>= this->pptr
) ? 0 : EOF
;
739 /* ?unbuffered@streambuf@@IAEXH@Z */
740 /* ?unbuffered@streambuf@@IEAAXH@Z */
741 DEFINE_THISCALL_WRAPPER(streambuf_unbuffered_set
, 8)
742 void __thiscall
streambuf_unbuffered_set(streambuf
*this, int buf
)
744 TRACE("(%p %d)\n", this, buf
);
745 this->unbuffered
= buf
;
748 /* ?unbuffered@streambuf@@IBEHXZ */
749 /* ?unbuffered@streambuf@@IEBAHXZ */
750 DEFINE_THISCALL_WRAPPER(streambuf_unbuffered_get
, 4)
751 int __thiscall
streambuf_unbuffered_get(const streambuf
*this)
753 TRACE("(%p)\n", this);
754 return this->unbuffered
;
758 DEFINE_THISCALL_WRAPPER(streambuf_underflow
, 4)
759 #define call_streambuf_underflow(this) CALL_VTBL_FUNC(this, 32, int, (streambuf*), (this))
760 int __thiscall
streambuf_underflow(streambuf
*this)
762 ERR("underflow is not implemented in streambuf\n");
766 /* ?unlock@streambuf@@QAEXXZ */
767 /* ?unlock@streambuf@@QEAAXXZ */
768 DEFINE_THISCALL_WRAPPER(streambuf_unlock
, 4)
769 void __thiscall
streambuf_unlock(streambuf
*this)
771 TRACE("(%p)\n", this);
772 if (this->do_lock
< 0)
773 LeaveCriticalSection(&this->lock
);
776 /* ?xsgetn@streambuf@@UAEHPADH@Z */
777 /* ?xsgetn@streambuf@@UEAAHPEADH@Z */
778 DEFINE_THISCALL_WRAPPER(streambuf_xsgetn
, 12)
779 #define call_streambuf_xsgetn(this, buffer, count) CALL_VTBL_FUNC(this, 24, int, (streambuf*, char*, int), (this, buffer, count))
780 int __thiscall
streambuf_xsgetn(streambuf
*this, char *buffer
, int count
)
782 int copied
= 0, chunk
;
784 TRACE("(%p %p %d)\n", this, buffer
, count
);
786 if (this->unbuffered
) {
787 if (this->stored_char
== EOF
)
788 this->stored_char
= call_streambuf_underflow(this);
789 while (copied
< count
&& this->stored_char
!= EOF
) {
790 buffer
[copied
++] = this->stored_char
;
791 this->stored_char
= call_streambuf_underflow(this);
794 while (copied
< count
) {
795 if (call_streambuf_underflow(this) == EOF
)
797 chunk
= this->egptr
- this->gptr
;
798 if (chunk
> count
- copied
)
799 chunk
= count
- copied
;
800 memcpy(buffer
+copied
, this->gptr
, chunk
);
808 /* ?xsputn@streambuf@@UAEHPBDH@Z */
809 /* ?xsputn@streambuf@@UEAAHPEBDH@Z */
810 DEFINE_THISCALL_WRAPPER(streambuf_xsputn
, 12)
811 #define call_streambuf_xsputn(this, data, length) CALL_VTBL_FUNC(this, 20, int, (streambuf*, const char*, int), (this, data, length))
812 int __thiscall
streambuf_xsputn(streambuf
*this, const char *data
, int length
)
814 int copied
= 0, chunk
;
816 TRACE("(%p %p %d)\n", this, data
, length
);
818 while (copied
< length
) {
819 if (this->unbuffered
|| this->pptr
== this->epptr
) {
820 if (call_streambuf_overflow(this, (unsigned char)data
[copied
]) == EOF
)
824 chunk
= this->epptr
- this->pptr
;
825 if (chunk
> length
- copied
)
826 chunk
= length
- copied
;
827 memcpy(this->pptr
, data
+copied
, chunk
);
835 /* ?sgetc@streambuf@@QAEHXZ */
836 /* ?sgetc@streambuf@@QEAAHXZ */
837 DEFINE_THISCALL_WRAPPER(streambuf_sgetc
, 4)
838 int __thiscall
streambuf_sgetc(streambuf
*this)
840 TRACE("(%p)\n", this);
841 if (this->unbuffered
) {
842 if (this->stored_char
== EOF
)
843 this->stored_char
= call_streambuf_underflow(this);
844 return this->stored_char
;
846 return call_streambuf_underflow(this);
849 /* ?sputc@streambuf@@QAEHH@Z */
850 /* ?sputc@streambuf@@QEAAHH@Z */
851 DEFINE_THISCALL_WRAPPER(streambuf_sputc
, 8)
852 int __thiscall
streambuf_sputc(streambuf
*this, int ch
)
854 TRACE("(%p %d)\n", this, ch
);
855 return (this->pptr
< this->epptr
) ? (unsigned char)(*this->pptr
++ = ch
) : call_streambuf_overflow(this, ch
);
858 /* ?sgetn@streambuf@@QAEHPADH@Z */
859 /* ?sgetn@streambuf@@QEAAHPEADH@Z */
860 DEFINE_THISCALL_WRAPPER(streambuf_sgetn
, 12)
861 int __thiscall
streambuf_sgetn(streambuf
*this, char *buffer
, int count
)
863 return call_streambuf_xsgetn(this, buffer
, count
);
866 /* ?sputn@streambuf@@QAEHPBDH@Z */
867 /* ?sputn@streambuf@@QEAAHPEBDH@Z */
868 DEFINE_THISCALL_WRAPPER(streambuf_sputn
, 12)
869 int __thiscall
streambuf_sputn(streambuf
*this, const char *data
, int length
)
871 return call_streambuf_xsputn(this, data
, length
);
874 /* ?snextc@streambuf@@QAEHXZ */
875 /* ?snextc@streambuf@@QEAAHXZ */
876 DEFINE_THISCALL_WRAPPER(streambuf_snextc
, 4)
877 int __thiscall
streambuf_snextc(streambuf
*this)
879 TRACE("(%p)\n", this);
880 if (this->unbuffered
) {
881 if (this->stored_char
== EOF
)
882 call_streambuf_underflow(this);
883 return this->stored_char
= call_streambuf_underflow(this);
885 if (this->gptr
>= this->egptr
)
886 call_streambuf_underflow(this);
888 return (this->gptr
< this->egptr
) ? (unsigned char)(*this->gptr
) : call_streambuf_underflow(this);
892 /* ?sbumpc@streambuf@@QAEHXZ */
893 /* ?sbumpc@streambuf@@QEAAHXZ */
894 DEFINE_THISCALL_WRAPPER(streambuf_sbumpc
, 4)
895 int __thiscall
streambuf_sbumpc(streambuf
*this)
899 TRACE("(%p)\n", this);
901 if (this->unbuffered
) {
902 ret
= this->stored_char
;
903 this->stored_char
= EOF
;
905 ret
= call_streambuf_underflow(this);
907 ret
= (this->gptr
< this->egptr
) ? (unsigned char)(*this->gptr
) : call_streambuf_underflow(this);
913 /* ?stossc@streambuf@@QAEXXZ */
914 /* ?stossc@streambuf@@QEAAXXZ */
915 DEFINE_THISCALL_WRAPPER(streambuf_stossc
, 4)
916 void __thiscall
streambuf_stossc(streambuf
*this)
918 TRACE("(%p)\n", this);
919 if (this->unbuffered
) {
920 if (this->stored_char
== EOF
)
921 call_streambuf_underflow(this);
923 this->stored_char
= EOF
;
925 if (this->gptr
>= this->egptr
)
926 call_streambuf_underflow(this);
927 if (this->gptr
< this->egptr
)
932 /* ?sputbackc@streambuf@@QAEHD@Z */
933 /* ?sputbackc@streambuf@@QEAAHD@Z */
934 DEFINE_THISCALL_WRAPPER(streambuf_sputbackc
, 8)
935 int __thiscall
streambuf_sputbackc(streambuf
*this, char ch
)
937 TRACE("(%p %d)\n", this, ch
);
938 return call_streambuf_pbackfail(this, ch
);
941 /* ?dbp@streambuf@@QAEXXZ */
942 /* ?dbp@streambuf@@QEAAXXZ */
943 DEFINE_THISCALL_WRAPPER(streambuf_dbp
, 4)
944 void __thiscall
streambuf_dbp(streambuf
*this)
946 printf("\nSTREAMBUF DEBUG INFO: this=%p, ", this);
947 if (this->unbuffered
) {
948 printf("unbuffered\n");
950 printf("_fAlloc=%d\n", this->allocated
);
951 printf(" base()=%p, ebuf()=%p, blen()=%d\n", this->base
, this->ebuf
, streambuf_blen(this));
952 printf("pbase()=%p, pptr()=%p, epptr()=%p\n", this->pbase
, this->pptr
, this->epptr
);
953 printf("eback()=%p, gptr()=%p, egptr()=%p\n", this->eback
, this->gptr
, this->egptr
);
957 /* ??0filebuf@@QAE@ABV0@@Z */
958 /* ??0filebuf@@QEAA@AEBV0@@Z */
959 DEFINE_THISCALL_WRAPPER(filebuf_copy_ctor
, 8)
960 filebuf
* __thiscall
filebuf_copy_ctor(filebuf
* this, const filebuf
*copy
)
962 TRACE("(%p %p)\n", this, copy
);
964 this->base
.vtable
= &filebuf_vtable
;
968 /* ??0filebuf@@QAE@HPADH@Z */
969 /* ??0filebuf@@QEAA@HPEADH@Z */
970 DEFINE_THISCALL_WRAPPER(filebuf_fd_reserve_ctor
, 16)
971 filebuf
* __thiscall
filebuf_fd_reserve_ctor(filebuf
* this, filedesc fd
, char *buffer
, int length
)
973 TRACE("(%p %d %p %d)\n", this, fd
, buffer
, length
);
974 streambuf_reserve_ctor(&this->base
, buffer
, length
);
975 this->base
.vtable
= &filebuf_vtable
;
981 /* ??0filebuf@@QAE@H@Z */
982 /* ??0filebuf@@QEAA@H@Z */
983 DEFINE_THISCALL_WRAPPER(filebuf_fd_ctor
, 8)
984 filebuf
* __thiscall
filebuf_fd_ctor(filebuf
* this, filedesc fd
)
986 filebuf_fd_reserve_ctor(this, fd
, NULL
, 0);
987 this->base
.unbuffered
= 0;
991 /* ??0filebuf@@QAE@XZ */
992 /* ??0filebuf@@QEAA@XZ */
993 DEFINE_THISCALL_WRAPPER(filebuf_ctor
, 4)
994 filebuf
* __thiscall
filebuf_ctor(filebuf
* this)
996 return filebuf_fd_ctor(this, -1);
999 /* ??1filebuf@@UAE@XZ */
1000 /* ??1filebuf@@UEAA@XZ */
1001 DEFINE_THISCALL_WRAPPER(filebuf_dtor
, 4)
1002 void __thiscall
filebuf_dtor(filebuf
* this)
1004 TRACE("(%p)\n", this);
1006 filebuf_close(this);
1007 streambuf_dtor(&this->base
);
1010 /* ??4filebuf@@QAEAAV0@ABV0@@Z */
1011 /* ??4filebuf@@QEAAAEAV0@AEBV0@@Z */
1012 DEFINE_THISCALL_WRAPPER(filebuf_assign
, 8)
1013 filebuf
* __thiscall
filebuf_assign(filebuf
* this, const filebuf
*rhs
)
1016 return filebuf_copy_ctor(this, rhs
);
1019 /* ??_Efilebuf@@UAEPAXI@Z */
1020 DEFINE_THISCALL_WRAPPER(filebuf_vector_dtor
, 8)
1021 filebuf
* __thiscall
filebuf_vector_dtor(filebuf
*this, unsigned int flags
)
1023 TRACE("(%p %x)\n", this, flags
);
1025 /* we have an array, with the number of elements stored before the first object */
1026 INT_PTR i
, *ptr
= (INT_PTR
*)this-1;
1028 for (i
= *ptr
-1; i
>= 0; i
--)
1029 filebuf_dtor(this+i
);
1030 operator_delete(ptr
);
1034 operator_delete(this);
1039 /* ??_Gfilebuf@@UAEPAXI@Z */
1040 DEFINE_THISCALL_WRAPPER(filebuf_scalar_dtor
, 8)
1041 filebuf
* __thiscall
filebuf_scalar_dtor(filebuf
*this, unsigned int flags
)
1043 TRACE("(%p %x)\n", this, flags
);
1045 if (flags
& 1) operator_delete(this);
1049 /* ?attach@filebuf@@QAEPAV1@H@Z */
1050 /* ?attach@filebuf@@QEAAPEAV1@H@Z */
1051 DEFINE_THISCALL_WRAPPER(filebuf_attach
, 8)
1052 filebuf
* __thiscall
filebuf_attach(filebuf
*this, filedesc fd
)
1054 TRACE("(%p %d)\n", this, fd
);
1058 streambuf_lock(&this->base
);
1060 streambuf_allocate(&this->base
);
1061 streambuf_unlock(&this->base
);
1065 /* ?close@filebuf@@QAEPAV1@XZ */
1066 /* ?close@filebuf@@QEAAPEAV1@XZ */
1067 DEFINE_THISCALL_WRAPPER(filebuf_close
, 4)
1068 filebuf
* __thiscall
filebuf_close(filebuf
*this)
1072 TRACE("(%p)\n", this);
1076 streambuf_lock(&this->base
);
1077 if (call_streambuf_sync(&this->base
) == EOF
|| _close(this->fd
) < 0) {
1083 streambuf_unlock(&this->base
);
1087 /* ?fd@filebuf@@QBEHXZ */
1088 /* ?fd@filebuf@@QEBAHXZ */
1089 DEFINE_THISCALL_WRAPPER(filebuf_fd
, 4)
1090 filedesc __thiscall
filebuf_fd(const filebuf
*this)
1092 TRACE("(%p)\n", this);
1096 /* ?is_open@filebuf@@QBEHXZ */
1097 /* ?is_open@filebuf@@QEBAHXZ */
1098 DEFINE_THISCALL_WRAPPER(filebuf_is_open
, 4)
1099 int __thiscall
filebuf_is_open(const filebuf
*this)
1101 TRACE("(%p)\n", this);
1102 return this->fd
!= -1;
1105 /* ?open@filebuf@@QAEPAV1@PBDHH@Z */
1106 /* ?open@filebuf@@QEAAPEAV1@PEBDHH@Z */
1107 DEFINE_THISCALL_WRAPPER(filebuf_open
, 16)
1108 filebuf
* __thiscall
filebuf_open(filebuf
*this, const char *name
, ios_open_mode mode
, int protection
)
1110 const int inout_mode
[4] = {-1, _O_RDONLY
, _O_WRONLY
, _O_RDWR
};
1111 const int share_mode
[4] = {_SH_DENYRW
, _SH_DENYWR
, _SH_DENYRD
, _SH_DENYNO
};
1112 int op_flags
, sh_flags
, fd
;
1114 TRACE("(%p %s %x %x)\n", this, name
, mode
, protection
);
1119 if (mode
& (OPENMODE_app
|OPENMODE_trunc
))
1120 mode
|= OPENMODE_out
;
1121 op_flags
= inout_mode
[mode
& (OPENMODE_in
|OPENMODE_out
)];
1124 if (mode
& OPENMODE_app
)
1125 op_flags
|= _O_APPEND
;
1126 if ((mode
& OPENMODE_trunc
) ||
1127 ((mode
& OPENMODE_out
) && !(mode
& (OPENMODE_in
|OPENMODE_app
|OPENMODE_ate
))))
1128 op_flags
|= _O_TRUNC
;
1129 if (!(mode
& OPENMODE_nocreate
))
1130 op_flags
|= _O_CREAT
;
1131 if (mode
& OPENMODE_noreplace
)
1132 op_flags
|= _O_EXCL
;
1133 op_flags
|= (mode
& OPENMODE_binary
) ? _O_BINARY
: _O_TEXT
;
1135 /* share protection */
1136 sh_flags
= (protection
& filebuf_sh_none
) ? share_mode
[(protection
>> 9) & 3] : _SH_DENYNO
;
1138 TRACE("op_flags %x, sh_flags %x\n", op_flags
, sh_flags
);
1139 fd
= _sopen(name
, op_flags
, sh_flags
, _S_IREAD
|_S_IWRITE
);
1143 streambuf_lock(&this->base
);
1146 if ((mode
& OPENMODE_ate
) &&
1147 call_streambuf_seekoff(&this->base
, 0, SEEKDIR_end
, mode
& (OPENMODE_in
|OPENMODE_out
)) == EOF
) {
1151 streambuf_allocate(&this->base
);
1152 streambuf_unlock(&this->base
);
1153 return (this->fd
== -1) ? NULL
: this;
1156 /* ?overflow@filebuf@@UAEHH@Z */
1157 /* ?overflow@filebuf@@UEAAHH@Z */
1158 DEFINE_THISCALL_WRAPPER(filebuf_overflow
, 8)
1159 int __thiscall
filebuf_overflow(filebuf
*this, int c
)
1161 TRACE("(%p %d)\n", this, c
);
1162 if (call_streambuf_sync(&this->base
) == EOF
)
1164 if (this->base
.unbuffered
)
1165 return (c
== EOF
) ? 1 : _write(this->fd
, &c
, 1);
1166 if (streambuf_allocate(&this->base
) == EOF
)
1169 this->base
.pbase
= this->base
.pptr
= this->base
.base
;
1170 this->base
.epptr
= this->base
.ebuf
;
1172 *this->base
.pptr
++ = c
;
1176 /* ?seekoff@filebuf@@UAEJJW4seek_dir@ios@@H@Z */
1177 /* ?seekoff@filebuf@@UEAAJJW4seek_dir@ios@@H@Z */
1178 DEFINE_THISCALL_WRAPPER(filebuf_seekoff
, 16)
1179 streampos __thiscall
filebuf_seekoff(filebuf
*this, streamoff offset
, ios_seek_dir dir
, int mode
)
1181 TRACE("(%p %ld %d %d)\n", this, offset
, dir
, mode
);
1182 if (call_streambuf_sync(&this->base
) == EOF
)
1184 return _lseek(this->fd
, offset
, dir
);
1187 /* ?setbuf@filebuf@@UAEPAVstreambuf@@PADH@Z */
1188 /* ?setbuf@filebuf@@UEAAPEAVstreambuf@@PEADH@Z */
1189 DEFINE_THISCALL_WRAPPER(filebuf_setbuf
, 12)
1190 streambuf
* __thiscall
filebuf_setbuf(filebuf
*this, char *buffer
, int length
)
1192 TRACE("(%p %p %d)\n", this, buffer
, length
);
1194 if (filebuf_is_open(this) && this->base
.base
!= NULL
)
1197 streambuf_lock(&this->base
);
1199 if (buffer
== NULL
|| !length
) {
1200 this->base
.unbuffered
= 1;
1202 if (this->base
.allocated
) {
1203 operator_delete(this->base
.base
);
1204 this->base
.allocated
= 0;
1207 this->base
.base
= buffer
;
1208 this->base
.ebuf
= buffer
+ length
;
1211 streambuf_unlock(&this->base
);
1216 /* ?setmode@filebuf@@QAEHH@Z */
1217 /* ?setmode@filebuf@@QEAAHH@Z */
1218 DEFINE_THISCALL_WRAPPER(filebuf_setmode
, 8)
1219 int __thiscall
filebuf_setmode(filebuf
*this, int mode
)
1223 TRACE("(%p %d)\n", this, mode
);
1224 if (mode
!= filebuf_text
&& mode
!= filebuf_binary
)
1227 streambuf_lock(&this->base
);
1228 ret
= (call_streambuf_sync(&this->base
) == EOF
) ? -1 : _setmode(this->fd
, mode
);
1229 streambuf_unlock(&this->base
);
1233 /* ?sync@filebuf@@UAEHXZ */
1234 /* ?sync@filebuf@@UEAAHXZ */
1235 DEFINE_THISCALL_WRAPPER(filebuf_sync
, 4)
1236 int __thiscall
filebuf_sync(filebuf
*this)
1242 TRACE("(%p)\n", this);
1245 if (this->base
.unbuffered
)
1248 /* flush output buffer */
1249 if (this->base
.pptr
!= NULL
) {
1250 count
= this->base
.pptr
- this->base
.pbase
;
1251 if (count
> 0 && _write(this->fd
, this->base
.pbase
, count
) != count
)
1254 this->base
.pbase
= this->base
.pptr
= this->base
.epptr
= NULL
;
1255 /* flush input buffer */
1256 if (this->base
.egptr
!= NULL
) {
1257 offset
= this->base
.egptr
- this->base
.gptr
;
1259 mode
= _setmode(this->fd
, _O_TEXT
);
1260 _setmode(this->fd
, mode
);
1261 if (mode
& _O_TEXT
) {
1262 /* in text mode, '\n' in the buffer means '\r\n' in the file */
1263 for (ptr
= this->base
.gptr
; ptr
< this->base
.egptr
; ptr
++)
1267 if (_lseek(this->fd
, -offset
, SEEK_CUR
) < 0)
1271 this->base
.eback
= this->base
.gptr
= this->base
.egptr
= NULL
;
1275 /* ?underflow@filebuf@@UAEHXZ */
1276 /* ?underflow@filebuf@@UEAAHXZ */
1277 DEFINE_THISCALL_WRAPPER(filebuf_underflow
, 4)
1278 int __thiscall
filebuf_underflow(filebuf
*this)
1280 int buffer_size
, read_bytes
;
1283 TRACE("(%p)\n", this);
1285 if (this->base
.unbuffered
)
1286 return (_read(this->fd
, &c
, 1) < 1) ? EOF
: (unsigned char) c
;
1288 if (this->base
.gptr
>= this->base
.egptr
) {
1289 if (call_streambuf_sync(&this->base
) == EOF
)
1291 buffer_size
= this->base
.ebuf
- this->base
.base
;
1292 read_bytes
= _read(this->fd
, this->base
.base
, buffer_size
);
1293 if (read_bytes
<= 0)
1295 this->base
.eback
= this->base
.gptr
= this->base
.base
;
1296 this->base
.egptr
= this->base
.base
+ read_bytes
;
1298 return (unsigned char) *this->base
.gptr
;
1301 /* ??0strstreambuf@@QAE@ABV0@@Z */
1302 /* ??0strstreambuf@@QEAA@AEBV0@@Z */
1303 DEFINE_THISCALL_WRAPPER(strstreambuf_copy_ctor
, 8)
1304 strstreambuf
* __thiscall
strstreambuf_copy_ctor(strstreambuf
*this, const strstreambuf
*copy
)
1306 TRACE("(%p %p)\n", this, copy
);
1308 this->base
.vtable
= &strstreambuf_vtable
;
1312 /* ??0strstreambuf@@QAE@H@Z */
1313 /* ??0strstreambuf@@QEAA@H@Z */
1314 DEFINE_THISCALL_WRAPPER(strstreambuf_dynamic_ctor
, 8)
1315 strstreambuf
* __thiscall
strstreambuf_dynamic_ctor(strstreambuf
* this, int length
)
1317 TRACE("(%p %d)\n", this, length
);
1318 streambuf_ctor(&this->base
);
1319 this->base
.vtable
= &strstreambuf_vtable
;
1321 this->increase
= length
;
1323 this->f_alloc
= NULL
;
1324 this->f_free
= NULL
;
1328 /* ??0strstreambuf@@QAE@P6APAXJ@ZP6AXPAX@Z@Z */
1329 /* ??0strstreambuf@@QEAA@P6APEAXJ@ZP6AXPEAX@Z@Z */
1330 DEFINE_THISCALL_WRAPPER(strstreambuf_funcs_ctor
, 12)
1331 strstreambuf
* __thiscall
strstreambuf_funcs_ctor(strstreambuf
* this, allocFunction falloc
, freeFunction ffree
)
1333 TRACE("(%p %p %p)\n", this, falloc
, ffree
);
1334 strstreambuf_dynamic_ctor(this, 1);
1335 this->f_alloc
= falloc
;
1336 this->f_free
= ffree
;
1340 /* ??0strstreambuf@@QAE@PADH0@Z */
1341 /* ??0strstreambuf@@QEAA@PEADH0@Z */
1342 DEFINE_THISCALL_WRAPPER(strstreambuf_buffer_ctor
, 16)
1343 strstreambuf
* __thiscall
strstreambuf_buffer_ctor(strstreambuf
*this, char *buffer
, int length
, char *put
)
1347 TRACE("(%p %p %d %p)\n", this, buffer
, length
, put
);
1350 end_buffer
= buffer
+ length
;
1351 else if (length
== 0)
1352 end_buffer
= buffer
+ strlen(buffer
);
1354 end_buffer
= (char*) -1;
1356 streambuf_ctor(&this->base
);
1357 streambuf_setb(&this->base
, buffer
, end_buffer
, 0);
1359 streambuf_setg(&this->base
, buffer
, buffer
, end_buffer
);
1361 streambuf_setg(&this->base
, buffer
, buffer
, put
);
1362 streambuf_setp(&this->base
, put
, end_buffer
);
1364 this->base
.vtable
= &strstreambuf_vtable
;
1370 /* ??0strstreambuf@@QAE@PAEH0@Z */
1371 /* ??0strstreambuf@@QEAA@PEAEH0@Z */
1372 DEFINE_THISCALL_WRAPPER(strstreambuf_ubuffer_ctor
, 16)
1373 strstreambuf
* __thiscall
strstreambuf_ubuffer_ctor(strstreambuf
*this, unsigned char *buffer
, int length
, unsigned char *put
)
1375 TRACE("(%p %p %d %p)\n", this, buffer
, length
, put
);
1376 return strstreambuf_buffer_ctor(this, (char*)buffer
, length
, (char*)put
);
1379 /* ??0strstreambuf@@QAE@XZ */
1380 /* ??0strstreambuf@@QEAA@XZ */
1381 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor
, 4)
1382 strstreambuf
* __thiscall
strstreambuf_ctor(strstreambuf
*this)
1384 TRACE("(%p)\n", this);
1385 return strstreambuf_dynamic_ctor(this, 1);
1388 /* ??1strstreambuf@@UAE@XZ */
1389 /* ??1strstreambuf@@UEAA@XZ */
1390 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor
, 4)
1391 void __thiscall
strstreambuf_dtor(strstreambuf
*this)
1393 TRACE("(%p)\n", this);
1394 if (this->dynamic
&& this->base
.base
) {
1396 this->f_free(this->base
.base
);
1398 operator_delete(this->base
.base
);
1400 streambuf_dtor(&this->base
);
1403 /* ??4strstreambuf@@QAEAAV0@ABV0@@Z */
1404 /* ??4strstreambuf@@QEAAAEAV0@AEBV0@@Z */
1405 DEFINE_THISCALL_WRAPPER(strstreambuf_assign
, 8)
1406 strstreambuf
* __thiscall
strstreambuf_assign(strstreambuf
*this, const strstreambuf
*rhs
)
1408 strstreambuf_dtor(this);
1409 return strstreambuf_copy_ctor(this, rhs
);
1412 /* ??_Estrstreambuf@@UAEPAXI@Z */
1413 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor
, 8)
1414 strstreambuf
* __thiscall
strstreambuf_vector_dtor(strstreambuf
*this, unsigned int flags
)
1416 TRACE("(%p %x)\n", this, flags
);
1418 /* we have an array, with the number of elements stored before the first object */
1419 INT_PTR i
, *ptr
= (INT_PTR
*)this-1;
1421 for (i
= *ptr
-1; i
>= 0; i
--)
1422 strstreambuf_dtor(this+i
);
1423 operator_delete(ptr
);
1425 strstreambuf_dtor(this);
1427 operator_delete(this);
1432 /* ??_Gstrstreambuf@@UAEPAXI@Z */
1433 DEFINE_THISCALL_WRAPPER(strstreambuf_scalar_dtor
, 8)
1434 strstreambuf
* __thiscall
strstreambuf_scalar_dtor(strstreambuf
*this, unsigned int flags
)
1436 TRACE("(%p %x)\n", this, flags
);
1437 strstreambuf_dtor(this);
1438 if (flags
& 1) operator_delete(this);
1442 /* ?doallocate@strstreambuf@@MAEHXZ */
1443 /* ?doallocate@strstreambuf@@MEAAHXZ */
1444 DEFINE_THISCALL_WRAPPER(strstreambuf_doallocate
, 4)
1445 int __thiscall
strstreambuf_doallocate(strstreambuf
*this)
1447 char *prev_buffer
= this->base
.base
, *new_buffer
;
1448 LONG prev_size
= this->base
.ebuf
- this->base
.base
, new_size
;
1450 TRACE("(%p)\n", this);
1452 /* calculate the size of the new buffer */
1453 new_size
= (prev_size
> 0 ? prev_size
: 0) + (this->increase
> 0 ? this->increase
: 1);
1454 /* get a new buffer */
1456 new_buffer
= this->f_alloc(new_size
);
1458 new_buffer
= operator_new(new_size
);
1461 if (this->base
.ebuf
) {
1462 /* copy the contents and adjust the pointers */
1463 memcpy(new_buffer
, this->base
.base
, prev_size
);
1464 if (this->base
.egptr
) {
1465 this->base
.eback
+= new_buffer
- prev_buffer
;
1466 this->base
.gptr
+= new_buffer
- prev_buffer
;
1467 this->base
.egptr
+= new_buffer
- prev_buffer
;
1469 if (this->base
.epptr
) {
1470 this->base
.pbase
+= new_buffer
- prev_buffer
;
1471 this->base
.pptr
+= new_buffer
- prev_buffer
;
1472 this->base
.epptr
+= new_buffer
- prev_buffer
;
1474 /* free the old buffer */
1476 this->f_free(this->base
.base
);
1478 operator_delete(this->base
.base
);
1480 streambuf_setb(&this->base
, new_buffer
, new_buffer
+ new_size
, 0);
1484 /* ?freeze@strstreambuf@@QAEXH@Z */
1485 /* ?freeze@strstreambuf@@QEAAXH@Z */
1486 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze
, 8)
1487 void __thiscall
strstreambuf_freeze(strstreambuf
*this, int frozen
)
1489 TRACE("(%p %d)\n", this, frozen
);
1490 if (!this->constant
)
1491 this->dynamic
= !frozen
;
1494 /* ?overflow@strstreambuf@@UAEHH@Z */
1495 /* ?overflow@strstreambuf@@UEAAHH@Z */
1496 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow
, 8)
1497 int __thiscall
strstreambuf_overflow(strstreambuf
*this, int c
)
1499 TRACE("(%p %d)\n", this, c
);
1500 if (this->base
.pptr
>= this->base
.epptr
) {
1501 /* increase the buffer size if it's dynamic */
1502 if (!this->dynamic
|| call_streambuf_doallocate(&this->base
) == EOF
)
1504 if (!this->base
.epptr
)
1505 this->base
.pbase
= this->base
.pptr
= this->base
.egptr
? this->base
.egptr
: this->base
.base
;
1506 this->base
.epptr
= this->base
.ebuf
;
1509 *this->base
.pptr
++ = c
;
1513 /* ?seekoff@strstreambuf@@UAEJJW4seek_dir@ios@@H@Z */
1514 /* ?seekoff@strstreambuf@@UEAAJJW4seek_dir@ios@@H@Z */
1515 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff
, 16)
1516 streampos __thiscall
strstreambuf_seekoff(strstreambuf
*this, streamoff offset
, ios_seek_dir dir
, int mode
)
1520 TRACE("(%p %ld %d %d)\n", this, offset
, dir
, mode
);
1522 if ((unsigned int)dir
> SEEKDIR_end
|| !(mode
& (OPENMODE_in
|OPENMODE_out
)))
1525 if (mode
& OPENMODE_in
) {
1526 call_streambuf_underflow(&this->base
);
1527 base
[SEEKDIR_beg
] = this->base
.eback
;
1528 base
[SEEKDIR_cur
] = this->base
.gptr
;
1529 base
[SEEKDIR_end
] = this->base
.egptr
;
1530 if (base
[dir
] + offset
< this->base
.eback
|| base
[dir
] + offset
> this->base
.egptr
)
1532 this->base
.gptr
= base
[dir
] + offset
;
1535 if (mode
& OPENMODE_out
) {
1536 if (!this->base
.epptr
&& call_streambuf_overflow(&this->base
, EOF
) == EOF
)
1538 base
[SEEKDIR_beg
] = this->base
.pbase
;
1539 base
[SEEKDIR_cur
] = this->base
.pptr
;
1540 base
[SEEKDIR_end
] = this->base
.epptr
;
1541 if (base
[dir
] + offset
< this->base
.pbase
)
1543 if (base
[dir
] + offset
> this->base
.epptr
) {
1544 /* make room if the buffer is dynamic */
1547 this->increase
= offset
;
1548 if (call_streambuf_doallocate(&this->base
) == EOF
)
1551 this->base
.pptr
= base
[dir
] + offset
;
1552 return this->base
.pptr
- base
[SEEKDIR_beg
];
1554 return this->base
.gptr
- base
[SEEKDIR_beg
];
1557 /* ?setbuf@strstreambuf@@UAEPAVstreambuf@@PADH@Z */
1558 /* ?setbuf@strstreambuf@@UEAAPEAVstreambuf@@PEADH@Z */
1559 DEFINE_THISCALL_WRAPPER(strstreambuf_setbuf
, 12)
1560 streambuf
* __thiscall
strstreambuf_setbuf(strstreambuf
*this, char *buffer
, int length
)
1562 TRACE("(%p %p %d)\n", this, buffer
, length
);
1564 this->increase
= length
;
1568 /* ?str@strstreambuf@@QAEPADXZ */
1569 /* ?str@strstreambuf@@QEAAPEADXZ */
1570 DEFINE_THISCALL_WRAPPER(strstreambuf_str
, 4)
1571 char* __thiscall
strstreambuf_str(strstreambuf
*this)
1573 TRACE("(%p)\n", this);
1574 strstreambuf_freeze(this, 1);
1575 return this->base
.base
;
1578 /* ?sync@strstreambuf@@UAEHXZ */
1579 /* ?sync@strstreambuf@@UEAAHXZ */
1580 DEFINE_THISCALL_WRAPPER(strstreambuf_sync
, 4)
1581 int __thiscall
strstreambuf_sync(strstreambuf
*this)
1583 TRACE("(%p)\n", this);
1587 /* ?underflow@strstreambuf@@UAEHXZ */
1588 /* ?underflow@strstreambuf@@UEAAHXZ */
1589 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow
, 4)
1590 int __thiscall
strstreambuf_underflow(strstreambuf
*this)
1592 TRACE("(%p)\n", this);
1593 if (this->base
.gptr
< this->base
.egptr
)
1594 return (unsigned char) *this->base
.gptr
;
1595 /* extend the get area to include the characters written */
1596 if (this->base
.egptr
< this->base
.pptr
) {
1597 this->base
.gptr
= this->base
.base
+ (this->base
.gptr
- this->base
.eback
);
1598 this->base
.eback
= this->base
.base
;
1599 this->base
.egptr
= this->base
.pptr
;
1601 return (this->base
.gptr
< this->base
.egptr
) ? (unsigned char)(*this->base
.gptr
) : EOF
;
1604 /* ??0stdiobuf@@QAE@ABV0@@Z */
1605 /* ??0stdiobuf@@QEAA@AEBV0@@Z */
1606 DEFINE_THISCALL_WRAPPER(stdiobuf_copy_ctor
, 8)
1607 stdiobuf
* __thiscall
stdiobuf_copy_ctor(stdiobuf
*this, const stdiobuf
*copy
)
1609 TRACE("(%p %p)\n", this, copy
);
1611 this->base
.vtable
= &stdiobuf_vtable
;
1615 /* ??0stdiobuf@@QAE@PAU_iobuf@@@Z */
1616 /* ??0stdiobuf@@QEAA@PEAU_iobuf@@@Z */
1617 DEFINE_THISCALL_WRAPPER(stdiobuf_file_ctor
, 8)
1618 stdiobuf
* __thiscall
stdiobuf_file_ctor(stdiobuf
*this, FILE *file
)
1620 TRACE("(%p %p)\n", this, file
);
1621 streambuf_reserve_ctor(&this->base
, NULL
, 0);
1622 this->base
.vtable
= &stdiobuf_vtable
;
1627 /* ??1stdiobuf@@UAE@XZ */
1628 /* ??1stdiobuf@@UEAA@XZ */
1629 DEFINE_THISCALL_WRAPPER(stdiobuf_dtor
, 4)
1630 void __thiscall
stdiobuf_dtor(stdiobuf
*this)
1632 TRACE("(%p)\n", this);
1633 call_streambuf_sync(&this->base
);
1634 streambuf_dtor(&this->base
);
1637 /* ??4stdiobuf@@QAEAAV0@ABV0@@Z */
1638 /* ??4stdiobuf@@QEAAAEAV0@AEBV0@@Z */
1639 DEFINE_THISCALL_WRAPPER(stdiobuf_assign
, 8)
1640 stdiobuf
* __thiscall
stdiobuf_assign(stdiobuf
*this, const stdiobuf
*rhs
)
1642 stdiobuf_dtor(this);
1643 return stdiobuf_copy_ctor(this, rhs
);
1646 /* ??_Estdiobuf@@UAEPAXI@Z */
1647 DEFINE_THISCALL_WRAPPER(stdiobuf_vector_dtor
, 8)
1648 stdiobuf
* __thiscall
stdiobuf_vector_dtor(stdiobuf
*this, unsigned int flags
)
1650 TRACE("(%p %x)\n", this, flags
);
1652 /* we have an array, with the number of elements stored before the first object */
1653 INT_PTR i
, *ptr
= (INT_PTR
*)this-1;
1655 for (i
= *ptr
-1; i
>= 0; i
--)
1656 stdiobuf_dtor(this+i
);
1657 operator_delete(ptr
);
1659 stdiobuf_dtor(this);
1661 operator_delete(this);
1666 /* ??_Gstdiobuf@@UAEPAXI@Z */
1667 DEFINE_THISCALL_WRAPPER(stdiobuf_scalar_dtor
, 8)
1668 stdiobuf
* __thiscall
stdiobuf_scalar_dtor(stdiobuf
*this, unsigned int flags
)
1670 TRACE("(%p %x)\n", this, flags
);
1671 stdiobuf_dtor(this);
1672 if (flags
& 1) operator_delete(this);
1676 /* ?overflow@stdiobuf@@UAEHH@Z */
1677 /* ?overflow@stdiobuf@@UEAAHH@Z */
1678 DEFINE_THISCALL_WRAPPER(stdiobuf_overflow
, 8)
1679 int __thiscall
stdiobuf_overflow(stdiobuf
*this, int c
)
1681 TRACE("(%p %d)\n", this, c
);
1682 if (this->base
.unbuffered
)
1683 return (c
== EOF
) ? 1 : fputc(c
, this->file
);
1684 if (streambuf_allocate(&this->base
) == EOF
)
1687 if (!this->base
.epptr
) {
1688 /* set the put area to the second half of the buffer */
1689 streambuf_setp(&this->base
,
1690 this->base
.base
+ (this->base
.ebuf
- this->base
.base
) / 2, this->base
.ebuf
);
1691 } else if (this->base
.pptr
> this->base
.pbase
) {
1692 /* flush the put area */
1693 int count
= this->base
.pptr
- this->base
.pbase
;
1694 if (fwrite(this->base
.pbase
, sizeof(char), count
, this->file
) != count
)
1696 this->base
.pptr
= this->base
.pbase
;
1699 if (this->base
.pbase
>= this->base
.epptr
)
1700 return fputc(c
, this->file
);
1701 *this->base
.pptr
++ = c
;
1706 /* ?pbackfail@stdiobuf@@UAEHH@Z */
1707 /* ?pbackfail@stdiobuf@@UEAAHH@Z */
1708 DEFINE_THISCALL_WRAPPER(stdiobuf_pbackfail
, 8)
1709 int __thiscall
stdiobuf_pbackfail(stdiobuf
*this, int c
)
1711 TRACE("(%p %d)\n", this, c
);
1712 return streambuf_pbackfail(&this->base
, c
);
1715 /* ?seekoff@stdiobuf@@UAEJJW4seek_dir@ios@@H@Z */
1716 /* ?seekoff@stdiobuf@@UEAAJJW4seek_dir@ios@@H@Z */
1717 DEFINE_THISCALL_WRAPPER(stdiobuf_seekoff
, 16)
1718 streampos __thiscall
stdiobuf_seekoff(stdiobuf
*this, streamoff offset
, ios_seek_dir dir
, int mode
)
1720 TRACE("(%p %ld %d %d)\n", this, offset
, dir
, mode
);
1721 call_streambuf_overflow(&this->base
, EOF
);
1722 if (fseek(this->file
, offset
, dir
))
1724 return ftell(this->file
);
1727 /* ?setrwbuf@stdiobuf@@QAEHHH@Z */
1728 /* ?setrwbuf@stdiobuf@@QEAAHHH@Z */
1729 DEFINE_THISCALL_WRAPPER(stdiobuf_setrwbuf
, 12)
1730 int __thiscall
stdiobuf_setrwbuf(stdiobuf
*this, int read_size
, int write_size
)
1733 int buffer_size
= read_size
+ write_size
;
1735 TRACE("(%p %d %d)\n", this, read_size
, write_size
);
1736 if (read_size
< 0 || write_size
< 0)
1739 this->base
.unbuffered
= 1;
1742 /* get a new buffer */
1743 reserve
= operator_new(buffer_size
);
1746 streambuf_setb(&this->base
, reserve
, reserve
+ buffer_size
, 1);
1747 this->base
.unbuffered
= 0;
1748 /* set the get/put areas */
1750 streambuf_setg(&this->base
, reserve
, reserve
+ read_size
, reserve
+ read_size
);
1752 streambuf_setg(&this->base
, NULL
, NULL
, NULL
);
1754 streambuf_setp(&this->base
, reserve
+ read_size
, reserve
+ buffer_size
);
1756 streambuf_setp(&this->base
, NULL
, NULL
);
1760 /* ?stdiofile@stdiobuf@@QAEPAU_iobuf@@XZ */
1761 /* ?stdiofile@stdiobuf@@QEAAPEAU_iobuf@@XZ */
1762 DEFINE_THISCALL_WRAPPER(stdiobuf_stdiofile
, 4)
1763 FILE* __thiscall
stdiobuf_stdiofile(stdiobuf
*this)
1765 TRACE("(%p)\n", this);
1769 /* ?sync@stdiobuf@@UAEHXZ */
1770 /* ?sync@stdiobuf@@UEAAHXZ */
1771 DEFINE_THISCALL_WRAPPER(stdiobuf_sync
, 4)
1772 int __thiscall
stdiobuf_sync(stdiobuf
*this)
1774 TRACE("(%p)\n", this);
1775 if (this->base
.unbuffered
)
1777 /* flush the put area */
1778 if (call_streambuf_overflow(&this->base
, EOF
) == EOF
)
1780 /* flush the get area */
1781 if (this->base
.gptr
< this->base
.egptr
) {
1783 int fd
, mode
, offset
= this->base
.egptr
- this->base
.gptr
;
1784 if ((fd
= fileno(this->file
)) < 0)
1786 mode
= _setmode(fd
, _O_TEXT
);
1788 if (mode
& _O_TEXT
) {
1789 /* in text mode, '\n' in the buffer means '\r\n' in the file */
1790 for (ptr
= this->base
.gptr
; ptr
< this->base
.egptr
; ptr
++)
1794 if (fseek(this->file
, -offset
, SEEK_CUR
))
1796 this->base
.gptr
= this->base
.egptr
;
1801 /* ?underflow@stdiobuf@@UAEHXZ */
1802 /* ?underflow@stdiobuf@@UEAAHXZ */
1803 DEFINE_THISCALL_WRAPPER(stdiobuf_underflow
, 4)
1804 int __thiscall
stdiobuf_underflow(stdiobuf
*this)
1806 TRACE("(%p)\n", this);
1809 if (this->base
.unbuffered
)
1810 return fgetc(this->file
);
1811 if (streambuf_allocate(&this->base
) == EOF
)
1814 if (!this->base
.egptr
) {
1815 /* set the get area to the first half of the buffer */
1816 char *middle
= this->base
.base
+ (this->base
.ebuf
- this->base
.base
) / 2;
1817 streambuf_setg(&this->base
, this->base
.base
, middle
, middle
);
1819 if (this->base
.gptr
>= this->base
.egptr
) {
1820 /* read characters from the file */
1821 int buffer_size
= this->base
.egptr
- this->base
.eback
, read_bytes
;
1822 if (!this->base
.eback
||
1823 (read_bytes
= fread(this->base
.eback
, sizeof(char), buffer_size
, this->file
)) <= 0)
1825 memmove(this->base
.egptr
- read_bytes
, this->base
.eback
, read_bytes
);
1826 this->base
.gptr
= this->base
.egptr
- read_bytes
;
1828 return (unsigned char) *this->base
.gptr
++;
1831 /* ??0ios@@IAE@ABV0@@Z */
1832 /* ??0ios@@IEAA@AEBV0@@Z */
1833 DEFINE_THISCALL_WRAPPER(ios_copy_ctor
, 8)
1834 ios
* __thiscall
ios_copy_ctor(ios
*this, const ios
*copy
)
1836 TRACE("(%p %p)\n", this, copy
);
1838 this->vtable
= &ios_vtable
;
1842 InitializeCriticalSection(&this->lock
);
1843 return ios_assign(this, copy
);
1846 /* ??0ios@@QAE@PAVstreambuf@@@Z */
1847 /* ??0ios@@QEAA@PEAVstreambuf@@@Z */
1848 DEFINE_THISCALL_WRAPPER(ios_sb_ctor
, 8)
1849 ios
* __thiscall
ios_sb_ctor(ios
*this, streambuf
*sb
)
1851 TRACE("(%p %p)\n", this, sb
);
1853 this->vtable
= &ios_vtable
;
1855 this->state
= sb
? IOSTATE_goodbit
: IOSTATE_badbit
;
1856 this->special
[0] = this->special
[1] = 0;
1860 this->precision
= 6;
1864 InitializeCriticalSection(&this->lock
);
1868 /* ??0ios@@IAE@XZ */
1869 /* ??0ios@@IEAA@XZ */
1870 DEFINE_THISCALL_WRAPPER(ios_ctor
, 4)
1871 ios
* __thiscall
ios_ctor(ios
*this)
1873 return ios_sb_ctor(this, NULL
);
1876 /* ??1ios@@UAE@XZ */
1877 /* ??1ios@@UEAA@XZ */
1878 DEFINE_THISCALL_WRAPPER(ios_dtor
, 4)
1879 void __thiscall
ios_dtor(ios
*this)
1881 TRACE("(%p)\n", this);
1883 if (this->delbuf
&& this->sb
)
1884 call_streambuf_vector_dtor(this->sb
, 1);
1886 this->state
= IOSTATE_badbit
;
1887 DeleteCriticalSection(&this->lock
);
1890 /* ??4ios@@IAEAAV0@ABV0@@Z */
1891 /* ??4ios@@IEAAAEAV0@AEBV0@@Z */
1892 DEFINE_THISCALL_WRAPPER(ios_assign
, 8)
1893 ios
* __thiscall
ios_assign(ios
*this, const ios
*rhs
)
1895 TRACE("(%p %p)\n", this, rhs
);
1896 this->state
= rhs
->state
;
1898 this->state
|= IOSTATE_badbit
;
1899 this->tie
= rhs
->tie
;
1900 this->flags
= rhs
->flags
;
1901 this->precision
= (char) rhs
->precision
;
1902 this->fill
= rhs
->fill
;
1903 this->width
= (char) rhs
->width
;
1907 /* ??7ios@@QBEHXZ */
1908 /* ??7ios@@QEBAHXZ */
1909 DEFINE_THISCALL_WRAPPER(ios_op_not
, 4)
1910 int __thiscall
ios_op_not(const ios
*this)
1912 TRACE("(%p)\n", this);
1913 return ios_fail(this);
1916 /* ??Bios@@QBEPAXXZ */
1917 /* ??Bios@@QEBAPEAXXZ */
1918 DEFINE_THISCALL_WRAPPER(ios_op_void
, 4)
1919 void* __thiscall
ios_op_void(const ios
*this)
1921 TRACE("(%p)\n", this);
1922 return ios_fail(this) ? NULL
: (void*)this;
1925 /* ??_Eios@@UAEPAXI@Z */
1926 DEFINE_THISCALL_WRAPPER(ios_vector_dtor
, 8)
1927 ios
* __thiscall
ios_vector_dtor(ios
*this, unsigned int flags
)
1929 TRACE("(%p %x)\n", this, flags
);
1931 /* we have an array, with the number of elements stored before the first object */
1932 INT_PTR i
, *ptr
= (INT_PTR
*)this-1;
1934 for (i
= *ptr
-1; i
>= 0; i
--)
1936 operator_delete(ptr
);
1940 operator_delete(this);
1945 /* ??_Gios@@UAEPAXI@Z */
1946 DEFINE_THISCALL_WRAPPER(ios_scalar_dtor
, 8)
1947 ios
* __thiscall
ios_scalar_dtor(ios
*this, unsigned int flags
)
1949 TRACE("(%p %x)\n", this, flags
);
1951 if (flags
& 1) operator_delete(this);
1955 /* ?bad@ios@@QBEHXZ */
1956 /* ?bad@ios@@QEBAHXZ */
1957 DEFINE_THISCALL_WRAPPER(ios_bad
, 4)
1958 int __thiscall
ios_bad(const ios
*this)
1960 TRACE("(%p)\n", this);
1961 return (this->state
& IOSTATE_badbit
);
1964 /* ?bitalloc@ios@@SAJXZ */
1965 LONG __cdecl
ios_bitalloc(void)
1974 /* ?clear@ios@@QAEXH@Z */
1975 /* ?clear@ios@@QEAAXH@Z */
1976 DEFINE_THISCALL_WRAPPER(ios_clear
, 8)
1977 void __thiscall
ios_clear(ios
*this, int state
)
1979 TRACE("(%p %d)\n", this, state
);
1981 this->state
= state
;
1985 /* ?clrlock@ios@@QAAXXZ */
1986 /* ?clrlock@ios@@QEAAXXZ */
1987 void __cdecl
ios_clrlock(ios
*this)
1989 TRACE("(%p)\n", this);
1990 if (this->do_lock
<= 0)
1993 streambuf_clrlock(this->sb
);
1996 /* ?delbuf@ios@@QAEXH@Z */
1997 /* ?delbuf@ios@@QEAAXH@Z */
1998 DEFINE_THISCALL_WRAPPER(ios_delbuf_set
, 8)
1999 void __thiscall
ios_delbuf_set(ios
*this, int delete)
2001 TRACE("(%p %d)\n", this, delete);
2002 this->delbuf
= delete;
2005 /* ?delbuf@ios@@QBEHXZ */
2006 /* ?delbuf@ios@@QEBAHXZ */
2007 DEFINE_THISCALL_WRAPPER(ios_delbuf_get
, 4)
2008 int __thiscall
ios_delbuf_get(const ios
*this)
2010 TRACE("(%p)\n", this);
2011 return this->delbuf
;
2014 /* ?dec@@YAAAVios@@AAV1@@Z */
2015 /* ?dec@@YAAEAVios@@AEAV1@@Z */
2016 ios
* __cdecl
ios_dec(ios
*this)
2018 TRACE("(%p)\n", this);
2019 ios_setf_mask(this, FLAGS_dec
, ios_basefield
);
2023 /* ?eof@ios@@QBEHXZ */
2024 /* ?eof@ios@@QEBAHXZ */
2025 DEFINE_THISCALL_WRAPPER(ios_eof
, 4)
2026 int __thiscall
ios_eof(const ios
*this)
2028 TRACE("(%p)\n", this);
2029 return (this->state
& IOSTATE_eofbit
);
2032 /* ?fail@ios@@QBEHXZ */
2033 /* ?fail@ios@@QEBAHXZ */
2034 DEFINE_THISCALL_WRAPPER(ios_fail
, 4)
2035 int __thiscall
ios_fail(const ios
*this)
2037 TRACE("(%p)\n", this);
2038 return (this->state
& (IOSTATE_failbit
|IOSTATE_badbit
));
2041 /* ?fill@ios@@QAEDD@Z */
2042 /* ?fill@ios@@QEAADD@Z */
2043 DEFINE_THISCALL_WRAPPER(ios_fill_set
, 8)
2044 char __thiscall
ios_fill_set(ios
*this, char fill
)
2046 char prev
= this->fill
;
2048 TRACE("(%p %d)\n", this, fill
);
2054 /* ?fill@ios@@QBEDXZ */
2055 /* ?fill@ios@@QEBADXZ */
2056 DEFINE_THISCALL_WRAPPER(ios_fill_get
, 4)
2057 char __thiscall
ios_fill_get(const ios
*this)
2059 TRACE("(%p)\n", this);
2063 /* ?flags@ios@@QAEJJ@Z */
2064 /* ?flags@ios@@QEAAJJ@Z */
2065 DEFINE_THISCALL_WRAPPER(ios_flags_set
, 8)
2066 LONG __thiscall
ios_flags_set(ios
*this, LONG flags
)
2068 LONG prev
= this->flags
;
2070 TRACE("(%p %lx)\n", this, flags
);
2072 this->flags
= flags
;
2076 /* ?flags@ios@@QBEJXZ */
2077 /* ?flags@ios@@QEBAJXZ */
2078 DEFINE_THISCALL_WRAPPER(ios_flags_get
, 4)
2079 LONG __thiscall
ios_flags_get(const ios
*this)
2081 TRACE("(%p)\n", this);
2085 /* ?good@ios@@QBEHXZ */
2086 /* ?good@ios@@QEBAHXZ */
2087 DEFINE_THISCALL_WRAPPER(ios_good
, 4)
2088 int __thiscall
ios_good(const ios
*this)
2090 TRACE("(%p)\n", this);
2091 return this->state
== IOSTATE_goodbit
;
2094 /* ?hex@@YAAAVios@@AAV1@@Z */
2095 /* ?hex@@YAAEAVios@@AEAV1@@Z */
2096 ios
* __cdecl
ios_hex(ios
*this)
2098 TRACE("(%p)\n", this);
2099 ios_setf_mask(this, FLAGS_hex
, ios_basefield
);
2103 /* ?init@ios@@IAEXPAVstreambuf@@@Z */
2104 /* ?init@ios@@IEAAXPEAVstreambuf@@@Z */
2105 DEFINE_THISCALL_WRAPPER(ios_init
, 8)
2106 void __thiscall
ios_init(ios
*this, streambuf
*sb
)
2108 TRACE("(%p %p)\n", this, sb
);
2109 if (this->delbuf
&& this->sb
)
2110 call_streambuf_vector_dtor(this->sb
, 1);
2113 this->state
|= IOSTATE_badbit
;
2115 this->state
&= ~IOSTATE_badbit
;
2118 /* ?iword@ios@@QBEAAJH@Z */
2119 /* ?iword@ios@@QEBAAEAJH@Z */
2120 DEFINE_THISCALL_WRAPPER(ios_iword
, 8)
2121 LONG
* __thiscall
ios_iword(const ios
*this, int index
)
2123 TRACE("(%p %d)\n", this, index
);
2124 return &ios_statebuf
[index
];
2127 /* ?lock@ios@@QAAXXZ */
2128 /* ?lock@ios@@QEAAXXZ */
2129 void __cdecl
ios_lock(ios
*this)
2131 TRACE("(%p)\n", this);
2132 if (this->do_lock
< 0)
2133 EnterCriticalSection(&this->lock
);
2136 /* ?lockbuf@ios@@QAAXXZ */
2137 /* ?lockbuf@ios@@QEAAXXZ */
2138 void __cdecl
ios_lockbuf(ios
*this)
2140 TRACE("(%p)\n", this);
2141 streambuf_lock(this->sb
);
2144 /* ?lockc@ios@@KAXXZ */
2145 void __cdecl
ios_lockc(void)
2148 EnterCriticalSection(&ios_static_lock
);
2151 /* ?lockptr@ios@@IAEPAU_CRT_CRITICAL_SECTION@@XZ */
2152 /* ?lockptr@ios@@IEAAPEAU_CRT_CRITICAL_SECTION@@XZ */
2153 DEFINE_THISCALL_WRAPPER(ios_lockptr
, 4)
2154 CRITICAL_SECTION
* __thiscall
ios_lockptr(ios
*this)
2156 TRACE("(%p)\n", this);
2160 /* ?oct@@YAAAVios@@AAV1@@Z */
2161 /* ?oct@@YAAEAVios@@AEAV1@@Z */
2162 ios
* __cdecl
ios_oct(ios
*this)
2164 TRACE("(%p)\n", this);
2165 ios_setf_mask(this, FLAGS_oct
, ios_basefield
);
2169 /* ?precision@ios@@QAEHH@Z */
2170 /* ?precision@ios@@QEAAHH@Z */
2171 DEFINE_THISCALL_WRAPPER(ios_precision_set
, 8)
2172 int __thiscall
ios_precision_set(ios
*this, int prec
)
2174 int prev
= this->precision
;
2176 TRACE("(%p %d)\n", this, prec
);
2178 this->precision
= prec
;
2182 /* ?precision@ios@@QBEHXZ */
2183 /* ?precision@ios@@QEBAHXZ */
2184 DEFINE_THISCALL_WRAPPER(ios_precision_get
, 4)
2185 int __thiscall
ios_precision_get(const ios
*this)
2187 TRACE("(%p)\n", this);
2188 return this->precision
;
2191 /* ?pword@ios@@QBEAAPAXH@Z */
2192 /* ?pword@ios@@QEBAAEAPEAXH@Z */
2193 DEFINE_THISCALL_WRAPPER(ios_pword
, 8)
2194 void** __thiscall
ios_pword(const ios
*this, int index
)
2196 TRACE("(%p %d)\n", this, index
);
2197 return (void**)&ios_statebuf
[index
];
2200 /* ?rdbuf@ios@@QBEPAVstreambuf@@XZ */
2201 /* ?rdbuf@ios@@QEBAPEAVstreambuf@@XZ */
2202 DEFINE_THISCALL_WRAPPER(ios_rdbuf
, 4)
2203 streambuf
* __thiscall
ios_rdbuf(const ios
*this)
2205 TRACE("(%p)\n", this);
2209 /* ?rdstate@ios@@QBEHXZ */
2210 /* ?rdstate@ios@@QEBAHXZ */
2211 DEFINE_THISCALL_WRAPPER(ios_rdstate
, 4)
2212 int __thiscall
ios_rdstate(const ios
*this)
2214 TRACE("(%p)\n", this);
2218 /* ?setf@ios@@QAEJJ@Z */
2219 /* ?setf@ios@@QEAAJJ@Z */
2220 DEFINE_THISCALL_WRAPPER(ios_setf
, 8)
2221 LONG __thiscall
ios_setf(ios
*this, LONG flags
)
2223 LONG prev
= this->flags
;
2225 TRACE("(%p %lx)\n", this, flags
);
2228 this->flags
|= flags
;
2233 /* ?setf@ios@@QAEJJJ@Z */
2234 /* ?setf@ios@@QEAAJJJ@Z */
2235 DEFINE_THISCALL_WRAPPER(ios_setf_mask
, 12)
2236 LONG __thiscall
ios_setf_mask(ios
*this, LONG flags
, LONG mask
)
2238 LONG prev
= this->flags
;
2240 TRACE("(%p %lx %lx)\n", this, flags
, mask
);
2243 this->flags
= (this->flags
& (~mask
)) | (flags
& mask
);
2248 /* ?setlock@ios@@QAAXXZ */
2249 /* ?setlock@ios@@QEAAXXZ */
2250 void __cdecl
ios_setlock(ios
*this)
2252 TRACE("(%p)\n", this);
2255 streambuf_setlock(this->sb
);
2258 /* ?tie@ios@@QAEPAVostream@@PAV2@@Z */
2259 /* ?tie@ios@@QEAAPEAVostream@@PEAV2@@Z */
2260 DEFINE_THISCALL_WRAPPER(ios_tie_set
, 8)
2261 ostream
* __thiscall
ios_tie_set(ios
*this, ostream
*ostr
)
2263 ostream
*prev
= this->tie
;
2265 TRACE("(%p %p)\n", this, ostr
);
2271 /* ?tie@ios@@QBEPAVostream@@XZ */
2272 /* ?tie@ios@@QEBAPEAVostream@@XZ */
2273 DEFINE_THISCALL_WRAPPER(ios_tie_get
, 4)
2274 ostream
* __thiscall
ios_tie_get(const ios
*this)
2276 TRACE("(%p)\n", this);
2280 /* ?unlock@ios@@QAAXXZ */
2281 /* ?unlock@ios@@QEAAXXZ */
2282 void __cdecl
ios_unlock(ios
*this)
2284 TRACE("(%p)\n", this);
2285 if (this->do_lock
< 0)
2286 LeaveCriticalSection(&this->lock
);
2289 /* ?unlockbuf@ios@@QAAXXZ */
2290 /* ?unlockbuf@ios@@QEAAXXZ */
2291 void __cdecl
ios_unlockbuf(ios
*this)
2293 TRACE("(%p)\n", this);
2294 streambuf_unlock(this->sb
);
2297 /* ?unlockc@ios@@KAXXZ */
2298 void __cdecl
ios_unlockc(void)
2301 LeaveCriticalSection(&ios_static_lock
);
2304 /* ?unsetf@ios@@QAEJJ@Z */
2305 /* ?unsetf@ios@@QEAAJJ@Z */
2306 DEFINE_THISCALL_WRAPPER(ios_unsetf
, 8)
2307 LONG __thiscall
ios_unsetf(ios
*this, LONG flags
)
2309 LONG prev
= this->flags
;
2311 TRACE("(%p %lx)\n", this, flags
);
2314 this->flags
&= ~flags
;
2319 /* ?width@ios@@QAEHH@Z */
2320 /* ?width@ios@@QEAAHH@Z */
2321 DEFINE_THISCALL_WRAPPER(ios_width_set
, 8)
2322 int __thiscall
ios_width_set(ios
*this, int width
)
2324 int prev
= this->width
;
2326 TRACE("(%p %d)\n", this, width
);
2328 this->width
= width
;
2332 /* ?width@ios@@QBEHXZ */
2333 /* ?width@ios@@QEBAHXZ */
2334 DEFINE_THISCALL_WRAPPER(ios_width_get
, 4)
2335 int __thiscall
ios_width_get(const ios
*this)
2337 TRACE("(%p)\n", this);
2341 /* ?xalloc@ios@@SAHXZ */
2342 int __cdecl
ios_xalloc(void)
2349 ret
= (ios_curindex
< STATEBUF_SIZE
-1) ? ++ios_curindex
: -1;
2354 static inline ios
* ostream_get_ios(const ostream
*this)
2356 return (ios
*)((char*)this + this->vbtable
[1]);
2359 static inline ios
* ostream_to_ios(const ostream
*this)
2361 return (ios
*)((char*)this + ostream_vbtable
[1]);
2364 static inline ostream
* ios_to_ostream(const ios
*base
)
2366 return (ostream
*)((char*)base
- ostream_vbtable
[1]);
2369 /* ??0ostream@@IAE@XZ */
2370 /* ??0ostream@@IEAA@XZ */
2371 DEFINE_THISCALL_WRAPPER(ostream_ctor
, 8)
2372 ostream
* __thiscall
ostream_ctor(ostream
*this, BOOL virt_init
)
2376 TRACE("(%p %d)\n", this, virt_init
);
2379 this->vbtable
= ostream_vbtable
;
2380 base
= ostream_get_ios(this);
2383 base
= ostream_get_ios(this);
2384 base
->vtable
= &ostream_vtable
;
2389 /* ??0ostream@@QAE@PAVstreambuf@@@Z */
2390 /* ??0ostream@@QEAA@PEAVstreambuf@@@Z */
2391 DEFINE_THISCALL_WRAPPER(ostream_sb_ctor
, 12)
2392 ostream
* __thiscall
ostream_sb_ctor(ostream
*this, streambuf
*sb
, BOOL virt_init
)
2394 TRACE("(%p %p %d)\n", this, sb
, virt_init
);
2395 ostream_ctor(this, virt_init
);
2396 ios_init(ostream_get_ios(this), sb
);
2400 /* ??0ostream@@IAE@ABV0@@Z */
2401 /* ??0ostream@@IEAA@AEBV0@@Z */
2402 DEFINE_THISCALL_WRAPPER(ostream_copy_ctor
, 12)
2403 ostream
* __thiscall
ostream_copy_ctor(ostream
*this, const ostream
*copy
, BOOL virt_init
)
2405 return ostream_sb_ctor(this, ostream_get_ios(copy
)->sb
, virt_init
);
2408 /* ??1ostream@@UAE@XZ */
2409 /* ??1ostream@@UEAA@XZ */
2410 /* ??1ostream_withassign@@UAE@XZ */
2411 /* ??1ostream_withassign@@UEAA@XZ */
2412 /* ??1ostrstream@@UAE@XZ */
2413 /* ??1ostrstream@@UEAA@XZ */
2414 /* ??1ofstream@@UAE@XZ */
2415 /* ??1ofstream@@UEAA@XZ */
2416 DEFINE_THISCALL_WRAPPER(ostream_dtor
, 4)
2417 void __thiscall
ostream_dtor(ios
*base
)
2419 ostream
*this = ios_to_ostream(base
);
2421 TRACE("(%p)\n", this);
2424 /* ??4ostream@@IAEAAV0@PAVstreambuf@@@Z */
2425 /* ??4ostream@@IEAAAEAV0@PEAVstreambuf@@@Z */
2426 /* ??4ostream_withassign@@QAEAAVostream@@PAVstreambuf@@@Z */
2427 /* ??4ostream_withassign@@QEAAAEAVostream@@PEAVstreambuf@@@Z */
2428 DEFINE_THISCALL_WRAPPER(ostream_assign_sb
, 8)
2429 ostream
* __thiscall
ostream_assign_sb(ostream
*this, streambuf
*sb
)
2431 ios
*base
= ostream_get_ios(this);
2433 TRACE("(%p %p)\n", this, sb
);
2436 base
->state
&= IOSTATE_badbit
;
2440 base
->precision
= 6;
2446 /* ??4ostream@@IAEAAV0@ABV0@@Z */
2447 /* ??4ostream@@IEAAAEAV0@AEBV0@@Z */
2448 /* ??4ostream_withassign@@QAEAAV0@ABV0@@Z */
2449 /* ??4ostream_withassign@@QEAAAEAV0@AEBV0@@Z */
2450 /* ??4ostream_withassign@@QAEAAVostream@@ABV1@@Z */
2451 /* ??4ostream_withassign@@QEAAAEAVostream@@AEBV1@@Z */
2452 /* ??4ostrstream@@QAEAAV0@ABV0@@Z */
2453 /* ??4ostrstream@@QEAAAEAV0@AEBV0@@Z */
2454 /* ??4ofstream@@QAEAAV0@ABV0@@Z */
2455 /* ??4ofstream@@QEAAAEAV0@AEBV0@@Z */
2456 DEFINE_THISCALL_WRAPPER(ostream_assign
, 8)
2457 ostream
* __thiscall
ostream_assign(ostream
*this, const ostream
*rhs
)
2459 return ostream_assign_sb(this, ostream_get_ios(rhs
)->sb
);
2462 /* ??_Dostream@@QAEXXZ */
2463 /* ??_Dostream@@QEAAXXZ */
2464 /* ??_Dostream_withassign@@QAEXXZ */
2465 /* ??_Dostream_withassign@@QEAAXXZ */
2466 /* ??_Dostrstream@@QAEXXZ */
2467 /* ??_Dostrstream@@QEAAXXZ */
2468 /* ??_Dofstream@@QAEXXZ */
2469 /* ??_Dofstream@@QEAAXXZ */
2470 DEFINE_THISCALL_WRAPPER(ostream_vbase_dtor
, 4)
2471 void __thiscall
ostream_vbase_dtor(ostream
*this)
2473 ios
*base
= ostream_to_ios(this);
2475 TRACE("(%p)\n", this);
2481 /* ??_Eostream@@UAEPAXI@Z */
2482 /* ??_Eostream_withassign@@UAEPAXI@Z */
2483 /* ??_Eostrstream@@UAEPAXI@Z */
2484 /* ??_Eofstream@@UAEPAXI@Z */
2485 DEFINE_THISCALL_WRAPPER(ostream_vector_dtor
, 8)
2486 ostream
* __thiscall
ostream_vector_dtor(ios
*base
, unsigned int flags
)
2488 ostream
*this = ios_to_ostream(base
);
2490 TRACE("(%p %x)\n", this, flags
);
2493 /* we have an array, with the number of elements stored before the first object */
2494 INT_PTR i
, *ptr
= (INT_PTR
*)this-1;
2496 for (i
= *ptr
-1; i
>= 0; i
--)
2497 ostream_vbase_dtor(this+i
);
2498 operator_delete(ptr
);
2500 ostream_vbase_dtor(this);
2502 operator_delete(this);
2507 /* ??_Gostream@@UAEPAXI@Z */
2508 /* ??_Gostream_withassign@@UAEPAXI@Z */
2509 /* ??_Gostrstream@@UAEPAXI@Z */
2510 /* ??_Gofstream@@UAEPAXI@Z */
2511 DEFINE_THISCALL_WRAPPER(ostream_scalar_dtor
, 8)
2512 ostream
* __thiscall
ostream_scalar_dtor(ios
*base
, unsigned int flags
)
2514 ostream
*this = ios_to_ostream(base
);
2516 TRACE("(%p %x)\n", this, flags
);
2518 ostream_vbase_dtor(this);
2519 if (flags
& 1) operator_delete(this);
2523 /* ?flush@ostream@@QAEAAV1@XZ */
2524 /* ?flush@ostream@@QEAAAEAV1@XZ */
2525 DEFINE_THISCALL_WRAPPER(ostream_flush
, 4)
2526 ostream
* __thiscall
ostream_flush(ostream
*this)
2528 ios
*base
= ostream_get_ios(this);
2530 TRACE("(%p)\n", this);
2533 if (call_streambuf_sync(base
->sb
) == EOF
)
2534 ios_clear(base
, base
->state
| IOSTATE_failbit
);
2535 ios_unlockbuf(base
);
2539 /* ?opfx@ostream@@QAEHXZ */
2540 /* ?opfx@ostream@@QEAAHXZ */
2541 DEFINE_THISCALL_WRAPPER(ostream_opfx
, 4)
2542 int __thiscall
ostream_opfx(ostream
*this)
2544 ios
*base
= ostream_get_ios(this);
2546 TRACE("(%p)\n", this);
2548 if (!ios_good(base
)) {
2549 ios_clear(base
, base
->state
| IOSTATE_failbit
);
2555 ostream_flush(base
->tie
);
2559 /* ?osfx@ostream@@QAEXXZ */
2560 /* ?osfx@ostream@@QEAAXXZ */
2561 DEFINE_THISCALL_WRAPPER(ostream_osfx
, 4)
2562 void __thiscall
ostream_osfx(ostream
*this)
2564 ios
*base
= ostream_get_ios(this);
2566 TRACE("(%p)\n", this);
2568 ios_unlockbuf(base
);
2569 ios_width_set(base
, 0);
2570 if (base
->flags
& FLAGS_unitbuf
)
2571 ostream_flush(this);
2572 if (base
->flags
& FLAGS_stdio
) {
2579 /* ?put@ostream@@QAEAAV1@C@Z */
2580 /* ?put@ostream@@QEAAAEAV1@C@Z */
2581 /* ?put@ostream@@QAEAAV1@D@Z */
2582 /* ?put@ostream@@QEAAAEAV1@D@Z */
2583 /* ?put@ostream@@QAEAAV1@E@Z */
2584 /* ?put@ostream@@QEAAAEAV1@E@Z */
2585 DEFINE_THISCALL_WRAPPER(ostream_put
, 8)
2586 ostream
* __thiscall
ostream_put(ostream
*this, char c
)
2588 ios
*base
= ostream_get_ios(this);
2590 TRACE("(%p %c)\n", this, c
);
2592 if (ostream_opfx(this)) {
2593 if (streambuf_sputc(base
->sb
, c
) == EOF
)
2594 base
->state
= IOSTATE_badbit
| IOSTATE_failbit
;
2600 /* ?seekp@ostream@@QAEAAV1@J@Z */
2601 /* ?seekp@ostream@@QEAAAEAV1@J@Z */
2602 DEFINE_THISCALL_WRAPPER(ostream_seekp
, 8)
2603 ostream
* __thiscall
ostream_seekp(ostream
*this, streampos pos
)
2605 ios
*base
= ostream_get_ios(this);
2607 TRACE("(%p %ld)\n", this, pos
);
2610 if (streambuf_seekpos(base
->sb
, pos
, OPENMODE_out
) == EOF
)
2611 ios_clear(base
, base
->state
| IOSTATE_failbit
);
2612 ios_unlockbuf(base
);
2616 /* ?seekp@ostream@@QAEAAV1@JW4seek_dir@ios@@@Z */
2617 /* ?seekp@ostream@@QEAAAEAV1@JW4seek_dir@ios@@@Z */
2618 DEFINE_THISCALL_WRAPPER(ostream_seekp_offset
, 12)
2619 ostream
* __thiscall
ostream_seekp_offset(ostream
*this, streamoff off
, ios_seek_dir dir
)
2621 ios
*base
= ostream_get_ios(this);
2623 TRACE("(%p %ld %d)\n", this, off
, dir
);
2626 if (call_streambuf_seekoff(base
->sb
, off
, dir
, OPENMODE_out
) == EOF
)
2627 ios_clear(base
, base
->state
| IOSTATE_failbit
);
2628 ios_unlockbuf(base
);
2632 /* ?tellp@ostream@@QAEJXZ */
2633 /* ?tellp@ostream@@QEAAJXZ */
2634 DEFINE_THISCALL_WRAPPER(ostream_tellp
, 4)
2635 streampos __thiscall
ostream_tellp(ostream
*this)
2637 ios
*base
= ostream_get_ios(this);
2640 TRACE("(%p)\n", this);
2643 if ((pos
= call_streambuf_seekoff(base
->sb
, 0, SEEKDIR_cur
, OPENMODE_out
)) == EOF
)
2644 ios_clear(base
, base
->state
| IOSTATE_failbit
);
2645 ios_unlockbuf(base
);
2649 /* ?write@ostream@@QAEAAV1@PBCH@Z */
2650 /* ?write@ostream@@QEAAAEAV1@PEBCH@Z */
2651 /* ?write@ostream@@QAEAAV1@PBDH@Z */
2652 /* ?write@ostream@@QEAAAEAV1@PEBDH@Z */
2653 /* ?write@ostream@@QAEAAV1@PBEH@Z */
2654 /* ?write@ostream@@QEAAAEAV1@PEBEH@Z */
2655 DEFINE_THISCALL_WRAPPER(ostream_write
, 12)
2656 ostream
* __thiscall
ostream_write(ostream
*this, const char *str
, int count
)
2658 ios
*base
= ostream_get_ios(this);
2660 TRACE("(%p %p %d)\n", this, str
, count
);
2662 if (ostream_opfx(this)) {
2663 if (streambuf_sputn(base
->sb
, str
, count
) != count
)
2664 base
->state
= IOSTATE_badbit
| IOSTATE_failbit
;
2670 static ostream
* ostream_writepad_len(ostream
*this, const char *str1
, const char *str2
, int len2
)
2672 ios
*base
= ostream_get_ios(this);
2673 int len1
= strlen(str1
), i
;
2675 TRACE("(%p %p %p %d)\n", this, str1
, str2
, len2
);
2677 /* left of the padding */
2678 if (base
->flags
& (FLAGS_left
|FLAGS_internal
)) {
2679 if (streambuf_sputn(base
->sb
, str1
, len1
) != len1
)
2680 base
->state
|= IOSTATE_failbit
| IOSTATE_badbit
;
2681 if (!(base
->flags
& FLAGS_internal
))
2682 if (streambuf_sputn(base
->sb
, str2
, len2
) != len2
)
2683 base
->state
|= IOSTATE_failbit
| IOSTATE_badbit
;
2685 /* add padding to fill the width */
2686 for (i
= len1
+ len2
; i
< base
->width
; i
++)
2687 if (streambuf_sputc(base
->sb
, base
->fill
) == EOF
)
2688 base
->state
|= IOSTATE_failbit
| IOSTATE_badbit
;
2689 /* right of the padding */
2690 if ((base
->flags
& (FLAGS_left
|FLAGS_internal
)) != FLAGS_left
) {
2691 if (!(base
->flags
& (FLAGS_left
|FLAGS_internal
)))
2692 if (streambuf_sputn(base
->sb
, str1
, len1
) != len1
)
2693 base
->state
|= IOSTATE_failbit
| IOSTATE_badbit
;
2694 if (streambuf_sputn(base
->sb
, str2
, len2
) != len2
)
2695 base
->state
|= IOSTATE_failbit
| IOSTATE_badbit
;
2700 /* ?writepad@ostream@@AAEAAV1@PBD0@Z */
2701 /* ?writepad@ostream@@AEAAAEAV1@PEBD0@Z */
2702 DEFINE_THISCALL_WRAPPER(ostream_writepad
, 12)
2703 ostream
* __thiscall
ostream_writepad(ostream
*this, const char *str1
, const char *str2
)
2705 return ostream_writepad_len(this, str1
, str2
, strlen(str2
));
2708 static ostream
* ostream_internal_print_integer(ostream
*ostr
, int n
, BOOL unsig
, BOOL shrt
)
2710 ios
*base
= ostream_get_ios(ostr
);
2711 char prefix_str
[3] = {0}, number_str
[12], sprintf_fmt
[4] = {'%','d',0};
2713 TRACE("(%p %d %d %d)\n", ostr
, n
, unsig
, shrt
);
2715 if (ostream_opfx(ostr
)) {
2716 if (base
->flags
& FLAGS_hex
) {
2717 sprintf_fmt
[1] = (base
->flags
& FLAGS_uppercase
) ? 'X' : 'x';
2718 if (base
->flags
& FLAGS_showbase
) {
2719 prefix_str
[0] = '0';
2720 prefix_str
[1] = (base
->flags
& FLAGS_uppercase
) ? 'X' : 'x';
2722 } else if (base
->flags
& FLAGS_oct
) {
2723 sprintf_fmt
[1] = 'o';
2724 if (base
->flags
& FLAGS_showbase
)
2725 prefix_str
[0] = '0';
2726 } else { /* FLAGS_dec */
2728 sprintf_fmt
[1] = 'u';
2729 if ((base
->flags
& FLAGS_showpos
) && n
!= 0 && (unsig
|| n
> 0))
2730 prefix_str
[0] = '+';
2734 sprintf_fmt
[2] = sprintf_fmt
[1];
2735 sprintf_fmt
[1] = 'h';
2738 if (sprintf(number_str
, sprintf_fmt
, n
) > 0)
2739 ostream_writepad(ostr
, prefix_str
, number_str
);
2741 base
->state
|= IOSTATE_failbit
;
2747 static ostream
* ostream_internal_print_float(ostream
*ostr
, double d
, BOOL dbl
)
2749 ios
*base
= ostream_get_ios(ostr
);
2750 char prefix_str
[2] = {0}, number_str
[24], sprintf_fmt
[6] = {'%','.','*','f',0};
2751 int prec
, max_prec
= dbl
? 15 : 6;
2752 int str_length
= 1; /* null end char */
2754 TRACE("(%p %lf %d)\n", ostr
, d
, dbl
);
2756 if (ostream_opfx(ostr
)) {
2757 if ((base
->flags
& FLAGS_showpos
) && d
> 0) {
2758 prefix_str
[0] = '+';
2759 str_length
++; /* plus sign */
2761 if ((base
->flags
& (FLAGS_scientific
|FLAGS_fixed
)) == FLAGS_scientific
)
2762 sprintf_fmt
[3] = (base
->flags
& FLAGS_uppercase
) ? 'E' : 'e';
2763 else if ((base
->flags
& (FLAGS_scientific
|FLAGS_fixed
)) != FLAGS_fixed
)
2764 sprintf_fmt
[3] = (base
->flags
& FLAGS_uppercase
) ? 'G' : 'g';
2765 if (base
->flags
& FLAGS_showpoint
) {
2766 sprintf_fmt
[4] = sprintf_fmt
[3];
2767 sprintf_fmt
[3] = sprintf_fmt
[2];
2768 sprintf_fmt
[2] = sprintf_fmt
[1];
2769 sprintf_fmt
[1] = '#';
2772 prec
= (base
->precision
>= 0 && base
->precision
<= max_prec
) ? base
->precision
: max_prec
;
2773 str_length
+= _scprintf(sprintf_fmt
, prec
, d
); /* number representation */
2774 if (str_length
> 24) {
2775 /* when the output length exceeds 24 characters, Windows prints an empty string with padding */
2776 ostream_writepad(ostr
, "", "");
2778 if (sprintf(number_str
, sprintf_fmt
, prec
, d
) > 0)
2779 ostream_writepad(ostr
, prefix_str
, number_str
);
2781 base
->state
|= IOSTATE_failbit
;
2788 /* ??6ostream@@QAEAAV0@C@Z */
2789 /* ??6ostream@@QEAAAEAV0@C@Z */
2790 /* ??6ostream@@QAEAAV0@D@Z */
2791 /* ??6ostream@@QEAAAEAV0@D@Z */
2792 /* ??6ostream@@QAEAAV0@E@Z */
2793 /* ??6ostream@@QEAAAEAV0@E@Z */
2794 DEFINE_THISCALL_WRAPPER(ostream_print_char
, 8)
2795 ostream
* __thiscall
ostream_print_char(ostream
*this, char c
)
2797 TRACE("(%p %d)\n", this, c
);
2799 if (ostream_opfx(this)) {
2800 ostream_writepad_len(this, "", &c
, 1);
2806 /* ??6ostream@@QAEAAV0@PBC@Z */
2807 /* ??6ostream@@QEAAAEAV0@PEBC@Z */
2808 /* ??6ostream@@QAEAAV0@PBD@Z */
2809 /* ??6ostream@@QEAAAEAV0@PEBD@Z */
2810 /* ??6ostream@@QAEAAV0@PBE@Z */
2811 /* ??6ostream@@QEAAAEAV0@PEBE@Z */
2812 DEFINE_THISCALL_WRAPPER(ostream_print_str
, 8)
2813 ostream
* __thiscall
ostream_print_str(ostream
*this, const char *str
)
2815 TRACE("(%p %s)\n", this, str
);
2816 if (ostream_opfx(this)) {
2817 ostream_writepad(this, "", str
);
2823 /* ??6ostream@@QAEAAV0@F@Z */
2824 /* ??6ostream@@QEAAAEAV0@F@Z */
2825 DEFINE_THISCALL_WRAPPER(ostream_print_short
, 8)
2826 ostream
* __thiscall
ostream_print_short(ostream
*this, short n
)
2828 return ostream_internal_print_integer(this, n
, FALSE
, TRUE
);
2831 /* ??6ostream@@QAEAAV0@G@Z */
2832 /* ??6ostream@@QEAAAEAV0@G@Z */
2833 DEFINE_THISCALL_WRAPPER(ostream_print_unsigned_short
, 8)
2834 ostream
* __thiscall
ostream_print_unsigned_short(ostream
*this, unsigned short n
)
2836 return ostream_internal_print_integer(this, n
, TRUE
, TRUE
);
2839 /* ??6ostream@@QAEAAV0@H@Z */
2840 /* ??6ostream@@QEAAAEAV0@H@Z */
2841 /* ??6ostream@@QAEAAV0@J@Z */
2842 /* ??6ostream@@QEAAAEAV0@J@Z */
2843 DEFINE_THISCALL_WRAPPER(ostream_print_int
, 8)
2844 ostream
* __thiscall
ostream_print_int(ostream
*this, int n
)
2846 return ostream_internal_print_integer(this, n
, FALSE
, FALSE
);
2849 /* ??6ostream@@QAEAAV0@I@Z */
2850 /* ??6ostream@@QEAAAEAV0@I@Z */
2851 /* ??6ostream@@QAEAAV0@K@Z */
2852 /* ??6ostream@@QEAAAEAV0@K@Z */
2853 DEFINE_THISCALL_WRAPPER(ostream_print_unsigned_int
, 8)
2854 ostream
* __thiscall
ostream_print_unsigned_int(ostream
*this, unsigned int n
)
2856 return ostream_internal_print_integer(this, n
, TRUE
, FALSE
);
2859 /* ??6ostream@@QAEAAV0@M@Z */
2860 /* ??6ostream@@QEAAAEAV0@M@Z */
2861 DEFINE_THISCALL_WRAPPER(ostream_print_float
, 8)
2862 ostream
* __thiscall
ostream_print_float(ostream
*this, float f
)
2864 return ostream_internal_print_float(this, f
, FALSE
);
2867 /* ??6ostream@@QAEAAV0@N@Z */
2868 /* ??6ostream@@QEAAAEAV0@N@Z */
2869 /* ??6ostream@@QAEAAV0@O@Z */
2870 /* ??6ostream@@QEAAAEAV0@O@Z */
2871 DEFINE_THISCALL_WRAPPER(ostream_print_double
, 12)
2872 ostream
* __thiscall
ostream_print_double(ostream
*this, double d
)
2874 return ostream_internal_print_float(this, d
, TRUE
);
2877 /* ??6ostream@@QAEAAV0@PBX@Z */
2878 /* ??6ostream@@QEAAAEAV0@PEBX@Z */
2879 DEFINE_THISCALL_WRAPPER(ostream_print_ptr
, 8)
2880 ostream
* __thiscall
ostream_print_ptr(ostream
*this, const void *ptr
)
2882 ios
*base
= ostream_get_ios(this);
2883 char prefix_str
[3] = {'0','x',0}, pointer_str
[17];
2885 TRACE("(%p %p)\n", this, ptr
);
2887 if (ostream_opfx(this)) {
2888 if (ptr
&& base
->flags
& FLAGS_uppercase
)
2889 prefix_str
[1] = 'X';
2891 if (sprintf(pointer_str
, "%p", ptr
) > 0)
2892 ostream_writepad(this, prefix_str
, pointer_str
);
2894 base
->state
|= IOSTATE_failbit
;
2900 /* ??6ostream@@QAEAAV0@PAVstreambuf@@@Z */
2901 /* ??6ostream@@QEAAAEAV0@PEAVstreambuf@@@Z */
2902 DEFINE_THISCALL_WRAPPER(ostream_print_streambuf
, 8)
2903 ostream
* __thiscall
ostream_print_streambuf(ostream
*this, streambuf
*sb
)
2905 ios
*base
= ostream_get_ios(this);
2908 TRACE("(%p %p)\n", this, sb
);
2910 if (ostream_opfx(this)) {
2911 while ((c
= streambuf_sbumpc(sb
)) != EOF
) {
2912 if (streambuf_sputc(base
->sb
, c
) == EOF
) {
2913 base
->state
|= IOSTATE_failbit
;
2922 /* ??6ostream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z */
2923 /* ??6ostream@@QEAAAEAV0@P6AAEAV0@AEAV0@@Z@Z */
2924 DEFINE_THISCALL_WRAPPER(ostream_print_manip
, 8)
2925 ostream
* __thiscall
ostream_print_manip(ostream
*this, ostream
* (__cdecl
*func
)(ostream
*))
2927 TRACE("(%p %p)\n", this, func
);
2931 /* ??6ostream@@QAEAAV0@P6AAAVios@@AAV1@@Z@Z */
2932 /* ??6ostream@@QEAAAEAV0@P6AAEAVios@@AEAV1@@Z@Z */
2933 DEFINE_THISCALL_WRAPPER(ostream_print_ios_manip
, 8)
2934 ostream
* __thiscall
ostream_print_ios_manip(ostream
*this, ios
* (__cdecl
*func
)(ios
*))
2936 TRACE("(%p %p)\n", this, func
);
2937 func(ostream_get_ios(this));
2941 /* ?endl@@YAAAVostream@@AAV1@@Z */
2942 /* ?endl@@YAAEAVostream@@AEAV1@@Z */
2943 ostream
* __cdecl
ostream_endl(ostream
*this)
2945 TRACE("(%p)\n", this);
2946 ostream_put(this, '\n');
2947 return ostream_flush(this);
2950 /* ?ends@@YAAAVostream@@AAV1@@Z */
2951 /* ?ends@@YAAEAVostream@@AEAV1@@Z */
2952 ostream
* __cdecl
ostream_ends(ostream
*this)
2954 TRACE("(%p)\n", this);
2955 return ostream_put(this, 0);
2958 /* ?flush@@YAAAVostream@@AAV1@@Z */
2959 /* ?flush@@YAAEAVostream@@AEAV1@@Z */
2960 ostream
* __cdecl
ostream_flush_manip(ostream
*this)
2962 TRACE("(%p)\n", this);
2963 return ostream_flush(this);
2966 /* ??0ostream_withassign@@QAE@ABV0@@Z */
2967 /* ??0ostream_withassign@@QEAA@AEBV0@@Z */
2968 DEFINE_THISCALL_WRAPPER(ostream_withassign_copy_ctor
, 12)
2969 ostream
* __thiscall
ostream_withassign_copy_ctor(ostream
*this, const ostream
*copy
, BOOL virt_init
)
2971 ios
*base
, *base_copy
;
2973 TRACE("(%p %p %d)\n", this, copy
, virt_init
);
2975 base_copy
= ostream_get_ios(copy
);
2977 this->vbtable
= ostream_vbtable
;
2978 base
= ostream_get_ios(this);
2979 ios_copy_ctor(base
, base_copy
);
2981 base
= ostream_get_ios(this);
2982 ios_init(base
, base_copy
->sb
);
2983 base
->vtable
= &ostream_withassign_vtable
;
2988 /* ??0ostream_withassign@@QAE@PAVstreambuf@@@Z */
2989 /* ??0ostream_withassign@@QEAA@PEAVstreambuf@@@Z */
2990 DEFINE_THISCALL_WRAPPER(ostream_withassign_sb_ctor
, 12)
2991 ostream
* __thiscall
ostream_withassign_sb_ctor(ostream
*this, streambuf
*sb
, BOOL virt_init
)
2995 TRACE("(%p %p %d)\n", this, sb
, virt_init
);
2997 ostream_sb_ctor(this, sb
, virt_init
);
2998 base
= ostream_get_ios(this);
2999 base
->vtable
= &ostream_withassign_vtable
;
3003 /* ??0ostream_withassign@@QAE@XZ */
3004 /* ??0ostream_withassign@@QEAA@XZ */
3005 DEFINE_THISCALL_WRAPPER(ostream_withassign_ctor
, 8)
3006 ostream
* __thiscall
ostream_withassign_ctor(ostream
*this, BOOL virt_init
)
3010 TRACE("(%p %d)\n", this, virt_init
);
3012 ostream_ctor(this, virt_init
);
3013 base
= ostream_get_ios(this);
3014 base
->vtable
= &ostream_withassign_vtable
;
3018 static ostream
* ostrstream_internal_sb_ctor(ostream
*this, strstreambuf
*ssb
, BOOL virt_init
)
3023 ostream_sb_ctor(this, &ssb
->base
, virt_init
);
3025 ostream_ctor(this, virt_init
);
3026 base
= ostream_get_ios(this);
3027 base
->vtable
= &ostrstream_vtable
;
3032 /* ??0ostrstream@@QAE@ABV0@@Z */
3033 /* ??0ostrstream@@QEAA@AEBV0@@Z */
3034 DEFINE_THISCALL_WRAPPER(ostrstream_copy_ctor
, 12)
3035 ostream
* __thiscall
ostrstream_copy_ctor(ostream
*this, const ostream
*copy
, BOOL virt_init
)
3037 TRACE("(%p %p %d)\n", this, copy
, virt_init
);
3038 ostream_withassign_copy_ctor(this, copy
, virt_init
);
3039 ostream_get_ios(this)->vtable
= &ostrstream_vtable
;
3043 /* ??0ostrstream@@QAE@PADHH@Z */
3044 /* ??0ostrstream@@QEAA@PEADHH@Z */
3045 DEFINE_THISCALL_WRAPPER(ostrstream_buffer_ctor
, 20)
3046 ostream
* __thiscall
ostrstream_buffer_ctor(ostream
*this, char *buffer
, int length
, int mode
, BOOL virt_init
)
3048 strstreambuf
*ssb
= operator_new(sizeof(strstreambuf
));
3050 TRACE("(%p %p %d %d %d)\n", this, buffer
, length
, mode
, virt_init
);
3053 FIXME("out of memory\n");
3057 strstreambuf_buffer_ctor(ssb
, buffer
, length
, buffer
);
3058 if (mode
& (OPENMODE_app
|OPENMODE_ate
))
3059 ssb
->base
.pptr
= buffer
+ strlen(buffer
);
3061 return ostrstream_internal_sb_ctor(this, ssb
, virt_init
);
3064 /* ??0ostrstream@@QAE@XZ */
3065 /* ??0ostrstream@@QEAA@XZ */
3066 DEFINE_THISCALL_WRAPPER(ostrstream_ctor
, 8)
3067 ostream
* __thiscall
ostrstream_ctor(ostream
*this, BOOL virt_init
)
3069 strstreambuf
*ssb
= operator_new(sizeof(strstreambuf
));
3071 TRACE("(%p %d)\n", this, virt_init
);
3074 FIXME("out of memory\n");
3078 strstreambuf_ctor(ssb
);
3080 return ostrstream_internal_sb_ctor(this, ssb
, virt_init
);
3083 /* ?pcount@ostrstream@@QBEHXZ */
3084 /* ?pcount@ostrstream@@QEBAHXZ */
3085 DEFINE_THISCALL_WRAPPER(ostrstream_pcount
, 4)
3086 int __thiscall
ostrstream_pcount(const ostream
*this)
3088 return streambuf_out_waiting(ostream_get_ios(this)->sb
);
3091 /* ?rdbuf@ostrstream@@QBEPAVstrstreambuf@@XZ */
3092 /* ?rdbuf@ostrstream@@QEBAPEAVstrstreambuf@@XZ */
3093 DEFINE_THISCALL_WRAPPER(ostrstream_rdbuf
, 4)
3094 strstreambuf
* __thiscall
ostrstream_rdbuf(const ostream
*this)
3096 return (strstreambuf
*) ostream_get_ios(this)->sb
;
3099 /* ?str@ostrstream@@QAEPADXZ */
3100 /* ?str@ostrstream@@QEAAPEADXZ */
3101 DEFINE_THISCALL_WRAPPER(ostrstream_str
, 4)
3102 char* __thiscall
ostrstream_str(ostream
*this)
3104 return strstreambuf_str(ostrstream_rdbuf(this));
3107 /* ??0ofstream@@QAE@ABV0@@Z */
3108 /* ??0ofstream@@QEAA@AEBV0@@Z */
3109 DEFINE_THISCALL_WRAPPER(ofstream_copy_ctor
, 12)
3110 ostream
* __thiscall
ofstream_copy_ctor(ostream
*this, const ostream
*copy
, BOOL virt_init
)
3112 TRACE("(%p %p %d)\n", this, copy
, virt_init
);
3113 ostream_withassign_copy_ctor(this, copy
, virt_init
);
3114 ostream_get_ios(this)->vtable
= &ofstream_vtable
;
3118 /* ??0ofstream@@QAE@HPADH@Z */
3119 /* ??0ofstream@@QEAA@HPEADH@Z */
3120 DEFINE_THISCALL_WRAPPER(ofstream_buffer_ctor
, 20)
3121 ostream
* __thiscall
ofstream_buffer_ctor(ostream
*this, filedesc fd
, char *buffer
, int length
, BOOL virt_init
)
3124 filebuf
*fb
= operator_new(sizeof(filebuf
));
3126 TRACE("(%p %d %p %d %d)\n", this, fd
, buffer
, length
, virt_init
);
3129 FIXME("out of memory\n");
3133 filebuf_fd_reserve_ctor(fb
, fd
, buffer
, length
);
3134 ostream_sb_ctor(this, &fb
->base
, virt_init
);
3136 base
= ostream_get_ios(this);
3137 base
->vtable
= &ofstream_vtable
;
3143 /* ??0ofstream@@QAE@H@Z */
3144 /* ??0ofstream@@QEAA@H@Z */
3145 DEFINE_THISCALL_WRAPPER(ofstream_fd_ctor
, 12)
3146 ostream
* __thiscall
ofstream_fd_ctor(ostream
*this, filedesc fd
, BOOL virt_init
)
3149 filebuf
*fb
= operator_new(sizeof(filebuf
));
3151 TRACE("(%p %d %d)\n", this, fd
, virt_init
);
3154 FIXME("out of memory\n");
3158 filebuf_fd_ctor(fb
, fd
);
3159 ostream_sb_ctor(this, &fb
->base
, virt_init
);
3161 base
= ostream_get_ios(this);
3162 base
->vtable
= &ofstream_vtable
;
3168 /* ??0ofstream@@QAE@PBDHH@Z */
3169 /* ??0ofstream@@QEAA@PEBDHH@Z */
3170 DEFINE_THISCALL_WRAPPER(ofstream_open_ctor
, 20)
3171 ostream
* __thiscall
ofstream_open_ctor(ostream
*this, const char *name
, int mode
, int protection
, BOOL virt_init
)
3174 filebuf
*fb
= operator_new(sizeof(filebuf
));
3176 TRACE("(%p %s %d %d %d)\n", this, name
, mode
, protection
, virt_init
);
3179 FIXME("out of memory\n");
3184 ostream_sb_ctor(this, &fb
->base
, virt_init
);
3186 base
= ostream_get_ios(this);
3187 base
->vtable
= &ofstream_vtable
;
3190 if (filebuf_open(fb
, name
, mode
|OPENMODE_out
, protection
) == NULL
)
3191 base
->state
|= IOSTATE_failbit
;
3195 /* ??0ofstream@@QAE@XZ */
3196 /* ??0ofstream@@QEAA@XZ */
3197 DEFINE_THISCALL_WRAPPER(ofstream_ctor
, 8)
3198 ostream
* __thiscall
ofstream_ctor(ostream
*this, BOOL virt_init
)
3200 return ofstream_fd_ctor(this, -1, virt_init
);
3203 /* ?rdbuf@ofstream@@QBEPAVfilebuf@@XZ */
3204 /* ?rdbuf@ofstream@@QEBAPEAVfilebuf@@XZ */
3205 DEFINE_THISCALL_WRAPPER(ofstream_rdbuf
, 4)
3206 filebuf
* __thiscall
ofstream_rdbuf(const ostream
*this)
3208 TRACE("(%p)\n", this);
3209 return (filebuf
*) ostream_get_ios(this)->sb
;
3212 /* ?fd@ofstream@@QBEHXZ */
3213 /* ?fd@ofstream@@QEBAHXZ */
3214 DEFINE_THISCALL_WRAPPER(ofstream_fd
, 4)
3215 filedesc __thiscall
ofstream_fd(ostream
*this)
3217 TRACE("(%p)\n", this);
3218 return filebuf_fd(ofstream_rdbuf(this));
3221 /* ?attach@ofstream@@QAEXH@Z */
3222 /* ?attach@ofstream@@QEAAXH@Z */
3223 DEFINE_THISCALL_WRAPPER(ofstream_attach
, 8)
3224 void __thiscall
ofstream_attach(ostream
*this, filedesc fd
)
3226 ios
*base
= ostream_get_ios(this);
3227 TRACE("(%p %d)\n", this, fd
);
3228 if (filebuf_attach(ofstream_rdbuf(this), fd
) == NULL
)
3229 ios_clear(base
, base
->state
| IOSTATE_failbit
);
3232 /* ?close@ofstream@@QAEXXZ */
3233 /* ?close@ofstream@@QEAAXXZ */
3234 DEFINE_THISCALL_WRAPPER(ofstream_close
, 4)
3235 void __thiscall
ofstream_close(ostream
*this)
3237 ios
*base
= ostream_get_ios(this);
3238 TRACE("(%p)\n", this);
3239 if (filebuf_close(ofstream_rdbuf(this)) == NULL
)
3240 ios_clear(base
, base
->state
| IOSTATE_failbit
);
3242 ios_clear(base
, IOSTATE_goodbit
);
3245 /* ?is_open@ofstream@@QBEHXZ */
3246 /* ?is_open@ofstream@@QEBAHXZ */
3247 DEFINE_THISCALL_WRAPPER(ofstream_is_open
, 4)
3248 int __thiscall
ofstream_is_open(const ostream
*this)
3250 TRACE("(%p)\n", this);
3251 return filebuf_is_open(ofstream_rdbuf(this));
3254 /* ?open@ofstream@@QAEXPBDHH@Z */
3255 /* ?open@ofstream@@QEAAXPEBDHH@Z */
3256 DEFINE_THISCALL_WRAPPER(ofstream_open
, 16)
3257 void __thiscall
ofstream_open(ostream
*this, const char *name
, ios_open_mode mode
, int protection
)
3259 ios
*base
= ostream_get_ios(this);
3260 TRACE("(%p %s %d %d)\n", this, name
, mode
, protection
);
3261 if (filebuf_open(ofstream_rdbuf(this), name
, mode
|OPENMODE_out
, protection
) == NULL
)
3262 ios_clear(base
, base
->state
| IOSTATE_failbit
);
3265 /* ?setbuf@ofstream@@QAEPAVstreambuf@@PADH@Z */
3266 /* ?setbuf@ofstream@@QEAAPEAVstreambuf@@PEADH@Z */
3267 DEFINE_THISCALL_WRAPPER(ofstream_setbuf
, 12)
3268 streambuf
* __thiscall
ofstream_setbuf(ostream
*this, char *buffer
, int length
)
3270 ios
*base
= ostream_get_ios(this);
3271 filebuf
* fb
= ofstream_rdbuf(this);
3273 TRACE("(%p %p %d)\n", this, buffer
, length
);
3275 if (filebuf_is_open(fb
)) {
3276 ios_clear(base
, base
->state
| IOSTATE_failbit
);
3280 return filebuf_setbuf(fb
, buffer
, length
);
3283 /* ?setmode@ofstream@@QAEHH@Z */
3284 /* ?setmode@ofstream@@QEAAHH@Z */
3285 DEFINE_THISCALL_WRAPPER(ofstream_setmode
, 8)
3286 int __thiscall
ofstream_setmode(ostream
*this, int mode
)
3288 TRACE("(%p %d)\n", this, mode
);
3289 return filebuf_setmode(ofstream_rdbuf(this), mode
);
3292 static inline ios
* istream_get_ios(const istream
*this)
3294 return (ios
*)((char*)this + this->vbtable
[1]);
3297 static inline ios
* istream_to_ios(const istream
*this)
3299 return (ios
*)((char*)this + istream_vbtable
[1]);
3302 static inline istream
* ios_to_istream(const ios
*base
)
3304 return (istream
*)((char*)base
- istream_vbtable
[1]);
3307 /* ??0istream@@IAE@XZ */
3308 /* ??0istream@@IEAA@XZ */
3309 DEFINE_THISCALL_WRAPPER(istream_ctor
, 8)
3310 istream
* __thiscall
istream_ctor(istream
*this, BOOL virt_init
)
3314 TRACE("(%p %d)\n", this, virt_init
);
3317 this->vbtable
= istream_vbtable
;
3318 base
= istream_get_ios(this);
3321 base
= istream_get_ios(this);
3322 base
->vtable
= &istream_vtable
;
3323 base
->flags
|= FLAGS_skipws
;
3324 this->extract_delim
= 0;
3329 /* ??0istream@@QAE@PAVstreambuf@@@Z */
3330 /* ??0istream@@QEAA@PEAVstreambuf@@@Z */
3331 DEFINE_THISCALL_WRAPPER(istream_sb_ctor
, 12)
3332 istream
* __thiscall
istream_sb_ctor(istream
*this, streambuf
*sb
, BOOL virt_init
)
3334 TRACE("(%p %p %d)\n", this, sb
, virt_init
);
3335 istream_ctor(this, virt_init
);
3336 ios_init(istream_get_ios(this), sb
);
3340 /* ??0istream@@IAE@ABV0@@Z */
3341 /* ??0istream@@IEAA@AEBV0@@Z */
3342 DEFINE_THISCALL_WRAPPER(istream_copy_ctor
, 12)
3343 istream
* __thiscall
istream_copy_ctor(istream
*this, const istream
*copy
, BOOL virt_init
)
3345 return istream_sb_ctor(this, istream_get_ios(copy
)->sb
, virt_init
);
3348 /* ??1istream@@UAE@XZ */
3349 /* ??1istream@@UEAA@XZ */
3350 /* ??1istream_withassign@@UAE@XZ */
3351 /* ??1istream_withassign@@UEAA@XZ */
3352 /* ??1istrstream@@UAE@XZ */
3353 /* ??1istrstream@@UEAA@XZ */
3354 /* ??1ifstream@@UAE@XZ */
3355 /* ??1ifstream@@UEAA@XZ */
3356 DEFINE_THISCALL_WRAPPER(istream_dtor
, 4)
3357 void __thiscall
istream_dtor(ios
*base
)
3359 istream
*this = ios_to_istream(base
);
3361 TRACE("(%p)\n", this);
3364 /* ??4istream@@IAEAAV0@PAVstreambuf@@@Z */
3365 /* ??4istream@@IEAAAEAV0@PEAVstreambuf@@@Z */
3366 /* ??4istream_withassign@@QAEAAVistream@@PAVstreambuf@@@Z */
3367 /* ??4istream_withassign@@QEAAAEAVistream@@PEAVstreambuf@@@Z */
3368 DEFINE_THISCALL_WRAPPER(istream_assign_sb
, 8)
3369 istream
* __thiscall
istream_assign_sb(istream
*this, streambuf
*sb
)
3371 ios
*base
= istream_get_ios(this);
3373 TRACE("(%p %p)\n", this, sb
);
3376 base
->state
&= IOSTATE_badbit
;
3379 base
->flags
= FLAGS_skipws
;
3380 base
->precision
= 6;
3387 /* ??4istream@@IAEAAV0@ABV0@@Z */
3388 /* ??4istream@@IEAAAEAV0@AEBV0@@Z */
3389 /* ??4istream_withassign@@QAEAAV0@ABV0@@Z */
3390 /* ??4istream_withassign@@QEAAAEAV0@AEBV0@@Z */
3391 /* ??4istream_withassign@@QAEAAVistream@@ABV1@@Z */
3392 /* ??4istream_withassign@@QEAAAEAVistream@@AEBV1@@Z */
3393 /* ??4istrstream@@QAEAAV0@ABV0@@Z */
3394 /* ??4istrstream@@QEAAAEAV0@AEBV0@@Z */
3395 /* ??4ifstream@@QAEAAV0@ABV0@@Z */
3396 /* ??4ifstream@@QEAAAEAV0@AEBV0@@Z */
3397 DEFINE_THISCALL_WRAPPER(istream_assign
, 8)
3398 istream
* __thiscall
istream_assign(istream
*this, const istream
*rhs
)
3400 return istream_assign_sb(this, istream_get_ios(rhs
)->sb
);
3403 /* ??_Distream@@QAEXXZ */
3404 /* ??_Distream@@QEAAXXZ */
3405 /* ??_Distream_withassign@@QAEXXZ */
3406 /* ??_Distream_withassign@@QEAAXXZ */
3407 /* ??_Distrstream@@QAEXXZ */
3408 /* ??_Distrstream@@QEAAXXZ */
3409 /* ??_Difstream@@QAEXXZ */
3410 /* ??_Difstream@@QEAAXXZ */
3411 DEFINE_THISCALL_WRAPPER(istream_vbase_dtor
, 4)
3412 void __thiscall
istream_vbase_dtor(istream
*this)
3414 ios
*base
= istream_to_ios(this);
3416 TRACE("(%p)\n", this);
3422 /* ??_Eistream@@UAEPAXI@Z */
3423 /* ??_Eistream_withassign@@UAEPAXI@Z */
3424 /* ??_Eistrstream@@UAEPAXI@Z */
3425 /* ??_Eifstream@@UAEPAXI@Z */
3426 DEFINE_THISCALL_WRAPPER(istream_vector_dtor
, 8)
3427 istream
* __thiscall
istream_vector_dtor(ios
*base
, unsigned int flags
)
3429 istream
*this = ios_to_istream(base
);
3431 TRACE("(%p %x)\n", this, flags
);
3434 /* we have an array, with the number of elements stored before the first object */
3435 INT_PTR i
, *ptr
= (INT_PTR
*)this-1;
3437 for (i
= *ptr
-1; i
>= 0; i
--)
3438 istream_vbase_dtor(this+i
);
3439 operator_delete(ptr
);
3441 istream_vbase_dtor(this);
3443 operator_delete(this);
3448 /* ??_Gistream@@UAEPAXI@Z */
3449 /* ??_Gistream_withassign@@UAEPAXI@Z */
3450 /* ??_Gistrstream@@UAEPAXI@Z */
3451 /* ??_Gifstream@@UAEPAXI@Z */
3452 DEFINE_THISCALL_WRAPPER(istream_scalar_dtor
, 8)
3453 istream
* __thiscall
istream_scalar_dtor(ios
*base
, unsigned int flags
)
3455 istream
*this = ios_to_istream(base
);
3457 TRACE("(%p %x)\n", this, flags
);
3459 istream_vbase_dtor(this);
3460 if (flags
& 1) operator_delete(this);
3464 /* ?eatwhite@istream@@QAEXXZ */
3465 /* ?eatwhite@istream@@QEAAXXZ */
3466 DEFINE_THISCALL_WRAPPER(istream_eatwhite
, 4)
3467 void __thiscall
istream_eatwhite(istream
*this)
3469 ios
*base
= istream_get_ios(this);
3472 TRACE("(%p)\n", this);
3475 for (c
= streambuf_sgetc(base
->sb
); isspace(c
); c
= streambuf_snextc(base
->sb
));
3476 ios_unlockbuf(base
);
3478 ios_clear(base
, base
->state
| IOSTATE_eofbit
);
3481 /* ?gcount@istream@@QBEHXZ */
3482 /* ?gcount@istream@@QEBAHXZ */
3483 DEFINE_THISCALL_WRAPPER(istream_gcount
, 4)
3484 int __thiscall
istream_gcount(const istream
*this)
3486 TRACE("(%p)\n", this);
3490 /* ?ipfx@istream@@QAEHH@Z */
3491 /* ?ipfx@istream@@QEAAHH@Z */
3492 DEFINE_THISCALL_WRAPPER(istream_ipfx
, 8)
3493 int __thiscall
istream_ipfx(istream
*this, int need
)
3495 ios
*base
= istream_get_ios(this);
3497 TRACE("(%p %d)\n", this, need
);
3501 if (!ios_good(base
)) {
3502 ios_clear(base
, base
->state
| IOSTATE_failbit
);
3507 if (base
->tie
&& (!need
|| streambuf_in_avail(base
->sb
) < need
))
3508 ostream_flush(base
->tie
);
3509 if ((base
->flags
& FLAGS_skipws
) && !need
) {
3510 istream_eatwhite(this);
3511 if (base
->state
& IOSTATE_eofbit
) {
3512 base
->state
|= IOSTATE_failbit
;
3513 ios_unlockbuf(base
);
3521 /* ?isfx@istream@@QAEXXZ */
3522 /* ?isfx@istream@@QEAAXXZ */
3523 DEFINE_THISCALL_WRAPPER(istream_isfx
, 4)
3524 void __thiscall
istream_isfx(istream
*this)
3526 ios
*base
= istream_get_ios(this);
3528 TRACE("(%p)\n", this);
3530 ios_unlockbuf(base
);
3534 /* ?get@istream@@IAEAAV1@PADHH@Z */
3535 /* ?get@istream@@IEAAAEAV1@PEADHH@Z */
3536 DEFINE_THISCALL_WRAPPER(istream_get_str_delim
, 16)
3537 istream
* __thiscall
istream_get_str_delim(istream
*this, char *str
, int count
, int delim
)
3539 ios
*base
= istream_get_ios(this);
3542 TRACE("(%p %p %d %d)\n", this, str
, count
, delim
);
3544 if (istream_ipfx(this, 1)) {
3545 while (i
< count
- 1) {
3546 if ((ch
= streambuf_sgetc(base
->sb
)) == EOF
) {
3547 base
->state
|= IOSTATE_eofbit
;
3548 if (!i
) /* tried to read, but not a single character was obtained */
3549 base
->state
|= IOSTATE_failbit
;
3553 if (this->extract_delim
) { /* discard the delimiter */
3554 streambuf_stossc(base
->sb
);
3561 streambuf_stossc(base
->sb
);
3567 if (str
&& count
) /* append a null terminator, unless a string of 0 characters was requested */
3569 this->extract_delim
= 0;
3573 /* ?get@istream@@QAEAAV1@PACHD@Z */
3574 /* ?get@istream@@QEAAAEAV1@PEACHD@Z */
3575 /* ?get@istream@@QAEAAV1@PADHD@Z */
3576 /* ?get@istream@@QEAAAEAV1@PEADHD@Z */
3577 /* ?get@istream@@QAEAAV1@PAEHD@Z */
3578 /* ?get@istream@@QEAAAEAV1@PEAEHD@Z */
3579 DEFINE_THISCALL_WRAPPER(istream_get_str
, 16)
3580 istream
* __thiscall
istream_get_str(istream
*this, char *str
, int count
, char delim
)
3582 return istream_get_str_delim(this, str
, count
, (unsigned char) delim
);
3585 static int istream_internal_get_char(istream
*this, char *ch
)
3587 ios
*base
= istream_get_ios(this);
3590 TRACE("(%p %p)\n", this, ch
);
3592 if (istream_ipfx(this, 1)) {
3593 if ((ret
= streambuf_sbumpc(base
->sb
)) != EOF
) {
3596 base
->state
|= IOSTATE_eofbit
;
3598 base
->state
|= IOSTATE_failbit
;
3607 /* ?get@istream@@QAEAAV1@AAC@Z */
3608 /* ?get@istream@@QEAAAEAV1@AEAC@Z */
3609 /* ?get@istream@@QAEAAV1@AAD@Z */
3610 /* ?get@istream@@QEAAAEAV1@AEAD@Z */
3611 /* ?get@istream@@QAEAAV1@AAE@Z */
3612 /* ?get@istream@@QEAAAEAV1@AEAE@Z */
3613 DEFINE_THISCALL_WRAPPER(istream_get_char
, 8)
3614 istream
* __thiscall
istream_get_char(istream
*this, char *ch
)
3616 istream_internal_get_char(this, ch
);
3620 /* ?get@istream@@QAEHXZ */
3621 /* ?get@istream@@QEAAHXZ */
3622 DEFINE_THISCALL_WRAPPER(istream_get
, 4)
3623 int __thiscall
istream_get(istream
*this)
3625 return istream_internal_get_char(this, NULL
);
3628 /* ?get@istream@@QAEAAV1@AAVstreambuf@@D@Z */
3629 /* ?get@istream@@QEAAAEAV1@AEAVstreambuf@@D@Z */
3630 DEFINE_THISCALL_WRAPPER(istream_get_sb
, 12)
3631 istream
* __thiscall
istream_get_sb(istream
*this, streambuf
*sb
, char delim
)
3633 ios
*base
= istream_get_ios(this);
3636 TRACE("(%p %p %c)\n", this, sb
, delim
);
3638 if (istream_ipfx(this, 1)) {
3639 for (ch
= streambuf_sgetc(base
->sb
); ch
!= delim
; ch
= streambuf_snextc(base
->sb
)) {
3641 base
->state
|= IOSTATE_eofbit
;
3644 if (streambuf_sputc(sb
, ch
) == EOF
)
3645 base
->state
|= IOSTATE_failbit
;
3653 /* ?getline@istream@@QAEAAV1@PACHD@Z */
3654 /* ?getline@istream@@QEAAAEAV1@PEACHD@Z */
3655 /* ?getline@istream@@QAEAAV1@PADHD@Z */
3656 /* ?getline@istream@@QEAAAEAV1@PEADHD@Z */
3657 /* ?getline@istream@@QAEAAV1@PAEHD@Z */
3658 /* ?getline@istream@@QEAAAEAV1@PEAEHD@Z */
3659 DEFINE_THISCALL_WRAPPER(istream_getline
, 16)
3660 istream
* __thiscall
istream_getline(istream
*this, char *str
, int count
, char delim
)
3662 ios
*base
= istream_get_ios(this);
3664 TRACE("(%p %p %d %c)\n", this, str
, count
, delim
);
3667 this->extract_delim
++;
3668 istream_get_str_delim(this, str
, count
, (unsigned char) delim
);
3673 /* ?ignore@istream@@QAEAAV1@HH@Z */
3674 /* ?ignore@istream@@QEAAAEAV1@HH@Z */
3675 DEFINE_THISCALL_WRAPPER(istream_ignore
, 12)
3676 istream
* __thiscall
istream_ignore(istream
*this, int count
, int delim
)
3678 ios
*base
= istream_get_ios(this);
3680 TRACE("(%p %d %d)\n", this, count
, delim
);
3683 this->extract_delim
++;
3684 istream_get_str_delim(this, NULL
, count
+ 1, delim
);
3689 /* ?peek@istream@@QAEHXZ */
3690 /* ?peek@istream@@QEAAHXZ */
3691 DEFINE_THISCALL_WRAPPER(istream_peek
, 4)
3692 int __thiscall
istream_peek(istream
*this)
3694 ios
*base
= istream_get_ios(this);
3697 TRACE("(%p)\n", this);
3699 if (istream_ipfx(this, 1)) {
3700 ret
= streambuf_sgetc(base
->sb
);
3706 /* ?putback@istream@@QAEAAV1@D@Z */
3707 /* ?putback@istream@@QEAAAEAV1@D@Z */
3708 DEFINE_THISCALL_WRAPPER(istream_putback
, 8)
3709 istream
* __thiscall
istream_putback(istream
*this, char ch
)
3711 ios
*base
= istream_get_ios(this);
3713 TRACE("(%p %c)\n", this, ch
);
3715 if (ios_good(base
)) {
3717 if (streambuf_sputbackc(base
->sb
, ch
) == EOF
)
3718 ios_clear(base
, base
->state
| IOSTATE_failbit
);
3719 ios_unlockbuf(base
);
3724 /* ?read@istream@@QAEAAV1@PACH@Z */
3725 /* ?read@istream@@QEAAAEAV1@PEACH@Z */
3726 /* ?read@istream@@QAEAAV1@PADH@Z */
3727 /* ?read@istream@@QEAAAEAV1@PEADH@Z */
3728 /* ?read@istream@@QAEAAV1@PAEH@Z */
3729 /* ?read@istream@@QEAAAEAV1@PEAEH@Z */
3730 DEFINE_THISCALL_WRAPPER(istream_read
, 12)
3731 istream
* __thiscall
istream_read(istream
*this, char *str
, int count
)
3733 ios
*base
= istream_get_ios(this);
3735 TRACE("(%p %p %d)\n", this, str
, count
);
3737 if (istream_ipfx(this, 1)) {
3738 if ((this->count
= streambuf_sgetn(base
->sb
, str
, count
)) != count
)
3739 base
->state
= IOSTATE_eofbit
| IOSTATE_failbit
;
3745 /* ?seekg@istream@@QAEAAV1@J@Z */
3746 /* ?seekg@istream@@QEAAAEAV1@J@Z */
3747 DEFINE_THISCALL_WRAPPER(istream_seekg
, 8)
3748 istream
* __thiscall
istream_seekg(istream
*this, streampos pos
)
3750 ios
*base
= istream_get_ios(this);
3752 TRACE("(%p %ld)\n", this, pos
);
3755 if (streambuf_seekpos(base
->sb
, pos
, OPENMODE_in
) == EOF
)
3756 ios_clear(base
, base
->state
| IOSTATE_failbit
);
3757 ios_unlockbuf(base
);
3761 /* ?seekg@istream@@QAEAAV1@JW4seek_dir@ios@@@Z */
3762 /* ?seekg@istream@@QEAAAEAV1@JW4seek_dir@ios@@@Z */
3763 DEFINE_THISCALL_WRAPPER(istream_seekg_offset
, 12)
3764 istream
* __thiscall
istream_seekg_offset(istream
*this, streamoff off
, ios_seek_dir dir
)
3766 ios
*base
= istream_get_ios(this);
3768 TRACE("(%p %ld %d)\n", this, off
, dir
);
3771 if (call_streambuf_seekoff(base
->sb
, off
, dir
, OPENMODE_in
) == EOF
)
3772 ios_clear(base
, base
->state
| IOSTATE_failbit
);
3773 ios_unlockbuf(base
);
3777 /* ?sync@istream@@QAEHXZ */
3778 /* ?sync@istream@@QEAAHXZ */
3779 DEFINE_THISCALL_WRAPPER(istream_sync
, 4)
3780 int __thiscall
istream_sync(istream
*this)
3782 ios
*base
= istream_get_ios(this);
3785 TRACE("(%p)\n", this);
3788 if ((ret
= call_streambuf_sync(base
->sb
)) == EOF
)
3789 ios_clear(base
, base
->state
| IOSTATE_badbit
| IOSTATE_failbit
);
3790 ios_unlockbuf(base
);
3794 /* ?tellg@istream@@QAEJXZ */
3795 /* ?tellg@istream@@QEAAJXZ */
3796 DEFINE_THISCALL_WRAPPER(istream_tellg
, 4)
3797 streampos __thiscall
istream_tellg(istream
*this)
3799 ios
*base
= istream_get_ios(this);
3802 TRACE("(%p)\n", this);
3805 if ((pos
= call_streambuf_seekoff(base
->sb
, 0, SEEKDIR_cur
, OPENMODE_in
)) == EOF
)
3806 ios_clear(base
, base
->state
| IOSTATE_failbit
);
3807 ios_unlockbuf(base
);
3811 static int getint_is_valid_digit(char ch
, int base
)
3813 if (base
== 8) return (ch
>= '0' && ch
<= '7');
3814 if (base
== 16) return isxdigit(ch
);
3818 /* ?getint@istream@@AAEHPAD@Z */
3819 /* ?getint@istream@@AEAAHPEAD@Z */
3820 DEFINE_THISCALL_WRAPPER(istream_getint
, 8)
3821 int __thiscall
istream_getint(istream
*this, char *str
)
3823 ios
*base
= istream_get_ios(this);
3824 int ch
, num_base
= 0, i
= 0;
3825 BOOL scan_sign
= TRUE
, scan_prefix
= TRUE
, scan_x
= FALSE
, valid_integer
= FALSE
;
3827 TRACE("(%p %p)\n", this, str
);
3829 if (istream_ipfx(this, 0)) {
3830 num_base
= (base
->flags
& FLAGS_dec
) ? 10 :
3831 (base
->flags
& FLAGS_hex
) ? 16 :
3832 (base
->flags
& FLAGS_oct
) ? 8 : 0; /* 0 = autodetect */
3833 /* scan valid characters, up to 15 (hard limit on Windows) */
3834 for (ch
= streambuf_sgetc(base
->sb
); i
< 15; ch
= streambuf_snextc(base
->sb
)) {
3835 if ((ch
== '+' || ch
== '-') && scan_sign
) {
3836 /* no additional sign allowed */
3838 } else if ((ch
== 'x' || ch
== 'X') && scan_x
) {
3839 /* only hex digits can (and must) follow */
3840 scan_x
= valid_integer
= FALSE
;
3842 } else if (ch
== '0' && scan_prefix
) {
3843 /* might be the octal prefix, the beginning of the hex prefix or a decimal zero */
3844 scan_sign
= scan_prefix
= FALSE
;
3845 scan_x
= !num_base
|| num_base
== 16;
3846 valid_integer
= TRUE
;
3849 } else if (getint_is_valid_digit(ch
, num_base
)) {
3850 /* only digits in the corresponding base can follow */
3851 scan_sign
= scan_prefix
= scan_x
= FALSE
;
3852 valid_integer
= TRUE
;
3854 /* unexpected character, stop scanning */
3855 if (!valid_integer
) {
3856 /* the result is not a valid integer */
3857 base
->state
|= IOSTATE_failbit
;
3858 /* put any extracted character back into the stream */
3860 if (streambuf_sputbackc(base
->sb
, str
[--i
]) == EOF
)
3861 base
->state
|= IOSTATE_badbit
; /* characters have been lost for good */
3862 } else if (ch
== EOF
) {
3863 base
->state
|= IOSTATE_eofbit
;
3864 if (scan_x
&& !(base
->flags
& ios_basefield
)) {
3865 /* when autodetecting, a single zero followed by EOF is regarded as decimal */
3873 /* append a null terminator */
3880 /* ?getdouble@istream@@AAEHPADH@Z */
3881 /* ?getdouble@istream@@AEAAHPEADH@Z */
3882 DEFINE_THISCALL_WRAPPER(istream_getdouble
, 12)
3883 int __thiscall
istream_getdouble(istream
*this, char *str
, int count
)
3885 ios
*base
= istream_get_ios(this);
3887 BOOL scan_sign
= TRUE
, scan_dot
= TRUE
, scan_exp
= TRUE
,
3888 valid_mantissa
= FALSE
, valid_exponent
= FALSE
;
3890 TRACE("(%p %p %d)\n", this, str
, count
);
3892 if (istream_ipfx(this, 0)) {
3894 /* can't output anything */
3895 base
->state
|= IOSTATE_failbit
;
3898 /* valid mantissas: +d. +.d +d.d (where d are sequences of digits and the sign is optional) */
3899 /* valid exponents: e+d E+d (where d are sequences of digits and the sign is optional) */
3900 for (ch
= streambuf_sgetc(base
->sb
); i
< count
; ch
= streambuf_snextc(base
->sb
)) {
3901 if ((ch
== '+' || ch
== '-') && scan_sign
) {
3902 /* no additional sign allowed */
3904 } else if (ch
== '.' && scan_dot
) {
3905 /* no sign or additional dot allowed */
3906 scan_sign
= scan_dot
= FALSE
;
3907 } else if ((ch
== 'e' || ch
== 'E') && scan_exp
) {
3908 /* sign is allowed again but not dots or exponents */
3910 scan_dot
= scan_exp
= FALSE
;
3911 } else if (isdigit(ch
)) {
3913 valid_mantissa
= TRUE
;
3915 valid_exponent
= TRUE
;
3916 /* no sign allowed after a digit */
3919 /* unexpected character, stop scanning */
3920 /* check whether the result is a valid double */
3921 if (!scan_exp
&& !valid_exponent
) {
3922 /* put the last character back into the stream, usually the 'e' or 'E' */
3923 if (streambuf_sputbackc(base
->sb
, str
[i
--]) == EOF
)
3924 base
->state
|= IOSTATE_badbit
; /* characters have been lost for good */
3925 } else if (ch
== EOF
)
3926 base
->state
|= IOSTATE_eofbit
;
3927 if (!valid_mantissa
)
3928 base
->state
|= IOSTATE_failbit
;
3933 /* check if character limit has been reached */
3935 base
->state
|= IOSTATE_failbit
;
3938 /* append a null terminator */
3946 /* ??5istream@@QAEAAV0@AAC@Z */
3947 /* ??5istream@@QEAAAEAV0@AEAC@Z */
3948 /* ??5istream@@QAEAAV0@AAD@Z */
3949 /* ??5istream@@QEAAAEAV0@AEAD@Z */
3950 /* ??5istream@@QAEAAV0@AAE@Z */
3951 /* ??5istream@@QEAAAEAV0@AEAE@Z */
3952 DEFINE_THISCALL_WRAPPER(istream_read_char
, 8)
3953 istream
* __thiscall
istream_read_char(istream
*this, char *ch
)
3955 ios
*base
= istream_get_ios(this);
3958 TRACE("(%p %p)\n", this, ch
);
3960 if (istream_ipfx(this, 0)) {
3961 if ((ret
= streambuf_sbumpc(base
->sb
)) == EOF
)
3962 base
->state
|= IOSTATE_eofbit
| IOSTATE_failbit
;
3970 /* ??5istream@@QAEAAV0@PAC@Z */
3971 /* ??5istream@@QEAAAEAV0@PEAC@Z */
3972 /* ??5istream@@QAEAAV0@PAD@Z */
3973 /* ??5istream@@QEAAAEAV0@PEAD@Z */
3974 /* ??5istream@@QAEAAV0@PAE@Z */
3975 /* ??5istream@@QEAAAEAV0@PEAE@Z */
3976 DEFINE_THISCALL_WRAPPER(istream_read_str
, 8)
3977 istream
* __thiscall
istream_read_str(istream
*this, char *str
)
3979 ios
*base
= istream_get_ios(this);
3982 TRACE("(%p %p)\n", this, str
);
3984 if (istream_ipfx(this, 0)) {
3986 for (ch
= streambuf_sgetc(base
->sb
);
3987 count
< (unsigned int) base
->width
- 1 && !isspace(ch
);
3988 ch
= streambuf_snextc(base
->sb
)) {
3990 base
->state
|= IOSTATE_eofbit
;
3996 if (!count
) /* nothing to output */
3997 base
->state
|= IOSTATE_failbit
;
3998 else /* append a null terminator */
4006 static LONG
istream_internal_read_integer(istream
*this, LONG min_value
, LONG max_value
, BOOL set_flag
)
4008 ios
*base
= istream_get_ios(this);
4013 TRACE("(%p %ld %ld %d)\n", this, min_value
, max_value
, set_flag
);
4015 num_base
= istream_getint(this, buffer
);
4017 ret
= strtol(buffer
, NULL
, num_base
);
4018 /* check for overflow and whether the value fits in the output var */
4019 if (set_flag
&& errno
== ERANGE
) {
4020 base
->state
|= IOSTATE_failbit
;
4021 } else if (ret
> max_value
) {
4022 base
->state
|= IOSTATE_failbit
;
4024 } else if (ret
< min_value
) {
4025 base
->state
|= IOSTATE_failbit
;
4031 static ULONG
istream_internal_read_unsigned_integer(istream
*this, LONG min_value
, ULONG max_value
)
4033 ios
*base
= istream_get_ios(this);
4038 TRACE("(%p %ld %lu)\n", this, min_value
, max_value
);
4040 num_base
= istream_getint(this, buffer
);
4042 ret
= strtoul(buffer
, NULL
, num_base
);
4043 /* check for overflow and whether the value fits in the output var */
4044 if ((ret
== ULONG_MAX
&& errno
== ERANGE
) ||
4045 (ret
> max_value
&& ret
< (ULONG
) min_value
)) {
4046 base
->state
|= IOSTATE_failbit
;
4052 /* ??5istream@@QAEAAV0@AAF@Z */
4053 /* ??5istream@@QEAAAEAV0@AEAF@Z */
4054 DEFINE_THISCALL_WRAPPER(istream_read_short
, 8)
4055 istream
* __thiscall
istream_read_short(istream
*this, short *p
)
4057 if (istream_ipfx(this, 0)) {
4058 *p
= istream_internal_read_integer(this, SHRT_MIN
, SHRT_MAX
, FALSE
);
4064 /* ??5istream@@QAEAAV0@AAG@Z */
4065 /* ??5istream@@QEAAAEAV0@AEAG@Z */
4066 DEFINE_THISCALL_WRAPPER(istream_read_unsigned_short
, 8)
4067 istream
* __thiscall
istream_read_unsigned_short(istream
*this, unsigned short *p
)
4069 if (istream_ipfx(this, 0)) {
4070 *p
= istream_internal_read_unsigned_integer(this, SHRT_MIN
, USHRT_MAX
);
4076 /* ??5istream@@QAEAAV0@AAH@Z */
4077 /* ??5istream@@QEAAAEAV0@AEAH@Z */
4078 DEFINE_THISCALL_WRAPPER(istream_read_int
, 8)
4079 istream
* __thiscall
istream_read_int(istream
*this, int *p
)
4081 if (istream_ipfx(this, 0)) {
4082 *p
= istream_internal_read_integer(this, INT_MIN
, INT_MAX
, FALSE
);
4088 /* ??5istream@@QAEAAV0@AAI@Z */
4089 /* ??5istream@@QEAAAEAV0@AEAI@Z */
4090 DEFINE_THISCALL_WRAPPER(istream_read_unsigned_int
, 8)
4091 istream
* __thiscall
istream_read_unsigned_int(istream
*this, unsigned int *p
)
4093 if (istream_ipfx(this, 0)) {
4094 *p
= istream_internal_read_unsigned_integer(this, INT_MIN
, UINT_MAX
);
4100 /* ??5istream@@QAEAAV0@AAJ@Z */
4101 /* ??5istream@@QEAAAEAV0@AEAJ@Z */
4102 DEFINE_THISCALL_WRAPPER(istream_read_long
, 8)
4103 istream
* __thiscall
istream_read_long(istream
*this, LONG
*p
)
4105 if (istream_ipfx(this, 0)) {
4106 *p
= istream_internal_read_integer(this, LONG_MIN
, LONG_MAX
, TRUE
);
4112 /* ??5istream@@QAEAAV0@AAK@Z */
4113 /* ??5istream@@QEAAAEAV0@AEAK@Z */
4114 DEFINE_THISCALL_WRAPPER(istream_read_unsigned_long
, 8)
4115 istream
* __thiscall
istream_read_unsigned_long(istream
*this, ULONG
*p
)
4117 if (istream_ipfx(this, 0)) {
4118 *p
= istream_internal_read_unsigned_integer(this, LONG_MIN
, ULONG_MAX
);
4124 static BOOL
istream_internal_read_float(istream
*this, int max_chars
, double *out
)
4129 TRACE("(%p %d %p)\n", this, max_chars
, out
);
4131 if (istream_ipfx(this, 0)) {
4132 /* character count is limited on Windows */
4133 if (istream_getdouble(this, buffer
, max_chars
) > 0) {
4134 *out
= strtod(buffer
, NULL
);
4142 /* ??5istream@@QAEAAV0@AAM@Z */
4143 /* ??5istream@@QEAAAEAV0@AEAM@Z */
4144 DEFINE_THISCALL_WRAPPER(istream_read_float
, 8)
4145 istream
* __thiscall
istream_read_float(istream
*this, float *f
)
4148 if (istream_internal_read_float(this, 20, &tmp
)) {
4149 /* check whether the value fits in the output var */
4152 else if (tmp
< -FLT_MAX
)
4154 else if (tmp
> 0 && tmp
< FLT_MIN
)
4156 else if (tmp
< 0 && tmp
> -FLT_MIN
)
4163 /* ??5istream@@QAEAAV0@AAN@Z */
4164 /* ??5istream@@QEAAAEAV0@AEAN@Z */
4165 DEFINE_THISCALL_WRAPPER(istream_read_double
, 8)
4166 istream
* __thiscall
istream_read_double(istream
*this, double *d
)
4168 istream_internal_read_float(this, 28, d
);
4172 /* ??5istream@@QAEAAV0@AAO@Z */
4173 /* ??5istream@@QEAAAEAV0@AEAO@Z */
4174 DEFINE_THISCALL_WRAPPER(istream_read_long_double
, 8)
4175 istream
* __thiscall
istream_read_long_double(istream
*this, double *ld
)
4177 istream_internal_read_float(this, 32, ld
);
4181 /* ??5istream@@QAEAAV0@PAVstreambuf@@@Z */
4182 /* ??5istream@@QEAAAEAV0@PEAVstreambuf@@@Z */
4183 DEFINE_THISCALL_WRAPPER(istream_read_streambuf
, 8)
4184 istream
* __thiscall
istream_read_streambuf(istream
*this, streambuf
*sb
)
4186 ios
*base
= istream_get_ios(this);
4189 TRACE("(%p %p)\n", this, sb
);
4191 if (istream_ipfx(this, 0)) {
4192 while ((ch
= streambuf_sbumpc(base
->sb
)) != EOF
)
4193 if (streambuf_sputc(sb
, ch
) == EOF
)
4194 base
->state
|= IOSTATE_failbit
;
4200 /* ??5istream@@QAEAAV0@P6AAAV0@AAV0@@Z@Z */
4201 /* ??5istream@@QEAAAEAV0@P6AAEAV0@AEAV0@@Z@Z */
4202 DEFINE_THISCALL_WRAPPER(istream_read_manip
, 8)
4203 istream
* __thiscall
istream_read_manip(istream
*this, istream
* (__cdecl
*func
)(istream
*))
4205 TRACE("(%p %p)\n", this, func
);
4209 /* ??5istream@@QAEAAV0@P6AAAVios@@AAV1@@Z@Z */
4210 /* ??5istream@@QEAAAEAV0@P6AAEAVios@@AEAV1@@Z@Z */
4211 DEFINE_THISCALL_WRAPPER(istream_read_ios_manip
, 8)
4212 istream
* __thiscall
istream_read_ios_manip(istream
*this, ios
* (__cdecl
*func
)(ios
*))
4214 TRACE("(%p %p)\n", this, func
);
4215 func(istream_get_ios(this));
4219 /* ?ws@@YAAAVistream@@AAV1@@Z */
4220 /* ?ws@@YAAEAVistream@@AEAV1@@Z */
4221 istream
* __cdecl
istream_ws(istream
*this)
4223 TRACE("(%p)\n", this);
4224 istream_eatwhite(this);
4228 /* ??0istream_withassign@@QAE@ABV0@@Z */
4229 /* ??0istream_withassign@@QEAA@AEBV0@@Z */
4230 DEFINE_THISCALL_WRAPPER(istream_withassign_copy_ctor
, 12)
4231 istream
* __thiscall
istream_withassign_copy_ctor(istream
*this, const istream
*copy
, BOOL virt_init
)
4233 ios
*base
, *base_copy
;
4235 TRACE("(%p %p %d)\n", this, copy
, virt_init
);
4237 base_copy
= istream_get_ios(copy
);
4239 this->vbtable
= istream_vbtable
;
4240 base
= istream_get_ios(this);
4241 ios_copy_ctor(base
, base_copy
);
4243 base
= istream_get_ios(this);
4244 ios_init(base
, base_copy
->sb
);
4245 base
->vtable
= &istream_withassign_vtable
;
4246 base
->flags
|= FLAGS_skipws
;
4247 this->extract_delim
= 0;
4252 /* ??0istream_withassign@@QAE@PAVstreambuf@@@Z */
4253 /* ??0istream_withassign@@QEAA@PEAVstreambuf@@@Z */
4254 DEFINE_THISCALL_WRAPPER(istream_withassign_sb_ctor
, 12)
4255 istream
* __thiscall
istream_withassign_sb_ctor(istream
*this, streambuf
*sb
, BOOL virt_init
)
4259 TRACE("(%p %p %d)\n", this, sb
, virt_init
);
4261 istream_sb_ctor(this, sb
, virt_init
);
4262 base
= istream_get_ios(this);
4263 base
->vtable
= &istream_withassign_vtable
;
4267 /* ??0istream_withassign@@QAE@XZ */
4268 /* ??0istream_withassign@@QEAA@XZ */
4269 DEFINE_THISCALL_WRAPPER(istream_withassign_ctor
, 8)
4270 istream
* __thiscall
istream_withassign_ctor(istream
*this, BOOL virt_init
)
4274 TRACE("(%p %d)\n", this, virt_init
);
4276 istream_ctor(this, virt_init
);
4277 base
= istream_get_ios(this);
4278 base
->vtable
= &istream_withassign_vtable
;
4282 /* ??0istrstream@@QAE@ABV0@@Z */
4283 /* ??0istrstream@@QEAA@AEBV0@@Z */
4284 DEFINE_THISCALL_WRAPPER(istrstream_copy_ctor
, 12)
4285 istream
* __thiscall
istrstream_copy_ctor(istream
*this, const istream
*copy
, BOOL virt_init
)
4287 TRACE("(%p %p %d)\n", this, copy
, virt_init
);
4288 istream_withassign_copy_ctor(this, copy
, virt_init
);
4289 istream_get_ios(this)->vtable
= &istrstream_vtable
;
4293 /* ??0istrstream@@QAE@PADH@Z */
4294 /* ??0istrstream@@QEAA@PEADH@Z */
4295 DEFINE_THISCALL_WRAPPER(istrstream_buffer_ctor
, 16)
4296 istream
* __thiscall
istrstream_buffer_ctor(istream
*this, char *buffer
, int length
, BOOL virt_init
)
4299 strstreambuf
*ssb
= operator_new(sizeof(strstreambuf
));
4301 TRACE("(%p %p %d %d)\n", this, buffer
, length
, virt_init
);
4304 FIXME("out of memory\n");
4308 strstreambuf_buffer_ctor(ssb
, buffer
, length
, NULL
);
4309 istream_sb_ctor(this, &ssb
->base
, virt_init
);
4311 base
= istream_get_ios(this);
4312 base
->vtable
= &istrstream_vtable
;
4317 /* ??0istrstream@@QAE@PAD@Z */
4318 /* ??0istrstream@@QEAA@PEAD@Z */
4319 DEFINE_THISCALL_WRAPPER(istrstream_str_ctor
, 12)
4320 istream
* __thiscall
istrstream_str_ctor(istream
*this, char *str
, BOOL virt_init
)
4322 return istrstream_buffer_ctor(this, str
, 0, virt_init
);
4325 /* ?rdbuf@istrstream@@QBEPAVstrstreambuf@@XZ */
4326 /* ?rdbuf@istrstream@@QEBAPEAVstrstreambuf@@XZ */
4327 DEFINE_THISCALL_WRAPPER(istrstream_rdbuf
, 4)
4328 strstreambuf
* __thiscall
istrstream_rdbuf(const istream
*this)
4330 return (strstreambuf
*) istream_get_ios(this)->sb
;
4333 /* ?str@istrstream@@QAEPADXZ */
4334 /* ?str@istrstream@@QEAAPEADXZ */
4335 DEFINE_THISCALL_WRAPPER(istrstream_str
, 4)
4336 char* __thiscall
istrstream_str(istream
*this)
4338 return strstreambuf_str(istrstream_rdbuf(this));
4341 /* ??0ifstream@@QAE@ABV0@@Z */
4342 /* ??0ifstream@@QEAA@AEBV0@@Z */
4343 DEFINE_THISCALL_WRAPPER(ifstream_copy_ctor
, 12)
4344 istream
* __thiscall
ifstream_copy_ctor(istream
*this, const istream
*copy
, BOOL virt_init
)
4346 TRACE("(%p %p %d)\n", this, copy
, virt_init
);
4347 istream_withassign_copy_ctor(this, copy
, virt_init
);
4348 istream_get_ios(this)->vtable
= &ifstream_vtable
;
4352 /* ??0ifstream@@QAE@HPADH@Z */
4353 /* ??0ifstream@@QEAA@HPEADH@Z */
4354 DEFINE_THISCALL_WRAPPER(ifstream_buffer_ctor
, 20)
4355 istream
* __thiscall
ifstream_buffer_ctor(istream
*this, filedesc fd
, char *buffer
, int length
, BOOL virt_init
)
4358 filebuf
*fb
= operator_new(sizeof(filebuf
));
4360 TRACE("(%p %d %p %d %d)\n", this, fd
, buffer
, length
, virt_init
);
4363 FIXME("out of memory\n");
4367 filebuf_fd_reserve_ctor(fb
, fd
, buffer
, length
);
4368 istream_sb_ctor(this, &fb
->base
, virt_init
);
4370 base
= istream_get_ios(this);
4371 base
->vtable
= &ifstream_vtable
;
4377 /* ??0ifstream@@QAE@H@Z */
4378 /* ??0ifstream@@QEAA@H@Z */
4379 DEFINE_THISCALL_WRAPPER(ifstream_fd_ctor
, 12)
4380 istream
* __thiscall
ifstream_fd_ctor(istream
*this, filedesc fd
, BOOL virt_init
)
4383 filebuf
*fb
= operator_new(sizeof(filebuf
));
4385 TRACE("(%p %d %d)\n", this, fd
, virt_init
);
4388 FIXME("out of memory\n");
4392 filebuf_fd_ctor(fb
, fd
);
4393 istream_sb_ctor(this, &fb
->base
, virt_init
);
4395 base
= istream_get_ios(this);
4396 base
->vtable
= &ifstream_vtable
;
4402 /* ??0ifstream@@QAE@PBDHH@Z */
4403 /* ??0ifstream@@QEAA@PEBDHH@Z */
4404 DEFINE_THISCALL_WRAPPER(ifstream_open_ctor
, 20)
4405 istream
* __thiscall
ifstream_open_ctor(istream
*this, const char *name
, ios_open_mode mode
, int protection
, BOOL virt_init
)
4408 filebuf
*fb
= operator_new(sizeof(filebuf
));
4410 TRACE("(%p %s %d %d %d)\n", this, name
, mode
, protection
, virt_init
);
4413 FIXME("out of memory\n");
4418 istream_sb_ctor(this, &fb
->base
, virt_init
);
4420 base
= istream_get_ios(this);
4421 base
->vtable
= &ifstream_vtable
;
4424 if (filebuf_open(fb
, name
, mode
|OPENMODE_in
, protection
) == NULL
)
4425 base
->state
|= IOSTATE_failbit
;
4429 /* ??0ifstream@@QAE@XZ */
4430 /* ??0ifstream@@QEAA@XZ */
4431 DEFINE_THISCALL_WRAPPER(ifstream_ctor
, 8)
4432 istream
* __thiscall
ifstream_ctor(istream
*this, BOOL virt_init
)
4434 return ifstream_fd_ctor(this, -1, virt_init
);
4437 /* ?rdbuf@ifstream@@QBEPAVfilebuf@@XZ */
4438 /* ?rdbuf@ifstream@@QEBAPEAVfilebuf@@XZ */
4439 DEFINE_THISCALL_WRAPPER(ifstream_rdbuf
, 4)
4440 filebuf
* __thiscall
ifstream_rdbuf(const istream
*this)
4442 TRACE("(%p)\n", this);
4443 return (filebuf
*) istream_get_ios(this)->sb
;
4446 /* ?fd@ifstream@@QBEHXZ */
4447 /* ?fd@ifstream@@QEBAHXZ */
4448 DEFINE_THISCALL_WRAPPER(ifstream_fd
, 4)
4449 filedesc __thiscall
ifstream_fd(istream
*this)
4451 TRACE("(%p)\n", this);
4452 return filebuf_fd(ifstream_rdbuf(this));
4455 /* ?attach@ifstream@@QAEXH@Z */
4456 /* ?attach@ifstream@@QEAAXH@Z */
4457 DEFINE_THISCALL_WRAPPER(ifstream_attach
, 8)
4458 void __thiscall
ifstream_attach(istream
*this, filedesc fd
)
4460 ios
*base
= istream_get_ios(this);
4461 TRACE("(%p %d)\n", this, fd
);
4462 if (filebuf_attach(ifstream_rdbuf(this), fd
) == NULL
)
4463 ios_clear(base
, base
->state
| IOSTATE_failbit
);
4466 /* ?close@ifstream@@QAEXXZ */
4467 /* ?close@ifstream@@QEAAXXZ */
4468 DEFINE_THISCALL_WRAPPER(ifstream_close
, 4)
4469 void __thiscall
ifstream_close(istream
*this)
4471 ios
*base
= istream_get_ios(this);
4472 TRACE("(%p)\n", this);
4473 if (filebuf_close(ifstream_rdbuf(this)) == NULL
)
4474 ios_clear(base
, base
->state
| IOSTATE_failbit
);
4476 ios_clear(base
, IOSTATE_goodbit
);
4479 /* ?is_open@ifstream@@QBEHXZ */
4480 /* ?is_open@ifstream@@QEBAHXZ */
4481 DEFINE_THISCALL_WRAPPER(ifstream_is_open
, 4)
4482 int __thiscall
ifstream_is_open(const istream
*this)
4484 TRACE("(%p)\n", this);
4485 return filebuf_is_open(ifstream_rdbuf(this));
4488 /* ?open@ifstream@@QAEXPBDHH@Z */
4489 /* ?open@ifstream@@QEAAXPEBDHH@Z */
4490 DEFINE_THISCALL_WRAPPER(ifstream_open
, 16)
4491 void __thiscall
ifstream_open(istream
*this, const char *name
, ios_open_mode mode
, int protection
)
4493 ios
*base
= istream_get_ios(this);
4494 TRACE("(%p %s %d %d)\n", this, name
, mode
, protection
);
4495 if (filebuf_open(ifstream_rdbuf(this), name
, mode
|OPENMODE_in
, protection
) == NULL
)
4496 ios_clear(base
, base
->state
| IOSTATE_failbit
);
4499 /* ?setbuf@ifstream@@QAEPAVstreambuf@@PADH@Z */
4500 /* ?setbuf@ifstream@@QEAAPEAVstreambuf@@PEADH@Z */
4501 DEFINE_THISCALL_WRAPPER(ifstream_setbuf
, 12)
4502 streambuf
* __thiscall
ifstream_setbuf(istream
*this, char *buffer
, int length
)
4504 ios
*base
= istream_get_ios(this);
4505 filebuf
* fb
= ifstream_rdbuf(this);
4507 TRACE("(%p %p %d)\n", this, buffer
, length
);
4509 if (filebuf_is_open(fb
)) {
4510 ios_clear(base
, base
->state
| IOSTATE_failbit
);
4514 return filebuf_setbuf(fb
, buffer
, length
);
4517 /* ?setmode@ifstream@@QAEHH@Z */
4518 /* ?setmode@ifstream@@QEAAHH@Z */
4519 DEFINE_THISCALL_WRAPPER(ifstream_setmode
, 8)
4520 int __thiscall
ifstream_setmode(istream
*this, int mode
)
4522 TRACE("(%p %d)\n", this, mode
);
4523 return filebuf_setmode(ifstream_rdbuf(this), mode
);
4526 static inline ios
* iostream_to_ios(const iostream
*this)
4528 return (ios
*)((char*)this + iostream_vbtable_istream
[1]);
4531 static inline iostream
* ios_to_iostream(const ios
*base
)
4533 return (iostream
*)((char*)base
- iostream_vbtable_istream
[1]);
4536 /* ??0iostream@@IAE@XZ */
4537 /* ??0iostream@@IEAA@XZ */
4538 DEFINE_THISCALL_WRAPPER(iostream_ctor
, 8)
4539 iostream
* __thiscall
iostream_ctor(iostream
*this, BOOL virt_init
)
4543 TRACE("(%p %d)\n", this, virt_init
);
4546 this->base1
.vbtable
= iostream_vbtable_istream
;
4547 this->base2
.vbtable
= iostream_vbtable_ostream
;
4548 base
= istream_get_ios(&this->base1
);
4551 base
= istream_get_ios(&this->base1
);
4552 istream_ctor(&this->base1
, FALSE
);
4553 ostream_ctor(&this->base2
, FALSE
);
4554 base
->vtable
= &iostream_vtable
;
4558 /* ??0iostream@@QAE@PAVstreambuf@@@Z */
4559 /* ??0iostream@@QEAA@PEAVstreambuf@@@Z */
4560 DEFINE_THISCALL_WRAPPER(iostream_sb_ctor
, 12)
4561 iostream
* __thiscall
iostream_sb_ctor(iostream
*this, streambuf
*sb
, BOOL virt_init
)
4563 TRACE("(%p %p %d)\n", this, sb
, virt_init
);
4564 iostream_ctor(this, virt_init
);
4565 ios_init(istream_get_ios(&this->base1
), sb
);
4569 /* ??0iostream@@IAE@ABV0@@Z */
4570 /* ??0iostream@@IEAA@AEBV0@@Z */
4571 DEFINE_THISCALL_WRAPPER(iostream_copy_ctor
, 12)
4572 iostream
* __thiscall
iostream_copy_ctor(iostream
*this, const iostream
*copy
, BOOL virt_init
)
4574 return iostream_sb_ctor(this, istream_get_ios(©
->base1
)->sb
, virt_init
);
4577 /* ??1iostream@@UAE@XZ */
4578 /* ??1iostream@@UEAA@XZ */
4579 /* ??1stdiostream@@UAE@XZ */
4580 /* ??1stdiostream@@UEAA@XZ */
4581 /* ??1strstream@@UAE@XZ */
4582 /* ??1strstream@@UEAA@XZ */
4583 /* ??1fstream@@UAE@XZ */
4584 /* ??1fstream@@UEAA@XZ */
4585 DEFINE_THISCALL_WRAPPER(iostream_dtor
, 4)
4586 void __thiscall
iostream_dtor(ios
*base
)
4588 iostream
*this = ios_to_iostream(base
);
4590 TRACE("(%p)\n", this);
4592 ostream_dtor(ostream_to_ios(&this->base2
));
4593 istream_dtor(istream_to_ios(&this->base1
));
4596 /* ??4iostream@@IAEAAV0@PAVstreambuf@@@Z */
4597 /* ??4iostream@@IEAAAEAV0@PEAVstreambuf@@@Z */
4598 DEFINE_THISCALL_WRAPPER(iostream_assign_sb
, 8)
4599 iostream
* __thiscall
iostream_assign_sb(iostream
*this, streambuf
*sb
)
4601 TRACE("(%p %p)\n", this, sb
);
4602 this->base1
.count
= 0;
4603 ostream_assign_sb(&this->base2
, sb
);
4607 /* ??4iostream@@IAEAAV0@AAV0@@Z */
4608 /* ??4iostream@@IEAAAEAV0@AEAV0@@Z */
4609 /* ??4stdiostream@@QAEAAV0@AAV0@@Z */
4610 /* ??4stdiostream@@QEAAAEAV0@AEAV0@@Z */
4611 /* ??4strstream@@QAEAAV0@ABV0@@Z */
4612 /* ??4strstream@@QEAAAEAV0@AEBV0@@Z */
4613 DEFINE_THISCALL_WRAPPER(iostream_assign
, 8)
4614 iostream
* __thiscall
iostream_assign(iostream
*this, const iostream
*rhs
)
4616 return iostream_assign_sb(this, istream_get_ios(&rhs
->base1
)->sb
);
4619 /* ??_Diostream@@QAEXXZ */
4620 /* ??_Diostream@@QEAAXXZ */
4621 /* ??_Dstdiostream@@QAEXXZ */
4622 /* ??_Dstdiostream@@QEAAXXZ */
4623 /* ??_Dstrstream@@QAEXXZ */
4624 /* ??_Dstrstream@@QEAAXXZ */
4625 DEFINE_THISCALL_WRAPPER(iostream_vbase_dtor
, 4)
4626 void __thiscall
iostream_vbase_dtor(iostream
*this)
4628 ios
*base
= iostream_to_ios(this);
4630 TRACE("(%p)\n", this);
4632 iostream_dtor(base
);
4636 /* ??_Eiostream@@UAEPAXI@Z */
4637 /* ??_Estdiostream@@UAEPAXI@Z */
4638 /* ??_Estrstream@@UAEPAXI@Z */
4639 DEFINE_THISCALL_WRAPPER(iostream_vector_dtor
, 8)
4640 iostream
* __thiscall
iostream_vector_dtor(ios
*base
, unsigned int flags
)
4642 iostream
*this = ios_to_iostream(base
);
4644 TRACE("(%p %x)\n", this, flags
);
4647 /* we have an array, with the number of elements stored before the first object */
4648 INT_PTR i
, *ptr
= (INT_PTR
*)this-1;
4650 for (i
= *ptr
-1; i
>= 0; i
--)
4651 iostream_vbase_dtor(this+i
);
4652 operator_delete(ptr
);
4654 iostream_vbase_dtor(this);
4656 operator_delete(this);
4661 /* ??_Giostream@@UAEPAXI@Z */
4662 /* ??_Gstdiostream@@UAEPAXI@Z */
4663 /* ??_Gstrstream@@UAEPAXI@Z */
4664 DEFINE_THISCALL_WRAPPER(iostream_scalar_dtor
, 8)
4665 iostream
* __thiscall
iostream_scalar_dtor(ios
*base
, unsigned int flags
)
4667 iostream
*this = ios_to_iostream(base
);
4669 TRACE("(%p %x)\n", this, flags
);
4671 iostream_vbase_dtor(this);
4672 if (flags
& 1) operator_delete(this);
4676 static iostream
* iostream_internal_copy_ctor(iostream
*this, const iostream
*copy
, const vtable_ptr
*vtbl
, BOOL virt_init
)
4678 ios
*base
, *base_copy
= istream_get_ios(©
->base1
);
4681 this->base1
.vbtable
= iostream_vbtable_istream
;
4682 this->base2
.vbtable
= iostream_vbtable_ostream
;
4683 base
= istream_get_ios(&this->base1
);
4684 ios_copy_ctor(base
, base_copy
);
4686 base
= istream_get_ios(&this->base1
);
4687 ios_init(base
, base_copy
->sb
);
4688 istream_ctor(&this->base1
, FALSE
);
4689 ostream_ctor(&this->base2
, FALSE
);
4690 base
->vtable
= vtbl
;
4694 static iostream
* iostream_internal_sb_ctor(iostream
*this, streambuf
*sb
, const vtable_ptr
*vtbl
, BOOL virt_init
)
4698 iostream_ctor(this, virt_init
);
4699 base
= istream_get_ios(&this->base1
);
4702 base
->vtable
= vtbl
;
4707 /* ??0strstream@@QAE@ABV0@@Z */
4708 /* ??0strstream@@QEAA@AEBV0@@Z */
4709 DEFINE_THISCALL_WRAPPER(strstream_copy_ctor
, 12)
4710 iostream
* __thiscall
strstream_copy_ctor(iostream
*this, const iostream
*copy
, BOOL virt_init
)
4712 TRACE("(%p %p %d)\n", this, copy
, virt_init
);
4713 return iostream_internal_copy_ctor(this, copy
, &strstream_vtable
, virt_init
);
4716 /* ??0strstream@@QAE@PADHH@Z */
4717 /* ??0strstream@@QEAA@PEADHH@Z */
4718 DEFINE_THISCALL_WRAPPER(strstream_buffer_ctor
, 20)
4719 iostream
* __thiscall
strstream_buffer_ctor(iostream
*this, char *buffer
, int length
, int mode
, BOOL virt_init
)
4721 strstreambuf
*ssb
= operator_new(sizeof(strstreambuf
));
4723 TRACE("(%p %p %d %d %d)\n", this, buffer
, length
, mode
, virt_init
);
4726 FIXME("out of memory\n");
4730 strstreambuf_buffer_ctor(ssb
, buffer
, length
, buffer
);
4732 if ((mode
& OPENMODE_out
) && (mode
& (OPENMODE_app
|OPENMODE_ate
)))
4733 ssb
->base
.pptr
= buffer
+ strlen(buffer
);
4735 return iostream_internal_sb_ctor(this, &ssb
->base
, &strstream_vtable
, virt_init
);
4738 /* ??0strstream@@QAE@XZ */
4739 /* ??0strstream@@QEAA@XZ */
4740 DEFINE_THISCALL_WRAPPER(strstream_ctor
, 8)
4741 iostream
* __thiscall
strstream_ctor(iostream
*this, BOOL virt_init
)
4743 strstreambuf
*ssb
= operator_new(sizeof(strstreambuf
));
4745 TRACE("(%p %d)\n", this, virt_init
);
4748 FIXME("out of memory\n");
4752 strstreambuf_ctor(ssb
);
4754 return iostream_internal_sb_ctor(this, &ssb
->base
, &strstream_vtable
, virt_init
);
4757 /* ?pcount@strstream@@QBEHXZ */
4758 /* ?pcount@strstream@@QEBAHXZ */
4759 DEFINE_THISCALL_WRAPPER(strstream_pcount
, 4)
4760 int __thiscall
strstream_pcount(const iostream
*this)
4762 return streambuf_out_waiting(istream_get_ios(&this->base1
)->sb
);
4765 /* ?rdbuf@strstream@@QBEPAVstrstreambuf@@XZ */
4766 /* ?rdbuf@strstream@@QEBAPEAVstrstreambuf@@XZ */
4767 DEFINE_THISCALL_WRAPPER(strstream_rdbuf
, 4)
4768 strstreambuf
* __thiscall
strstream_rdbuf(const iostream
*this)
4770 return (strstreambuf
*) istream_get_ios(&this->base1
)->sb
;
4773 /* ?str@strstream@@QAEPADXZ */
4774 /* ?str@strstream@@QEAAPEADXZ */
4775 DEFINE_THISCALL_WRAPPER(strstream_str
, 4)
4776 char* __thiscall
strstream_str(iostream
*this)
4778 return strstreambuf_str(strstream_rdbuf(this));
4781 /* ??0stdiostream@@QAE@ABV0@@Z */
4782 /* ??0stdiostream@@QEAA@AEBV0@@Z */
4783 DEFINE_THISCALL_WRAPPER(stdiostream_copy_ctor
, 12)
4784 iostream
* __thiscall
stdiostream_copy_ctor(iostream
*this, const iostream
*copy
, BOOL virt_init
)
4786 TRACE("(%p %p %d)\n", this, copy
, virt_init
);
4787 return iostream_internal_copy_ctor(this, copy
, &stdiostream_vtable
, virt_init
);
4790 /* ??0stdiostream@@QAE@PAU_iobuf@@@Z */
4791 /* ??0stdiostream@@QEAA@PEAU_iobuf@@@Z */
4792 DEFINE_THISCALL_WRAPPER(stdiostream_file_ctor
, 12)
4793 iostream
* __thiscall
stdiostream_file_ctor(iostream
*this, FILE *file
, BOOL virt_init
)
4795 stdiobuf
*stb
= operator_new(sizeof(stdiobuf
));
4797 TRACE("(%p %p %d)\n", this, file
, virt_init
);
4800 FIXME("out of memory\n");
4804 stdiobuf_file_ctor(stb
, file
);
4806 return iostream_internal_sb_ctor(this, &stb
->base
, &stdiostream_vtable
, virt_init
);
4809 /* ?rdbuf@stdiostream@@QBEPAVstdiobuf@@XZ */
4810 /* ?rdbuf@stdiostream@@QEBAPEAVstdiobuf@@XZ */
4811 DEFINE_THISCALL_WRAPPER(stdiostream_rdbuf
, 4)
4812 stdiobuf
* __thiscall
stdiostream_rdbuf(const iostream
*this)
4814 return (stdiobuf
*) istream_get_ios(&this->base1
)->sb
;
4817 /* ??0fstream@@QAE@ABV0@@Z */
4818 /* ??0fstream@@QEAA@AEBV0@@Z */
4819 DEFINE_THISCALL_WRAPPER(fstream_copy_ctor
, 12)
4820 iostream
* __thiscall
fstream_copy_ctor(iostream
*this, const iostream
*copy
, BOOL virt_init
)
4822 TRACE("(%p %p %d)\n", this, copy
, virt_init
);
4823 iostream_internal_copy_ctor(this, copy
, &fstream_vtable
, virt_init
);
4827 /* ??0fstream@@QAE@HPADH@Z */
4828 /* ??0fstream@@QEAA@HPEADH@Z */
4829 DEFINE_THISCALL_WRAPPER(fstream_buffer_ctor
, 20)
4830 iostream
* __thiscall
fstream_buffer_ctor(iostream
*this, filedesc fd
, char *buffer
, int length
, BOOL virt_init
)
4833 filebuf
*fb
= operator_new(sizeof(filebuf
));
4835 TRACE("(%p %d %p %d %d)\n", this, fd
, buffer
, length
, virt_init
);
4838 FIXME("out of memory\n");
4842 filebuf_fd_reserve_ctor(fb
, fd
, buffer
, length
);
4844 iostream_internal_sb_ctor(this, &fb
->base
, &fstream_vtable
, virt_init
);
4846 base
= istream_get_ios(&this->base1
);
4852 /* ??0fstream@@QAE@H@Z */
4853 /* ??0fstream@@QEAA@H@Z */
4854 DEFINE_THISCALL_WRAPPER(fstream_fd_ctor
, 12)
4855 iostream
* __thiscall
fstream_fd_ctor(iostream
*this, filedesc fd
, BOOL virt_init
)
4858 filebuf
*fb
= operator_new(sizeof(filebuf
));
4860 TRACE("(%p %d %d)\n", this, fd
, virt_init
);
4863 FIXME("out of memory\n");
4867 filebuf_fd_ctor(fb
, fd
);
4869 iostream_internal_sb_ctor(this, &fb
->base
, &fstream_vtable
, virt_init
);
4871 base
= istream_get_ios(&this->base1
);
4877 /* ??0fstream@@QAE@PBDHH@Z */
4878 /* ??0fstream@@QEAA@PEBDHH@Z */
4879 DEFINE_THISCALL_WRAPPER(fstream_open_ctor
, 20)
4880 iostream
* __thiscall
fstream_open_ctor(iostream
*this, const char *name
, ios_open_mode mode
, int protection
, BOOL virt_init
)
4883 filebuf
*fb
= operator_new(sizeof(filebuf
));
4885 TRACE("(%p %s %d %d %d)\n", this, name
, mode
, protection
, virt_init
);
4888 FIXME("out of memory\n");
4894 iostream_internal_sb_ctor(this, &fb
->base
, &fstream_vtable
, virt_init
);
4896 base
= istream_get_ios(&this->base1
);
4899 if (filebuf_open(fb
, name
, mode
, protection
) == NULL
)
4900 base
->state
|= IOSTATE_failbit
;
4904 /* ??0fstream@@QAE@XZ */
4905 /* ??0fstream@@QEAA@XZ */
4906 DEFINE_THISCALL_WRAPPER(fstream_ctor
, 8)
4907 iostream
* __thiscall
fstream_ctor(iostream
*this, BOOL virt_init
)
4909 return fstream_fd_ctor(this, -1, virt_init
);
4912 /* ?rdbuf@fstream@@QBEPAVfilebuf@@XZ */
4913 /* ?rdbuf@fstream@@QEBAPEAVfilebuf@@XZ */
4914 DEFINE_THISCALL_WRAPPER(fstream_rdbuf
, 4)
4915 filebuf
* __thiscall
fstream_rdbuf(const iostream
*this)
4917 TRACE("(%p)\n", this);
4918 return (filebuf
*) istream_get_ios(&this->base1
)->sb
;
4921 /* ?fd@fstream@@QBEHXZ */
4922 /* ?fd@fstream@@QEBAHXZ */
4923 DEFINE_THISCALL_WRAPPER(fstream_fd
, 4)
4924 filedesc __thiscall
fstream_fd(iostream
*this)
4926 TRACE("(%p)\n", this);
4927 return filebuf_fd(fstream_rdbuf(this));
4930 /* ?attach@fstream@@QAEXH@Z */
4931 /* ?attach@fstream@@QEAAXH@Z */
4932 DEFINE_THISCALL_WRAPPER(fstream_attach
, 8)
4933 void __thiscall
fstream_attach(iostream
*this, filedesc fd
)
4935 ios
*base
= istream_get_ios(&this->base1
);
4936 TRACE("(%p %d)\n", this, fd
);
4937 if (filebuf_attach(fstream_rdbuf(this), fd
) == NULL
)
4938 ios_clear(base
, base
->state
| IOSTATE_failbit
);
4941 /* ?close@fstream@@QAEXXZ */
4942 /* ?close@fstream@@QEAAXXZ */
4943 DEFINE_THISCALL_WRAPPER(fstream_close
, 4)
4944 void __thiscall
fstream_close(iostream
*this)
4946 ios
*base
= istream_get_ios(&this->base1
);
4947 TRACE("(%p)\n", this);
4948 if (filebuf_close(fstream_rdbuf(this)) == NULL
)
4949 ios_clear(base
, base
->state
| IOSTATE_failbit
);
4951 ios_clear(base
, IOSTATE_goodbit
);
4954 /* ?is_open@fstream@@QBEHXZ */
4955 /* ?is_open@fstream@@QEBAHXZ */
4956 DEFINE_THISCALL_WRAPPER(fstream_is_open
, 4)
4957 int __thiscall
fstream_is_open(const iostream
*this)
4959 TRACE("(%p)\n", this);
4960 return filebuf_is_open(fstream_rdbuf(this));
4963 /* ?open@fstream@@QAEXPBDHH@Z */
4964 /* ?open@fstream@@QEAAXPEBDHH@Z */
4965 DEFINE_THISCALL_WRAPPER(fstream_open
, 16)
4966 void __thiscall
fstream_open(iostream
*this, const char *name
, ios_open_mode mode
, int protection
)
4968 ios
*base
= istream_get_ios(&this->base1
);
4969 TRACE("(%p %s %d %d)\n", this, name
, mode
, protection
);
4970 if (filebuf_open(fstream_rdbuf(this), name
, mode
|OPENMODE_out
, protection
) == NULL
)
4971 ios_clear(base
, base
->state
| IOSTATE_failbit
);
4974 /* ?setbuf@fstream@@QAEPAVstreambuf@@PADH@Z */
4975 /* ?setbuf@fstream@@QEAAPEAVstreambuf@@PEADH@Z */
4976 DEFINE_THISCALL_WRAPPER(fstream_setbuf
, 12)
4977 streambuf
* __thiscall
fstream_setbuf(iostream
*this, char *buffer
, int length
)
4979 ios
*base
= istream_get_ios(&this->base1
);
4980 filebuf
* fb
= fstream_rdbuf(this);
4982 TRACE("(%p %p %d)\n", this, buffer
, length
);
4984 if (filebuf_is_open(fb
)) {
4985 ios_clear(base
, base
->state
| IOSTATE_failbit
);
4989 return filebuf_setbuf(fb
, buffer
, length
);
4992 /* ?setmode@fstream@@QAEHH@Z */
4993 /* ?setmode@fstream@@QEAAHH@Z */
4994 DEFINE_THISCALL_WRAPPER(fstream_setmode
, 8)
4995 int __thiscall
fstream_setmode(iostream
*this, int mode
)
4997 TRACE("(%p %d)\n", this, mode
);
4998 return filebuf_setmode(fstream_rdbuf(this), mode
);
5001 /* ??0Iostream_init@@QAE@AAVios@@H@Z */
5002 /* ??0Iostream_init@@QEAA@AEAVios@@H@Z */
5003 DEFINE_THISCALL_WRAPPER(Iostream_init_ios_ctor
, 12)
5004 void* __thiscall
Iostream_init_ios_ctor(void *this, ios
*obj
, int n
)
5006 TRACE("(%p %p %d)\n", this, obj
, n
);
5009 obj
->tie
= &cout
.os
;
5011 ios_setf(obj
, FLAGS_unitbuf
);
5016 /* ??0Iostream_init@@QAE@XZ */
5017 /* ??0Iostream_init@@QEAA@XZ */
5018 DEFINE_THISCALL_WRAPPER(Iostream_init_ctor
, 4)
5019 void* __thiscall
Iostream_init_ctor(void *this)
5021 TRACE("(%p)\n", this);
5025 /* ??1Iostream_init@@QAE@XZ */
5026 /* ??1Iostream_init@@QEAA@XZ */
5027 DEFINE_THISCALL_WRAPPER(Iostream_init_dtor
, 4)
5028 void __thiscall
Iostream_init_dtor(void *this)
5030 TRACE("(%p)\n", this);
5033 /* ??4Iostream_init@@QAEAAV0@ABV0@@Z */
5034 /* ??4Iostream_init@@QEAAAEAV0@AEBV0@@Z */
5035 DEFINE_THISCALL_WRAPPER(Iostream_init_assign
, 8)
5036 void* __thiscall
Iostream_init_assign(void *this, const void *rhs
)
5038 TRACE("(%p %p)\n", this, rhs
);
5042 /* ?sync_with_stdio@ios@@SAXXZ */
5043 void __cdecl
ios_sync_with_stdio(void)
5045 if (!ios_sunk_with_stdio
) {
5050 /* run at most once */
5051 ios_sunk_with_stdio
++;
5053 /* calls to [io]stream_assign_sb automatically destroy the old buffers */
5054 if ((new_buf
= operator_new(sizeof(stdiobuf
)))) {
5055 stdiobuf_file_ctor(new_buf
, stdin
);
5056 istream_assign_sb(&cin
.is
, &new_buf
->base
);
5058 istream_assign_sb(&cin
.is
, NULL
);
5059 cin
.vbase
.delbuf
= 1;
5060 ios_setf(&cin
.vbase
, FLAGS_stdio
);
5062 if ((new_buf
= operator_new(sizeof(stdiobuf
)))) {
5063 stdiobuf_file_ctor(new_buf
, stdout
);
5064 stdiobuf_setrwbuf(new_buf
, 0, 80);
5065 ostream_assign_sb(&cout
.os
, &new_buf
->base
);
5067 ostream_assign_sb(&cout
.os
, NULL
);
5068 cout
.vbase
.delbuf
= 1;
5069 ios_setf(&cout
.vbase
, FLAGS_unitbuf
| FLAGS_stdio
);
5071 if ((new_buf
= operator_new(sizeof(stdiobuf
)))) {
5072 stdiobuf_file_ctor(new_buf
, stderr
);
5073 stdiobuf_setrwbuf(new_buf
, 0, 80);
5074 ostream_assign_sb(&cerr
.os
, &new_buf
->base
);
5076 ostream_assign_sb(&cerr
.os
, NULL
);
5077 cerr
.vbase
.delbuf
= 1;
5078 ios_setf(&cerr
.vbase
, FLAGS_unitbuf
| FLAGS_stdio
);
5080 if ((new_buf
= operator_new(sizeof(stdiobuf
)))) {
5081 stdiobuf_file_ctor(new_buf
, stderr
);
5082 stdiobuf_setrwbuf(new_buf
, 0, 512);
5083 ostream_assign_sb(&MSVCP_clog
.os
, &new_buf
->base
);
5085 ostream_assign_sb(&MSVCP_clog
.os
, NULL
);
5086 MSVCP_clog
.vbase
.delbuf
= 1;
5087 ios_setf(&MSVCP_clog
.vbase
, FLAGS_stdio
);
5092 #ifdef __ASM_USE_THISCALL_WRAPPER
5094 #define DEFINE_VTBL_WRAPPER(off) \
5095 __ASM_GLOBAL_FUNC(vtbl_wrapper_ ## off, \
5099 "movl 0(%ecx), %eax\n\t" \
5100 "jmp *" #off "(%eax)\n\t")
5102 DEFINE_VTBL_WRAPPER(0);
5103 DEFINE_VTBL_WRAPPER(4);
5104 DEFINE_VTBL_WRAPPER(8);
5105 DEFINE_VTBL_WRAPPER(12);
5106 DEFINE_VTBL_WRAPPER(16);
5107 DEFINE_VTBL_WRAPPER(20);
5108 DEFINE_VTBL_WRAPPER(24);
5109 DEFINE_VTBL_WRAPPER(28);
5110 DEFINE_VTBL_WRAPPER(32);
5111 DEFINE_VTBL_WRAPPER(36);
5112 DEFINE_VTBL_WRAPPER(40);
5113 DEFINE_VTBL_WRAPPER(44);
5114 DEFINE_VTBL_WRAPPER(48);
5115 DEFINE_VTBL_WRAPPER(52);
5116 DEFINE_VTBL_WRAPPER(56);
5120 void __cdecl
_mtlock(CRITICAL_SECTION
*crit
)
5122 TRACE("(%p)\n", crit
);
5123 EnterCriticalSection(crit
);
5126 void __cdecl
_mtunlock(CRITICAL_SECTION
*crit
)
5128 TRACE("(%p)\n", crit
);
5129 LeaveCriticalSection(crit
);
5132 static void* (__cdecl
*MSVCRT_operator_new
)(SIZE_T
);
5133 static void (__cdecl
*MSVCRT_operator_delete
)(void*);
5135 void* __cdecl
operator_new(SIZE_T size
)
5137 return MSVCRT_operator_new(size
);
5140 void __cdecl
operator_delete(void *mem
)
5142 MSVCRT_operator_delete(mem
);
5145 static void init_cxx_funcs(void)
5147 HMODULE hmod
= GetModuleHandleA("msvcrt.dll");
5149 if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */
5151 MSVCRT_operator_new
= (void*)GetProcAddress(hmod
, "??2@YAPEAX_K@Z");
5152 MSVCRT_operator_delete
= (void*)GetProcAddress(hmod
, "??3@YAXPEAX@Z");
5156 MSVCRT_operator_new
= (void*)GetProcAddress(hmod
, "??2@YAPAXI@Z");
5157 MSVCRT_operator_delete
= (void*)GetProcAddress(hmod
, "??3@YAXPAX@Z");
5161 static void init_io(void *base
)
5166 init_streambuf_rtti(base
);
5167 init_filebuf_rtti(base
);
5168 init_strstreambuf_rtti(base
);
5169 init_stdiobuf_rtti(base
);
5170 init_ios_rtti(base
);
5171 init_ostream_rtti(base
);
5172 init_ostream_withassign_rtti(base
);
5173 init_ostrstream_rtti(base
);
5174 init_ofstream_rtti(base
);
5175 init_istream_rtti(base
);
5176 init_istream_withassign_rtti(base
);
5177 init_istrstream_rtti(base
);
5178 init_ifstream_rtti(base
);
5179 init_iostream_rtti(base
);
5180 init_strstream_rtti(base
);
5181 init_stdiostream_rtti(base
);
5182 init_fstream_rtti(base
);
5185 if ((fb
= operator_new(sizeof(filebuf
)))) {
5186 filebuf_fd_ctor(fb
, 0);
5187 istream_withassign_sb_ctor(&cin
.is
, &fb
->base
, TRUE
);
5189 istream_withassign_sb_ctor(&cin
.is
, NULL
, TRUE
);
5190 Iostream_init_ios_ctor(NULL
, &cin
.vbase
, 0);
5192 if ((fb
= operator_new(sizeof(filebuf
)))) {
5193 filebuf_fd_ctor(fb
, 1);
5194 ostream_withassign_sb_ctor(&cout
.os
, &fb
->base
, TRUE
);
5196 ostream_withassign_sb_ctor(&cout
.os
, NULL
, TRUE
);
5197 Iostream_init_ios_ctor(NULL
, &cout
.vbase
, -1);
5199 if ((fb
= operator_new(sizeof(filebuf
)))) {
5200 filebuf_fd_ctor(fb
, 2);
5201 ostream_withassign_sb_ctor(&cerr
.os
, &fb
->base
, TRUE
);
5203 ostream_withassign_sb_ctor(&cerr
.os
, NULL
, TRUE
);
5204 Iostream_init_ios_ctor(NULL
, &cerr
.vbase
, 1);
5206 if ((fb
= operator_new(sizeof(filebuf
)))) {
5207 filebuf_fd_ctor(fb
, 2);
5208 ostream_withassign_sb_ctor(&MSVCP_clog
.os
, &fb
->base
, TRUE
);
5210 ostream_withassign_sb_ctor(&MSVCP_clog
.os
, NULL
, TRUE
);
5211 Iostream_init_ios_ctor(NULL
, &MSVCP_clog
.vbase
, 0);
5214 static void free_io(void)
5216 /* destructors take care of deleting the buffers */
5217 istream_vbase_dtor(&cin
.is
);
5218 ostream_vbase_dtor(&cout
.os
);
5219 ostream_vbase_dtor(&cerr
.os
);
5220 ostream_vbase_dtor(&MSVCP_clog
.os
);
5223 BOOL WINAPI
DllMain( HINSTANCE inst
, DWORD reason
, LPVOID reserved
)
5227 case DLL_PROCESS_ATTACH
:
5229 init_exception(inst
);
5231 DisableThreadLibraryCalls( inst
);
5233 case DLL_PROCESS_DETACH
:
5234 if (reserved
) break;