msvcp90: Fixed incorrect sentry object usage.
[wine] / dlls / msvcp60 / ios.c
1 /*
2  * Copyright 2011 Piotr Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <limits.h>
24 #include <share.h>
25
26 #include "msvcp.h"
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
31
32 /* ?_Index@ios_base@std@@0HA */
33 int ios_base_Index = 0;
34 /* ?_Sync@ios_base@std@@0_NA */
35 MSVCP_bool ios_base_Sync = FALSE;
36
37 typedef struct {
38     streamoff off;
39     __int64 DECLSPEC_ALIGN(8) pos;
40     int state;
41 } fpos_int;
42
43 static inline const char* debugstr_fpos_int(fpos_int *fpos)
44 {
45     return wine_dbg_sprintf("fpos(%ld %s %d)", fpos->off, wine_dbgstr_longlong(fpos->pos), fpos->state);
46 }
47
48 typedef struct {
49     void (__cdecl *pfunc)(ios_base*, streamsize);
50     streamsize arg;
51 } manip_streamsize;
52
53 typedef struct {
54     void (__cdecl *pfunc)(ios_base*, int);
55     int arg;
56 } manip_int;
57
58 typedef enum {
59     INITFL_new   = 0,
60     INITFL_open  = 1,
61     INITFL_close = 2
62 } basic_filebuf__Initfl;
63
64 typedef struct {
65     basic_streambuf_char base;
66     codecvt_char *cvt;
67     char putback;
68     MSVCP_bool wrotesome;
69     int state;
70     MSVCP_bool close;
71     FILE *file;
72 } basic_filebuf_char;
73
74 typedef struct {
75     basic_streambuf_wchar base;
76     codecvt_wchar *cvt;
77     wchar_t putback;
78     MSVCP_bool wrotesome;
79     int state;
80     MSVCP_bool close;
81     FILE *file;
82 } basic_filebuf_wchar;
83
84 typedef enum {
85     STRINGBUF_allocated = 1,
86     STRINGBUF_no_write = 2,
87     STRINGBUF_no_read = 4,
88     STRINGBUF_append = 8,
89     STRINGBUF_at_end = 16
90 } basic_stringbuf_state;
91
92 typedef struct {
93     basic_streambuf_char base;
94     char *pendsave;
95     char *seekhigh;
96     int alsize;
97     int state;
98     char allocator; /* empty struct */
99 } basic_stringbuf_char;
100
101 typedef struct {
102     basic_streambuf_wchar base;
103     wchar_t *pendsave;
104     wchar_t *seekhigh;
105     int alsize;
106     int state;
107     char allocator; /* empty struct */
108 } basic_stringbuf_wchar;
109
110 typedef struct {
111     ios_base base;
112     basic_streambuf_char *strbuf;
113     struct _basic_ostream_char *stream;
114     char fillch;
115 } basic_ios_char;
116
117 typedef struct {
118     ios_base base;
119     basic_streambuf_wchar *strbuf;
120     struct _basic_ostream_wchar *stream;
121     wchar_t fillch;
122 } basic_ios_wchar;
123
124 typedef struct _basic_ostream_char {
125     const int *vbtable;
126     /* virtual inheritance
127      * basic_ios_char basic_ios;
128      */
129 } basic_ostream_char;
130
131 typedef struct _basic_ostream_wchar {
132     const int *vbtable;
133     /* virtual inheritance
134      * basic_ios_wchar basic_ios;
135      */
136 } basic_ostream_wchar;
137
138 typedef struct {
139     const int *vbtable;
140     streamsize count;
141     /* virtual inheritance
142      * basic_ios_char basic_ios;
143      */
144 } basic_istream_char;
145
146 typedef struct {
147     const int *vbtable;
148     streamsize count;
149     /* virtual inheritance
150      * basic_ios_wchar basic_ios;
151      */
152 } basic_istream_wchar;
153
154 typedef struct {
155     basic_istream_char base1;
156     basic_ostream_char base2;
157     /* virtual inheritance
158      * basic_ios_char basic_ios;
159      */
160 } basic_iostream_char;
161
162 typedef struct {
163     basic_istream_wchar base1;
164     basic_ostream_wchar base2;
165     /* virtual inheritance
166      * basic_ios_wchar basic_ios;
167      */
168 } basic_iostream_wchar;
169
170 typedef struct {
171     basic_ostream_char base;
172     basic_filebuf_char filebuf;
173     /* virtual inheritance
174      * basic_ios_char basic_ios;
175      */
176 } basic_ofstream_char;
177
178 typedef struct {
179     basic_ostream_wchar base;
180     basic_filebuf_wchar filebuf;
181     /* virtual inheritance
182      * basic_ios_wchar basic_ios;
183      */
184 } basic_ofstream_wchar;
185
186 typedef struct {
187     basic_istream_char base;
188     basic_filebuf_char filebuf;
189     /* virtual inheritance
190      * basic_ios_char basic_ios;
191      */
192 } basic_ifstream_char;
193
194 typedef struct {
195     basic_istream_wchar base;
196     basic_filebuf_wchar filebuf;
197     /* virtual inheritance
198      * basic_ios_wchar basic_ios;
199      */
200 } basic_ifstream_wchar;
201
202 typedef struct {
203     basic_iostream_char base;
204     basic_filebuf_char filebuf;
205     /* virtual inheritance
206      * basic_ios_char basic_ios;
207      */
208 } basic_fstream_char;
209
210 typedef struct {
211     basic_iostream_wchar base;
212     basic_filebuf_wchar filebuf;
213     /* virtual inheritance
214      * basic_ios_char basic_ios;
215      */
216 } basic_fstream_wchar;
217
218 typedef struct {
219     basic_ostream_char base;
220     basic_stringbuf_char strbuf;
221     /* virtual inheritance
222      * basic_ios_char basic_ios;
223      */
224 } basic_ostringstream_char;
225
226 typedef struct {
227     basic_ostream_wchar base;
228     basic_stringbuf_wchar strbuf;
229     /* virtual inheritance
230      * basic_ios_wchar basic_ios;
231      */
232 } basic_ostringstream_wchar;
233
234 typedef struct {
235     basic_istream_char base;
236     basic_stringbuf_char strbuf;
237     /* virtual inheritance
238      * basic_ios_char basic_ios;
239      */
240 } basic_istringstream_char;
241
242 typedef struct {
243     basic_istream_wchar base;
244     basic_stringbuf_wchar strbuf;
245     /* virtual inheritance
246      * basic_ios_wchar basic_ios;
247      */
248 } basic_istringstream_wchar;
249
250 typedef struct {
251     basic_iostream_char base;
252     basic_stringbuf_char strbuf;
253     /* virtual inheritance
254      * basic_ios_char basic_ios;
255      */
256 } basic_stringstream_char;
257
258 typedef struct {
259     basic_iostream_wchar base;
260     basic_stringbuf_wchar strbuf;
261     /* virtual inheritance
262      * basic_ios_wchar basic_ios;
263      */
264 } basic_stringstream_wchar;
265
266 typedef enum {
267     STRSTATE_Allocated = 1,
268     STRSTATE_Constant = 2,
269     STRSTATE_Dynamic = 4,
270     STRSTATE_Frozen = 8
271 } strstreambuf__Strstate;
272
273 typedef struct {
274     basic_streambuf_char base;
275     streamsize minsize;
276     char *endsave;
277     char *seekhigh;
278     int strmode;
279     void* (__cdecl *palloc)(MSVCP_size_t);
280     void (__cdecl *pfree)(void*);
281 } strstreambuf;
282
283 typedef struct {
284     basic_ostream_char base;
285     strstreambuf buf;
286     /* virtual inheritance
287      * basic_ios_char basic_ios;
288      */
289 } ostrstream;
290
291 typedef struct {
292     basic_istream_char base;
293     strstreambuf buf;
294     /* virtual inheritance
295      * basic_ios_char basic_ios;
296      */
297 } istrstream;
298
299 typedef struct {
300     basic_iostream_char base;
301     strstreambuf buf;
302     /* virtual inheritance
303      * basic_ios_char basic_ios;
304      */
305 } strstream;
306
307 extern const vtable_ptr MSVCP_iosb_vtable;
308
309 /* ??_7ios_base@std@@6B@ */
310 extern const vtable_ptr MSVCP_ios_base_vtable;
311
312 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
313 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
314
315 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
316 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
317
318 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
319 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
320
321 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
322 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
323
324 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
325 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
326
327 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
328 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
329
330 /* ??_7?$basic_filebuf@DU?$char_traits@D@std@@@std@@6B@ */
331 extern const vtable_ptr MSVCP_basic_filebuf_char_vtable;
332
333 /* ??_7?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@6B@ */
334 extern const vtable_ptr MSVCP_basic_filebuf_wchar_vtable;
335
336 /* ??_7?$basic_filebuf@GU?$char_traits@G@std@@@std@@6B@ */
337 extern const vtable_ptr MSVCP_basic_filebuf_short_vtable;
338
339 /* ??_7?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
340 extern const vtable_ptr MSVCP_basic_stringbuf_char_vtable;
341
342 /* ??_7?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
343 extern const vtable_ptr MSVCP_basic_stringbuf_wchar_vtable;
344
345 /* ??_7?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
346 extern const vtable_ptr MSVCP_basic_stringbuf_short_vtable;
347
348 /* ??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@ */
349 const int basic_ostream_char_vbtable[] = {0, sizeof(basic_ostream_char)};
350 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
351 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
352
353 /* ??_8?$basic_ostream@_WU?$char_traits@_W@std@@@std@@7B@ */
354 const int basic_ostream_wchar_vbtable[] = {0, sizeof(basic_ostream_wchar)};
355 /* ??_7?$basic_ostream@_WU?$char_traits@_W@std@@@std@@6B@ */
356 extern const vtable_ptr MSVCP_basic_ostream_wchar_vtable;
357
358 /* ??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@ */
359 const int basic_ostream_short_vbtable[] = {0, sizeof(basic_ostream_wchar)};
360 /* ??_7?$basic_ostream@GU?$char_traits@G@std@@@std@@6B@ */
361 extern const vtable_ptr MSVCP_basic_ostream_short_vtable;
362
363 /* ??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@ */
364 const int basic_istream_char_vbtable[] = {0, sizeof(basic_istream_char)};
365 /* ??_7?$basic_istream@DU?$char_traits@D@std@@@std@@6B@ */
366 extern const vtable_ptr MSVCP_basic_istream_char_vtable;
367
368 /* ??_8?$basic_istream@_WU?$char_traits@_W@std@@@std@@7B@ */
369 const int basic_istream_wchar_vbtable[] = {0, sizeof(basic_istream_wchar)};
370 /* ??_7?$basic_istream@_WU?$char_traits@_W@std@@@std@@6B@ */
371 extern const vtable_ptr MSVCP_basic_istream_wchar_vtable;
372
373 /* ??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@ */
374 const int basic_istream_short_vbtable[] = {0, sizeof(basic_istream_wchar)};
375 /* ??_7?$basic_istream@GU?$char_traits@G@std@@@std@@6B@ */
376 extern const vtable_ptr MSVCP_basic_istream_short_vtable;
377
378 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
379 const int basic_iostream_char_vbtable1[] = {0, sizeof(basic_iostream_char)};
380 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
381 const int basic_iostream_char_vbtable2[] = {0, sizeof(basic_iostream_char)-FIELD_OFFSET(basic_iostream_char, base2)};
382 /* ??_7?$basic_iostream@DU?$char_traits@D@std@@@std@@6B@ */
383 extern const vtable_ptr MSVCP_basic_iostream_char_vtable;
384
385 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
386 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
387 const int basic_iostream_wchar_vbtable1[] = {0, sizeof(basic_iostream_wchar)};
388 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
389 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
390 const int basic_iostream_wchar_vbtable2[] = {0, sizeof(basic_iostream_wchar)-FIELD_OFFSET(basic_iostream_wchar, base2)};
391 /* ??_7?$basic_iostream@_WU?$char_traits@_W@std@@@std@@6B@ */
392 extern const vtable_ptr MSVCP_basic_iostream_wchar_vtable;
393 /* ??_7?$basic_iostream@GU?$char_traits@G@std@@@std@@6B@ */
394 extern const vtable_ptr MSVCP_basic_iostream_short_vtable;
395
396 /* ??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@ */
397 const int basic_ofstream_char_vbtable[] = {0, sizeof(basic_ofstream_char)};
398 /* ??_7?$basic_ofstream@DU?$char_traits@D@std@@@std@@6B@ */
399 extern const vtable_ptr MSVCP_basic_ofstream_char_vtable;
400
401 /* ??_8?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@7B@ */
402 const int basic_ofstream_wchar_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
403 /* ??_7?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@6B@ */
404 extern const vtable_ptr MSVCP_basic_ofstream_wchar_vtable;
405
406 /* ??_8?$basic_ofstream@GU?$char_traits@G@std@@@std@@7B@ */
407 const int basic_ofstream_short_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
408 /* ??_7?$basic_ofstream@GU?$char_traits@G@std@@@std@@6B@ */
409 extern const vtable_ptr MSVCP_basic_ofstream_short_vtable;
410
411 /* ??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@ */
412 const int basic_ifstream_char_vbtable[] = {0, sizeof(basic_ifstream_char)};
413 /* ??_7?$basic_ifstream@DU?$char_traits@D@std@@@std@@6B@ */
414 extern const vtable_ptr MSVCP_basic_ifstream_char_vtable;
415
416 /* ??_8?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@7B@ */
417 const int basic_ifstream_wchar_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
418 /* ??_7?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@6B@ */
419 extern const vtable_ptr MSVCP_basic_ifstream_wchar_vtable;
420
421 /* ??_8?$basic_ifstream@GU?$char_traits@G@std@@@std@@7B@ */
422 const int basic_ifstream_short_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
423 /* ??_7?$basic_ifstream@GU?$char_traits@G@std@@@std@@6B@ */
424 extern const vtable_ptr MSVCP_basic_ifstream_short_vtable;
425
426 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
427 const int basic_fstream_char_vbtable1[] = {0, sizeof(basic_fstream_char)};
428 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
429 const int basic_fstream_char_vbtable2[] = {0, sizeof(basic_fstream_char)-FIELD_OFFSET(basic_fstream_char, base.base2)};
430 /* ??_7?$basic_fstream@DU?$char_traits@D@std@@@std@@6B@ */
431 extern const vtable_ptr MSVCP_basic_fstream_char_vtable;
432
433 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
434 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
435 const int basic_fstream_wchar_vbtable1[] = {0, sizeof(basic_fstream_wchar)};
436 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
437 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
438 const int basic_fstream_wchar_vbtable2[] = {0, sizeof(basic_fstream_wchar)-FIELD_OFFSET(basic_fstream_wchar, base.base2)};
439 /* ??_7?$basic_fstream@_WU?$char_traits@_W@std@@@std@@6B@ */
440 extern const vtable_ptr MSVCP_basic_fstream_wchar_vtable;
441 /* ??_7?$basic_fstream@GU?$char_traits@G@std@@@std@@6B@ */
442 extern const vtable_ptr MSVCP_basic_fstream_short_vtable;
443
444 /* ??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
445 const int basic_ostringstream_char_vbtable[] = {0, sizeof(basic_ostringstream_char)};
446 /* ??_7?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
447 extern const vtable_ptr MSVCP_basic_ostringstream_char_vtable;
448
449 /* ??_8?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
450 const int basic_ostringstream_wchar_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
451 /* ??_7?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
452 extern const vtable_ptr MSVCP_basic_ostringstream_wchar_vtable;
453
454 /* ??_8?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
455 const int basic_ostringstream_short_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
456 /* ??_7?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
457 extern const vtable_ptr MSVCP_basic_ostringstream_short_vtable;
458
459 /* ??_8?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
460 const int basic_istringstream_char_vbtable[] = {0, sizeof(basic_istringstream_char)};
461 /* ??_7?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
462 extern const vtable_ptr MSVCP_basic_istringstream_char_vtable;
463
464 /* ??_8?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
465 const int basic_istringstream_wchar_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
466 /* ??_7?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
467 extern const vtable_ptr MSVCP_basic_istringstream_wchar_vtable;
468
469 /* ??_8?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
470 const int basic_istringstream_short_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
471 /* ??_7?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
472 extern const vtable_ptr MSVCP_basic_istringstream_short_vtable;
473
474 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
475 const int basic_stringstream_char_vbtable1[] = {0, sizeof(basic_stringstream_char)};
476 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
477 const int basic_stringstream_char_vbtable2[] = {0, sizeof(basic_stringstream_char)-FIELD_OFFSET(basic_stringstream_char, base.base2)};
478 /* ??_7?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
479 extern const vtable_ptr MSVCP_basic_stringstream_char_vtable;
480
481 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
482 const int basic_stringstream_wchar_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
483 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
484 const int basic_stringstream_wchar_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
485 /* ??_7?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
486 extern const vtable_ptr MSVCP_basic_stringstream_wchar_vtable;
487
488 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
489 const int basic_stringstream_short_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
490 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
491 const int basic_stringstream_short_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
492 /* ??_7?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
493 extern const vtable_ptr MSVCP_basic_stringstream_short_vtable;
494
495 /* ??_7strstreambuf@std@@6B */
496 extern const vtable_ptr MSVCP_strstreambuf_vtable;
497
498 static const int ostrstream_vbtable[] = {0, sizeof(ostrstream)};
499 extern const vtable_ptr MSVCP_ostrstream_vtable;
500
501 static const int istrstream_vbtable[] = {0, sizeof(istrstream)};
502
503 static const int strstream_vbtable1[] = {0, sizeof(strstream)};
504 static const int strstream_vbtable2[] = {0, sizeof(strstream)-FIELD_OFFSET(strstream, base.base2)};
505 extern const vtable_ptr MSVCP_strstream_vtable;
506
507 DEFINE_RTTI_DATA0(iosb, 0, ".?AV?$_Iosb@H@std@@");
508 DEFINE_RTTI_DATA1(ios_base, 0, &iosb_rtti_base_descriptor, ".?AV?$_Iosb@H@std@@");
509 DEFINE_RTTI_DATA2(basic_ios_char, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
510         ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@");
511 DEFINE_RTTI_DATA2(basic_ios_wchar, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
512         ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@");
513 DEFINE_RTTI_DATA2(basic_ios_short, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
514         ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@");
515 DEFINE_RTTI_DATA0(basic_streambuf_char, 0,
516         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@");
517 DEFINE_RTTI_DATA0(basic_streambuf_wchar, 0,
518         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@");
519 DEFINE_RTTI_DATA0(basic_streambuf_short, 0,
520         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@");
521 DEFINE_RTTI_DATA1(basic_filebuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
522         ".?AV?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@");
523 DEFINE_RTTI_DATA1(basic_filebuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
524         ".?AV?$basic_filebuf@GU?$char_traits@G@std@@@std@@");
525 DEFINE_RTTI_DATA1(basic_filebuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
526         ".?AV?$basic_filebuf@DU?$char_traits@D@std@@@std@@");
527 DEFINE_RTTI_DATA1(basic_stringbuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
528         ".?AV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
529 DEFINE_RTTI_DATA1(basic_stringbuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
530         ".?AV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
531 DEFINE_RTTI_DATA1(basic_stringbuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
532         ".?AV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
533 DEFINE_RTTI_DATA3(basic_ostream_char, sizeof(basic_ostream_char), &basic_ios_char_rtti_base_descriptor,
534         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
535         ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@");
536 DEFINE_RTTI_DATA3(basic_ostream_wchar, sizeof(basic_ostream_wchar), &basic_ios_wchar_rtti_base_descriptor,
537         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
538         ".?AV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@");
539 DEFINE_RTTI_DATA3(basic_ostream_short, sizeof(basic_ostream_wchar), &basic_ios_short_rtti_base_descriptor,
540         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
541         ".?AV?$basic_ostream@GU?$char_traits@G@std@@@std@@");
542 DEFINE_RTTI_DATA3(basic_istream_char, sizeof(basic_istream_char), &basic_ios_char_rtti_base_descriptor,
543         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
544         ".?AV?$basic_istream@DU?$char_traits@D@std@@@std@@");
545 DEFINE_RTTI_DATA3(basic_istream_wchar, sizeof(basic_istream_wchar), &basic_ios_wchar_rtti_base_descriptor,
546         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
547         ".?AV?$basic_istream@_WU?$char_traits@_W@std@@@std@@");
548 DEFINE_RTTI_DATA3(basic_istream_short, sizeof(basic_istream_wchar), &basic_ios_short_rtti_base_descriptor,
549         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
550         ".?AV?$basic_istream@GU?$char_traits@G@std@@@std@@");
551 DEFINE_RTTI_DATA8(basic_iostream_char, sizeof(basic_iostream_char),
552         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
553         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
554         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
555         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
556         ".?AV?$basic_iostream@DU?$char_traits@D@std@@@std@@");
557 DEFINE_RTTI_DATA8(basic_iostream_wchar, sizeof(basic_iostream_wchar),
558         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
559         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
560         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
561         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
562         ".?AV?$basic_iostream@_WU?$char_traits@_W@std@@@std@@");
563 DEFINE_RTTI_DATA8(basic_iostream_short, sizeof(basic_iostream_wchar),
564         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
565         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
566         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
567         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
568         ".?AV?$basic_iostream@GU?$char_traits@G@std@@@std@@");
569 DEFINE_RTTI_DATA4(basic_ofstream_char, sizeof(basic_ofstream_char),
570         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
571         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
572         ".?AV?$basic_ofstream@DU?$char_traits@D@std@@@std@@");
573 DEFINE_RTTI_DATA4(basic_ofstream_wchar, sizeof(basic_ofstream_wchar),
574         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
575         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
576         ".?AV?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@");
577 DEFINE_RTTI_DATA4(basic_ofstream_short, sizeof(basic_ofstream_wchar),
578         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
579         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
580         ".?AV?$basic_ofstream@GU?$char_traits@G@std@@@std@@");
581 DEFINE_RTTI_DATA4(basic_ifstream_char, sizeof(basic_ifstream_char),
582         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
583         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
584         ".?AV?$basic_ifstream@DU?$char_traits@D@std@@@std@@");
585 DEFINE_RTTI_DATA4(basic_ifstream_wchar, sizeof(basic_ifstream_wchar),
586         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
587         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
588         ".?AV?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@");
589 DEFINE_RTTI_DATA4(basic_ifstream_short, sizeof(basic_ifstream_wchar),
590         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
591         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
592         ".?AV?$basic_ifstream@GU?$char_traits@G@std@@@std@@");
593 DEFINE_RTTI_DATA8(basic_fstream_char, sizeof(basic_fstream_char),
594         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
595         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
596         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
597         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
598         ".?AV?$basic_fstream@DU?$char_traits@D@std@@@std@@");
599 DEFINE_RTTI_DATA8(basic_fstream_wchar, sizeof(basic_fstream_wchar),
600         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
601         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
602         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
603         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
604         ".?AV?$basic_fstream@_WU?$char_traits@_W@std@@@std@@");
605 DEFINE_RTTI_DATA8(basic_fstream_short, sizeof(basic_fstream_wchar),
606         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
607         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
608         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
609         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
610         ".?AV?$basic_fstream@GU?$char_traits@G@std@@@std@@");
611 DEFINE_RTTI_DATA4(basic_ostringstream_char, sizeof(basic_ostringstream_char),
612         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
613         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
614         ".?AV?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
615 DEFINE_RTTI_DATA4(basic_ostringstream_wchar, sizeof(basic_ostringstream_wchar),
616         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
617         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
618         ".?AV?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
619 DEFINE_RTTI_DATA4(basic_ostringstream_short, sizeof(basic_ostringstream_wchar),
620         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
621         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
622         ".?AV?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
623 DEFINE_RTTI_DATA4(basic_istringstream_char, sizeof(basic_istringstream_char),
624         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
625         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
626         ".?AV?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
627 DEFINE_RTTI_DATA4(basic_istringstream_wchar, sizeof(basic_istringstream_wchar),
628         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
629         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
630         ".?AV?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
631 DEFINE_RTTI_DATA4(basic_istringstream_short, sizeof(basic_istringstream_wchar),
632         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
633         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
634         ".?AV?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
635 DEFINE_RTTI_DATA8(basic_stringstream_char, sizeof(basic_stringstream_char),
636         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
637         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
638         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
639         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
640         ".?AV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
641 DEFINE_RTTI_DATA8(basic_stringstream_wchar, sizeof(basic_stringstream_wchar),
642         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
643         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
644         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
645         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
646         ".?AV?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
647 DEFINE_RTTI_DATA8(basic_stringstream_short, sizeof(basic_stringstream_wchar),
648         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
649         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
650         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
651         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
652         ".?AV?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
653 DEFINE_RTTI_DATA1(strstreambuf, sizeof(strstreambuf),
654         &basic_streambuf_char_rtti_base_descriptor, ".?AVstrstreambuf@std@@");
655 DEFINE_RTTI_DATA4(ostrstream, sizeof(ostrstream),
656         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
657         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
658         "?AVostrstream@std@@");
659 DEFINE_RTTI_DATA8(strstream, sizeof(strstream),
660         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
661         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
662         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
663         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
664         "?AVstrstream@std@@");
665
666 #ifndef __GNUC__
667 void __asm_dummy_vtables(void) {
668 #endif
669     __ASM_VTABLE(iosb,
670             VTABLE_ADD_FUNC(iosb_vector_dtor));
671     __ASM_VTABLE(ios_base,
672             VTABLE_ADD_FUNC(ios_base_vector_dtor));
673     __ASM_VTABLE(basic_ios_char,
674             VTABLE_ADD_FUNC(basic_ios_char_vector_dtor));
675     __ASM_VTABLE(basic_ios_wchar,
676             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
677     __ASM_VTABLE(basic_ios_short,
678             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
679     __ASM_VTABLE(basic_streambuf_char,
680             VTABLE_ADD_FUNC(basic_streambuf_char_vector_dtor)
681             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
682             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
683             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
684             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
685             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
686             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
687             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
688             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
689             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
690             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
691             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
692             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
693     __ASM_VTABLE(basic_streambuf_wchar,
694             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
695             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
696             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
697             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
698             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
699             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
700             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
701             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
702             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
703             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
704             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
705             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
706             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
707     __ASM_VTABLE(basic_streambuf_short,
708             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
709             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
710             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
711             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
712             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
713             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
714             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
715             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
716             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
717             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
718             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
719             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
720             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
721     __ASM_VTABLE(basic_filebuf_char,
722             VTABLE_ADD_FUNC(basic_filebuf_char_vector_dtor)
723             VTABLE_ADD_FUNC(basic_filebuf_char_overflow)
724             VTABLE_ADD_FUNC(basic_filebuf_char_pbackfail)
725             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
726             VTABLE_ADD_FUNC(basic_filebuf_char_underflow)
727             VTABLE_ADD_FUNC(basic_filebuf_char_uflow)
728             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
729             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
730             VTABLE_ADD_FUNC(basic_filebuf_char_seekoff)
731             VTABLE_ADD_FUNC(basic_filebuf_char_seekpos)
732             VTABLE_ADD_FUNC(basic_filebuf_char_setbuf)
733             VTABLE_ADD_FUNC(basic_filebuf_char_sync)
734             VTABLE_ADD_FUNC(basic_filebuf_char_imbue));
735     __ASM_VTABLE(basic_filebuf_wchar,
736             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
737             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
738             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
739             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
740             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
741             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
742             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
743             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
744             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
745             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
746             VTABLE_ADD_FUNC(basic_filebuf_wchar_setbuf)
747             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
748             VTABLE_ADD_FUNC(basic_filebuf_wchar_imbue));
749     __ASM_VTABLE(basic_filebuf_short,
750             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
751             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
752             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
753             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
754             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
755             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
756             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
757             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
758             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
759             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
760             VTABLE_ADD_FUNC(basic_filebuf_short_setbuf)
761             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
762             VTABLE_ADD_FUNC(basic_filebuf_short_imbue));
763     __ASM_VTABLE(basic_stringbuf_char,
764             VTABLE_ADD_FUNC(basic_stringbuf_char_vector_dtor)
765             VTABLE_ADD_FUNC(basic_stringbuf_char_overflow)
766             VTABLE_ADD_FUNC(basic_stringbuf_char_pbackfail)
767             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
768             VTABLE_ADD_FUNC(basic_stringbuf_char_underflow)
769             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
770             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
771             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
772             VTABLE_ADD_FUNC(basic_stringbuf_char_seekoff)
773             VTABLE_ADD_FUNC(basic_stringbuf_char_seekpos)
774             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
775             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
776             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
777     __ASM_VTABLE(basic_stringbuf_wchar,
778             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
779             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
780             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
781             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
782             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
783             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
784             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
785             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
786             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
787             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
788             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
789             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
790             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
791     __ASM_VTABLE(basic_stringbuf_short,
792             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
793             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
794             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
795             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
796             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
797             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
798             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
799             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
800             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
801             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
802             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
803             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
804             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
805     __ASM_VTABLE(basic_ostream_char,
806             VTABLE_ADD_FUNC(basic_ostream_char_vector_dtor));
807     __ASM_VTABLE(basic_ostream_wchar,
808             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
809     __ASM_VTABLE(basic_ostream_short,
810             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
811     __ASM_VTABLE(basic_istream_char,
812             VTABLE_ADD_FUNC(basic_istream_char_vector_dtor));
813     __ASM_VTABLE(basic_istream_wchar,
814             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
815     __ASM_VTABLE(basic_istream_short,
816             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
817     __ASM_VTABLE(basic_iostream_char,
818             VTABLE_ADD_FUNC(basic_iostream_char_vector_dtor));
819     __ASM_VTABLE(basic_iostream_wchar,
820             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
821     __ASM_VTABLE(basic_iostream_short,
822             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
823     __ASM_VTABLE(basic_ofstream_char,
824             VTABLE_ADD_FUNC(basic_ofstream_char_vector_dtor));
825     __ASM_VTABLE(basic_ofstream_wchar,
826             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
827     __ASM_VTABLE(basic_ofstream_short,
828             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
829     __ASM_VTABLE(basic_ifstream_char,
830             VTABLE_ADD_FUNC(basic_ifstream_char_vector_dtor));
831     __ASM_VTABLE(basic_ifstream_wchar,
832             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
833     __ASM_VTABLE(basic_ifstream_short,
834             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
835     __ASM_VTABLE(basic_fstream_char,
836             VTABLE_ADD_FUNC(basic_fstream_char_vector_dtor));
837     __ASM_VTABLE(basic_fstream_wchar,
838             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
839     __ASM_VTABLE(basic_fstream_short,
840             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
841     __ASM_VTABLE(basic_ostringstream_char,
842             VTABLE_ADD_FUNC(basic_ostringstream_char_vector_dtor));
843     __ASM_VTABLE(basic_ostringstream_wchar,
844             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
845     __ASM_VTABLE(basic_ostringstream_short,
846             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
847     __ASM_VTABLE(basic_istringstream_char,
848             VTABLE_ADD_FUNC(basic_istringstream_char_vector_dtor));
849     __ASM_VTABLE(basic_istringstream_wchar,
850             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
851     __ASM_VTABLE(basic_istringstream_short,
852             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
853     __ASM_VTABLE(basic_stringstream_char,
854             VTABLE_ADD_FUNC(basic_stringstream_char_vector_dtor));
855     __ASM_VTABLE(basic_stringstream_wchar,
856             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
857     __ASM_VTABLE(basic_stringstream_short,
858             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
859     __ASM_VTABLE(strstreambuf,
860             VTABLE_ADD_FUNC(strstreambuf_vector_dtor)
861             VTABLE_ADD_FUNC(strstreambuf_overflow)
862             VTABLE_ADD_FUNC(strstreambuf_pbackfail)
863             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
864             VTABLE_ADD_FUNC(strstreambuf_underflow)
865             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
866             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
867             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
868             VTABLE_ADD_FUNC(strstreambuf_seekoff)
869             VTABLE_ADD_FUNC(strstreambuf_seekpos)
870             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
871             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
872             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
873     __ASM_VTABLE(ostrstream,
874             VTABLE_ADD_FUNC(ostrstream_vector_dtor));
875     __ASM_VTABLE(strstream,
876             VTABLE_ADD_FUNC(strstream_vector_dtor));
877 #ifndef __GNUC__
878 }
879 #endif
880
881 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
882 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
883 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
884 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
885 {
886     TRACE("(%p %p %p %p)\n", this, first, next, last);
887
888     this->wbuf = first;
889     this->wpos = next;
890     this->wsize = last-next;
891 }
892
893 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
894 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
895 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
896 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
897 {
898     basic_streambuf_char_setp_next(this, first, first, last);
899 }
900
901 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
902 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
903 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
904 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
905 {
906     TRACE("(%p %p %p %p)\n", this, first, next, last);
907
908     this->rbuf = first;
909     this->rpos = next;
910     this->rsize = last-next;
911 }
912
913 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
914 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
915 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
916 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
917 {
918     TRACE("(%p)\n", this);
919
920     this->prbuf = &this->rbuf;
921     this->pwbuf = &this->wbuf;
922     this->prpos = &this->rpos;
923     this->pwpos = &this->wpos;
924     this->prsize = &this->rsize;
925     this->pwsize = &this->wsize;
926
927     basic_streambuf_char_setp(this, NULL, NULL);
928     basic_streambuf_char_setg(this, NULL, NULL, NULL);
929 }
930
931 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
932 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
933 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
934 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
935 {
936     TRACE("(%p %d)\n", this, uninitialized);
937     this->vtable = &MSVCP_basic_streambuf_char_vtable;
938     return this;
939 }
940
941 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
942 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
943 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
944 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
945 {
946     TRACE("(%p)\n", this);
947
948     this->vtable = &MSVCP_basic_streambuf_char_vtable;
949     this->loc = MSVCRT_operator_new(sizeof(locale));
950     locale_ctor(this->loc);
951     basic_streambuf_char__Init_empty(this);
952
953     return this;
954 }
955
956 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
957 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
958 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
959 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
960 {
961     TRACE("(%p)\n", this);
962
963     locale_dtor(this->loc);
964     MSVCRT_operator_delete(this->loc);
965 }
966
967 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_vector_dtor, 8)
968 basic_streambuf_char* __thiscall basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
969 {
970     TRACE("(%p %x)\n", this, flags);
971     if(flags & 2) {
972         /* we have an array, with the number of elements stored before the first object */
973         INT_PTR i, *ptr = (INT_PTR *)this-1;
974
975         for(i=*ptr-1; i>=0; i--)
976             basic_streambuf_char_dtor(this+i);
977         MSVCRT_operator_delete(ptr);
978     } else {
979         basic_streambuf_char_dtor(this);
980         if(flags & 1)
981             MSVCRT_operator_delete(this);
982     }
983
984     return this;
985 }
986
987 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
988 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
989 static streamsize basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
990 {
991     TRACE("(%p)\n", this);
992     return *this->prpos ? *this->prsize : 0;
993 }
994
995 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
996 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
997 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
998 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
999 {
1000     TRACE("(%p)\n", this);
1001     (*this->prsize)++;
1002     (*this->prpos)--;
1003     return *this->prpos;
1004 }
1005
1006 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1007 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1008 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
1009 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
1010 {
1011     TRACE("(%p)\n", this);
1012     (*this->prsize)--;
1013     return (*this->prpos)++;
1014 }
1015
1016 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1017 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1018 static char* basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
1019 {
1020     TRACE("(%p)\n", this);
1021     (*this->prsize)--;
1022     (*this->prpos)++;
1023     return *this->prpos;
1024 }
1025
1026 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
1027 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
1028 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
1029 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
1030 {
1031     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1032
1033     this->prbuf = gf;
1034     this->pwbuf = pf;
1035     this->prpos = gn;
1036     this->pwpos = pn;
1037     this->prsize = gc;
1038     this->pwsize = pc;
1039 }
1040
1041 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1042 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1043 static void basic_streambuf_char__Lock(basic_streambuf_char *this)
1044 {
1045     TRACE("(%p)\n", this);
1046 }
1047
1048 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
1049 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
1050 static streamsize basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
1051 {
1052     TRACE("(%p)\n", this);
1053     return *this->pwpos ? *this->pwsize : 0;
1054 }
1055
1056 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1057 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1058 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
1059 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
1060 {
1061     TRACE("(%p)\n", this);
1062     (*this->pwsize)--;
1063     return (*this->pwpos)++;
1064 }
1065
1066 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1067 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1068 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
1069 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
1070         int, (basic_streambuf_char*), (this))
1071 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
1072 {
1073     TRACE("(%p)\n", this);
1074     return EOF;
1075 }
1076
1077 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1078 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1079 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
1080 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
1081         int, (basic_streambuf_char*), (this))
1082 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
1083 {
1084     int ret;
1085
1086     TRACE("(%p)\n", this);
1087
1088     if(call_basic_streambuf_char_underflow(this)==EOF)
1089         return EOF;
1090
1091     ret = (unsigned char)**this->prpos;
1092     (*this->prsize)--;
1093     (*this->prpos)++;
1094     return ret;
1095 }
1096
1097 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
1098 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
1099 static streamsize basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1100 {
1101     streamsize copied, chunk;
1102     int c;
1103
1104     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1105
1106     for(copied=0; copied<count && size;) {
1107         chunk = basic_streambuf_char__Gnavail(this);
1108         if(chunk > count-copied)
1109             chunk = count-copied;
1110
1111         if(chunk > 0) {
1112             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1113             *this->prpos += chunk;
1114             *this->prsize -= chunk;
1115             copied += chunk;
1116             size -= chunk;
1117         }else if((c = call_basic_streambuf_char_uflow(this)) != EOF) {
1118             ptr[copied] = c;
1119             copied++;
1120             size--;
1121         }else {
1122             break;
1123         }
1124     }
1125
1126     return copied;
1127 }
1128
1129 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
1130 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
1131 static streamsize basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1132 {
1133     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1134     return basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
1135 }
1136
1137 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1138 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1139 static void basic_streambuf_char__Unlock(basic_streambuf_char *this)
1140 {
1141     TRACE("(%p)\n", this);
1142 }
1143
1144 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1145 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1146 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
1147 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
1148 {
1149     TRACE("(%p)\n", this);
1150     return *this->prbuf;
1151 }
1152
1153 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1154 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1155 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
1156 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
1157 {
1158     TRACE("(%p)\n", this);
1159     return *this->prpos;
1160 }
1161
1162 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1163 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1164 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
1165 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
1166 {
1167     TRACE("(%p)\n", this);
1168     return *this->prpos+*this->prsize;
1169 }
1170
1171 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1172 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1173 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
1174 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
1175 {
1176     TRACE("(%p)\n", this);
1177     return *this->pwpos+*this->pwsize;
1178 }
1179
1180 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1181 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1182 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
1183 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
1184 {
1185     TRACE("(%p %d)\n", this, off);
1186     *this->prpos += off;
1187     *this->prsize -= off;
1188 }
1189
1190 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
1191 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
1192 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
1193 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1194         void, (basic_streambuf_char*, const locale*), (this, loc))
1195 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
1196 {
1197     TRACE("(%p %p)\n", this, loc);
1198 }
1199
1200 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1201 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1202 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
1203 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1204         int, (basic_streambuf_char*, int), (this, ch))
1205 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
1206 {
1207     TRACE("(%p %d)\n", this, ch);
1208     return EOF;
1209 }
1210
1211 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1212 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1213 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
1214 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1215         int, (basic_streambuf_char*, int), (this, ch))
1216 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
1217 {
1218     TRACE("(%p %d)\n", this, ch);
1219     return EOF;
1220 }
1221
1222 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1223 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1224 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
1225 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
1226 {
1227     TRACE("(%p)\n", this);
1228     return *this->pwbuf;
1229 }
1230
1231 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1232 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1233 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
1234 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
1235 {
1236     TRACE("(%p %d)\n", this, off);
1237     *this->pwpos += off;
1238     *this->pwsize -= off;
1239 }
1240
1241 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1242 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1243 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
1244 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
1245 {
1246     TRACE("(%p)\n", this);
1247     return *this->pwpos;
1248 }
1249
1250 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1251 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1252 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
1253 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
1254 {
1255     TRACE("(%p %p)\n", this, loc);
1256     memcpy(ret, this->loc, sizeof(locale));
1257     call_basic_streambuf_char_imbue(this, loc);
1258     locale_copy_ctor(this->loc, loc);
1259     return ret;
1260 }
1261
1262 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1263 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1264 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
1265 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1266         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1267 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
1268         fpos_int *ret, streamoff off, int way, int mode)
1269 {
1270     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1271     ret->off = -1;
1272     ret->pos = 0;
1273     ret->state = 0;
1274     return ret;
1275 }
1276
1277 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1278 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1279 static fpos_int* basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
1280         fpos_int *ret, streamoff off, int way, int mode)
1281 {
1282     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1283     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
1284 }
1285
1286 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1287 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1288 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
1289 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
1290         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1291 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
1292         fpos_int *ret, fpos_int pos, int mode)
1293 {
1294     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1295     ret->off = -1;
1296     ret->pos = 0;
1297     ret->state = 0;
1298     return ret;
1299 }
1300
1301 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1302 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1303 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
1304 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
1305         fpos_int *ret, fpos_int pos, int mode)
1306 {
1307     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1308     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
1309 }
1310
1311 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
1312 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
1313 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
1314 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
1315         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
1316 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
1317 {
1318     TRACE("(%p %p %ld)\n", this, buf, count);
1319     return this;
1320 }
1321
1322 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
1323 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
1324 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
1325 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
1326 {
1327     TRACE("(%p %p %ld)\n", this, buf, count);
1328     return call_basic_streambuf_char_setbuf(this, buf, count);
1329 }
1330
1331 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1332 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1333 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
1334 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 44, \
1335         int, (basic_streambuf_char*), (this))
1336 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
1337 {
1338     TRACE("(%p)\n", this);
1339     return 0;
1340 }
1341
1342 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1343 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1344 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
1345 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
1346 {
1347     TRACE("(%p)\n", this);
1348     return call_basic_streambuf_char_sync(this);
1349 }
1350
1351 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
1352 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
1353 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
1354 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1355 {
1356     TRACE("(%p %p %ld)\n", this, ptr, count);
1357     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1358 }
1359
1360 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1361 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
1362 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
1363 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1364         streamsize, (basic_streambuf_char*), (this))
1365 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
1366 {
1367     TRACE("(%p)\n", this);
1368     return 0;
1369 }
1370
1371 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1372 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
1373 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
1374 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
1375 {
1376     streamsize ret;
1377
1378     TRACE("(%p)\n", this);
1379
1380     ret = basic_streambuf_char__Gnavail(this);
1381     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
1382 }
1383
1384 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1385 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1386 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
1387 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
1388 {
1389     TRACE("(%p %d)\n", this, ch);
1390     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1391         (*this->prsize)++;
1392         (*this->prpos)--;
1393         return (unsigned char)ch;
1394     }
1395
1396     return call_basic_streambuf_char_pbackfail(this, (unsigned char)ch);
1397 }
1398
1399 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1400 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1401 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
1402 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
1403 {
1404     TRACE("(%p %d)\n", this, ch);
1405     return basic_streambuf_char__Pnavail(this) ?
1406         (*basic_streambuf_char__Pninc(this) = ch) :
1407         call_basic_streambuf_char_overflow(this, (unsigned char)ch);
1408 }
1409
1410 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1411 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1412 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
1413 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
1414 {
1415     TRACE("(%p)\n", this);
1416     if(*this->prpos && *this->prpos>*this->prbuf) {
1417         (*this->prsize)++;
1418         (*this->prpos)--;
1419         return (unsigned char)**this->prpos;
1420     }
1421
1422     return call_basic_streambuf_char_pbackfail(this, EOF);
1423 }
1424
1425 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1426 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1427 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1428 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1429 {
1430     TRACE("(%p)\n", this);
1431     if(basic_streambuf_char__Gnavail(this))
1432         basic_streambuf_char__Gninc(this);
1433     else
1434         call_basic_streambuf_char_uflow(this);
1435 }
1436
1437 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1438 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1439 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1440 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1441 {
1442     TRACE("(%p)\n", this);
1443     return basic_streambuf_char__Gnavail(this) ?
1444         (int)(unsigned char)*basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1445 }
1446
1447 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1448 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1449 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1450 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1451 {
1452     TRACE("(%p)\n", this);
1453     return basic_streambuf_char__Gnavail(this) ?
1454         (int)(unsigned char)*basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1455 }
1456
1457 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1458 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1459 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1460 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1461 {
1462     TRACE("(%p)\n", this);
1463
1464     if(basic_streambuf_char__Gnavail(this) > 1)
1465         return (unsigned char)*basic_streambuf_char__Gnpreinc(this);
1466     return basic_streambuf_char_sbumpc(this)==EOF ?
1467         EOF : basic_streambuf_char_sgetc(this);
1468 }
1469
1470 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1471 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1472 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
1473 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1474         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1475 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1476 {
1477     TRACE("(%p %p %ld)\n", this, ptr, count);
1478     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1479 }
1480
1481 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1482 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1483 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
1484 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
1485         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1486 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1487 {
1488     streamsize copied, chunk;
1489
1490     TRACE("(%p %p %ld)\n", this, ptr, count);
1491
1492     for(copied=0; copied<count;) {
1493         chunk = basic_streambuf_char__Pnavail(this);
1494         if(chunk > count-copied)
1495             chunk = count-copied;
1496
1497         if(chunk > 0) {
1498             memcpy(*this->pwpos, ptr+copied, chunk);
1499             *this->pwpos += chunk;
1500             *this->pwsize -= chunk;
1501             copied += chunk;
1502         }else if(call_basic_streambuf_char_overflow(this, (unsigned char)ptr[copied]) != EOF) {
1503             copied++;
1504         }else {
1505             break;
1506         }
1507     }
1508
1509     return copied;
1510 }
1511
1512 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1513 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1514 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
1515 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1516 {
1517     TRACE("(%p %p %ld)\n", this, ptr, count);
1518     return call_basic_streambuf_char_xsputn(this, ptr, count);
1519 }
1520
1521 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1522 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1523 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1524 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1525 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1526 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1527 {
1528     TRACE("(%p %p %p %p)\n", this, first, next, last);
1529
1530     this->wbuf = first;
1531     this->wpos = next;
1532     this->wsize = last-next;
1533 }
1534
1535 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1536 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1537 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1538 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1539 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1540 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1541 {
1542     basic_streambuf_wchar_setp_next(this, first, first, last);
1543 }
1544
1545 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1546 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1547 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1548 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1549 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1550 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1551 {
1552     TRACE("(%p %p %p %p)\n", this, first, next, last);
1553
1554     this->rbuf = first;
1555     this->rpos = next;
1556     this->rsize = last-next;
1557 }
1558
1559 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1560 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1561 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1562 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1563 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1564 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1565 {
1566     TRACE("(%p)\n", this);
1567
1568     this->prbuf = &this->rbuf;
1569     this->pwbuf = &this->wbuf;
1570     this->prpos = &this->rpos;
1571     this->pwpos = &this->wpos;
1572     this->prsize = &this->rsize;
1573     this->pwsize = &this->wsize;
1574
1575     basic_streambuf_wchar_setp(this, NULL, NULL);
1576     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1577 }
1578
1579 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1580 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1581 static basic_streambuf_wchar* basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1582 {
1583     TRACE("(%p %d)\n", this, uninitialized);
1584     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1585     mutex_ctor(&this->lock);
1586     return this;
1587 }
1588
1589 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1590 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1591 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1592 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1593 {
1594     TRACE("(%p %d)\n", this, uninitialized);
1595     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1596     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1597     return this;
1598 }
1599
1600 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1601 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1602 static basic_streambuf_wchar* basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1603 {
1604     TRACE("(%p)\n", this);
1605
1606     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1607     mutex_ctor(&this->lock);
1608     this->loc = MSVCRT_operator_new(sizeof(locale));
1609     locale_ctor(this->loc);
1610     basic_streambuf_wchar__Init_empty(this);
1611
1612     return this;
1613 }
1614
1615 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1616 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1617 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1618 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1619 {
1620     TRACE("(%p)\n", this);
1621     basic_streambuf_wchar_ctor(this);
1622     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1623     return this;
1624 }
1625
1626 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1627 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1628 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1629 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1630 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1631 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1632 {
1633     TRACE("(%p)\n", this);
1634
1635     mutex_dtor(&this->lock);
1636     locale_dtor(this->loc);
1637     MSVCRT_operator_delete(this->loc);
1638 }
1639
1640 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_vector_dtor, 8)
1641 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1642 {
1643     TRACE("(%p %x)\n", this, flags);
1644     if(flags & 2) {
1645         /* we have an array, with the number of elements stored before the first object */
1646         INT_PTR i, *ptr = (INT_PTR *)this-1;
1647
1648         for(i=*ptr-1; i>=0; i--)
1649             basic_streambuf_wchar_dtor(this+i);
1650         MSVCRT_operator_delete(ptr);
1651     } else {
1652         basic_streambuf_wchar_dtor(this);
1653         if(flags & 1)
1654             MSVCRT_operator_delete(this);
1655     }
1656
1657     return this;
1658 }
1659
1660 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1661 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1662 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1663 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1664 static streamsize basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1665 {
1666     TRACE("(%p)\n", this);
1667     return *this->prpos ? *this->prsize : 0;
1668 }
1669
1670 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1671 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1672 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1673 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1674 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1675 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1676 {
1677     TRACE("(%p)\n", this);
1678     (*this->prsize)++;
1679     (*this->prpos)--;
1680     return *this->prpos;
1681 }
1682
1683 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1684 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1685 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1686 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1687 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1688 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1689 {
1690     TRACE("(%p)\n", this);
1691     (*this->prsize)--;
1692     return (*this->prpos)++;
1693 }
1694
1695 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1696 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1697 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1698 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1699 static wchar_t* basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1700 {
1701     TRACE("(%p)\n", this);
1702     (*this->prsize)--;
1703     (*this->prpos)++;
1704     return *this->prpos;
1705 }
1706
1707 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1708 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1709 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1710 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1711 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1712 void __thiscall basic_streambuf_wchar__Init(basic_streambuf_wchar *this, wchar_t **gf, wchar_t **gn, int *gc, wchar_t **pf, wchar_t **pn, int *pc)
1713 {
1714     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1715
1716     this->prbuf = gf;
1717     this->pwbuf = pf;
1718     this->prpos = gn;
1719     this->pwpos = pn;
1720     this->prsize = gc;
1721     this->pwsize = pc;
1722 }
1723
1724 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1725 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1726 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1727 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1728 static void basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1729 {
1730     TRACE("(%p)\n", this);
1731     mutex_lock(&this->lock);
1732 }
1733
1734 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1735 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1736 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1737 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1738 static streamsize basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1739 {
1740     TRACE("(%p)\n", this);
1741     return *this->pwpos ? *this->pwsize : 0;
1742 }
1743
1744 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1745 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1746 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1747 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1748 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1749 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1750 {
1751     TRACE("(%p)\n", this);
1752     (*this->pwsize)--;
1753     return (*this->pwpos)++;
1754 }
1755
1756 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1757 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1758 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1759 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1760 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1761 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1762         unsigned short, (basic_streambuf_wchar*), (this))
1763 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1764 {
1765     TRACE("(%p)\n", this);
1766     return WEOF;
1767 }
1768
1769 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1770 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1771 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1772 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1773 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1774 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1775         unsigned short, (basic_streambuf_wchar*), (this))
1776 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1777 {
1778     int ret;
1779
1780     TRACE("(%p)\n", this);
1781
1782     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1783         return WEOF;
1784
1785     ret = **this->prpos;
1786     (*this->prsize)--;
1787     (*this->prpos)++;
1788     return ret;
1789 }
1790
1791 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1792 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1793 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1794 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1795 static streamsize basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1796 {
1797     streamsize copied, chunk;
1798     unsigned short c;
1799
1800     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1801
1802     for(copied=0; copied<count && size;) {
1803         chunk = basic_streambuf_wchar__Gnavail(this);
1804         if(chunk > count-copied)
1805             chunk = count-copied;
1806
1807         if(chunk > 0) {
1808             memcpy_s(ptr+copied, size, *this->prpos, chunk*sizeof(wchar_t));
1809             *this->prpos += chunk;
1810             *this->prsize -= chunk;
1811             copied += chunk;
1812             size -= chunk*sizeof(wchar_t);
1813         }else if((c = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1814             ptr[copied] = c;
1815             copied++;
1816             size--;
1817         }else {
1818             break;
1819         }
1820     }
1821
1822     return copied;
1823 }
1824
1825 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1826 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1827 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1828 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1829 static streamsize basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1830 {
1831     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1832     return basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1833 }
1834
1835 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1836 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1837 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1838 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1839 static void basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1840 {
1841     TRACE("(%p)\n", this);
1842     mutex_unlock(&this->lock);
1843 }
1844
1845 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1846 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1847 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1848 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1849 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1850 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1851 {
1852     TRACE("(%p)\n", this);
1853     return *this->prbuf;
1854 }
1855
1856 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1857 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1858 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1859 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1860 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1861 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1862 {
1863     TRACE("(%p)\n", this);
1864     return *this->prpos;
1865 }
1866
1867 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1868 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1869 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1870 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1871 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1872 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1873 {
1874     TRACE("(%p)\n", this);
1875     return *this->prpos+*this->prsize;
1876 }
1877
1878 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1879 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1880 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1881 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1882 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1883 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1884 {
1885     TRACE("(%p)\n", this);
1886     return *this->pwpos+*this->pwsize;
1887 }
1888
1889 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1890 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1891 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1892 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1893 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1894 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1895 {
1896     TRACE("(%p %d)\n", this, off);
1897     *this->prpos += off;
1898     *this->prsize -= off;
1899 }
1900
1901 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1902 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1903 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1904 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1905 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1906 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1907         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1908 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1909 {
1910     TRACE("(%p %p)\n", this, loc);
1911 }
1912
1913 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1914 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1915 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1916 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1917 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1918 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1919         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1920 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1921 {
1922     TRACE("(%p %d)\n", this, ch);
1923     return WEOF;
1924 }
1925
1926 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1927 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1928 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1929 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1930 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1931 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1932         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1933 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1934 {
1935     TRACE("(%p %d)\n", this, ch);
1936     return WEOF;
1937 }
1938
1939 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1940 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1941 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1942 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1943 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1944 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1945 {
1946     TRACE("(%p)\n", this);
1947     return *this->pwbuf;
1948 }
1949
1950 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1951 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1952 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1953 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1954 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1955 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1956 {
1957     TRACE("(%p %d)\n", this, off);
1958     *this->pwpos += off;
1959     *this->pwsize -= off;
1960 }
1961
1962 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1963 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1964 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1965 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1966 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1967 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1968 {
1969     TRACE("(%p)\n", this);
1970     return *this->pwpos;
1971 }
1972
1973 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1974 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1975 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1976 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1977 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
1978 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
1979 {
1980     TRACE("(%p %p)\n", this, loc);
1981     memcpy(ret, this->loc, sizeof(locale));
1982     call_basic_streambuf_wchar_imbue(this, loc);
1983     locale_copy_ctor(this->loc, loc);
1984     return ret;
1985 }
1986
1987 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1988 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1989 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1990 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1991 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
1992 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1993         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1994 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
1995         fpos_int *ret, streamoff off, int way, int mode)
1996 {
1997     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1998     ret->off = -1;
1999     ret->pos = 0;
2000     ret->state = 0;
2001     return ret;
2002 }
2003
2004 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2005 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2006 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2007 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2008 static fpos_int* basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
2009         fpos_int *ret, streamoff off, int way, int mode)
2010 {
2011     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2012     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
2013 }
2014
2015 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2016 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2017 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2018 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2019 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
2020 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
2021         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
2022 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
2023         fpos_int *ret, fpos_int pos, int mode)
2024 {
2025     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2026     ret->off = -1;
2027     ret->pos = 0;
2028     ret->state = 0;
2029     return ret;
2030 }
2031
2032 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2033 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2034 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2035 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2036 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
2037 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
2038         fpos_int *ret, fpos_int pos, int mode)
2039 {
2040     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2041     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
2042 }
2043
2044 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
2045 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
2046 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
2047 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
2048 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
2049 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
2050         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
2051 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2052 {
2053     TRACE("(%p %p %ld)\n", this, buf, count);
2054     return this;
2055 }
2056
2057 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
2058 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
2059 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
2060 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
2061 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
2062 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2063 {
2064     TRACE("(%p %p %ld)\n", this, buf, count);
2065     return call_basic_streambuf_wchar_setbuf(this, buf, count);
2066 }
2067
2068 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2069 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2070 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2071 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2072 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
2073 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 44, \
2074         int, (basic_streambuf_wchar*), (this))
2075 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
2076 {
2077     TRACE("(%p)\n", this);
2078     return 0;
2079 }
2080
2081 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2082 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
2083 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2084 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
2085 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
2086 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
2087 {
2088     TRACE("(%p)\n", this);
2089     return call_basic_streambuf_wchar_sync(this);
2090 }
2091
2092 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
2093 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
2094 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
2095 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
2096 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
2097 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2098 {
2099     TRACE("(%p %p %ld)\n", this, ptr, count);
2100     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2101 }
2102
2103 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2104 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
2105 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2106 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
2107 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
2108 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
2109         streamsize, (basic_streambuf_wchar*), (this))
2110 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
2111 {
2112     TRACE("(%p)\n", this);
2113     return 0;
2114 }
2115
2116 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2117 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
2118 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2119 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
2120 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
2121 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
2122 {
2123     streamsize ret;
2124
2125     TRACE("(%p)\n", this);
2126
2127     ret = basic_streambuf_wchar__Gnavail(this);
2128     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
2129 }
2130
2131 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2132 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2133 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2134 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2135 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
2136 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
2137 {
2138     TRACE("(%p %d)\n", this, ch);
2139     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
2140         (*this->prsize)++;
2141         (*this->prpos)--;
2142         return ch;
2143     }
2144
2145     return call_basic_streambuf_wchar_pbackfail(this, ch);
2146 }
2147
2148 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2149 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2150 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2151 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
2152 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
2153 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
2154 {
2155     TRACE("(%p %d)\n", this, ch);
2156     return basic_streambuf_wchar__Pnavail(this) ?
2157         (*basic_streambuf_wchar__Pninc(this) = ch) :
2158         call_basic_streambuf_wchar_overflow(this, ch);
2159 }
2160
2161 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2162 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2163 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2164 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2165 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
2166 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
2167 {
2168     TRACE("(%p)\n", this);
2169     if(*this->prpos && *this->prpos>*this->prbuf) {
2170         (*this->prsize)++;
2171         (*this->prpos)--;
2172         return **this->prpos;
2173     }
2174
2175     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
2176 }
2177
2178 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2179 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2180 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2181 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2182 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
2183 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
2184 {
2185     TRACE("(%p)\n", this);
2186     if(basic_streambuf_wchar__Gnavail(this))
2187         basic_streambuf_wchar__Gninc(this);
2188     else
2189         call_basic_streambuf_wchar_uflow(this);
2190 }
2191
2192 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2193 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2194 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2195 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2196 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
2197 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
2198 {
2199     TRACE("(%p)\n", this);
2200     return basic_streambuf_wchar__Gnavail(this) ?
2201         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
2202 }
2203
2204 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2205 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2206 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2207 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2208 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
2209 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
2210 {
2211     TRACE("(%p)\n", this);
2212     return basic_streambuf_wchar__Gnavail(this) ?
2213         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
2214 }
2215
2216 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2217 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2218 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2219 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2220 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
2221 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
2222 {
2223     TRACE("(%p)\n", this);
2224
2225     if(basic_streambuf_wchar__Gnavail(this) > 1)
2226         return *basic_streambuf_wchar__Gnpreinc(this);
2227     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
2228         WEOF : basic_streambuf_wchar_sgetc(this);
2229 }
2230
2231 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
2232 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
2233 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
2234 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
2235 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
2236 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
2237         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
2238 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2239 {
2240     TRACE("(%p %p %ld)\n", this, ptr, count);
2241     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2242 }
2243
2244 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
2245 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
2246 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
2247 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
2248 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
2249 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
2250         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
2251 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2252 {
2253     streamsize copied, chunk;
2254
2255     TRACE("(%p %p %ld)\n", this, ptr, count);
2256
2257     for(copied=0; copied<count;) {
2258         chunk = basic_streambuf_wchar__Pnavail(this);
2259         if(chunk > count-copied)
2260             chunk = count-copied;
2261
2262         if(chunk > 0) {
2263             memcpy(*this->pwpos, ptr+copied, chunk*sizeof(wchar_t));
2264             *this->pwpos += chunk;
2265             *this->pwsize -= chunk;
2266             copied += chunk;
2267         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
2268             copied++;
2269         }else {
2270             break;
2271         }
2272     }
2273
2274     return copied;
2275 }
2276
2277 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
2278 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
2279 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
2280 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
2281 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
2282 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2283 {
2284     TRACE("(%p %p %ld)\n", this, ptr, count);
2285     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
2286 }
2287
2288 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2289 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2290 int basic_filebuf_char__Init__Stinit = 0;
2291
2292 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2293 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2294 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
2295 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
2296 {
2297     TRACE("(%p %p %d)\n", this, file, which);
2298
2299     this->cvt = NULL;
2300     this->wrotesome = FALSE;
2301     this->state = basic_filebuf_char__Init__Stinit;
2302     this->close = (which == INITFL_open);
2303     this->file = file;
2304
2305     basic_streambuf_char__Init_empty(&this->base);
2306     if(file)
2307         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
2308                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
2309 }
2310
2311 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAV?$codecvt@DDH@2@@Z */
2312 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$codecvt@DDH@2@@Z */
2313 static void basic_filebuf_char__Initcvt(basic_filebuf_char *this, codecvt_char *cvt)
2314 {
2315     TRACE("(%p %p)\n", this, cvt);
2316
2317     if(codecvt_base_always_noconv(&cvt->base)) {
2318         this->cvt = NULL;
2319     }else {
2320         basic_streambuf_char__Init_empty(&this->base);
2321         this->cvt = cvt;
2322     }
2323 }
2324
2325 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAE_NXZ */
2326 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAA_NXZ */
2327 static MSVCP_bool basic_filebuf_char__Endwrite(basic_filebuf_char *this)
2328 {
2329     TRACE("(%p)\n", this);
2330
2331     if(!this->wrotesome || !this->cvt)
2332         return TRUE;
2333
2334
2335     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2336         return FALSE;
2337
2338     while(1) {
2339         /* TODO: check if we need a dynamic buffer here */
2340         char buf[128];
2341         char *next;
2342         int ret;
2343
2344         ret = codecvt_char_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2345         switch(ret) {
2346         case CODECVT_ok:
2347             this->wrotesome = FALSE;
2348             /* fall through */
2349         case CODECVT_partial:
2350             if(!fwrite(buf, next-buf, 1, this->file))
2351                 return FALSE;
2352             if(this->wrotesome)
2353                 break;
2354             /* fall through */
2355         case CODECVT_noconv:
2356             if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2357                 return FALSE;
2358             return TRUE;
2359         default:
2360             return FALSE;
2361         }
2362     }
2363 }
2364
2365 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2366 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2367 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2368 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2369 {
2370     basic_filebuf_char *ret = this;
2371
2372     TRACE("(%p)\n", this);
2373
2374     if(!this->file)
2375         return NULL;
2376
2377     /* TODO: handle exceptions */
2378     if(!basic_filebuf_char__Endwrite(this))
2379         ret = NULL;
2380     if(fclose(this->file))
2381         ret  = NULL;
2382
2383     basic_filebuf_char__Init(this, NULL, INITFL_close);
2384     return ret;
2385 }
2386
2387 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2388 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2389 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2390 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2391 {
2392     TRACE("(%p %p)\n", this, file);
2393
2394     basic_streambuf_char_ctor(&this->base);
2395     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2396
2397     basic_filebuf_char__Init(this, file, INITFL_new);
2398     return this;
2399 }
2400
2401 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2402 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2403 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2404 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2405 {
2406     return basic_filebuf_char_ctor_file(this, NULL);
2407 }
2408
2409 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2410 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2411 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2412 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2413 {
2414     TRACE("(%p %d)\n", this, uninitialized);
2415
2416     basic_streambuf_char_ctor(&this->base);
2417     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2418     return this;
2419 }
2420
2421 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2422 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2423 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2424 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2425 {
2426     TRACE("(%p)\n", this);
2427
2428     if(this->close)
2429         basic_filebuf_char_close(this);
2430     basic_streambuf_char_dtor(&this->base);
2431 }
2432
2433 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2434 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2435 {
2436     TRACE("(%p %x)\n", this, flags);
2437     if(flags & 2) {
2438         /* we have an array, with the number of elements stored before the first object */
2439         INT_PTR i, *ptr = (INT_PTR *)this-1;
2440
2441         for(i=*ptr-1; i>=0; i--)
2442             basic_filebuf_char_dtor(this+i);
2443         MSVCRT_operator_delete(ptr);
2444     } else {
2445         basic_filebuf_char_dtor(this);
2446         if(flags & 1)
2447             MSVCRT_operator_delete(this);
2448     }
2449
2450     return this;
2451 }
2452
2453 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2454 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2455 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2456 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2457 {
2458     TRACE("(%p)\n", this);
2459     return this->file != NULL;
2460 }
2461
2462 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2463 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2464 static FILE* _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2465 {
2466     static const wchar_t rW[] = {'r',0};
2467     static const struct {
2468         int mode;
2469         const wchar_t str[4];
2470         const wchar_t str_bin[4];
2471     } str_mode[] = {
2472         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2473         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2474         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2475         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2476         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2477         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2478         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2479         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2480         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2481     };
2482
2483     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2484     int mode_idx;
2485     FILE *f = NULL;
2486
2487     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2488
2489     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2490         if(str_mode[mode_idx].mode == real_mode)
2491             break;
2492     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2493         return NULL;
2494
2495     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2496         return NULL;
2497     else if(f)
2498         fclose(f);
2499
2500     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2501             && (f = _wfopen(name, rW))) {
2502         fclose(f);
2503         return NULL;
2504     }
2505
2506     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2507             : str_mode[mode_idx].str, prot);
2508     if(!f)
2509         return NULL;
2510
2511     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2512         fclose(f);
2513         return NULL;
2514     }
2515
2516     return f;
2517 }
2518
2519 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2520 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2521 static FILE* _Fiopen(const char *name, int mode, int prot)
2522 {
2523     wchar_t nameW[FILENAME_MAX];
2524
2525     TRACE("(%s %d %d)\n", name, mode, prot);
2526
2527     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2528         return NULL;
2529     return _Fiopen_wchar(nameW, mode, prot);
2530 }
2531
2532 /* ?__Fiopen@std@@YAPAU_iobuf@@PBDH@Z */
2533 /* ?__Fiopen@std@@YAPEAU_iobuf@@PEBDH@Z */
2534 FILE* __cdecl ___Fiopen(const char *name, int mode)
2535 {
2536     TRACE("(%p %d)\n", name, mode);
2537     return _Fiopen(name, mode, _SH_DENYNO);
2538 }
2539
2540 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2541 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2542 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2543 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2544 static basic_filebuf_char* basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2545 {
2546     FILE *f = NULL;
2547
2548     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2549
2550     if(basic_filebuf_char_is_open(this))
2551         return NULL;
2552
2553     if(!(f = _Fiopen_wchar(name, mode, prot)))
2554         return NULL;
2555
2556     basic_filebuf_char__Init(this, f, INITFL_open);
2557     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(this->base.loc));
2558     return this;
2559 }
2560
2561 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2562 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2563 static basic_filebuf_char* basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2564 {
2565     wchar_t nameW[FILENAME_MAX];
2566
2567     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2568
2569     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2570         return NULL;
2571     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2572 }
2573
2574 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDF@Z */
2575 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDF@Z */
2576 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode_old, 12)
2577 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode_old(basic_filebuf_char *this, const char *name, short mode)
2578 {
2579     TRACE("(%p %p %d)\n", this, name, mode);
2580     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2581 }
2582
2583 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDH@Z */
2584 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDH@Z */
2585 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2586 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, int mode)
2587 {
2588     TRACE("(%p %p %d)\n", this, name, mode);
2589     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2590 }
2591
2592 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2593 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2594 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2595 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2596 {
2597     char buf[8], *dyn_buf;
2598     char ch = c, *to_next;
2599     const char *from_next;
2600     int ret, max_size;
2601
2602
2603     TRACE("(%p %d)\n", this, c);
2604
2605     if(!basic_filebuf_char_is_open(this))
2606         return EOF;
2607     if(c == EOF)
2608         return !c;
2609
2610     if(!this->cvt)
2611         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2612
2613     from_next = &ch;
2614     do {
2615         ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2616                 &from_next, buf, buf+sizeof(buf), &to_next);
2617
2618         switch(ret) {
2619         case CODECVT_partial:
2620             if(to_next == buf)
2621                 break;
2622             /* fall through */
2623         case CODECVT_ok:
2624             if(!fwrite(buf, to_next-buf, 1, this->file))
2625                 return EOF;
2626             if(ret == CODECVT_partial)
2627                 continue;
2628             return c;
2629         case CODECVT_noconv:
2630             return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2631         default:
2632             return EOF;
2633         }
2634
2635         break;
2636     } while(1);
2637
2638     max_size = codecvt_base_max_length(&this->cvt->base);
2639     dyn_buf = malloc(max_size);
2640     if(!dyn_buf)
2641         return EOF;
2642
2643     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2644             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2645
2646     switch(ret) {
2647     case CODECVT_ok:
2648         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2649         free(dyn_buf);
2650         return ret ? c : EOF;
2651     case CODECVT_partial:
2652         ERR("buffer should be big enough to store all output\n");
2653         /* fall through */
2654     default:
2655         free(dyn_buf);
2656         return EOF;
2657     }
2658 }
2659
2660 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2661 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2662 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2663 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2664 {
2665     TRACE("(%p %d)\n", this, c);
2666
2667     if(!basic_filebuf_char_is_open(this))
2668         return EOF;
2669
2670     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2671             && (c==EOF || (int)(unsigned char)basic_streambuf_char_gptr(&this->base)[-1]==c)) {
2672         basic_streambuf_char__Gndec(&this->base);
2673         return c==EOF ? !c : c;
2674     }else if(c!=EOF && !this->cvt) {
2675         return ungetc(c, this->file);
2676     }
2677
2678     return EOF;
2679 }
2680
2681 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2682 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2683 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2684 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2685 {
2686     char ch, buf[128], *to_next;
2687     const char *buf_next;
2688     int c, i;
2689
2690     TRACE("(%p)\n", this);
2691
2692     if(!basic_filebuf_char_is_open(this))
2693         return EOF;
2694
2695     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2696         return (unsigned char)*basic_streambuf_char__Gninc(&this->base);
2697
2698     c = fgetc(this->file);
2699     if(!this->cvt || c==EOF)
2700         return c;
2701
2702     buf_next = buf;
2703     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
2704         buf[i] = c;
2705
2706         switch(codecvt_char_in(this->cvt, &this->state, buf_next,
2707                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2708         case CODECVT_partial:
2709         case CODECVT_ok:
2710             if(to_next == &ch) {
2711                 c = fgetc(this->file);
2712                 if(c == EOF)
2713                     return EOF;
2714                 continue;
2715             }
2716
2717             for(i--; i>=buf_next-buf; i--)
2718                 ungetc(buf[i], this->file);
2719             return ch;
2720         case CODECVT_noconv:
2721             return (unsigned char)buf[0];
2722         default:
2723             return EOF;
2724         }
2725     }
2726
2727     FIXME("buffer is too small\n");
2728     return EOF;
2729 }
2730
2731 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2732 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2733 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2734 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2735 {
2736     int ret;
2737
2738     TRACE("(%p)\n", this);
2739
2740     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2741         return (unsigned char)*basic_streambuf_char_gptr(&this->base);
2742
2743     ret = call_basic_streambuf_char_uflow(&this->base);
2744     if(ret != EOF)
2745         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2746     return ret;
2747 }
2748
2749 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2750 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2751 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2752 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2753         fpos_int *ret, streamoff off, int way, int mode)
2754 {
2755     fpos_t pos;
2756
2757     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2758
2759     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2760             || fseek(this->file, off, way)) {
2761         ret->off = -1;
2762         ret->pos = 0;
2763         ret->state = 0;
2764         return ret;
2765     }
2766
2767     fgetpos(this->file, &pos);
2768     ret->off = 0;
2769     ret->pos = pos;
2770     ret->state = this->state;
2771     return ret;
2772 }
2773
2774 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2775 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2776 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2777 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2778         fpos_int *ret, fpos_int pos, int mode)
2779 {
2780     fpos_t fpos;
2781
2782     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2783
2784     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2785             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2786             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2787         ret->off = -1;
2788         ret->pos = 0;
2789         ret->state = 0;
2790         return ret;
2791     }
2792
2793     fgetpos(this->file, &fpos);
2794     ret->off = 0;
2795     ret->pos = fpos;
2796     ret->state = this->state;
2797     return ret;
2798 }
2799
2800 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2801 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2802 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2803 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2804 {
2805     TRACE("(%p %p %ld)\n", this, buf, count);
2806
2807     if(!basic_filebuf_char_is_open(this))
2808         return NULL;
2809
2810     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2811         return NULL;
2812
2813     basic_filebuf_char__Init(this, this->file, INITFL_open);
2814     return &this->base;
2815 }
2816
2817 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2818 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2819 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2820 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2821 {
2822     TRACE("(%p)\n", this);
2823
2824     if(!basic_filebuf_char_is_open(this))
2825         return 0;
2826
2827     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2828         return 0;
2829     return fflush(this->file);
2830 }
2831
2832 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
2833 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
2834 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_imbue, 8)
2835 void __thiscall basic_filebuf_char_imbue(basic_filebuf_char *this, const locale *loc)
2836 {
2837     TRACE("(%p %p)\n", this, loc);
2838     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(loc));
2839 }
2840
2841 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2842 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2843 int basic_filebuf_short__Init__Stinit = 0;
2844
2845 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2846 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2847 static void basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2848 {
2849     TRACE("(%p %p %d)\n", this, file, which);
2850
2851     this->cvt = NULL;
2852     this->wrotesome = FALSE;
2853     this->state = 0;
2854     this->close = (which == INITFL_open);
2855     this->file = file;
2856
2857     basic_streambuf_wchar__Init_empty(&this->base);
2858 }
2859
2860 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2861 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2862 DEFINE_THISCALL_WRAPPER(basic_filebuf_short__Init, 12)
2863 void __thiscall basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2864 {
2865     TRACE("(%p %p %d)\n", this, file, which);
2866
2867     this->cvt = NULL;
2868     this->wrotesome = FALSE;
2869     this->state = basic_filebuf_short__Init__Stinit;
2870     this->close = (which == INITFL_open);
2871     this->file = file;
2872
2873     basic_streambuf_wchar__Init_empty(&this->base);
2874 }
2875
2876 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$codecvt@_WDH@2@@Z */
2877 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$codecvt@_WDH@2@@Z */
2878 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAV?$codecvt@GDH@2@@Z */
2879 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$codecvt@GDH@2@@Z */
2880 static void basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this, codecvt_wchar *cvt)
2881 {
2882     TRACE("(%p %p)\n", this, cvt);
2883
2884     if(codecvt_base_always_noconv(&cvt->base)) {
2885         this->cvt = NULL;
2886     }else {
2887         basic_streambuf_wchar__Init_empty(&this->base);
2888         this->cvt = cvt;
2889     }
2890 }
2891
2892 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAE_NXZ */
2893 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAA_NXZ */
2894 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAE_NXZ */
2895 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAA_NXZ */
2896 static MSVCP_bool basic_filebuf_wchar__Endwrite(basic_filebuf_wchar *this)
2897 {
2898     TRACE("(%p)\n", this);
2899
2900     if(!this->wrotesome || !this->cvt)
2901         return TRUE;
2902
2903     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2904         return FALSE;
2905
2906     while(1) {
2907         /* TODO: check if we need a dynamic buffer here */
2908         char buf[128];
2909         char *next;
2910         int ret;
2911
2912         ret = codecvt_wchar_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2913         switch(ret) {
2914         case CODECVT_ok:
2915             this->wrotesome = FALSE;
2916             /* fall through */
2917         case CODECVT_partial:
2918             if(!fwrite(buf, next-buf, 1, this->file))
2919                 return FALSE;
2920             if(this->wrotesome)
2921                 break;
2922             /* fall through */
2923         case CODECVT_noconv:
2924             if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2925                 return FALSE;
2926             return TRUE;
2927         default:
2928             return FALSE;
2929         }
2930     }
2931 }
2932
2933 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
2934 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
2935 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
2936 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
2937 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_close, 4)
2938 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_close(basic_filebuf_wchar *this)
2939 {
2940     basic_filebuf_wchar *ret = this;
2941
2942     TRACE("(%p)\n", this);
2943
2944     if(!this->file)
2945         return NULL;
2946
2947     /* TODO: handle exceptions */
2948     if(!basic_filebuf_wchar__Endwrite(this))
2949         ret = NULL;
2950     if(fclose(this->file))
2951         ret  = NULL;
2952
2953     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
2954     return ret;
2955 }
2956
2957 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
2958 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2959 static basic_filebuf_wchar* basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
2960 {
2961     TRACE("(%p %p)\n", this, file);
2962
2963     basic_streambuf_wchar_ctor(&this->base);
2964     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
2965
2966     basic_filebuf_wchar__Init(this, file, INITFL_new);
2967     return this;
2968 }
2969
2970 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
2971 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2972 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_file, 8)
2973 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
2974 {
2975     TRACE("(%p %p)\n", this, file);
2976
2977     basic_streambuf_short_ctor(&this->base);
2978     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
2979
2980     basic_filebuf_short__Init(this, file, INITFL_new);
2981     return this;
2982 }
2983
2984 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2985 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2986 static basic_filebuf_wchar* basic_filebuf_wchar_ctor(basic_filebuf_wchar *this)
2987 {
2988     return basic_filebuf_wchar_ctor_file(this, NULL);
2989 }
2990
2991 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2992 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2993 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor, 4)
2994 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor(basic_filebuf_wchar *this)
2995 {
2996     return basic_filebuf_short_ctor_file(this, NULL);
2997 }
2998
2999 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3000 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3001 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_uninitialized, 8)
3002 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
3003 {
3004     TRACE("(%p %d)\n", this, uninitialized);
3005
3006     basic_streambuf_short_ctor(&this->base);
3007     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3008     return this;
3009 }
3010
3011 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
3012 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
3013 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
3014 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
3015 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_dtor, 4)
3016 void __thiscall basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
3017 {
3018     TRACE("(%p)\n", this);
3019
3020     if(this->close)
3021         basic_filebuf_wchar_close(this);
3022     basic_streambuf_wchar_dtor(&this->base);
3023 }
3024
3025 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
3026 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
3027 {
3028     TRACE("(%p %x)\n", this, flags);
3029     if(flags & 2) {
3030         /* we have an array, with the number of elements stored before the first object */
3031         INT_PTR i, *ptr = (INT_PTR *)this-1;
3032
3033         for(i=*ptr-1; i>=0; i--)
3034             basic_filebuf_wchar_dtor(this+i);
3035         MSVCRT_operator_delete(ptr);
3036     } else {
3037         basic_filebuf_wchar_dtor(this);
3038         if(flags & 1)
3039             MSVCRT_operator_delete(this);
3040     }
3041
3042     return this;
3043 }
3044
3045 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
3046 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
3047 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
3048 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
3049 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_is_open, 4)
3050 MSVCP_bool __thiscall basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
3051 {
3052     TRACE("(%p)\n", this);
3053     return this->file != NULL;
3054 }
3055
3056 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WHH@Z */
3057 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3058 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGHH@Z */
3059 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3060 static basic_filebuf_wchar* basic_filebuf_wchar_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3061 {
3062     FILE *f = NULL;
3063
3064     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3065
3066     if(basic_filebuf_wchar_is_open(this))
3067         return NULL;
3068
3069     if(!(f = _Fiopen_wchar(name, mode, prot)))
3070         return NULL;
3071
3072     basic_filebuf_wchar__Init(this, f, INITFL_open);
3073     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(this->base.loc));
3074     return this;
3075 }
3076
3077 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDHH@Z */
3078 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3079 static basic_filebuf_wchar* basic_filebuf_wchar_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3080 {
3081     wchar_t nameW[FILENAME_MAX];
3082
3083     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3084
3085     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3086         return NULL;
3087     return basic_filebuf_wchar_open_wchar(this, nameW, mode, prot);
3088 }
3089
3090 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
3091 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
3092 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode_old, 12)
3093 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode_old(basic_filebuf_wchar *this, const char *name, short mode)
3094 {
3095     TRACE("(%p %p %d)\n", this, name, mode);
3096     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3097 }
3098
3099 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
3100 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
3101 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode, 12)
3102 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode(basic_filebuf_wchar *this, const char *name, int mode)
3103 {
3104     TRACE("(%p %p %d)\n", this, name, mode);
3105     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3106 }
3107
3108 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3109 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3110 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3111 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3112 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
3113 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
3114 {
3115     char buf[8], *dyn_buf, *to_next;
3116     wchar_t ch = c;
3117     const wchar_t *from_next;
3118     int max_size;
3119     unsigned short ret;
3120
3121
3122     TRACE("(%p %d)\n", this, c);
3123
3124     if(!basic_filebuf_wchar_is_open(this))
3125         return WEOF;
3126     if(c == WEOF)
3127         return !c;
3128
3129     if(!this->cvt)
3130         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3131
3132     from_next = &ch;
3133     do {
3134         ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3135                 &from_next, buf, buf+sizeof(buf), &to_next);
3136
3137         switch(ret) {
3138         case CODECVT_partial:
3139             if(to_next == buf)
3140                 break;
3141             /* fall through */
3142         case CODECVT_ok:
3143             if(!fwrite(buf, to_next-buf, 1, this->file))
3144                 return WEOF;
3145             if(ret == CODECVT_partial)
3146                 continue;
3147             return c;
3148         case CODECVT_noconv:
3149             return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3150         default:
3151             return WEOF;
3152         }
3153
3154         break;
3155     } while(1);
3156
3157     max_size = codecvt_base_max_length(&this->cvt->base);
3158     dyn_buf = malloc(max_size);
3159     if(!dyn_buf)
3160         return WEOF;
3161
3162     ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3163             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
3164
3165     switch(ret) {
3166     case CODECVT_ok:
3167         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
3168         free(dyn_buf);
3169         return ret ? c : WEOF;
3170     case CODECVT_partial:
3171         ERR("buffer should be big enough to store all output\n");
3172         /* fall through */
3173     default:
3174         free(dyn_buf);
3175         return WEOF;
3176     }
3177 }
3178
3179 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3180 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3181 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3182 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3183 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
3184 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
3185 {
3186     TRACE("(%p %d)\n", this, c);
3187
3188     if(!basic_filebuf_wchar_is_open(this))
3189         return WEOF;
3190
3191     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
3192             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==c)) {
3193         basic_streambuf_wchar__Gndec(&this->base);
3194         return c==WEOF ? !c : c;
3195     }else if(c!=WEOF && !this->cvt) {
3196         return ungetwc(c, this->file);
3197     }else if(c!=WEOF && basic_streambuf_wchar_gptr(&this->base)!=&this->putback) {
3198         this->putback = c;
3199         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback, &this->putback+1);
3200         return c;
3201     }
3202
3203     return WEOF;
3204 }
3205
3206 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3207 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3208 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3209 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3210 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
3211 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
3212 {
3213     wchar_t ch, *to_next;
3214     char buf[128];
3215     const char *buf_next;
3216     int c, i;
3217
3218     TRACE("(%p)\n", this);
3219
3220     if(!basic_filebuf_wchar_is_open(this))
3221         return WEOF;
3222
3223     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3224         return *basic_streambuf_wchar__Gninc(&this->base);
3225
3226     if(!this->cvt)
3227         return fgetwc(this->file);
3228
3229     buf_next = buf;
3230     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
3231         if((c = fgetc(this->file)) == EOF)
3232             return WEOF;
3233         buf[i] = c;
3234
3235         switch(codecvt_wchar_in(this->cvt, &this->state, buf_next,
3236                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
3237         case CODECVT_partial:
3238         case CODECVT_ok:
3239             if(to_next == &ch)
3240                 continue;
3241
3242             for(i--; i>=buf_next-buf; i--)
3243                 ungetc(buf[i], this->file);
3244             return ch;
3245         case CODECVT_noconv:
3246             if(i+1 < sizeof(wchar_t))
3247                 continue;
3248
3249             memcpy(&ch, buf, sizeof(wchar_t));
3250             return ch;
3251         default:
3252             return WEOF;
3253         }
3254     }
3255
3256     FIXME("buffer is too small\n");
3257     return WEOF;
3258 }
3259
3260 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3261 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3262 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3263 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3264 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
3265 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
3266 {
3267     unsigned short ret;
3268
3269     TRACE("(%p)\n", this);
3270
3271     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3272         return *basic_streambuf_wchar_gptr(&this->base);
3273
3274     ret = call_basic_streambuf_wchar_uflow(&this->base);
3275     if(ret != WEOF)
3276         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
3277     return ret;
3278 }
3279
3280 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3281 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3282 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3283 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3284 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 20)
3285 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
3286         fpos_int *ret, streamoff off, int way, int mode)
3287 {
3288     fpos_t pos;
3289
3290     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3291
3292     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback) {
3293         if(way == SEEKDIR_cur)
3294             off -= sizeof(wchar_t);
3295
3296         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3297     }
3298
3299     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3300             || fseek(this->file, off, way)) {
3301         ret->off = -1;
3302         ret->pos = 0;
3303         ret->state = 0;
3304         return ret;
3305     }
3306
3307     fgetpos(this->file, &pos);
3308     ret->off = 0;
3309     ret->pos = pos;
3310     ret->state = this->state;
3311     return ret;
3312 }
3313
3314 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3315 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3316 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3317 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3318 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
3319 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
3320         fpos_int *ret, fpos_int pos, int mode)
3321 {
3322     fpos_t fpos;
3323
3324     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3325
3326     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3327             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
3328             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
3329         ret->off = -1;
3330         ret->pos = 0;
3331         ret->state = 0;
3332         return ret;
3333     }
3334
3335     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback)
3336         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3337
3338     fgetpos(this->file, &fpos);
3339     ret->off = 0;
3340     ret->pos = fpos;
3341     ret->state = this->state;
3342     return ret;
3343 }
3344
3345 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
3346 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
3347 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 12)
3348 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3349 {
3350     TRACE("(%p %p %ld)\n", this, buf, count);
3351
3352     if(!basic_filebuf_wchar_is_open(this))
3353         return NULL;
3354
3355     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3356         return NULL;
3357
3358     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
3359     return &this->base;
3360 }
3361
3362 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
3363 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
3364 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 12)
3365 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3366 {
3367     TRACE("(%p %p %ld)\n", this, buf, count);
3368
3369     if(!basic_filebuf_wchar_is_open(this))
3370         return NULL;
3371
3372     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3373         return NULL;
3374
3375     basic_filebuf_short__Init(this, this->file, INITFL_open);
3376     return &this->base;
3377 }
3378
3379 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
3380 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
3381 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
3382 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
3383 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
3384 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
3385 {
3386     TRACE("(%p)\n", this);
3387
3388     if(!basic_filebuf_wchar_is_open(this))
3389         return 0;
3390
3391     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
3392         return 0;
3393     return fflush(this->file);
3394 }
3395
3396 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
3397 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
3398 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_imbue, 8)
3399 void __thiscall basic_filebuf_wchar_imbue(basic_filebuf_wchar *this, const locale *loc)
3400 {
3401     TRACE("(%p %p)\n", this, loc);
3402     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(loc));
3403 }
3404
3405 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
3406 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
3407 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_imbue, 8)
3408 void __thiscall basic_filebuf_short_imbue(basic_filebuf_wchar *this, const locale *loc)
3409 {
3410     TRACE("(%p %p)\n", this, loc);
3411     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(loc));
3412 }
3413
3414 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3415 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3416 static int basic_stringbuf_char__Getstate(basic_stringbuf_char *this, IOSB_openmode mode)
3417 {
3418     int state = 0;
3419
3420     if(!(mode & OPENMODE_in))
3421         state |= STRINGBUF_no_read;
3422
3423     if(!(mode & OPENMODE_out))
3424         state |= STRINGBUF_no_write;
3425
3426     if(mode & OPENMODE_ate)
3427         state |= STRINGBUF_at_end;
3428
3429     if(mode & OPENMODE_app)
3430         state |= STRINGBUF_append;
3431
3432     return state;
3433 }
3434
3435 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXPBDIH@Z */
3436 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXPEBD_KH@Z */
3437 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Init, 16)
3438 void __thiscall basic_stringbuf_char__Init(basic_stringbuf_char *this, const char *str, MSVCP_size_t count, int state)
3439 {
3440     TRACE("(%p, %p, %ld, %d)\n", this, str, count, state);
3441
3442     basic_streambuf_char__Init_empty(&this->base);
3443
3444     this->state = state;
3445     this->seekhigh = NULL;
3446
3447     if(count && str) {
3448         char *buf = MSVCRT_operator_new(count);
3449         if(!buf) {
3450             ERR("Out of memory\n");
3451             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3452         }
3453
3454         memcpy(buf, str, count);
3455         this->seekhigh = buf + count;
3456
3457         this->state |= STRINGBUF_allocated;
3458
3459         if(!(state & STRINGBUF_no_read))
3460             basic_streambuf_char_setg(&this->base, buf, buf, buf + count);
3461
3462         if(!(state & STRINGBUF_no_write)) {
3463             basic_streambuf_char_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3464
3465             if(!basic_streambuf_char_gptr(&this->base))
3466                 basic_streambuf_char_setg(&this->base, buf, 0, buf);
3467         }
3468     }
3469 }
3470
3471 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
3472 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
3473 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_str, 12)
3474 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_str(basic_stringbuf_char *this,
3475         const basic_string_char *str, IOSB_openmode mode)
3476 {
3477     TRACE("(%p %p %d)\n", this, str, mode);
3478
3479     basic_streambuf_char_ctor(&this->base);
3480     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3481
3482     basic_stringbuf_char__Init(this, basic_string_char_c_str(str),
3483             str->size, basic_stringbuf_char__Getstate(this, mode));
3484     return this;
3485 }
3486
3487 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
3488 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
3489 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_mode, 8)
3490 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_mode(
3491         basic_stringbuf_char *this, IOSB_openmode mode)
3492 {
3493     TRACE("(%p %d)\n", this, mode);
3494
3495     basic_streambuf_char_ctor(&this->base);
3496     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3497
3498     basic_stringbuf_char__Init(this, NULL, 0, basic_stringbuf_char__Getstate(this, mode));
3499     return this;
3500 }
3501
3502 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
3503 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
3504 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor, 4)
3505 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor(basic_stringbuf_char *this)
3506 {
3507     return basic_stringbuf_char_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3508 }
3509
3510 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXXZ */
3511 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXXZ */
3512 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Tidy, 4)
3513 void __thiscall basic_stringbuf_char__Tidy(basic_stringbuf_char *this)
3514 {
3515     TRACE("(%p)\n", this);
3516
3517     if(this->state & STRINGBUF_allocated) {
3518         MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
3519         this->seekhigh = NULL;
3520         this->state &= ~STRINGBUF_allocated;
3521     }
3522
3523     basic_streambuf_char__Init_empty(&this->base);
3524 }
3525
3526 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
3527 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
3528 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_dtor, 4)
3529 void __thiscall basic_stringbuf_char_dtor(basic_stringbuf_char *this)
3530 {
3531     TRACE("(%p)\n", this);
3532
3533     basic_stringbuf_char__Tidy(this);
3534     basic_streambuf_char_dtor(&this->base);
3535 }
3536
3537 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_vector_dtor, 8)
3538 basic_stringbuf_char* __thiscall basic_stringbuf_char_vector_dtor(basic_stringbuf_char *this, unsigned int flags)
3539 {
3540     TRACE("(%p %x)\n", this, flags);
3541
3542     if(flags & 2) {
3543         /* we have an array, with the number of elements stored before the first object */
3544         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3545
3546         for (i = *ptr - 1; i >= 0; i--)
3547             basic_stringbuf_char_dtor(this+i);
3548
3549         MSVCRT_operator_delete(ptr);
3550     }else {
3551         basic_stringbuf_char_dtor(this);
3552
3553         if(flags & 1)
3554             MSVCRT_operator_delete(this);
3555     }
3556
3557     return this;
3558 }
3559
3560 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3561 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3562 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_overflow, 8)
3563 int __thiscall basic_stringbuf_char_overflow(basic_stringbuf_char *this, int meta)
3564 {
3565     MSVCP_size_t oldsize, size;
3566     char *ptr, *buf;
3567
3568     TRACE("(%p %x)\n", this, meta);
3569
3570     if(meta == EOF)
3571         return !EOF;
3572     if(this->state & STRINGBUF_no_write)
3573         return EOF;
3574
3575     ptr = basic_streambuf_char_pptr(&this->base);
3576     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3577         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
3578                 this->seekhigh, basic_streambuf_char_epptr(&this->base));
3579
3580     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
3581         return (*basic_streambuf_char__Pninc(&this->base) = meta);
3582
3583     oldsize = (ptr ? basic_streambuf_char_epptr(&this->base)-basic_streambuf_char_eback(&this->base): 0);
3584     size = oldsize|0xf;
3585     size += size/2;
3586     buf = MSVCRT_operator_new(size);
3587     if(!buf) {
3588         ERR("Out of memory\n");
3589         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3590     }
3591
3592     if(!oldsize) {
3593         this->seekhigh = buf;
3594         basic_streambuf_char_setp(&this->base, buf, buf+size);
3595         if(this->state & STRINGBUF_no_read)
3596             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3597         else
3598             basic_streambuf_char_setg(&this->base, buf, buf, buf+1);
3599
3600         this->state |= STRINGBUF_allocated;
3601     }else {
3602         ptr = basic_streambuf_char_eback(&this->base);
3603         memcpy(buf, ptr, oldsize);
3604
3605         this->seekhigh = buf+(this->seekhigh-ptr);
3606         basic_streambuf_char_setp_next(&this->base, buf,
3607                 buf+(basic_streambuf_char_pptr(&this->base)-ptr), buf+size);
3608         if(this->state & STRINGBUF_no_read)
3609             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3610         else
3611             basic_streambuf_char_setg(&this->base, buf,
3612                     buf+(basic_streambuf_char_gptr(&this->base)-ptr),
3613                     basic_streambuf_char_pptr(&this->base)+1);
3614
3615         MSVCRT_operator_delete(ptr);
3616     }
3617
3618     return (*basic_streambuf_char__Pninc(&this->base) = meta);
3619 }
3620
3621 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3622 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3623 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_pbackfail, 8)
3624 int __thiscall basic_stringbuf_char_pbackfail(basic_stringbuf_char *this, int c)
3625 {
3626     char *cur;
3627
3628     TRACE("(%p %x)\n", this, c);
3629
3630     cur = basic_streambuf_char_gptr(&this->base);
3631     if(!cur || cur==basic_streambuf_char_eback(&this->base)
3632             || (c!=EOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3633         return EOF;
3634
3635     if(c != EOF)
3636         cur[-1] = c;
3637     basic_streambuf_char_gbump(&this->base, -1);
3638     return c==EOF ? !EOF : c;
3639 }
3640
3641 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHXZ */
3642 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHXZ */
3643 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_underflow, 4)
3644 int __thiscall basic_stringbuf_char_underflow(basic_stringbuf_char *this)
3645 {
3646     char *ptr, *cur;
3647
3648     TRACE("(%p)\n", this);
3649
3650     cur = basic_streambuf_char_gptr(&this->base);
3651     if(!cur || this->state&STRINGBUF_no_read)
3652         return EOF;
3653
3654     ptr  = basic_streambuf_char_pptr(&this->base);
3655     if(this->seekhigh < ptr)
3656         this->seekhigh = ptr;
3657
3658     ptr = basic_streambuf_char_egptr(&this->base);
3659     if(this->seekhigh > ptr)
3660         basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base), cur, this->seekhigh);
3661
3662     if(cur < this->seekhigh)
3663         return (unsigned char)*cur;
3664     return EOF;
3665 }
3666
3667 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3668 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3669 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekoff, 20)
3670 fpos_int* __thiscall basic_stringbuf_char_seekoff(basic_stringbuf_char *this,
3671         fpos_int *ret, streamoff off, int way, int mode)
3672 {
3673     char *beg, *cur_r, *cur_w;
3674
3675     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3676
3677     cur_w = basic_streambuf_char_pptr(&this->base);
3678     if(cur_w > this->seekhigh)
3679         this->seekhigh = cur_w;
3680
3681     ret->off = 0;
3682     ret->pos = 0;
3683     ret->state = 0;
3684
3685     beg = basic_streambuf_char_eback(&this->base);
3686     cur_r = basic_streambuf_char_gptr(&this->base);
3687     if((mode & OPENMODE_in) && cur_r) {
3688         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3689             off += cur_r-beg;
3690         else if(way == SEEKDIR_end)
3691             off += this->seekhigh-beg;
3692         else if(way != SEEKDIR_beg)
3693             off = -1;
3694
3695         if(off<0 || off>this->seekhigh-beg) {
3696             off = -1;
3697         }else {
3698             basic_streambuf_char_gbump(&this->base, beg-cur_r+off);
3699             if((mode & OPENMODE_out) && cur_w) {
3700                 basic_streambuf_char_setp_next(&this->base, beg,
3701                         basic_streambuf_char_gptr(&this->base),
3702                         basic_streambuf_char_epptr(&this->base));
3703             }
3704         }
3705     }else if((mode & OPENMODE_out) && cur_w) {
3706         if(way == SEEKDIR_cur)
3707             off += cur_w-beg;
3708         else if(way == SEEKDIR_end)
3709             off += this->seekhigh-beg;
3710         else if(way != SEEKDIR_beg)
3711             off = -1;
3712
3713         if(off<0 || off>this->seekhigh-beg)
3714             off = -1;
3715         else
3716             basic_streambuf_char_pbump(&this->base, beg-cur_w+off);
3717     }else {
3718         off = -1;
3719     }
3720
3721     ret->off = off;
3722     return ret;
3723 }
3724
3725 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3726 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3727 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekpos, 36)
3728 fpos_int* __thiscall basic_stringbuf_char_seekpos(basic_stringbuf_char *this,
3729         fpos_int *ret, fpos_int pos, int mode)
3730 {
3731     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3732
3733     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
3734         *ret = pos;
3735         return ret;
3736     }
3737
3738     return basic_stringbuf_char_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
3739 }
3740
3741 /* ?str@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
3742 /* ?str@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
3743 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_set, 8)
3744 void __thiscall basic_stringbuf_char_str_set(basic_stringbuf_char *this, const basic_string_char *str)
3745 {
3746     TRACE("(%p %p)\n", this, str);
3747
3748     basic_stringbuf_char__Tidy(this);
3749     basic_stringbuf_char__Init(this, basic_string_char_c_str(str), str->size, this->state);
3750 }
3751
3752 /* ?str@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
3753 /* ?str@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
3754 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_get, 8)
3755 basic_string_char* __thiscall basic_stringbuf_char_str_get(const basic_stringbuf_char *this, basic_string_char *ret)
3756 {
3757     char *ptr;
3758
3759     TRACE("(%p)\n", this);
3760
3761     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_char_pptr(&this->base)) {
3762         char *pptr;
3763
3764         ptr = basic_streambuf_char_pbase(&this->base);
3765         pptr = basic_streambuf_char_pptr(&this->base);
3766
3767         return basic_string_char_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
3768     }
3769
3770     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_char_gptr(&this->base)) {
3771         ptr = basic_streambuf_char_eback(&this->base);
3772         return basic_string_char_ctor_cstr_len(ret, ptr, basic_streambuf_char_egptr(&this->base) - ptr);
3773     }
3774
3775     return basic_string_char_ctor(ret);
3776 }
3777
3778 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAEHH@Z */
3779 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAAHH@Z */
3780 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3781 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3782 static int basic_stringbuf_wchar__Getstate(basic_stringbuf_wchar *this, IOSB_openmode mode)
3783 {
3784     int state = 0;
3785
3786     if(!(mode & OPENMODE_in))
3787         state |= STRINGBUF_no_read;
3788
3789     if(!(mode & OPENMODE_out))
3790         state |= STRINGBUF_no_write;
3791
3792     if(mode & OPENMODE_ate)
3793         state |= STRINGBUF_at_end;
3794
3795     if(mode & OPENMODE_app)
3796         state |= STRINGBUF_append;
3797
3798     return state;
3799 }
3800
3801 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXPB_WIH@Z */
3802 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXPEB_W_KH@Z */
3803 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXPBGIH@Z */
3804 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXPEBG_KH@Z */
3805 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Init, 16)
3806 void __thiscall basic_stringbuf_wchar__Init(basic_stringbuf_wchar *this, const wchar_t *str, MSVCP_size_t count, int state)
3807 {
3808     TRACE("(%p, %p, %lu, %d)\n", this, str, count, state);
3809
3810     basic_streambuf_wchar__Init_empty(&this->base);
3811
3812     this->state = state;
3813     this->seekhigh = NULL;
3814
3815     if(count && str) {
3816         wchar_t *buf = MSVCRT_operator_new(count*sizeof(wchar_t));
3817         if(!buf) {
3818             ERR("Out of memory\n");
3819             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3820         }
3821
3822         memcpy(buf, str, count*sizeof(wchar_t));
3823         this->seekhigh = buf + count;
3824
3825         this->state |= STRINGBUF_allocated;
3826
3827         if(!(state & STRINGBUF_no_read))
3828             basic_streambuf_wchar_setg(&this->base, buf, buf, buf + count);
3829
3830         if(!(state & STRINGBUF_no_write)) {
3831             basic_streambuf_wchar_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3832
3833             if(!basic_streambuf_wchar_gptr(&this->base))
3834                 basic_streambuf_wchar_setg(&this->base, buf, 0, buf);
3835         }
3836     }
3837 }
3838
3839 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z */
3840 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@AEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z */
3841 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_str(basic_stringbuf_wchar *this,
3842         const basic_string_wchar *str, IOSB_openmode mode)
3843 {
3844     TRACE("(%p %p %d)\n", this, str, mode);
3845
3846     basic_streambuf_wchar_ctor(&this->base);
3847     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3848
3849     basic_stringbuf_wchar__Init(this, basic_string_wchar_c_str(str),
3850             str->size, basic_stringbuf_wchar__Getstate(this, mode));
3851     return this;
3852 }
3853
3854 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z */
3855 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@AEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z */
3856 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_str, 12)
3857 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_str(basic_stringbuf_wchar *this,
3858         const basic_string_wchar *str, IOSB_openmode mode)
3859 {
3860     basic_stringbuf_wchar_ctor_str(this, str, mode);
3861     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3862     return this;
3863 }
3864
3865 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
3866 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
3867 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_mode(
3868         basic_stringbuf_wchar *this, IOSB_openmode mode)
3869 {
3870     TRACE("(%p %d)\n", this, mode);
3871
3872     basic_streambuf_wchar_ctor(&this->base);
3873     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3874
3875     basic_stringbuf_wchar__Init(this, NULL, 0, basic_stringbuf_wchar__Getstate(this, mode));
3876     return this;
3877 }
3878
3879 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
3880 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
3881 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_mode, 8)
3882 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_mode(
3883         basic_stringbuf_wchar *this, IOSB_openmode mode)
3884 {
3885     basic_stringbuf_wchar_ctor_mode(this, mode);
3886     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3887     return this;
3888 }
3889
3890 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
3891 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
3892 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor, 4)
3893 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor(basic_stringbuf_wchar *this)
3894 {
3895     return basic_stringbuf_short_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3896 }
3897
3898 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXXZ */
3899 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXXZ */
3900 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXXZ */
3901 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXXZ */
3902 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Tidy, 4)
3903 void __thiscall basic_stringbuf_wchar__Tidy(basic_stringbuf_wchar *this)
3904 {
3905     TRACE("(%p)\n", this);
3906
3907     if(this->state & STRINGBUF_allocated) {
3908         MSVCRT_operator_delete(basic_streambuf_wchar_eback(&this->base));
3909         this->seekhigh = NULL;
3910         this->state &= ~STRINGBUF_allocated;
3911     }
3912
3913     basic_streambuf_wchar__Init_empty(&this->base);
3914 }
3915
3916 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
3917 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
3918 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
3919 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
3920 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_dtor, 4)
3921 void __thiscall basic_stringbuf_wchar_dtor(basic_stringbuf_wchar *this)
3922 {
3923     TRACE("(%p)\n", this);
3924
3925     basic_stringbuf_wchar__Tidy(this);
3926     basic_streambuf_wchar_dtor(&this->base);
3927 }
3928
3929 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_vector_dtor, 8)
3930 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_vector_dtor(basic_stringbuf_wchar *this, unsigned int flags)
3931 {
3932     TRACE("(%p %x)\n", this, flags);
3933
3934     if(flags & 2) {
3935         /* we have an array, with the number of elements stored before the first object */
3936         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3937
3938         for (i = *ptr - 1; i >= 0; i--)
3939             basic_stringbuf_wchar_dtor(this+i);
3940
3941         MSVCRT_operator_delete(ptr);
3942     }else {
3943         basic_stringbuf_wchar_dtor(this);
3944
3945         if(flags & 1)
3946             MSVCRT_operator_delete(this);
3947     }
3948
3949     return this;
3950 }
3951
3952 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
3953 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
3954 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
3955 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
3956 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_overflow, 8)
3957 unsigned short __thiscall basic_stringbuf_wchar_overflow(basic_stringbuf_wchar *this, unsigned short meta)
3958 {
3959     MSVCP_size_t oldsize, size;
3960     wchar_t *ptr, *buf;
3961
3962     TRACE("(%p %x)\n", this, meta);
3963
3964     if(meta == WEOF)
3965         return !WEOF;
3966     if(this->state & STRINGBUF_no_write)
3967         return WEOF;
3968
3969     ptr = basic_streambuf_wchar_pptr(&this->base);
3970     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3971         basic_streambuf_wchar_setp_next(&this->base, basic_streambuf_wchar_pbase(&this->base),
3972                 this->seekhigh, basic_streambuf_wchar_epptr(&this->base));
3973
3974     if(ptr && ptr<basic_streambuf_wchar_epptr(&this->base))
3975         return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
3976
3977     oldsize = (ptr ? basic_streambuf_wchar_epptr(&this->base)-basic_streambuf_wchar_eback(&this->base): 0);
3978     size = oldsize|0xf;
3979     size += size/2;
3980     buf = MSVCRT_operator_new(size*sizeof(wchar_t));
3981     if(!buf) {
3982         ERR("Out of memory\n");
3983         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3984     }
3985
3986     if(!oldsize) {
3987         this->seekhigh = buf;
3988         basic_streambuf_wchar_setp(&this->base, buf, buf+size);
3989         if(this->state & STRINGBUF_no_read)
3990             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
3991         else
3992             basic_streambuf_wchar_setg(&this->base, buf, buf, buf+1);
3993
3994         this->state |= STRINGBUF_allocated;
3995     }else {
3996         ptr = basic_streambuf_wchar_eback(&this->base);
3997         memcpy(buf, ptr, oldsize*sizeof(wchar_t));
3998
3999         this->seekhigh = buf+(this->seekhigh-ptr);
4000         basic_streambuf_wchar_setp_next(&this->base, buf,
4001                 buf+(basic_streambuf_wchar_pptr(&this->base)-ptr), buf+size);
4002         if(this->state & STRINGBUF_no_read)
4003             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4004         else
4005             basic_streambuf_wchar_setg(&this->base, buf,
4006                     buf+(basic_streambuf_wchar_gptr(&this->base)-ptr),
4007                     basic_streambuf_wchar_pptr(&this->base)+1);
4008
4009         MSVCRT_operator_delete(ptr);
4010     }
4011
4012     return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4013 }
4014
4015 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4016 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4017 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4018 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4019 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_pbackfail, 8)
4020 unsigned short __thiscall basic_stringbuf_wchar_pbackfail(basic_stringbuf_wchar *this, unsigned short c)
4021 {
4022     wchar_t *cur;
4023
4024     TRACE("(%p %x)\n", this, c);
4025
4026     cur = basic_streambuf_wchar_gptr(&this->base);
4027     if(!cur || cur==basic_streambuf_wchar_eback(&this->base)
4028             || (c!=WEOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
4029         return WEOF;
4030
4031     if(c != WEOF)
4032         cur[-1] = c;
4033     basic_streambuf_wchar_gbump(&this->base, -1);
4034     return c==WEOF ? !WEOF : c;
4035 }
4036
4037 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGXZ */
4038 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGXZ */
4039 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGXZ */
4040 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGXZ */
4041 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_underflow, 4)
4042 unsigned short __thiscall basic_stringbuf_wchar_underflow(basic_stringbuf_wchar *this)
4043 {
4044     wchar_t *ptr, *cur;
4045
4046     TRACE("(%p)\n", this);
4047
4048     cur = basic_streambuf_wchar_gptr(&this->base);
4049     if(!cur || this->state&STRINGBUF_no_read)
4050         return WEOF;
4051
4052     ptr  = basic_streambuf_wchar_pptr(&this->base);
4053     if(this->seekhigh < ptr)
4054         this->seekhigh = ptr;
4055
4056     ptr = basic_streambuf_wchar_egptr(&this->base);
4057     if(this->seekhigh > ptr)
4058         basic_streambuf_wchar_setg(&this->base, basic_streambuf_wchar_eback(&this->base), cur, this->seekhigh);
4059
4060     if(cur < this->seekhigh)
4061         return *cur;
4062     return WEOF;
4063 }
4064
4065 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4066 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4067 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4068 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4069 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekoff, 20)
4070 fpos_int* __thiscall basic_stringbuf_wchar_seekoff(basic_stringbuf_wchar *this,
4071         fpos_int *ret, streamoff off, int way, int mode)
4072 {
4073     wchar_t *beg, *cur_r, *cur_w;
4074
4075     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
4076
4077     cur_w = basic_streambuf_wchar_pptr(&this->base);
4078     if(cur_w > this->seekhigh)
4079         this->seekhigh = cur_w;
4080
4081     ret->off = 0;
4082     ret->pos = 0;
4083     ret->state = 0;
4084
4085     beg = basic_streambuf_wchar_eback(&this->base);
4086     cur_r = basic_streambuf_wchar_gptr(&this->base);
4087     if((mode & OPENMODE_in) && cur_r) {
4088         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
4089             off += cur_r-beg;
4090         else if(way == SEEKDIR_end)
4091             off += this->seekhigh-beg;
4092         else if(way != SEEKDIR_beg)
4093             off = -1;
4094
4095         if(off<0 || off>this->seekhigh-beg) {
4096             off = -1;
4097         }else {
4098             basic_streambuf_wchar_gbump(&this->base, beg-cur_r+off);
4099             if((mode & OPENMODE_out) && cur_w) {
4100                 basic_streambuf_wchar_setp_next(&this->base, beg,
4101                         basic_streambuf_wchar_gptr(&this->base),
4102                         basic_streambuf_wchar_epptr(&this->base));
4103             }
4104         }
4105     }else if((mode & OPENMODE_out) && cur_w) {
4106         if(way == SEEKDIR_cur)
4107             off += cur_w-beg;
4108         else if(way == SEEKDIR_end)
4109             off += this->seekhigh-beg;
4110         else if(way != SEEKDIR_beg)
4111             off = -1;
4112
4113         if(off<0 || off>this->seekhigh-beg)
4114             off = -1;
4115         else
4116             basic_streambuf_wchar_pbump(&this->base, beg-cur_w+off);
4117     }else {
4118         off = -1;
4119     }
4120
4121     ret->off = off;
4122     return ret;
4123 }
4124
4125 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4126 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4127 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4128 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4129 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekpos, 36)
4130 fpos_int* __thiscall basic_stringbuf_wchar_seekpos(basic_stringbuf_wchar *this,
4131         fpos_int *ret, fpos_int pos, int mode)
4132 {
4133     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
4134
4135     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
4136         *ret = pos;
4137         return ret;
4138     }
4139
4140     return basic_stringbuf_wchar_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
4141 }
4142
4143 /* ?str@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@@Z */
4144 /* ?str@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXAEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@@Z */
4145 /* ?str@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z */
4146 /* ?str@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXAEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z */
4147 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_set, 8)
4148 void __thiscall basic_stringbuf_wchar_str_set(basic_stringbuf_wchar *this, const basic_string_wchar *str)
4149 {
4150     TRACE("(%p %p)\n", this, str);
4151
4152     basic_stringbuf_wchar__Tidy(this);
4153     basic_stringbuf_wchar__Init(this, basic_string_wchar_c_str(str), str->size, this->state);
4154 }
4155
4156 /* ?str@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBE?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
4157 /* ?str@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
4158 /* ?str@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
4159 /* ?str@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBA?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
4160 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_get, 8)
4161 basic_string_wchar* __thiscall basic_stringbuf_wchar_str_get(const basic_stringbuf_wchar *this, basic_string_wchar *ret)
4162 {
4163     wchar_t *ptr;
4164
4165     TRACE("(%p)\n", this);
4166
4167     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_wchar_pptr(&this->base)) {
4168         wchar_t *pptr;
4169
4170         ptr = basic_streambuf_wchar_pbase(&this->base);
4171         pptr = basic_streambuf_wchar_pptr(&this->base);
4172
4173         return basic_string_wchar_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
4174     }
4175
4176     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_wchar_gptr(&this->base)) {
4177         ptr = basic_streambuf_wchar_eback(&this->base);
4178         return basic_string_wchar_ctor_cstr_len(ret, ptr, basic_streambuf_wchar_egptr(&this->base) - ptr);
4179     }
4180
4181     return basic_string_wchar_ctor(ret);
4182 }
4183
4184 /* ??0ios_base@std@@IAE@XZ */
4185 /* ??0ios_base@std@@IEAA@XZ */
4186 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
4187 ios_base* __thiscall ios_base_ctor(ios_base *this)
4188 {
4189     TRACE("(%p)\n", this);
4190     this->vtable = &MSVCP_ios_base_vtable;
4191     return this;
4192 }
4193
4194 /* ??0ios_base@std@@QAE@ABV01@@Z */
4195 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
4196 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
4197 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
4198 {
4199     TRACE("(%p %p)\n", this, copy);
4200     *this = *copy;
4201     this->vtable = &MSVCP_ios_base_vtable;
4202     return this;
4203 }
4204
4205 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
4206 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
4207 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
4208 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
4209 {
4210     IOS_BASE_fnarray *cur;
4211
4212     TRACE("(%p %x)\n", this, event);
4213
4214     for(cur=this->calls; cur; cur=cur->next)
4215         cur->event_handler(event, this, cur->index);
4216 }
4217
4218 /* ?_Tidy@ios_base@std@@AAAXXZ */
4219 /* ?_Tidy@ios_base@std@@AEAAXXZ */
4220 void CDECL ios_base_Tidy(ios_base *this)
4221 {
4222     IOS_BASE_iosarray *arr_cur, *arr_next;
4223     IOS_BASE_fnarray *event_cur, *event_next;
4224
4225     TRACE("(%p)\n", this);
4226
4227     ios_base_Callfns(this, EVENT_erase_event);
4228
4229     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
4230         arr_next = arr_cur->next;
4231         MSVCRT_operator_delete(arr_cur);
4232     }
4233     this->arr = NULL;
4234
4235     for(event_cur=this->calls; event_cur; event_cur=event_next) {
4236         event_next = event_cur->next;
4237         MSVCRT_operator_delete(event_cur);
4238     }
4239     this->calls = NULL;
4240 }
4241
4242 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
4243 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
4244 static void ios_base_Ios_base_dtor(ios_base *obj)
4245 {
4246     TRACE("(%p)\n", obj);
4247     if(obj->loc) {
4248         locale_dtor(obj->loc);
4249         MSVCRT_operator_delete(obj->loc);
4250     }
4251     ios_base_Tidy(obj);
4252 }
4253
4254 /* ??1ios_base@std@@UAE@XZ */
4255 /* ??1ios_base@std@@UEAA@XZ */
4256 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
4257 void __thiscall ios_base_dtor(ios_base *this)
4258 {
4259     ios_base_Ios_base_dtor(this);
4260 }
4261
4262 DEFINE_THISCALL_WRAPPER(ios_base_vector_dtor, 8)
4263 ios_base* __thiscall ios_base_vector_dtor(ios_base *this, unsigned int flags)
4264 {
4265     TRACE("(%p %x)\n", this, flags);
4266     if(flags & 2) {
4267         /* we have an array, with the number of elements stored before the first object */
4268         INT_PTR i, *ptr = (INT_PTR *)this-1;
4269
4270         for(i=*ptr-1; i>=0; i--)
4271             ios_base_dtor(this+i);
4272         MSVCRT_operator_delete(ptr);
4273     } else {
4274         ios_base_dtor(this);
4275         if(flags & 1)
4276             MSVCRT_operator_delete(this);
4277     }
4278
4279     return this;
4280 }
4281
4282 DEFINE_THISCALL_WRAPPER(iosb_vector_dtor, 8)
4283 void* __thiscall iosb_vector_dtor(void *this, unsigned int flags)
4284 {
4285     TRACE("(%p %x)\n", this, flags);
4286     if(flags & 2) {
4287         INT_PTR *ptr = (INT_PTR *)this-1;
4288         MSVCRT_operator_delete(ptr);
4289     } else {
4290         if(flags & 1)
4291             MSVCRT_operator_delete(this);
4292     }
4293
4294     return this;
4295 }
4296
4297 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
4298 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
4299 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
4300 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
4301 {
4302     IOS_BASE_iosarray *p;
4303
4304     TRACE("(%p %d)\n", this, index);
4305
4306     for(p=this->arr; p; p=p->next) {
4307         if(p->index == index)
4308             return p;
4309     }
4310
4311     for(p=this->arr; p; p=p->next) {
4312         if(!p->long_val && !p->ptr_val) {
4313             p->index = index;
4314             return p;
4315         }
4316     }
4317
4318     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
4319     p->next = this->arr;
4320     p->index = index;
4321     p->long_val = 0;
4322     p->ptr_val = NULL;
4323     this->arr = p;
4324     return p;
4325 }
4326
4327 /* ?iword@ios_base@std@@QAEAAJH@Z */
4328 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
4329 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
4330 LONG* __thiscall ios_base_iword(ios_base *this, int index)
4331 {
4332     TRACE("(%p %d)\n", this, index);
4333     return &ios_base_Findarr(this, index)->long_val;
4334 }
4335
4336 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
4337 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
4338 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
4339 void** __thiscall ios_base_pword(ios_base *this, int index)
4340 {
4341     TRACE("(%p %d)\n", this, index);
4342     return &ios_base_Findarr(this, index)->ptr_val;
4343 }
4344
4345 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
4346 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
4347 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
4348 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
4349 {
4350     IOS_BASE_fnarray *event;
4351
4352     TRACE("(%p %p %d)\n", this, callback, index);
4353
4354     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
4355     event->next = this->calls;
4356     event->index = index;
4357     event->event_handler = callback;
4358     this->calls = event;
4359 }
4360
4361 /* ?clear@ios_base@std@@QAEXH_N@Z */
4362 /* ?clear@ios_base@std@@QEAAXH_N@Z */
4363 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
4364 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4365 {
4366     TRACE("(%p %x %x)\n", this, state, reraise);
4367
4368     this->state = state & IOSTATE_mask;
4369     if(!(this->state & this->except))
4370         return;
4371
4372     if(reraise)
4373         throw_exception(EXCEPTION_RERAISE, NULL);
4374     else if(this->state & this->except & IOSTATE_eofbit)
4375         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
4376     else if(this->state & this->except & IOSTATE_failbit)
4377         throw_exception(EXCEPTION_FAILURE, "failbit is set");
4378     else if(this->state & this->except & IOSTATE_badbit)
4379         throw_exception(EXCEPTION_FAILURE, "badbit is set");
4380     else if(this->state & this->except & IOSTATE__Hardfail)
4381         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
4382 }
4383
4384 /* ?clear@ios_base@std@@QAEXH@Z */
4385 /* ?clear@ios_base@std@@QEAAXH@Z */
4386 static void ios_base_clear(ios_base *this, IOSB_iostate state)
4387 {
4388     ios_base_clear_reraise(this, state, FALSE);
4389 }
4390
4391 /* ?exceptions@ios_base@std@@QAEXH@Z */
4392 /* ?exceptions@ios_base@std@@QEAAXH@Z */
4393 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
4394 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
4395 {
4396     TRACE("(%p %x)\n", this, state);
4397     this->except = state & IOSTATE_mask;
4398     ios_base_clear(this, this->state);
4399 }
4400
4401 /* ?exceptions@ios_base@std@@QBEHXZ */
4402 /* ?exceptions@ios_base@std@@QEBAHXZ */
4403 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
4404 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
4405 {
4406     TRACE("(%p)\n", this);
4407     return this->except;
4408 }
4409
4410 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
4411 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
4412 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
4413 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
4414 {
4415     TRACE("(%p %p)\n", this, rhs);
4416
4417     if(this != rhs) {
4418         IOS_BASE_iosarray *arr_cur;
4419         IOS_BASE_fnarray *event_cur;
4420
4421         ios_base_Tidy(this);
4422
4423         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
4424             if(arr_cur->long_val)
4425                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
4426             if(arr_cur->ptr_val)
4427                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
4428         }
4429         this->stdstr = rhs->stdstr;
4430         this->fmtfl = rhs->fmtfl;
4431         this->prec = rhs->prec;
4432         this->wide = rhs->wide;
4433         locale_operator_assign(this->loc, rhs->loc);
4434
4435         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
4436             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
4437
4438         ios_base_Callfns(this, EVENT_copyfmt_event);
4439         ios_base_exceptions_set(this, rhs->except);
4440     }
4441
4442     return this;
4443 }
4444
4445 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
4446 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
4447 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
4448 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
4449 {
4450     TRACE("(%p %p)\n", this, right);
4451
4452     if(this != right) {
4453         this->state = right->state;
4454         ios_base_copyfmt(this, right);
4455     }
4456
4457     return this;
4458 }
4459
4460 /* ?fail@ios_base@std@@QBE_NXZ */
4461 /* ?fail@ios_base@std@@QEBA_NXZ */
4462 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
4463 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
4464 {
4465     TRACE("(%p)\n", this);
4466     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
4467 }
4468
4469 /* ??7ios_base@std@@QBE_NXZ */
4470 /* ??7ios_base@std@@QEBA_NXZ */
4471 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
4472 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
4473 {
4474     TRACE("(%p)\n", this);
4475     return ios_base_fail(this);
4476 }
4477
4478 /* ??Bios_base@std@@QBEPAXXZ */
4479 /* ??Bios_base@std@@QEBAPEAXXZ */
4480 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
4481 void* __thiscall ios_base_op_fail(const ios_base *this)
4482 {
4483     TRACE("(%p)\n", this);
4484     return ios_base_fail(this) ? NULL : (void*)this;
4485 }
4486
4487 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
4488 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
4489 static void ios_base_Addstd(ios_base *add)
4490 {
4491     FIXME("(%p) stub\n", add);
4492 }
4493
4494 /* ?_Init@ios_base@std@@IAEXXZ */
4495 /* ?_Init@ios_base@std@@IEAAXXZ */
4496 DEFINE_THISCALL_WRAPPER(ios_base__Init, 4)
4497 void __thiscall ios_base__Init(ios_base *this)
4498 {
4499     TRACE("(%p)\n", this);
4500
4501     this->stdstr = 0;
4502     this->state = this->except = IOSTATE_goodbit;
4503     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
4504     this->prec = 6;
4505     this->wide = 0;
4506     this->arr = NULL;
4507     this->calls = NULL;
4508     this->loc = MSVCRT_operator_new(sizeof(locale));
4509     locale_ctor(this->loc);
4510 }
4511
4512 /* ?bad@ios_base@std@@QBE_NXZ */
4513 /* ?bad@ios_base@std@@QEBA_NXZ */
4514 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
4515 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
4516 {
4517     TRACE("(%p)\n", this);
4518     return (this->state & IOSTATE_badbit) != 0;
4519 }
4520
4521 /* ?eof@ios_base@std@@QBE_NXZ */
4522 /* ?eof@ios_base@std@@QEBA_NXZ */
4523 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
4524 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
4525 {
4526     TRACE("(%p)\n", this);
4527     return (this->state & IOSTATE_eofbit) != 0;
4528 }
4529
4530 /* ?flags@ios_base@std@@QAEHH@Z */
4531 /* ?flags@ios_base@std@@QEAAHH@Z */
4532 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
4533 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
4534 {
4535     IOSB_fmtflags ret = this->fmtfl;
4536
4537     TRACE("(%p %x)\n", this, flags);
4538
4539     this->fmtfl = flags & FMTFLAG_mask;
4540     return ret;
4541 }
4542
4543 /* ?flags@ios_base@std@@QBEHXZ */
4544 /* ?flags@ios_base@std@@QEBAHXZ */
4545 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
4546 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
4547 {
4548     TRACE("(%p)\n", this);
4549     return this->fmtfl;
4550 }
4551
4552 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
4553 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
4554 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
4555 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
4556 {
4557     TRACE("(%p)\n", this);
4558     return locale_copy_ctor(ret, this->loc);
4559 }
4560
4561 /* ?good@ios_base@std@@QBE_NXZ */
4562 /* ?good@ios_base@std@@QEBA_NXZ */
4563 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
4564 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
4565 {
4566     TRACE("(%p)\n", this);
4567     return this->state == IOSTATE_goodbit;
4568 }
4569
4570 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
4571 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
4572 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
4573 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
4574 {
4575     TRACE("(%p %p)\n", this, loc);
4576     *ret = *this->loc;
4577     locale_copy_ctor(this->loc, loc);
4578     return ret;
4579 }
4580
4581 /* ?precision@ios_base@std@@QAEHH@Z */
4582 /* ?precision@ios_base@std@@QEAA_J_J@Z */
4583 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
4584 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
4585 {
4586     streamsize ret = this->prec;
4587
4588     TRACE("(%p %ld)\n", this, precision);
4589
4590     this->prec = precision;
4591     return ret;
4592 }
4593
4594 /* ?precision@ios_base@std@@QBEHXZ */
4595 /* ?precision@ios_base@std@@QEBA_JXZ */
4596 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
4597 streamsize __thiscall ios_base_precision_get(const ios_base *this)
4598 {
4599     TRACE("(%p)\n", this);
4600     return this->prec;
4601 }
4602
4603 /* ?rdstate@ios_base@std@@QBEHXZ */
4604 /* ?rdstate@ios_base@std@@QEBAHXZ */
4605 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
4606 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
4607 {
4608     TRACE("(%p)\n", this);
4609     return this->state;
4610 }
4611
4612 /* ?setf@ios_base@std@@QAEHHH@Z */
4613 /* ?setf@ios_base@std@@QEAAHHH@Z */
4614 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
4615 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
4616 {
4617     IOSB_fmtflags ret = this->fmtfl;
4618
4619     TRACE("(%p %x %x)\n", this, flags, mask);
4620
4621     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
4622     return ret;
4623 }
4624
4625 /* ?setf@ios_base@std@@QAEHH@Z */
4626 /* ?setf@ios_base@std@@QEAAHH@Z */
4627 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
4628 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
4629 {
4630     return ios_base_setf_mask(this, flags, ~0);
4631 }
4632
4633 /* ?setstate@ios_base@std@@QAEXH_N@Z */
4634 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
4635 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
4636 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4637 {
4638     TRACE("(%p %x %x)\n", this, state, reraise);
4639
4640     if(state != IOSTATE_goodbit)
4641         ios_base_clear_reraise(this, this->state | state, reraise);
4642 }
4643
4644 /* ?setstate@ios_base@std@@QAEXH@Z */
4645 /* ?setstate@ios_base@std@@QEAAXH@Z */
4646 static void ios_base_setstate(ios_base *this, IOSB_iostate state)
4647 {
4648     ios_base_setstate_reraise(this, state, FALSE);
4649 }
4650
4651 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
4652 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
4653 {
4654     _Lockit lock;
4655     MSVCP_bool ret;
4656
4657     TRACE("(%x)\n", sync);
4658
4659     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4660     ret = ios_base_Sync;
4661     ios_base_Sync = sync;
4662     _Lockit_dtor(&lock);
4663     return ret;
4664 }
4665
4666 /* ?unsetf@ios_base@std@@QAEXH@Z */
4667 /* ?unsetf@ios_base@std@@QEAAXH@Z */
4668 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
4669 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
4670 {
4671     TRACE("(%p %x)\n", this, flags);
4672     this->fmtfl &= ~flags;
4673 }
4674
4675 /* ?width@ios_base@std@@QAEHH@Z */
4676 /* ?width@ios_base@std@@QEAA_J_J@Z */
4677 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
4678 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
4679 {
4680     streamsize ret = this->wide;
4681
4682     TRACE("(%p %ld)\n", this, width);
4683
4684     this->wide = width;
4685     return ret;
4686 }
4687
4688 /* ?width@ios_base@std@@QBEHXZ */
4689 /* ?width@ios_base@std@@QEBA_JXZ */
4690 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
4691 streamsize __thiscall ios_base_width_get(ios_base *this)
4692 {
4693     TRACE("(%p)\n", this);
4694     return this->wide;
4695 }
4696
4697 /* ?xalloc@ios_base@std@@SAHXZ */
4698 int CDECL ios_base_xalloc(void)
4699 {
4700     _Lockit lock;
4701     int ret;
4702
4703     TRACE("\n");
4704
4705     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4706     ret = ios_base_Index++;
4707     _Lockit_dtor(&lock);
4708     return ret;
4709 }
4710
4711 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
4712 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
4713 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
4714 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
4715 {
4716     TRACE("(%p)\n", this);
4717
4718     ios_base_ctor(&this->base);
4719     this->base.vtable = &MSVCP_basic_ios_char_vtable;
4720     return this;
4721 }
4722
4723 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4724 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4725 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
4726 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
4727 {
4728     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4729     ios_base__Init(&this->base);
4730     this->strbuf = streambuf;
4731     this->stream = NULL;
4732     this->fillch = ' ';
4733
4734     if(!streambuf)
4735         ios_base_setstate(&this->base, IOSTATE_badbit);
4736
4737     if(isstd)
4738         FIXME("standard streams not handled yet\n");
4739 }
4740
4741 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4742 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4743 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
4744 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
4745 {
4746     TRACE("(%p %p)\n", this, strbuf);
4747
4748     basic_ios_char_ctor(this);
4749     basic_ios_char_init(this, strbuf, FALSE);
4750     return this;
4751 }
4752
4753 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
4754 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4755 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
4756 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
4757 {
4758     TRACE("(%p)\n", this);
4759     ios_base_dtor(&this->base);
4760 }
4761
4762 DEFINE_THISCALL_WRAPPER(basic_ios_char_vector_dtor, 8)
4763 basic_ios_char* __thiscall basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
4764 {
4765     TRACE("(%p %x)\n", this, flags);
4766     if(flags & 2) {
4767         /* we have an array, with the number of elements stored before the first object */
4768         INT_PTR i, *ptr = (INT_PTR *)this-1;
4769
4770         for(i=*ptr-1; i>=0; i--)
4771             basic_ios_char_dtor(this+i);
4772         MSVCRT_operator_delete(ptr);
4773     } else {
4774         basic_ios_char_dtor(this);
4775         if(flags & 1)
4776             MSVCRT_operator_delete(this);
4777     }
4778
4779     return this;
4780 }
4781
4782 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4783 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4784 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
4785 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4786 {
4787     TRACE("(%p %x %x)\n", this, state, reraise);
4788     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4789 }
4790
4791 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4792 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4793 static void basic_ios_char_clear(basic_ios_char *this, unsigned int state)
4794 {
4795     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
4796 }
4797
4798 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
4799 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4800 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
4801 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
4802 {
4803     TRACE("(%p %p)\n", this, copy);
4804     if(this == copy)
4805         return this;
4806
4807     this->stream = copy->stream;
4808     this->fillch = copy->fillch;
4809     ios_base_copyfmt(&this->base, &copy->base);
4810     return this;
4811 }
4812
4813 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
4814 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
4815 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
4816 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
4817 {
4818     char ret = this->fillch;
4819
4820     TRACE("(%p %c)\n", this, fill);
4821
4822     this->fillch = fill;
4823     return ret;
4824 }
4825
4826 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
4827 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
4828 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
4829 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
4830 {
4831     TRACE("(%p)\n", this);
4832     return this->fillch;
4833 }
4834
4835 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
4836 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
4837 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
4838 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
4839 {
4840     TRACE("(%p %p %p)\n", this, ret, loc);
4841
4842     if(this->strbuf) {
4843         basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
4844         locale_dtor(ret);
4845     }
4846
4847     return ios_base_imbue(&this->base, ret, loc);
4848 }
4849
4850 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
4851 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
4852 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
4853 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
4854 {
4855     TRACE("(%p %c %c)\n", this, ch, def);
4856     return ctype_char_narrow_ch(ctype_char_use_facet(this->strbuf->loc), ch, def);
4857 }
4858
4859 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
4860 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
4861 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
4862 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
4863 {
4864     basic_streambuf_char *ret = this->strbuf;
4865
4866     TRACE("(%p %p)\n", this, streambuf);
4867
4868     this->strbuf = streambuf;
4869     basic_ios_char_clear(this, IOSTATE_goodbit);
4870     return ret;
4871 }
4872
4873 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
4874 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
4875 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
4876 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
4877 {
4878     TRACE("(%p)\n", this);
4879     return this->strbuf;
4880 }
4881
4882 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4883 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4884 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
4885 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4886 {
4887     TRACE("(%p %x %x)\n", this, state, reraise);
4888
4889     if(state != IOSTATE_goodbit)
4890         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
4891 }
4892
4893 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4894 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4895 static void basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
4896 {
4897     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
4898 }
4899
4900 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
4901 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
4902 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
4903 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
4904 {
4905     basic_ostream_char *ret = this->stream;
4906
4907     TRACE("(%p %p)\n", this, ostream);
4908
4909     this->stream = ostream;
4910     return ret;
4911 }
4912
4913 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
4914 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
4915 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
4916 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
4917 {
4918     TRACE("(%p)\n", this);
4919     return this->stream;
4920 }
4921
4922 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
4923 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
4924 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
4925 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
4926 {
4927     TRACE("(%p %c)\n", this, ch);
4928     return ctype_char_widen_ch(ctype_char_use_facet(this->strbuf->loc), ch);
4929 }
4930
4931
4932 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
4933 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
4934 static basic_ios_wchar* basic_ios_wchar_ctor(basic_ios_wchar *this)
4935 {
4936     TRACE("(%p)\n", this);
4937
4938     ios_base_ctor(&this->base);
4939     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
4940     return this;
4941 }
4942
4943 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
4944 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
4945 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
4946 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
4947 {
4948     basic_ios_wchar_ctor(this);
4949     this->base.vtable = &MSVCP_basic_ios_short_vtable;
4950     return this;
4951 }
4952
4953 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
4954 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
4955 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
4956 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
4957 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
4958 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
4959 {
4960     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4961     ios_base__Init(&this->base);
4962     this->strbuf = streambuf;
4963     this->stream = NULL;
4964     this->fillch = ' ';
4965
4966     if(!streambuf)
4967         ios_base_setstate(&this->base, IOSTATE_badbit);
4968
4969     if(isstd)
4970         FIXME("standard streams not handled yet\n");
4971 }
4972
4973 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
4974 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
4975 static basic_ios_wchar* basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
4976 {
4977     TRACE("(%p %p)\n", this, strbuf);
4978
4979     basic_ios_wchar_ctor(this);
4980     basic_ios_wchar_init(this, strbuf, FALSE);
4981     return this;
4982 }
4983
4984 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
4985 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
4986 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
4987 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
4988 {
4989     basic_ios_wchar_ctor_streambuf(this, strbuf);
4990     this->base.vtable = &MSVCP_basic_ios_short_vtable;
4991     return this;
4992 }
4993
4994 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
4995 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
4996 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
4997 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
4998 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
4999 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
5000 {
5001     TRACE("(%p)\n", this);
5002     ios_base_dtor(&this->base);
5003 }
5004
5005 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_vector_dtor, 8)
5006 basic_ios_wchar* __thiscall basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
5007 {
5008     TRACE("(%p %x)\n", this, flags);
5009     if(flags & 2) {
5010         /* we have an array, with the number of elements stored before the first object */
5011         INT_PTR i, *ptr = (INT_PTR *)this-1;
5012
5013         for(i=*ptr-1; i>=0; i--)
5014             basic_ios_wchar_dtor(this+i);
5015         MSVCRT_operator_delete(ptr);
5016     } else {
5017         basic_ios_wchar_dtor(this);
5018         if(flags & 1)
5019             MSVCRT_operator_delete(this);
5020     }
5021
5022     return this;
5023 }
5024
5025 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5026 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5027 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5028 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5029 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
5030 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5031 {
5032     TRACE("(%p %x %x)\n", this, state, reraise);
5033     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
5034 }
5035
5036 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5037 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5038 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5039 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5040 static void basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
5041 {
5042     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
5043 }
5044
5045 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
5046 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5047 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
5048 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5049 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
5050 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
5051 {
5052     TRACE("(%p %p)\n", this, copy);
5053     if(this == copy)
5054         return this;
5055
5056     this->stream = copy->stream;
5057     this->fillch = copy->fillch;
5058     ios_base_copyfmt(&this->base, &copy->base);
5059     return this;
5060 }
5061
5062 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
5063 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
5064 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
5065 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
5066 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
5067 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
5068 {
5069     wchar_t ret = this->fillch;
5070
5071     TRACE("(%p %c)\n", this, fill);
5072
5073     this->fillch = fill;
5074     return ret;
5075 }
5076
5077 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
5078 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
5079 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
5080 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
5081 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
5082 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
5083 {
5084     TRACE("(%p)\n", this);
5085     return this->fillch;
5086 }
5087
5088 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5089 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5090 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5091 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5092 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
5093 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
5094 {
5095     TRACE("(%p %p %p)\n", this, ret, loc);
5096
5097     if(this->strbuf) {
5098         basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
5099         locale_dtor(ret);
5100     }
5101
5102     return ios_base_imbue(&this->base, ret, loc);
5103 }
5104
5105 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
5106 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
5107 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
5108 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
5109 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
5110 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
5111 {
5112     TRACE("(%p %c %c)\n", this, ch, def);
5113     return ctype_wchar_narrow_ch(ctype_wchar_use_facet(this->strbuf->loc), ch, def);
5114 }
5115
5116 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5117 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5118 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
5119 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5120 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
5121 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
5122 {
5123     basic_streambuf_wchar *ret = this->strbuf;
5124
5125     TRACE("(%p %p)\n", this, streambuf);
5126
5127     this->strbuf = streambuf;
5128     basic_ios_wchar_clear(this, IOSTATE_goodbit);
5129     return ret;
5130 }
5131
5132 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5133 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5134 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5135 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5136 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
5137 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
5138 {
5139     TRACE("(%p)\n", this);
5140     return this->strbuf;
5141 }
5142
5143 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5144 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5145 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5146 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5147 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
5148 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5149 {
5150     TRACE("(%p %x %x)\n", this, state, reraise);
5151
5152     if(state != IOSTATE_goodbit)
5153         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
5154 }
5155
5156 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5157 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5158 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5159 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5160 static void basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
5161 {
5162     basic_ios_wchar_setstate_reraise(this, state, FALSE);
5163 }
5164
5165 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5166 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5167 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
5168 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5169 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
5170 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
5171 {
5172     basic_ostream_wchar *ret = this->stream;
5173
5174     TRACE("(%p %p)\n", this, ostream);
5175
5176     this->stream = ostream;
5177     return ret;
5178 }
5179
5180 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5181 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5182 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5183 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5184 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
5185 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
5186 {
5187     TRACE("(%p)\n", this);
5188     return this->stream;
5189 }
5190
5191 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
5192 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
5193 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
5194 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
5195 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
5196 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
5197 {
5198     TRACE("(%p %c)\n", this, ch);
5199     return ctype_wchar_widen_ch(ctype_wchar_use_facet(this->strbuf->loc), ch);
5200 }
5201
5202 /* Caution: basic_ostream uses virtual inheritance.
5203  * All constructors have additional parameter that says if base class should be initialized.
5204  * Base class needs to be accessed using vbtable.
5205  */
5206 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
5207 {
5208     return (basic_ios_char*)((char*)this+this->vbtable[1]);
5209 }
5210
5211 static inline basic_ios_char* basic_ostream_char_to_basic_ios(basic_ostream_char *ptr)
5212 {
5213     return (basic_ios_char*)((char*)ptr+basic_ostream_char_vbtable[1]);
5214 }
5215
5216 static inline basic_ostream_char* basic_ostream_char_from_basic_ios(basic_ios_char *ptr)
5217 {
5218     return (basic_ostream_char*)((char*)ptr-basic_ostream_char_vbtable[1]);
5219 }
5220
5221 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5222 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5223 static basic_ostream_char* basic_ostream_char_ctor(basic_ostream_char *this,
5224         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5225 {
5226     basic_ios_char *base;
5227
5228     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5229
5230     if(virt_init) {
5231         this->vbtable = basic_ostream_char_vbtable;
5232         base = basic_ostream_char_get_basic_ios(this);
5233         basic_ios_char_ctor(base);
5234     }else {
5235         base = basic_ostream_char_get_basic_ios(this);
5236     }
5237
5238     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5239     basic_ios_char_init(base, strbuf, isstd);
5240     return this;
5241 }
5242
5243 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5244 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5245 static basic_ostream_char* basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
5246         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5247 {
5248     basic_ios_char *base;
5249
5250     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5251
5252     if(virt_init) {
5253         this->vbtable = basic_ostream_char_vbtable;
5254         base = basic_ostream_char_get_basic_ios(this);
5255         basic_ios_char_ctor(base);
5256     }else {
5257         base = basic_ostream_char_get_basic_ios(this);
5258     }
5259
5260     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5261     if(addstd)
5262         ios_base_Addstd(&base->base);
5263     return this;
5264 }
5265
5266 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5267 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5268 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
5269 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
5270 {
5271     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5272
5273     /* don't destroy virtual base here */
5274     TRACE("(%p)\n", this);
5275 }
5276
5277 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5278 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5279 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
5280 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
5281 {
5282     TRACE("(%p)\n", this);
5283     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
5284     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
5285 }
5286
5287 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
5288 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5289 {
5290     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5291
5292     TRACE("(%p %x)\n", this, flags);
5293
5294     if(flags & 2) {
5295         /* we have an array, with the number of elements stored before the first object */
5296         INT_PTR i, *ptr = (INT_PTR *)this-1;
5297
5298         for(i=*ptr-1; i>=0; i--)
5299             basic_ostream_char_vbase_dtor(this+i);
5300         MSVCRT_operator_delete(ptr);
5301     } else {
5302         basic_ostream_char_vbase_dtor(this);
5303         if(flags & 1)
5304             MSVCRT_operator_delete(this);
5305     }
5306
5307     return this;
5308 }
5309
5310 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5311 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5312 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
5313 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
5314 {
5315     /* this function is not matching C++ specification */
5316     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5317
5318     TRACE("(%p)\n", this);
5319
5320     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
5321             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
5322         basic_ios_char_setstate(base, IOSTATE_badbit);
5323     return this;
5324 }
5325
5326 /* ?flush@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5327 /* ?flush@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5328 basic_ostream_char* __cdecl flush_ostream_char(basic_ostream_char *ostream)
5329 {
5330     return basic_ostream_char_flush(ostream);
5331 }
5332
5333 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5334 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5335 static void basic_ostream_char__Osfx(basic_ostream_char *this)
5336 {
5337     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5338
5339     TRACE("(%p)\n", this);
5340
5341     if(base->base.fmtfl & FMTFLAG_unitbuf)
5342         basic_ostream_char_flush(this);
5343 }
5344
5345 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5346 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5347 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
5348 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
5349 {
5350     TRACE("(%p)\n", this);
5351     basic_ostream_char__Osfx(this);
5352 }
5353
5354 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
5355 {
5356     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5357
5358     if(basic_ios_char_rdbuf_get(base))
5359         basic_streambuf_char__Lock(base->strbuf);
5360
5361     if(ios_base_good(&base->base) && base->stream)
5362         basic_ostream_char_flush(base->stream);
5363
5364     return ios_base_good(&base->base);
5365 }
5366
5367 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
5368 {
5369     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5370
5371     if(ios_base_good(&base->base) && !__uncaught_exception())
5372         basic_ostream_char_osfx(ostr);
5373
5374     if(basic_ios_char_rdbuf_get(base))
5375         basic_streambuf_char__Unlock(base->strbuf);
5376 }
5377
5378 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
5379 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
5380 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
5381 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
5382 {
5383     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5384
5385     TRACE("(%p)\n", this);
5386
5387     if(ios_base_good(&base->base) && base->stream)
5388         basic_ostream_char_flush(base->stream);
5389     return ios_base_good(&base->base);
5390 }
5391
5392 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5393 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5394 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
5395 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
5396 {
5397     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5398
5399     TRACE("(%p %c)\n", this, ch);
5400
5401     if(!basic_ostream_char_sentry_create(this)
5402             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
5403         basic_ostream_char_sentry_destroy(this);
5404         basic_ios_char_setstate(base, IOSTATE_badbit);
5405         return this;
5406     }
5407
5408     basic_ostream_char_sentry_destroy(this);
5409     return this;
5410 }
5411
5412 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
5413 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
5414 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
5415 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
5416 {
5417     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5418
5419     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
5420
5421     if(!ios_base_fail(&base->base)) {
5422         fpos_int seek;
5423
5424         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
5425                 &seek, pos, OPENMODE_out);
5426         if(seek.off==-1 && seek.pos==0 && seek.state==0)
5427             basic_ios_char_setstate(base, IOSTATE_failbit);
5428     }
5429     return this;
5430 }
5431
5432 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
5433 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
5434 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
5435 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
5436 {
5437     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5438
5439     TRACE("(%p)\n", this);
5440
5441     if(!ios_base_fail(&base->base)) {
5442         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5443                 ret, 0, SEEKDIR_cur, OPENMODE_out);
5444     }else {
5445         ret->off = -1;
5446         ret->pos = 0;
5447         ret->state = 0;
5448     }
5449     return ret;
5450 }
5451
5452 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
5453 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
5454 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
5455 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
5456 {
5457     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5458
5459     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
5460
5461     if(!basic_ostream_char_sentry_create(this)
5462             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
5463         basic_ostream_char_sentry_destroy(this);
5464         basic_ios_char_setstate(base, IOSTATE_badbit);
5465         return this;
5466     }
5467
5468     basic_ostream_char_sentry_destroy(this);
5469     return this;
5470 }
5471
5472 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
5473 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
5474 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
5475 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
5476 {
5477     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5478     int state = IOSTATE_goodbit;
5479
5480     TRACE("(%p %d)\n", this, val);
5481
5482     if(basic_ostream_char_sentry_create(this)) {
5483         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5484         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5485         ostreambuf_iterator_char dest = {0, strbuf};
5486
5487         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
5488                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
5489                 ? (LONG)((unsigned short)val) : (LONG)val);
5490     }
5491     basic_ostream_char_sentry_destroy(this);
5492
5493     basic_ios_char_setstate(base, state);
5494     return this;
5495 }
5496
5497 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
5498 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
5499 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
5500 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
5501 {
5502     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5503     int state = IOSTATE_goodbit;
5504
5505     TRACE("(%p %u)\n", this, val);
5506
5507     if(basic_ostream_char_sentry_create(this)) {
5508         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5509         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5510         ostreambuf_iterator_char dest = {0, strbuf};
5511
5512         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5513     }
5514     basic_ostream_char_sentry_destroy(this);
5515
5516     basic_ios_char_setstate(base, state);
5517     return this;
5518 }
5519
5520 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
5521 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
5522 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
5523 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
5524 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
5525 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
5526 {
5527     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5528     int state = IOSTATE_goodbit;
5529
5530     TRACE("(%p %d)\n", this, val);
5531
5532     if(basic_ostream_char_sentry_create(this)) {
5533         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5534         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5535         ostreambuf_iterator_char dest = {0, strbuf};
5536
5537         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5538     }
5539     basic_ostream_char_sentry_destroy(this);
5540
5541     basic_ios_char_setstate(base, state);
5542     return this;
5543 }
5544
5545 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
5546 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
5547 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
5548 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
5549 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
5550 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
5551 {
5552     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5553     int state = IOSTATE_goodbit;
5554
5555     TRACE("(%p %u)\n", this, val);
5556
5557     if(basic_ostream_char_sentry_create(this)) {
5558         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5559         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5560         ostreambuf_iterator_char dest = {0, strbuf};
5561
5562         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5563     }
5564     basic_ostream_char_sentry_destroy(this);
5565
5566     basic_ios_char_setstate(base, state);
5567     return this;
5568 }
5569
5570 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
5571 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
5572 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
5573 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
5574 {
5575     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5576     int state = IOSTATE_goodbit;
5577
5578     TRACE("(%p %f)\n", this, val);
5579
5580     if(basic_ostream_char_sentry_create(this)) {
5581         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5582         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5583         ostreambuf_iterator_char dest = {0, strbuf};
5584
5585         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5586     }
5587     basic_ostream_char_sentry_destroy(this);
5588
5589     basic_ios_char_setstate(base, state);
5590     return this;
5591 }
5592
5593 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
5594 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
5595 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
5596 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
5597 {
5598     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5599     int state = IOSTATE_goodbit;
5600
5601     TRACE("(%p %lf)\n", this, val);
5602
5603     if(basic_ostream_char_sentry_create(this)) {
5604         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5605         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5606         ostreambuf_iterator_char dest = {0, strbuf};
5607
5608         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5609     }
5610     basic_ostream_char_sentry_destroy(this);
5611
5612     basic_ios_char_setstate(base, state);
5613     return this;
5614 }
5615
5616 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
5617 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
5618 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
5619 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
5620 {
5621     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5622     int state = IOSTATE_goodbit;
5623
5624     TRACE("(%p %lf)\n", this, val);
5625
5626     if(basic_ostream_char_sentry_create(this)) {
5627         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5628         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5629         ostreambuf_iterator_char dest = {0, strbuf};
5630
5631         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5632     }
5633     basic_ostream_char_sentry_destroy(this);
5634
5635     basic_ios_char_setstate(base, state);
5636     return this;
5637 }
5638
5639 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5640 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5641 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
5642 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
5643 {
5644     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5645     IOSB_iostate state = IOSTATE_badbit;
5646     int c = '\n';
5647
5648     TRACE("(%p %p)\n", this, val);
5649
5650     if(basic_ostream_char_sentry_create(this)) {
5651         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
5652                 c = basic_streambuf_char_snextc(val)) {
5653             state = IOSTATE_goodbit;
5654
5655             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
5656                 state = IOSTATE_badbit;
5657                 break;
5658             }
5659         }
5660     }else {
5661         state = IOSTATE_badbit;
5662     }
5663     basic_ostream_char_sentry_destroy(this);
5664
5665     ios_base_width_set(&base->base, 0);
5666     basic_ios_char_setstate(base, state);
5667     return this;
5668 }
5669
5670 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
5671 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
5672 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
5673 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
5674 {
5675     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5676     int state = IOSTATE_goodbit;
5677
5678     TRACE("(%p %p)\n", this, val);
5679
5680     if(basic_ostream_char_sentry_create(this)) {
5681         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5682         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5683         ostreambuf_iterator_char dest = {0, strbuf};
5684
5685         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5686     }
5687     basic_ostream_char_sentry_destroy(this);
5688
5689     basic_ios_char_setstate(base, state);
5690     return this;
5691 }
5692
5693 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
5694 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
5695 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
5696 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
5697 {
5698     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5699     int state = IOSTATE_goodbit;
5700
5701     TRACE("(%p)\n", this);
5702
5703     if(basic_ostream_char_sentry_create(this)) {
5704         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5705         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5706         ostreambuf_iterator_char dest = {0, strbuf};
5707
5708         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5709     }
5710     basic_ostream_char_sentry_destroy(this);
5711
5712     basic_ios_char_setstate(base, state);
5713     return this;
5714 }
5715
5716 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
5717 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
5718 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
5719 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
5720 {
5721     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5722     int state = IOSTATE_goodbit;
5723
5724     TRACE("(%p)\n", this);
5725
5726     if(basic_ostream_char_sentry_create(this)) {
5727         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5728         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5729         ostreambuf_iterator_char dest = {0, strbuf};
5730
5731         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5732     }
5733     basic_ostream_char_sentry_destroy(this);
5734
5735     basic_ios_char_setstate(base, state);
5736     return this;
5737 }
5738
5739 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
5740 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
5741 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
5742 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
5743 {
5744     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5745     int state = IOSTATE_goodbit;
5746
5747     TRACE("(%p %x)\n", this, val);
5748
5749     if(basic_ostream_char_sentry_create(this)) {
5750         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5751         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5752         ostreambuf_iterator_char dest = {0, strbuf};
5753
5754         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5755     }
5756     basic_ostream_char_sentry_destroy(this);
5757
5758     basic_ios_char_setstate(base, state);
5759     return this;
5760 }
5761
5762 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5763 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5764 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
5765 {
5766     TRACE("(%p)\n", ostr);
5767
5768     basic_ostream_char_put(ostr, '\n');
5769     basic_ostream_char_flush(ostr);
5770     return ostr;
5771 }
5772
5773 /* $?6DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
5774 /* ??$?6DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
5775 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
5776 {
5777     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5778     IOSB_iostate state = IOSTATE_goodbit;
5779
5780     TRACE("(%p %p)\n", ostr, str);
5781
5782     if(basic_ostream_char_sentry_create(ostr)) {
5783         MSVCP_size_t len = basic_string_char_length(str);
5784         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5785
5786         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5787             for(; pad!=0; pad--) {
5788                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5789                     state = IOSTATE_badbit;
5790                     break;
5791                 }
5792             }
5793         }
5794
5795         if(state == IOSTATE_goodbit) {
5796             if(basic_streambuf_char_sputn(base->strbuf, basic_string_char_c_str(str), len) != len)
5797                     state = IOSTATE_badbit;
5798         }
5799
5800         if(state == IOSTATE_goodbit) {
5801             for(; pad!=0; pad--) {
5802                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5803                     state = IOSTATE_badbit;
5804                     break;
5805                 }
5806             }
5807         }
5808
5809         base->base.wide = 0;
5810     }else {
5811         state = IOSTATE_badbit;
5812     }
5813     basic_ostream_char_sentry_destroy(ostr);
5814
5815     basic_ios_char_setstate(base, state);
5816     return ostr;
5817 }
5818
5819 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@C@Z */
5820 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@C@Z */
5821 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z */
5822 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z */
5823 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@E@Z */
5824 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@E@Z */
5825 basic_ostream_char* __cdecl basic_ostream_char_print_ch(basic_ostream_char *ostr, char ch)
5826 {
5827     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5828     IOSB_iostate state = IOSTATE_goodbit;
5829
5830     TRACE("(%p %d)\n", ostr, ch);
5831
5832     if(basic_ostream_char_sentry_create(ostr)) {
5833         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
5834
5835         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5836             for(; pad!=0; pad--) {
5837                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5838                     state = IOSTATE_badbit;
5839                     break;
5840                 }
5841             }
5842         }
5843
5844         if(state == IOSTATE_goodbit) {
5845             if(basic_streambuf_char_sputc(base->strbuf, ch) == EOF)
5846                 state = IOSTATE_badbit;
5847         }
5848
5849         if(state == IOSTATE_goodbit) {
5850             for(; pad!=0; pad--) {
5851                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5852                     state = IOSTATE_badbit;
5853                     break;
5854                 }
5855             }
5856         }
5857
5858         base->base.wide = 0;
5859     }else {
5860         state = IOSTATE_badbit;
5861     }
5862     basic_ostream_char_sentry_destroy(ostr);
5863
5864     basic_ios_char_setstate(base, state);
5865     return ostr;
5866 }
5867
5868 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBC@Z */
5869 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBC@Z */
5870 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z */
5871 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z */
5872 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBE@Z */
5873 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBE@Z */
5874 basic_ostream_char* __cdecl basic_ostream_char_print_str(basic_ostream_char *ostr, const char *str)
5875 {
5876     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5877     IOSB_iostate state = IOSTATE_goodbit;
5878
5879     TRACE("(%p %s)\n", ostr, str);
5880
5881     if(basic_ostream_char_sentry_create(ostr)) {
5882         MSVCP_size_t len = strlen(str);
5883         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5884
5885         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5886             for(; pad!=0; pad--) {
5887                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5888                     state = IOSTATE_badbit;
5889                     break;
5890                 }
5891             }
5892         }
5893
5894         if(state == IOSTATE_goodbit) {
5895             if(basic_streambuf_char_sputn(base->strbuf, str, len) != len)
5896                 state = IOSTATE_badbit;
5897         }
5898
5899         if(state == IOSTATE_goodbit) {
5900             for(; pad!=0; pad--) {
5901                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5902                     state = IOSTATE_badbit;
5903                     break;
5904                 }
5905             }
5906         }
5907
5908         base->base.wide = 0;
5909     }else {
5910         state = IOSTATE_badbit;
5911     }
5912     basic_ostream_char_sentry_destroy(ostr);
5913
5914     basic_ios_char_setstate(base, state);
5915     return ostr;
5916 }
5917
5918 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
5919 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
5920 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
5921 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
5922         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
5923 {
5924     TRACE("(%p %p)\n", this, pfunc);
5925     pfunc(this);
5926     return this;
5927 }
5928
5929 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
5930 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
5931 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
5932 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
5933         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
5934 {
5935     TRACE("(%p %p)\n", this, pfunc);
5936     pfunc(basic_ostream_char_get_basic_ios(this));
5937     return this;
5938 }
5939
5940 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
5941 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
5942 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
5943 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
5944         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
5945 {
5946     TRACE("(%p %p)\n", this, pfunc);
5947     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
5948     return this;
5949 }
5950
5951 /* Caution: basic_ostream uses virtual inheritance. */
5952 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
5953 {
5954     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
5955 }
5956
5957 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
5958 {
5959     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
5960 }
5961
5962 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
5963 {
5964     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
5965 }
5966
5967 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
5968 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
5969 static basic_ostream_wchar* basic_ostream_wchar_ctor(basic_ostream_wchar *this,
5970         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5971 {
5972     basic_ios_wchar *base;
5973
5974     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5975
5976     if(virt_init) {
5977         this->vbtable = basic_ostream_wchar_vbtable;
5978         base = basic_ostream_wchar_get_basic_ios(this);
5979         basic_ios_wchar_ctor(base);
5980     }else {
5981         base = basic_ostream_wchar_get_basic_ios(this);
5982     }
5983
5984     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
5985     basic_ios_wchar_init(base, strbuf, isstd);
5986     return this;
5987 }
5988
5989 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
5990 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
5991 static basic_ostream_wchar* basic_ostream_short_ctor(basic_ostream_wchar *this,
5992         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5993 {
5994     basic_ostream_wchar_ctor(this, strbuf, isstd, virt_init);
5995     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
5996     return this;
5997 }
5998
5999 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
6000 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
6001 static basic_ostream_wchar* basic_ostream_wchar_ctor_uninitialized(basic_ostream_wchar *this,
6002         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
6003 {
6004     basic_ios_wchar *base;
6005
6006     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
6007
6008     if(virt_init) {
6009         this->vbtable = basic_ostream_wchar_vbtable;
6010         base = basic_ostream_wchar_get_basic_ios(this);
6011         basic_ios_wchar_ctor(base);
6012     }else {
6013         base = basic_ostream_wchar_get_basic_ios(this);
6014     }
6015
6016     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6017     if(addstd)
6018         ios_base_Addstd(&base->base);
6019     return this;
6020 }
6021
6022 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
6023 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
6024 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
6025 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
6026 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
6027 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
6028 {
6029     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6030
6031     /* don't destroy virtual base here */
6032     TRACE("(%p)\n", this);
6033 }
6034
6035 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6036 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6037 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6038 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6039 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
6040 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
6041 {
6042     TRACE("(%p)\n", this);
6043     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
6044     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
6045 }
6046
6047 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
6048 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
6049 {
6050     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6051
6052     TRACE("(%p %x)\n", this, flags);
6053
6054     if(flags & 2) {
6055         /* we have an array, with the number of elements stored before the first object */
6056         INT_PTR i, *ptr = (INT_PTR *)this-1;
6057
6058         for(i=*ptr-1; i>=0; i--)
6059             basic_ostream_wchar_vbase_dtor(this+i);
6060         MSVCRT_operator_delete(ptr);
6061     } else {
6062         basic_ostream_wchar_vbase_dtor(this);
6063         if(flags & 1)
6064             MSVCRT_operator_delete(this);
6065     }
6066
6067     return this;
6068 }
6069
6070 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
6071 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
6072 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
6073 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
6074 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
6075 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
6076 {
6077     /* this function is not matching C++ specification */
6078     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6079
6080     TRACE("(%p)\n", this);
6081
6082     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
6083             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
6084         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6085     return this;
6086 }
6087
6088 /* ?flush@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6089 /* ?flush@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6090 /* ?flush@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6091 /* ?flush@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6092 basic_ostream_wchar* __cdecl flush_ostream_wchar(basic_ostream_wchar *ostream)
6093 {
6094     return basic_ostream_wchar_flush(ostream);
6095 }
6096
6097 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6098 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6099 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6100 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6101 static void basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
6102 {
6103     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6104
6105     TRACE("(%p)\n", this);
6106
6107     if(base->base.fmtfl & FMTFLAG_unitbuf)
6108         basic_ostream_wchar_flush(this);
6109 }
6110
6111 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6112 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6113 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6114 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6115 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
6116 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
6117 {
6118     TRACE("(%p)\n", this);
6119     basic_ostream_wchar__Osfx(this);
6120 }
6121
6122 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
6123 {
6124     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6125
6126     if(basic_ios_wchar_rdbuf_get(base))
6127         basic_streambuf_wchar__Lock(base->strbuf);
6128
6129     if(ios_base_good(&base->base) && base->stream)
6130         basic_ostream_wchar_flush(base->stream);
6131
6132     return ios_base_good(&base->base);
6133 }
6134
6135 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
6136 {
6137     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6138
6139     if(ios_base_good(&base->base) && !__uncaught_exception())
6140         basic_ostream_wchar_osfx(ostr);
6141
6142     if(basic_ios_wchar_rdbuf_get(base))
6143         basic_streambuf_wchar__Unlock(base->strbuf);
6144 }
6145
6146 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
6147 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
6148 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
6149 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
6150 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
6151 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
6152 {
6153     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6154
6155     TRACE("(%p)\n", this);
6156
6157     if(ios_base_good(&base->base) && base->stream)
6158         basic_ostream_wchar_flush(base->stream);
6159     return ios_base_good(&base->base);
6160 }
6161
6162 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
6163 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
6164 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
6165 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
6166 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
6167 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
6168 {
6169     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6170
6171     TRACE("(%p %c)\n", this, ch);
6172
6173     if(!basic_ostream_wchar_sentry_create(this)
6174             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
6175         basic_ostream_wchar_sentry_destroy(this);
6176         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6177         return this;
6178     }
6179
6180     basic_ostream_wchar_sentry_destroy(this);
6181     return this;
6182 }
6183
6184 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6185 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6186 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6187 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6188 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
6189 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
6190 {
6191     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6192
6193     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6194
6195     if(!ios_base_fail(&base->base)) {
6196         fpos_int seek;
6197
6198         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
6199                 &seek, pos, OPENMODE_out);
6200         if(seek.off==-1 && seek.pos==0 && seek.state==0)
6201             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6202     }
6203     return this;
6204 }
6205
6206 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6207 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6208 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6209 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6210 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
6211 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
6212 {
6213     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6214
6215     TRACE("(%p)\n", this);
6216
6217     if(!ios_base_fail(&base->base)) {
6218         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6219                 ret, 0, SEEKDIR_cur, OPENMODE_out);
6220     }else {
6221         ret->off = -1;
6222         ret->pos = 0;
6223         ret->state = 0;
6224     }
6225     return ret;
6226 }
6227
6228 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
6229 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
6230 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
6231 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
6232 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 12)
6233 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
6234 {
6235     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6236
6237     TRACE("(%p %s %ld)\n", this, debugstr_w(str), count);
6238
6239     if(!basic_ostream_wchar_sentry_create(this)
6240             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
6241         basic_ostream_wchar_sentry_destroy(this);
6242         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6243         return this;
6244     }
6245
6246     basic_ostream_wchar_sentry_destroy(this);
6247     return this;
6248 }
6249
6250 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
6251 {
6252     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6253     int state = IOSTATE_goodbit;
6254
6255     TRACE("(%p %d)\n", this, val);
6256
6257     if(basic_ostream_wchar_sentry_create(this)) {
6258         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6259         ostreambuf_iterator_wchar dest = {0, strbuf};
6260
6261         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
6262                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
6263                 ? (LONG)((unsigned short)val) : (LONG)val);
6264     }
6265     basic_ostream_wchar_sentry_destroy(this);
6266
6267     basic_ios_wchar_setstate(base, state);
6268     return this;
6269 }
6270
6271 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
6272 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
6273 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
6274 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
6275 {
6276     return basic_ostream_print_short(this, val, num_put_short_use_facet(
6277                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6278 }
6279
6280 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
6281 {
6282     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6283     int state = IOSTATE_goodbit;
6284
6285     TRACE("(%p %d)\n", this, val);
6286
6287     if(basic_ostream_wchar_sentry_create(this)) {
6288         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6289         ostreambuf_iterator_wchar dest = {0, strbuf};
6290
6291         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6292     }
6293     basic_ostream_wchar_sentry_destroy(this);
6294
6295     basic_ios_wchar_setstate(base, state);
6296     return this;
6297 }
6298
6299 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
6300 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
6301 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
6302 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
6303 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
6304 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
6305 {
6306     return basic_ostream_print_int(this, val, num_put_short_use_facet(
6307                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6308 }
6309
6310 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
6311 {
6312     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6313     int state = IOSTATE_goodbit;
6314
6315     TRACE("(%p %u)\n", this, val);
6316
6317     if(basic_ostream_wchar_sentry_create(this)) {
6318         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6319         ostreambuf_iterator_wchar dest = {0, strbuf};
6320
6321         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6322     }
6323     basic_ostream_wchar_sentry_destroy(this);
6324
6325     basic_ios_wchar_setstate(base, state);
6326     return this;
6327 }
6328
6329 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
6330 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
6331 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
6332 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
6333 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
6334 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
6335 {
6336     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
6337                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6338 }
6339
6340 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
6341 {
6342     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6343     int state = IOSTATE_goodbit;
6344
6345     TRACE("(%p %f)\n", this, val);
6346
6347     if(basic_ostream_wchar_sentry_create(this)) {
6348         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6349         ostreambuf_iterator_wchar dest = {0, strbuf};
6350
6351         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6352     }
6353     basic_ostream_wchar_sentry_destroy(this);
6354
6355     basic_ios_wchar_setstate(base, state);
6356     return this;
6357 }
6358
6359 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
6360 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
6361 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
6362 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
6363 {
6364     return basic_ostream_print_float(this, val, num_put_short_use_facet(
6365                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6366 }
6367
6368 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
6369 {
6370     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6371     int state = IOSTATE_goodbit;
6372
6373     TRACE("(%p %lf)\n", this, val);
6374
6375     if(basic_ostream_wchar_sentry_create(this)) {
6376         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6377         ostreambuf_iterator_wchar dest = {0, strbuf};
6378
6379         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6380     }
6381     basic_ostream_wchar_sentry_destroy(this);
6382
6383     basic_ios_wchar_setstate(base, state);
6384     return this;
6385 }
6386
6387 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
6388 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
6389 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
6390 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
6391 {
6392     return basic_ostream_print_double(this, val, num_put_short_use_facet(
6393                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6394 }
6395
6396 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
6397 {
6398     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6399     int state = IOSTATE_goodbit;
6400
6401     TRACE("(%p %lf)\n", this, val);
6402
6403     if(basic_ostream_wchar_sentry_create(this)) {
6404         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6405         ostreambuf_iterator_wchar dest = {0, strbuf};
6406
6407         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6408     }
6409     basic_ostream_wchar_sentry_destroy(this);
6410
6411     basic_ios_wchar_setstate(base, state);
6412     return this;
6413 }
6414
6415 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
6416 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
6417 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
6418 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
6419 {
6420     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
6421                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6422 }
6423
6424 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6425 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6426 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6427 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6428 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
6429 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
6430 {
6431     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6432     IOSB_iostate state = IOSTATE_badbit;
6433     unsigned short c = '\n';
6434
6435     TRACE("(%p %p)\n", this, val);
6436
6437     if(basic_ostream_wchar_sentry_create(this)) {
6438         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
6439                 c = basic_streambuf_wchar_snextc(val)) {
6440             state = IOSTATE_goodbit;
6441
6442             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
6443                 state = IOSTATE_badbit;
6444                 break;
6445             }
6446         }
6447     }else {
6448         state = IOSTATE_badbit;
6449     }
6450     basic_ostream_wchar_sentry_destroy(this);
6451
6452     ios_base_width_set(&base->base, 0);
6453     basic_ios_wchar_setstate(base, state);
6454     return this;
6455 }
6456
6457 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
6458 {
6459     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6460     int state = IOSTATE_goodbit;
6461
6462     TRACE("(%p %p)\n", this, val);
6463
6464     if(basic_ostream_wchar_sentry_create(this)) {
6465         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6466         ostreambuf_iterator_wchar dest = {0, strbuf};
6467
6468         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6469     }
6470     basic_ostream_wchar_sentry_destroy(this);
6471
6472     basic_ios_wchar_setstate(base, state);
6473     return this;
6474 }
6475
6476 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
6477 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
6478 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
6479 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
6480 {
6481     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
6482                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6483 }
6484
6485 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
6486 {
6487     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6488     int state = IOSTATE_goodbit;
6489
6490     TRACE("(%p)\n", this);
6491
6492     if(basic_ostream_wchar_sentry_create(this)) {
6493         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6494         ostreambuf_iterator_wchar dest = {0, strbuf};
6495
6496         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6497     }
6498     basic_ostream_wchar_sentry_destroy(this);
6499
6500     basic_ios_wchar_setstate(base, state);
6501     return this;
6502 }
6503
6504 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
6505 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
6506 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
6507 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
6508 {
6509     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
6510                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6511 }
6512
6513 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
6514 {
6515     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6516     int state = IOSTATE_goodbit;
6517
6518     TRACE("(%p)\n", this);
6519
6520     if(basic_ostream_wchar_sentry_create(this)) {
6521         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6522         ostreambuf_iterator_wchar dest = {0, strbuf};
6523
6524         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6525     }
6526     basic_ostream_wchar_sentry_destroy(this);
6527
6528     basic_ios_wchar_setstate(base, state);
6529     return this;
6530 }
6531
6532 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
6533 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
6534 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
6535 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6536 {
6537     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
6538                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6539 }
6540
6541 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
6542 {
6543     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6544     int state = IOSTATE_goodbit;
6545
6546     TRACE("(%p %x)\n", this, val);
6547
6548     if(basic_ostream_wchar_sentry_create(this)) {
6549         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6550         ostreambuf_iterator_wchar dest = {0, strbuf};
6551
6552         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6553     }
6554     basic_ostream_wchar_sentry_destroy(this);
6555
6556     basic_ios_wchar_setstate(base, state);
6557     return this;
6558 }
6559
6560 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
6561 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
6562 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
6563 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6564 {
6565     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
6566                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6567 }
6568
6569 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6570 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6571 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6572 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6573 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
6574 {
6575     TRACE("(%p)\n", ostr);
6576
6577     basic_ostream_wchar_put(ostr, '\n');
6578     basic_ostream_wchar_flush(ostr);
6579     return ostr;
6580 }
6581
6582 /* ??$?6_WU?$char_traits@_W@std@@V?$allocator@_W@1@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@@Z */
6583 /* ??$?6_WU?$char_traits@_W@std@@V?$allocator@_W@1@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@AEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@@Z */
6584 /* ??$?6GU?$char_traits@G@std@@V?$allocator@G@1@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@@Z */
6585 /* ??$?6GU?$char_traits@G@std@@V?$allocator@G@1@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@AEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@@Z */
6586 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_bstr(basic_ostream_wchar *ostr, const basic_string_wchar *str)
6587 {
6588     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6589     IOSB_iostate state = IOSTATE_goodbit;
6590
6591     TRACE("(%p %p)\n", ostr, str);
6592
6593     if(basic_ostream_wchar_sentry_create(ostr)) {
6594         MSVCP_size_t len = basic_string_wchar_length(str);
6595         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6596
6597         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6598             for(; pad!=0; pad--) {
6599                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6600                     state = IOSTATE_badbit;
6601                     break;
6602                 }
6603             }
6604         }
6605
6606         if(state == IOSTATE_goodbit) {
6607             if(basic_streambuf_wchar_sputn(base->strbuf, basic_string_wchar_c_str(str), len) != len)
6608                 state = IOSTATE_badbit;
6609         }
6610
6611         if(state == IOSTATE_goodbit) {
6612             for(; pad!=0; pad--) {
6613                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6614                     state = IOSTATE_badbit;
6615                     break;
6616                 }
6617             }
6618         }
6619
6620         base->base.wide = 0;
6621     }else {
6622         state = IOSTATE_badbit;
6623     }
6624     basic_ostream_wchar_sentry_destroy(ostr);
6625
6626     basic_ios_wchar_setstate(base, state);
6627     return ostr;
6628 }
6629
6630 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@_W@Z */
6631 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@_W@Z */
6632 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@G@Z */
6633 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@G@Z */
6634 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_ch(basic_ostream_wchar *ostr, wchar_t ch)
6635 {
6636     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6637     IOSB_iostate state = IOSTATE_goodbit;
6638
6639     TRACE("(%p %d)\n", ostr, ch);
6640
6641     if(basic_ostream_wchar_sentry_create(ostr)) {
6642         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6643
6644         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6645             for(; pad!=0; pad--) {
6646                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6647                     state = IOSTATE_badbit;
6648                     break;
6649                 }
6650             }
6651         }
6652
6653         if(state == IOSTATE_goodbit) {
6654             if(basic_streambuf_wchar_sputc(base->strbuf, ch) == WEOF)
6655                 state = IOSTATE_badbit;
6656         }
6657
6658         if(state == IOSTATE_goodbit) {
6659             for(; pad!=0; pad--) {
6660                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6661                     state = IOSTATE_badbit;
6662                     break;
6663                 }
6664             }
6665         }
6666
6667         base->base.wide = 0;
6668     }else {
6669         state = IOSTATE_badbit;
6670     }
6671     basic_ostream_wchar_sentry_destroy(ostr);
6672
6673     basic_ios_wchar_setstate(base, state);
6674     return ostr;
6675 }
6676
6677 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@PB_W@Z */
6678 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@PEB_W@Z */
6679 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@PBG@Z */
6680 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@PEBG@Z */
6681 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_str(basic_ostream_wchar *ostr, const wchar_t *str)
6682 {
6683     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6684     IOSB_iostate state = IOSTATE_goodbit;
6685
6686     TRACE("(%p %s)\n", ostr, debugstr_w(str));
6687
6688     if(basic_ostream_wchar_sentry_create(ostr)) {
6689         MSVCP_size_t len = wcslen(str);
6690         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6691
6692         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6693             for(; pad!=0; pad--) {
6694                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6695                     state = IOSTATE_badbit;
6696                     break;
6697                 }
6698             }
6699         }
6700
6701         if(state == IOSTATE_goodbit) {
6702             if(basic_streambuf_wchar_sputn(base->strbuf, str, len) != len)
6703                                         state = IOSTATE_badbit;
6704         }
6705
6706         if(state == IOSTATE_goodbit) {
6707             for(; pad!=0; pad--) {
6708                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6709                     state = IOSTATE_badbit;
6710                     break;
6711                 }
6712             }
6713         }
6714
6715         base->base.wide = 0;
6716     }else {
6717         state = IOSTATE_badbit;
6718     }
6719     basic_ostream_wchar_sentry_destroy(ostr);
6720
6721     basic_ios_wchar_setstate(base, state);
6722     return ostr;
6723 }
6724
6725 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6726 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6727 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6728 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6729 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
6730 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
6731         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
6732 {
6733     TRACE("(%p %p)\n", this, pfunc);
6734     pfunc(this);
6735     return this;
6736 }
6737
6738 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
6739 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
6740 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
6741 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
6742 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
6743 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
6744         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
6745 {
6746     TRACE("(%p %p)\n", this, pfunc);
6747     pfunc(basic_ostream_wchar_get_basic_ios(this));
6748     return this;
6749 }
6750
6751 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6752 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6753 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6754 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6755 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
6756 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
6757         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
6758 {
6759     TRACE("(%p %p)\n", this, pfunc);
6760     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
6761     return this;
6762 }
6763
6764 /* Caution: basic_istream uses virtual inheritance. */
6765 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
6766 {
6767     return (basic_ios_char*)((char*)this+this->vbtable[1]);
6768 }
6769
6770 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
6771 {
6772     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
6773 }
6774
6775 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
6776 {
6777     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
6778 }
6779
6780 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6781 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6782 static basic_istream_char* basic_istream_char_ctor_init(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
6783 {
6784     basic_ios_char *base;
6785
6786     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
6787
6788     if(virt_init) {
6789         this->vbtable = basic_istream_char_vbtable;
6790         base = basic_istream_char_get_basic_ios(this);
6791         basic_ios_char_ctor(base);
6792     }else {
6793         base = basic_istream_char_get_basic_ios(this);
6794     }
6795
6796     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6797     this->count = 0;
6798     if(!noinit)
6799         basic_ios_char_init(base, strbuf, isstd);
6800     return this;
6801 }
6802
6803 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6804 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6805 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
6806 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6807 {
6808     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
6809 }
6810
6811 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
6812 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
6813 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
6814 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
6815 {
6816     basic_ios_char *base;
6817
6818     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
6819
6820     if(virt_init) {
6821         this->vbtable = basic_istream_char_vbtable;
6822         base = basic_istream_char_get_basic_ios(this);
6823         basic_ios_char_ctor(base);
6824     }else {
6825         base = basic_istream_char_get_basic_ios(this);
6826     }
6827
6828     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6829     ios_base_Addstd(&base->base);
6830     return this;
6831 }
6832
6833 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
6834 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
6835 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
6836 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
6837 {
6838     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6839
6840     /* don't destroy virtual base here */
6841     TRACE("(%p)\n", this);
6842 }
6843
6844 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6845 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6846 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
6847 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
6848 {
6849     TRACE("(%p)\n", this);
6850     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
6851     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
6852 }
6853
6854 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
6855 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
6856 {
6857     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6858
6859     TRACE("(%p %x)\n", this, flags);
6860
6861     if(flags & 2) {
6862         /* we have an array, with the number of elements stored before the first object */
6863         INT_PTR i, *ptr = (INT_PTR *)this-1;
6864
6865         for(i=*ptr-1; i>=0; i--)
6866             basic_istream_char_vbase_dtor(this+i);
6867         MSVCRT_operator_delete(ptr);
6868     } else {
6869         basic_istream_char_vbase_dtor(this);
6870         if(flags & 1)
6871             MSVCRT_operator_delete(this);
6872     }
6873
6874     return this;
6875 }
6876
6877 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6878 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6879 static MSVCP_bool basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
6880 {
6881     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6882
6883     TRACE("(%p %d)\n", this, noskip);
6884
6885     if(ios_base_good(&base->base)) {
6886         if(basic_ios_char_tie_get(base))
6887             basic_ostream_char_flush(basic_ios_char_tie_get(base));
6888
6889         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
6890             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6891             const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
6892             int ch;
6893
6894             for(ch = basic_streambuf_char_sgetc(strbuf); ;
6895                     ch = basic_streambuf_char_snextc(strbuf)) {
6896                 if(ch == EOF) {
6897                     basic_ios_char_setstate(base, IOSTATE_eofbit);
6898                     break;
6899                 }
6900
6901                 if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
6902                     break;
6903             }
6904         }
6905     }
6906
6907     if(!ios_base_good(&base->base)) {
6908         basic_ios_char_setstate(base, IOSTATE_failbit);
6909         return FALSE;
6910     }
6911
6912     return TRUE;
6913 }
6914
6915 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6916 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6917 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
6918 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
6919 {
6920     return basic_istream_char__Ipfx(this, noskip);
6921 }
6922
6923 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6924 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6925 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
6926 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
6927 {
6928     TRACE("(%p)\n", this);
6929 }
6930
6931 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
6932 {
6933     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6934
6935     if(basic_ios_char_rdbuf_get(base))
6936         basic_streambuf_char__Lock(base->strbuf);
6937
6938     return basic_istream_char_ipfx(istr, noskip);
6939 }
6940
6941 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
6942 {
6943     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6944
6945     if(basic_ios_char_rdbuf_get(base))
6946         basic_streambuf_char__Unlock(base->strbuf);
6947 }
6948
6949 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
6950 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
6951 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
6952 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
6953 {
6954     TRACE("(%p)\n", this);
6955     return this->count;
6956 }
6957
6958 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
6959 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
6960 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
6961 int __thiscall basic_istream_char_get(basic_istream_char *this)
6962 {
6963     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6964     int ret;
6965
6966     TRACE("(%p)\n", this);
6967
6968     this->count = 0;
6969
6970     if(!basic_istream_char_sentry_create(this, TRUE)) {
6971         basic_istream_char_sentry_destroy(this);
6972         return EOF;
6973     }
6974
6975     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
6976     basic_istream_char_sentry_destroy(this);
6977     if(ret == EOF)
6978         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
6979     else
6980         this->count++;
6981
6982     return ret;
6983 }
6984
6985 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
6986 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
6987 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
6988 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
6989 {
6990     int ret;
6991
6992     TRACE("(%p %p)\n", this, ch);
6993
6994     ret = basic_istream_char_get(this);
6995     if(ret != EOF)
6996         *ch = (char)ret;
6997     return this;
6998 }
6999
7000 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7001 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7002 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
7003 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7004 {
7005     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7006     int ch = delim;
7007
7008     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7009
7010     this->count = 0;
7011
7012     if(basic_istream_char_sentry_create(this, TRUE)) {
7013         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7014
7015         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
7016                 ch = basic_streambuf_char_snextc(strbuf)) {
7017             if(ch==EOF || ch==delim)
7018                 break;
7019
7020             *str++ = ch;
7021             this->count++;
7022             count--;
7023         }
7024     }
7025     basic_istream_char_sentry_destroy(this);
7026
7027     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7028             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7029     if(count > 0)
7030         *str = 0;
7031     return this;
7032 }
7033
7034 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7035 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7036 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
7037 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
7038 {
7039     return basic_istream_char_get_str_delim(this, str, count, '\n');
7040 }
7041
7042 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7043 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7044 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
7045 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
7046 {
7047     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7048     int ch = delim;
7049
7050     TRACE("(%p %p %c)\n", this, strbuf, delim);
7051
7052     this->count = 0;
7053
7054     if(basic_istream_char_sentry_create(this, TRUE)) {
7055         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
7056
7057         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
7058                 ch = basic_streambuf_char_snextc(strbuf_read)) {
7059             if(ch==EOF || ch==delim)
7060                 break;
7061
7062             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
7063                 break;
7064             this->count++;
7065         }
7066     }
7067     basic_istream_char_sentry_destroy(this);
7068
7069     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7070             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7071     return this;
7072 }
7073
7074 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7075 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7076 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
7077 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
7078 {
7079     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
7080 }
7081
7082 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7083 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7084 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
7085 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7086 {
7087     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7088     int ch = (unsigned char)delim;
7089
7090     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7091
7092     this->count = 0;
7093
7094     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
7095         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7096
7097         while(count > 1) {
7098             ch = basic_streambuf_char_sbumpc(strbuf);
7099
7100             if(ch==EOF || ch==(unsigned char)delim)
7101                 break;
7102
7103             *str++ = ch;
7104             this->count++;
7105             count--;
7106         }
7107
7108         if(ch == (unsigned char)delim)
7109             this->count++;
7110         else if(ch != EOF) {
7111             ch = basic_streambuf_char_sgetc(strbuf);
7112
7113             if(ch == (unsigned char)delim) {
7114                 basic_streambuf_char__Gninc(strbuf);
7115                 this->count++;
7116             }
7117         }
7118     }
7119     basic_istream_char_sentry_destroy(this);
7120
7121     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
7122             (!this->count || (ch!=(unsigned char)delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
7123     if(count > 0)
7124         *str = 0;
7125     return this;
7126 }
7127
7128 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7129 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7130 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
7131 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
7132 {
7133     return basic_istream_char_getline_delim(this, str, count, '\n');
7134 }
7135
7136 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
7137 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7138 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
7139 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
7140 {
7141     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7142     int ch = (unsigned char)delim;
7143     unsigned int state;
7144
7145     TRACE("(%p %ld %d)\n", this, count, delim);
7146
7147     this->count = 0;
7148
7149     if(basic_istream_char_sentry_create(this, TRUE)) {
7150         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7151         state = IOSTATE_goodbit;
7152
7153         while(count > 0) {
7154             ch = basic_streambuf_char_sbumpc(strbuf);
7155
7156             if(ch==EOF) {
7157                 state = IOSTATE_eofbit;
7158                 break;
7159             }
7160
7161             if(ch==(unsigned char)delim)
7162                 break;
7163
7164             this->count++;
7165             if(count != INT_MAX)
7166                 count--;
7167         }
7168     }else
7169         state = IOSTATE_failbit;
7170     basic_istream_char_sentry_destroy(this);
7171
7172     basic_ios_char_setstate(base, state);
7173     return this;
7174 }
7175
7176 /* ?ws@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@1@AAV21@@Z */
7177 /* ?ws@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
7178 basic_istream_char* __cdecl ws_basic_istream_char(basic_istream_char *istream)
7179 {
7180     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7181     int ch = '\n';
7182
7183     TRACE("(%p)\n", istream);
7184
7185     if(basic_istream_char_sentry_create(istream, TRUE)) {
7186         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7187         const ctype_char *ctype = ctype_char_use_facet(strbuf->loc);
7188
7189         for(ch = basic_streambuf_char_sgetc(strbuf); ctype_char_is_ch(ctype, _SPACE, ch);
7190                 ch = basic_streambuf_char_snextc(strbuf)) {
7191             if(ch == EOF)
7192                 break;
7193         }
7194     }
7195     basic_istream_char_sentry_destroy(istream);
7196
7197     if(ch == EOF)
7198         basic_ios_char_setstate(base, IOSTATE_eofbit);
7199     return istream;
7200 }
7201
7202 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7203 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7204 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
7205 int __thiscall basic_istream_char_peek(basic_istream_char *this)
7206 {
7207     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7208     int ret = EOF;
7209
7210     TRACE("(%p)\n", this);
7211
7212     this->count = 0;
7213
7214     if(basic_istream_char_sentry_create(this, TRUE))
7215         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7216     basic_istream_char_sentry_destroy(this);
7217
7218     if (ret == EOF)
7219         basic_ios_char_setstate(base, IOSTATE_eofbit);
7220
7221     return ret;
7222 }
7223
7224 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
7225 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
7226 static basic_istream_char* basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7227 {
7228     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7229     IOSB_iostate state = IOSTATE_goodbit;
7230
7231     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7232
7233     if(basic_istream_char_sentry_create(this, TRUE)) {
7234         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7235
7236         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
7237         if(this->count != count)
7238             state |= IOSTATE_failbit | IOSTATE_eofbit;
7239     }else {
7240         this->count = 0;
7241     }
7242     basic_istream_char_sentry_destroy(this);
7243
7244     basic_ios_char_setstate(base, state);
7245     return this;
7246 }
7247
7248 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7249 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7250 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
7251 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
7252 {
7253     return basic_istream_char__Read_s(this, str, count, count);
7254 }
7255
7256 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
7257 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
7258 static streamsize basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7259 {
7260     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7261     IOSB_iostate state = IOSTATE_goodbit;
7262
7263     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7264
7265     this->count = 0;
7266
7267     if(basic_istream_char_sentry_create(this, TRUE)) {
7268         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
7269         if(avail > count)
7270             avail = count;
7271
7272         if(avail == -1)
7273             state |= IOSTATE_eofbit;
7274         else if(avail > 0)
7275             basic_istream_char__Read_s(this, str, size, avail);
7276     }else {
7277         state |= IOSTATE_failbit;
7278     }
7279     basic_istream_char_sentry_destroy(this);
7280
7281     basic_ios_char_setstate(base, state);
7282     return this->count;
7283 }
7284
7285 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
7286 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
7287 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
7288 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
7289 {
7290     return basic_istream_char__Readsome_s(this, str, count, count);
7291 }
7292
7293 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
7294 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
7295 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
7296 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
7297 {
7298     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7299     IOSB_iostate state = IOSTATE_goodbit;
7300
7301     TRACE("(%p %c)\n", this, ch);
7302
7303     this->count = 0;
7304
7305     if(basic_istream_char_sentry_create(this, TRUE)) {
7306         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7307
7308         if(!ios_base_good(&base->base))
7309             state |= IOSTATE_failbit;
7310         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
7311             state |= IOSTATE_badbit;
7312     }
7313     basic_istream_char_sentry_destroy(this);
7314
7315     basic_ios_char_setstate(base, state);
7316     return this;
7317 }
7318
7319 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
7320 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
7321 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
7322 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
7323 {
7324     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7325     IOSB_iostate state = IOSTATE_goodbit;
7326
7327     TRACE("(%p)\n", this);
7328
7329     this->count = 0;
7330
7331     if(basic_istream_char_sentry_create(this, TRUE)) {
7332         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7333
7334         if(!ios_base_good(&base->base))
7335             state |= IOSTATE_failbit;
7336         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
7337             state |= IOSTATE_badbit;
7338     }
7339     basic_istream_char_sentry_destroy(this);
7340
7341     basic_ios_char_setstate(base, state);
7342     return this;
7343 }
7344
7345 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7346 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7347 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
7348 int __thiscall basic_istream_char_sync(basic_istream_char *this)
7349 {
7350     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7351     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7352
7353     TRACE("(%p)\n", this);
7354
7355     if(!strbuf)
7356         return -1;
7357
7358     if(basic_istream_char_sentry_create(this, TRUE)) {
7359         if(basic_streambuf_char_pubsync(strbuf) != -1) {
7360             basic_istream_char_sentry_destroy(this);
7361             return 0;
7362         }
7363     }
7364     basic_istream_char_sentry_destroy(this);
7365
7366     basic_ios_char_setstate(base, IOSTATE_badbit);
7367     return -1;
7368 }
7369
7370 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7371 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7372 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
7373 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
7374 {
7375     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7376
7377     TRACE("(%p %p)\n", this, ret);
7378
7379     if(ios_base_fail(&base->base)) {
7380         ret->off = -1;
7381         ret->pos = 0;
7382         ret->state = 0;
7383         return ret;
7384     }
7385
7386     basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
7387             ret, 0, SEEKDIR_cur, OPENMODE_in);
7388
7389     if(ret->off==-1 && ret->pos==0 && ret->state==0)
7390         basic_ios_char_setstate(base, IOSTATE_failbit);
7391
7392     return ret;
7393 }
7394
7395 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z */
7396 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z */
7397 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
7398 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
7399 {
7400     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7401
7402     TRACE("(%p %ld %d)\n", this, off, dir);
7403
7404     if(!ios_base_fail(&base->base)) {
7405         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7406         fpos_int ret;
7407
7408         basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
7409
7410         if(ret.off==-1 && ret.pos==0 && ret.state==0)
7411             basic_ios_char_setstate(base, IOSTATE_failbit);
7412         else
7413             basic_ios_char_clear(base, IOSTATE_goodbit);
7414         return this;
7415     }else
7416         basic_ios_char_clear(base, IOSTATE_goodbit);
7417
7418     return this;
7419 }
7420
7421 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7422 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7423 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
7424 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
7425 {
7426     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7427
7428     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7429
7430     if(!ios_base_fail(&base->base)) {
7431         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7432         fpos_int ret;
7433
7434         basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7435
7436         if(ret.off==-1 && ret.pos==0 && ret.state==0)
7437             basic_ios_char_setstate(base, IOSTATE_failbit);
7438         else
7439             basic_ios_char_clear(base, IOSTATE_goodbit);
7440         return this;
7441     }else
7442         basic_ios_char_clear(base, IOSTATE_goodbit);
7443
7444     return this;
7445 }
7446
7447 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
7448 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
7449 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
7450 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
7451 {
7452     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7453     int state = IOSTATE_goodbit;
7454
7455     TRACE("(%p %p)\n", this, v);
7456
7457     if(basic_istream_char_sentry_create(this, FALSE)) {
7458         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7459         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7460         istreambuf_iterator_char first={0}, last={0};
7461         LONG tmp;
7462
7463         first.strbuf = strbuf;
7464         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7465
7466         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7467             *v = tmp;
7468         else
7469             state |= IOSTATE_failbit;
7470     }
7471     basic_istream_char_sentry_destroy(this);
7472
7473     basic_ios_char_setstate(base, state);
7474     return this;
7475 }
7476
7477 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
7478 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
7479 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
7480 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
7481 {
7482     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7483     int state = IOSTATE_goodbit;
7484
7485     TRACE("(%p %p)\n", this, v);
7486
7487     if(basic_istream_char_sentry_create(this, FALSE)) {
7488         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7489         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7490         istreambuf_iterator_char first={0}, last={0};
7491
7492         first.strbuf = strbuf;
7493         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
7494     }
7495     basic_istream_char_sentry_destroy(this);
7496
7497     basic_ios_char_setstate(base, state);
7498     return this;
7499 }
7500
7501 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
7502 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
7503 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
7504 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
7505 {
7506     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7507     int state = IOSTATE_goodbit;
7508
7509     TRACE("(%p %p)\n", this, v);
7510
7511     if(basic_istream_char_sentry_create(this, FALSE)) {
7512         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7513         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7514         istreambuf_iterator_char first={0}, last={0};
7515
7516         first.strbuf = strbuf;
7517         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7518     }
7519     basic_istream_char_sentry_destroy(this);
7520
7521     basic_ios_char_setstate(base, state);
7522     return this;
7523 }
7524
7525 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
7526 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
7527 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
7528 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *v)
7529 {
7530     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7531     int state = IOSTATE_goodbit;
7532
7533     TRACE("(%p %p)\n", this, v);
7534
7535     if(basic_istream_char_sentry_create(this, FALSE)) {
7536         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7537         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7538         istreambuf_iterator_char first={0}, last={0};
7539
7540         first.strbuf = strbuf;
7541         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
7542     }
7543     basic_istream_char_sentry_destroy(this);
7544
7545     basic_ios_char_setstate(base, state);
7546     return this;
7547 }
7548
7549 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
7550 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
7551 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
7552 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
7553 {
7554     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7555     int state = IOSTATE_goodbit;
7556
7557     TRACE("(%p %p)\n", this, v);
7558
7559     if(basic_istream_char_sentry_create(this, FALSE)) {
7560         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7561         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7562         istreambuf_iterator_char first={0}, last={0};
7563
7564         first.strbuf = strbuf;
7565         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7566     }
7567     basic_istream_char_sentry_destroy(this);
7568
7569     basic_ios_char_setstate(base, state);
7570     return this;
7571 }
7572
7573 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
7574 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
7575 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
7576 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
7577 {
7578     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7579     int state = IOSTATE_goodbit;
7580
7581     TRACE("(%p %p)\n", this, v);
7582
7583     if(basic_istream_char_sentry_create(this, FALSE)) {
7584         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7585         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7586         istreambuf_iterator_char first={0}, last={0};
7587
7588         first.strbuf = strbuf;
7589         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
7590     }
7591     basic_istream_char_sentry_destroy(this);
7592
7593     basic_ios_char_setstate(base, state);
7594     return this;
7595 }
7596
7597 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
7598 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
7599 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
7600 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
7601 {
7602     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7603     int state = IOSTATE_goodbit;
7604
7605     TRACE("(%p %p)\n", this, v);
7606
7607     if(basic_istream_char_sentry_create(this, FALSE)) {
7608         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7609         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7610         istreambuf_iterator_char first={0}, last={0};
7611
7612         first.strbuf = strbuf;
7613         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
7614     }
7615     basic_istream_char_sentry_destroy(this);
7616
7617     basic_ios_char_setstate(base, state);
7618     return this;
7619 }
7620
7621 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
7622 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
7623 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
7624 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
7625 {
7626     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7627     int state = IOSTATE_goodbit;
7628
7629     TRACE("(%p %p)\n", this, v);
7630
7631     if(basic_istream_char_sentry_create(this, FALSE)) {
7632         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7633         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7634         istreambuf_iterator_char first={0}, last={0};
7635
7636         first.strbuf = strbuf;
7637         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
7638     }
7639     basic_istream_char_sentry_destroy(this);
7640
7641     basic_ios_char_setstate(base, state);
7642     return this;
7643 }
7644
7645 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
7646 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
7647 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
7648 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
7649 {
7650     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7651     int state = IOSTATE_goodbit;
7652
7653     TRACE("(%p %p)\n", this, v);
7654
7655     if(basic_istream_char_sentry_create(this, FALSE)) {
7656         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7657         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7658         istreambuf_iterator_char first={0}, last={0};
7659
7660         first.strbuf = strbuf;
7661         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
7662     }
7663     basic_istream_char_sentry_destroy(this);
7664
7665     basic_ios_char_setstate(base, state);
7666     return this;
7667 }
7668
7669 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
7670 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
7671 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
7672 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
7673 {
7674     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7675     int state = IOSTATE_goodbit;
7676
7677     TRACE("(%p %p)\n", this, v);
7678
7679     if(basic_istream_char_sentry_create(this, FALSE)) {
7680         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7681         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7682         istreambuf_iterator_char first={0}, last={0};
7683
7684         first.strbuf = strbuf;
7685         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
7686     }
7687     basic_istream_char_sentry_destroy(this);
7688
7689     basic_ios_char_setstate(base, state);
7690     return this;
7691 }
7692
7693 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
7694 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
7695 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
7696 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
7697 {
7698     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7699     int state = IOSTATE_goodbit;
7700
7701     TRACE("(%p %p)\n", this, v);
7702
7703     if(basic_istream_char_sentry_create(this, FALSE)) {
7704         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7705         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7706         istreambuf_iterator_char first={0}, last={0};
7707
7708         first.strbuf = strbuf;
7709         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
7710     }
7711     basic_istream_char_sentry_destroy(this);
7712
7713     basic_ios_char_setstate(base, state);
7714     return this;
7715 }
7716
7717 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
7718 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
7719 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
7720 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
7721 {
7722     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7723     int state = IOSTATE_goodbit;
7724
7725     TRACE("(%p %p)\n", this, v);
7726
7727     if(basic_istream_char_sentry_create(this, FALSE)) {
7728         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7729         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7730         istreambuf_iterator_char first={0}, last={0};
7731
7732         first.strbuf = strbuf;
7733         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
7734     }
7735     basic_istream_char_sentry_destroy(this);
7736
7737     basic_ios_char_setstate(base, state);
7738     return this;
7739 }
7740
7741 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
7742 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
7743 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
7744 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
7745 {
7746     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7747     int state = IOSTATE_goodbit;
7748
7749     TRACE("(%p %p)\n", this, v);
7750
7751     if(basic_istream_char_sentry_create(this, FALSE)) {
7752         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7753         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7754         istreambuf_iterator_char first={0}, last={0};
7755
7756         first.strbuf = strbuf;
7757         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
7758     }
7759     basic_istream_char_sentry_destroy(this);
7760
7761     basic_ios_char_setstate(base, state);
7762     return this;
7763 }
7764
7765 /* ??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@D@Z */
7766 /* ??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@D@Z */
7767 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
7768         basic_istream_char *istream, basic_string_char *str, char delim)
7769 {
7770     IOSB_iostate state = IOSTATE_failbit;
7771     int c = (unsigned char)delim;
7772
7773     TRACE("(%p %p %c)\n", istream, str, delim);
7774
7775     if(basic_istream_char_sentry_create(istream, TRUE)) {
7776         basic_string_char_clear(str);
7777
7778         c = basic_istream_char_get(istream);
7779         if(c != EOF)
7780             state = IOSTATE_goodbit;
7781
7782         for(; c!=(unsigned char)delim && c!=EOF; c = basic_istream_char_get(istream)) {
7783             state = IOSTATE_goodbit;
7784             basic_string_char_append_ch(str, c);
7785         }
7786     }
7787     basic_istream_char_sentry_destroy(istream);
7788
7789     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
7790         state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7791     return istream;
7792 }
7793
7794 /* ??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
7795 /* ??$getline@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
7796 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
7797         basic_istream_char *istream, basic_string_char *str)
7798 {
7799     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
7800 }
7801
7802 /* ??$?5DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
7803 /* ??$?5DU?$char_traits@D@std@@V?$allocator@D@1@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@0@@Z */
7804 basic_istream_char* __cdecl basic_istream_char_read_bstr(
7805         basic_istream_char *istream, basic_string_char *str)
7806 {
7807     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7808     IOSB_iostate state = IOSTATE_failbit;
7809     int c = '\n';
7810
7811     TRACE("(%p %p)\n", istream, str);
7812
7813     if(basic_istream_char_sentry_create(istream, FALSE)) {
7814         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
7815         MSVCP_size_t count = ios_base_width_get(&base->base);
7816
7817         if(!count)
7818             count = -1;
7819
7820         basic_string_char_clear(str);
7821
7822         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7823                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7824                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7825             state = IOSTATE_goodbit;
7826             basic_string_char_append_ch(str, c);
7827         }
7828     }
7829     basic_istream_char_sentry_destroy(istream);
7830
7831     ios_base_width_set(&base->base, 0);
7832     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7833     return istream;
7834 }
7835
7836 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z */
7837 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z */
7838 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAC@Z */
7839 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAC@Z */
7840 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAE@Z */
7841 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAE@Z */
7842 basic_istream_char* __cdecl basic_istream_char_read_str(basic_istream_char *istream, char *str)
7843 {
7844     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7845     IOSB_iostate state = IOSTATE_failbit;
7846     int c = '\n';
7847
7848     TRACE("(%p %p)\n", istream, str);
7849
7850     if(basic_istream_char_sentry_create(istream, FALSE)) {
7851         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
7852         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
7853
7854         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7855                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7856                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7857             state = IOSTATE_goodbit;
7858             *str++ = c;
7859         }
7860     }
7861     basic_istream_char_sentry_destroy(istream);
7862
7863     *str = 0;
7864     ios_base_width_set(&base->base, 0);
7865     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7866     return istream;
7867 }
7868
7869 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z */
7870 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAD@Z */
7871 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z */
7872 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAC@Z */
7873 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z */
7874 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAE@Z */
7875 basic_istream_char* __cdecl basic_istream_char_read_ch(basic_istream_char *istream, char *ch)
7876 {
7877     IOSB_iostate state = IOSTATE_failbit;
7878     int c = 0;
7879
7880     TRACE("(%p %p)\n", istream, ch);
7881
7882     if(basic_istream_char_sentry_create(istream, FALSE)) {
7883         c = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(
7884                     basic_istream_char_get_basic_ios(istream)));
7885         if(c != EOF) {
7886             state = IOSTATE_goodbit;
7887             *ch = c;
7888         }
7889     }
7890     basic_istream_char_sentry_destroy(istream);
7891
7892     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
7893             state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7894     return istream;
7895 }
7896
7897 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7898 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7899 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
7900 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
7901         basic_istream_char *this, basic_streambuf_char *streambuf)
7902 {
7903     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7904     IOSB_iostate state = IOSTATE_failbit;
7905     int c = '\n';
7906
7907     TRACE("(%p %p)\n", this, streambuf);
7908
7909     if(basic_istream_char_sentry_create(this, FALSE)) {
7910         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
7911                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
7912             state = IOSTATE_goodbit;
7913             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
7914                 break;
7915         }
7916     }
7917     basic_istream_char_sentry_destroy(this);
7918
7919     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7920     return this;
7921 }
7922
7923 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7924 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7925 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
7926 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
7927         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
7928 {
7929     TRACE("(%p %p)\n", this, pfunc);
7930     pfunc(this);
7931     return this;
7932 }
7933
7934 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
7935 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
7936 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
7937 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
7938         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
7939 {
7940     TRACE("(%p %p)\n", this, pfunc);
7941     pfunc(basic_istream_char_get_basic_ios(this));
7942     return this;
7943 }
7944
7945 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7946 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7947 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
7948 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
7949         ios_base* (__cdecl *pfunc)(ios_base*))
7950 {
7951     TRACE("(%p %p)\n", this, pfunc);
7952     pfunc(&basic_istream_char_get_basic_ios(this)->base);
7953     return this;
7954 }
7955
7956 /* Caution: basic_istream uses virtual inheritance. */
7957 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
7958 {
7959     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
7960 }
7961
7962 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
7963 {
7964     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
7965 }
7966
7967 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
7968 {
7969     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
7970 }
7971
7972 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7973 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7974 static basic_istream_wchar* basic_istream_wchar_ctor_init(basic_istream_wchar *this,
7975         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7976 {
7977     basic_ios_wchar *base;
7978
7979     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
7980
7981     if(virt_init) {
7982         this->vbtable = basic_istream_wchar_vbtable;
7983         base = basic_istream_wchar_get_basic_ios(this);
7984         basic_ios_wchar_ctor(base);
7985     }else {
7986         base = basic_istream_wchar_get_basic_ios(this);
7987     }
7988
7989     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
7990     this->count = 0;
7991     if(!noinit)
7992         basic_ios_wchar_init(base, strbuf, isstd);
7993     return this;
7994 }
7995
7996 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7997 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7998 static basic_istream_wchar* basic_istream_short_ctor_init(basic_istream_wchar *this,
7999         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
8000 {
8001     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
8002     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8003     return this;
8004 }
8005
8006 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8007 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8008 static basic_istream_wchar* basic_istream_wchar_ctor(basic_istream_wchar *this,
8009         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8010 {
8011     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8012 }
8013
8014 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8015 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8016 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor, 16)
8017 basic_istream_wchar* __thiscall basic_istream_short_ctor(basic_istream_wchar *this,
8018         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8019 {
8020     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8021 }
8022
8023 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8024 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8025 static basic_istream_wchar* basic_istream_wchar_ctor_uninitialized(
8026         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8027 {
8028     basic_ios_wchar *base;
8029
8030     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
8031
8032     if(virt_init) {
8033         this->vbtable = basic_istream_wchar_vbtable;
8034         base = basic_istream_wchar_get_basic_ios(this);
8035         basic_ios_wchar_ctor(base);
8036     }else {
8037         base = basic_istream_wchar_get_basic_ios(this);
8038     }
8039
8040     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8041     ios_base_Addstd(&base->base);
8042     return this;
8043 }
8044
8045 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8046 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8047 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
8048 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
8049         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8050 {
8051     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
8052     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8053     return this;
8054 }
8055
8056 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
8057 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
8058 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
8059 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
8060 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
8061 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
8062 {
8063     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8064
8065     /* don't destroy virtual base here */
8066     TRACE("(%p)\n", this);
8067 }
8068
8069 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8070 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8071 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8072 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8073 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
8074 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
8075 {
8076     TRACE("(%p)\n", this);
8077     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
8078     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
8079 }
8080
8081 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
8082 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
8083 {
8084     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8085
8086     TRACE("(%p %x)\n", this, flags);
8087
8088     if(flags & 2) {
8089         /* we have an array, with the number of elements stored before the first object */
8090         INT_PTR i, *ptr = (INT_PTR *)this-1;
8091
8092         for(i=*ptr-1; i>=0; i--)
8093             basic_istream_wchar_vbase_dtor(this+i);
8094         MSVCRT_operator_delete(ptr);
8095     } else {
8096         basic_istream_wchar_vbase_dtor(this);
8097         if(flags & 1)
8098             MSVCRT_operator_delete(this);
8099     }
8100
8101     return this;
8102 }
8103
8104 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8105 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8106 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8107 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8108 static MSVCP_bool basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8109 {
8110     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8111
8112     TRACE("(%p %d)\n", this, noskip);
8113
8114     if(ios_base_good(&base->base)) {
8115         if(basic_ios_wchar_tie_get(base))
8116             basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
8117
8118         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
8119             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8120             const ctype_wchar *ctype = ctype_wchar_use_facet(base->strbuf->loc);
8121             int ch;
8122
8123             for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
8124                     ch = basic_streambuf_wchar_snextc(strbuf)) {
8125                 if(ch == WEOF) {
8126                     basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8127                     break;
8128                 }
8129
8130                 if(!ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
8131                     break;
8132             }
8133         }
8134     }
8135
8136     if(!ios_base_good(&base->base)) {
8137         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8138         return FALSE;
8139     }
8140     return TRUE;
8141 }
8142
8143 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8144 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8145 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8146 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8147 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
8148 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8149 {
8150     return basic_istream_wchar__Ipfx(this, noskip);
8151 }
8152
8153 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8154 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8155 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8156 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8157 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
8158 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
8159 {
8160     TRACE("(%p)\n", this);
8161 }
8162
8163 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
8164 {
8165     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8166
8167     if(basic_ios_wchar_rdbuf_get(base))
8168         basic_streambuf_wchar__Lock(base->strbuf);
8169
8170     return basic_istream_wchar_ipfx(istr, noskip);
8171 }
8172
8173 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
8174 {
8175     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8176
8177     if(basic_ios_wchar_rdbuf_get(base))
8178         basic_streambuf_wchar__Unlock(base->strbuf);
8179 }
8180
8181 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
8182 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
8183 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
8184 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
8185 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
8186 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
8187 {
8188     TRACE("(%p)\n", this);
8189     return this->count;
8190 }
8191
8192 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8193 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8194 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8195 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8196 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
8197 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
8198 {
8199     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8200     int ret;
8201
8202     TRACE("(%p)\n", this);
8203
8204     this->count = 0;
8205
8206     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
8207         basic_istream_wchar_sentry_destroy(this);
8208         return WEOF;
8209     }
8210
8211     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
8212     basic_istream_wchar_sentry_destroy(this);
8213     if(ret == WEOF)
8214         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
8215     else
8216         this->count++;
8217
8218     return ret;
8219 }
8220
8221 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
8222 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
8223 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
8224 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
8225 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
8226 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
8227 {
8228     unsigned short ret;
8229
8230     TRACE("(%p %p)\n", this, ch);
8231
8232     ret = basic_istream_wchar_get(this);
8233     if(ret != WEOF)
8234         *ch = (wchar_t)ret;
8235     return this;
8236 }
8237
8238 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8239 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8240 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8241 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8242 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 16)
8243 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8244 {
8245     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8246     unsigned short ch = delim;
8247
8248     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8249
8250     this->count = 0;
8251
8252     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8253         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8254
8255         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
8256                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8257             if(ch==WEOF || ch==delim)
8258                 break;
8259
8260             *str++ = ch;
8261             this->count++;
8262             count--;
8263         }
8264     }
8265     basic_istream_wchar_sentry_destroy(this);
8266
8267     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8268             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8269     if(count > 0)
8270         *str = 0;
8271     return this;
8272 }
8273
8274 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8275 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8276 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8277 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8278 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 12)
8279 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
8280 {
8281     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
8282 }
8283
8284 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8285 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8286 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8287 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8288 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
8289 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
8290 {
8291     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8292     unsigned short ch = delim;
8293
8294     TRACE("(%p %p %c)\n", this, strbuf, delim);
8295
8296     this->count = 0;
8297
8298     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8299         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
8300
8301         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
8302                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
8303             if(ch==WEOF || ch==delim)
8304                 break;
8305
8306             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
8307                 break;
8308             this->count++;
8309         }
8310     }
8311     basic_istream_wchar_sentry_destroy(this);
8312
8313     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8314             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8315     return this;
8316 }
8317
8318 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8319 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8320 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8321 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8322 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
8323 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
8324 {
8325     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
8326 }
8327
8328 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8329 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8330 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8331 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8332 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 16)
8333 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8334 {
8335     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8336     unsigned short ch = delim;
8337
8338     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8339
8340     this->count = 0;
8341
8342     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
8343         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8344
8345         while(count > 1) {
8346             ch = basic_streambuf_wchar_sbumpc(strbuf);
8347
8348             if(ch==WEOF || ch==delim)
8349                 break;
8350
8351             *str++ = ch;
8352             this->count++;
8353             count--;
8354         }
8355
8356         if(ch == delim)
8357             this->count++;
8358         else if(ch != WEOF) {
8359             ch = basic_streambuf_wchar_sgetc(strbuf);
8360
8361             if(ch == delim) {
8362                 basic_streambuf_wchar__Gninc(strbuf);
8363                 this->count++;
8364             }
8365         }
8366     }
8367     basic_istream_wchar_sentry_destroy(this);
8368
8369     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
8370             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
8371     if(count > 0)
8372         *str = 0;
8373     return this;
8374 }
8375
8376 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8377 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8378 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8379 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8380 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 12)
8381 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
8382 {
8383     return basic_istream_wchar_getline_delim(this, str, count, '\n');
8384 }
8385
8386 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
8387 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
8388 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
8389 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
8390 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 12)
8391 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
8392 {
8393     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8394     unsigned short ch = delim;
8395     unsigned int state;
8396
8397     TRACE("(%p %ld %d)\n", this, count, delim);
8398
8399     this->count = 0;
8400
8401     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8402         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8403         state = IOSTATE_goodbit;
8404
8405         while(count > 0) {
8406             ch = basic_streambuf_wchar_sbumpc(strbuf);
8407
8408             if(ch==WEOF) {
8409                 state = IOSTATE_eofbit;
8410                 break;
8411             }
8412
8413             if(ch==delim)
8414                 break;
8415
8416             this->count++;
8417             if(count != INT_MAX)
8418                 count--;
8419         }
8420     }else
8421         state = IOSTATE_failbit;
8422     basic_istream_wchar_sentry_destroy(this);
8423
8424     basic_ios_wchar_setstate(base, state);
8425     return this;
8426 }
8427
8428 /* ?ws@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
8429 /* ?ws@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
8430 /* ?ws@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@1@AAV21@@Z */
8431 /* ?ws@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
8432 basic_istream_wchar* __cdecl ws_basic_istream_wchar(basic_istream_wchar *istream)
8433 {
8434     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8435     unsigned short ch = '\n';
8436
8437     TRACE("(%p)\n", istream);
8438
8439     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8440         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8441         const ctype_wchar *ctype = ctype_wchar_use_facet(strbuf->loc);
8442
8443         for(ch = basic_streambuf_wchar_sgetc(strbuf); ctype_wchar_is_ch(ctype, _SPACE, ch);
8444                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8445             if(ch == WEOF)
8446                 break;
8447         }
8448     }
8449     basic_istream_wchar_sentry_destroy(istream);
8450
8451     if(ch == WEOF)
8452         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8453     return istream;
8454 }
8455
8456 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8457 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8458 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8459 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8460 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
8461 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
8462 {
8463     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8464     unsigned short ret = WEOF;
8465
8466     TRACE("(%p)\n", this);
8467
8468     this->count = 0;
8469
8470     if(basic_istream_wchar_sentry_create(this, TRUE))
8471         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8472     basic_istream_wchar_sentry_destroy(this);
8473
8474     if (ret == WEOF)
8475         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8476
8477     return ret;
8478 }
8479
8480 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
8481 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
8482 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
8483 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
8484 static basic_istream_wchar* basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8485 {
8486     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8487     IOSB_iostate state = IOSTATE_goodbit;
8488
8489     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8490
8491     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8492         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8493
8494         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
8495         if(this->count != count)
8496             state |= IOSTATE_failbit | IOSTATE_eofbit;
8497     }else {
8498         this->count = 0;
8499     }
8500     basic_istream_wchar_sentry_destroy(this);
8501
8502     basic_ios_wchar_setstate(base, state);
8503     return this;
8504 }
8505
8506 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8507 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8508 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8509 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8510 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 12)
8511 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
8512 {
8513     return basic_istream_wchar__Read_s(this, str, count, count);
8514 }
8515
8516 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
8517 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
8518 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
8519 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
8520 static streamsize basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8521 {
8522     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8523     IOSB_iostate state = IOSTATE_goodbit;
8524
8525     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8526
8527     this->count = 0;
8528
8529     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8530         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
8531         if(avail > count)
8532             avail = count;
8533
8534         if(avail == -1)
8535             state |= IOSTATE_eofbit;
8536         else if(avail > 0)
8537             basic_istream_wchar__Read_s(this, str, size, avail);
8538     }else {
8539         state |= IOSTATE_failbit;
8540     }
8541     basic_istream_wchar_sentry_destroy(this);
8542
8543     basic_ios_wchar_setstate(base, state);
8544     return this->count;
8545 }
8546
8547 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
8548 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
8549 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
8550 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
8551 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 12)
8552 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
8553 {
8554     return basic_istream_wchar__Readsome_s(this, str, count, count);
8555 }
8556
8557 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
8558 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
8559 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
8560 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
8561 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
8562 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
8563 {
8564     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8565     IOSB_iostate state = IOSTATE_goodbit;
8566
8567     TRACE("(%p %c)\n", this, ch);
8568
8569     this->count = 0;
8570
8571     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8572         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8573
8574         if(!ios_base_good(&base->base))
8575             state |= IOSTATE_failbit;
8576         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
8577             state |= IOSTATE_badbit;
8578     }
8579     basic_istream_wchar_sentry_destroy(this);
8580
8581     basic_ios_wchar_setstate(base, state);
8582     return this;
8583 }
8584
8585 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
8586 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
8587 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
8588 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
8589 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
8590 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
8591 {
8592     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8593     IOSB_iostate state = IOSTATE_goodbit;
8594
8595     TRACE("(%p)\n", this);
8596
8597     this->count = 0;
8598
8599     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8600         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8601
8602         if(!ios_base_good(&base->base))
8603             state |= IOSTATE_failbit;
8604         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
8605             state |= IOSTATE_badbit;
8606     }
8607     basic_istream_wchar_sentry_destroy(this);
8608
8609     basic_ios_wchar_setstate(base, state);
8610     return this;
8611 }
8612
8613 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
8614 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
8615 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
8616 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
8617 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
8618 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
8619 {
8620     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8621     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8622
8623     TRACE("(%p)\n", this);
8624
8625     if(!strbuf)
8626         return -1;
8627
8628     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8629         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
8630             basic_istream_wchar_sentry_destroy(this);
8631             return 0;
8632         }
8633     }
8634     basic_istream_wchar_sentry_destroy(this);
8635
8636     basic_ios_wchar_setstate(base, IOSTATE_badbit);
8637     return -1;
8638 }
8639
8640 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8641 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8642 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8643 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8644 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
8645 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
8646 {
8647     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8648
8649     TRACE("(%p %p)\n", this, ret);
8650
8651     if(ios_base_fail(&base->base)) {
8652         ret->off = -1;
8653         ret->pos = 0;
8654         ret->state = 0;
8655         return ret;
8656     }
8657
8658     basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
8659             ret, 0, SEEKDIR_cur, OPENMODE_in);
8660     if(ret->off==-1 && ret->pos==0 && ret->state==0)
8661         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8662
8663     return ret;
8664 }
8665
8666 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z */
8667 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z */
8668 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 12)
8669 basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir)
8670 {
8671     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8672
8673     TRACE("(%p %ld %d)\n", this, off, dir);
8674
8675     if(!ios_base_fail(&base->base)) {
8676         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8677         fpos_int ret;
8678
8679         basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
8680
8681         if(ret.off==-1 && ret.pos==0 && ret.state==0)
8682             basic_ios_wchar_setstate(base, IOSTATE_failbit);
8683         else
8684             basic_ios_wchar_clear(base, IOSTATE_goodbit);
8685         return this;
8686     }else
8687         basic_ios_wchar_clear(base, IOSTATE_goodbit);
8688
8689     return this;
8690 }
8691
8692 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8693 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8694 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8695 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8696 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
8697 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
8698 {
8699     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8700
8701     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
8702
8703     if(!ios_base_fail(&base->base)) {
8704         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8705         fpos_int ret;
8706
8707         basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
8708
8709         if(ret.off==-1 && ret.pos==0 && ret.state==0)
8710             basic_ios_wchar_setstate(base, IOSTATE_failbit);
8711         else
8712             basic_ios_wchar_clear(base, IOSTATE_goodbit);
8713         return this;
8714     }else
8715         basic_ios_wchar_clear(base, IOSTATE_goodbit);
8716
8717     return this;
8718 }
8719
8720 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
8721 {
8722     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8723     int state = IOSTATE_goodbit;
8724
8725     TRACE("(%p %p)\n", this, v);
8726
8727     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8728         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8729         istreambuf_iterator_wchar first={0}, last={0};
8730         LONG tmp;
8731
8732         first.strbuf = strbuf;
8733         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
8734
8735         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
8736             *v = tmp;
8737         else
8738             state |= IOSTATE_failbit;
8739     }
8740     basic_istream_wchar_sentry_destroy(this);
8741
8742     basic_ios_wchar_setstate(base, state);
8743     return this;
8744 }
8745
8746 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
8747 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
8748 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
8749 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
8750 {
8751     return basic_istream_read_short(this, v, num_get_short_use_facet(
8752                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8753 }
8754
8755 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
8756 {
8757     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8758     int state = IOSTATE_goodbit;
8759
8760     TRACE("(%p %p)\n", this, v);
8761
8762     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8763         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8764         istreambuf_iterator_wchar first={0}, last={0};
8765
8766         first.strbuf = strbuf;
8767         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8768     }
8769     basic_istream_wchar_sentry_destroy(this);
8770
8771     basic_ios_wchar_setstate(base, state);
8772     return this;
8773 }
8774
8775 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
8776 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
8777 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
8778 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
8779 {
8780     return basic_istream_read_int(this, v, num_get_short_use_facet(
8781                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8782 }
8783
8784 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
8785 {
8786     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8787     int state = IOSTATE_goodbit;
8788
8789     TRACE("(%p %p)\n", this, v);
8790
8791     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8792         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8793         istreambuf_iterator_wchar first={0}, last={0};
8794
8795         first.strbuf = strbuf;
8796         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
8797     }
8798     basic_istream_wchar_sentry_destroy(this);
8799
8800     basic_ios_wchar_setstate(base, state);
8801     return this;
8802 }
8803
8804 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
8805 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
8806 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
8807 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
8808 {
8809     return basic_istream_read_uint(this, v, num_get_short_use_facet(
8810                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8811 }
8812
8813 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
8814 {
8815     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8816     int state = IOSTATE_goodbit;
8817
8818     TRACE("(%p %p)\n", this, v);
8819
8820     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8821         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8822         istreambuf_iterator_wchar first={0}, last={0};
8823
8824         first.strbuf = strbuf;
8825         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8826     }
8827     basic_istream_wchar_sentry_destroy(this);
8828
8829     basic_ios_wchar_setstate(base, state);
8830     return this;
8831 }
8832
8833 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
8834 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
8835 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
8836 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
8837 {
8838     return basic_istream_read_long(this, v, num_get_short_use_facet(
8839                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8840 }
8841
8842 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
8843 {
8844     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8845     int state = IOSTATE_goodbit;
8846
8847     TRACE("(%p %p)\n", this, v);
8848
8849     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8850         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8851         istreambuf_iterator_wchar first={0}, last={0};
8852
8853         first.strbuf = strbuf;
8854         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
8855     }
8856     basic_istream_wchar_sentry_destroy(this);
8857
8858     basic_ios_wchar_setstate(base, state);
8859     return this;
8860 }
8861
8862 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
8863 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
8864 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
8865 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
8866 {
8867     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
8868                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8869 }
8870
8871 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
8872 {
8873     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8874     int state = IOSTATE_goodbit;
8875
8876     TRACE("(%p %p)\n", this, v);
8877
8878     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8879         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8880         istreambuf_iterator_wchar first={0}, last={0};
8881
8882         first.strbuf = strbuf;
8883         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
8884     }
8885     basic_istream_wchar_sentry_destroy(this);
8886
8887     basic_ios_wchar_setstate(base, state);
8888     return this;
8889 }
8890
8891 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
8892 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
8893 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
8894 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
8895 {
8896     return basic_istream_read_float(this, v, num_get_short_use_facet(
8897                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8898 }
8899
8900 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
8901 {
8902     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8903     int state = IOSTATE_goodbit;
8904
8905     TRACE("(%p %p)\n", this, v);
8906
8907     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8908         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8909         istreambuf_iterator_wchar first={0}, last={0};
8910
8911         first.strbuf = strbuf;
8912         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
8913     }
8914     basic_istream_wchar_sentry_destroy(this);
8915
8916     basic_ios_wchar_setstate(base, state);
8917     return this;
8918 }
8919
8920 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
8921 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
8922 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
8923 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
8924 {
8925     return basic_istream_read_double(this, v, num_get_short_use_facet(
8926                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8927 }
8928
8929 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
8930 {
8931     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8932     int state = IOSTATE_goodbit;
8933
8934     TRACE("(%p %p)\n", this, v);
8935
8936     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8937         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8938         istreambuf_iterator_wchar first={0}, last={0};
8939
8940         first.strbuf = strbuf;
8941         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
8942     }
8943     basic_istream_wchar_sentry_destroy(this);
8944
8945     basic_ios_wchar_setstate(base, state);
8946     return this;
8947 }
8948
8949 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
8950 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
8951 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
8952 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
8953 {
8954     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
8955                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8956 }
8957
8958 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
8959 {
8960     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8961     int state = IOSTATE_goodbit;
8962
8963     TRACE("(%p %p)\n", this, v);
8964
8965     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8966         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8967         istreambuf_iterator_wchar first={0}, last={0};
8968
8969         first.strbuf = strbuf;
8970         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
8971     }
8972     basic_istream_wchar_sentry_destroy(this);
8973
8974     basic_ios_wchar_setstate(base, state);
8975     return this;
8976 }
8977
8978 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
8979 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
8980 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
8981 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
8982 {
8983     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
8984                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8985 }
8986
8987 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
8988 {
8989     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8990     int state = IOSTATE_goodbit;
8991
8992     TRACE("(%p %p)\n", this, v);
8993
8994     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8995         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8996         istreambuf_iterator_wchar first={0}, last={0};
8997
8998         first.strbuf = strbuf;
8999         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
9000     }
9001     basic_istream_wchar_sentry_destroy(this);
9002
9003     basic_ios_wchar_setstate(base, state);
9004     return this;
9005 }
9006
9007 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
9008 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
9009 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
9010 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
9011 {
9012     return basic_istream_read_int64(this, v, num_get_short_use_facet(
9013                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9014 }
9015
9016 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
9017 {
9018     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9019     int state = IOSTATE_goodbit;
9020
9021     TRACE("(%p %p)\n", this, v);
9022
9023     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9024         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9025         istreambuf_iterator_wchar first={0}, last={0};
9026
9027         first.strbuf = strbuf;
9028         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
9029     }
9030     basic_istream_wchar_sentry_destroy(this);
9031
9032     basic_ios_wchar_setstate(base, state);
9033     return this;
9034 }
9035
9036 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
9037 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
9038 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
9039 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9040 {
9041     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
9042                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9043 }
9044
9045 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
9046 {
9047     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9048     int state = IOSTATE_goodbit;
9049
9050     TRACE("(%p %p)\n", this, v);
9051
9052     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9053         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9054         istreambuf_iterator_wchar first={0}, last={0};
9055
9056         first.strbuf = strbuf;
9057         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
9058     }
9059     basic_istream_wchar_sentry_destroy(this);
9060
9061     basic_ios_wchar_setstate(base, state);
9062     return this;
9063 }
9064
9065 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
9066 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
9067 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
9068 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9069 {
9070     return basic_istream_read_bool(this, v, num_get_short_use_facet(
9071                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9072 }
9073
9074 /* ??$getline@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@_W@Z */
9075 /* ??$getline@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@_W@Z */
9076 /* ??$getline@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@G@Z */
9077 /* ??$getline@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@G@Z */
9078 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr_delim(
9079         basic_istream_wchar *istream, basic_string_wchar *str, wchar_t delim)
9080 {
9081     IOSB_iostate state = IOSTATE_failbit;
9082     int c = delim;
9083
9084     TRACE("(%p %p %c)\n", istream, str, delim);
9085
9086     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
9087         basic_string_wchar_clear(str);
9088
9089         c = basic_istream_wchar_get(istream);
9090         if(c != WEOF)
9091             state = IOSTATE_goodbit;
9092
9093         for(; c!=delim && c!=WEOF; c = basic_istream_wchar_get(istream)) {
9094             state = IOSTATE_goodbit;
9095             basic_string_wchar_append_ch(str, c);
9096         }
9097     }
9098     basic_istream_wchar_sentry_destroy(istream);
9099
9100     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9101             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9102     return istream;
9103 }
9104
9105 /* ??$getline@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@@Z */
9106 /* ??$getline@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@@Z */
9107 /* ??$getline@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@@Z */
9108 /* ??$getline@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@@Z */
9109 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr(
9110         basic_istream_wchar *istream, basic_string_wchar *str)
9111 {
9112     return basic_istream_wchar_getline_bstr_delim(istream, str, '\n');
9113 }
9114
9115 static basic_istream_wchar* basic_istream_read_bstr(basic_istream_wchar *istream,
9116         basic_string_wchar *str, const ctype_wchar *ctype)
9117 {
9118     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9119     IOSB_iostate state = IOSTATE_failbit;
9120     int c = '\n';
9121
9122     TRACE("(%p %p)\n", istream, str);
9123
9124     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9125         MSVCP_size_t count = ios_base_width_get(&base->base);
9126
9127         if(!count)
9128             count = -1;
9129
9130         basic_string_wchar_clear(str);
9131
9132         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9133                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9134                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9135             state = IOSTATE_goodbit;
9136             basic_string_wchar_append_ch(str, c);
9137         }
9138     }
9139     basic_istream_wchar_sentry_destroy(istream);
9140
9141     ios_base_width_set(&base->base, 0);
9142     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9143     return istream;
9144 }
9145
9146 /* ??$?5_WU?$char_traits@_W@std@@V?$allocator@_W@1@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@@Z */
9147 /* ??$?5_WU?$char_traits@_W@std@@V?$allocator@_W@1@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@0@@Z */
9148 basic_istream_wchar* __cdecl basic_istream_wchar_read_bstr(
9149         basic_istream_wchar *istream, basic_string_wchar *str)
9150 {
9151     return basic_istream_read_bstr(istream, str, ctype_wchar_use_facet(
9152                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9153 }
9154
9155 /* ??$?5GU?$char_traits@G@std@@V?$allocator@G@1@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@@Z */
9156 /* ??$?5GU?$char_traits@G@std@@V?$allocator@G@1@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@0@@Z */
9157 basic_istream_wchar* __cdecl basic_istream_short_read_bstr(
9158         basic_istream_wchar *istream, basic_string_wchar *str)
9159 {
9160     return basic_istream_read_bstr(istream, str, ctype_short_use_facet(
9161                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9162 }
9163
9164 static basic_istream_wchar* basic_istream_read_str(basic_istream_wchar *istream, wchar_t *str, const ctype_wchar *ctype)
9165 {
9166     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9167     IOSB_iostate state = IOSTATE_failbit;
9168     unsigned short c = '\n';
9169
9170     TRACE("(%p %p)\n", istream, str);
9171
9172     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9173         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
9174
9175         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9176                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9177                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9178             state = IOSTATE_goodbit;
9179             *str++ = c;
9180         }
9181     }
9182     basic_istream_wchar_sentry_destroy(istream);
9183
9184     *str = 0;
9185     ios_base_width_set(&base->base, 0);
9186     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9187     return istream;
9188 }
9189
9190 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@PAG@Z */
9191 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@PEAG@Z */
9192 basic_istream_wchar* __cdecl basic_istream_short_read_str(basic_istream_wchar *istream, wchar_t *str)
9193 {
9194     return basic_istream_read_str(istream, str, ctype_short_use_facet(
9195                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9196 }
9197
9198 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AA_W@Z */
9199 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEA_W@Z */
9200 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAG@Z */
9201 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAG@Z */
9202 basic_istream_wchar* __cdecl basic_istream_wchar_read_ch(basic_istream_wchar *istream, wchar_t *ch)
9203 {
9204     IOSB_iostate state = IOSTATE_failbit;
9205     unsigned short c = 0;
9206
9207     TRACE("(%p %p)\n", istream, ch);
9208
9209     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9210         c = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(
9211                     basic_istream_wchar_get_basic_ios(istream)));
9212         if(c != WEOF) {
9213             state = IOSTATE_goodbit;
9214             *ch = c;
9215         }
9216     }
9217     basic_istream_wchar_sentry_destroy(istream);
9218
9219     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9220             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9221     return istream;
9222 }
9223
9224 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9225 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9226 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9227 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9228 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
9229 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
9230         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
9231 {
9232     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9233     IOSB_iostate state = IOSTATE_failbit;
9234     unsigned short c = '\n';
9235
9236     TRACE("(%p %p)\n", this, streambuf);
9237
9238     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9239         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
9240                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
9241             state = IOSTATE_goodbit;
9242             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
9243                 break;
9244         }
9245     }
9246     basic_istream_wchar_sentry_destroy(this);
9247
9248     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9249     return this;
9250 }
9251
9252 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9253 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9254 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9255 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9256 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
9257 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
9258         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
9259 {
9260     TRACE("(%p %p)\n", this, pfunc);
9261     pfunc(this);
9262     return this;
9263 }
9264
9265 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
9266 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
9267 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
9268 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
9269 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
9270 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
9271         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
9272 {
9273     TRACE("(%p %p)\n", this, pfunc);
9274     pfunc(basic_istream_wchar_get_basic_ios(this));
9275     return this;
9276 }
9277
9278 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9279 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9280 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9281 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9282 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
9283 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
9284         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
9285 {
9286     TRACE("(%p %p)\n", this, pfunc);
9287     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
9288     return this;
9289 }
9290
9291 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
9292 {
9293     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
9294 }
9295
9296 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
9297 {
9298     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
9299 }
9300
9301 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9302 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9303 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
9304 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
9305 {
9306     basic_ios_char *basic_ios;
9307
9308     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9309
9310     if(virt_init) {
9311         this->base1.vbtable = basic_iostream_char_vbtable1;
9312         this->base2.vbtable = basic_iostream_char_vbtable2;
9313         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9314         basic_ios_char_ctor(basic_ios);
9315     }else {
9316         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9317     }
9318
9319     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
9320
9321     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
9322     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9323     return this;
9324 }
9325
9326 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9327 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9328 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
9329 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
9330 {
9331     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9332
9333     TRACE("(%p)\n", this);
9334     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
9335     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
9336 }
9337
9338 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9339 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9340 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
9341 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
9342 {
9343     TRACE("(%p)\n", this);
9344     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
9345     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
9346 }
9347
9348 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
9349 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9350 {
9351     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9352
9353     TRACE("(%p %x)\n", this, flags);
9354
9355     if(flags & 2) {
9356         /* we have an array, with the number of elements stored before the first object */
9357         INT_PTR i, *ptr = (INT_PTR *)this-1;
9358
9359         for(i=*ptr-1; i>=0; i--)
9360             basic_iostream_char_vbase_dtor(this+i);
9361         MSVCRT_operator_delete(ptr);
9362     } else {
9363         basic_iostream_char_vbase_dtor(this);
9364         if(flags & 1)
9365             MSVCRT_operator_delete(this);
9366     }
9367
9368     return this;
9369 }
9370
9371 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
9372 {
9373     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
9374 }
9375
9376 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9377 {
9378     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
9379 }
9380
9381 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9382 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9383 static basic_iostream_wchar* basic_iostream_wchar_ctor(basic_iostream_wchar *this,
9384         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9385 {
9386     basic_ios_wchar *basic_ios;
9387
9388     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9389
9390     if(virt_init) {
9391         this->base1.vbtable = basic_iostream_wchar_vbtable1;
9392         this->base2.vbtable = basic_iostream_wchar_vbtable2;
9393         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9394         basic_ios_wchar_ctor(basic_ios);
9395     }else {
9396         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9397     }
9398
9399     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
9400     basic_ostream_wchar_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9401
9402     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
9403     return this;
9404 }
9405
9406 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9407 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9408 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
9409 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
9410         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9411 {
9412     basic_iostream_wchar_ctor(this, strbuf, virt_init);
9413     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
9414     return this;
9415 }
9416
9417 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9418 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9419 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9420 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9421 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
9422 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
9423 {
9424     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9425
9426     TRACE("(%p)\n", this);
9427     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
9428     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
9429 }
9430
9431 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9432 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9433 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9434 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9435 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
9436 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
9437 {
9438     TRACE("(%p)\n", this);
9439     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
9440     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
9441 }
9442
9443 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
9444 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9445 {
9446     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9447
9448     TRACE("(%p %x)\n", this, flags);
9449
9450     if(flags & 2) {
9451         /* we have an array, with the number of elements stored before the first object */
9452         INT_PTR i, *ptr = (INT_PTR *)this-1;
9453
9454         for(i=*ptr-1; i>=0; i--)
9455             basic_iostream_wchar_vbase_dtor(this+i);
9456         MSVCRT_operator_delete(ptr);
9457     } else {
9458         basic_iostream_wchar_vbase_dtor(this);
9459         if(flags & 1)
9460             MSVCRT_operator_delete(this);
9461     }
9462
9463     return this;
9464 }
9465
9466 static inline basic_ios_char* basic_ofstream_char_to_basic_ios(basic_ofstream_char *ptr)
9467 {
9468     return (basic_ios_char*)((char*)ptr+basic_ofstream_char_vbtable[1]);
9469 }
9470
9471 static inline basic_ofstream_char* basic_ofstream_char_from_basic_ios(basic_ios_char *ptr)
9472 {
9473     return (basic_ofstream_char*)((char*)ptr-basic_ofstream_char_vbtable[1]);
9474 }
9475
9476 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9477 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9478 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
9479 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
9480 {
9481     basic_ios_char *basic_ios;
9482
9483     TRACE("(%p %d)\n", this, virt_init);
9484
9485     if(virt_init) {
9486         this->base.vbtable = basic_ofstream_char_vbtable;
9487         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9488         basic_ios_char_ctor(basic_ios);
9489     }else {
9490         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9491     }
9492
9493     basic_filebuf_char_ctor(&this->filebuf);
9494     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9495     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9496     return this;
9497 }
9498
9499 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
9500 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9501 static basic_ofstream_char* basic_ofstream_char_ctor_file(
9502         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
9503 {
9504     basic_ios_char *basic_ios;
9505
9506     TRACE("(%p %p %d)\n", this, file, virt_init);
9507
9508     if(virt_init) {
9509         this->base.vbtable = basic_ofstream_char_vbtable;
9510         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9511         basic_ios_char_ctor(basic_ios);
9512     }else {
9513         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9514     }
9515
9516     basic_filebuf_char_ctor_file(&this->filebuf, file);
9517     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9518     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9519     return this;
9520 }
9521
9522 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
9523 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
9524 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_copy_ctor, 12)
9525 basic_ofstream_char* __thiscall basic_ofstream_char_copy_ctor(basic_ofstream_char *this,
9526         basic_ofstream_char *copy, MSVCP_bool virt_init)
9527 {
9528     TRACE("(%p %p %d)\n", this, copy, virt_init);
9529     return basic_ofstream_char_ctor_file(this, copy->filebuf.file, virt_init);
9530 }
9531
9532 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
9533 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
9534 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 16)
9535 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
9536         const char *name, int mode, MSVCP_bool virt_init)
9537 {
9538     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9539
9540     basic_ofstream_char_ctor(this, virt_init);
9541
9542     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9543         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9544         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9545     }
9546     return this;
9547 }
9548
9549 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9550 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9551 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
9552 void __thiscall basic_ofstream_char_dtor(basic_ios_char *base)
9553 {
9554     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9555
9556     TRACE("(%p)\n", this);
9557
9558     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
9559     basic_filebuf_char_dtor(&this->filebuf);
9560 }
9561
9562 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9563 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9564 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
9565 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
9566 {
9567     TRACE("(%p)\n", this);
9568
9569     basic_ofstream_char_dtor(basic_ofstream_char_to_basic_ios(this));
9570     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
9571 }
9572
9573 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vector_dtor, 8)
9574 basic_ofstream_char* __thiscall basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9575 {
9576     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9577
9578     TRACE("(%p %x)\n", this, flags);
9579
9580     if(flags & 2) {
9581         /* we have an array, with the number of elements stored before the first object */
9582         INT_PTR i, *ptr = (INT_PTR *)this-1;
9583
9584         for(i=*ptr-1; i>=0; i--)
9585             basic_ofstream_char_vbase_dtor(this+i);
9586         MSVCRT_operator_delete(ptr);
9587     } else {
9588         basic_ofstream_char_vbase_dtor(this);
9589         if(flags & 1)
9590             MSVCRT_operator_delete(this);
9591     }
9592
9593     return this;
9594 }
9595
9596 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9597 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9598 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
9599 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
9600 {
9601     TRACE("(%p)\n", this);
9602
9603     if(!basic_filebuf_char_close(&this->filebuf)) {
9604         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9605         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9606     }
9607 }
9608
9609 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
9610 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
9611 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
9612 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
9613 {
9614     TRACE("(%p)\n", this);
9615     return basic_filebuf_char_is_open(&this->filebuf);
9616 }
9617
9618 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
9619 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
9620 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 12)
9621 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
9622         const char *name, int mode)
9623 {
9624     TRACE("(%p %s %d)\n", this, name, mode);
9625
9626     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9627         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9628         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9629     }
9630 }
9631
9632 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
9633 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
9634 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
9635 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
9636         const char *name, short mode)
9637 {
9638     basic_ofstream_char_open(this, name, mode);
9639 }
9640
9641 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9642 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9643 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
9644 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
9645 {
9646     TRACE("(%p)\n", this);
9647     return (basic_filebuf_char*)&this->filebuf;
9648 }
9649
9650 static inline basic_ios_wchar* basic_ofstream_wchar_to_basic_ios(basic_ofstream_wchar *ptr)
9651 {
9652     return (basic_ios_wchar*)((char*)ptr+basic_ofstream_wchar_vbtable[1]);
9653 }
9654
9655 static inline basic_ofstream_wchar* basic_ofstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9656 {
9657     return (basic_ofstream_wchar*)((char*)ptr-basic_ofstream_wchar_vbtable[1]);
9658 }
9659
9660 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
9661 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
9662 static basic_ofstream_wchar* basic_ofstream_wchar_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9663 {
9664     basic_ios_wchar *basic_ios;
9665
9666     TRACE("(%p %d)\n", this, virt_init);
9667
9668     if(virt_init) {
9669         this->base.vbtable = basic_ofstream_wchar_vbtable;
9670         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9671         basic_ios_wchar_ctor(basic_ios);
9672     }else {
9673         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9674     }
9675
9676     basic_filebuf_wchar_ctor(&this->filebuf);
9677     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9678     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
9679     return this;
9680 }
9681
9682 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
9683 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
9684 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor, 8)
9685 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9686 {
9687     basic_ofstream_wchar_ctor(this, virt_init);
9688     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
9689     return this;
9690 }
9691
9692 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
9693 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9694 static basic_ofstream_wchar* basic_ofstream_wchar_ctor_file(
9695         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9696 {
9697     basic_ios_wchar *basic_ios;
9698
9699     TRACE("(%p %p %d)\n", this, file, virt_init);
9700
9701     if(virt_init) {
9702         this->base.vbtable = basic_ofstream_wchar_vbtable;
9703         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9704         basic_ios_wchar_ctor(basic_ios);
9705     }else {
9706         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9707     }
9708
9709     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
9710     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9711     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
9712     return this;
9713 }
9714
9715 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
9716 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9717 static basic_ofstream_wchar* basic_ofstream_short_ctor_file(
9718         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9719 {
9720     basic_ofstream_wchar_ctor_file(this, file, virt_init);
9721     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
9722     return this;
9723 }
9724
9725 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
9726 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
9727 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_copy_ctor, 12)
9728 basic_ofstream_wchar* __thiscall basic_ofstream_short_copy_ctor(basic_ofstream_wchar *this,
9729         basic_ofstream_wchar *copy, MSVCP_bool virt_init)
9730 {
9731     TRACE("(%p %p %d)\n", this, copy, virt_init);
9732     return basic_ofstream_short_ctor_file(this, copy->filebuf.file, virt_init);
9733 }
9734
9735 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBDH@Z */
9736 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDH@Z */
9737 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name, 16)
9738 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name(basic_ofstream_wchar *this,
9739         const char *name, int mode, MSVCP_bool virt_init)
9740 {
9741     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9742
9743     basic_ofstream_short_ctor(this, virt_init);
9744
9745     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9746         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9747         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9748     }
9749     return this;
9750 }
9751
9752 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9753 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9754 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9755 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9756 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_dtor, 4)
9757 void __thiscall basic_ofstream_wchar_dtor(basic_ios_wchar *base)
9758 {
9759     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9760
9761     TRACE("(%p)\n", this);
9762
9763     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
9764     basic_filebuf_wchar_dtor(&this->filebuf);
9765 }
9766
9767 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9768 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9769 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9770 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9771 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vbase_dtor, 4)
9772 void __thiscall basic_ofstream_wchar_vbase_dtor(basic_ofstream_wchar *this)
9773 {
9774     TRACE("(%p)\n", this);
9775
9776     basic_ofstream_wchar_dtor(basic_ofstream_wchar_to_basic_ios(this));
9777     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
9778 }
9779
9780 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vector_dtor, 8)
9781 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9782 {
9783     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9784
9785     TRACE("(%p %x)\n", this, flags);
9786
9787     if(flags & 2) {
9788         /* we have an array, with the number of elements stored before the first object */
9789         INT_PTR i, *ptr = (INT_PTR *)this-1;
9790
9791         for(i=*ptr-1; i>=0; i--)
9792             basic_ofstream_wchar_vbase_dtor(this+i);
9793         MSVCRT_operator_delete(ptr);
9794     } else {
9795         basic_ofstream_wchar_vbase_dtor(this);
9796         if(flags & 1)
9797             MSVCRT_operator_delete(this);
9798     }
9799
9800     return this;
9801 }
9802
9803 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9804 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9805 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9806 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9807 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_close, 4)
9808 void __thiscall basic_ofstream_wchar_close(basic_ofstream_wchar *this)
9809 {
9810     TRACE("(%p)\n", this);
9811
9812     if(!basic_filebuf_wchar_close(&this->filebuf)) {
9813         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9814         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9815     }
9816 }
9817
9818 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
9819 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
9820 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
9821 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
9822 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_is_open, 4)
9823 MSVCP_bool __thiscall basic_ofstream_wchar_is_open(const basic_ofstream_wchar *this)
9824 {
9825     TRACE("(%p)\n", this);
9826     return basic_filebuf_wchar_is_open(&this->filebuf);
9827 }
9828
9829 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
9830 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
9831 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open, 12)
9832 void __thiscall basic_ofstream_wchar_open(basic_ofstream_wchar *this,
9833         const char *name, int mode)
9834 {
9835     TRACE("(%p %s %d)\n", this, name, mode);
9836
9837     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9838         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9839         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9840     }
9841 }
9842
9843 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
9844 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
9845 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_old, 12)
9846 void __thiscall basic_ofstream_wchar_open_old(basic_ofstream_wchar *this,
9847         const char *name, int mode)
9848 {
9849     basic_ofstream_wchar_open(this, name, mode);
9850 }
9851
9852 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9853 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9854 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9855 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9856 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_rdbuf, 4)
9857 basic_filebuf_wchar* __thiscall basic_ofstream_wchar_rdbuf(const basic_ofstream_wchar *this)
9858 {
9859     TRACE("(%p)\n", this);
9860     return (basic_filebuf_wchar*)&this->filebuf;
9861 }
9862
9863 static inline basic_ios_char* basic_ifstream_char_to_basic_ios(basic_ifstream_char *ptr)
9864 {
9865     return (basic_ios_char*)((char*)ptr+basic_ifstream_char_vbtable[1]);
9866 }
9867
9868 static inline basic_ifstream_char* basic_ifstream_char_from_basic_ios(basic_ios_char *ptr)
9869 {
9870     return (basic_ifstream_char*)((char*)ptr-basic_ifstream_char_vbtable[1]);
9871 }
9872
9873 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9874 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9875 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
9876 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
9877 {
9878     basic_ios_char *basic_ios;
9879
9880     TRACE("(%p %d)\n", this, virt_init);
9881
9882     if(virt_init) {
9883         this->base.vbtable = basic_ifstream_char_vbtable;
9884         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9885         basic_ios_char_ctor(basic_ios);
9886     }else {
9887         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9888     }
9889
9890     basic_filebuf_char_ctor(&this->filebuf);
9891     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9892     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
9893     return this;
9894 }
9895
9896 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
9897 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9898 static basic_ifstream_char* basic_ifstream_char_ctor_file(
9899         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
9900 {
9901     basic_ios_char *basic_ios;
9902
9903     TRACE("(%p %p %d)\n", this, file, virt_init);
9904
9905     if(virt_init) {
9906         this->base.vbtable = basic_ifstream_char_vbtable;
9907         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9908         basic_ios_char_ctor(basic_ios);
9909     }else {
9910         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9911     }
9912
9913     basic_filebuf_char_ctor_file(&this->filebuf, file);
9914     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9915     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
9916     return this;
9917 }
9918
9919 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
9920 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
9921 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_copy_ctor, 12)
9922 basic_ifstream_char* __thiscall basic_ifstream_char_copy_ctor(basic_ifstream_char *this,
9923         const basic_ifstream_char *copy, MSVCP_bool virt_init)
9924 {
9925     TRACE("(%p %p %d)\n", this, copy, virt_init);
9926     return basic_ifstream_char_ctor_file(this, copy->filebuf.file, virt_init);
9927 }
9928
9929 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
9930 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
9931 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 16)
9932 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
9933         const char *name, int mode, MSVCP_bool virt_init)
9934 {
9935     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9936
9937     basic_ifstream_char_ctor(this, virt_init);
9938
9939     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9940         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9941         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9942     }
9943     return this;
9944 }
9945
9946 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9947 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9948 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
9949 void __thiscall basic_ifstream_char_dtor(basic_ios_char *base)
9950 {
9951     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9952
9953     TRACE("(%p)\n", this);
9954
9955     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
9956     basic_filebuf_char_dtor(&this->filebuf);
9957 }
9958
9959 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9960 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9961 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
9962 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
9963 {
9964     TRACE("(%p)\n", this);
9965
9966     basic_ifstream_char_dtor(basic_ifstream_char_to_basic_ios(this));
9967     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
9968 }
9969
9970 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vector_dtor, 8)
9971 basic_ifstream_char* __thiscall basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9972 {
9973     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9974
9975     TRACE("(%p %x)\n", this, flags);
9976
9977     if(flags & 2) {
9978         /* we have an array, with the number of elements stored before the first object */
9979         INT_PTR i, *ptr = (INT_PTR *)this-1;
9980
9981         for(i=*ptr-1; i>=0; i--)
9982             basic_ifstream_char_vbase_dtor(this+i);
9983         MSVCRT_operator_delete(ptr);
9984     } else {
9985         basic_ifstream_char_vbase_dtor(this);
9986         if(flags & 1)
9987             MSVCRT_operator_delete(this);
9988     }
9989
9990     return this;
9991 }
9992
9993 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9994 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9995 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
9996 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
9997 {
9998     TRACE("(%p)\n", this);
9999
10000     if(!basic_filebuf_char_close(&this->filebuf)) {
10001         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10002         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10003     }
10004 }
10005
10006 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10007 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10008 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
10009 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
10010 {
10011     TRACE("(%p)\n", this);
10012     return basic_filebuf_char_is_open(&this->filebuf);
10013 }
10014
10015 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
10016 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
10017 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 12)
10018 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
10019         const char *name, int mode)
10020 {
10021     TRACE("(%p %s %d)\n", this, name, mode);
10022
10023     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
10024         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10025         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10026     }
10027 }
10028
10029 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
10030 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
10031 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
10032 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
10033         const char *name, short mode)
10034 {
10035     basic_ifstream_char_open(this, name, mode);
10036 }
10037
10038 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10039 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10040 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
10041 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
10042 {
10043     TRACE("(%p)\n", this);
10044     return (basic_filebuf_char*)&this->filebuf;
10045 }
10046
10047 static inline basic_ios_wchar* basic_ifstream_wchar_to_basic_ios(basic_ifstream_wchar *ptr)
10048 {
10049     return (basic_ios_wchar*)((char*)ptr+basic_ifstream_wchar_vbtable[1]);
10050 }
10051
10052 static inline basic_ifstream_wchar* basic_ifstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10053 {
10054     return (basic_ifstream_wchar*)((char*)ptr-basic_ifstream_wchar_vbtable[1]);
10055 }
10056
10057 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10058 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10059 static basic_ifstream_wchar* basic_ifstream_wchar_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10060 {
10061     basic_ios_wchar *basic_ios;
10062
10063     TRACE("(%p %d)\n", this, virt_init);
10064
10065     if(virt_init) {
10066         this->base.vbtable = basic_ifstream_wchar_vbtable;
10067         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10068         basic_ios_wchar_ctor(basic_ios);
10069     }else {
10070         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10071     }
10072
10073     basic_filebuf_wchar_ctor(&this->filebuf);
10074     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10075     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10076     return this;
10077 }
10078
10079 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10080 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10081 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor, 8)
10082 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10083 {
10084     basic_ifstream_wchar_ctor(this, virt_init);
10085     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10086     return this;
10087 }
10088
10089 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10090 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10091 static basic_ifstream_wchar* basic_ifstream_wchar_ctor_file(
10092         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10093 {
10094     basic_ios_wchar *basic_ios;
10095
10096     TRACE("(%p %p %d)\n", this, file, virt_init);
10097
10098     if(virt_init) {
10099         this->base.vbtable = basic_ifstream_wchar_vbtable;
10100         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10101         basic_ios_wchar_ctor(basic_ios);
10102     }else {
10103         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10104     }
10105
10106     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10107     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10108     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10109     return this;
10110 }
10111
10112 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10113 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10114 static basic_ifstream_wchar* basic_ifstream_short_ctor_file(
10115         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10116 {
10117     basic_ifstream_wchar_ctor_file(this, file, virt_init);
10118     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10119     return this;
10120 }
10121
10122 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
10123 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
10124 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_copy_ctor, 12)
10125 basic_ifstream_wchar* __thiscall basic_ifstream_short_copy_ctor(basic_ifstream_wchar *this,
10126         basic_ifstream_wchar *copy, MSVCP_bool virt_init)
10127 {
10128     TRACE("(%p %p %d)\n", this, copy, virt_init);
10129     return basic_ifstream_short_ctor_file(this, copy->filebuf.file, virt_init);
10130 }
10131
10132 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBDH@Z */
10133 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDH@Z */
10134 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name, 16)
10135 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name(basic_ifstream_wchar *this,
10136         const char *name, int mode, MSVCP_bool virt_init)
10137 {
10138     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10139
10140     basic_ifstream_short_ctor(this, virt_init);
10141
10142     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
10143         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10144         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10145     }
10146     return this;
10147 }
10148
10149 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10150 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10151 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10152 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10153 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_dtor, 4)
10154 void __thiscall basic_ifstream_wchar_dtor(basic_ios_wchar *base)
10155 {
10156     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10157
10158     TRACE("(%p)\n", this);
10159
10160     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
10161     basic_filebuf_wchar_dtor(&this->filebuf);
10162 }
10163
10164 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10165 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10166 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10167 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10168 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vbase_dtor, 4)
10169 void __thiscall basic_ifstream_wchar_vbase_dtor(basic_ifstream_wchar *this)
10170 {
10171     TRACE("(%p)\n", this);
10172
10173     basic_ifstream_wchar_dtor(basic_ifstream_wchar_to_basic_ios(this));
10174     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
10175 }
10176
10177 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vector_dtor, 8)
10178 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10179 {
10180     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10181
10182     TRACE("(%p %x)\n", this, flags);
10183
10184     if(flags & 2) {
10185         /* we have an array, with the number of elements stored before the first object */
10186         INT_PTR i, *ptr = (INT_PTR *)this-1;
10187
10188         for(i=*ptr-1; i>=0; i--)
10189             basic_ifstream_wchar_vbase_dtor(this+i);
10190         MSVCRT_operator_delete(ptr);
10191     } else {
10192         basic_ifstream_wchar_vbase_dtor(this);
10193         if(flags & 1)
10194             MSVCRT_operator_delete(this);
10195     }
10196
10197     return this;
10198 }
10199
10200 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10201 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10202 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10203 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10204 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_close, 4)
10205 void __thiscall basic_ifstream_wchar_close(basic_ifstream_wchar *this)
10206 {
10207     TRACE("(%p)\n", this);
10208
10209     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10210         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10211         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10212     }
10213 }
10214
10215 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10216 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10217 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10218 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10219 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_is_open, 4)
10220 MSVCP_bool __thiscall basic_ifstream_wchar_is_open(const basic_ifstream_wchar *this)
10221 {
10222     TRACE("(%p)\n", this);
10223     return basic_filebuf_wchar_is_open(&this->filebuf);
10224 }
10225
10226 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
10227 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
10228 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open, 12)
10229 void __thiscall basic_ifstream_wchar_open(basic_ifstream_wchar *this,
10230         const char *name, int mode)
10231 {
10232     TRACE("(%p %s %d)\n", this, name, mode);
10233
10234     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
10235         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10236         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10237     }
10238 }
10239
10240 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
10241 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
10242 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_old, 12)
10243 void __thiscall basic_ifstream_wchar_open_old(basic_ifstream_wchar *this,
10244         const char *name, short mode)
10245 {
10246     basic_ifstream_wchar_open(this, name, mode);
10247 }
10248
10249 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10250 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10251 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10252 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10253 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_rdbuf, 4)
10254 basic_filebuf_wchar* __thiscall basic_ifstream_wchar_rdbuf(const basic_ifstream_wchar *this)
10255 {
10256     TRACE("(%p)\n", this);
10257     return (basic_filebuf_wchar*)&this->filebuf;
10258 }
10259
10260 static inline basic_ios_char* basic_fstream_char_to_basic_ios(basic_fstream_char *ptr)
10261 {
10262     return (basic_ios_char*)((char*)ptr+basic_fstream_char_vbtable1[1]);
10263 }
10264
10265 static inline basic_fstream_char* basic_fstream_char_from_basic_ios(basic_ios_char *ptr)
10266 {
10267     return (basic_fstream_char*)((char*)ptr-basic_fstream_char_vbtable1[1]);
10268 }
10269
10270 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10271 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10272 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
10273 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
10274 {
10275     basic_ios_char *basic_ios;
10276
10277     TRACE("(%p %d)\n", this, virt_init);
10278
10279     if(virt_init) {
10280         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10281         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10282         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10283         basic_ios_char_ctor(basic_ios);
10284     }else {
10285         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10286     }
10287
10288     basic_filebuf_char_ctor(&this->filebuf);
10289     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10290     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10291     return this;
10292 }
10293
10294 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10295 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10296 static basic_fstream_char* basic_fstream_char_ctor_file(basic_fstream_char *this,
10297         FILE *file, MSVCP_bool virt_init)
10298 {
10299     basic_ios_char *basic_ios;
10300
10301     TRACE("(%p %p %d)\n", this, file, virt_init);
10302
10303     if(virt_init) {
10304         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10305         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10306         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10307         basic_ios_char_ctor(basic_ios);
10308     }else {
10309         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10310     }
10311
10312     basic_filebuf_char_ctor_file(&this->filebuf, file);
10313     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10314     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10315     return this;
10316 }
10317
10318 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
10319 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
10320 DEFINE_THISCALL_WRAPPER(basic_fstream_char_copy_ctor, 12)
10321 basic_fstream_char* __thiscall basic_fstream_char_copy_ctor(basic_fstream_char *this,
10322         basic_fstream_char *copy, MSVCP_bool virt_init)
10323 {
10324     TRACE("(%p %p %d)\n", this, copy, virt_init);
10325     return basic_fstream_char_ctor_file(this, copy->filebuf.file, virt_init);
10326 }
10327
10328 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
10329 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
10330 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 16)
10331 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
10332         const char *name, int mode, MSVCP_bool virt_init)
10333 {
10334     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10335
10336     basic_fstream_char_ctor(this, virt_init);
10337
10338     if(!basic_filebuf_char_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10339         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10340         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10341     }
10342     return this;
10343 }
10344
10345 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10346 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10347 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
10348 void __thiscall basic_fstream_char_dtor(basic_ios_char *base)
10349 {
10350     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10351
10352     TRACE("(%p)\n", this);
10353
10354     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
10355     basic_filebuf_char_dtor(&this->filebuf);
10356 }
10357
10358 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10359 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10360 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
10361 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
10362 {
10363     TRACE("(%p)\n", this);
10364
10365     basic_fstream_char_dtor(basic_fstream_char_to_basic_ios(this));
10366     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
10367 }
10368
10369 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vector_dtor, 8)
10370 basic_fstream_char* __thiscall basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10371 {
10372     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10373
10374     TRACE("(%p %x)\n", this, flags);
10375
10376     if(flags & 2) {
10377         /* we have an array, with the number of elements stored before the first object */
10378         INT_PTR i, *ptr = (INT_PTR *)this-1;
10379
10380         for(i=*ptr-1; i>=0; i--)
10381             basic_fstream_char_vbase_dtor(this+i);
10382         MSVCRT_operator_delete(ptr);
10383     } else {
10384         basic_fstream_char_vbase_dtor(this);
10385         if(flags & 1)
10386             MSVCRT_operator_delete(this);
10387     }
10388
10389     return this;
10390 }
10391
10392 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10393 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10394 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
10395 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
10396 {
10397     TRACE("(%p)\n", this);
10398
10399     if(!basic_filebuf_char_close(&this->filebuf)) {
10400         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10401         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10402     }
10403 }
10404
10405 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10406 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10407 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
10408 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
10409 {
10410     TRACE("(%p)\n", this);
10411     return basic_filebuf_char_is_open(&this->filebuf);
10412 }
10413
10414 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
10415 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
10416 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 12)
10417 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
10418         const char *name, int mode)
10419 {
10420     TRACE("(%p %s %d)\n", this, name, mode);
10421
10422     if(!basic_filebuf_char_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10423         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10424         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10425     }
10426 }
10427
10428 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
10429 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
10430 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
10431 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
10432         const char *name, int mode)
10433 {
10434     basic_fstream_char_open(this, name, mode);
10435 }
10436
10437 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10438 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10439 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
10440 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
10441 {
10442     TRACE("(%p)\n", this);
10443     return (basic_filebuf_char*)&this->filebuf;
10444 }
10445
10446 static inline basic_ios_wchar* basic_fstream_wchar_to_basic_ios(basic_fstream_wchar *ptr)
10447 {
10448     return (basic_ios_wchar*)((char*)ptr+basic_fstream_wchar_vbtable1[1]);
10449 }
10450
10451 static inline basic_fstream_wchar* basic_fstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10452 {
10453     return (basic_fstream_wchar*)((char*)ptr-basic_fstream_wchar_vbtable1[1]);
10454 }
10455
10456 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10457 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10458 static basic_fstream_wchar* basic_fstream_wchar_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10459 {
10460     basic_ios_wchar *basic_ios;
10461
10462     TRACE("(%p %d)\n", this, virt_init);
10463
10464     if(virt_init) {
10465         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10466         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10467         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10468         basic_ios_wchar_ctor(basic_ios);
10469     }else {
10470         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10471     }
10472
10473     basic_filebuf_wchar_ctor(&this->filebuf);
10474     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10475     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10476     return this;
10477 }
10478
10479 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10480 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10481 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor, 8)
10482 basic_fstream_wchar* __thiscall basic_fstream_short_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10483 {
10484     basic_fstream_wchar_ctor(this, virt_init);
10485     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
10486     return this;
10487 }
10488
10489 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10490 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10491 static basic_fstream_wchar* basic_fstream_wchar_ctor_file(basic_fstream_wchar *this,
10492         FILE *file, MSVCP_bool virt_init)
10493 {
10494     basic_ios_wchar *basic_ios;
10495
10496     TRACE("(%p %p %d)\n", this, file, virt_init);
10497
10498     if(virt_init) {
10499         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10500         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10501         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10502         basic_ios_wchar_ctor(basic_ios);
10503     }else {
10504         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10505     }
10506
10507     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10508     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10509     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10510     return this;
10511 }
10512
10513 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10514 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10515 static basic_fstream_wchar* basic_fstream_short_ctor_file(basic_fstream_wchar *this,
10516         FILE *file, MSVCP_bool virt_init)
10517 {
10518     basic_fstream_wchar_ctor_file(this, file, virt_init);
10519     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
10520     return this;
10521 }
10522
10523 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
10524 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
10525 DEFINE_THISCALL_WRAPPER(basic_fstream_short_copy_ctor, 12)
10526 basic_fstream_wchar* __thiscall basic_fstream_short_copy_ctor(basic_fstream_wchar *this,
10527         basic_fstream_wchar *copy, MSVCP_bool virt_init)
10528 {
10529     TRACE("(%p %p %d)\n", this, copy, virt_init);
10530     return basic_fstream_short_ctor_file(this, copy->filebuf.file, virt_init);
10531 }
10532
10533 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10534 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10535 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name, 16)
10536 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name(basic_fstream_wchar *this,
10537         const char *name, int mode, MSVCP_bool virt_init)
10538 {
10539     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10540
10541     basic_fstream_short_ctor(this, virt_init);
10542
10543     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10544         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10545         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10546     }
10547     return this;
10548 }
10549
10550 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10551 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10552 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10553 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10554 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_dtor, 4)
10555 void __thiscall basic_fstream_wchar_dtor(basic_ios_wchar *base)
10556 {
10557     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10558
10559     TRACE("(%p)\n", this);
10560
10561     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
10562     basic_filebuf_wchar_dtor(&this->filebuf);
10563 }
10564
10565 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10566 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10567 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10568 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10569 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vbase_dtor, 4)
10570 void __thiscall basic_fstream_wchar_vbase_dtor(basic_fstream_wchar *this)
10571 {
10572     TRACE("(%p)\n", this);
10573
10574     basic_fstream_wchar_dtor(basic_fstream_wchar_to_basic_ios(this));
10575     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
10576 }
10577
10578 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vector_dtor, 8)
10579 basic_fstream_wchar* __thiscall basic_fstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10580 {
10581     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10582
10583     TRACE("(%p %x)\n", this, flags);
10584
10585     if(flags & 2) {
10586         /* we have an array, with the number of elements stored before the first object */
10587         INT_PTR i, *ptr = (INT_PTR *)this-1;
10588
10589         for(i=*ptr-1; i>=0; i--)
10590             basic_fstream_wchar_vbase_dtor(this+i);
10591         MSVCRT_operator_delete(ptr);
10592     } else {
10593         basic_fstream_wchar_vbase_dtor(this);
10594         if(flags & 1)
10595             MSVCRT_operator_delete(this);
10596     }
10597
10598     return this;
10599 }
10600
10601 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10602 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10603 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10604 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10605 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_close, 4)
10606 void __thiscall basic_fstream_wchar_close(basic_fstream_wchar *this)
10607 {
10608     TRACE("(%p)\n", this);
10609
10610     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10611         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10612         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10613     }
10614 }
10615
10616 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10617 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10618 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10619 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10620 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_is_open, 4)
10621 MSVCP_bool __thiscall basic_fstream_wchar_is_open(const basic_fstream_wchar *this)
10622 {
10623     TRACE("(%p)\n", this);
10624     return basic_filebuf_wchar_is_open(&this->filebuf);
10625 }
10626
10627 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
10628 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
10629 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open, 12)
10630 void __thiscall basic_fstream_wchar_open(basic_fstream_wchar *this,
10631         const char *name, int mode)
10632 {
10633     TRACE("(%p %s %d)\n", this, name, mode);
10634
10635     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10636         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10637         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10638     }
10639 }
10640
10641 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
10642 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
10643 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_old, 12)
10644 void __thiscall basic_fstream_wchar_open_old(basic_fstream_wchar *this,
10645         const char *name, int mode)
10646 {
10647     basic_fstream_wchar_open(this, name, mode);
10648 }
10649
10650 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10651 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10652 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10653 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10654 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_rdbuf, 4)
10655 basic_filebuf_wchar* __thiscall basic_fstream_wchar_rdbuf(const basic_fstream_wchar *this)
10656 {
10657     TRACE("(%p)\n", this);
10658     return (basic_filebuf_wchar*)&this->filebuf;
10659 }
10660
10661 static inline basic_ios_char* basic_ostringstream_char_to_basic_ios(basic_ostringstream_char *ptr)
10662 {
10663     return (basic_ios_char*)((char*)ptr+basic_ostringstream_char_vbtable[1]);
10664 }
10665
10666 static inline basic_ostringstream_char* basic_ostringstream_char_from_basic_ios(basic_ios_char *ptr)
10667 {
10668     return (basic_ostringstream_char*)((char*)ptr-basic_ostringstream_char_vbtable[1]);
10669 }
10670
10671 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
10672 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
10673 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_str, 16)
10674 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_str(basic_ostringstream_char *this,
10675         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10676 {
10677     basic_ios_char *basic_ios;
10678
10679     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10680
10681     if(virt_init) {
10682         this->base.vbtable = basic_ostringstream_char_vbtable;
10683         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10684         basic_ios_char_ctor(basic_ios);
10685     }else {
10686         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10687     }
10688
10689     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10690     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10691     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10692     return this;
10693 }
10694
10695 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
10696 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
10697 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_mode, 12)
10698 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_mode(
10699         basic_ostringstream_char *this, int mode, MSVCP_bool virt_init)
10700 {
10701     basic_ios_char *basic_ios;
10702
10703     TRACE("(%p %d %d)\n", this, mode, virt_init);
10704
10705     if(virt_init) {
10706         this->base.vbtable = basic_ostringstream_char_vbtable;
10707         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10708         basic_ios_char_ctor(basic_ios);
10709     }else {
10710         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10711     }
10712
10713     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10714     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10715     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10716     return this;
10717 }
10718
10719 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10720 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10721 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor, 8)
10722 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor(
10723         basic_ostringstream_char *this, MSVCP_bool virt_init)
10724 {
10725     return basic_ostringstream_char_ctor_mode(this, 0, virt_init);
10726 }
10727
10728 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
10729 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
10730 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_dtor, 4)
10731 void __thiscall basic_ostringstream_char_dtor(basic_ios_char *base)
10732 {
10733     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10734
10735     TRACE("(%p)\n", this);
10736
10737     basic_stringbuf_char_dtor(&this->strbuf);
10738     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
10739 }
10740
10741 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10742 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10743 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vbase_dtor, 4)
10744 void __thiscall basic_ostringstream_char_vbase_dtor(basic_ostringstream_char *this)
10745 {
10746     TRACE("(%p)\n", this);
10747
10748     basic_ostringstream_char_dtor(basic_ostringstream_char_to_basic_ios(this));
10749     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
10750 }
10751
10752 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vector_dtor, 8)
10753 basic_ostringstream_char* __thiscall basic_ostringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10754 {
10755     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10756
10757     TRACE("(%p %x)\n", this, flags);
10758
10759     if(flags & 2) {
10760         /* we have an array, with the number of elements stored before the first object */
10761         INT_PTR i, *ptr = (INT_PTR *)this-1;
10762
10763         for(i=*ptr-1; i>=0; i--)
10764             basic_ostringstream_char_vbase_dtor(this+i);
10765         MSVCRT_operator_delete(ptr);
10766     } else {
10767         basic_ostringstream_char_vbase_dtor(this);
10768         if(flags & 1)
10769             MSVCRT_operator_delete(this);
10770     }
10771
10772     return this;
10773 }
10774
10775 /* ?rdbuf@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPAV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
10776 /* ?rdbuf@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEAV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
10777 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_rdbuf, 4)
10778 basic_stringbuf_char* __thiscall basic_ostringstream_char_rdbuf(const basic_ostringstream_char *this)
10779 {
10780     TRACE("(%p)\n", this);
10781     return (basic_stringbuf_char*)&this->strbuf;
10782 }
10783
10784 /* ?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
10785 /* ?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
10786 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_set, 8)
10787 void __thiscall basic_ostringstream_char_str_set(basic_ostringstream_char *this, const basic_string_char *str)
10788 {
10789     TRACE("(%p %p)\n", this, str);
10790     basic_stringbuf_char_str_set(&this->strbuf, str);
10791 }
10792
10793 /* ?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
10794 /* ?str@?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
10795 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_get, 8)
10796 basic_string_char* __thiscall basic_ostringstream_char_str_get(const basic_ostringstream_char *this, basic_string_char *ret)
10797 {
10798     TRACE("(%p %p)\n", this, ret);
10799     return basic_stringbuf_char_str_get(&this->strbuf, ret);
10800 }
10801
10802 static inline basic_ios_wchar* basic_ostringstream_wchar_to_basic_ios(basic_ostringstream_wchar *ptr)
10803 {
10804     return (basic_ios_wchar*)((char*)ptr+basic_ostringstream_wchar_vbtable[1]);
10805 }
10806
10807 static inline basic_ostringstream_wchar* basic_ostringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10808 {
10809     return (basic_ostringstream_wchar*)((char*)ptr-basic_ostringstream_wchar_vbtable[1]);
10810 }
10811
10812 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z */
10813 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@AEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z */
10814 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_str(basic_ostringstream_wchar *this,
10815         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10816 {
10817     basic_ios_wchar *basic_ios;
10818
10819     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10820
10821     if(virt_init) {
10822         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10823         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10824         basic_ios_wchar_ctor(basic_ios);
10825     }else {
10826         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10827     }
10828
10829     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10830     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10831     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10832     return this;
10833 }
10834
10835 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z */
10836 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@AEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z */
10837 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_str, 16)
10838 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_str(basic_ostringstream_wchar *this,
10839         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10840 {
10841     basic_ostringstream_wchar_ctor_str(this, str, mode, virt_init);
10842     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10843     return this;
10844 }
10845
10846 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
10847 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
10848 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_mode(
10849         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10850 {
10851     basic_ios_wchar *basic_ios;
10852
10853     TRACE("(%p %d %d)\n", this, mode, virt_init);
10854
10855     if(virt_init) {
10856         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10857         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10858         basic_ios_wchar_ctor(basic_ios);
10859     }else {
10860         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10861     }
10862
10863     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10864     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10865     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10866     return this;
10867 }
10868
10869 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
10870 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
10871 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_mode, 12)
10872 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_mode(
10873         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10874 {
10875     basic_ostringstream_wchar_ctor_mode(this, mode, virt_init);
10876     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10877     return this;
10878 }
10879
10880 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10881 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10882 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor, 8)
10883 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor(
10884         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
10885 {
10886     return basic_ostringstream_short_ctor_mode(this, 0, virt_init);
10887 }
10888
10889 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
10890 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
10891 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
10892 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
10893 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_dtor, 4)
10894 void __thiscall basic_ostringstream_wchar_dtor(basic_ios_wchar *base)
10895 {
10896     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10897
10898     TRACE("(%p)\n", this);
10899
10900     basic_stringbuf_wchar_dtor(&this->strbuf);
10901     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
10902 }
10903
10904 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
10905 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
10906 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10907 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10908 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vbase_dtor, 4)
10909 void __thiscall basic_ostringstream_wchar_vbase_dtor(basic_ostringstream_wchar *this)
10910 {
10911     TRACE("(%p)\n", this);
10912
10913     basic_ostringstream_wchar_dtor(basic_ostringstream_wchar_to_basic_ios(this));
10914     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
10915 }
10916
10917 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vector_dtor, 8)
10918 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10919 {
10920     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10921
10922     TRACE("(%p %x)\n", this, flags);
10923
10924     if(flags & 2) {
10925         /* we have an array, with the number of elements stored before the first object */
10926         INT_PTR i, *ptr = (INT_PTR *)this-1;
10927
10928         for(i=*ptr-1; i>=0; i--)
10929             basic_ostringstream_wchar_vbase_dtor(this+i);
10930         MSVCRT_operator_delete(ptr);
10931     } else {
10932         basic_ostringstream_wchar_vbase_dtor(this);
10933         if(flags & 1)
10934             MSVCRT_operator_delete(this);
10935     }
10936
10937     return this;
10938 }
10939
10940 /* ?rdbuf@?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPAV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
10941 /* ?rdbuf@?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBAPEAV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
10942 /* ?rdbuf@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBEPAV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
10943 /* ?rdbuf@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBAPEAV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
10944 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_rdbuf, 4)
10945 basic_stringbuf_wchar* __thiscall basic_ostringstream_wchar_rdbuf(const basic_ostringstream_wchar *this)
10946 {
10947     TRACE("(%p)\n", this);
10948     return (basic_stringbuf_wchar*)&this->strbuf;
10949 }
10950
10951 /* ?str@?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@@Z */
10952 /* ?str@?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXAEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@@Z */
10953 /* ?str@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z */
10954 /* ?str@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXAEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z */
10955 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_set, 8)
10956 void __thiscall basic_ostringstream_wchar_str_set(basic_ostringstream_wchar *this, const basic_string_wchar *str)
10957 {
10958     TRACE("(%p %p)\n", this, str);
10959     basic_stringbuf_wchar_str_set(&this->strbuf, str);
10960 }
10961
10962 /* ?str@?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBE?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
10963 /* ?str@?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
10964 /* ?str@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
10965 /* ?str@?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBA?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
10966 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_get, 8)
10967 basic_string_wchar* __thiscall basic_ostringstream_wchar_str_get(const basic_ostringstream_wchar *this, basic_string_wchar *ret)
10968 {
10969     TRACE("(%p %p)\n", this, ret);
10970     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
10971 }
10972
10973 static inline basic_ios_char* basic_istringstream_char_to_basic_ios(basic_istringstream_char *ptr)
10974 {
10975     return (basic_ios_char*)((char*)ptr+basic_istringstream_char_vbtable[1]);
10976 }
10977
10978 static inline basic_istringstream_char* basic_istringstream_char_from_basic_ios(basic_ios_char *ptr)
10979 {
10980     return (basic_istringstream_char*)((char*)ptr-basic_istringstream_char_vbtable[1]);
10981 }
10982
10983 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
10984 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
10985 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_str, 16)
10986 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_str(basic_istringstream_char *this,
10987         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10988 {
10989     basic_ios_char *basic_ios;
10990
10991     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10992
10993     if(virt_init) {
10994         this->base.vbtable = basic_istringstream_char_vbtable;
10995         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10996         basic_ios_char_ctor(basic_ios);
10997     }else {
10998         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10999     }
11000
11001     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
11002     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11003     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11004     return this;
11005 }
11006
11007 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11008 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11009 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_mode, 12)
11010 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_mode(
11011         basic_istringstream_char *this, int mode, MSVCP_bool virt_init)
11012 {
11013     basic_ios_char *basic_ios;
11014
11015     TRACE("(%p %d %d)\n", this, mode, virt_init);
11016
11017     if(virt_init) {
11018         this->base.vbtable = basic_istringstream_char_vbtable;
11019         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11020         basic_ios_char_ctor(basic_ios);
11021     }else {
11022         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11023     }
11024
11025     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11026     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11027     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11028     return this;
11029 }
11030
11031 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11032 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11033 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor, 8)
11034 basic_istringstream_char* __thiscall basic_istringstream_char_ctor(
11035         basic_istringstream_char *this, MSVCP_bool virt_init)
11036 {
11037     return basic_istringstream_char_ctor_mode(this, 0, virt_init);
11038 }
11039
11040 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11041 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11042 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_dtor, 4)
11043 void __thiscall basic_istringstream_char_dtor(basic_ios_char *base)
11044 {
11045     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11046
11047     TRACE("(%p)\n", this);
11048
11049     basic_stringbuf_char_dtor(&this->strbuf);
11050     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11051 }
11052
11053 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11054 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11055 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vbase_dtor, 4)
11056 void __thiscall basic_istringstream_char_vbase_dtor(basic_istringstream_char *this)
11057 {
11058     TRACE("(%p)\n", this);
11059
11060     basic_istringstream_char_dtor(basic_istringstream_char_to_basic_ios(this));
11061     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
11062 }
11063
11064 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vector_dtor, 8)
11065 basic_istringstream_char* __thiscall basic_istringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11066 {
11067     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11068
11069     TRACE("(%p %x)\n", this, flags);
11070
11071     if(flags & 2) {
11072         /* we have an array, with the number of elements stored before the first object */
11073         INT_PTR i, *ptr = (INT_PTR *)this-1;
11074
11075         for(i=*ptr-1; i>=0; i--)
11076             basic_istringstream_char_vbase_dtor(this+i);
11077         MSVCRT_operator_delete(ptr);
11078     } else {
11079         basic_istringstream_char_vbase_dtor(this);
11080         if(flags & 1)
11081             MSVCRT_operator_delete(this);
11082     }
11083
11084     return this;
11085 }
11086
11087 /* ?rdbuf@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPAV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
11088 /* ?rdbuf@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEAV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
11089 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_rdbuf, 4)
11090 basic_stringbuf_char* __thiscall basic_istringstream_char_rdbuf(const basic_istringstream_char *this)
11091 {
11092     TRACE("(%p)\n", this);
11093     return (basic_stringbuf_char*)&this->strbuf;
11094 }
11095
11096 /* ?str@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
11097 /* ?str@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
11098 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_set, 8)
11099 void __thiscall basic_istringstream_char_str_set(basic_istringstream_char *this, const basic_string_char *str)
11100 {
11101     TRACE("(%p %p)\n", this, str);
11102     basic_stringbuf_char_str_set(&this->strbuf, str);
11103 }
11104
11105 /* ?str@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
11106 /* ?str@?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
11107 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_get, 8)
11108 basic_string_char* __thiscall basic_istringstream_char_str_get(const basic_istringstream_char *this, basic_string_char *ret)
11109 {
11110     TRACE("(%p %p)\n", this, ret);
11111     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11112 }
11113
11114 static inline basic_ios_wchar* basic_istringstream_wchar_to_basic_ios(basic_istringstream_wchar *ptr)
11115 {
11116     return (basic_ios_wchar*)((char*)ptr+basic_istringstream_wchar_vbtable[1]);
11117 }
11118
11119 static inline basic_istringstream_wchar* basic_istringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11120 {
11121     return (basic_istringstream_wchar*)((char*)ptr-basic_istringstream_wchar_vbtable[1]);
11122 }
11123
11124 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z */
11125 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@AEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z */
11126 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_str(basic_istringstream_wchar *this,
11127         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11128 {
11129     basic_ios_wchar *basic_ios;
11130
11131     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11132
11133     if(virt_init) {
11134         this->base.vbtable = basic_istringstream_wchar_vbtable;
11135         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11136         basic_ios_wchar_ctor(basic_ios);
11137     }else {
11138         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11139     }
11140
11141     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
11142     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11143     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11144     return this;
11145 }
11146
11147 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z */
11148 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@AEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z */
11149 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_str, 16)
11150 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_str(basic_istringstream_wchar *this,
11151         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11152 {
11153     basic_istringstream_wchar_ctor_str(this, str, mode, virt_init);
11154     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11155     return this;
11156 }
11157
11158 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11159 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11160 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_mode(
11161         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11162 {
11163     basic_ios_wchar *basic_ios;
11164
11165     TRACE("(%p %d %d)\n", this, mode, virt_init);
11166
11167     if(virt_init) {
11168         this->base.vbtable = basic_istringstream_wchar_vbtable;
11169         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11170         basic_ios_wchar_ctor(basic_ios);
11171     }else {
11172         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11173     }
11174
11175     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11176     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11177     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11178     return this;
11179 }
11180
11181 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11182 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11183 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_mode, 12)
11184 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_mode(
11185         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11186 {
11187     basic_istringstream_wchar_ctor_mode(this, mode, virt_init);
11188     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11189     return this;
11190 }
11191
11192 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11193 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11194 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor, 8)
11195 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor(
11196         basic_istringstream_wchar *this, MSVCP_bool virt_init)
11197 {
11198     return basic_istringstream_short_ctor_mode(this, 0, virt_init);
11199 }
11200
11201 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11202 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11203 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11204 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11205 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_dtor, 4)
11206 void __thiscall basic_istringstream_wchar_dtor(basic_ios_wchar *base)
11207 {
11208     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11209
11210     TRACE("(%p)\n", this);
11211
11212     basic_stringbuf_wchar_dtor(&this->strbuf);
11213     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
11214 }
11215
11216 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11217 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11218 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11219 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11220 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vbase_dtor, 4)
11221 void __thiscall basic_istringstream_wchar_vbase_dtor(basic_istringstream_wchar *this)
11222 {
11223     TRACE("(%p)\n", this);
11224
11225     basic_istringstream_wchar_dtor(basic_istringstream_wchar_to_basic_ios(this));
11226     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
11227 }
11228
11229 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vector_dtor, 8)
11230 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11231 {
11232     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11233
11234     TRACE("(%p %x)\n", this, flags);
11235
11236     if(flags & 2) {
11237         /* we have an array, with the number of elements stored before the first object */
11238         INT_PTR i, *ptr = (INT_PTR *)this-1;
11239
11240         for(i=*ptr-1; i>=0; i--)
11241             basic_istringstream_wchar_vbase_dtor(this+i);
11242         MSVCRT_operator_delete(ptr);
11243     } else {
11244         basic_istringstream_wchar_vbase_dtor(this);
11245         if(flags & 1)
11246             MSVCRT_operator_delete(this);
11247     }
11248
11249     return this;
11250 }
11251
11252 /* ?rdbuf@?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPAV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
11253 /* ?rdbuf@?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBAPEAV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
11254 /* ?rdbuf@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBEPAV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
11255 /* ?rdbuf@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBAPEAV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
11256 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_rdbuf, 4)
11257 basic_stringbuf_wchar* __thiscall basic_istringstream_wchar_rdbuf(const basic_istringstream_wchar *this)
11258 {
11259     TRACE("(%p)\n", this);
11260     return (basic_stringbuf_wchar*)&this->strbuf;
11261 }
11262
11263 /* ?str@?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@@Z */
11264 /* ?str@?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXAEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@@Z */
11265 /* ?str@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z */
11266 /* ?str@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXAEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z */
11267 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_set, 8)
11268 void __thiscall basic_istringstream_wchar_str_set(basic_istringstream_wchar *this, const basic_string_wchar *str)
11269 {
11270     TRACE("(%p %p)\n", this, str);
11271     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11272 }
11273
11274 /* ?str@?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBE?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
11275 /* ?str@?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
11276 /* ?str@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
11277 /* ?str@?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBA?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
11278 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_get, 8)
11279 basic_string_wchar* __thiscall basic_istringstream_wchar_str_get(const basic_istringstream_wchar *this, basic_string_wchar *ret)
11280 {
11281     TRACE("(%p %p)\n", this, ret);
11282     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11283 }
11284
11285 static inline basic_ios_char* basic_stringstream_char_to_basic_ios(basic_stringstream_char *ptr)
11286 {
11287     return (basic_ios_char*)((char*)ptr+basic_stringstream_char_vbtable1[1]);
11288 }
11289
11290 static inline basic_stringstream_char* basic_stringstream_char_from_basic_ios(basic_ios_char *ptr)
11291 {
11292     return (basic_stringstream_char*)((char*)ptr-basic_stringstream_char_vbtable1[1]);
11293 }
11294
11295 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
11296 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
11297 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_str, 16)
11298 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_str(basic_stringstream_char *this,
11299         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11300 {
11301     basic_ios_char *basic_ios;
11302
11303     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11304
11305     if(virt_init) {
11306         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11307         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11308         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11309         basic_ios_char_ctor(basic_ios);
11310     }else {
11311         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11312     }
11313
11314     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode);
11315     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11316     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11317     return this;
11318 }
11319
11320 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11321 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11322 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_mode, 12)
11323 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_mode(
11324         basic_stringstream_char *this, int mode, MSVCP_bool virt_init)
11325 {
11326     basic_ios_char *basic_ios;
11327
11328     TRACE("(%p %d %d)\n", this, mode, virt_init);
11329
11330     if(virt_init) {
11331         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11332         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11333         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11334         basic_ios_char_ctor(basic_ios);
11335     }else {
11336         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11337     }
11338
11339     basic_stringbuf_char_ctor_mode(&this->strbuf, mode);
11340     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11341     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11342     return this;
11343 }
11344
11345 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11346 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11347 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor, 8)
11348 basic_stringstream_char* __thiscall basic_stringstream_char_ctor(
11349         basic_stringstream_char *this, MSVCP_bool virt_init)
11350 {
11351     return basic_stringstream_char_ctor_mode(
11352             this, OPENMODE_out|OPENMODE_in, virt_init);
11353 }
11354
11355 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11356 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11357 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_dtor, 4)
11358 void __thiscall basic_stringstream_char_dtor(basic_ios_char *base)
11359 {
11360     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11361
11362     TRACE("(%p)\n", this);
11363
11364     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11365     basic_stringbuf_char_dtor(&this->strbuf);
11366 }
11367
11368 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11369 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11370 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vbase_dtor, 4)
11371 void __thiscall basic_stringstream_char_vbase_dtor(basic_stringstream_char *this)
11372 {
11373     TRACE("(%p)\n", this);
11374
11375     basic_stringstream_char_dtor(basic_stringstream_char_to_basic_ios(this));
11376     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11377 }
11378
11379 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vector_dtor, 8)
11380 basic_stringstream_char* __thiscall basic_stringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11381 {
11382     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11383
11384     TRACE("(%p %x)\n", this, flags);
11385
11386     if(flags & 2) {
11387         /* we have an array, with the number of elements stored before the first object */
11388         INT_PTR i, *ptr = (INT_PTR *)this-1;
11389
11390         for(i=*ptr-1; i>=0; i--)
11391             basic_stringstream_char_vbase_dtor(this+i);
11392         MSVCRT_operator_delete(ptr);
11393     } else {
11394         basic_stringstream_char_vbase_dtor(this);
11395         if(flags & 1)
11396             MSVCRT_operator_delete(this);
11397     }
11398
11399     return this;
11400 }
11401
11402 /* ?rdbuf@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBEPAV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
11403 /* ?rdbuf@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBAPEAV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
11404 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_rdbuf, 4)
11405 basic_stringbuf_char* __thiscall basic_stringstream_char_rdbuf(const basic_stringstream_char *this)
11406 {
11407     TRACE("(%p)\n", this);
11408     return (basic_stringbuf_char*)&this->strbuf;
11409 }
11410
11411 /* ?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
11412 /* ?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z */
11413 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_set, 8)
11414 void __thiscall basic_stringstream_char_str_set(basic_stringstream_char *this, const basic_string_char *str)
11415 {
11416     TRACE("(%p %p)\n", this, str);
11417     basic_stringbuf_char_str_set(&this->strbuf, str);
11418 }
11419
11420 /* ?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
11421 /* ?str@?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@XZ */
11422 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_get, 8)
11423 basic_string_char* __thiscall basic_stringstream_char_str_get(const basic_stringstream_char *this, basic_string_char *ret)
11424 {
11425     TRACE("(%p %p)\n", this, ret);
11426     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11427 }
11428
11429 static inline basic_ios_wchar* basic_stringstream_wchar_to_basic_ios(basic_stringstream_wchar *ptr)
11430 {
11431     return (basic_ios_wchar*)((char*)ptr+basic_stringstream_wchar_vbtable1[1]);
11432 }
11433
11434 static inline basic_stringstream_wchar* basic_stringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11435 {
11436     return (basic_stringstream_wchar*)((char*)ptr-basic_stringstream_wchar_vbtable1[1]);
11437 }
11438
11439 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@ABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z */
11440 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@AEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@1@H@Z */
11441 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_str(basic_stringstream_wchar *this,
11442         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11443 {
11444     basic_ios_wchar *basic_ios;
11445
11446     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11447
11448     if(virt_init) {
11449         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11450         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11451         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11452         basic_ios_wchar_ctor(basic_ios);
11453     }else {
11454         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11455     }
11456
11457     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode);
11458     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11459     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11460     return this;
11461 }
11462
11463 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@ABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z */
11464 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@AEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@1@H@Z */
11465 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_str, 16)
11466 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_str(basic_stringstream_wchar *this,
11467         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11468 {
11469     basic_stringstream_wchar_ctor_str(this, str, mode, virt_init);
11470     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11471     return this;
11472 }
11473
11474 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11475 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11476 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_mode(
11477         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11478 {
11479     basic_ios_wchar *basic_ios;
11480
11481     TRACE("(%p %d %d)\n", this, mode, virt_init);
11482
11483     if(virt_init) {
11484         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11485         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11486         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11487         basic_ios_wchar_ctor(basic_ios);
11488     }else {
11489         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11490     }
11491
11492     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode);
11493     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11494     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11495     return this;
11496 }
11497
11498 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11499 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11500 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_mode, 12)
11501 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_mode(
11502         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11503 {
11504     basic_stringstream_wchar_ctor_mode(this, mode, virt_init);
11505     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11506     return this;
11507 }
11508
11509 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11510 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11511 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor, 8)
11512 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor(
11513         basic_stringstream_wchar *this, MSVCP_bool virt_init)
11514 {
11515     return basic_stringstream_short_ctor_mode(
11516             this, OPENMODE_out|OPENMODE_in, virt_init);
11517 }
11518
11519 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11520 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11521 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11522 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11523 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_dtor, 4)
11524 void __thiscall basic_stringstream_wchar_dtor(basic_ios_wchar *base)
11525 {
11526     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11527
11528     TRACE("(%p)\n", this);
11529
11530     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
11531     basic_stringbuf_wchar_dtor(&this->strbuf);
11532 }
11533
11534 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11535 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11536 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11537 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11538 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vbase_dtor, 4)
11539 void __thiscall basic_stringstream_wchar_vbase_dtor(basic_stringstream_wchar *this)
11540 {
11541     TRACE("(%p)\n", this);
11542
11543     basic_stringstream_wchar_dtor(basic_stringstream_wchar_to_basic_ios(this));
11544     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
11545 }
11546
11547 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vector_dtor, 8)
11548 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11549 {
11550     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11551
11552     TRACE("(%p %x)\n", this, flags);
11553
11554     if(flags & 2) {
11555         /* we have an array, with the number of elements stored before the first object */
11556         INT_PTR i, *ptr = (INT_PTR *)this-1;
11557
11558         for(i=*ptr-1; i>=0; i--)
11559             basic_stringstream_wchar_vbase_dtor(this+i);
11560         MSVCRT_operator_delete(ptr);
11561     } else {
11562         basic_stringstream_wchar_vbase_dtor(this);
11563         if(flags & 1)
11564             MSVCRT_operator_delete(this);
11565     }
11566
11567     return this;
11568 }
11569
11570 /* ?rdbuf@?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBEPAV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
11571 /* ?rdbuf@?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBAPEAV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
11572 /* ?rdbuf@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBEPAV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
11573 /* ?rdbuf@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBAPEAV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
11574 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_rdbuf, 4)
11575 basic_stringbuf_wchar* __thiscall basic_stringstream_wchar_rdbuf(const basic_stringstream_wchar *this)
11576 {
11577     TRACE("(%p)\n", this);
11578     return (basic_stringbuf_wchar*)&this->strbuf;
11579 }
11580
11581 /* ?str@?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXABV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@@Z */
11582 /* ?str@?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXAEBV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@@Z */
11583 /* ?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXABV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z */
11584 /* ?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXAEBV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@@Z */
11585 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_set, 8)
11586 void __thiscall basic_stringstream_wchar_str_set(basic_stringstream_wchar *this, const basic_string_wchar *str)
11587 {
11588     TRACE("(%p %p)\n", this, str);
11589     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11590 }
11591
11592 /* ?str@?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBE?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
11593 /* ?str@?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBA?AV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@2@XZ */
11594 /* ?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
11595 /* ?str@?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBA?AV?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@2@XZ */
11596 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_get, 8)
11597 basic_string_wchar* __thiscall basic_stringstream_wchar_str_get(const basic_stringstream_wchar *this, basic_string_wchar *ret)
11598 {
11599     TRACE("(%p %p)\n", this, ret);
11600     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11601 }
11602
11603 /* ?_Init@strstreambuf@std@@IAEXHPAD0H@Z */
11604 /* ?_Init@strstreambuf@std@@IEAAX_JPEAD1H@Z */
11605 DEFINE_THISCALL_WRAPPER(strstreambuf__Init, 20)
11606 void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g, char *p, int mode)
11607 {
11608     TRACE("(%p %ld %p %p %d)\n", this, len, g, p, mode);
11609
11610     this->minsize = 32;
11611     this->endsave = NULL;
11612     this->strmode = mode;
11613     this->palloc = NULL;
11614     this->pfree = NULL;
11615
11616     if(!g) {
11617         this->strmode |= STRSTATE_Dynamic;
11618         if(len > this->minsize)
11619             this->minsize = len;
11620         this->seekhigh = NULL;
11621         return;
11622     }
11623
11624     if(len < 0)
11625         len = INT_MAX;
11626     else if(!len)
11627         len = strlen(g);
11628
11629     this->seekhigh = g+len;
11630     basic_streambuf_char_setg(&this->base, g, g, p ? p : this->seekhigh);
11631     if(p)
11632         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
11633 }
11634
11635 /* ??0strstreambuf@std@@QAE@PACH0@Z */
11636 /* ??0strstreambuf@std@@QEAA@PEAC_J0@Z */
11637 /* ??0strstreambuf@std@@QAE@PADH0@Z */
11638 /* ??0strstreambuf@std@@QEAA@PEAD_J0@Z */
11639 /* ??0strstreambuf@std@@QAE@PAEH0@Z */
11640 /* ??0strstreambuf@std@@QEAA@PEAE_J0@Z */
11641 static strstreambuf* strstreambuf_ctor_get_put(strstreambuf *this, char *g, streamsize len, char *p)
11642 {
11643     TRACE("(%p %p %ld %p)\n", this, g, len, p);
11644
11645     basic_streambuf_char_ctor(&this->base);
11646     this->base.vtable = &MSVCP_strstreambuf_vtable;
11647
11648     strstreambuf__Init(this, len, g, p, 0);
11649     return this;
11650 }
11651
11652 /* ?_Tidy@strstreambuf@std@@IAEXXZ */
11653 /* ?_Tidy@strstreambuf@std@@IEAAXXZ */
11654 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
11655 void __thiscall strstreambuf__Tidy(strstreambuf *this)
11656 {
11657     TRACE("(%p)\n", this);
11658
11659     if((this->strmode & STRSTATE_Allocated) && !(this->strmode & STRSTATE_Frozen)) {
11660         if(this->pfree)
11661             this->pfree(basic_streambuf_char_eback(&this->base));
11662         else
11663             MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
11664     }
11665
11666     this->endsave = NULL;
11667     this->seekhigh = NULL;
11668     this->strmode &= ~(STRSTATE_Allocated | STRSTATE_Frozen);
11669     basic_streambuf_char_setg(&this->base, NULL, NULL, NULL);
11670     basic_streambuf_char_setp(&this->base, NULL, NULL);
11671 }
11672
11673 /* ??1strstreambuf@std@@UAE@XZ */
11674 /* ??1strstreambuf@std@@UEAA@XZ */
11675 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor, 4)
11676 void __thiscall strstreambuf_dtor(strstreambuf *this)
11677 {
11678     TRACE("(%p)\n", this);
11679
11680     strstreambuf__Tidy(this);
11681     basic_streambuf_char_dtor(&this->base);
11682 }
11683
11684 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor, 8)
11685 strstreambuf* __thiscall strstreambuf_vector_dtor(strstreambuf *this, unsigned int flags)
11686 {
11687     TRACE("(%p %x)\n", this, flags);
11688     if(flags & 2) {
11689         /* we have an array, with the number of elements stored before the first object */
11690         INT_PTR i, *ptr = (INT_PTR *)this-1;
11691
11692         for(i=*ptr-1; i>=0; i--)
11693             strstreambuf_dtor(this+i);
11694         MSVCRT_operator_delete(ptr);
11695     } else {
11696         strstreambuf_dtor(this);
11697         if(flags & 1)
11698             MSVCRT_operator_delete(this);
11699     }
11700
11701     return this;
11702 }
11703
11704 /* ?freeze@strstreambuf@std@@QAEX_N@Z */
11705 /* ?freeze@strstreambuf@std@@QEAAX_N@Z */
11706 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze, 8)
11707 void __thiscall strstreambuf_freeze(strstreambuf *this, MSVCP_bool freeze)
11708 {
11709     TRACE("(%p %d)\n", this, freeze);
11710
11711     if(!freeze == !(this->strmode *STRSTATE_Frozen))
11712         return;
11713
11714     if(freeze) {
11715         this->strmode |= STRSTATE_Frozen;
11716         this->endsave = basic_streambuf_char_epptr(&this->base);
11717         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11718                 basic_streambuf_char_pptr(&this->base), basic_streambuf_char_eback(&this->base));
11719     }else {
11720         this->strmode &= ~STRSTATE_Frozen;
11721         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11722                 basic_streambuf_char_pptr(&this->base), this->endsave);
11723     }
11724 }
11725
11726 /* ?overflow@strstreambuf@std@@MAEHH@Z */
11727 /* ?overflow@strstreambuf@std@@MEAAHH@Z */
11728 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow, 8)
11729 int __thiscall strstreambuf_overflow(strstreambuf *this, int c)
11730 {
11731     MSVCP_size_t old_size, size;
11732     char *ptr, *buf;
11733
11734     TRACE("(%p %d)\n", this, c);
11735
11736     if(c == EOF)
11737         return !EOF;
11738
11739     if(this->strmode & STRSTATE_Frozen)
11740         return EOF;
11741
11742     ptr = basic_streambuf_char_pptr(&this->base);
11743     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
11744         return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11745
11746     if(!(this->strmode & STRSTATE_Dynamic) || (this->strmode & STRSTATE_Constant))
11747         return EOF;
11748
11749     ptr = basic_streambuf_char_eback(&this->base);
11750     old_size = ptr ? basic_streambuf_char_epptr(&this->base) - ptr : 0;
11751
11752     size = old_size + old_size/2;
11753     if(size < this->minsize)
11754         size = this->minsize;
11755
11756     if(this->palloc)
11757         buf = this->palloc(size);
11758     else
11759         buf = MSVCRT_operator_new(size);
11760     if(!buf)
11761         return EOF;
11762
11763     memcpy(buf, ptr, old_size);
11764     if(this->strmode & STRSTATE_Allocated) {
11765         if(this->pfree)
11766             this->pfree(ptr);
11767         else
11768             MSVCRT_operator_delete(ptr);
11769     }
11770
11771     this->strmode |= STRSTATE_Allocated;
11772     if(!old_size) {
11773         this->seekhigh = buf;
11774         basic_streambuf_char_setp(&this->base, buf, buf+size);
11775         basic_streambuf_char_setg(&this->base, buf, buf, buf);
11776     }else {
11777         this->seekhigh = this->seekhigh-ptr+buf;
11778         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base)-ptr+buf,
11779                 basic_streambuf_char_pptr(&this->base)-ptr+buf, buf+size);
11780         basic_streambuf_char_setg(&this->base, buf, basic_streambuf_char_gptr(&this->base)-ptr+buf,
11781                 basic_streambuf_char_pptr(&this->base));
11782     }
11783
11784     return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11785 }
11786
11787 /* ?pbackfail@strstreambuf@std@@MAEHH@Z */
11788 /* ?pbackfail@strstreambuf@std@@MEAAHH@Z */
11789 DEFINE_THISCALL_WRAPPER(strstreambuf_pbackfail, 8)
11790 int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c)
11791 {
11792     char *ptr = basic_streambuf_char_gptr(&this->base);
11793
11794     TRACE("(%p %d)\n", this, c);
11795
11796     if(ptr<=basic_streambuf_char_eback(&this->base)
11797             || ((this->strmode & STRSTATE_Constant) && c!=ptr[-1]))
11798         return EOF;
11799
11800     basic_streambuf_char_gbump(&this->base, -1);
11801     if(c == EOF)
11802         return !EOF;
11803     if(this->strmode & STRSTATE_Constant)
11804         return (unsigned char)c;
11805
11806     return (unsigned char)(ptr[0] = c);
11807 }
11808
11809 /* ?seekoff@strstreambuf@std@@MAE?AV?$fpos@H@2@JHH@Z */
11810 /* ?seekoff@strstreambuf@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
11811 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20)
11812 fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode)
11813 {
11814     char *eback = basic_streambuf_char_eback(&this->base);
11815     char *pptr = basic_streambuf_char_pptr(&this->base);
11816     char *gptr = basic_streambuf_char_gptr(&this->base);
11817
11818     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
11819
11820     ret->off = 0;
11821     ret->state = 0;
11822
11823     if(pptr > this->seekhigh)
11824         this->seekhigh = pptr;
11825
11826     if((mode & OPENMODE_in) && gptr) {
11827         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
11828             off += gptr-eback;
11829         else if(way == SEEKDIR_end)
11830             off += this->seekhigh-eback;
11831         else if(way != SEEKDIR_beg)
11832             off = -1;
11833
11834         if(off<0 || off>this->seekhigh-eback) {
11835             off = -1;
11836         }else {
11837             basic_streambuf_char_gbump(&this->base, eback-gptr+off);
11838             if((mode & OPENMODE_out) && pptr) {
11839                 basic_streambuf_char_setp_next(&this->base, eback,
11840                         gptr, basic_streambuf_char_epptr(&this->base));
11841             }
11842         }
11843     }else if((mode & OPENMODE_out) && pptr) {
11844         if(way == SEEKDIR_cur)
11845             off += pptr-eback;
11846         else if(way == SEEKDIR_end)
11847             off += this->seekhigh-eback;
11848         else if(way != SEEKDIR_beg)
11849             off = -1;
11850
11851          if(off<0 || off>this->seekhigh-eback)
11852              off = -1;
11853          else
11854              basic_streambuf_char_pbump(&this->base, eback-pptr+off);
11855     }else {
11856         off = -1;
11857     }
11858
11859     ret->pos = off;
11860     return ret;
11861 }
11862
11863 /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */
11864 /* ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
11865 DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36)
11866 fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode)
11867 {
11868     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
11869
11870     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
11871         *ret = pos;
11872         return ret;
11873     }
11874
11875     return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
11876 }
11877
11878 /* ?underflow@strstreambuf@std@@MAEHXZ */
11879 /* ?underflow@strstreambuf@std@@MEAAHXZ */
11880 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow, 4)
11881 int __thiscall strstreambuf_underflow(strstreambuf *this)
11882 {
11883     char *gptr = basic_streambuf_char_gptr(&this->base);
11884     char *pptr;
11885
11886     TRACE("(%p)\n", this);
11887
11888     if(!gptr)
11889         return EOF;
11890
11891     if(gptr < basic_streambuf_char_egptr(&this->base))
11892         return (unsigned char)(*gptr);
11893
11894     pptr = basic_streambuf_char_gptr(&this->base);
11895     if(pptr > this->seekhigh)
11896         this->seekhigh = pptr;
11897
11898     if(this->seekhigh <= gptr)
11899         return EOF;
11900
11901     basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base),
11902             gptr, this->seekhigh);
11903     return (unsigned char)(*gptr);
11904 }
11905
11906 static inline basic_ios_char* ostrstream_to_basic_ios(ostrstream *ptr)
11907 {
11908     return (basic_ios_char*)((char*)ptr+ostrstream_vbtable[1]);
11909 }
11910
11911 static inline ostrstream* ostrstream_from_basic_ios(basic_ios_char *ptr)
11912 {
11913     return (ostrstream*)((char*)ptr-ostrstream_vbtable[1]);
11914 }
11915
11916 /* ??0ostrstream@std@@QAE@PADHH@Z */
11917 DEFINE_THISCALL_WRAPPER(ostrstream_ctor, 20)
11918 ostrstream* __thiscall ostrstream_ctor(ostrstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
11919 {
11920     basic_ios_char *basic_ios;
11921
11922     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
11923
11924     if(virt_init) {
11925         this->base.vbtable = ostrstream_vbtable;
11926         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11927         basic_ios_char_ctor(basic_ios);
11928     }else {
11929         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11930     }
11931
11932     strstreambuf_ctor_get_put(&this->buf, buf, size,
11933             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
11934     basic_ostream_char_ctor(&this->base, &this->buf.base, FALSE, FALSE);
11935     basic_ios->base.vtable = &MSVCP_ostrstream_vtable;
11936     return this;
11937 }
11938
11939 /* ??1ostrstream@std@@UAE@XZ */
11940 /* ??1ostrstream@std@@UEAA@XZ */
11941 DEFINE_THISCALL_WRAPPER(ostrstream_dtor, 4)
11942 void __thiscall ostrstream_dtor(basic_ios_char *base)
11943 {
11944     ostrstream *this = ostrstream_from_basic_ios(base);
11945
11946     TRACE("(%p)\n", this);
11947
11948     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
11949     strstreambuf_dtor(&this->buf);
11950 }
11951
11952 static void ostrstream_vbase_dtor(ostrstream *this)
11953 {
11954     TRACE("(%p)\n", this);
11955
11956     ostrstream_dtor(ostrstream_to_basic_ios(this));
11957     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
11958 }
11959
11960 DEFINE_THISCALL_WRAPPER(ostrstream_vector_dtor, 8)
11961 ostrstream* __thiscall ostrstream_vector_dtor(basic_ios_char *base, unsigned int flags)
11962 {
11963     ostrstream *this = ostrstream_from_basic_ios(base);
11964
11965     TRACE("(%p %x)\n", this, flags);
11966
11967     if(flags & 2) {
11968         /* we have an array, with the number of elements stored before the first object */
11969         INT_PTR i, *ptr = (INT_PTR *)this-1;
11970
11971         for(i=*ptr-1; i>=0; i--)
11972             ostrstream_vbase_dtor(this+i);
11973         MSVCRT_operator_delete(ptr);
11974     } else {
11975         ostrstream_vbase_dtor(this);
11976         if(flags & 1)
11977             MSVCRT_operator_delete(this);
11978     }
11979
11980     return this;
11981 }
11982
11983 static inline istrstream* istrstream_from_basic_ios(basic_ios_char *ptr)
11984 {
11985     return (istrstream*)((char*)ptr-istrstream_vbtable[1]);
11986 }
11987
11988 /* ??1istrstream@std@@UAE@XZ */
11989 /* ??1istrstream@std@@UEAA@XZ */
11990 DEFINE_THISCALL_WRAPPER(istrstream_dtor, 4)
11991 void __thiscall istrstream_dtor(basic_ios_char *base)
11992 {
11993     istrstream *this = istrstream_from_basic_ios(base);
11994
11995     TRACE("(%p)\n", this);
11996
11997     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11998     strstreambuf_dtor(&this->buf);
11999 }
12000
12001 static inline basic_ios_char* strstream_to_basic_ios(strstream *ptr)
12002 {
12003     return (basic_ios_char*)((char*)ptr+strstream_vbtable1[1]);
12004 }
12005
12006 static inline strstream* strstream_from_basic_ios(basic_ios_char *ptr)
12007 {
12008     return (strstream*)((char*)ptr-strstream_vbtable1[1]);
12009 }
12010
12011 /* ??0strstream@std@@QAE@PADHH@Z */
12012 /* ??0strstream@std@@QEAA@PEAD_JH@Z */
12013 DEFINE_THISCALL_WRAPPER(strstream_ctor, 20)
12014 strstream* __thiscall strstream_ctor(strstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
12015 {
12016     basic_ios_char *basic_ios;
12017
12018     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
12019
12020     if(virt_init) {
12021         this->base.base1.vbtable = strstream_vbtable1;
12022         this->base.base2.vbtable = strstream_vbtable2;
12023         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12024         basic_ios_char_ctor(basic_ios);
12025     }else {
12026         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12027     }
12028
12029     strstreambuf_ctor_get_put(&this->buf, buf, size,
12030             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
12031     basic_iostream_char_ctor(&this->base, &this->buf.base, FALSE);
12032     basic_ios->base.vtable = &MSVCP_strstream_vtable;
12033     return this;
12034 }
12035
12036 /* ??1strstream@std@@UAE@XZ */
12037 /* ??1strstream@std@@UEAA@XZ */
12038 DEFINE_THISCALL_WRAPPER(strstream_dtor, 4)
12039 void __thiscall strstream_dtor(basic_ios_char *base)
12040 {
12041     strstream *this = strstream_from_basic_ios(base);
12042
12043     TRACE("(%p)\n", this);
12044
12045     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
12046     strstreambuf_dtor(&this->buf);
12047 }
12048
12049 static void strstream_vbase_dtor(strstream *this)
12050 {
12051     TRACE("(%p)\n", this);
12052
12053     strstream_dtor(strstream_to_basic_ios(this));
12054     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
12055 }
12056
12057 DEFINE_THISCALL_WRAPPER(strstream_vector_dtor, 8)
12058 strstream* __thiscall strstream_vector_dtor(basic_ios_char *base, unsigned int flags)
12059 {
12060     strstream *this = strstream_from_basic_ios(base);
12061
12062     TRACE("(%p %x)\n", this, flags);
12063
12064     if(flags & 2) {
12065         /* we have an array, with the number of elements stored before the first object */
12066         INT_PTR i, *ptr = (INT_PTR *)this-1;
12067
12068         for(i=*ptr-1; i>=0; i--)
12069             strstream_vbase_dtor(this+i);
12070         MSVCRT_operator_delete(ptr);
12071     } else {
12072         strstream_vbase_dtor(this);
12073         if(flags & 1)
12074             MSVCRT_operator_delete(this);
12075     }
12076
12077     return this;
12078 }
12079
12080 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
12081 {
12082     ios_base_precision_set(base, prec);
12083 }
12084
12085 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
12086 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12087 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
12088 {
12089     TRACE("(%p %ld)\n", ret, prec);
12090
12091     ret->pfunc = setprecision_func;
12092     ret->arg = prec;
12093     return ret;
12094 }
12095
12096 static void __cdecl setw_func(ios_base *base, streamsize width)
12097 {
12098     ios_base_width_set(base, width);
12099 }
12100
12101 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
12102 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12103 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
12104 {
12105     TRACE("(%p %ld)\n", ret, width);
12106
12107     ret->pfunc = setw_func;
12108     ret->arg = width;
12109     return ret;
12110 }
12111
12112 static void __cdecl resetioflags_func(ios_base *base, int mask)
12113 {
12114     ios_base_setf_mask(base, 0, mask);
12115 }
12116
12117 /* ?resetiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12118 manip_int* __cdecl resetiosflags(manip_int *ret, int mask)
12119 {
12120     TRACE("(%p %d)\n", ret, mask);
12121
12122     ret->pfunc = resetioflags_func;
12123     ret->arg = mask;
12124     return ret;
12125 }
12126
12127 static void __cdecl setiosflags_func(ios_base *base, int mask)
12128 {
12129     ios_base_setf_mask(base, FMTFLAG_mask, mask);
12130 }
12131
12132 /* ?setiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12133 manip_int* __cdecl setiosflags(manip_int *ret, int mask)
12134 {
12135     TRACE("(%p %d)\n", ret, mask);
12136
12137     ret->pfunc = setiosflags_func;
12138     ret->arg = mask;
12139     return ret;
12140 }
12141
12142 static void __cdecl setbase_func(ios_base *base, int set_base)
12143 {
12144     if(set_base == 10)
12145         set_base = FMTFLAG_dec;
12146     else if(set_base == 8)
12147         set_base = FMTFLAG_oct;
12148     else if(set_base == 16)
12149         set_base = FMTFLAG_hex;
12150     else
12151         set_base = 0;
12152
12153     ios_base_setf_mask(base, set_base, FMTFLAG_basefield);
12154 }
12155
12156 /* ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z */
12157 manip_int* __cdecl setbase(manip_int *ret, int base)
12158 {
12159     TRACE("(%p %d)\n", ret, base);
12160
12161     ret->pfunc = setbase_func;
12162     ret->arg = base;
12163     return ret;
12164 }
12165
12166 static basic_filebuf_char filebuf_char_stdin;
12167 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
12168 struct {
12169     basic_istream_char obj;
12170     basic_ios_char vbase;
12171 } cin = { { 0 } };
12172 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
12173 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
12174 basic_istream_char *_Ptr_cin = &cin.obj;
12175
12176 static basic_filebuf_wchar filebuf_short_stdin;
12177 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
12178 struct {
12179     basic_istream_wchar obj;
12180     basic_ios_wchar vbase;
12181 } ucin = { { 0 } };
12182 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
12183 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
12184 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
12185
12186 static basic_filebuf_wchar filebuf_wchar_stdin;
12187 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12188 struct {
12189     basic_istream_wchar obj;
12190     basic_ios_wchar vbase;
12191 } wcin = { { 0 } };
12192 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12193 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
12194 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
12195
12196 static basic_filebuf_char filebuf_char_stdout;
12197 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12198 struct {
12199     basic_ostream_char obj;
12200     basic_ios_char vbase;
12201 } cout = { { 0 } };
12202 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12203 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12204 basic_ostream_char *_Ptr_cout = &cout.obj;
12205
12206 static basic_filebuf_wchar filebuf_short_stdout;
12207 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12208 struct {
12209     basic_ostream_wchar obj;
12210     basic_ios_wchar vbase;
12211 } ucout = { { 0 } };
12212 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12213 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12214 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
12215
12216 static basic_filebuf_wchar filebuf_wchar_stdout;
12217 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12218 struct {
12219     basic_ostream_wchar obj;
12220     basic_ios_wchar vbase;
12221 } wcout = { { 0 } };
12222 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12223 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12224 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
12225
12226 static basic_filebuf_char filebuf_char_stderr;
12227 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12228 struct {
12229     basic_ostream_char obj;
12230     basic_ios_char vbase;
12231 } cerr = { { 0 } };
12232 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12233 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12234 basic_ostream_char *_Ptr_cerr = &cerr.obj;
12235
12236 static basic_filebuf_wchar filebuf_short_stderr;
12237 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12238 struct {
12239     basic_ostream_wchar obj;
12240     basic_ios_wchar vbase;
12241 } ucerr = { { 0 } };
12242 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12243 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12244 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
12245
12246 static basic_filebuf_wchar filebuf_wchar_stderr;
12247 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12248 struct {
12249     basic_ostream_wchar obj;
12250     basic_ios_wchar vbase;
12251 } wcerr = { { 0 } };
12252 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12253 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12254 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
12255
12256 static basic_filebuf_char filebuf_char_log;
12257 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12258 struct {
12259     basic_ostream_char obj;
12260     basic_ios_char vbase;
12261 } clog = { { 0 } };
12262 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12263 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12264 basic_ostream_char *_Ptr_clog = &clog.obj;
12265
12266 static basic_filebuf_wchar filebuf_short_log;
12267 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12268 struct {
12269     basic_ostream_wchar obj;
12270     basic_ios_wchar vbase;
12271 } uclog = { { 0 } };
12272 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12273 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12274 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
12275
12276 static basic_filebuf_wchar filebuf_wchar_log;
12277 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12278 struct {
12279     basic_ostream_wchar obj;
12280     basic_ios_wchar vbase;
12281 } wclog = { { 0 } };
12282 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12283 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12284 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
12285
12286 /* ?_Init_cnt@Init@ios_base@std@@0HA */
12287 int ios_base_Init__Init_cnt = -1;
12288
12289 /* ?_Init_ctor@Init@ios_base@std@@CAXPAV123@@Z */
12290 /* ?_Init_ctor@Init@ios_base@std@@CAXPEAV123@@Z */
12291 static void ios_base_Init__Init_ctor(void *this)
12292 {
12293     TRACE("(%p)\n", this);
12294
12295     if(ios_base_Init__Init_cnt < 0)
12296         ios_base_Init__Init_cnt = 1;
12297     else
12298         ios_base_Init__Init_cnt++;
12299 }
12300
12301 /* ??0Init@ios_base@std@@QAE@XZ */
12302 /* ??0Init@ios_base@std@@QEAA@XZ */
12303 DEFINE_THISCALL_WRAPPER(ios_base_Init_ctor, 4)
12304 void* __thiscall ios_base_Init_ctor(void *this)
12305 {
12306     ios_base_Init__Init_ctor(this);
12307     return this;
12308 }
12309
12310 /* ?_Init_dtor@Init@ios_base@std@@CAXPAV123@@Z */
12311 /* ?_Init_dtor@Init@ios_base@std@@CAXPEAV123@@Z */
12312 static void ios_base_Init__Init_dtor(void *this)
12313 {
12314     TRACE("(%p)\n", this);
12315
12316     ios_base_Init__Init_cnt--;
12317     if(!ios_base_Init__Init_cnt) {
12318         basic_ostream_char_flush(&cout.obj);
12319         basic_ostream_char_flush(&cerr.obj);
12320         basic_ostream_char_flush(&clog.obj);
12321     }
12322 }
12323
12324 /* ??1Init@ios_base@std@@QAE@XZ */
12325 /* ??1Init@ios_base@std@@QEAA@XZ */
12326 DEFINE_THISCALL_WRAPPER(ios_base_Init_dtor, 4)
12327 void __thiscall ios_base_Init_dtor(void *this)
12328 {
12329     ios_base_Init__Init_dtor(this);
12330 }
12331
12332 /* ??4Init@ios_base@std@@QAEAAV012@ABV012@@Z */
12333 /* ??4Init@ios_base@std@@QEAAAEAV012@AEBV012@@Z */
12334 DEFINE_THISCALL_WRAPPER(ios_base_Init_op_assign, 8)
12335 void* __thiscall ios_base_Init_op_assign(void *this, void *rhs)
12336 {
12337     TRACE("(%p %p)\n", this, rhs);
12338     return this;
12339 }
12340
12341 /* ?_Init_cnt@_Winit@std@@0HA */
12342 int _Winit__Init_cnt = -1;
12343
12344 /* ??0_Winit@std@@QAE@XZ */
12345 /* ??0_Winit@std@@QEAA@XZ */
12346 DEFINE_THISCALL_WRAPPER(_Winit_ctor, 4)
12347 void* __thiscall _Winit_ctor(void *this)
12348 {
12349     TRACE("(%p)\n", this);
12350
12351     if(_Winit__Init_cnt < 0)
12352         _Winit__Init_cnt = 1;
12353     else
12354         _Winit__Init_cnt++;
12355
12356     return this;
12357 }
12358
12359 /* ??1_Winit@std@@QAE@XZ */
12360 /* ??1_Winit@std@@QAE@XZ */
12361 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)
12362 void __thiscall _Winit_dtor(void *this)
12363 {
12364     TRACE("(%p)\n", this);
12365
12366     _Winit__Init_cnt--;
12367     if(!_Winit__Init_cnt) {
12368         basic_ostream_wchar_flush(&wcout.obj);
12369         basic_ostream_wchar_flush(&wcerr.obj);
12370         basic_ostream_wchar_flush(&wclog.obj);
12371     }
12372 }
12373
12374 /* ??4_Winit@std@@QAEAAV01@ABV01@@Z */
12375 /* ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z */
12376 DEFINE_THISCALL_WRAPPER(_Winit_op_assign, 8)
12377 void* __thiscall _Winit_op_assign(void *this, void *rhs)
12378 {
12379     TRACE("(%p %p)\n", this, rhs);
12380     return this;
12381 }
12382
12383 void init_io(void *base)
12384 {
12385 #ifdef __x86_64__
12386     init_iosb_rtti(base);
12387     init_ios_base_rtti(base);
12388     init_basic_ios_char_rtti(base);
12389     init_basic_ios_wchar_rtti(base);
12390     init_basic_ios_short_rtti(base);
12391     init_basic_streambuf_char_rtti(base);
12392     init_basic_streambuf_wchar_rtti(base);
12393     init_basic_streambuf_short_rtti(base);
12394     init_basic_filebuf_char_rtti(base);
12395     init_basic_filebuf_wchar_rtti(base);
12396     init_basic_filebuf_short_rtti(base);
12397     init_basic_stringbuf_char_rtti(base);
12398     init_basic_stringbuf_wchar_rtti(base);
12399     init_basic_stringbuf_short_rtti(base);
12400     init_basic_ostream_char_rtti(base);
12401     init_basic_ostream_wchar_rtti(base);
12402     init_basic_ostream_short_rtti(base);
12403     init_basic_istream_char_rtti(base);
12404     init_basic_istream_wchar_rtti(base);
12405     init_basic_istream_short_rtti(base);
12406     init_basic_iostream_char_rtti(base);
12407     init_basic_iostream_wchar_rtti(base);
12408     init_basic_iostream_short_rtti(base);
12409     init_basic_ofstream_char_rtti(base);
12410     init_basic_ofstream_wchar_rtti(base);
12411     init_basic_ofstream_short_rtti(base);
12412     init_basic_ifstream_char_rtti(base);
12413     init_basic_ifstream_wchar_rtti(base);
12414     init_basic_ifstream_short_rtti(base);
12415     init_basic_fstream_char_rtti(base);
12416     init_basic_fstream_wchar_rtti(base);
12417     init_basic_fstream_short_rtti(base);
12418     init_basic_ostringstream_char_rtti(base);
12419     init_basic_ostringstream_wchar_rtti(base);
12420     init_basic_ostringstream_short_rtti(base);
12421     init_basic_istringstream_char_rtti(base);
12422     init_basic_istringstream_wchar_rtti(base);
12423     init_basic_istringstream_short_rtti(base);
12424     init_basic_stringstream_char_rtti(base);
12425     init_basic_stringstream_wchar_rtti(base);
12426     init_basic_stringstream_short_rtti(base);
12427     init_strstreambuf_rtti(base);
12428     init_strstream_rtti(base);
12429     init_ostrstream_rtti(base);
12430 #endif
12431
12432     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
12433     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
12434
12435     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
12436     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
12437
12438     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
12439     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
12440
12441     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
12442     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE);
12443
12444     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
12445     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE);
12446
12447     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
12448     basic_ostream_wchar_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE);
12449
12450     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
12451     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE);
12452
12453     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
12454     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE);
12455
12456     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
12457     basic_ostream_wchar_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE);
12458
12459     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
12460     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE);
12461
12462     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
12463     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE);
12464
12465     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
12466     basic_ostream_wchar_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE);
12467 }
12468
12469 void free_io(void)
12470 {
12471     basic_istream_char_vbase_dtor(&cin.obj);
12472     basic_filebuf_char_dtor(&filebuf_char_stdin);
12473
12474     basic_istream_wchar_vbase_dtor(&ucin.obj);
12475     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
12476
12477     basic_istream_wchar_vbase_dtor(&wcin.obj);
12478     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
12479
12480     basic_ostream_char_vbase_dtor(&cout.obj);
12481     basic_filebuf_char_dtor(&filebuf_char_stdout);
12482
12483     basic_ostream_wchar_vbase_dtor(&ucout.obj);
12484     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
12485
12486     basic_ostream_wchar_vbase_dtor(&wcout.obj);
12487     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
12488
12489     basic_ostream_char_vbase_dtor(&cerr.obj);
12490     basic_filebuf_char_dtor(&filebuf_char_stderr);
12491
12492     basic_ostream_wchar_vbase_dtor(&ucerr.obj);
12493     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
12494
12495     basic_ostream_wchar_vbase_dtor(&wcerr.obj);
12496     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
12497
12498     basic_ostream_char_vbase_dtor(&clog.obj);
12499     basic_filebuf_char_dtor(&filebuf_char_log);
12500
12501     basic_ostream_wchar_vbase_dtor(&uclog.obj);
12502     basic_filebuf_wchar_dtor(&filebuf_short_log);
12503
12504     basic_ostream_wchar_vbase_dtor(&wclog.obj);
12505     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
12506 }