opengl32: Apply correct normals to text rendered with wglUseFontOutlines.
[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     locale_ctor(&this->loc);
950     basic_streambuf_char__Init_empty(this);
951
952     return this;
953 }
954
955 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
956 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
957 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
958 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
959 {
960     TRACE("(%p)\n", this);
961
962     locale_dtor(&this->loc);
963 }
964
965 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_vector_dtor, 8)
966 basic_streambuf_char* __thiscall basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
967 {
968     TRACE("(%p %x)\n", this, flags);
969     if(flags & 2) {
970         /* we have an array, with the number of elements stored before the first object */
971         INT_PTR i, *ptr = (INT_PTR *)this-1;
972
973         for(i=*ptr-1; i>=0; i--)
974             basic_streambuf_char_dtor(this+i);
975         MSVCRT_operator_delete(ptr);
976     } else {
977         basic_streambuf_char_dtor(this);
978         if(flags & 1)
979             MSVCRT_operator_delete(this);
980     }
981
982     return this;
983 }
984
985 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
986 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
987 static streamsize basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
988 {
989     TRACE("(%p)\n", this);
990     return *this->prpos ? *this->prsize : 0;
991 }
992
993 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
994 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
995 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
996 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
997 {
998     TRACE("(%p)\n", this);
999     (*this->prsize)++;
1000     (*this->prpos)--;
1001     return *this->prpos;
1002 }
1003
1004 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1005 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1006 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
1007 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
1008 {
1009     TRACE("(%p)\n", this);
1010     (*this->prsize)--;
1011     return (*this->prpos)++;
1012 }
1013
1014 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1015 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1016 static char* basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
1017 {
1018     TRACE("(%p)\n", this);
1019     (*this->prsize)--;
1020     (*this->prpos)++;
1021     return *this->prpos;
1022 }
1023
1024 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
1025 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
1026 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
1027 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
1028 {
1029     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1030
1031     this->prbuf = gf;
1032     this->pwbuf = pf;
1033     this->prpos = gn;
1034     this->pwpos = pn;
1035     this->prsize = gc;
1036     this->pwsize = pc;
1037 }
1038
1039 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1040 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1041 static void basic_streambuf_char__Lock(basic_streambuf_char *this)
1042 {
1043     TRACE("(%p)\n", this);
1044 }
1045
1046 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
1047 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
1048 static streamsize basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
1049 {
1050     TRACE("(%p)\n", this);
1051     return *this->pwpos ? *this->pwsize : 0;
1052 }
1053
1054 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1055 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1056 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
1057 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
1058 {
1059     TRACE("(%p)\n", this);
1060     (*this->pwsize)--;
1061     return (*this->pwpos)++;
1062 }
1063
1064 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1065 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1066 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
1067 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
1068         int, (basic_streambuf_char*), (this))
1069 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
1070 {
1071     TRACE("(%p)\n", this);
1072     return EOF;
1073 }
1074
1075 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1076 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1077 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
1078 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
1079         int, (basic_streambuf_char*), (this))
1080 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
1081 {
1082     int ret;
1083
1084     TRACE("(%p)\n", this);
1085
1086     if(call_basic_streambuf_char_underflow(this)==EOF)
1087         return EOF;
1088
1089     ret = (unsigned char)**this->prpos;
1090     (*this->prsize)--;
1091     (*this->prpos)++;
1092     return ret;
1093 }
1094
1095 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
1096 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
1097 static streamsize basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1098 {
1099     streamsize copied, chunk;
1100     int c;
1101
1102     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1103
1104     for(copied=0; copied<count && size;) {
1105         chunk = basic_streambuf_char__Gnavail(this);
1106         if(chunk > count-copied)
1107             chunk = count-copied;
1108
1109         if(chunk > 0) {
1110             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1111             *this->prpos += chunk;
1112             *this->prsize -= chunk;
1113             copied += chunk;
1114             size -= chunk;
1115         }else if((c = call_basic_streambuf_char_uflow(this)) != EOF) {
1116             ptr[copied] = c;
1117             copied++;
1118             size--;
1119         }else {
1120             break;
1121         }
1122     }
1123
1124     return copied;
1125 }
1126
1127 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
1128 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
1129 static streamsize basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1130 {
1131     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1132     return basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
1133 }
1134
1135 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1136 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1137 static void basic_streambuf_char__Unlock(basic_streambuf_char *this)
1138 {
1139     TRACE("(%p)\n", this);
1140 }
1141
1142 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1143 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1144 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
1145 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
1146 {
1147     TRACE("(%p)\n", this);
1148     return *this->prbuf;
1149 }
1150
1151 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1152 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1153 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
1154 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
1155 {
1156     TRACE("(%p)\n", this);
1157     return *this->prpos;
1158 }
1159
1160 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1161 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1162 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
1163 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
1164 {
1165     TRACE("(%p)\n", this);
1166     return *this->prpos+*this->prsize;
1167 }
1168
1169 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1170 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1171 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
1172 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
1173 {
1174     TRACE("(%p)\n", this);
1175     return *this->pwpos+*this->pwsize;
1176 }
1177
1178 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1179 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1180 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
1181 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
1182 {
1183     TRACE("(%p %d)\n", this, off);
1184     *this->prpos += off;
1185     *this->prsize -= off;
1186 }
1187
1188 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
1189 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
1190 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
1191 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1192         void, (basic_streambuf_char*, const locale*), (this, loc))
1193 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
1194 {
1195     TRACE("(%p %p)\n", this, loc);
1196 }
1197
1198 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1199 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1200 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
1201 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1202         int, (basic_streambuf_char*, int), (this, ch))
1203 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
1204 {
1205     TRACE("(%p %d)\n", this, ch);
1206     return EOF;
1207 }
1208
1209 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1210 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1211 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
1212 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1213         int, (basic_streambuf_char*, int), (this, ch))
1214 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
1215 {
1216     TRACE("(%p %d)\n", this, ch);
1217     return EOF;
1218 }
1219
1220 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1221 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1222 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
1223 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
1224 {
1225     TRACE("(%p)\n", this);
1226     return *this->pwbuf;
1227 }
1228
1229 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1230 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1231 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
1232 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
1233 {
1234     TRACE("(%p %d)\n", this, off);
1235     *this->pwpos += off;
1236     *this->pwsize -= off;
1237 }
1238
1239 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1240 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1241 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
1242 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
1243 {
1244     TRACE("(%p)\n", this);
1245     return *this->pwpos;
1246 }
1247
1248 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1249 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1250 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
1251 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
1252 {
1253     TRACE("(%p %p)\n", this, loc);
1254     memcpy(ret, &this->loc, sizeof(locale));
1255     call_basic_streambuf_char_imbue(this, loc);
1256     locale_copy_ctor(&this->loc, loc);
1257     return ret;
1258 }
1259
1260 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1261 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1262 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
1263 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1264         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1265 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
1266         fpos_int *ret, streamoff off, int way, int mode)
1267 {
1268     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1269     ret->off = -1;
1270     ret->pos = 0;
1271     ret->state = 0;
1272     return ret;
1273 }
1274
1275 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1276 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1277 static fpos_int* basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
1278         fpos_int *ret, streamoff off, int way, int mode)
1279 {
1280     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1281     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
1282 }
1283
1284 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1285 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1286 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
1287 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
1288         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1289 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
1290         fpos_int *ret, fpos_int pos, int mode)
1291 {
1292     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1293     ret->off = -1;
1294     ret->pos = 0;
1295     ret->state = 0;
1296     return ret;
1297 }
1298
1299 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1300 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1301 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
1302 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
1303         fpos_int *ret, fpos_int pos, int mode)
1304 {
1305     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1306     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
1307 }
1308
1309 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
1310 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
1311 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
1312 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
1313         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
1314 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
1315 {
1316     TRACE("(%p %p %ld)\n", this, buf, count);
1317     return this;
1318 }
1319
1320 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
1321 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
1322 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
1323 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
1324 {
1325     TRACE("(%p %p %ld)\n", this, buf, count);
1326     return call_basic_streambuf_char_setbuf(this, buf, count);
1327 }
1328
1329 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1330 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1331 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
1332 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 44, \
1333         int, (basic_streambuf_char*), (this))
1334 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
1335 {
1336     TRACE("(%p)\n", this);
1337     return 0;
1338 }
1339
1340 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1341 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1342 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
1343 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
1344 {
1345     TRACE("(%p)\n", this);
1346     return call_basic_streambuf_char_sync(this);
1347 }
1348
1349 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
1350 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
1351 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
1352 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1353 {
1354     TRACE("(%p %p %ld)\n", this, ptr, count);
1355     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1356 }
1357
1358 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1359 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
1360 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
1361 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1362         streamsize, (basic_streambuf_char*), (this))
1363 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
1364 {
1365     TRACE("(%p)\n", this);
1366     return 0;
1367 }
1368
1369 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1370 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
1371 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
1372 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
1373 {
1374     streamsize ret;
1375
1376     TRACE("(%p)\n", this);
1377
1378     ret = basic_streambuf_char__Gnavail(this);
1379     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
1380 }
1381
1382 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1383 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1384 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
1385 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
1386 {
1387     TRACE("(%p %d)\n", this, ch);
1388     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1389         (*this->prsize)++;
1390         (*this->prpos)--;
1391         return (unsigned char)ch;
1392     }
1393
1394     return call_basic_streambuf_char_pbackfail(this, (unsigned char)ch);
1395 }
1396
1397 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1398 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1399 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
1400 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
1401 {
1402     TRACE("(%p %d)\n", this, ch);
1403     return basic_streambuf_char__Pnavail(this) ?
1404         (*basic_streambuf_char__Pninc(this) = ch) :
1405         call_basic_streambuf_char_overflow(this, (unsigned char)ch);
1406 }
1407
1408 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1409 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1410 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
1411 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
1412 {
1413     TRACE("(%p)\n", this);
1414     if(*this->prpos && *this->prpos>*this->prbuf) {
1415         (*this->prsize)++;
1416         (*this->prpos)--;
1417         return (unsigned char)**this->prpos;
1418     }
1419
1420     return call_basic_streambuf_char_pbackfail(this, EOF);
1421 }
1422
1423 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1424 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1425 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1426 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1427 {
1428     TRACE("(%p)\n", this);
1429     if(basic_streambuf_char__Gnavail(this))
1430         basic_streambuf_char__Gninc(this);
1431     else
1432         call_basic_streambuf_char_uflow(this);
1433 }
1434
1435 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1436 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1437 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1438 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1439 {
1440     TRACE("(%p)\n", this);
1441     return basic_streambuf_char__Gnavail(this) ?
1442         (int)(unsigned char)*basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1443 }
1444
1445 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1446 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1447 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1448 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1449 {
1450     TRACE("(%p)\n", this);
1451     return basic_streambuf_char__Gnavail(this) ?
1452         (int)(unsigned char)*basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1453 }
1454
1455 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1456 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1457 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1458 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1459 {
1460     TRACE("(%p)\n", this);
1461
1462     if(basic_streambuf_char__Gnavail(this) > 1)
1463         return (unsigned char)*basic_streambuf_char__Gnpreinc(this);
1464     return basic_streambuf_char_sbumpc(this)==EOF ?
1465         EOF : basic_streambuf_char_sgetc(this);
1466 }
1467
1468 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1469 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1470 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
1471 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1472         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1473 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1474 {
1475     TRACE("(%p %p %ld)\n", this, ptr, count);
1476     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1477 }
1478
1479 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1480 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1481 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
1482 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
1483         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1484 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1485 {
1486     streamsize copied, chunk;
1487
1488     TRACE("(%p %p %ld)\n", this, ptr, count);
1489
1490     for(copied=0; copied<count;) {
1491         chunk = basic_streambuf_char__Pnavail(this);
1492         if(chunk > count-copied)
1493             chunk = count-copied;
1494
1495         if(chunk > 0) {
1496             memcpy(*this->pwpos, ptr+copied, chunk);
1497             *this->pwpos += chunk;
1498             *this->pwsize -= chunk;
1499             copied += chunk;
1500         }else if(call_basic_streambuf_char_overflow(this, (unsigned char)ptr[copied]) != EOF) {
1501             copied++;
1502         }else {
1503             break;
1504         }
1505     }
1506
1507     return copied;
1508 }
1509
1510 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1511 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1512 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
1513 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1514 {
1515     TRACE("(%p %p %ld)\n", this, ptr, count);
1516     return call_basic_streambuf_char_xsputn(this, ptr, count);
1517 }
1518
1519 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1520 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1521 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1522 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1523 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1524 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1525 {
1526     TRACE("(%p %p %p %p)\n", this, first, next, last);
1527
1528     this->wbuf = first;
1529     this->wpos = next;
1530     this->wsize = last-next;
1531 }
1532
1533 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1534 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1535 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1536 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1537 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1538 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1539 {
1540     basic_streambuf_wchar_setp_next(this, first, first, last);
1541 }
1542
1543 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1544 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1545 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1546 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1547 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1548 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1549 {
1550     TRACE("(%p %p %p %p)\n", this, first, next, last);
1551
1552     this->rbuf = first;
1553     this->rpos = next;
1554     this->rsize = last-next;
1555 }
1556
1557 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1558 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1559 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1560 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1561 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1562 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1563 {
1564     TRACE("(%p)\n", this);
1565
1566     this->prbuf = &this->rbuf;
1567     this->pwbuf = &this->wbuf;
1568     this->prpos = &this->rpos;
1569     this->pwpos = &this->wpos;
1570     this->prsize = &this->rsize;
1571     this->pwsize = &this->wsize;
1572
1573     basic_streambuf_wchar_setp(this, NULL, NULL);
1574     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1575 }
1576
1577 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1578 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1579 static basic_streambuf_wchar* basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1580 {
1581     TRACE("(%p %d)\n", this, uninitialized);
1582     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1583     mutex_ctor(&this->lock);
1584     return this;
1585 }
1586
1587 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1588 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1589 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1590 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1591 {
1592     TRACE("(%p %d)\n", this, uninitialized);
1593     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1594     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1595     return this;
1596 }
1597
1598 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1599 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1600 static basic_streambuf_wchar* basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1601 {
1602     TRACE("(%p)\n", this);
1603
1604     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1605     mutex_ctor(&this->lock);
1606     locale_ctor(&this->loc);
1607     basic_streambuf_wchar__Init_empty(this);
1608
1609     return this;
1610 }
1611
1612 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1613 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1614 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1615 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1616 {
1617     TRACE("(%p)\n", this);
1618     basic_streambuf_wchar_ctor(this);
1619     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1620     return this;
1621 }
1622
1623 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1624 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1625 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1626 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1627 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1628 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1629 {
1630     TRACE("(%p)\n", this);
1631
1632     mutex_dtor(&this->lock);
1633     locale_dtor(&this->loc);
1634 }
1635
1636 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_vector_dtor, 8)
1637 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1638 {
1639     TRACE("(%p %x)\n", this, flags);
1640     if(flags & 2) {
1641         /* we have an array, with the number of elements stored before the first object */
1642         INT_PTR i, *ptr = (INT_PTR *)this-1;
1643
1644         for(i=*ptr-1; i>=0; i--)
1645             basic_streambuf_wchar_dtor(this+i);
1646         MSVCRT_operator_delete(ptr);
1647     } else {
1648         basic_streambuf_wchar_dtor(this);
1649         if(flags & 1)
1650             MSVCRT_operator_delete(this);
1651     }
1652
1653     return this;
1654 }
1655
1656 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1657 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1658 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1659 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1660 static streamsize basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1661 {
1662     TRACE("(%p)\n", this);
1663     return *this->prpos ? *this->prsize : 0;
1664 }
1665
1666 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1667 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1668 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1669 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1670 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1671 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1672 {
1673     TRACE("(%p)\n", this);
1674     (*this->prsize)++;
1675     (*this->prpos)--;
1676     return *this->prpos;
1677 }
1678
1679 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1680 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1681 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1682 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1683 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1684 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1685 {
1686     TRACE("(%p)\n", this);
1687     (*this->prsize)--;
1688     return (*this->prpos)++;
1689 }
1690
1691 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1692 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1693 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1694 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1695 static wchar_t* basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1696 {
1697     TRACE("(%p)\n", this);
1698     (*this->prsize)--;
1699     (*this->prpos)++;
1700     return *this->prpos;
1701 }
1702
1703 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1704 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1705 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1706 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1707 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1708 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)
1709 {
1710     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1711
1712     this->prbuf = gf;
1713     this->pwbuf = pf;
1714     this->prpos = gn;
1715     this->pwpos = pn;
1716     this->prsize = gc;
1717     this->pwsize = pc;
1718 }
1719
1720 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1721 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1722 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1723 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1724 static void basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1725 {
1726     TRACE("(%p)\n", this);
1727     mutex_lock(&this->lock);
1728 }
1729
1730 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1731 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1732 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1733 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1734 static streamsize basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1735 {
1736     TRACE("(%p)\n", this);
1737     return *this->pwpos ? *this->pwsize : 0;
1738 }
1739
1740 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1741 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1742 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1743 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1744 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1745 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1746 {
1747     TRACE("(%p)\n", this);
1748     (*this->pwsize)--;
1749     return (*this->pwpos)++;
1750 }
1751
1752 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1753 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1754 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1755 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1756 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1757 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1758         unsigned short, (basic_streambuf_wchar*), (this))
1759 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1760 {
1761     TRACE("(%p)\n", this);
1762     return WEOF;
1763 }
1764
1765 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1766 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1767 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1768 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1769 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1770 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1771         unsigned short, (basic_streambuf_wchar*), (this))
1772 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1773 {
1774     int ret;
1775
1776     TRACE("(%p)\n", this);
1777
1778     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1779         return WEOF;
1780
1781     ret = **this->prpos;
1782     (*this->prsize)--;
1783     (*this->prpos)++;
1784     return ret;
1785 }
1786
1787 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1788 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1789 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1790 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1791 static streamsize basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1792 {
1793     streamsize copied, chunk;
1794     unsigned short c;
1795
1796     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1797
1798     for(copied=0; copied<count && size;) {
1799         chunk = basic_streambuf_wchar__Gnavail(this);
1800         if(chunk > count-copied)
1801             chunk = count-copied;
1802
1803         if(chunk > 0) {
1804             memcpy_s(ptr+copied, size, *this->prpos, chunk*sizeof(wchar_t));
1805             *this->prpos += chunk;
1806             *this->prsize -= chunk;
1807             copied += chunk;
1808             size -= chunk*sizeof(wchar_t);
1809         }else if((c = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1810             ptr[copied] = c;
1811             copied++;
1812             size--;
1813         }else {
1814             break;
1815         }
1816     }
1817
1818     return copied;
1819 }
1820
1821 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1822 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1823 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1824 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1825 static streamsize basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1826 {
1827     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1828     return basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1829 }
1830
1831 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1832 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1833 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1834 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1835 static void basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1836 {
1837     TRACE("(%p)\n", this);
1838     mutex_unlock(&this->lock);
1839 }
1840
1841 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1842 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1843 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1844 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1845 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1846 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1847 {
1848     TRACE("(%p)\n", this);
1849     return *this->prbuf;
1850 }
1851
1852 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1853 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1854 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1855 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1856 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1857 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1858 {
1859     TRACE("(%p)\n", this);
1860     return *this->prpos;
1861 }
1862
1863 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1864 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1865 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1866 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1867 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1868 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1869 {
1870     TRACE("(%p)\n", this);
1871     return *this->prpos+*this->prsize;
1872 }
1873
1874 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1875 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1876 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1877 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1878 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1879 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1880 {
1881     TRACE("(%p)\n", this);
1882     return *this->pwpos+*this->pwsize;
1883 }
1884
1885 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1886 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1887 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1888 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1889 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1890 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1891 {
1892     TRACE("(%p %d)\n", this, off);
1893     *this->prpos += off;
1894     *this->prsize -= off;
1895 }
1896
1897 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1898 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1899 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1900 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1901 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1902 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1903         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1904 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1905 {
1906     TRACE("(%p %p)\n", this, loc);
1907 }
1908
1909 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1910 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1911 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1912 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1913 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1914 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1915         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1916 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1917 {
1918     TRACE("(%p %d)\n", this, ch);
1919     return WEOF;
1920 }
1921
1922 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1923 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1924 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1925 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1926 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1927 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1928         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1929 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1930 {
1931     TRACE("(%p %d)\n", this, ch);
1932     return WEOF;
1933 }
1934
1935 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1936 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1937 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1938 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1939 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1940 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1941 {
1942     TRACE("(%p)\n", this);
1943     return *this->pwbuf;
1944 }
1945
1946 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1947 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1948 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1949 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1950 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1951 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1952 {
1953     TRACE("(%p %d)\n", this, off);
1954     *this->pwpos += off;
1955     *this->pwsize -= off;
1956 }
1957
1958 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1959 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1960 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1961 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1962 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1963 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1964 {
1965     TRACE("(%p)\n", this);
1966     return *this->pwpos;
1967 }
1968
1969 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1970 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1971 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1972 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1973 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
1974 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
1975 {
1976     TRACE("(%p %p)\n", this, loc);
1977     memcpy(ret, &this->loc, sizeof(locale));
1978     call_basic_streambuf_wchar_imbue(this, loc);
1979     locale_copy_ctor(&this->loc, loc);
1980     return ret;
1981 }
1982
1983 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1984 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1985 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1986 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1987 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
1988 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1989         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1990 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
1991         fpos_int *ret, streamoff off, int way, int mode)
1992 {
1993     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1994     ret->off = -1;
1995     ret->pos = 0;
1996     ret->state = 0;
1997     return ret;
1998 }
1999
2000 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2001 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2002 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2003 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2004 static fpos_int* basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
2005         fpos_int *ret, streamoff off, int way, int mode)
2006 {
2007     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2008     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
2009 }
2010
2011 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2012 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2013 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2014 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2015 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
2016 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
2017         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
2018 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
2019         fpos_int *ret, fpos_int pos, int mode)
2020 {
2021     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2022     ret->off = -1;
2023     ret->pos = 0;
2024     ret->state = 0;
2025     return ret;
2026 }
2027
2028 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2029 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2030 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2031 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2032 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
2033 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
2034         fpos_int *ret, fpos_int pos, int mode)
2035 {
2036     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2037     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
2038 }
2039
2040 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
2041 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
2042 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
2043 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
2044 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
2045 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
2046         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
2047 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2048 {
2049     TRACE("(%p %p %ld)\n", this, buf, count);
2050     return this;
2051 }
2052
2053 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
2054 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
2055 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
2056 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
2057 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
2058 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2059 {
2060     TRACE("(%p %p %ld)\n", this, buf, count);
2061     return call_basic_streambuf_wchar_setbuf(this, buf, count);
2062 }
2063
2064 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2065 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2066 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2067 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2068 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
2069 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 44, \
2070         int, (basic_streambuf_wchar*), (this))
2071 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
2072 {
2073     TRACE("(%p)\n", this);
2074     return 0;
2075 }
2076
2077 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2078 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
2079 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2080 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
2081 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
2082 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
2083 {
2084     TRACE("(%p)\n", this);
2085     return call_basic_streambuf_wchar_sync(this);
2086 }
2087
2088 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
2089 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
2090 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
2091 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
2092 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
2093 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2094 {
2095     TRACE("(%p %p %ld)\n", this, ptr, count);
2096     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2097 }
2098
2099 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2100 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
2101 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2102 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
2103 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
2104 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
2105         streamsize, (basic_streambuf_wchar*), (this))
2106 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
2107 {
2108     TRACE("(%p)\n", this);
2109     return 0;
2110 }
2111
2112 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2113 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
2114 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2115 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
2116 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
2117 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
2118 {
2119     streamsize ret;
2120
2121     TRACE("(%p)\n", this);
2122
2123     ret = basic_streambuf_wchar__Gnavail(this);
2124     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
2125 }
2126
2127 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2128 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2129 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2130 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2131 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
2132 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
2133 {
2134     TRACE("(%p %d)\n", this, ch);
2135     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
2136         (*this->prsize)++;
2137         (*this->prpos)--;
2138         return ch;
2139     }
2140
2141     return call_basic_streambuf_wchar_pbackfail(this, ch);
2142 }
2143
2144 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2145 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2146 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2147 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
2148 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
2149 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
2150 {
2151     TRACE("(%p %d)\n", this, ch);
2152     return basic_streambuf_wchar__Pnavail(this) ?
2153         (*basic_streambuf_wchar__Pninc(this) = ch) :
2154         call_basic_streambuf_wchar_overflow(this, ch);
2155 }
2156
2157 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2158 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2159 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2160 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2161 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
2162 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
2163 {
2164     TRACE("(%p)\n", this);
2165     if(*this->prpos && *this->prpos>*this->prbuf) {
2166         (*this->prsize)++;
2167         (*this->prpos)--;
2168         return **this->prpos;
2169     }
2170
2171     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
2172 }
2173
2174 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2175 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2176 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2177 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2178 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
2179 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
2180 {
2181     TRACE("(%p)\n", this);
2182     if(basic_streambuf_wchar__Gnavail(this))
2183         basic_streambuf_wchar__Gninc(this);
2184     else
2185         call_basic_streambuf_wchar_uflow(this);
2186 }
2187
2188 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2189 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2190 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2191 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2192 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
2193 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
2194 {
2195     TRACE("(%p)\n", this);
2196     return basic_streambuf_wchar__Gnavail(this) ?
2197         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
2198 }
2199
2200 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2201 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2202 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2203 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2204 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
2205 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
2206 {
2207     TRACE("(%p)\n", this);
2208     return basic_streambuf_wchar__Gnavail(this) ?
2209         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
2210 }
2211
2212 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2213 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2214 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2215 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2216 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
2217 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
2218 {
2219     TRACE("(%p)\n", this);
2220
2221     if(basic_streambuf_wchar__Gnavail(this) > 1)
2222         return *basic_streambuf_wchar__Gnpreinc(this);
2223     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
2224         WEOF : basic_streambuf_wchar_sgetc(this);
2225 }
2226
2227 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
2228 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
2229 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
2230 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
2231 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
2232 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
2233         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
2234 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2235 {
2236     TRACE("(%p %p %ld)\n", this, ptr, count);
2237     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2238 }
2239
2240 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
2241 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
2242 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
2243 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
2244 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
2245 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
2246         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
2247 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2248 {
2249     streamsize copied, chunk;
2250
2251     TRACE("(%p %p %ld)\n", this, ptr, count);
2252
2253     for(copied=0; copied<count;) {
2254         chunk = basic_streambuf_wchar__Pnavail(this);
2255         if(chunk > count-copied)
2256             chunk = count-copied;
2257
2258         if(chunk > 0) {
2259             memcpy(*this->pwpos, ptr+copied, chunk*sizeof(wchar_t));
2260             *this->pwpos += chunk;
2261             *this->pwsize -= chunk;
2262             copied += chunk;
2263         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
2264             copied++;
2265         }else {
2266             break;
2267         }
2268     }
2269
2270     return copied;
2271 }
2272
2273 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
2274 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
2275 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
2276 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
2277 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
2278 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2279 {
2280     TRACE("(%p %p %ld)\n", this, ptr, count);
2281     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
2282 }
2283
2284 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2285 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2286 int basic_filebuf_char__Init__Stinit = 0;
2287
2288 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2289 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2290 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
2291 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
2292 {
2293     TRACE("(%p %p %d)\n", this, file, which);
2294
2295     this->cvt = NULL;
2296     this->wrotesome = FALSE;
2297     this->state = basic_filebuf_char__Init__Stinit;
2298     this->close = (which == INITFL_open);
2299     this->file = file;
2300
2301     basic_streambuf_char__Init_empty(&this->base);
2302     if(file)
2303         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
2304                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
2305 }
2306
2307 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAV?$codecvt@DDH@2@@Z */
2308 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$codecvt@DDH@2@@Z */
2309 static void basic_filebuf_char__Initcvt(basic_filebuf_char *this, codecvt_char *cvt)
2310 {
2311     TRACE("(%p %p)\n", this, cvt);
2312
2313     if(codecvt_base_always_noconv(&cvt->base)) {
2314         this->cvt = NULL;
2315     }else {
2316         basic_streambuf_char__Init_empty(&this->base);
2317         this->cvt = cvt;
2318     }
2319 }
2320
2321 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAE_NXZ */
2322 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAA_NXZ */
2323 static MSVCP_bool basic_filebuf_char__Endwrite(basic_filebuf_char *this)
2324 {
2325     TRACE("(%p)\n", this);
2326
2327     if(!this->wrotesome || !this->cvt)
2328         return TRUE;
2329
2330
2331     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2332         return FALSE;
2333
2334     while(1) {
2335         /* TODO: check if we need a dynamic buffer here */
2336         char buf[128];
2337         char *next;
2338         int ret;
2339
2340         ret = codecvt_char_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2341         switch(ret) {
2342         case CODECVT_ok:
2343             this->wrotesome = FALSE;
2344             /* fall through */
2345         case CODECVT_partial:
2346             if(!fwrite(buf, next-buf, 1, this->file))
2347                 return FALSE;
2348             if(this->wrotesome)
2349                 break;
2350             /* fall through */
2351         case CODECVT_noconv:
2352             if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2353                 return FALSE;
2354             return TRUE;
2355         default:
2356             return FALSE;
2357         }
2358     }
2359 }
2360
2361 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2362 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2363 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2364 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2365 {
2366     basic_filebuf_char *ret = this;
2367
2368     TRACE("(%p)\n", this);
2369
2370     if(!this->file)
2371         return NULL;
2372
2373     /* TODO: handle exceptions */
2374     if(!basic_filebuf_char__Endwrite(this))
2375         ret = NULL;
2376     if(fclose(this->file))
2377         ret  = NULL;
2378
2379     basic_filebuf_char__Init(this, NULL, INITFL_close);
2380     return ret;
2381 }
2382
2383 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2384 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2385 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2386 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2387 {
2388     TRACE("(%p %p)\n", this, file);
2389
2390     basic_streambuf_char_ctor(&this->base);
2391     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2392
2393     basic_filebuf_char__Init(this, file, INITFL_new);
2394     return this;
2395 }
2396
2397 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2398 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2399 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2400 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2401 {
2402     return basic_filebuf_char_ctor_file(this, NULL);
2403 }
2404
2405 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2406 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2407 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2408 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2409 {
2410     TRACE("(%p %d)\n", this, uninitialized);
2411
2412     basic_streambuf_char_ctor(&this->base);
2413     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2414     return this;
2415 }
2416
2417 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2418 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2419 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2420 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2421 {
2422     TRACE("(%p)\n", this);
2423
2424     if(this->close)
2425         basic_filebuf_char_close(this);
2426     basic_streambuf_char_dtor(&this->base);
2427 }
2428
2429 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2430 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2431 {
2432     TRACE("(%p %x)\n", this, flags);
2433     if(flags & 2) {
2434         /* we have an array, with the number of elements stored before the first object */
2435         INT_PTR i, *ptr = (INT_PTR *)this-1;
2436
2437         for(i=*ptr-1; i>=0; i--)
2438             basic_filebuf_char_dtor(this+i);
2439         MSVCRT_operator_delete(ptr);
2440     } else {
2441         basic_filebuf_char_dtor(this);
2442         if(flags & 1)
2443             MSVCRT_operator_delete(this);
2444     }
2445
2446     return this;
2447 }
2448
2449 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2450 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2451 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2452 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2453 {
2454     TRACE("(%p)\n", this);
2455     return this->file != NULL;
2456 }
2457
2458 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2459 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2460 static FILE* _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2461 {
2462     static const wchar_t rW[] = {'r',0};
2463     static const struct {
2464         int mode;
2465         const wchar_t str[4];
2466         const wchar_t str_bin[4];
2467     } str_mode[] = {
2468         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2469         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2470         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2471         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2472         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2473         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2474         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2475         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2476         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2477     };
2478
2479     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2480     int mode_idx;
2481     FILE *f = NULL;
2482
2483     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2484
2485     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2486         if(str_mode[mode_idx].mode == real_mode)
2487             break;
2488     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2489         return NULL;
2490
2491     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2492         return NULL;
2493     else if(f)
2494         fclose(f);
2495
2496     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2497             && (f = _wfopen(name, rW))) {
2498         fclose(f);
2499         return NULL;
2500     }
2501
2502     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2503             : str_mode[mode_idx].str, prot);
2504     if(!f)
2505         return NULL;
2506
2507     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2508         fclose(f);
2509         return NULL;
2510     }
2511
2512     return f;
2513 }
2514
2515 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2516 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2517 static FILE* _Fiopen(const char *name, int mode, int prot)
2518 {
2519     wchar_t nameW[FILENAME_MAX];
2520
2521     TRACE("(%s %d %d)\n", name, mode, prot);
2522
2523     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2524         return NULL;
2525     return _Fiopen_wchar(nameW, mode, prot);
2526 }
2527
2528 /* ?__Fiopen@std@@YAPAU_iobuf@@PBDH@Z */
2529 /* ?__Fiopen@std@@YAPEAU_iobuf@@PEBDH@Z */
2530 FILE* __cdecl ___Fiopen(const char *name, int mode)
2531 {
2532     TRACE("(%p %d)\n", name, mode);
2533     return _Fiopen(name, mode, _SH_DENYNO);
2534 }
2535
2536 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2537 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2538 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2539 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2540 static basic_filebuf_char* basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2541 {
2542     FILE *f = NULL;
2543
2544     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2545
2546     if(basic_filebuf_char_is_open(this))
2547         return NULL;
2548
2549     if(!(f = _Fiopen_wchar(name, mode, prot)))
2550         return NULL;
2551
2552     basic_filebuf_char__Init(this, f, INITFL_open);
2553     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(&this->base.loc));
2554     return this;
2555 }
2556
2557 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2558 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2559 static basic_filebuf_char* basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2560 {
2561     wchar_t nameW[FILENAME_MAX];
2562
2563     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2564
2565     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2566         return NULL;
2567     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2568 }
2569
2570 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDF@Z */
2571 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDF@Z */
2572 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode_old, 12)
2573 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode_old(basic_filebuf_char *this, const char *name, short mode)
2574 {
2575     TRACE("(%p %p %d)\n", this, name, mode);
2576     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2577 }
2578
2579 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDH@Z */
2580 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDH@Z */
2581 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2582 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, int mode)
2583 {
2584     TRACE("(%p %p %d)\n", this, name, mode);
2585     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2586 }
2587
2588 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2589 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2590 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2591 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2592 {
2593     char buf[8], *dyn_buf;
2594     char ch = c, *to_next;
2595     const char *from_next;
2596     int ret, max_size;
2597
2598
2599     TRACE("(%p %d)\n", this, c);
2600
2601     if(!basic_filebuf_char_is_open(this))
2602         return EOF;
2603     if(c == EOF)
2604         return !c;
2605
2606     if(!this->cvt)
2607         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2608
2609     from_next = &ch;
2610     do {
2611         ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2612                 &from_next, buf, buf+sizeof(buf), &to_next);
2613
2614         switch(ret) {
2615         case CODECVT_partial:
2616             if(to_next == buf)
2617                 break;
2618             /* fall through */
2619         case CODECVT_ok:
2620             if(!fwrite(buf, to_next-buf, 1, this->file))
2621                 return EOF;
2622             if(ret == CODECVT_partial)
2623                 continue;
2624             return c;
2625         case CODECVT_noconv:
2626             return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2627         default:
2628             return EOF;
2629         }
2630
2631         break;
2632     } while(1);
2633
2634     max_size = codecvt_base_max_length(&this->cvt->base);
2635     dyn_buf = malloc(max_size);
2636     if(!dyn_buf)
2637         return EOF;
2638
2639     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2640             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2641
2642     switch(ret) {
2643     case CODECVT_ok:
2644         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2645         free(dyn_buf);
2646         return ret ? c : EOF;
2647     case CODECVT_partial:
2648         ERR("buffer should be big enough to store all output\n");
2649         /* fall through */
2650     default:
2651         free(dyn_buf);
2652         return EOF;
2653     }
2654 }
2655
2656 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2657 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2658 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2659 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2660 {
2661     TRACE("(%p %d)\n", this, c);
2662
2663     if(!basic_filebuf_char_is_open(this))
2664         return EOF;
2665
2666     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2667             && (c==EOF || (int)(unsigned char)basic_streambuf_char_gptr(&this->base)[-1]==c)) {
2668         basic_streambuf_char__Gndec(&this->base);
2669         return c==EOF ? !c : c;
2670     }else if(c!=EOF && !this->cvt) {
2671         return ungetc(c, this->file);
2672     }
2673
2674     return EOF;
2675 }
2676
2677 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2678 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2679 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2680 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2681 {
2682     char ch, buf[128], *to_next;
2683     const char *buf_next;
2684     int c, i;
2685
2686     TRACE("(%p)\n", this);
2687
2688     if(!basic_filebuf_char_is_open(this))
2689         return EOF;
2690
2691     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2692         return (unsigned char)*basic_streambuf_char__Gninc(&this->base);
2693
2694     c = fgetc(this->file);
2695     if(!this->cvt || c==EOF)
2696         return c;
2697
2698     buf_next = buf;
2699     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
2700         buf[i] = c;
2701
2702         switch(codecvt_char_in(this->cvt, &this->state, buf_next,
2703                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2704         case CODECVT_partial:
2705         case CODECVT_ok:
2706             if(to_next == &ch) {
2707                 c = fgetc(this->file);
2708                 if(c == EOF)
2709                     return EOF;
2710                 continue;
2711             }
2712
2713             for(i--; i>=buf_next-buf; i--)
2714                 ungetc(buf[i], this->file);
2715             return ch;
2716         case CODECVT_noconv:
2717             return (unsigned char)buf[0];
2718         default:
2719             return EOF;
2720         }
2721     }
2722
2723     FIXME("buffer is too small\n");
2724     return EOF;
2725 }
2726
2727 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2728 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2729 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2730 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2731 {
2732     int ret;
2733
2734     TRACE("(%p)\n", this);
2735
2736     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2737         return (unsigned char)*basic_streambuf_char_gptr(&this->base);
2738
2739     ret = call_basic_streambuf_char_uflow(&this->base);
2740     if(ret != EOF)
2741         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2742     return ret;
2743 }
2744
2745 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2746 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2747 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2748 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2749         fpos_int *ret, streamoff off, int way, int mode)
2750 {
2751     fpos_t pos;
2752
2753     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2754
2755     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2756             || fseek(this->file, off, way)) {
2757         ret->off = -1;
2758         ret->pos = 0;
2759         ret->state = 0;
2760         return ret;
2761     }
2762
2763     fgetpos(this->file, &pos);
2764     ret->off = 0;
2765     ret->pos = pos;
2766     ret->state = this->state;
2767     return ret;
2768 }
2769
2770 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2771 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2772 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2773 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2774         fpos_int *ret, fpos_int pos, int mode)
2775 {
2776     fpos_t fpos;
2777
2778     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2779
2780     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2781             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2782             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2783         ret->off = -1;
2784         ret->pos = 0;
2785         ret->state = 0;
2786         return ret;
2787     }
2788
2789     fgetpos(this->file, &fpos);
2790     ret->off = 0;
2791     ret->pos = fpos;
2792     ret->state = this->state;
2793     return ret;
2794 }
2795
2796 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2797 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2798 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2799 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2800 {
2801     TRACE("(%p %p %ld)\n", this, buf, count);
2802
2803     if(!basic_filebuf_char_is_open(this))
2804         return NULL;
2805
2806     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2807         return NULL;
2808
2809     basic_filebuf_char__Init(this, this->file, INITFL_open);
2810     return &this->base;
2811 }
2812
2813 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2814 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2815 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2816 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2817 {
2818     TRACE("(%p)\n", this);
2819
2820     if(!basic_filebuf_char_is_open(this))
2821         return 0;
2822
2823     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2824         return 0;
2825     return fflush(this->file);
2826 }
2827
2828 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
2829 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
2830 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_imbue, 8)
2831 void __thiscall basic_filebuf_char_imbue(basic_filebuf_char *this, const locale *loc)
2832 {
2833     TRACE("(%p %p)\n", this, loc);
2834     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(loc));
2835 }
2836
2837 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2838 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2839 int basic_filebuf_short__Init__Stinit = 0;
2840
2841 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2842 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2843 static void basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2844 {
2845     TRACE("(%p %p %d)\n", this, file, which);
2846
2847     this->cvt = NULL;
2848     this->wrotesome = FALSE;
2849     this->state = 0;
2850     this->close = (which == INITFL_open);
2851     this->file = file;
2852
2853     basic_streambuf_wchar__Init_empty(&this->base);
2854 }
2855
2856 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2857 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2858 DEFINE_THISCALL_WRAPPER(basic_filebuf_short__Init, 12)
2859 void __thiscall basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2860 {
2861     TRACE("(%p %p %d)\n", this, file, which);
2862
2863     this->cvt = NULL;
2864     this->wrotesome = FALSE;
2865     this->state = basic_filebuf_short__Init__Stinit;
2866     this->close = (which == INITFL_open);
2867     this->file = file;
2868
2869     basic_streambuf_wchar__Init_empty(&this->base);
2870 }
2871
2872 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$codecvt@_WDH@2@@Z */
2873 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$codecvt@_WDH@2@@Z */
2874 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAV?$codecvt@GDH@2@@Z */
2875 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$codecvt@GDH@2@@Z */
2876 static void basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this, codecvt_wchar *cvt)
2877 {
2878     TRACE("(%p %p)\n", this, cvt);
2879
2880     if(codecvt_base_always_noconv(&cvt->base)) {
2881         this->cvt = NULL;
2882     }else {
2883         basic_streambuf_wchar__Init_empty(&this->base);
2884         this->cvt = cvt;
2885     }
2886 }
2887
2888 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAE_NXZ */
2889 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAA_NXZ */
2890 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAE_NXZ */
2891 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAA_NXZ */
2892 static MSVCP_bool basic_filebuf_wchar__Endwrite(basic_filebuf_wchar *this)
2893 {
2894     TRACE("(%p)\n", this);
2895
2896     if(!this->wrotesome || !this->cvt)
2897         return TRUE;
2898
2899     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2900         return FALSE;
2901
2902     while(1) {
2903         /* TODO: check if we need a dynamic buffer here */
2904         char buf[128];
2905         char *next;
2906         int ret;
2907
2908         ret = codecvt_wchar_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2909         switch(ret) {
2910         case CODECVT_ok:
2911             this->wrotesome = FALSE;
2912             /* fall through */
2913         case CODECVT_partial:
2914             if(!fwrite(buf, next-buf, 1, this->file))
2915                 return FALSE;
2916             if(this->wrotesome)
2917                 break;
2918             /* fall through */
2919         case CODECVT_noconv:
2920             if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2921                 return FALSE;
2922             return TRUE;
2923         default:
2924             return FALSE;
2925         }
2926     }
2927 }
2928
2929 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
2930 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
2931 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
2932 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
2933 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_close, 4)
2934 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_close(basic_filebuf_wchar *this)
2935 {
2936     basic_filebuf_wchar *ret = this;
2937
2938     TRACE("(%p)\n", this);
2939
2940     if(!this->file)
2941         return NULL;
2942
2943     /* TODO: handle exceptions */
2944     if(!basic_filebuf_wchar__Endwrite(this))
2945         ret = NULL;
2946     if(fclose(this->file))
2947         ret  = NULL;
2948
2949     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
2950     return ret;
2951 }
2952
2953 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
2954 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2955 static basic_filebuf_wchar* basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
2956 {
2957     TRACE("(%p %p)\n", this, file);
2958
2959     basic_streambuf_wchar_ctor(&this->base);
2960     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
2961
2962     basic_filebuf_wchar__Init(this, file, INITFL_new);
2963     return this;
2964 }
2965
2966 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
2967 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2968 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_file, 8)
2969 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
2970 {
2971     TRACE("(%p %p)\n", this, file);
2972
2973     basic_streambuf_short_ctor(&this->base);
2974     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
2975
2976     basic_filebuf_short__Init(this, file, INITFL_new);
2977     return this;
2978 }
2979
2980 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2981 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2982 static basic_filebuf_wchar* basic_filebuf_wchar_ctor(basic_filebuf_wchar *this)
2983 {
2984     return basic_filebuf_wchar_ctor_file(this, NULL);
2985 }
2986
2987 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2988 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2989 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor, 4)
2990 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor(basic_filebuf_wchar *this)
2991 {
2992     return basic_filebuf_short_ctor_file(this, NULL);
2993 }
2994
2995 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2996 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2997 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_uninitialized, 8)
2998 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
2999 {
3000     TRACE("(%p %d)\n", this, uninitialized);
3001
3002     basic_streambuf_short_ctor(&this->base);
3003     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3004     return this;
3005 }
3006
3007 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
3008 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
3009 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
3010 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
3011 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_dtor, 4)
3012 void __thiscall basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
3013 {
3014     TRACE("(%p)\n", this);
3015
3016     if(this->close)
3017         basic_filebuf_wchar_close(this);
3018     basic_streambuf_wchar_dtor(&this->base);
3019 }
3020
3021 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
3022 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
3023 {
3024     TRACE("(%p %x)\n", this, flags);
3025     if(flags & 2) {
3026         /* we have an array, with the number of elements stored before the first object */
3027         INT_PTR i, *ptr = (INT_PTR *)this-1;
3028
3029         for(i=*ptr-1; i>=0; i--)
3030             basic_filebuf_wchar_dtor(this+i);
3031         MSVCRT_operator_delete(ptr);
3032     } else {
3033         basic_filebuf_wchar_dtor(this);
3034         if(flags & 1)
3035             MSVCRT_operator_delete(this);
3036     }
3037
3038     return this;
3039 }
3040
3041 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
3042 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
3043 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
3044 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
3045 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_is_open, 4)
3046 MSVCP_bool __thiscall basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
3047 {
3048     TRACE("(%p)\n", this);
3049     return this->file != NULL;
3050 }
3051
3052 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WHH@Z */
3053 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3054 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGHH@Z */
3055 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3056 static basic_filebuf_wchar* basic_filebuf_wchar_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3057 {
3058     FILE *f = NULL;
3059
3060     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3061
3062     if(basic_filebuf_wchar_is_open(this))
3063         return NULL;
3064
3065     if(!(f = _Fiopen_wchar(name, mode, prot)))
3066         return NULL;
3067
3068     basic_filebuf_wchar__Init(this, f, INITFL_open);
3069     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(&this->base.loc));
3070     return this;
3071 }
3072
3073 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDHH@Z */
3074 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3075 static basic_filebuf_wchar* basic_filebuf_wchar_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3076 {
3077     wchar_t nameW[FILENAME_MAX];
3078
3079     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3080
3081     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3082         return NULL;
3083     return basic_filebuf_wchar_open_wchar(this, nameW, mode, prot);
3084 }
3085
3086 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
3087 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
3088 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode_old, 12)
3089 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode_old(basic_filebuf_wchar *this, const char *name, short mode)
3090 {
3091     TRACE("(%p %p %d)\n", this, name, mode);
3092     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3093 }
3094
3095 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
3096 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
3097 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode, 12)
3098 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode(basic_filebuf_wchar *this, const char *name, int mode)
3099 {
3100     TRACE("(%p %p %d)\n", this, name, mode);
3101     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3102 }
3103
3104 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3105 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3106 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3107 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3108 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
3109 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
3110 {
3111     char buf[8], *dyn_buf, *to_next;
3112     wchar_t ch = c;
3113     const wchar_t *from_next;
3114     int max_size;
3115     unsigned short ret;
3116
3117
3118     TRACE("(%p %d)\n", this, c);
3119
3120     if(!basic_filebuf_wchar_is_open(this))
3121         return WEOF;
3122     if(c == WEOF)
3123         return !c;
3124
3125     if(!this->cvt)
3126         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3127
3128     from_next = &ch;
3129     do {
3130         ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3131                 &from_next, buf, buf+sizeof(buf), &to_next);
3132
3133         switch(ret) {
3134         case CODECVT_partial:
3135             if(to_next == buf)
3136                 break;
3137             /* fall through */
3138         case CODECVT_ok:
3139             if(!fwrite(buf, to_next-buf, 1, this->file))
3140                 return WEOF;
3141             if(ret == CODECVT_partial)
3142                 continue;
3143             return c;
3144         case CODECVT_noconv:
3145             return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3146         default:
3147             return WEOF;
3148         }
3149
3150         break;
3151     } while(1);
3152
3153     max_size = codecvt_base_max_length(&this->cvt->base);
3154     dyn_buf = malloc(max_size);
3155     if(!dyn_buf)
3156         return WEOF;
3157
3158     ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3159             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
3160
3161     switch(ret) {
3162     case CODECVT_ok:
3163         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
3164         free(dyn_buf);
3165         return ret ? c : WEOF;
3166     case CODECVT_partial:
3167         ERR("buffer should be big enough to store all output\n");
3168         /* fall through */
3169     default:
3170         free(dyn_buf);
3171         return WEOF;
3172     }
3173 }
3174
3175 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3176 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3177 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3178 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3179 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
3180 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
3181 {
3182     TRACE("(%p %d)\n", this, c);
3183
3184     if(!basic_filebuf_wchar_is_open(this))
3185         return WEOF;
3186
3187     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
3188             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==c)) {
3189         basic_streambuf_wchar__Gndec(&this->base);
3190         return c==WEOF ? !c : c;
3191     }else if(c!=WEOF && !this->cvt) {
3192         return ungetwc(c, this->file);
3193     }else if(c!=WEOF && basic_streambuf_wchar_gptr(&this->base)!=&this->putback) {
3194         this->putback = c;
3195         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback, &this->putback+1);
3196         return c;
3197     }
3198
3199     return WEOF;
3200 }
3201
3202 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3203 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3204 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3205 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3206 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
3207 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
3208 {
3209     wchar_t ch, *to_next;
3210     char buf[128];
3211     const char *buf_next;
3212     int c, i;
3213
3214     TRACE("(%p)\n", this);
3215
3216     if(!basic_filebuf_wchar_is_open(this))
3217         return WEOF;
3218
3219     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3220         return *basic_streambuf_wchar__Gninc(&this->base);
3221
3222     if(!this->cvt)
3223         return fgetwc(this->file);
3224
3225     buf_next = buf;
3226     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
3227         if((c = fgetc(this->file)) == EOF)
3228             return WEOF;
3229         buf[i] = c;
3230
3231         switch(codecvt_wchar_in(this->cvt, &this->state, buf_next,
3232                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
3233         case CODECVT_partial:
3234         case CODECVT_ok:
3235             if(to_next == &ch)
3236                 continue;
3237
3238             for(i--; i>=buf_next-buf; i--)
3239                 ungetc(buf[i], this->file);
3240             return ch;
3241         case CODECVT_noconv:
3242             if(i+1 < sizeof(wchar_t))
3243                 continue;
3244
3245             memcpy(&ch, buf, sizeof(wchar_t));
3246             return ch;
3247         default:
3248             return WEOF;
3249         }
3250     }
3251
3252     FIXME("buffer is too small\n");
3253     return WEOF;
3254 }
3255
3256 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3257 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3258 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3259 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3260 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
3261 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
3262 {
3263     unsigned short ret;
3264
3265     TRACE("(%p)\n", this);
3266
3267     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3268         return *basic_streambuf_wchar_gptr(&this->base);
3269
3270     ret = call_basic_streambuf_wchar_uflow(&this->base);
3271     if(ret != WEOF)
3272         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
3273     return ret;
3274 }
3275
3276 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3277 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3278 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3279 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3280 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 20)
3281 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
3282         fpos_int *ret, streamoff off, int way, int mode)
3283 {
3284     fpos_t pos;
3285
3286     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3287
3288     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback) {
3289         if(way == SEEKDIR_cur)
3290             off -= sizeof(wchar_t);
3291
3292         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3293     }
3294
3295     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3296             || fseek(this->file, off, way)) {
3297         ret->off = -1;
3298         ret->pos = 0;
3299         ret->state = 0;
3300         return ret;
3301     }
3302
3303     fgetpos(this->file, &pos);
3304     ret->off = 0;
3305     ret->pos = pos;
3306     ret->state = this->state;
3307     return ret;
3308 }
3309
3310 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3311 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3312 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3313 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3314 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
3315 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
3316         fpos_int *ret, fpos_int pos, int mode)
3317 {
3318     fpos_t fpos;
3319
3320     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3321
3322     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3323             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
3324             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
3325         ret->off = -1;
3326         ret->pos = 0;
3327         ret->state = 0;
3328         return ret;
3329     }
3330
3331     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback)
3332         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3333
3334     fgetpos(this->file, &fpos);
3335     ret->off = 0;
3336     ret->pos = fpos;
3337     ret->state = this->state;
3338     return ret;
3339 }
3340
3341 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
3342 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
3343 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 12)
3344 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3345 {
3346     TRACE("(%p %p %ld)\n", this, buf, count);
3347
3348     if(!basic_filebuf_wchar_is_open(this))
3349         return NULL;
3350
3351     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3352         return NULL;
3353
3354     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
3355     return &this->base;
3356 }
3357
3358 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
3359 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
3360 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 12)
3361 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3362 {
3363     TRACE("(%p %p %ld)\n", this, buf, count);
3364
3365     if(!basic_filebuf_wchar_is_open(this))
3366         return NULL;
3367
3368     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3369         return NULL;
3370
3371     basic_filebuf_short__Init(this, this->file, INITFL_open);
3372     return &this->base;
3373 }
3374
3375 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
3376 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
3377 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
3378 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
3379 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
3380 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
3381 {
3382     TRACE("(%p)\n", this);
3383
3384     if(!basic_filebuf_wchar_is_open(this))
3385         return 0;
3386
3387     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
3388         return 0;
3389     return fflush(this->file);
3390 }
3391
3392 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
3393 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
3394 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_imbue, 8)
3395 void __thiscall basic_filebuf_wchar_imbue(basic_filebuf_wchar *this, const locale *loc)
3396 {
3397     TRACE("(%p %p)\n", this, loc);
3398     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(loc));
3399 }
3400
3401 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
3402 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
3403 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_imbue, 8)
3404 void __thiscall basic_filebuf_short_imbue(basic_filebuf_wchar *this, const locale *loc)
3405 {
3406     TRACE("(%p %p)\n", this, loc);
3407     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(loc));
3408 }
3409
3410 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3411 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3412 static int basic_stringbuf_char__Getstate(basic_stringbuf_char *this, IOSB_openmode mode)
3413 {
3414     int state = 0;
3415
3416     if(!(mode & OPENMODE_in))
3417         state |= STRINGBUF_no_read;
3418
3419     if(!(mode & OPENMODE_out))
3420         state |= STRINGBUF_no_write;
3421
3422     if(mode & OPENMODE_ate)
3423         state |= STRINGBUF_at_end;
3424
3425     if(mode & OPENMODE_app)
3426         state |= STRINGBUF_append;
3427
3428     return state;
3429 }
3430
3431 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXPBDIH@Z */
3432 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXPEBD_KH@Z */
3433 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Init, 16)
3434 void __thiscall basic_stringbuf_char__Init(basic_stringbuf_char *this, const char *str, MSVCP_size_t count, int state)
3435 {
3436     TRACE("(%p, %p, %ld, %d)\n", this, str, count, state);
3437
3438     basic_streambuf_char__Init_empty(&this->base);
3439
3440     this->state = state;
3441     this->seekhigh = NULL;
3442
3443     if(count && str) {
3444         char *buf = MSVCRT_operator_new(count);
3445         if(!buf) {
3446             ERR("Out of memory\n");
3447             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3448         }
3449
3450         memcpy(buf, str, count);
3451         this->seekhigh = buf + count;
3452
3453         this->state |= STRINGBUF_allocated;
3454
3455         if(!(state & STRINGBUF_no_read))
3456             basic_streambuf_char_setg(&this->base, buf, buf, buf + count);
3457
3458         if(!(state & STRINGBUF_no_write)) {
3459             basic_streambuf_char_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3460
3461             if(!basic_streambuf_char_gptr(&this->base))
3462                 basic_streambuf_char_setg(&this->base, buf, 0, buf);
3463         }
3464     }
3465 }
3466
3467 /* ??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 */
3468 /* ??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 */
3469 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_str, 12)
3470 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_str(basic_stringbuf_char *this,
3471         const basic_string_char *str, IOSB_openmode mode)
3472 {
3473     TRACE("(%p %p %d)\n", this, str, mode);
3474
3475     basic_streambuf_char_ctor(&this->base);
3476     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3477
3478     basic_stringbuf_char__Init(this, basic_string_char_c_str(str),
3479             str->size, basic_stringbuf_char__Getstate(this, mode));
3480     return this;
3481 }
3482
3483 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
3484 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
3485 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_mode, 8)
3486 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_mode(
3487         basic_stringbuf_char *this, IOSB_openmode mode)
3488 {
3489     TRACE("(%p %d)\n", this, mode);
3490
3491     basic_streambuf_char_ctor(&this->base);
3492     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3493
3494     basic_stringbuf_char__Init(this, NULL, 0, basic_stringbuf_char__Getstate(this, mode));
3495     return this;
3496 }
3497
3498 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
3499 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
3500 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor, 4)
3501 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor(basic_stringbuf_char *this)
3502 {
3503     return basic_stringbuf_char_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3504 }
3505
3506 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXXZ */
3507 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXXZ */
3508 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Tidy, 4)
3509 void __thiscall basic_stringbuf_char__Tidy(basic_stringbuf_char *this)
3510 {
3511     TRACE("(%p)\n", this);
3512
3513     if(this->state & STRINGBUF_allocated) {
3514         MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
3515         this->seekhigh = NULL;
3516         this->state &= ~STRINGBUF_allocated;
3517     }
3518
3519     basic_streambuf_char__Init_empty(&this->base);
3520 }
3521
3522 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
3523 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
3524 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_dtor, 4)
3525 void __thiscall basic_stringbuf_char_dtor(basic_stringbuf_char *this)
3526 {
3527     TRACE("(%p)\n", this);
3528
3529     basic_stringbuf_char__Tidy(this);
3530     basic_streambuf_char_dtor(&this->base);
3531 }
3532
3533 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_vector_dtor, 8)
3534 basic_stringbuf_char* __thiscall basic_stringbuf_char_vector_dtor(basic_stringbuf_char *this, unsigned int flags)
3535 {
3536     TRACE("(%p %x)\n", this, flags);
3537
3538     if(flags & 2) {
3539         /* we have an array, with the number of elements stored before the first object */
3540         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3541
3542         for (i = *ptr - 1; i >= 0; i--)
3543             basic_stringbuf_char_dtor(this+i);
3544
3545         MSVCRT_operator_delete(ptr);
3546     }else {
3547         basic_stringbuf_char_dtor(this);
3548
3549         if(flags & 1)
3550             MSVCRT_operator_delete(this);
3551     }
3552
3553     return this;
3554 }
3555
3556 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3557 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3558 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_overflow, 8)
3559 int __thiscall basic_stringbuf_char_overflow(basic_stringbuf_char *this, int meta)
3560 {
3561     MSVCP_size_t oldsize, size;
3562     char *ptr, *buf;
3563
3564     TRACE("(%p %x)\n", this, meta);
3565
3566     if(meta == EOF)
3567         return !EOF;
3568     if(this->state & STRINGBUF_no_write)
3569         return EOF;
3570
3571     ptr = basic_streambuf_char_pptr(&this->base);
3572     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3573         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
3574                 this->seekhigh, basic_streambuf_char_epptr(&this->base));
3575
3576     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
3577         return (*basic_streambuf_char__Pninc(&this->base) = meta);
3578
3579     oldsize = (ptr ? basic_streambuf_char_epptr(&this->base)-basic_streambuf_char_eback(&this->base): 0);
3580     size = oldsize|0xf;
3581     size += size/2;
3582     buf = MSVCRT_operator_new(size);
3583     if(!buf) {
3584         ERR("Out of memory\n");
3585         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3586     }
3587
3588     if(!oldsize) {
3589         this->seekhigh = buf;
3590         basic_streambuf_char_setp(&this->base, buf, buf+size);
3591         if(this->state & STRINGBUF_no_read)
3592             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3593         else
3594             basic_streambuf_char_setg(&this->base, buf, buf, buf+1);
3595
3596         this->state |= STRINGBUF_allocated;
3597     }else {
3598         ptr = basic_streambuf_char_eback(&this->base);
3599         memcpy(buf, ptr, oldsize);
3600
3601         this->seekhigh = buf+(this->seekhigh-ptr);
3602         basic_streambuf_char_setp_next(&this->base, buf,
3603                 buf+(basic_streambuf_char_pptr(&this->base)-ptr), buf+size);
3604         if(this->state & STRINGBUF_no_read)
3605             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3606         else
3607             basic_streambuf_char_setg(&this->base, buf,
3608                     buf+(basic_streambuf_char_gptr(&this->base)-ptr),
3609                     basic_streambuf_char_pptr(&this->base)+1);
3610
3611         MSVCRT_operator_delete(ptr);
3612     }
3613
3614     return (*basic_streambuf_char__Pninc(&this->base) = meta);
3615 }
3616
3617 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3618 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3619 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_pbackfail, 8)
3620 int __thiscall basic_stringbuf_char_pbackfail(basic_stringbuf_char *this, int c)
3621 {
3622     char *cur;
3623
3624     TRACE("(%p %x)\n", this, c);
3625
3626     cur = basic_streambuf_char_gptr(&this->base);
3627     if(!cur || cur==basic_streambuf_char_eback(&this->base)
3628             || (c!=EOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3629         return EOF;
3630
3631     if(c != EOF)
3632         cur[-1] = c;
3633     basic_streambuf_char_gbump(&this->base, -1);
3634     return c==EOF ? !EOF : c;
3635 }
3636
3637 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHXZ */
3638 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHXZ */
3639 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_underflow, 4)
3640 int __thiscall basic_stringbuf_char_underflow(basic_stringbuf_char *this)
3641 {
3642     char *ptr, *cur;
3643
3644     TRACE("(%p)\n", this);
3645
3646     cur = basic_streambuf_char_gptr(&this->base);
3647     if(!cur || this->state&STRINGBUF_no_read)
3648         return EOF;
3649
3650     ptr  = basic_streambuf_char_pptr(&this->base);
3651     if(this->seekhigh < ptr)
3652         this->seekhigh = ptr;
3653
3654     ptr = basic_streambuf_char_egptr(&this->base);
3655     if(this->seekhigh > ptr)
3656         basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base), cur, this->seekhigh);
3657
3658     if(cur < this->seekhigh)
3659         return (unsigned char)*cur;
3660     return EOF;
3661 }
3662
3663 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3664 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3665 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekoff, 20)
3666 fpos_int* __thiscall basic_stringbuf_char_seekoff(basic_stringbuf_char *this,
3667         fpos_int *ret, streamoff off, int way, int mode)
3668 {
3669     char *beg, *cur_r, *cur_w;
3670
3671     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3672
3673     cur_w = basic_streambuf_char_pptr(&this->base);
3674     if(cur_w > this->seekhigh)
3675         this->seekhigh = cur_w;
3676
3677     ret->off = 0;
3678     ret->pos = 0;
3679     ret->state = 0;
3680
3681     beg = basic_streambuf_char_eback(&this->base);
3682     cur_r = basic_streambuf_char_gptr(&this->base);
3683     if((mode & OPENMODE_in) && cur_r) {
3684         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3685             off += cur_r-beg;
3686         else if(way == SEEKDIR_end)
3687             off += this->seekhigh-beg;
3688         else if(way != SEEKDIR_beg)
3689             off = -1;
3690
3691         if(off<0 || off>this->seekhigh-beg) {
3692             off = -1;
3693         }else {
3694             basic_streambuf_char_gbump(&this->base, beg-cur_r+off);
3695             if((mode & OPENMODE_out) && cur_w) {
3696                 basic_streambuf_char_setp_next(&this->base, beg,
3697                         basic_streambuf_char_gptr(&this->base),
3698                         basic_streambuf_char_epptr(&this->base));
3699             }
3700         }
3701     }else if((mode & OPENMODE_out) && cur_w) {
3702         if(way == SEEKDIR_cur)
3703             off += cur_w-beg;
3704         else if(way == SEEKDIR_end)
3705             off += this->seekhigh-beg;
3706         else if(way != SEEKDIR_beg)
3707             off = -1;
3708
3709         if(off<0 || off>this->seekhigh-beg)
3710             off = -1;
3711         else
3712             basic_streambuf_char_pbump(&this->base, beg-cur_w+off);
3713     }else {
3714         off = -1;
3715     }
3716
3717     ret->off = off;
3718     return ret;
3719 }
3720
3721 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3722 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3723 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekpos, 36)
3724 fpos_int* __thiscall basic_stringbuf_char_seekpos(basic_stringbuf_char *this,
3725         fpos_int *ret, fpos_int pos, int mode)
3726 {
3727     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3728
3729     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
3730         *ret = pos;
3731         return ret;
3732     }
3733
3734     return basic_stringbuf_char_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
3735 }
3736
3737 /* ?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 */
3738 /* ?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 */
3739 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_set, 8)
3740 void __thiscall basic_stringbuf_char_str_set(basic_stringbuf_char *this, const basic_string_char *str)
3741 {
3742     TRACE("(%p %p)\n", this, str);
3743
3744     basic_stringbuf_char__Tidy(this);
3745     basic_stringbuf_char__Init(this, basic_string_char_c_str(str), str->size, this->state);
3746 }
3747
3748 /* ?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 */
3749 /* ?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 */
3750 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_get, 8)
3751 basic_string_char* __thiscall basic_stringbuf_char_str_get(const basic_stringbuf_char *this, basic_string_char *ret)
3752 {
3753     char *ptr;
3754
3755     TRACE("(%p)\n", this);
3756
3757     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_char_pptr(&this->base)) {
3758         char *pptr;
3759
3760         ptr = basic_streambuf_char_pbase(&this->base);
3761         pptr = basic_streambuf_char_pptr(&this->base);
3762
3763         return basic_string_char_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
3764     }
3765
3766     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_char_gptr(&this->base)) {
3767         ptr = basic_streambuf_char_eback(&this->base);
3768         return basic_string_char_ctor_cstr_len(ret, ptr, basic_streambuf_char_egptr(&this->base) - ptr);
3769     }
3770
3771     return basic_string_char_ctor(ret);
3772 }
3773
3774 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAEHH@Z */
3775 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAAHH@Z */
3776 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3777 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3778 static int basic_stringbuf_wchar__Getstate(basic_stringbuf_wchar *this, IOSB_openmode mode)
3779 {
3780     int state = 0;
3781
3782     if(!(mode & OPENMODE_in))
3783         state |= STRINGBUF_no_read;
3784
3785     if(!(mode & OPENMODE_out))
3786         state |= STRINGBUF_no_write;
3787
3788     if(mode & OPENMODE_ate)
3789         state |= STRINGBUF_at_end;
3790
3791     if(mode & OPENMODE_app)
3792         state |= STRINGBUF_append;
3793
3794     return state;
3795 }
3796
3797 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXPB_WIH@Z */
3798 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXPEB_W_KH@Z */
3799 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXPBGIH@Z */
3800 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXPEBG_KH@Z */
3801 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Init, 16)
3802 void __thiscall basic_stringbuf_wchar__Init(basic_stringbuf_wchar *this, const wchar_t *str, MSVCP_size_t count, int state)
3803 {
3804     TRACE("(%p, %p, %lu, %d)\n", this, str, count, state);
3805
3806     basic_streambuf_wchar__Init_empty(&this->base);
3807
3808     this->state = state;
3809     this->seekhigh = NULL;
3810
3811     if(count && str) {
3812         wchar_t *buf = MSVCRT_operator_new(count*sizeof(wchar_t));
3813         if(!buf) {
3814             ERR("Out of memory\n");
3815             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3816         }
3817
3818         memcpy(buf, str, count*sizeof(wchar_t));
3819         this->seekhigh = buf + count;
3820
3821         this->state |= STRINGBUF_allocated;
3822
3823         if(!(state & STRINGBUF_no_read))
3824             basic_streambuf_wchar_setg(&this->base, buf, buf, buf + count);
3825
3826         if(!(state & STRINGBUF_no_write)) {
3827             basic_streambuf_wchar_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3828
3829             if(!basic_streambuf_wchar_gptr(&this->base))
3830                 basic_streambuf_wchar_setg(&this->base, buf, 0, buf);
3831         }
3832     }
3833 }
3834
3835 /* ??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 */
3836 /* ??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 */
3837 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_str(basic_stringbuf_wchar *this,
3838         const basic_string_wchar *str, IOSB_openmode mode)
3839 {
3840     TRACE("(%p %p %d)\n", this, str, mode);
3841
3842     basic_streambuf_wchar_ctor(&this->base);
3843     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3844
3845     basic_stringbuf_wchar__Init(this, basic_string_wchar_c_str(str),
3846             str->size, basic_stringbuf_wchar__Getstate(this, mode));
3847     return this;
3848 }
3849
3850 /* ??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 */
3851 /* ??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 */
3852 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_str, 12)
3853 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_str(basic_stringbuf_wchar *this,
3854         const basic_string_wchar *str, IOSB_openmode mode)
3855 {
3856     basic_stringbuf_wchar_ctor_str(this, str, mode);
3857     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3858     return this;
3859 }
3860
3861 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
3862 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
3863 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_mode(
3864         basic_stringbuf_wchar *this, IOSB_openmode mode)
3865 {
3866     TRACE("(%p %d)\n", this, mode);
3867
3868     basic_streambuf_wchar_ctor(&this->base);
3869     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3870
3871     basic_stringbuf_wchar__Init(this, NULL, 0, basic_stringbuf_wchar__Getstate(this, mode));
3872     return this;
3873 }
3874
3875 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
3876 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
3877 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_mode, 8)
3878 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_mode(
3879         basic_stringbuf_wchar *this, IOSB_openmode mode)
3880 {
3881     basic_stringbuf_wchar_ctor_mode(this, mode);
3882     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3883     return this;
3884 }
3885
3886 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
3887 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
3888 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor, 4)
3889 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor(basic_stringbuf_wchar *this)
3890 {
3891     return basic_stringbuf_short_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3892 }
3893
3894 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXXZ */
3895 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXXZ */
3896 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXXZ */
3897 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXXZ */
3898 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Tidy, 4)
3899 void __thiscall basic_stringbuf_wchar__Tidy(basic_stringbuf_wchar *this)
3900 {
3901     TRACE("(%p)\n", this);
3902
3903     if(this->state & STRINGBUF_allocated) {
3904         MSVCRT_operator_delete(basic_streambuf_wchar_eback(&this->base));
3905         this->seekhigh = NULL;
3906         this->state &= ~STRINGBUF_allocated;
3907     }
3908
3909     basic_streambuf_wchar__Init_empty(&this->base);
3910 }
3911
3912 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
3913 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
3914 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
3915 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
3916 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_dtor, 4)
3917 void __thiscall basic_stringbuf_wchar_dtor(basic_stringbuf_wchar *this)
3918 {
3919     TRACE("(%p)\n", this);
3920
3921     basic_stringbuf_wchar__Tidy(this);
3922     basic_streambuf_wchar_dtor(&this->base);
3923 }
3924
3925 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_vector_dtor, 8)
3926 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_vector_dtor(basic_stringbuf_wchar *this, unsigned int flags)
3927 {
3928     TRACE("(%p %x)\n", this, flags);
3929
3930     if(flags & 2) {
3931         /* we have an array, with the number of elements stored before the first object */
3932         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3933
3934         for (i = *ptr - 1; i >= 0; i--)
3935             basic_stringbuf_wchar_dtor(this+i);
3936
3937         MSVCRT_operator_delete(ptr);
3938     }else {
3939         basic_stringbuf_wchar_dtor(this);
3940
3941         if(flags & 1)
3942             MSVCRT_operator_delete(this);
3943     }
3944
3945     return this;
3946 }
3947
3948 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
3949 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
3950 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
3951 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
3952 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_overflow, 8)
3953 unsigned short __thiscall basic_stringbuf_wchar_overflow(basic_stringbuf_wchar *this, unsigned short meta)
3954 {
3955     MSVCP_size_t oldsize, size;
3956     wchar_t *ptr, *buf;
3957
3958     TRACE("(%p %x)\n", this, meta);
3959
3960     if(meta == WEOF)
3961         return !WEOF;
3962     if(this->state & STRINGBUF_no_write)
3963         return WEOF;
3964
3965     ptr = basic_streambuf_wchar_pptr(&this->base);
3966     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3967         basic_streambuf_wchar_setp_next(&this->base, basic_streambuf_wchar_pbase(&this->base),
3968                 this->seekhigh, basic_streambuf_wchar_epptr(&this->base));
3969
3970     if(ptr && ptr<basic_streambuf_wchar_epptr(&this->base))
3971         return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
3972
3973     oldsize = (ptr ? basic_streambuf_wchar_epptr(&this->base)-basic_streambuf_wchar_eback(&this->base): 0);
3974     size = oldsize|0xf;
3975     size += size/2;
3976     buf = MSVCRT_operator_new(size*sizeof(wchar_t));
3977     if(!buf) {
3978         ERR("Out of memory\n");
3979         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3980     }
3981
3982     if(!oldsize) {
3983         this->seekhigh = buf;
3984         basic_streambuf_wchar_setp(&this->base, buf, buf+size);
3985         if(this->state & STRINGBUF_no_read)
3986             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
3987         else
3988             basic_streambuf_wchar_setg(&this->base, buf, buf, buf+1);
3989
3990         this->state |= STRINGBUF_allocated;
3991     }else {
3992         ptr = basic_streambuf_wchar_eback(&this->base);
3993         memcpy(buf, ptr, oldsize*sizeof(wchar_t));
3994
3995         this->seekhigh = buf+(this->seekhigh-ptr);
3996         basic_streambuf_wchar_setp_next(&this->base, buf,
3997                 buf+(basic_streambuf_wchar_pptr(&this->base)-ptr), buf+size);
3998         if(this->state & STRINGBUF_no_read)
3999             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4000         else
4001             basic_streambuf_wchar_setg(&this->base, buf,
4002                     buf+(basic_streambuf_wchar_gptr(&this->base)-ptr),
4003                     basic_streambuf_wchar_pptr(&this->base)+1);
4004
4005         MSVCRT_operator_delete(ptr);
4006     }
4007
4008     return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4009 }
4010
4011 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4012 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4013 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4014 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4015 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_pbackfail, 8)
4016 unsigned short __thiscall basic_stringbuf_wchar_pbackfail(basic_stringbuf_wchar *this, unsigned short c)
4017 {
4018     wchar_t *cur;
4019
4020     TRACE("(%p %x)\n", this, c);
4021
4022     cur = basic_streambuf_wchar_gptr(&this->base);
4023     if(!cur || cur==basic_streambuf_wchar_eback(&this->base)
4024             || (c!=WEOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
4025         return WEOF;
4026
4027     if(c != WEOF)
4028         cur[-1] = c;
4029     basic_streambuf_wchar_gbump(&this->base, -1);
4030     return c==WEOF ? !WEOF : c;
4031 }
4032
4033 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGXZ */
4034 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGXZ */
4035 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGXZ */
4036 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGXZ */
4037 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_underflow, 4)
4038 unsigned short __thiscall basic_stringbuf_wchar_underflow(basic_stringbuf_wchar *this)
4039 {
4040     wchar_t *ptr, *cur;
4041
4042     TRACE("(%p)\n", this);
4043
4044     cur = basic_streambuf_wchar_gptr(&this->base);
4045     if(!cur || this->state&STRINGBUF_no_read)
4046         return WEOF;
4047
4048     ptr  = basic_streambuf_wchar_pptr(&this->base);
4049     if(this->seekhigh < ptr)
4050         this->seekhigh = ptr;
4051
4052     ptr = basic_streambuf_wchar_egptr(&this->base);
4053     if(this->seekhigh > ptr)
4054         basic_streambuf_wchar_setg(&this->base, basic_streambuf_wchar_eback(&this->base), cur, this->seekhigh);
4055
4056     if(cur < this->seekhigh)
4057         return *cur;
4058     return WEOF;
4059 }
4060
4061 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4062 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4063 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4064 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4065 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekoff, 20)
4066 fpos_int* __thiscall basic_stringbuf_wchar_seekoff(basic_stringbuf_wchar *this,
4067         fpos_int *ret, streamoff off, int way, int mode)
4068 {
4069     wchar_t *beg, *cur_r, *cur_w;
4070
4071     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
4072
4073     cur_w = basic_streambuf_wchar_pptr(&this->base);
4074     if(cur_w > this->seekhigh)
4075         this->seekhigh = cur_w;
4076
4077     ret->off = 0;
4078     ret->pos = 0;
4079     ret->state = 0;
4080
4081     beg = basic_streambuf_wchar_eback(&this->base);
4082     cur_r = basic_streambuf_wchar_gptr(&this->base);
4083     if((mode & OPENMODE_in) && cur_r) {
4084         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
4085             off += cur_r-beg;
4086         else if(way == SEEKDIR_end)
4087             off += this->seekhigh-beg;
4088         else if(way != SEEKDIR_beg)
4089             off = -1;
4090
4091         if(off<0 || off>this->seekhigh-beg) {
4092             off = -1;
4093         }else {
4094             basic_streambuf_wchar_gbump(&this->base, beg-cur_r+off);
4095             if((mode & OPENMODE_out) && cur_w) {
4096                 basic_streambuf_wchar_setp_next(&this->base, beg,
4097                         basic_streambuf_wchar_gptr(&this->base),
4098                         basic_streambuf_wchar_epptr(&this->base));
4099             }
4100         }
4101     }else if((mode & OPENMODE_out) && cur_w) {
4102         if(way == SEEKDIR_cur)
4103             off += cur_w-beg;
4104         else if(way == SEEKDIR_end)
4105             off += this->seekhigh-beg;
4106         else if(way != SEEKDIR_beg)
4107             off = -1;
4108
4109         if(off<0 || off>this->seekhigh-beg)
4110             off = -1;
4111         else
4112             basic_streambuf_wchar_pbump(&this->base, beg-cur_w+off);
4113     }else {
4114         off = -1;
4115     }
4116
4117     ret->off = off;
4118     return ret;
4119 }
4120
4121 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4122 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4123 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4124 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4125 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekpos, 36)
4126 fpos_int* __thiscall basic_stringbuf_wchar_seekpos(basic_stringbuf_wchar *this,
4127         fpos_int *ret, fpos_int pos, int mode)
4128 {
4129     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
4130
4131     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
4132         *ret = pos;
4133         return ret;
4134     }
4135
4136     return basic_stringbuf_wchar_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
4137 }
4138
4139 /* ?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 */
4140 /* ?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 */
4141 /* ?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 */
4142 /* ?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 */
4143 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_set, 8)
4144 void __thiscall basic_stringbuf_wchar_str_set(basic_stringbuf_wchar *this, const basic_string_wchar *str)
4145 {
4146     TRACE("(%p %p)\n", this, str);
4147
4148     basic_stringbuf_wchar__Tidy(this);
4149     basic_stringbuf_wchar__Init(this, basic_string_wchar_c_str(str), str->size, this->state);
4150 }
4151
4152 /* ?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 */
4153 /* ?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 */
4154 /* ?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 */
4155 /* ?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 */
4156 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_get, 8)
4157 basic_string_wchar* __thiscall basic_stringbuf_wchar_str_get(const basic_stringbuf_wchar *this, basic_string_wchar *ret)
4158 {
4159     wchar_t *ptr;
4160
4161     TRACE("(%p)\n", this);
4162
4163     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_wchar_pptr(&this->base)) {
4164         wchar_t *pptr;
4165
4166         ptr = basic_streambuf_wchar_pbase(&this->base);
4167         pptr = basic_streambuf_wchar_pptr(&this->base);
4168
4169         return basic_string_wchar_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
4170     }
4171
4172     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_wchar_gptr(&this->base)) {
4173         ptr = basic_streambuf_wchar_eback(&this->base);
4174         return basic_string_wchar_ctor_cstr_len(ret, ptr, basic_streambuf_wchar_egptr(&this->base) - ptr);
4175     }
4176
4177     return basic_string_wchar_ctor(ret);
4178 }
4179
4180 /* ??0ios_base@std@@IAE@XZ */
4181 /* ??0ios_base@std@@IEAA@XZ */
4182 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
4183 ios_base* __thiscall ios_base_ctor(ios_base *this)
4184 {
4185     TRACE("(%p)\n", this);
4186     this->vtable = &MSVCP_ios_base_vtable;
4187     return this;
4188 }
4189
4190 /* ??0ios_base@std@@QAE@ABV01@@Z */
4191 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
4192 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
4193 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
4194 {
4195     TRACE("(%p %p)\n", this, copy);
4196     *this = *copy;
4197     this->vtable = &MSVCP_ios_base_vtable;
4198     return this;
4199 }
4200
4201 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
4202 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
4203 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
4204 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
4205 {
4206     IOS_BASE_fnarray *cur;
4207
4208     TRACE("(%p %x)\n", this, event);
4209
4210     for(cur=this->calls; cur; cur=cur->next)
4211         cur->event_handler(event, this, cur->index);
4212 }
4213
4214 /* ?_Tidy@ios_base@std@@AAAXXZ */
4215 /* ?_Tidy@ios_base@std@@AEAAXXZ */
4216 void CDECL ios_base_Tidy(ios_base *this)
4217 {
4218     IOS_BASE_iosarray *arr_cur, *arr_next;
4219     IOS_BASE_fnarray *event_cur, *event_next;
4220
4221     TRACE("(%p)\n", this);
4222
4223     ios_base_Callfns(this, EVENT_erase_event);
4224
4225     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
4226         arr_next = arr_cur->next;
4227         MSVCRT_operator_delete(arr_cur);
4228     }
4229     this->arr = NULL;
4230
4231     for(event_cur=this->calls; event_cur; event_cur=event_next) {
4232         event_next = event_cur->next;
4233         MSVCRT_operator_delete(event_cur);
4234     }
4235     this->calls = NULL;
4236 }
4237
4238 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
4239 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
4240 static void ios_base_Ios_base_dtor(ios_base *obj)
4241 {
4242     TRACE("(%p)\n", obj);
4243     if(obj->loc) {
4244         locale_dtor(obj->loc);
4245         MSVCRT_operator_delete(obj->loc);
4246     }
4247     ios_base_Tidy(obj);
4248 }
4249
4250 /* ??1ios_base@std@@UAE@XZ */
4251 /* ??1ios_base@std@@UEAA@XZ */
4252 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
4253 void __thiscall ios_base_dtor(ios_base *this)
4254 {
4255     ios_base_Ios_base_dtor(this);
4256 }
4257
4258 DEFINE_THISCALL_WRAPPER(ios_base_vector_dtor, 8)
4259 ios_base* __thiscall ios_base_vector_dtor(ios_base *this, unsigned int flags)
4260 {
4261     TRACE("(%p %x)\n", this, flags);
4262     if(flags & 2) {
4263         /* we have an array, with the number of elements stored before the first object */
4264         INT_PTR i, *ptr = (INT_PTR *)this-1;
4265
4266         for(i=*ptr-1; i>=0; i--)
4267             ios_base_dtor(this+i);
4268         MSVCRT_operator_delete(ptr);
4269     } else {
4270         ios_base_dtor(this);
4271         if(flags & 1)
4272             MSVCRT_operator_delete(this);
4273     }
4274
4275     return this;
4276 }
4277
4278 DEFINE_THISCALL_WRAPPER(iosb_vector_dtor, 8)
4279 void* __thiscall iosb_vector_dtor(void *this, unsigned int flags)
4280 {
4281     TRACE("(%p %x)\n", this, flags);
4282     if(flags & 2) {
4283         INT_PTR *ptr = (INT_PTR *)this-1;
4284         MSVCRT_operator_delete(ptr);
4285     } else {
4286         if(flags & 1)
4287             MSVCRT_operator_delete(this);
4288     }
4289
4290     return this;
4291 }
4292
4293 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
4294 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
4295 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
4296 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
4297 {
4298     IOS_BASE_iosarray *p;
4299
4300     TRACE("(%p %d)\n", this, index);
4301
4302     for(p=this->arr; p; p=p->next) {
4303         if(p->index == index)
4304             return p;
4305     }
4306
4307     for(p=this->arr; p; p=p->next) {
4308         if(!p->long_val && !p->ptr_val) {
4309             p->index = index;
4310             return p;
4311         }
4312     }
4313
4314     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
4315     p->next = this->arr;
4316     p->index = index;
4317     p->long_val = 0;
4318     p->ptr_val = NULL;
4319     this->arr = p;
4320     return p;
4321 }
4322
4323 /* ?iword@ios_base@std@@QAEAAJH@Z */
4324 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
4325 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
4326 LONG* __thiscall ios_base_iword(ios_base *this, int index)
4327 {
4328     TRACE("(%p %d)\n", this, index);
4329     return &ios_base_Findarr(this, index)->long_val;
4330 }
4331
4332 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
4333 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
4334 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
4335 void** __thiscall ios_base_pword(ios_base *this, int index)
4336 {
4337     TRACE("(%p %d)\n", this, index);
4338     return &ios_base_Findarr(this, index)->ptr_val;
4339 }
4340
4341 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
4342 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
4343 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
4344 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
4345 {
4346     IOS_BASE_fnarray *event;
4347
4348     TRACE("(%p %p %d)\n", this, callback, index);
4349
4350     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
4351     event->next = this->calls;
4352     event->index = index;
4353     event->event_handler = callback;
4354     this->calls = event;
4355 }
4356
4357 /* ?clear@ios_base@std@@QAEXH_N@Z */
4358 /* ?clear@ios_base@std@@QEAAXH_N@Z */
4359 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
4360 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4361 {
4362     TRACE("(%p %x %x)\n", this, state, reraise);
4363
4364     this->state = state & IOSTATE_mask;
4365     if(!(this->state & this->except))
4366         return;
4367
4368     if(reraise)
4369         throw_exception(EXCEPTION_RERAISE, NULL);
4370     else if(this->state & this->except & IOSTATE_eofbit)
4371         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
4372     else if(this->state & this->except & IOSTATE_failbit)
4373         throw_exception(EXCEPTION_FAILURE, "failbit is set");
4374     else if(this->state & this->except & IOSTATE_badbit)
4375         throw_exception(EXCEPTION_FAILURE, "badbit is set");
4376     else if(this->state & this->except & IOSTATE__Hardfail)
4377         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
4378 }
4379
4380 /* ?clear@ios_base@std@@QAEXH@Z */
4381 /* ?clear@ios_base@std@@QEAAXH@Z */
4382 static void ios_base_clear(ios_base *this, IOSB_iostate state)
4383 {
4384     ios_base_clear_reraise(this, state, FALSE);
4385 }
4386
4387 /* ?exceptions@ios_base@std@@QAEXH@Z */
4388 /* ?exceptions@ios_base@std@@QEAAXH@Z */
4389 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
4390 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
4391 {
4392     TRACE("(%p %x)\n", this, state);
4393     this->except = state & IOSTATE_mask;
4394     ios_base_clear(this, this->state);
4395 }
4396
4397 /* ?exceptions@ios_base@std@@QBEHXZ */
4398 /* ?exceptions@ios_base@std@@QEBAHXZ */
4399 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
4400 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
4401 {
4402     TRACE("(%p)\n", this);
4403     return this->except;
4404 }
4405
4406 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
4407 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
4408 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
4409 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
4410 {
4411     TRACE("(%p %p)\n", this, rhs);
4412
4413     if(this != rhs) {
4414         IOS_BASE_iosarray *arr_cur;
4415         IOS_BASE_fnarray *event_cur;
4416
4417         ios_base_Tidy(this);
4418
4419         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
4420             if(arr_cur->long_val)
4421                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
4422             if(arr_cur->ptr_val)
4423                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
4424         }
4425         this->stdstr = rhs->stdstr;
4426         this->fmtfl = rhs->fmtfl;
4427         this->prec = rhs->prec;
4428         this->wide = rhs->wide;
4429         locale_operator_assign(this->loc, rhs->loc);
4430
4431         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
4432             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
4433
4434         ios_base_Callfns(this, EVENT_copyfmt_event);
4435         ios_base_exceptions_set(this, rhs->except);
4436     }
4437
4438     return this;
4439 }
4440
4441 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
4442 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
4443 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
4444 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
4445 {
4446     TRACE("(%p %p)\n", this, right);
4447
4448     if(this != right) {
4449         this->state = right->state;
4450         ios_base_copyfmt(this, right);
4451     }
4452
4453     return this;
4454 }
4455
4456 /* ?fail@ios_base@std@@QBE_NXZ */
4457 /* ?fail@ios_base@std@@QEBA_NXZ */
4458 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
4459 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
4460 {
4461     TRACE("(%p)\n", this);
4462     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
4463 }
4464
4465 /* ??7ios_base@std@@QBE_NXZ */
4466 /* ??7ios_base@std@@QEBA_NXZ */
4467 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
4468 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
4469 {
4470     TRACE("(%p)\n", this);
4471     return ios_base_fail(this);
4472 }
4473
4474 /* ??Bios_base@std@@QBEPAXXZ */
4475 /* ??Bios_base@std@@QEBAPEAXXZ */
4476 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
4477 void* __thiscall ios_base_op_fail(const ios_base *this)
4478 {
4479     TRACE("(%p)\n", this);
4480     return ios_base_fail(this) ? NULL : (void*)this;
4481 }
4482
4483 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
4484 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
4485 static void ios_base_Addstd(ios_base *add)
4486 {
4487     FIXME("(%p) stub\n", add);
4488 }
4489
4490 /* ?_Init@ios_base@std@@IAEXXZ */
4491 /* ?_Init@ios_base@std@@IEAAXXZ */
4492 DEFINE_THISCALL_WRAPPER(ios_base__Init, 4)
4493 void __thiscall ios_base__Init(ios_base *this)
4494 {
4495     TRACE("(%p)\n", this);
4496
4497     this->stdstr = 0;
4498     this->state = this->except = IOSTATE_goodbit;
4499     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
4500     this->prec = 6;
4501     this->wide = 0;
4502     this->arr = NULL;
4503     this->calls = NULL;
4504     this->loc = MSVCRT_operator_new(sizeof(locale));
4505     locale_ctor(this->loc);
4506 }
4507
4508 /* ?bad@ios_base@std@@QBE_NXZ */
4509 /* ?bad@ios_base@std@@QEBA_NXZ */
4510 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
4511 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
4512 {
4513     TRACE("(%p)\n", this);
4514     return (this->state & IOSTATE_badbit) != 0;
4515 }
4516
4517 /* ?eof@ios_base@std@@QBE_NXZ */
4518 /* ?eof@ios_base@std@@QEBA_NXZ */
4519 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
4520 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
4521 {
4522     TRACE("(%p)\n", this);
4523     return (this->state & IOSTATE_eofbit) != 0;
4524 }
4525
4526 /* ?flags@ios_base@std@@QAEHH@Z */
4527 /* ?flags@ios_base@std@@QEAAHH@Z */
4528 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
4529 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
4530 {
4531     IOSB_fmtflags ret = this->fmtfl;
4532
4533     TRACE("(%p %x)\n", this, flags);
4534
4535     this->fmtfl = flags & FMTFLAG_mask;
4536     return ret;
4537 }
4538
4539 /* ?flags@ios_base@std@@QBEHXZ */
4540 /* ?flags@ios_base@std@@QEBAHXZ */
4541 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
4542 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
4543 {
4544     TRACE("(%p)\n", this);
4545     return this->fmtfl;
4546 }
4547
4548 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
4549 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
4550 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
4551 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
4552 {
4553     TRACE("(%p)\n", this);
4554     return locale_copy_ctor(ret, this->loc);
4555 }
4556
4557 /* ?good@ios_base@std@@QBE_NXZ */
4558 /* ?good@ios_base@std@@QEBA_NXZ */
4559 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
4560 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
4561 {
4562     TRACE("(%p)\n", this);
4563     return this->state == IOSTATE_goodbit;
4564 }
4565
4566 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
4567 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
4568 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
4569 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
4570 {
4571     TRACE("(%p %p)\n", this, loc);
4572     *ret = *this->loc;
4573     locale_copy_ctor(this->loc, loc);
4574     return ret;
4575 }
4576
4577 /* ?precision@ios_base@std@@QAEHH@Z */
4578 /* ?precision@ios_base@std@@QEAA_J_J@Z */
4579 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
4580 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
4581 {
4582     streamsize ret = this->prec;
4583
4584     TRACE("(%p %ld)\n", this, precision);
4585
4586     this->prec = precision;
4587     return ret;
4588 }
4589
4590 /* ?precision@ios_base@std@@QBEHXZ */
4591 /* ?precision@ios_base@std@@QEBA_JXZ */
4592 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
4593 streamsize __thiscall ios_base_precision_get(const ios_base *this)
4594 {
4595     TRACE("(%p)\n", this);
4596     return this->prec;
4597 }
4598
4599 /* ?rdstate@ios_base@std@@QBEHXZ */
4600 /* ?rdstate@ios_base@std@@QEBAHXZ */
4601 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
4602 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
4603 {
4604     TRACE("(%p)\n", this);
4605     return this->state;
4606 }
4607
4608 /* ?setf@ios_base@std@@QAEHHH@Z */
4609 /* ?setf@ios_base@std@@QEAAHHH@Z */
4610 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
4611 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
4612 {
4613     IOSB_fmtflags ret = this->fmtfl;
4614
4615     TRACE("(%p %x %x)\n", this, flags, mask);
4616
4617     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
4618     return ret;
4619 }
4620
4621 /* ?setf@ios_base@std@@QAEHH@Z */
4622 /* ?setf@ios_base@std@@QEAAHH@Z */
4623 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
4624 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
4625 {
4626     return ios_base_setf_mask(this, flags, ~0);
4627 }
4628
4629 /* ?setstate@ios_base@std@@QAEXH_N@Z */
4630 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
4631 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
4632 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4633 {
4634     TRACE("(%p %x %x)\n", this, state, reraise);
4635
4636     if(state != IOSTATE_goodbit)
4637         ios_base_clear_reraise(this, this->state | state, reraise);
4638 }
4639
4640 /* ?setstate@ios_base@std@@QAEXH@Z */
4641 /* ?setstate@ios_base@std@@QEAAXH@Z */
4642 static void ios_base_setstate(ios_base *this, IOSB_iostate state)
4643 {
4644     ios_base_setstate_reraise(this, state, FALSE);
4645 }
4646
4647 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
4648 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
4649 {
4650     _Lockit lock;
4651     MSVCP_bool ret;
4652
4653     TRACE("(%x)\n", sync);
4654
4655     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4656     ret = ios_base_Sync;
4657     ios_base_Sync = sync;
4658     _Lockit_dtor(&lock);
4659     return ret;
4660 }
4661
4662 /* ?unsetf@ios_base@std@@QAEXH@Z */
4663 /* ?unsetf@ios_base@std@@QEAAXH@Z */
4664 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
4665 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
4666 {
4667     TRACE("(%p %x)\n", this, flags);
4668     this->fmtfl &= ~flags;
4669 }
4670
4671 /* ?width@ios_base@std@@QAEHH@Z */
4672 /* ?width@ios_base@std@@QEAA_J_J@Z */
4673 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
4674 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
4675 {
4676     streamsize ret = this->wide;
4677
4678     TRACE("(%p %ld)\n", this, width);
4679
4680     this->wide = width;
4681     return ret;
4682 }
4683
4684 /* ?width@ios_base@std@@QBEHXZ */
4685 /* ?width@ios_base@std@@QEBA_JXZ */
4686 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
4687 streamsize __thiscall ios_base_width_get(ios_base *this)
4688 {
4689     TRACE("(%p)\n", this);
4690     return this->wide;
4691 }
4692
4693 /* ?xalloc@ios_base@std@@SAHXZ */
4694 int CDECL ios_base_xalloc(void)
4695 {
4696     _Lockit lock;
4697     int ret;
4698
4699     TRACE("\n");
4700
4701     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4702     ret = ios_base_Index++;
4703     _Lockit_dtor(&lock);
4704     return ret;
4705 }
4706
4707 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
4708 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
4709 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
4710 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
4711 {
4712     TRACE("(%p)\n", this);
4713
4714     ios_base_ctor(&this->base);
4715     this->base.vtable = &MSVCP_basic_ios_char_vtable;
4716     return this;
4717 }
4718
4719 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4720 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4721 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
4722 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
4723 {
4724     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4725     ios_base__Init(&this->base);
4726     this->strbuf = streambuf;
4727     this->stream = NULL;
4728     this->fillch = ' ';
4729
4730     if(!streambuf)
4731         ios_base_setstate(&this->base, IOSTATE_badbit);
4732
4733     if(isstd)
4734         FIXME("standard streams not handled yet\n");
4735 }
4736
4737 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4738 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4739 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
4740 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
4741 {
4742     TRACE("(%p %p)\n", this, strbuf);
4743
4744     basic_ios_char_ctor(this);
4745     basic_ios_char_init(this, strbuf, FALSE);
4746     return this;
4747 }
4748
4749 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
4750 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4751 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
4752 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
4753 {
4754     TRACE("(%p)\n", this);
4755     ios_base_dtor(&this->base);
4756 }
4757
4758 DEFINE_THISCALL_WRAPPER(basic_ios_char_vector_dtor, 8)
4759 basic_ios_char* __thiscall basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
4760 {
4761     TRACE("(%p %x)\n", this, flags);
4762     if(flags & 2) {
4763         /* we have an array, with the number of elements stored before the first object */
4764         INT_PTR i, *ptr = (INT_PTR *)this-1;
4765
4766         for(i=*ptr-1; i>=0; i--)
4767             basic_ios_char_dtor(this+i);
4768         MSVCRT_operator_delete(ptr);
4769     } else {
4770         basic_ios_char_dtor(this);
4771         if(flags & 1)
4772             MSVCRT_operator_delete(this);
4773     }
4774
4775     return this;
4776 }
4777
4778 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4779 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4780 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
4781 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4782 {
4783     TRACE("(%p %x %x)\n", this, state, reraise);
4784     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4785 }
4786
4787 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4788 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4789 static void basic_ios_char_clear(basic_ios_char *this, unsigned int state)
4790 {
4791     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
4792 }
4793
4794 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
4795 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4796 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
4797 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
4798 {
4799     TRACE("(%p %p)\n", this, copy);
4800     if(this == copy)
4801         return this;
4802
4803     this->stream = copy->stream;
4804     this->fillch = copy->fillch;
4805     ios_base_copyfmt(&this->base, &copy->base);
4806     return this;
4807 }
4808
4809 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
4810 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
4811 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
4812 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
4813 {
4814     char ret = this->fillch;
4815
4816     TRACE("(%p %c)\n", this, fill);
4817
4818     this->fillch = fill;
4819     return ret;
4820 }
4821
4822 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
4823 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
4824 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
4825 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
4826 {
4827     TRACE("(%p)\n", this);
4828     return this->fillch;
4829 }
4830
4831 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
4832 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
4833 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
4834 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
4835 {
4836     TRACE("(%p %p %p)\n", this, ret, loc);
4837
4838     if(this->strbuf) {
4839         basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
4840         locale_dtor(ret);
4841     }
4842
4843     return ios_base_imbue(&this->base, ret, loc);
4844 }
4845
4846 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
4847 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
4848 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
4849 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
4850 {
4851     TRACE("(%p %c %c)\n", this, ch, def);
4852     return ctype_char_narrow_ch(ctype_char_use_facet(&this->strbuf->loc), ch, def);
4853 }
4854
4855 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
4856 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
4857 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
4858 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
4859 {
4860     basic_streambuf_char *ret = this->strbuf;
4861
4862     TRACE("(%p %p)\n", this, streambuf);
4863
4864     this->strbuf = streambuf;
4865     basic_ios_char_clear(this, IOSTATE_goodbit);
4866     return ret;
4867 }
4868
4869 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
4870 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
4871 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
4872 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
4873 {
4874     TRACE("(%p)\n", this);
4875     return this->strbuf;
4876 }
4877
4878 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4879 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4880 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
4881 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4882 {
4883     TRACE("(%p %x %x)\n", this, state, reraise);
4884
4885     if(state != IOSTATE_goodbit)
4886         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
4887 }
4888
4889 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4890 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4891 static void basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
4892 {
4893     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
4894 }
4895
4896 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
4897 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
4898 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
4899 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
4900 {
4901     basic_ostream_char *ret = this->stream;
4902
4903     TRACE("(%p %p)\n", this, ostream);
4904
4905     this->stream = ostream;
4906     return ret;
4907 }
4908
4909 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
4910 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
4911 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
4912 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
4913 {
4914     TRACE("(%p)\n", this);
4915     return this->stream;
4916 }
4917
4918 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
4919 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
4920 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
4921 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
4922 {
4923     TRACE("(%p %c)\n", this, ch);
4924     return ctype_char_widen_ch(ctype_char_use_facet(&this->strbuf->loc), ch);
4925 }
4926
4927
4928 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
4929 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
4930 static basic_ios_wchar* basic_ios_wchar_ctor(basic_ios_wchar *this)
4931 {
4932     TRACE("(%p)\n", this);
4933
4934     ios_base_ctor(&this->base);
4935     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
4936     return this;
4937 }
4938
4939 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
4940 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
4941 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
4942 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
4943 {
4944     basic_ios_wchar_ctor(this);
4945     this->base.vtable = &MSVCP_basic_ios_short_vtable;
4946     return this;
4947 }
4948
4949 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
4950 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
4951 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
4952 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
4953 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
4954 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
4955 {
4956     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4957     ios_base__Init(&this->base);
4958     this->strbuf = streambuf;
4959     this->stream = NULL;
4960     this->fillch = ' ';
4961
4962     if(!streambuf)
4963         ios_base_setstate(&this->base, IOSTATE_badbit);
4964
4965     if(isstd)
4966         FIXME("standard streams not handled yet\n");
4967 }
4968
4969 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
4970 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
4971 static basic_ios_wchar* basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
4972 {
4973     TRACE("(%p %p)\n", this, strbuf);
4974
4975     basic_ios_wchar_ctor(this);
4976     basic_ios_wchar_init(this, strbuf, FALSE);
4977     return this;
4978 }
4979
4980 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
4981 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
4982 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
4983 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
4984 {
4985     basic_ios_wchar_ctor_streambuf(this, strbuf);
4986     this->base.vtable = &MSVCP_basic_ios_short_vtable;
4987     return this;
4988 }
4989
4990 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
4991 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
4992 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
4993 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
4994 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
4995 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
4996 {
4997     TRACE("(%p)\n", this);
4998     ios_base_dtor(&this->base);
4999 }
5000
5001 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_vector_dtor, 8)
5002 basic_ios_wchar* __thiscall basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
5003 {
5004     TRACE("(%p %x)\n", this, flags);
5005     if(flags & 2) {
5006         /* we have an array, with the number of elements stored before the first object */
5007         INT_PTR i, *ptr = (INT_PTR *)this-1;
5008
5009         for(i=*ptr-1; i>=0; i--)
5010             basic_ios_wchar_dtor(this+i);
5011         MSVCRT_operator_delete(ptr);
5012     } else {
5013         basic_ios_wchar_dtor(this);
5014         if(flags & 1)
5015             MSVCRT_operator_delete(this);
5016     }
5017
5018     return this;
5019 }
5020
5021 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5022 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5023 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5024 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5025 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
5026 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5027 {
5028     TRACE("(%p %x %x)\n", this, state, reraise);
5029     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
5030 }
5031
5032 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5033 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5034 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5035 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5036 static void basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
5037 {
5038     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
5039 }
5040
5041 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
5042 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5043 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
5044 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5045 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
5046 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
5047 {
5048     TRACE("(%p %p)\n", this, copy);
5049     if(this == copy)
5050         return this;
5051
5052     this->stream = copy->stream;
5053     this->fillch = copy->fillch;
5054     ios_base_copyfmt(&this->base, &copy->base);
5055     return this;
5056 }
5057
5058 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
5059 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
5060 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
5061 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
5062 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
5063 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
5064 {
5065     wchar_t ret = this->fillch;
5066
5067     TRACE("(%p %c)\n", this, fill);
5068
5069     this->fillch = fill;
5070     return ret;
5071 }
5072
5073 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
5074 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
5075 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
5076 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
5077 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
5078 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
5079 {
5080     TRACE("(%p)\n", this);
5081     return this->fillch;
5082 }
5083
5084 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5085 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5086 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5087 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5088 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
5089 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
5090 {
5091     TRACE("(%p %p %p)\n", this, ret, loc);
5092
5093     if(this->strbuf) {
5094         basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
5095         locale_dtor(ret);
5096     }
5097
5098     return ios_base_imbue(&this->base, ret, loc);
5099 }
5100
5101 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
5102 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
5103 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
5104 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
5105 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
5106 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
5107 {
5108     TRACE("(%p %c %c)\n", this, ch, def);
5109     return ctype_wchar_narrow_ch(ctype_wchar_use_facet(&this->strbuf->loc), ch, def);
5110 }
5111
5112 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5113 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5114 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
5115 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5116 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
5117 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
5118 {
5119     basic_streambuf_wchar *ret = this->strbuf;
5120
5121     TRACE("(%p %p)\n", this, streambuf);
5122
5123     this->strbuf = streambuf;
5124     basic_ios_wchar_clear(this, IOSTATE_goodbit);
5125     return ret;
5126 }
5127
5128 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5129 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5130 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5131 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5132 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
5133 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
5134 {
5135     TRACE("(%p)\n", this);
5136     return this->strbuf;
5137 }
5138
5139 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5140 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5141 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5142 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5143 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
5144 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5145 {
5146     TRACE("(%p %x %x)\n", this, state, reraise);
5147
5148     if(state != IOSTATE_goodbit)
5149         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
5150 }
5151
5152 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5153 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5154 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5155 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5156 static void basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
5157 {
5158     basic_ios_wchar_setstate_reraise(this, state, FALSE);
5159 }
5160
5161 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5162 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5163 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
5164 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5165 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
5166 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
5167 {
5168     basic_ostream_wchar *ret = this->stream;
5169
5170     TRACE("(%p %p)\n", this, ostream);
5171
5172     this->stream = ostream;
5173     return ret;
5174 }
5175
5176 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5177 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5178 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5179 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5180 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
5181 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
5182 {
5183     TRACE("(%p)\n", this);
5184     return this->stream;
5185 }
5186
5187 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
5188 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
5189 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
5190 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
5191 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
5192 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
5193 {
5194     TRACE("(%p %c)\n", this, ch);
5195     return ctype_wchar_widen_ch(ctype_wchar_use_facet(&this->strbuf->loc), ch);
5196 }
5197
5198 /* Caution: basic_ostream uses virtual inheritance.
5199  * All constructors have additional parameter that says if base class should be initialized.
5200  * Base class needs to be accessed using vbtable.
5201  */
5202 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
5203 {
5204     return (basic_ios_char*)((char*)this+this->vbtable[1]);
5205 }
5206
5207 static inline basic_ios_char* basic_ostream_char_to_basic_ios(basic_ostream_char *ptr)
5208 {
5209     return (basic_ios_char*)((char*)ptr+basic_ostream_char_vbtable[1]);
5210 }
5211
5212 static inline basic_ostream_char* basic_ostream_char_from_basic_ios(basic_ios_char *ptr)
5213 {
5214     return (basic_ostream_char*)((char*)ptr-basic_ostream_char_vbtable[1]);
5215 }
5216
5217 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5218 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5219 static basic_ostream_char* basic_ostream_char_ctor(basic_ostream_char *this,
5220         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5221 {
5222     basic_ios_char *base;
5223
5224     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5225
5226     if(virt_init) {
5227         this->vbtable = basic_ostream_char_vbtable;
5228         base = basic_ostream_char_get_basic_ios(this);
5229         basic_ios_char_ctor(base);
5230     }else {
5231         base = basic_ostream_char_get_basic_ios(this);
5232     }
5233
5234     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5235     basic_ios_char_init(base, strbuf, isstd);
5236     return this;
5237 }
5238
5239 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5240 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5241 static basic_ostream_char* basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
5242         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5243 {
5244     basic_ios_char *base;
5245
5246     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5247
5248     if(virt_init) {
5249         this->vbtable = basic_ostream_char_vbtable;
5250         base = basic_ostream_char_get_basic_ios(this);
5251         basic_ios_char_ctor(base);
5252     }else {
5253         base = basic_ostream_char_get_basic_ios(this);
5254     }
5255
5256     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5257     if(addstd)
5258         ios_base_Addstd(&base->base);
5259     return this;
5260 }
5261
5262 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5263 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5264 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
5265 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
5266 {
5267     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5268
5269     /* don't destroy virtual base here */
5270     TRACE("(%p)\n", this);
5271 }
5272
5273 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5274 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5275 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
5276 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
5277 {
5278     TRACE("(%p)\n", this);
5279     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
5280     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
5281 }
5282
5283 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
5284 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5285 {
5286     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5287
5288     TRACE("(%p %x)\n", this, flags);
5289
5290     if(flags & 2) {
5291         /* we have an array, with the number of elements stored before the first object */
5292         INT_PTR i, *ptr = (INT_PTR *)this-1;
5293
5294         for(i=*ptr-1; i>=0; i--)
5295             basic_ostream_char_vbase_dtor(this+i);
5296         MSVCRT_operator_delete(ptr);
5297     } else {
5298         basic_ostream_char_vbase_dtor(this);
5299         if(flags & 1)
5300             MSVCRT_operator_delete(this);
5301     }
5302
5303     return this;
5304 }
5305
5306 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5307 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5308 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
5309 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
5310 {
5311     /* this function is not matching C++ specification */
5312     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5313
5314     TRACE("(%p)\n", this);
5315
5316     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
5317             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
5318         basic_ios_char_setstate(base, IOSTATE_badbit);
5319     return this;
5320 }
5321
5322 /* ?flush@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5323 /* ?flush@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5324 basic_ostream_char* __cdecl flush_ostream_char(basic_ostream_char *ostream)
5325 {
5326     return basic_ostream_char_flush(ostream);
5327 }
5328
5329 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5330 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5331 static void basic_ostream_char__Osfx(basic_ostream_char *this)
5332 {
5333     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5334
5335     TRACE("(%p)\n", this);
5336
5337     if(base->base.fmtfl & FMTFLAG_unitbuf)
5338         basic_ostream_char_flush(this);
5339 }
5340
5341 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5342 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5343 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
5344 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
5345 {
5346     TRACE("(%p)\n", this);
5347     basic_ostream_char__Osfx(this);
5348 }
5349
5350 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
5351 {
5352     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5353
5354     if(basic_ios_char_rdbuf_get(base))
5355         basic_streambuf_char__Lock(base->strbuf);
5356
5357     if(ios_base_good(&base->base) && base->stream)
5358         basic_ostream_char_flush(base->stream);
5359
5360     return ios_base_good(&base->base);
5361 }
5362
5363 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
5364 {
5365     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5366
5367     if(ios_base_good(&base->base) && !__uncaught_exception())
5368         basic_ostream_char_osfx(ostr);
5369
5370     if(basic_ios_char_rdbuf_get(base))
5371         basic_streambuf_char__Unlock(base->strbuf);
5372 }
5373
5374 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
5375 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
5376 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
5377 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
5378 {
5379     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5380
5381     TRACE("(%p)\n", this);
5382
5383     if(ios_base_good(&base->base) && base->stream)
5384         basic_ostream_char_flush(base->stream);
5385     return ios_base_good(&base->base);
5386 }
5387
5388 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5389 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5390 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
5391 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
5392 {
5393     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5394
5395     TRACE("(%p %c)\n", this, ch);
5396
5397     if(!basic_ostream_char_sentry_create(this)
5398             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
5399         basic_ostream_char_sentry_destroy(this);
5400         basic_ios_char_setstate(base, IOSTATE_badbit);
5401         return this;
5402     }
5403
5404     basic_ostream_char_sentry_destroy(this);
5405     return this;
5406 }
5407
5408 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
5409 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
5410 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
5411 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
5412 {
5413     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5414
5415     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
5416
5417     if(!ios_base_fail(&base->base)) {
5418         fpos_int seek;
5419
5420         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
5421                 &seek, pos, OPENMODE_out);
5422         if(seek.off==-1 && seek.pos==0 && seek.state==0)
5423             basic_ios_char_setstate(base, IOSTATE_failbit);
5424     }
5425     return this;
5426 }
5427
5428 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
5429 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
5430 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
5431 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
5432 {
5433     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5434
5435     TRACE("(%p)\n", this);
5436
5437     if(!ios_base_fail(&base->base)) {
5438         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5439                 ret, 0, SEEKDIR_cur, OPENMODE_out);
5440     }else {
5441         ret->off = -1;
5442         ret->pos = 0;
5443         ret->state = 0;
5444     }
5445     return ret;
5446 }
5447
5448 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
5449 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
5450 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
5451 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
5452 {
5453     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5454
5455     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
5456
5457     if(!basic_ostream_char_sentry_create(this)
5458             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
5459         basic_ostream_char_sentry_destroy(this);
5460         basic_ios_char_setstate(base, IOSTATE_badbit);
5461         return this;
5462     }
5463
5464     basic_ostream_char_sentry_destroy(this);
5465     return this;
5466 }
5467
5468 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
5469 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
5470 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
5471 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
5472 {
5473     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5474     int state = IOSTATE_goodbit;
5475
5476     TRACE("(%p %d)\n", this, val);
5477
5478     if(basic_ostream_char_sentry_create(this)) {
5479         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5480         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5481         ostreambuf_iterator_char dest = {0, strbuf};
5482
5483         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
5484                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
5485                 ? (LONG)((unsigned short)val) : (LONG)val);
5486     }
5487     basic_ostream_char_sentry_destroy(this);
5488
5489     basic_ios_char_setstate(base, state);
5490     return this;
5491 }
5492
5493 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
5494 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
5495 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
5496 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
5497 {
5498     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5499     int state = IOSTATE_goodbit;
5500
5501     TRACE("(%p %u)\n", this, val);
5502
5503     if(basic_ostream_char_sentry_create(this)) {
5504         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5505         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5506         ostreambuf_iterator_char dest = {0, strbuf};
5507
5508         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5509     }
5510     basic_ostream_char_sentry_destroy(this);
5511
5512     basic_ios_char_setstate(base, state);
5513     return this;
5514 }
5515
5516 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
5517 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
5518 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
5519 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
5520 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
5521 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
5522 {
5523     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5524     int state = IOSTATE_goodbit;
5525
5526     TRACE("(%p %d)\n", this, val);
5527
5528     if(basic_ostream_char_sentry_create(this)) {
5529         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5530         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5531         ostreambuf_iterator_char dest = {0, strbuf};
5532
5533         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5534     }
5535     basic_ostream_char_sentry_destroy(this);
5536
5537     basic_ios_char_setstate(base, state);
5538     return this;
5539 }
5540
5541 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
5542 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
5543 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
5544 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
5545 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
5546 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
5547 {
5548     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5549     int state = IOSTATE_goodbit;
5550
5551     TRACE("(%p %u)\n", this, val);
5552
5553     if(basic_ostream_char_sentry_create(this)) {
5554         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5555         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5556         ostreambuf_iterator_char dest = {0, strbuf};
5557
5558         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5559     }
5560     basic_ostream_char_sentry_destroy(this);
5561
5562     basic_ios_char_setstate(base, state);
5563     return this;
5564 }
5565
5566 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
5567 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
5568 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
5569 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
5570 {
5571     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5572     int state = IOSTATE_goodbit;
5573
5574     TRACE("(%p %f)\n", this, val);
5575
5576     if(basic_ostream_char_sentry_create(this)) {
5577         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5578         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5579         ostreambuf_iterator_char dest = {0, strbuf};
5580
5581         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5582     }
5583     basic_ostream_char_sentry_destroy(this);
5584
5585     basic_ios_char_setstate(base, state);
5586     return this;
5587 }
5588
5589 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
5590 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
5591 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
5592 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
5593 {
5594     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5595     int state = IOSTATE_goodbit;
5596
5597     TRACE("(%p %lf)\n", this, val);
5598
5599     if(basic_ostream_char_sentry_create(this)) {
5600         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5601         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5602         ostreambuf_iterator_char dest = {0, strbuf};
5603
5604         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5605     }
5606     basic_ostream_char_sentry_destroy(this);
5607
5608     basic_ios_char_setstate(base, state);
5609     return this;
5610 }
5611
5612 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
5613 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
5614 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
5615 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
5616 {
5617     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5618     int state = IOSTATE_goodbit;
5619
5620     TRACE("(%p %lf)\n", this, val);
5621
5622     if(basic_ostream_char_sentry_create(this)) {
5623         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5624         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5625         ostreambuf_iterator_char dest = {0, strbuf};
5626
5627         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5628     }
5629     basic_ostream_char_sentry_destroy(this);
5630
5631     basic_ios_char_setstate(base, state);
5632     return this;
5633 }
5634
5635 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5636 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5637 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
5638 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
5639 {
5640     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5641     IOSB_iostate state = IOSTATE_badbit;
5642     int c = '\n';
5643
5644     TRACE("(%p %p)\n", this, val);
5645
5646     if(basic_ostream_char_sentry_create(this)) {
5647         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
5648                 c = basic_streambuf_char_snextc(val)) {
5649             state = IOSTATE_goodbit;
5650
5651             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
5652                 state = IOSTATE_badbit;
5653                 break;
5654             }
5655         }
5656     }else {
5657         state = IOSTATE_badbit;
5658     }
5659     basic_ostream_char_sentry_destroy(this);
5660
5661     ios_base_width_set(&base->base, 0);
5662     basic_ios_char_setstate(base, state);
5663     return this;
5664 }
5665
5666 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
5667 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
5668 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
5669 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
5670 {
5671     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5672     int state = IOSTATE_goodbit;
5673
5674     TRACE("(%p %p)\n", this, val);
5675
5676     if(basic_ostream_char_sentry_create(this)) {
5677         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5678         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5679         ostreambuf_iterator_char dest = {0, strbuf};
5680
5681         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5682     }
5683     basic_ostream_char_sentry_destroy(this);
5684
5685     basic_ios_char_setstate(base, state);
5686     return this;
5687 }
5688
5689 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
5690 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
5691 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
5692 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
5693 {
5694     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5695     int state = IOSTATE_goodbit;
5696
5697     TRACE("(%p)\n", this);
5698
5699     if(basic_ostream_char_sentry_create(this)) {
5700         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5701         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5702         ostreambuf_iterator_char dest = {0, strbuf};
5703
5704         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5705     }
5706     basic_ostream_char_sentry_destroy(this);
5707
5708     basic_ios_char_setstate(base, state);
5709     return this;
5710 }
5711
5712 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
5713 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
5714 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
5715 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
5716 {
5717     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5718     int state = IOSTATE_goodbit;
5719
5720     TRACE("(%p)\n", this);
5721
5722     if(basic_ostream_char_sentry_create(this)) {
5723         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5724         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5725         ostreambuf_iterator_char dest = {0, strbuf};
5726
5727         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5728     }
5729     basic_ostream_char_sentry_destroy(this);
5730
5731     basic_ios_char_setstate(base, state);
5732     return this;
5733 }
5734
5735 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
5736 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
5737 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
5738 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
5739 {
5740     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5741     int state = IOSTATE_goodbit;
5742
5743     TRACE("(%p %x)\n", this, val);
5744
5745     if(basic_ostream_char_sentry_create(this)) {
5746         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5747         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5748         ostreambuf_iterator_char dest = {0, strbuf};
5749
5750         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5751     }
5752     basic_ostream_char_sentry_destroy(this);
5753
5754     basic_ios_char_setstate(base, state);
5755     return this;
5756 }
5757
5758 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5759 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5760 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
5761 {
5762     TRACE("(%p)\n", ostr);
5763
5764     basic_ostream_char_put(ostr, '\n');
5765     basic_ostream_char_flush(ostr);
5766     return ostr;
5767 }
5768
5769 /* $?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 */
5770 /* ??$?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 */
5771 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
5772 {
5773     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5774     IOSB_iostate state = IOSTATE_goodbit;
5775
5776     TRACE("(%p %p)\n", ostr, str);
5777
5778     if(basic_ostream_char_sentry_create(ostr)) {
5779         MSVCP_size_t len = basic_string_char_length(str);
5780         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5781
5782         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5783             for(; pad!=0; pad--) {
5784                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5785                     state = IOSTATE_badbit;
5786                     break;
5787                 }
5788             }
5789         }
5790
5791         if(state == IOSTATE_goodbit) {
5792             if(basic_streambuf_char_sputn(base->strbuf, basic_string_char_c_str(str), len) != len)
5793                     state = IOSTATE_badbit;
5794         }
5795
5796         if(state == IOSTATE_goodbit) {
5797             for(; pad!=0; pad--) {
5798                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5799                     state = IOSTATE_badbit;
5800                     break;
5801                 }
5802             }
5803         }
5804
5805         base->base.wide = 0;
5806     }else {
5807         state = IOSTATE_badbit;
5808     }
5809     basic_ostream_char_sentry_destroy(ostr);
5810
5811     basic_ios_char_setstate(base, state);
5812     return ostr;
5813 }
5814
5815 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@C@Z */
5816 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@C@Z */
5817 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z */
5818 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z */
5819 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@E@Z */
5820 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@E@Z */
5821 basic_ostream_char* __cdecl basic_ostream_char_print_ch(basic_ostream_char *ostr, char ch)
5822 {
5823     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5824     IOSB_iostate state = IOSTATE_goodbit;
5825
5826     TRACE("(%p %d)\n", ostr, ch);
5827
5828     if(basic_ostream_char_sentry_create(ostr)) {
5829         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
5830
5831         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5832             for(; pad!=0; pad--) {
5833                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5834                     state = IOSTATE_badbit;
5835                     break;
5836                 }
5837             }
5838         }
5839
5840         if(state == IOSTATE_goodbit) {
5841             if(basic_streambuf_char_sputc(base->strbuf, ch) == EOF)
5842                 state = IOSTATE_badbit;
5843         }
5844
5845         if(state == IOSTATE_goodbit) {
5846             for(; pad!=0; pad--) {
5847                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5848                     state = IOSTATE_badbit;
5849                     break;
5850                 }
5851             }
5852         }
5853
5854         base->base.wide = 0;
5855     }else {
5856         state = IOSTATE_badbit;
5857     }
5858     basic_ostream_char_sentry_destroy(ostr);
5859
5860     basic_ios_char_setstate(base, state);
5861     return ostr;
5862 }
5863
5864 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBC@Z */
5865 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBC@Z */
5866 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z */
5867 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z */
5868 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBE@Z */
5869 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBE@Z */
5870 basic_ostream_char* __cdecl basic_ostream_char_print_str(basic_ostream_char *ostr, const char *str)
5871 {
5872     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5873     IOSB_iostate state = IOSTATE_goodbit;
5874
5875     TRACE("(%p %s)\n", ostr, str);
5876
5877     if(basic_ostream_char_sentry_create(ostr)) {
5878         MSVCP_size_t len = strlen(str);
5879         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5880
5881         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5882             for(; pad!=0; pad--) {
5883                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5884                     state = IOSTATE_badbit;
5885                     break;
5886                 }
5887             }
5888         }
5889
5890         if(state == IOSTATE_goodbit) {
5891             if(basic_streambuf_char_sputn(base->strbuf, str, len) != len)
5892                 state = IOSTATE_badbit;
5893         }
5894
5895         if(state == IOSTATE_goodbit) {
5896             for(; pad!=0; pad--) {
5897                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5898                     state = IOSTATE_badbit;
5899                     break;
5900                 }
5901             }
5902         }
5903
5904         base->base.wide = 0;
5905     }else {
5906         state = IOSTATE_badbit;
5907     }
5908     basic_ostream_char_sentry_destroy(ostr);
5909
5910     basic_ios_char_setstate(base, state);
5911     return ostr;
5912 }
5913
5914 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
5915 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
5916 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
5917 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
5918         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
5919 {
5920     TRACE("(%p %p)\n", this, pfunc);
5921     pfunc(this);
5922     return this;
5923 }
5924
5925 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
5926 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
5927 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
5928 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
5929         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
5930 {
5931     TRACE("(%p %p)\n", this, pfunc);
5932     pfunc(basic_ostream_char_get_basic_ios(this));
5933     return this;
5934 }
5935
5936 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
5937 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
5938 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
5939 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
5940         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
5941 {
5942     TRACE("(%p %p)\n", this, pfunc);
5943     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
5944     return this;
5945 }
5946
5947 /* Caution: basic_ostream uses virtual inheritance. */
5948 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
5949 {
5950     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
5951 }
5952
5953 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
5954 {
5955     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
5956 }
5957
5958 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
5959 {
5960     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
5961 }
5962
5963 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
5964 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
5965 static basic_ostream_wchar* basic_ostream_wchar_ctor(basic_ostream_wchar *this,
5966         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5967 {
5968     basic_ios_wchar *base;
5969
5970     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5971
5972     if(virt_init) {
5973         this->vbtable = basic_ostream_wchar_vbtable;
5974         base = basic_ostream_wchar_get_basic_ios(this);
5975         basic_ios_wchar_ctor(base);
5976     }else {
5977         base = basic_ostream_wchar_get_basic_ios(this);
5978     }
5979
5980     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
5981     basic_ios_wchar_init(base, strbuf, isstd);
5982     return this;
5983 }
5984
5985 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
5986 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
5987 static basic_ostream_wchar* basic_ostream_short_ctor(basic_ostream_wchar *this,
5988         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5989 {
5990     basic_ostream_wchar_ctor(this, strbuf, isstd, virt_init);
5991     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
5992     return this;
5993 }
5994
5995 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5996 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5997 static basic_ostream_wchar* basic_ostream_wchar_ctor_uninitialized(basic_ostream_wchar *this,
5998         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5999 {
6000     basic_ios_wchar *base;
6001
6002     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
6003
6004     if(virt_init) {
6005         this->vbtable = basic_ostream_wchar_vbtable;
6006         base = basic_ostream_wchar_get_basic_ios(this);
6007         basic_ios_wchar_ctor(base);
6008     }else {
6009         base = basic_ostream_wchar_get_basic_ios(this);
6010     }
6011
6012     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6013     if(addstd)
6014         ios_base_Addstd(&base->base);
6015     return this;
6016 }
6017
6018 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
6019 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
6020 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
6021 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
6022 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
6023 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
6024 {
6025     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6026
6027     /* don't destroy virtual base here */
6028     TRACE("(%p)\n", this);
6029 }
6030
6031 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6032 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6033 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6034 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6035 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
6036 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
6037 {
6038     TRACE("(%p)\n", this);
6039     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
6040     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
6041 }
6042
6043 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
6044 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
6045 {
6046     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6047
6048     TRACE("(%p %x)\n", this, flags);
6049
6050     if(flags & 2) {
6051         /* we have an array, with the number of elements stored before the first object */
6052         INT_PTR i, *ptr = (INT_PTR *)this-1;
6053
6054         for(i=*ptr-1; i>=0; i--)
6055             basic_ostream_wchar_vbase_dtor(this+i);
6056         MSVCRT_operator_delete(ptr);
6057     } else {
6058         basic_ostream_wchar_vbase_dtor(this);
6059         if(flags & 1)
6060             MSVCRT_operator_delete(this);
6061     }
6062
6063     return this;
6064 }
6065
6066 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
6067 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
6068 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
6069 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
6070 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
6071 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
6072 {
6073     /* this function is not matching C++ specification */
6074     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6075
6076     TRACE("(%p)\n", this);
6077
6078     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
6079             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
6080         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6081     return this;
6082 }
6083
6084 /* ?flush@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6085 /* ?flush@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6086 /* ?flush@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6087 /* ?flush@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6088 basic_ostream_wchar* __cdecl flush_ostream_wchar(basic_ostream_wchar *ostream)
6089 {
6090     return basic_ostream_wchar_flush(ostream);
6091 }
6092
6093 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6094 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6095 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6096 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6097 static void basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
6098 {
6099     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6100
6101     TRACE("(%p)\n", this);
6102
6103     if(base->base.fmtfl & FMTFLAG_unitbuf)
6104         basic_ostream_wchar_flush(this);
6105 }
6106
6107 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6108 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6109 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6110 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6111 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
6112 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
6113 {
6114     TRACE("(%p)\n", this);
6115     basic_ostream_wchar__Osfx(this);
6116 }
6117
6118 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
6119 {
6120     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6121
6122     if(basic_ios_wchar_rdbuf_get(base))
6123         basic_streambuf_wchar__Lock(base->strbuf);
6124
6125     if(ios_base_good(&base->base) && base->stream)
6126         basic_ostream_wchar_flush(base->stream);
6127
6128     return ios_base_good(&base->base);
6129 }
6130
6131 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
6132 {
6133     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6134
6135     if(ios_base_good(&base->base) && !__uncaught_exception())
6136         basic_ostream_wchar_osfx(ostr);
6137
6138     if(basic_ios_wchar_rdbuf_get(base))
6139         basic_streambuf_wchar__Unlock(base->strbuf);
6140 }
6141
6142 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
6143 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
6144 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
6145 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
6146 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
6147 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
6148 {
6149     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6150
6151     TRACE("(%p)\n", this);
6152
6153     if(ios_base_good(&base->base) && base->stream)
6154         basic_ostream_wchar_flush(base->stream);
6155     return ios_base_good(&base->base);
6156 }
6157
6158 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
6159 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
6160 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
6161 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
6162 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
6163 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
6164 {
6165     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6166
6167     TRACE("(%p %c)\n", this, ch);
6168
6169     if(!basic_ostream_wchar_sentry_create(this)
6170             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
6171         basic_ostream_wchar_sentry_destroy(this);
6172         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6173         return this;
6174     }
6175
6176     basic_ostream_wchar_sentry_destroy(this);
6177     return this;
6178 }
6179
6180 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6181 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6182 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6183 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6184 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
6185 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
6186 {
6187     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6188
6189     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6190
6191     if(!ios_base_fail(&base->base)) {
6192         fpos_int seek;
6193
6194         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
6195                 &seek, pos, OPENMODE_out);
6196         if(seek.off==-1 && seek.pos==0 && seek.state==0)
6197             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6198     }
6199     return this;
6200 }
6201
6202 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6203 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6204 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6205 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6206 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
6207 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
6208 {
6209     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6210
6211     TRACE("(%p)\n", this);
6212
6213     if(!ios_base_fail(&base->base)) {
6214         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6215                 ret, 0, SEEKDIR_cur, OPENMODE_out);
6216     }else {
6217         ret->off = -1;
6218         ret->pos = 0;
6219         ret->state = 0;
6220     }
6221     return ret;
6222 }
6223
6224 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
6225 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
6226 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
6227 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
6228 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 12)
6229 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
6230 {
6231     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6232
6233     TRACE("(%p %s %ld)\n", this, debugstr_w(str), count);
6234
6235     if(!basic_ostream_wchar_sentry_create(this)
6236             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
6237         basic_ostream_wchar_sentry_destroy(this);
6238         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6239         return this;
6240     }
6241
6242     basic_ostream_wchar_sentry_destroy(this);
6243     return this;
6244 }
6245
6246 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
6247 {
6248     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6249     int state = IOSTATE_goodbit;
6250
6251     TRACE("(%p %d)\n", this, val);
6252
6253     if(basic_ostream_wchar_sentry_create(this)) {
6254         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6255         ostreambuf_iterator_wchar dest = {0, strbuf};
6256
6257         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
6258                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
6259                 ? (LONG)((unsigned short)val) : (LONG)val);
6260     }
6261     basic_ostream_wchar_sentry_destroy(this);
6262
6263     basic_ios_wchar_setstate(base, state);
6264     return this;
6265 }
6266
6267 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
6268 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
6269 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
6270 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
6271 {
6272     return basic_ostream_print_short(this, val, num_put_short_use_facet(
6273                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6274 }
6275
6276 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
6277 {
6278     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6279     int state = IOSTATE_goodbit;
6280
6281     TRACE("(%p %d)\n", this, val);
6282
6283     if(basic_ostream_wchar_sentry_create(this)) {
6284         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6285         ostreambuf_iterator_wchar dest = {0, strbuf};
6286
6287         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6288     }
6289     basic_ostream_wchar_sentry_destroy(this);
6290
6291     basic_ios_wchar_setstate(base, state);
6292     return this;
6293 }
6294
6295 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
6296 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
6297 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
6298 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
6299 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
6300 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
6301 {
6302     return basic_ostream_print_int(this, val, num_put_short_use_facet(
6303                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6304 }
6305
6306 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
6307 {
6308     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6309     int state = IOSTATE_goodbit;
6310
6311     TRACE("(%p %u)\n", this, val);
6312
6313     if(basic_ostream_wchar_sentry_create(this)) {
6314         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6315         ostreambuf_iterator_wchar dest = {0, strbuf};
6316
6317         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6318     }
6319     basic_ostream_wchar_sentry_destroy(this);
6320
6321     basic_ios_wchar_setstate(base, state);
6322     return this;
6323 }
6324
6325 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
6326 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
6327 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
6328 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
6329 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
6330 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
6331 {
6332     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
6333                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6334 }
6335
6336 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
6337 {
6338     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6339     int state = IOSTATE_goodbit;
6340
6341     TRACE("(%p %f)\n", this, val);
6342
6343     if(basic_ostream_wchar_sentry_create(this)) {
6344         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6345         ostreambuf_iterator_wchar dest = {0, strbuf};
6346
6347         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6348     }
6349     basic_ostream_wchar_sentry_destroy(this);
6350
6351     basic_ios_wchar_setstate(base, state);
6352     return this;
6353 }
6354
6355 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
6356 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
6357 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
6358 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
6359 {
6360     return basic_ostream_print_float(this, val, num_put_short_use_facet(
6361                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6362 }
6363
6364 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
6365 {
6366     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6367     int state = IOSTATE_goodbit;
6368
6369     TRACE("(%p %lf)\n", this, val);
6370
6371     if(basic_ostream_wchar_sentry_create(this)) {
6372         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6373         ostreambuf_iterator_wchar dest = {0, strbuf};
6374
6375         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6376     }
6377     basic_ostream_wchar_sentry_destroy(this);
6378
6379     basic_ios_wchar_setstate(base, state);
6380     return this;
6381 }
6382
6383 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
6384 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
6385 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
6386 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
6387 {
6388     return basic_ostream_print_double(this, val, num_put_short_use_facet(
6389                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6390 }
6391
6392 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
6393 {
6394     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6395     int state = IOSTATE_goodbit;
6396
6397     TRACE("(%p %lf)\n", this, val);
6398
6399     if(basic_ostream_wchar_sentry_create(this)) {
6400         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6401         ostreambuf_iterator_wchar dest = {0, strbuf};
6402
6403         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6404     }
6405     basic_ostream_wchar_sentry_destroy(this);
6406
6407     basic_ios_wchar_setstate(base, state);
6408     return this;
6409 }
6410
6411 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
6412 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
6413 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
6414 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
6415 {
6416     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
6417                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6418 }
6419
6420 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6421 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6422 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6423 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6424 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
6425 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
6426 {
6427     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6428     IOSB_iostate state = IOSTATE_badbit;
6429     unsigned short c = '\n';
6430
6431     TRACE("(%p %p)\n", this, val);
6432
6433     if(basic_ostream_wchar_sentry_create(this)) {
6434         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
6435                 c = basic_streambuf_wchar_snextc(val)) {
6436             state = IOSTATE_goodbit;
6437
6438             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
6439                 state = IOSTATE_badbit;
6440                 break;
6441             }
6442         }
6443     }else {
6444         state = IOSTATE_badbit;
6445     }
6446     basic_ostream_wchar_sentry_destroy(this);
6447
6448     ios_base_width_set(&base->base, 0);
6449     basic_ios_wchar_setstate(base, state);
6450     return this;
6451 }
6452
6453 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
6454 {
6455     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6456     int state = IOSTATE_goodbit;
6457
6458     TRACE("(%p %p)\n", this, val);
6459
6460     if(basic_ostream_wchar_sentry_create(this)) {
6461         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6462         ostreambuf_iterator_wchar dest = {0, strbuf};
6463
6464         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6465     }
6466     basic_ostream_wchar_sentry_destroy(this);
6467
6468     basic_ios_wchar_setstate(base, state);
6469     return this;
6470 }
6471
6472 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
6473 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
6474 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
6475 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
6476 {
6477     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
6478                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6479 }
6480
6481 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
6482 {
6483     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6484     int state = IOSTATE_goodbit;
6485
6486     TRACE("(%p)\n", this);
6487
6488     if(basic_ostream_wchar_sentry_create(this)) {
6489         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6490         ostreambuf_iterator_wchar dest = {0, strbuf};
6491
6492         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6493     }
6494     basic_ostream_wchar_sentry_destroy(this);
6495
6496     basic_ios_wchar_setstate(base, state);
6497     return this;
6498 }
6499
6500 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
6501 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
6502 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
6503 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
6504 {
6505     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
6506                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6507 }
6508
6509 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
6510 {
6511     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6512     int state = IOSTATE_goodbit;
6513
6514     TRACE("(%p)\n", this);
6515
6516     if(basic_ostream_wchar_sentry_create(this)) {
6517         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6518         ostreambuf_iterator_wchar dest = {0, strbuf};
6519
6520         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6521     }
6522     basic_ostream_wchar_sentry_destroy(this);
6523
6524     basic_ios_wchar_setstate(base, state);
6525     return this;
6526 }
6527
6528 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
6529 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
6530 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
6531 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6532 {
6533     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
6534                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6535 }
6536
6537 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
6538 {
6539     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6540     int state = IOSTATE_goodbit;
6541
6542     TRACE("(%p %x)\n", this, val);
6543
6544     if(basic_ostream_wchar_sentry_create(this)) {
6545         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6546         ostreambuf_iterator_wchar dest = {0, strbuf};
6547
6548         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6549     }
6550     basic_ostream_wchar_sentry_destroy(this);
6551
6552     basic_ios_wchar_setstate(base, state);
6553     return this;
6554 }
6555
6556 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
6557 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
6558 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
6559 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6560 {
6561     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
6562                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6563 }
6564
6565 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6566 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6567 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6568 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6569 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
6570 {
6571     TRACE("(%p)\n", ostr);
6572
6573     basic_ostream_wchar_put(ostr, '\n');
6574     basic_ostream_wchar_flush(ostr);
6575     return ostr;
6576 }
6577
6578 /* ??$?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 */
6579 /* ??$?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 */
6580 /* ??$?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 */
6581 /* ??$?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 */
6582 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_bstr(basic_ostream_wchar *ostr, const basic_string_wchar *str)
6583 {
6584     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6585     IOSB_iostate state = IOSTATE_goodbit;
6586
6587     TRACE("(%p %p)\n", ostr, str);
6588
6589     if(basic_ostream_wchar_sentry_create(ostr)) {
6590         MSVCP_size_t len = basic_string_wchar_length(str);
6591         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6592
6593         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6594             for(; pad!=0; pad--) {
6595                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6596                     state = IOSTATE_badbit;
6597                     break;
6598                 }
6599             }
6600         }
6601
6602         if(state == IOSTATE_goodbit) {
6603             if(basic_streambuf_wchar_sputn(base->strbuf, basic_string_wchar_c_str(str), len) != len)
6604                 state = IOSTATE_badbit;
6605         }
6606
6607         if(state == IOSTATE_goodbit) {
6608             for(; pad!=0; pad--) {
6609                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6610                     state = IOSTATE_badbit;
6611                     break;
6612                 }
6613             }
6614         }
6615
6616         base->base.wide = 0;
6617     }else {
6618         state = IOSTATE_badbit;
6619     }
6620     basic_ostream_wchar_sentry_destroy(ostr);
6621
6622     basic_ios_wchar_setstate(base, state);
6623     return ostr;
6624 }
6625
6626 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@_W@Z */
6627 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@_W@Z */
6628 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@G@Z */
6629 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@G@Z */
6630 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_ch(basic_ostream_wchar *ostr, wchar_t ch)
6631 {
6632     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6633     IOSB_iostate state = IOSTATE_goodbit;
6634
6635     TRACE("(%p %d)\n", ostr, ch);
6636
6637     if(basic_ostream_wchar_sentry_create(ostr)) {
6638         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6639
6640         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6641             for(; pad!=0; pad--) {
6642                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6643                     state = IOSTATE_badbit;
6644                     break;
6645                 }
6646             }
6647         }
6648
6649         if(state == IOSTATE_goodbit) {
6650             if(basic_streambuf_wchar_sputc(base->strbuf, ch) == WEOF)
6651                 state = IOSTATE_badbit;
6652         }
6653
6654         if(state == IOSTATE_goodbit) {
6655             for(; pad!=0; pad--) {
6656                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6657                     state = IOSTATE_badbit;
6658                     break;
6659                 }
6660             }
6661         }
6662
6663         base->base.wide = 0;
6664     }else {
6665         state = IOSTATE_badbit;
6666     }
6667     basic_ostream_wchar_sentry_destroy(ostr);
6668
6669     basic_ios_wchar_setstate(base, state);
6670     return ostr;
6671 }
6672
6673 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@PB_W@Z */
6674 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@PEB_W@Z */
6675 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@PBG@Z */
6676 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@PEBG@Z */
6677 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_str(basic_ostream_wchar *ostr, const wchar_t *str)
6678 {
6679     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6680     IOSB_iostate state = IOSTATE_goodbit;
6681
6682     TRACE("(%p %s)\n", ostr, debugstr_w(str));
6683
6684     if(basic_ostream_wchar_sentry_create(ostr)) {
6685         MSVCP_size_t len = wcslen(str);
6686         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6687
6688         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6689             for(; pad!=0; pad--) {
6690                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6691                     state = IOSTATE_badbit;
6692                     break;
6693                 }
6694             }
6695         }
6696
6697         if(state == IOSTATE_goodbit) {
6698             if(basic_streambuf_wchar_sputn(base->strbuf, str, len) != len)
6699                                         state = IOSTATE_badbit;
6700         }
6701
6702         if(state == IOSTATE_goodbit) {
6703             for(; pad!=0; pad--) {
6704                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6705                     state = IOSTATE_badbit;
6706                     break;
6707                 }
6708             }
6709         }
6710
6711         base->base.wide = 0;
6712     }else {
6713         state = IOSTATE_badbit;
6714     }
6715     basic_ostream_wchar_sentry_destroy(ostr);
6716
6717     basic_ios_wchar_setstate(base, state);
6718     return ostr;
6719 }
6720
6721 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6722 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6723 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6724 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6725 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
6726 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
6727         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
6728 {
6729     TRACE("(%p %p)\n", this, pfunc);
6730     pfunc(this);
6731     return this;
6732 }
6733
6734 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
6735 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
6736 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
6737 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
6738 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
6739 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
6740         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
6741 {
6742     TRACE("(%p %p)\n", this, pfunc);
6743     pfunc(basic_ostream_wchar_get_basic_ios(this));
6744     return this;
6745 }
6746
6747 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6748 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6749 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6750 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6751 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
6752 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
6753         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
6754 {
6755     TRACE("(%p %p)\n", this, pfunc);
6756     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
6757     return this;
6758 }
6759
6760 /* Caution: basic_istream uses virtual inheritance. */
6761 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
6762 {
6763     return (basic_ios_char*)((char*)this+this->vbtable[1]);
6764 }
6765
6766 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
6767 {
6768     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
6769 }
6770
6771 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
6772 {
6773     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
6774 }
6775
6776 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6777 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6778 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)
6779 {
6780     basic_ios_char *base;
6781
6782     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
6783
6784     if(virt_init) {
6785         this->vbtable = basic_istream_char_vbtable;
6786         base = basic_istream_char_get_basic_ios(this);
6787         basic_ios_char_ctor(base);
6788     }else {
6789         base = basic_istream_char_get_basic_ios(this);
6790     }
6791
6792     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6793     this->count = 0;
6794     if(!noinit)
6795         basic_ios_char_init(base, strbuf, isstd);
6796     return this;
6797 }
6798
6799 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6800 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6801 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
6802 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6803 {
6804     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
6805 }
6806
6807 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
6808 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
6809 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
6810 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
6811 {
6812     basic_ios_char *base;
6813
6814     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
6815
6816     if(virt_init) {
6817         this->vbtable = basic_istream_char_vbtable;
6818         base = basic_istream_char_get_basic_ios(this);
6819         basic_ios_char_ctor(base);
6820     }else {
6821         base = basic_istream_char_get_basic_ios(this);
6822     }
6823
6824     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6825     ios_base_Addstd(&base->base);
6826     return this;
6827 }
6828
6829 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
6830 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
6831 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
6832 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
6833 {
6834     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6835
6836     /* don't destroy virtual base here */
6837     TRACE("(%p)\n", this);
6838 }
6839
6840 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6841 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6842 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
6843 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
6844 {
6845     TRACE("(%p)\n", this);
6846     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
6847     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
6848 }
6849
6850 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
6851 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
6852 {
6853     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6854
6855     TRACE("(%p %x)\n", this, flags);
6856
6857     if(flags & 2) {
6858         /* we have an array, with the number of elements stored before the first object */
6859         INT_PTR i, *ptr = (INT_PTR *)this-1;
6860
6861         for(i=*ptr-1; i>=0; i--)
6862             basic_istream_char_vbase_dtor(this+i);
6863         MSVCRT_operator_delete(ptr);
6864     } else {
6865         basic_istream_char_vbase_dtor(this);
6866         if(flags & 1)
6867             MSVCRT_operator_delete(this);
6868     }
6869
6870     return this;
6871 }
6872
6873 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6874 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6875 static MSVCP_bool basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
6876 {
6877     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6878
6879     TRACE("(%p %d)\n", this, noskip);
6880
6881     if(ios_base_good(&base->base)) {
6882         if(basic_ios_char_tie_get(base))
6883             basic_ostream_char_flush(basic_ios_char_tie_get(base));
6884
6885         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
6886             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6887             const ctype_char *ctype = ctype_char_use_facet(&base->strbuf->loc);
6888             int ch;
6889
6890             for(ch = basic_streambuf_char_sgetc(strbuf); ;
6891                     ch = basic_streambuf_char_snextc(strbuf)) {
6892                 if(ch == EOF) {
6893                     basic_ios_char_setstate(base, IOSTATE_eofbit);
6894                     break;
6895                 }
6896
6897                 if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
6898                     break;
6899             }
6900         }
6901     }
6902
6903     if(!ios_base_good(&base->base)) {
6904         basic_ios_char_setstate(base, IOSTATE_failbit);
6905         return FALSE;
6906     }
6907
6908     return TRUE;
6909 }
6910
6911 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6912 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6913 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
6914 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
6915 {
6916     return basic_istream_char__Ipfx(this, noskip);
6917 }
6918
6919 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6920 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6921 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
6922 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
6923 {
6924     TRACE("(%p)\n", this);
6925 }
6926
6927 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
6928 {
6929     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6930
6931     if(basic_ios_char_rdbuf_get(base))
6932         basic_streambuf_char__Lock(base->strbuf);
6933
6934     return basic_istream_char_ipfx(istr, noskip);
6935 }
6936
6937 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
6938 {
6939     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6940
6941     if(basic_ios_char_rdbuf_get(base))
6942         basic_streambuf_char__Unlock(base->strbuf);
6943 }
6944
6945 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
6946 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
6947 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
6948 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
6949 {
6950     TRACE("(%p)\n", this);
6951     return this->count;
6952 }
6953
6954 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
6955 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
6956 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
6957 int __thiscall basic_istream_char_get(basic_istream_char *this)
6958 {
6959     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6960     int ret;
6961
6962     TRACE("(%p)\n", this);
6963
6964     this->count = 0;
6965
6966     if(!basic_istream_char_sentry_create(this, TRUE)) {
6967         basic_istream_char_sentry_destroy(this);
6968         return EOF;
6969     }
6970
6971     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
6972     basic_istream_char_sentry_destroy(this);
6973     if(ret == EOF)
6974         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
6975     else
6976         this->count++;
6977
6978     return ret;
6979 }
6980
6981 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
6982 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
6983 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
6984 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
6985 {
6986     int ret;
6987
6988     TRACE("(%p %p)\n", this, ch);
6989
6990     ret = basic_istream_char_get(this);
6991     if(ret != EOF)
6992         *ch = (char)ret;
6993     return this;
6994 }
6995
6996 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
6997 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
6998 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
6999 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7000 {
7001     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7002     int ch = delim;
7003
7004     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7005
7006     this->count = 0;
7007
7008     if(basic_istream_char_sentry_create(this, TRUE)) {
7009         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7010
7011         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
7012                 ch = basic_streambuf_char_snextc(strbuf)) {
7013             if(ch==EOF || ch==delim)
7014                 break;
7015
7016             *str++ = ch;
7017             this->count++;
7018             count--;
7019         }
7020     }
7021     basic_istream_char_sentry_destroy(this);
7022
7023     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7024             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7025     if(count > 0)
7026         *str = 0;
7027     return this;
7028 }
7029
7030 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7031 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7032 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
7033 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
7034 {
7035     return basic_istream_char_get_str_delim(this, str, count, '\n');
7036 }
7037
7038 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7039 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7040 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
7041 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
7042 {
7043     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7044     int ch = delim;
7045
7046     TRACE("(%p %p %c)\n", this, strbuf, delim);
7047
7048     this->count = 0;
7049
7050     if(basic_istream_char_sentry_create(this, TRUE)) {
7051         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
7052
7053         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
7054                 ch = basic_streambuf_char_snextc(strbuf_read)) {
7055             if(ch==EOF || ch==delim)
7056                 break;
7057
7058             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
7059                 break;
7060             this->count++;
7061         }
7062     }
7063     basic_istream_char_sentry_destroy(this);
7064
7065     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7066             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7067     return this;
7068 }
7069
7070 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7071 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7072 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
7073 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
7074 {
7075     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
7076 }
7077
7078 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7079 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7080 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
7081 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7082 {
7083     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7084     int ch = (unsigned char)delim;
7085
7086     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7087
7088     this->count = 0;
7089
7090     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
7091         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7092
7093         while(count > 1) {
7094             ch = basic_streambuf_char_sbumpc(strbuf);
7095
7096             if(ch==EOF || ch==(unsigned char)delim)
7097                 break;
7098
7099             *str++ = ch;
7100             this->count++;
7101             count--;
7102         }
7103
7104         if(ch == (unsigned char)delim)
7105             this->count++;
7106         else if(ch != EOF) {
7107             ch = basic_streambuf_char_sgetc(strbuf);
7108
7109             if(ch == (unsigned char)delim) {
7110                 basic_streambuf_char__Gninc(strbuf);
7111                 this->count++;
7112             }
7113         }
7114     }
7115     basic_istream_char_sentry_destroy(this);
7116
7117     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
7118             (!this->count || (ch!=(unsigned char)delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
7119     if(count > 0)
7120         *str = 0;
7121     return this;
7122 }
7123
7124 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7125 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7126 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
7127 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
7128 {
7129     return basic_istream_char_getline_delim(this, str, count, '\n');
7130 }
7131
7132 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
7133 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7134 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
7135 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
7136 {
7137     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7138     int ch = (unsigned char)delim;
7139     unsigned int state;
7140
7141     TRACE("(%p %ld %d)\n", this, count, delim);
7142
7143     this->count = 0;
7144
7145     if(basic_istream_char_sentry_create(this, TRUE)) {
7146         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7147         state = IOSTATE_goodbit;
7148
7149         while(count > 0) {
7150             ch = basic_streambuf_char_sbumpc(strbuf);
7151
7152             if(ch==EOF) {
7153                 state = IOSTATE_eofbit;
7154                 break;
7155             }
7156
7157             if(ch==(unsigned char)delim)
7158                 break;
7159
7160             this->count++;
7161             if(count != INT_MAX)
7162                 count--;
7163         }
7164     }else
7165         state = IOSTATE_failbit;
7166     basic_istream_char_sentry_destroy(this);
7167
7168     basic_ios_char_setstate(base, state);
7169     return this;
7170 }
7171
7172 /* ?ws@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@1@AAV21@@Z */
7173 /* ?ws@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
7174 basic_istream_char* __cdecl ws_basic_istream_char(basic_istream_char *istream)
7175 {
7176     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7177     int ch = '\n';
7178
7179     TRACE("(%p)\n", istream);
7180
7181     if(basic_istream_char_sentry_create(istream, TRUE)) {
7182         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7183         const ctype_char *ctype = ctype_char_use_facet(&strbuf->loc);
7184
7185         for(ch = basic_streambuf_char_sgetc(strbuf); ctype_char_is_ch(ctype, _SPACE, ch);
7186                 ch = basic_streambuf_char_snextc(strbuf)) {
7187             if(ch == EOF)
7188                 break;
7189         }
7190     }
7191     basic_istream_char_sentry_destroy(istream);
7192
7193     if(ch == EOF)
7194         basic_ios_char_setstate(base, IOSTATE_eofbit);
7195     return istream;
7196 }
7197
7198 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7199 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7200 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
7201 int __thiscall basic_istream_char_peek(basic_istream_char *this)
7202 {
7203     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7204     int ret = EOF;
7205
7206     TRACE("(%p)\n", this);
7207
7208     this->count = 0;
7209
7210     if(basic_istream_char_sentry_create(this, TRUE))
7211         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7212     basic_istream_char_sentry_destroy(this);
7213
7214     if (ret == EOF)
7215         basic_ios_char_setstate(base, IOSTATE_eofbit);
7216
7217     return ret;
7218 }
7219
7220 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
7221 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
7222 static basic_istream_char* basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7223 {
7224     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7225     IOSB_iostate state = IOSTATE_goodbit;
7226
7227     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7228
7229     if(basic_istream_char_sentry_create(this, TRUE)) {
7230         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7231
7232         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
7233         if(this->count != count)
7234             state |= IOSTATE_failbit | IOSTATE_eofbit;
7235     }else {
7236         this->count = 0;
7237     }
7238     basic_istream_char_sentry_destroy(this);
7239
7240     basic_ios_char_setstate(base, state);
7241     return this;
7242 }
7243
7244 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7245 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7246 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
7247 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
7248 {
7249     return basic_istream_char__Read_s(this, str, count, count);
7250 }
7251
7252 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
7253 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
7254 static streamsize basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7255 {
7256     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7257     IOSB_iostate state = IOSTATE_goodbit;
7258
7259     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7260
7261     this->count = 0;
7262
7263     if(basic_istream_char_sentry_create(this, TRUE)) {
7264         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
7265         if(avail > count)
7266             avail = count;
7267
7268         if(avail == -1)
7269             state |= IOSTATE_eofbit;
7270         else if(avail > 0)
7271             basic_istream_char__Read_s(this, str, size, avail);
7272     }else {
7273         state |= IOSTATE_failbit;
7274     }
7275     basic_istream_char_sentry_destroy(this);
7276
7277     basic_ios_char_setstate(base, state);
7278     return this->count;
7279 }
7280
7281 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
7282 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
7283 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
7284 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
7285 {
7286     return basic_istream_char__Readsome_s(this, str, count, count);
7287 }
7288
7289 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
7290 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
7291 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
7292 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
7293 {
7294     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7295     IOSB_iostate state = IOSTATE_goodbit;
7296
7297     TRACE("(%p %c)\n", this, ch);
7298
7299     this->count = 0;
7300
7301     if(basic_istream_char_sentry_create(this, TRUE)) {
7302         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7303
7304         if(!ios_base_good(&base->base))
7305             state |= IOSTATE_failbit;
7306         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
7307             state |= IOSTATE_badbit;
7308     }
7309     basic_istream_char_sentry_destroy(this);
7310
7311     basic_ios_char_setstate(base, state);
7312     return this;
7313 }
7314
7315 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
7316 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
7317 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
7318 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
7319 {
7320     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7321     IOSB_iostate state = IOSTATE_goodbit;
7322
7323     TRACE("(%p)\n", this);
7324
7325     this->count = 0;
7326
7327     if(basic_istream_char_sentry_create(this, TRUE)) {
7328         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7329
7330         if(!ios_base_good(&base->base))
7331             state |= IOSTATE_failbit;
7332         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
7333             state |= IOSTATE_badbit;
7334     }
7335     basic_istream_char_sentry_destroy(this);
7336
7337     basic_ios_char_setstate(base, state);
7338     return this;
7339 }
7340
7341 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7342 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7343 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
7344 int __thiscall basic_istream_char_sync(basic_istream_char *this)
7345 {
7346     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7347     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7348
7349     TRACE("(%p)\n", this);
7350
7351     if(!strbuf)
7352         return -1;
7353
7354     if(basic_istream_char_sentry_create(this, TRUE)) {
7355         if(basic_streambuf_char_pubsync(strbuf) != -1) {
7356             basic_istream_char_sentry_destroy(this);
7357             return 0;
7358         }
7359     }
7360     basic_istream_char_sentry_destroy(this);
7361
7362     basic_ios_char_setstate(base, IOSTATE_badbit);
7363     return -1;
7364 }
7365
7366 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7367 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7368 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
7369 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
7370 {
7371     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7372
7373     TRACE("(%p %p)\n", this, ret);
7374
7375     if(ios_base_fail(&base->base)) {
7376         ret->off = -1;
7377         ret->pos = 0;
7378         ret->state = 0;
7379         return ret;
7380     }
7381
7382     basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
7383             ret, 0, SEEKDIR_cur, OPENMODE_in);
7384
7385     if(ret->off==-1 && ret->pos==0 && ret->state==0)
7386         basic_ios_char_setstate(base, IOSTATE_failbit);
7387
7388     return ret;
7389 }
7390
7391 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z */
7392 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z */
7393 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
7394 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
7395 {
7396     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7397
7398     TRACE("(%p %ld %d)\n", this, off, dir);
7399
7400     if(!ios_base_fail(&base->base)) {
7401         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7402         fpos_int ret;
7403
7404         basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
7405
7406         if(ret.off==-1 && ret.pos==0 && ret.state==0)
7407             basic_ios_char_setstate(base, IOSTATE_failbit);
7408         else
7409             basic_ios_char_clear(base, IOSTATE_goodbit);
7410         return this;
7411     }else
7412         basic_ios_char_clear(base, IOSTATE_goodbit);
7413
7414     return this;
7415 }
7416
7417 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7418 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7419 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
7420 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
7421 {
7422     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7423
7424     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7425
7426     if(!ios_base_fail(&base->base)) {
7427         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7428         fpos_int ret;
7429
7430         basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7431
7432         if(ret.off==-1 && ret.pos==0 && ret.state==0)
7433             basic_ios_char_setstate(base, IOSTATE_failbit);
7434         else
7435             basic_ios_char_clear(base, IOSTATE_goodbit);
7436         return this;
7437     }else
7438         basic_ios_char_clear(base, IOSTATE_goodbit);
7439
7440     return this;
7441 }
7442
7443 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
7444 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
7445 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
7446 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
7447 {
7448     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7449     int state = IOSTATE_goodbit;
7450
7451     TRACE("(%p %p)\n", this, v);
7452
7453     if(basic_istream_char_sentry_create(this, FALSE)) {
7454         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7455         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7456         istreambuf_iterator_char first={0}, last={0};
7457         LONG tmp;
7458
7459         first.strbuf = strbuf;
7460         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7461
7462         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7463             *v = tmp;
7464         else
7465             state |= IOSTATE_failbit;
7466     }
7467     basic_istream_char_sentry_destroy(this);
7468
7469     basic_ios_char_setstate(base, state);
7470     return this;
7471 }
7472
7473 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
7474 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
7475 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
7476 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
7477 {
7478     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7479     int state = IOSTATE_goodbit;
7480
7481     TRACE("(%p %p)\n", this, v);
7482
7483     if(basic_istream_char_sentry_create(this, FALSE)) {
7484         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7485         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7486         istreambuf_iterator_char first={0}, last={0};
7487
7488         first.strbuf = strbuf;
7489         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
7490     }
7491     basic_istream_char_sentry_destroy(this);
7492
7493     basic_ios_char_setstate(base, state);
7494     return this;
7495 }
7496
7497 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
7498 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
7499 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
7500 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
7501 {
7502     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7503     int state = IOSTATE_goodbit;
7504
7505     TRACE("(%p %p)\n", this, v);
7506
7507     if(basic_istream_char_sentry_create(this, FALSE)) {
7508         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7509         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7510         istreambuf_iterator_char first={0}, last={0};
7511
7512         first.strbuf = strbuf;
7513         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7514     }
7515     basic_istream_char_sentry_destroy(this);
7516
7517     basic_ios_char_setstate(base, state);
7518     return this;
7519 }
7520
7521 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
7522 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
7523 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
7524 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *v)
7525 {
7526     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7527     int state = IOSTATE_goodbit;
7528
7529     TRACE("(%p %p)\n", this, v);
7530
7531     if(basic_istream_char_sentry_create(this, FALSE)) {
7532         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7533         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7534         istreambuf_iterator_char first={0}, last={0};
7535
7536         first.strbuf = strbuf;
7537         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
7538     }
7539     basic_istream_char_sentry_destroy(this);
7540
7541     basic_ios_char_setstate(base, state);
7542     return this;
7543 }
7544
7545 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
7546 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
7547 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
7548 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
7549 {
7550     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7551     int state = IOSTATE_goodbit;
7552
7553     TRACE("(%p %p)\n", this, v);
7554
7555     if(basic_istream_char_sentry_create(this, FALSE)) {
7556         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7557         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7558         istreambuf_iterator_char first={0}, last={0};
7559
7560         first.strbuf = strbuf;
7561         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7562     }
7563     basic_istream_char_sentry_destroy(this);
7564
7565     basic_ios_char_setstate(base, state);
7566     return this;
7567 }
7568
7569 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
7570 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
7571 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
7572 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
7573 {
7574     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7575     int state = IOSTATE_goodbit;
7576
7577     TRACE("(%p %p)\n", this, v);
7578
7579     if(basic_istream_char_sentry_create(this, FALSE)) {
7580         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7581         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7582         istreambuf_iterator_char first={0}, last={0};
7583
7584         first.strbuf = strbuf;
7585         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
7586     }
7587     basic_istream_char_sentry_destroy(this);
7588
7589     basic_ios_char_setstate(base, state);
7590     return this;
7591 }
7592
7593 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
7594 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
7595 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
7596 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
7597 {
7598     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7599     int state = IOSTATE_goodbit;
7600
7601     TRACE("(%p %p)\n", this, v);
7602
7603     if(basic_istream_char_sentry_create(this, FALSE)) {
7604         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7605         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7606         istreambuf_iterator_char first={0}, last={0};
7607
7608         first.strbuf = strbuf;
7609         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
7610     }
7611     basic_istream_char_sentry_destroy(this);
7612
7613     basic_ios_char_setstate(base, state);
7614     return this;
7615 }
7616
7617 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
7618 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
7619 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
7620 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
7621 {
7622     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7623     int state = IOSTATE_goodbit;
7624
7625     TRACE("(%p %p)\n", this, v);
7626
7627     if(basic_istream_char_sentry_create(this, FALSE)) {
7628         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7629         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7630         istreambuf_iterator_char first={0}, last={0};
7631
7632         first.strbuf = strbuf;
7633         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
7634     }
7635     basic_istream_char_sentry_destroy(this);
7636
7637     basic_ios_char_setstate(base, state);
7638     return this;
7639 }
7640
7641 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
7642 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
7643 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
7644 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
7645 {
7646     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7647     int state = IOSTATE_goodbit;
7648
7649     TRACE("(%p %p)\n", this, v);
7650
7651     if(basic_istream_char_sentry_create(this, FALSE)) {
7652         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7653         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7654         istreambuf_iterator_char first={0}, last={0};
7655
7656         first.strbuf = strbuf;
7657         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
7658     }
7659     basic_istream_char_sentry_destroy(this);
7660
7661     basic_ios_char_setstate(base, state);
7662     return this;
7663 }
7664
7665 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
7666 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
7667 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
7668 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
7669 {
7670     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7671     int state = IOSTATE_goodbit;
7672
7673     TRACE("(%p %p)\n", this, v);
7674
7675     if(basic_istream_char_sentry_create(this, FALSE)) {
7676         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7677         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7678         istreambuf_iterator_char first={0}, last={0};
7679
7680         first.strbuf = strbuf;
7681         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
7682     }
7683     basic_istream_char_sentry_destroy(this);
7684
7685     basic_ios_char_setstate(base, state);
7686     return this;
7687 }
7688
7689 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
7690 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
7691 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
7692 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
7693 {
7694     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7695     int state = IOSTATE_goodbit;
7696
7697     TRACE("(%p %p)\n", this, v);
7698
7699     if(basic_istream_char_sentry_create(this, FALSE)) {
7700         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7701         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7702         istreambuf_iterator_char first={0}, last={0};
7703
7704         first.strbuf = strbuf;
7705         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
7706     }
7707     basic_istream_char_sentry_destroy(this);
7708
7709     basic_ios_char_setstate(base, state);
7710     return this;
7711 }
7712
7713 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
7714 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
7715 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
7716 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
7717 {
7718     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7719     int state = IOSTATE_goodbit;
7720
7721     TRACE("(%p %p)\n", this, v);
7722
7723     if(basic_istream_char_sentry_create(this, FALSE)) {
7724         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7725         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7726         istreambuf_iterator_char first={0}, last={0};
7727
7728         first.strbuf = strbuf;
7729         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
7730     }
7731     basic_istream_char_sentry_destroy(this);
7732
7733     basic_ios_char_setstate(base, state);
7734     return this;
7735 }
7736
7737 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
7738 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
7739 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
7740 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
7741 {
7742     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7743     int state = IOSTATE_goodbit;
7744
7745     TRACE("(%p %p)\n", this, v);
7746
7747     if(basic_istream_char_sentry_create(this, FALSE)) {
7748         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7749         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7750         istreambuf_iterator_char first={0}, last={0};
7751
7752         first.strbuf = strbuf;
7753         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
7754     }
7755     basic_istream_char_sentry_destroy(this);
7756
7757     basic_ios_char_setstate(base, state);
7758     return this;
7759 }
7760
7761 /* ??$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 */
7762 /* ??$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 */
7763 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
7764         basic_istream_char *istream, basic_string_char *str, char delim)
7765 {
7766     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7767     IOSB_iostate state = IOSTATE_goodbit;
7768     int c = (unsigned char)delim;
7769
7770     TRACE("(%p %p %c)\n", istream, str, delim);
7771
7772     if(basic_istream_char_sentry_create(istream, TRUE)) {
7773         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7774         basic_string_char_clear(str);
7775
7776         c = basic_streambuf_char_sgetc(strbuf);
7777         for(; c!=(unsigned char)delim && c!=EOF; c = basic_streambuf_char_snextc(strbuf))
7778             basic_string_char_append_ch(str, c);
7779         if(c==EOF) state |= IOSTATE_eofbit;
7780         else if(c==(unsigned char)delim) basic_streambuf_char_sbumpc(strbuf);
7781
7782         if(!basic_string_char_length(str) && c!=(unsigned char)delim) state |= IOSTATE_failbit;
7783     }
7784     basic_istream_char_sentry_destroy(istream);
7785
7786     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream), state);
7787     return istream;
7788 }
7789
7790 /* ??$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 */
7791 /* ??$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 */
7792 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
7793         basic_istream_char *istream, basic_string_char *str)
7794 {
7795     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
7796 }
7797
7798 /* ??$?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 */
7799 /* ??$?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 */
7800 basic_istream_char* __cdecl basic_istream_char_read_bstr(
7801         basic_istream_char *istream, basic_string_char *str)
7802 {
7803     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7804     IOSB_iostate state = IOSTATE_failbit;
7805     int c = '\n';
7806
7807     TRACE("(%p %p)\n", istream, str);
7808
7809     if(basic_istream_char_sentry_create(istream, FALSE)) {
7810         const ctype_char *ctype = ctype_char_use_facet(&base->strbuf->loc);
7811         MSVCP_size_t count = ios_base_width_get(&base->base);
7812
7813         if(!count)
7814             count = -1;
7815
7816         basic_string_char_clear(str);
7817
7818         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7819                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7820                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7821             state = IOSTATE_goodbit;
7822             basic_string_char_append_ch(str, c);
7823         }
7824     }
7825     basic_istream_char_sentry_destroy(istream);
7826
7827     ios_base_width_set(&base->base, 0);
7828     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7829     return istream;
7830 }
7831
7832 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z */
7833 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z */
7834 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAC@Z */
7835 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAC@Z */
7836 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAE@Z */
7837 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAE@Z */
7838 basic_istream_char* __cdecl basic_istream_char_read_str(basic_istream_char *istream, char *str)
7839 {
7840     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7841     IOSB_iostate state = IOSTATE_failbit;
7842     int c = '\n';
7843
7844     TRACE("(%p %p)\n", istream, str);
7845
7846     if(basic_istream_char_sentry_create(istream, FALSE)) {
7847         const ctype_char *ctype = ctype_char_use_facet(&base->strbuf->loc);
7848         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
7849
7850         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7851                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7852                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7853             state = IOSTATE_goodbit;
7854             *str++ = c;
7855         }
7856     }
7857     basic_istream_char_sentry_destroy(istream);
7858
7859     *str = 0;
7860     ios_base_width_set(&base->base, 0);
7861     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7862     return istream;
7863 }
7864
7865 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z */
7866 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAD@Z */
7867 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z */
7868 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAC@Z */
7869 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z */
7870 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAE@Z */
7871 basic_istream_char* __cdecl basic_istream_char_read_ch(basic_istream_char *istream, char *ch)
7872 {
7873     IOSB_iostate state = IOSTATE_failbit;
7874     int c = 0;
7875
7876     TRACE("(%p %p)\n", istream, ch);
7877
7878     if(basic_istream_char_sentry_create(istream, FALSE)) {
7879         c = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(
7880                     basic_istream_char_get_basic_ios(istream)));
7881         if(c != EOF) {
7882             state = IOSTATE_goodbit;
7883             *ch = c;
7884         }
7885     }
7886     basic_istream_char_sentry_destroy(istream);
7887
7888     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
7889             state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7890     return istream;
7891 }
7892
7893 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7894 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7895 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
7896 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
7897         basic_istream_char *this, basic_streambuf_char *streambuf)
7898 {
7899     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7900     IOSB_iostate state = IOSTATE_failbit;
7901     int c = '\n';
7902
7903     TRACE("(%p %p)\n", this, streambuf);
7904
7905     if(basic_istream_char_sentry_create(this, FALSE)) {
7906         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
7907                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
7908             state = IOSTATE_goodbit;
7909             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
7910                 break;
7911         }
7912     }
7913     basic_istream_char_sentry_destroy(this);
7914
7915     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7916     return this;
7917 }
7918
7919 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7920 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7921 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
7922 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
7923         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
7924 {
7925     TRACE("(%p %p)\n", this, pfunc);
7926     pfunc(this);
7927     return this;
7928 }
7929
7930 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
7931 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
7932 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
7933 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
7934         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
7935 {
7936     TRACE("(%p %p)\n", this, pfunc);
7937     pfunc(basic_istream_char_get_basic_ios(this));
7938     return this;
7939 }
7940
7941 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7942 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7943 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
7944 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
7945         ios_base* (__cdecl *pfunc)(ios_base*))
7946 {
7947     TRACE("(%p %p)\n", this, pfunc);
7948     pfunc(&basic_istream_char_get_basic_ios(this)->base);
7949     return this;
7950 }
7951
7952 /* Caution: basic_istream uses virtual inheritance. */
7953 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
7954 {
7955     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
7956 }
7957
7958 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
7959 {
7960     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
7961 }
7962
7963 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
7964 {
7965     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
7966 }
7967
7968 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7969 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7970 static basic_istream_wchar* basic_istream_wchar_ctor_init(basic_istream_wchar *this,
7971         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7972 {
7973     basic_ios_wchar *base;
7974
7975     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
7976
7977     if(virt_init) {
7978         this->vbtable = basic_istream_wchar_vbtable;
7979         base = basic_istream_wchar_get_basic_ios(this);
7980         basic_ios_wchar_ctor(base);
7981     }else {
7982         base = basic_istream_wchar_get_basic_ios(this);
7983     }
7984
7985     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
7986     this->count = 0;
7987     if(!noinit)
7988         basic_ios_wchar_init(base, strbuf, isstd);
7989     return this;
7990 }
7991
7992 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7993 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7994 static basic_istream_wchar* basic_istream_short_ctor_init(basic_istream_wchar *this,
7995         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7996 {
7997     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
7998     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
7999     return this;
8000 }
8001
8002 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8003 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8004 static basic_istream_wchar* basic_istream_wchar_ctor(basic_istream_wchar *this,
8005         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8006 {
8007     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8008 }
8009
8010 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8011 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8012 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor, 16)
8013 basic_istream_wchar* __thiscall basic_istream_short_ctor(basic_istream_wchar *this,
8014         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8015 {
8016     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8017 }
8018
8019 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8020 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8021 static basic_istream_wchar* basic_istream_wchar_ctor_uninitialized(
8022         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8023 {
8024     basic_ios_wchar *base;
8025
8026     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
8027
8028     if(virt_init) {
8029         this->vbtable = basic_istream_wchar_vbtable;
8030         base = basic_istream_wchar_get_basic_ios(this);
8031         basic_ios_wchar_ctor(base);
8032     }else {
8033         base = basic_istream_wchar_get_basic_ios(this);
8034     }
8035
8036     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8037     ios_base_Addstd(&base->base);
8038     return this;
8039 }
8040
8041 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8042 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8043 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
8044 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
8045         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8046 {
8047     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
8048     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8049     return this;
8050 }
8051
8052 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
8053 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
8054 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
8055 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
8056 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
8057 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
8058 {
8059     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8060
8061     /* don't destroy virtual base here */
8062     TRACE("(%p)\n", this);
8063 }
8064
8065 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8066 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8067 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8068 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8069 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
8070 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
8071 {
8072     TRACE("(%p)\n", this);
8073     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
8074     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
8075 }
8076
8077 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
8078 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
8079 {
8080     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8081
8082     TRACE("(%p %x)\n", this, flags);
8083
8084     if(flags & 2) {
8085         /* we have an array, with the number of elements stored before the first object */
8086         INT_PTR i, *ptr = (INT_PTR *)this-1;
8087
8088         for(i=*ptr-1; i>=0; i--)
8089             basic_istream_wchar_vbase_dtor(this+i);
8090         MSVCRT_operator_delete(ptr);
8091     } else {
8092         basic_istream_wchar_vbase_dtor(this);
8093         if(flags & 1)
8094             MSVCRT_operator_delete(this);
8095     }
8096
8097     return this;
8098 }
8099
8100 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8101 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8102 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8103 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8104 static MSVCP_bool basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8105 {
8106     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8107
8108     TRACE("(%p %d)\n", this, noskip);
8109
8110     if(ios_base_good(&base->base)) {
8111         if(basic_ios_wchar_tie_get(base))
8112             basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
8113
8114         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
8115             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8116             const ctype_wchar *ctype = ctype_wchar_use_facet(&base->strbuf->loc);
8117             int ch;
8118
8119             for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
8120                     ch = basic_streambuf_wchar_snextc(strbuf)) {
8121                 if(ch == WEOF) {
8122                     basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8123                     break;
8124                 }
8125
8126                 if(!ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
8127                     break;
8128             }
8129         }
8130     }
8131
8132     if(!ios_base_good(&base->base)) {
8133         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8134         return FALSE;
8135     }
8136     return TRUE;
8137 }
8138
8139 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8140 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8141 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8142 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8143 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
8144 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8145 {
8146     return basic_istream_wchar__Ipfx(this, noskip);
8147 }
8148
8149 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8150 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8151 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8152 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8153 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
8154 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
8155 {
8156     TRACE("(%p)\n", this);
8157 }
8158
8159 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
8160 {
8161     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8162
8163     if(basic_ios_wchar_rdbuf_get(base))
8164         basic_streambuf_wchar__Lock(base->strbuf);
8165
8166     return basic_istream_wchar_ipfx(istr, noskip);
8167 }
8168
8169 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
8170 {
8171     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8172
8173     if(basic_ios_wchar_rdbuf_get(base))
8174         basic_streambuf_wchar__Unlock(base->strbuf);
8175 }
8176
8177 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
8178 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
8179 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
8180 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
8181 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
8182 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
8183 {
8184     TRACE("(%p)\n", this);
8185     return this->count;
8186 }
8187
8188 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8189 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8190 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8191 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8192 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
8193 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
8194 {
8195     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8196     int ret;
8197
8198     TRACE("(%p)\n", this);
8199
8200     this->count = 0;
8201
8202     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
8203         basic_istream_wchar_sentry_destroy(this);
8204         return WEOF;
8205     }
8206
8207     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
8208     basic_istream_wchar_sentry_destroy(this);
8209     if(ret == WEOF)
8210         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
8211     else
8212         this->count++;
8213
8214     return ret;
8215 }
8216
8217 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
8218 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
8219 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
8220 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
8221 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
8222 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
8223 {
8224     unsigned short ret;
8225
8226     TRACE("(%p %p)\n", this, ch);
8227
8228     ret = basic_istream_wchar_get(this);
8229     if(ret != WEOF)
8230         *ch = (wchar_t)ret;
8231     return this;
8232 }
8233
8234 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8235 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8236 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8237 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8238 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 16)
8239 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8240 {
8241     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8242     unsigned short ch = delim;
8243
8244     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8245
8246     this->count = 0;
8247
8248     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8249         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8250
8251         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
8252                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8253             if(ch==WEOF || ch==delim)
8254                 break;
8255
8256             *str++ = ch;
8257             this->count++;
8258             count--;
8259         }
8260     }
8261     basic_istream_wchar_sentry_destroy(this);
8262
8263     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8264             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8265     if(count > 0)
8266         *str = 0;
8267     return this;
8268 }
8269
8270 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8271 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8272 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8273 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8274 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 12)
8275 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
8276 {
8277     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
8278 }
8279
8280 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8281 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8282 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8283 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8284 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
8285 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
8286 {
8287     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8288     unsigned short ch = delim;
8289
8290     TRACE("(%p %p %c)\n", this, strbuf, delim);
8291
8292     this->count = 0;
8293
8294     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8295         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
8296
8297         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
8298                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
8299             if(ch==WEOF || ch==delim)
8300                 break;
8301
8302             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
8303                 break;
8304             this->count++;
8305         }
8306     }
8307     basic_istream_wchar_sentry_destroy(this);
8308
8309     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8310             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8311     return this;
8312 }
8313
8314 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8315 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8316 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8317 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8318 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
8319 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
8320 {
8321     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
8322 }
8323
8324 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8325 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8326 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8327 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8328 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 16)
8329 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8330 {
8331     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8332     unsigned short ch = delim;
8333
8334     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8335
8336     this->count = 0;
8337
8338     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
8339         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8340
8341         while(count > 1) {
8342             ch = basic_streambuf_wchar_sbumpc(strbuf);
8343
8344             if(ch==WEOF || ch==delim)
8345                 break;
8346
8347             *str++ = ch;
8348             this->count++;
8349             count--;
8350         }
8351
8352         if(ch == delim)
8353             this->count++;
8354         else if(ch != WEOF) {
8355             ch = basic_streambuf_wchar_sgetc(strbuf);
8356
8357             if(ch == delim) {
8358                 basic_streambuf_wchar__Gninc(strbuf);
8359                 this->count++;
8360             }
8361         }
8362     }
8363     basic_istream_wchar_sentry_destroy(this);
8364
8365     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
8366             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
8367     if(count > 0)
8368         *str = 0;
8369     return this;
8370 }
8371
8372 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8373 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8374 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8375 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8376 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 12)
8377 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
8378 {
8379     return basic_istream_wchar_getline_delim(this, str, count, '\n');
8380 }
8381
8382 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
8383 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
8384 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
8385 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
8386 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 12)
8387 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
8388 {
8389     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8390     unsigned short ch = delim;
8391     unsigned int state;
8392
8393     TRACE("(%p %ld %d)\n", this, count, delim);
8394
8395     this->count = 0;
8396
8397     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8398         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8399         state = IOSTATE_goodbit;
8400
8401         while(count > 0) {
8402             ch = basic_streambuf_wchar_sbumpc(strbuf);
8403
8404             if(ch==WEOF) {
8405                 state = IOSTATE_eofbit;
8406                 break;
8407             }
8408
8409             if(ch==delim)
8410                 break;
8411
8412             this->count++;
8413             if(count != INT_MAX)
8414                 count--;
8415         }
8416     }else
8417         state = IOSTATE_failbit;
8418     basic_istream_wchar_sentry_destroy(this);
8419
8420     basic_ios_wchar_setstate(base, state);
8421     return this;
8422 }
8423
8424 /* ?ws@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
8425 /* ?ws@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
8426 /* ?ws@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@1@AAV21@@Z */
8427 /* ?ws@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
8428 basic_istream_wchar* __cdecl ws_basic_istream_wchar(basic_istream_wchar *istream)
8429 {
8430     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8431     unsigned short ch = '\n';
8432
8433     TRACE("(%p)\n", istream);
8434
8435     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8436         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8437         const ctype_wchar *ctype = ctype_wchar_use_facet(&strbuf->loc);
8438
8439         for(ch = basic_streambuf_wchar_sgetc(strbuf); ctype_wchar_is_ch(ctype, _SPACE, ch);
8440                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8441             if(ch == WEOF)
8442                 break;
8443         }
8444     }
8445     basic_istream_wchar_sentry_destroy(istream);
8446
8447     if(ch == WEOF)
8448         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8449     return istream;
8450 }
8451
8452 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8453 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8454 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8455 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8456 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
8457 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
8458 {
8459     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8460     unsigned short ret = WEOF;
8461
8462     TRACE("(%p)\n", this);
8463
8464     this->count = 0;
8465
8466     if(basic_istream_wchar_sentry_create(this, TRUE))
8467         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8468     basic_istream_wchar_sentry_destroy(this);
8469
8470     if (ret == WEOF)
8471         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8472
8473     return ret;
8474 }
8475
8476 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
8477 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
8478 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
8479 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
8480 static basic_istream_wchar* basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8481 {
8482     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8483     IOSB_iostate state = IOSTATE_goodbit;
8484
8485     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8486
8487     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8488         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8489
8490         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
8491         if(this->count != count)
8492             state |= IOSTATE_failbit | IOSTATE_eofbit;
8493     }else {
8494         this->count = 0;
8495     }
8496     basic_istream_wchar_sentry_destroy(this);
8497
8498     basic_ios_wchar_setstate(base, state);
8499     return this;
8500 }
8501
8502 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8503 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8504 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8505 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8506 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 12)
8507 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
8508 {
8509     return basic_istream_wchar__Read_s(this, str, count, count);
8510 }
8511
8512 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
8513 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
8514 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
8515 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
8516 static streamsize basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8517 {
8518     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8519     IOSB_iostate state = IOSTATE_goodbit;
8520
8521     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8522
8523     this->count = 0;
8524
8525     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8526         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
8527         if(avail > count)
8528             avail = count;
8529
8530         if(avail == -1)
8531             state |= IOSTATE_eofbit;
8532         else if(avail > 0)
8533             basic_istream_wchar__Read_s(this, str, size, avail);
8534     }else {
8535         state |= IOSTATE_failbit;
8536     }
8537     basic_istream_wchar_sentry_destroy(this);
8538
8539     basic_ios_wchar_setstate(base, state);
8540     return this->count;
8541 }
8542
8543 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
8544 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
8545 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
8546 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
8547 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 12)
8548 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
8549 {
8550     return basic_istream_wchar__Readsome_s(this, str, count, count);
8551 }
8552
8553 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
8554 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
8555 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
8556 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
8557 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
8558 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
8559 {
8560     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8561     IOSB_iostate state = IOSTATE_goodbit;
8562
8563     TRACE("(%p %c)\n", this, ch);
8564
8565     this->count = 0;
8566
8567     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8568         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8569
8570         if(!ios_base_good(&base->base))
8571             state |= IOSTATE_failbit;
8572         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
8573             state |= IOSTATE_badbit;
8574     }
8575     basic_istream_wchar_sentry_destroy(this);
8576
8577     basic_ios_wchar_setstate(base, state);
8578     return this;
8579 }
8580
8581 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
8582 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
8583 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
8584 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
8585 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
8586 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
8587 {
8588     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8589     IOSB_iostate state = IOSTATE_goodbit;
8590
8591     TRACE("(%p)\n", this);
8592
8593     this->count = 0;
8594
8595     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8596         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8597
8598         if(!ios_base_good(&base->base))
8599             state |= IOSTATE_failbit;
8600         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
8601             state |= IOSTATE_badbit;
8602     }
8603     basic_istream_wchar_sentry_destroy(this);
8604
8605     basic_ios_wchar_setstate(base, state);
8606     return this;
8607 }
8608
8609 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
8610 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
8611 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
8612 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
8613 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
8614 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
8615 {
8616     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8617     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8618
8619     TRACE("(%p)\n", this);
8620
8621     if(!strbuf)
8622         return -1;
8623
8624     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8625         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
8626             basic_istream_wchar_sentry_destroy(this);
8627             return 0;
8628         }
8629     }
8630     basic_istream_wchar_sentry_destroy(this);
8631
8632     basic_ios_wchar_setstate(base, IOSTATE_badbit);
8633     return -1;
8634 }
8635
8636 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8637 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8638 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8639 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8640 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
8641 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
8642 {
8643     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8644
8645     TRACE("(%p %p)\n", this, ret);
8646
8647     if(ios_base_fail(&base->base)) {
8648         ret->off = -1;
8649         ret->pos = 0;
8650         ret->state = 0;
8651         return ret;
8652     }
8653
8654     basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
8655             ret, 0, SEEKDIR_cur, OPENMODE_in);
8656     if(ret->off==-1 && ret->pos==0 && ret->state==0)
8657         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8658
8659     return ret;
8660 }
8661
8662 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z */
8663 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z */
8664 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 12)
8665 basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir)
8666 {
8667     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8668
8669     TRACE("(%p %ld %d)\n", this, off, dir);
8670
8671     if(!ios_base_fail(&base->base)) {
8672         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8673         fpos_int ret;
8674
8675         basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
8676
8677         if(ret.off==-1 && ret.pos==0 && ret.state==0)
8678             basic_ios_wchar_setstate(base, IOSTATE_failbit);
8679         else
8680             basic_ios_wchar_clear(base, IOSTATE_goodbit);
8681         return this;
8682     }else
8683         basic_ios_wchar_clear(base, IOSTATE_goodbit);
8684
8685     return this;
8686 }
8687
8688 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8689 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8690 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8691 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8692 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
8693 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
8694 {
8695     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8696
8697     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
8698
8699     if(!ios_base_fail(&base->base)) {
8700         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8701         fpos_int ret;
8702
8703         basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
8704
8705         if(ret.off==-1 && ret.pos==0 && ret.state==0)
8706             basic_ios_wchar_setstate(base, IOSTATE_failbit);
8707         else
8708             basic_ios_wchar_clear(base, IOSTATE_goodbit);
8709         return this;
8710     }else
8711         basic_ios_wchar_clear(base, IOSTATE_goodbit);
8712
8713     return this;
8714 }
8715
8716 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
8717 {
8718     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8719     int state = IOSTATE_goodbit;
8720
8721     TRACE("(%p %p)\n", this, v);
8722
8723     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8724         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8725         istreambuf_iterator_wchar first={0}, last={0};
8726         LONG tmp;
8727
8728         first.strbuf = strbuf;
8729         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
8730
8731         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
8732             *v = tmp;
8733         else
8734             state |= IOSTATE_failbit;
8735     }
8736     basic_istream_wchar_sentry_destroy(this);
8737
8738     basic_ios_wchar_setstate(base, state);
8739     return this;
8740 }
8741
8742 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
8743 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
8744 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
8745 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
8746 {
8747     return basic_istream_read_short(this, v, num_get_short_use_facet(
8748                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8749 }
8750
8751 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
8752 {
8753     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8754     int state = IOSTATE_goodbit;
8755
8756     TRACE("(%p %p)\n", this, v);
8757
8758     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8759         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8760         istreambuf_iterator_wchar first={0}, last={0};
8761
8762         first.strbuf = strbuf;
8763         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8764     }
8765     basic_istream_wchar_sentry_destroy(this);
8766
8767     basic_ios_wchar_setstate(base, state);
8768     return this;
8769 }
8770
8771 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
8772 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
8773 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
8774 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
8775 {
8776     return basic_istream_read_int(this, v, num_get_short_use_facet(
8777                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8778 }
8779
8780 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
8781 {
8782     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8783     int state = IOSTATE_goodbit;
8784
8785     TRACE("(%p %p)\n", this, v);
8786
8787     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8788         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8789         istreambuf_iterator_wchar first={0}, last={0};
8790
8791         first.strbuf = strbuf;
8792         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
8793     }
8794     basic_istream_wchar_sentry_destroy(this);
8795
8796     basic_ios_wchar_setstate(base, state);
8797     return this;
8798 }
8799
8800 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
8801 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
8802 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
8803 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
8804 {
8805     return basic_istream_read_uint(this, v, num_get_short_use_facet(
8806                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8807 }
8808
8809 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
8810 {
8811     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8812     int state = IOSTATE_goodbit;
8813
8814     TRACE("(%p %p)\n", this, v);
8815
8816     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8817         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8818         istreambuf_iterator_wchar first={0}, last={0};
8819
8820         first.strbuf = strbuf;
8821         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8822     }
8823     basic_istream_wchar_sentry_destroy(this);
8824
8825     basic_ios_wchar_setstate(base, state);
8826     return this;
8827 }
8828
8829 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
8830 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
8831 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
8832 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
8833 {
8834     return basic_istream_read_long(this, v, num_get_short_use_facet(
8835                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8836 }
8837
8838 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
8839 {
8840     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8841     int state = IOSTATE_goodbit;
8842
8843     TRACE("(%p %p)\n", this, v);
8844
8845     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8846         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8847         istreambuf_iterator_wchar first={0}, last={0};
8848
8849         first.strbuf = strbuf;
8850         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
8851     }
8852     basic_istream_wchar_sentry_destroy(this);
8853
8854     basic_ios_wchar_setstate(base, state);
8855     return this;
8856 }
8857
8858 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
8859 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
8860 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
8861 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
8862 {
8863     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
8864                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8865 }
8866
8867 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
8868 {
8869     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8870     int state = IOSTATE_goodbit;
8871
8872     TRACE("(%p %p)\n", this, v);
8873
8874     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8875         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8876         istreambuf_iterator_wchar first={0}, last={0};
8877
8878         first.strbuf = strbuf;
8879         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
8880     }
8881     basic_istream_wchar_sentry_destroy(this);
8882
8883     basic_ios_wchar_setstate(base, state);
8884     return this;
8885 }
8886
8887 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
8888 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
8889 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
8890 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
8891 {
8892     return basic_istream_read_float(this, v, num_get_short_use_facet(
8893                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8894 }
8895
8896 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
8897 {
8898     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8899     int state = IOSTATE_goodbit;
8900
8901     TRACE("(%p %p)\n", this, v);
8902
8903     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8904         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8905         istreambuf_iterator_wchar first={0}, last={0};
8906
8907         first.strbuf = strbuf;
8908         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
8909     }
8910     basic_istream_wchar_sentry_destroy(this);
8911
8912     basic_ios_wchar_setstate(base, state);
8913     return this;
8914 }
8915
8916 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
8917 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
8918 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
8919 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
8920 {
8921     return basic_istream_read_double(this, v, num_get_short_use_facet(
8922                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8923 }
8924
8925 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
8926 {
8927     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8928     int state = IOSTATE_goodbit;
8929
8930     TRACE("(%p %p)\n", this, v);
8931
8932     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8933         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8934         istreambuf_iterator_wchar first={0}, last={0};
8935
8936         first.strbuf = strbuf;
8937         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
8938     }
8939     basic_istream_wchar_sentry_destroy(this);
8940
8941     basic_ios_wchar_setstate(base, state);
8942     return this;
8943 }
8944
8945 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
8946 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
8947 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
8948 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
8949 {
8950     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
8951                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8952 }
8953
8954 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
8955 {
8956     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8957     int state = IOSTATE_goodbit;
8958
8959     TRACE("(%p %p)\n", this, v);
8960
8961     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8962         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8963         istreambuf_iterator_wchar first={0}, last={0};
8964
8965         first.strbuf = strbuf;
8966         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
8967     }
8968     basic_istream_wchar_sentry_destroy(this);
8969
8970     basic_ios_wchar_setstate(base, state);
8971     return this;
8972 }
8973
8974 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
8975 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
8976 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
8977 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
8978 {
8979     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
8980                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8981 }
8982
8983 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
8984 {
8985     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8986     int state = IOSTATE_goodbit;
8987
8988     TRACE("(%p %p)\n", this, v);
8989
8990     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8991         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8992         istreambuf_iterator_wchar first={0}, last={0};
8993
8994         first.strbuf = strbuf;
8995         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
8996     }
8997     basic_istream_wchar_sentry_destroy(this);
8998
8999     basic_ios_wchar_setstate(base, state);
9000     return this;
9001 }
9002
9003 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
9004 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
9005 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
9006 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
9007 {
9008     return basic_istream_read_int64(this, v, num_get_short_use_facet(
9009                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9010 }
9011
9012 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
9013 {
9014     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9015     int state = IOSTATE_goodbit;
9016
9017     TRACE("(%p %p)\n", this, v);
9018
9019     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9020         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9021         istreambuf_iterator_wchar first={0}, last={0};
9022
9023         first.strbuf = strbuf;
9024         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
9025     }
9026     basic_istream_wchar_sentry_destroy(this);
9027
9028     basic_ios_wchar_setstate(base, state);
9029     return this;
9030 }
9031
9032 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
9033 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
9034 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
9035 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9036 {
9037     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
9038                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9039 }
9040
9041 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
9042 {
9043     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9044     int state = IOSTATE_goodbit;
9045
9046     TRACE("(%p %p)\n", this, v);
9047
9048     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9049         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9050         istreambuf_iterator_wchar first={0}, last={0};
9051
9052         first.strbuf = strbuf;
9053         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
9054     }
9055     basic_istream_wchar_sentry_destroy(this);
9056
9057     basic_ios_wchar_setstate(base, state);
9058     return this;
9059 }
9060
9061 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
9062 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
9063 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
9064 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9065 {
9066     return basic_istream_read_bool(this, v, num_get_short_use_facet(
9067                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9068 }
9069
9070 /* ??$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 */
9071 /* ??$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 */
9072 /* ??$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 */
9073 /* ??$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 */
9074 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr_delim(
9075         basic_istream_wchar *istream, basic_string_wchar *str, wchar_t delim)
9076 {
9077     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9078     IOSB_iostate state = IOSTATE_goodbit;
9079     int c = delim;
9080
9081     TRACE("(%p %p %c)\n", istream, str, delim);
9082
9083     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
9084         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9085         basic_string_wchar_clear(str);
9086
9087         c = basic_streambuf_wchar_sgetc(strbuf);
9088         for(; c!=delim && c!=WEOF; c = basic_streambuf_wchar_snextc(strbuf))
9089             basic_string_wchar_append_ch(str, c);
9090         if(c==delim) basic_streambuf_wchar_sbumpc(strbuf);
9091         else if(c==WEOF) state |= IOSTATE_eofbit;
9092
9093         if(!basic_string_wchar_length(str) && c!=delim) state |= IOSTATE_failbit;
9094     }
9095     basic_istream_wchar_sentry_destroy(istream);
9096
9097     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream), state);
9098     return istream;
9099 }
9100
9101 /* ??$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 */
9102 /* ??$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 */
9103 /* ??$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 */
9104 /* ??$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 */
9105 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr(
9106         basic_istream_wchar *istream, basic_string_wchar *str)
9107 {
9108     return basic_istream_wchar_getline_bstr_delim(istream, str, '\n');
9109 }
9110
9111 static basic_istream_wchar* basic_istream_read_bstr(basic_istream_wchar *istream,
9112         basic_string_wchar *str, const ctype_wchar *ctype)
9113 {
9114     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9115     IOSB_iostate state = IOSTATE_failbit;
9116     int c = '\n';
9117
9118     TRACE("(%p %p)\n", istream, str);
9119
9120     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9121         MSVCP_size_t count = ios_base_width_get(&base->base);
9122
9123         if(!count)
9124             count = -1;
9125
9126         basic_string_wchar_clear(str);
9127
9128         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9129                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9130                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9131             state = IOSTATE_goodbit;
9132             basic_string_wchar_append_ch(str, c);
9133         }
9134     }
9135     basic_istream_wchar_sentry_destroy(istream);
9136
9137     ios_base_width_set(&base->base, 0);
9138     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9139     return istream;
9140 }
9141
9142 /* ??$?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 */
9143 /* ??$?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 */
9144 basic_istream_wchar* __cdecl basic_istream_wchar_read_bstr(
9145         basic_istream_wchar *istream, basic_string_wchar *str)
9146 {
9147     return basic_istream_read_bstr(istream, str, ctype_wchar_use_facet(
9148                 &basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9149 }
9150
9151 /* ??$?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 */
9152 /* ??$?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 */
9153 basic_istream_wchar* __cdecl basic_istream_short_read_bstr(
9154         basic_istream_wchar *istream, basic_string_wchar *str)
9155 {
9156     return basic_istream_read_bstr(istream, str, ctype_short_use_facet(
9157                 &basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9158 }
9159
9160 static basic_istream_wchar* basic_istream_read_str(basic_istream_wchar *istream, wchar_t *str, const ctype_wchar *ctype)
9161 {
9162     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9163     IOSB_iostate state = IOSTATE_failbit;
9164     unsigned short c = '\n';
9165
9166     TRACE("(%p %p)\n", istream, str);
9167
9168     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9169         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
9170
9171         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9172                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9173                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9174             state = IOSTATE_goodbit;
9175             *str++ = c;
9176         }
9177     }
9178     basic_istream_wchar_sentry_destroy(istream);
9179
9180     *str = 0;
9181     ios_base_width_set(&base->base, 0);
9182     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9183     return istream;
9184 }
9185
9186 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@PAG@Z */
9187 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@PEAG@Z */
9188 basic_istream_wchar* __cdecl basic_istream_short_read_str(basic_istream_wchar *istream, wchar_t *str)
9189 {
9190     return basic_istream_read_str(istream, str, ctype_short_use_facet(
9191                 &basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9192 }
9193
9194 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AA_W@Z */
9195 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEA_W@Z */
9196 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAG@Z */
9197 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAG@Z */
9198 basic_istream_wchar* __cdecl basic_istream_wchar_read_ch(basic_istream_wchar *istream, wchar_t *ch)
9199 {
9200     IOSB_iostate state = IOSTATE_failbit;
9201     unsigned short c = 0;
9202
9203     TRACE("(%p %p)\n", istream, ch);
9204
9205     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9206         c = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(
9207                     basic_istream_wchar_get_basic_ios(istream)));
9208         if(c != WEOF) {
9209             state = IOSTATE_goodbit;
9210             *ch = c;
9211         }
9212     }
9213     basic_istream_wchar_sentry_destroy(istream);
9214
9215     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9216             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9217     return istream;
9218 }
9219
9220 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9221 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9222 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9223 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9224 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
9225 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
9226         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
9227 {
9228     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9229     IOSB_iostate state = IOSTATE_failbit;
9230     unsigned short c = '\n';
9231
9232     TRACE("(%p %p)\n", this, streambuf);
9233
9234     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9235         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
9236                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
9237             state = IOSTATE_goodbit;
9238             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
9239                 break;
9240         }
9241     }
9242     basic_istream_wchar_sentry_destroy(this);
9243
9244     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9245     return this;
9246 }
9247
9248 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9249 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9250 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9251 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9252 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
9253 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
9254         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
9255 {
9256     TRACE("(%p %p)\n", this, pfunc);
9257     pfunc(this);
9258     return this;
9259 }
9260
9261 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
9262 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
9263 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
9264 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
9265 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
9266 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
9267         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
9268 {
9269     TRACE("(%p %p)\n", this, pfunc);
9270     pfunc(basic_istream_wchar_get_basic_ios(this));
9271     return this;
9272 }
9273
9274 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9275 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9276 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9277 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9278 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
9279 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
9280         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
9281 {
9282     TRACE("(%p %p)\n", this, pfunc);
9283     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
9284     return this;
9285 }
9286
9287 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
9288 {
9289     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
9290 }
9291
9292 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
9293 {
9294     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
9295 }
9296
9297 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9298 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9299 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
9300 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
9301 {
9302     basic_ios_char *basic_ios;
9303
9304     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9305
9306     if(virt_init) {
9307         this->base1.vbtable = basic_iostream_char_vbtable1;
9308         this->base2.vbtable = basic_iostream_char_vbtable2;
9309         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9310         basic_ios_char_ctor(basic_ios);
9311     }else {
9312         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9313     }
9314
9315     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
9316
9317     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
9318     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9319     return this;
9320 }
9321
9322 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9323 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9324 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
9325 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
9326 {
9327     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9328
9329     TRACE("(%p)\n", this);
9330     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
9331     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
9332 }
9333
9334 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9335 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9336 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
9337 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
9338 {
9339     TRACE("(%p)\n", this);
9340     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
9341     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
9342 }
9343
9344 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
9345 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9346 {
9347     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9348
9349     TRACE("(%p %x)\n", this, flags);
9350
9351     if(flags & 2) {
9352         /* we have an array, with the number of elements stored before the first object */
9353         INT_PTR i, *ptr = (INT_PTR *)this-1;
9354
9355         for(i=*ptr-1; i>=0; i--)
9356             basic_iostream_char_vbase_dtor(this+i);
9357         MSVCRT_operator_delete(ptr);
9358     } else {
9359         basic_iostream_char_vbase_dtor(this);
9360         if(flags & 1)
9361             MSVCRT_operator_delete(this);
9362     }
9363
9364     return this;
9365 }
9366
9367 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
9368 {
9369     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
9370 }
9371
9372 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9373 {
9374     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
9375 }
9376
9377 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9378 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9379 static basic_iostream_wchar* basic_iostream_wchar_ctor(basic_iostream_wchar *this,
9380         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9381 {
9382     basic_ios_wchar *basic_ios;
9383
9384     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9385
9386     if(virt_init) {
9387         this->base1.vbtable = basic_iostream_wchar_vbtable1;
9388         this->base2.vbtable = basic_iostream_wchar_vbtable2;
9389         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9390         basic_ios_wchar_ctor(basic_ios);
9391     }else {
9392         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9393     }
9394
9395     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
9396     basic_ostream_wchar_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9397
9398     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
9399     return this;
9400 }
9401
9402 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9403 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9404 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
9405 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
9406         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9407 {
9408     basic_iostream_wchar_ctor(this, strbuf, virt_init);
9409     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
9410     return this;
9411 }
9412
9413 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9414 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9415 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9416 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9417 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
9418 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
9419 {
9420     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9421
9422     TRACE("(%p)\n", this);
9423     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
9424     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
9425 }
9426
9427 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9428 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9429 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9430 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9431 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
9432 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
9433 {
9434     TRACE("(%p)\n", this);
9435     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
9436     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
9437 }
9438
9439 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
9440 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9441 {
9442     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9443
9444     TRACE("(%p %x)\n", this, flags);
9445
9446     if(flags & 2) {
9447         /* we have an array, with the number of elements stored before the first object */
9448         INT_PTR i, *ptr = (INT_PTR *)this-1;
9449
9450         for(i=*ptr-1; i>=0; i--)
9451             basic_iostream_wchar_vbase_dtor(this+i);
9452         MSVCRT_operator_delete(ptr);
9453     } else {
9454         basic_iostream_wchar_vbase_dtor(this);
9455         if(flags & 1)
9456             MSVCRT_operator_delete(this);
9457     }
9458
9459     return this;
9460 }
9461
9462 static inline basic_ios_char* basic_ofstream_char_to_basic_ios(basic_ofstream_char *ptr)
9463 {
9464     return (basic_ios_char*)((char*)ptr+basic_ofstream_char_vbtable[1]);
9465 }
9466
9467 static inline basic_ofstream_char* basic_ofstream_char_from_basic_ios(basic_ios_char *ptr)
9468 {
9469     return (basic_ofstream_char*)((char*)ptr-basic_ofstream_char_vbtable[1]);
9470 }
9471
9472 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9473 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9474 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
9475 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
9476 {
9477     basic_ios_char *basic_ios;
9478
9479     TRACE("(%p %d)\n", this, virt_init);
9480
9481     if(virt_init) {
9482         this->base.vbtable = basic_ofstream_char_vbtable;
9483         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9484         basic_ios_char_ctor(basic_ios);
9485     }else {
9486         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9487     }
9488
9489     basic_filebuf_char_ctor(&this->filebuf);
9490     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9491     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9492     return this;
9493 }
9494
9495 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
9496 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9497 static basic_ofstream_char* basic_ofstream_char_ctor_file(
9498         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
9499 {
9500     basic_ios_char *basic_ios;
9501
9502     TRACE("(%p %p %d)\n", this, file, virt_init);
9503
9504     if(virt_init) {
9505         this->base.vbtable = basic_ofstream_char_vbtable;
9506         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9507         basic_ios_char_ctor(basic_ios);
9508     }else {
9509         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9510     }
9511
9512     basic_filebuf_char_ctor_file(&this->filebuf, file);
9513     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9514     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9515     return this;
9516 }
9517
9518 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
9519 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
9520 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_copy_ctor, 12)
9521 basic_ofstream_char* __thiscall basic_ofstream_char_copy_ctor(basic_ofstream_char *this,
9522         basic_ofstream_char *copy, MSVCP_bool virt_init)
9523 {
9524     TRACE("(%p %p %d)\n", this, copy, virt_init);
9525     return basic_ofstream_char_ctor_file(this, copy->filebuf.file, virt_init);
9526 }
9527
9528 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
9529 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
9530 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 16)
9531 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
9532         const char *name, int mode, MSVCP_bool virt_init)
9533 {
9534     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9535
9536     basic_ofstream_char_ctor(this, virt_init);
9537
9538     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9539         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9540         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9541     }
9542     return this;
9543 }
9544
9545 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9546 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9547 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
9548 void __thiscall basic_ofstream_char_dtor(basic_ios_char *base)
9549 {
9550     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9551
9552     TRACE("(%p)\n", this);
9553
9554     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
9555     basic_filebuf_char_dtor(&this->filebuf);
9556 }
9557
9558 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9559 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9560 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
9561 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
9562 {
9563     TRACE("(%p)\n", this);
9564
9565     basic_ofstream_char_dtor(basic_ofstream_char_to_basic_ios(this));
9566     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
9567 }
9568
9569 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vector_dtor, 8)
9570 basic_ofstream_char* __thiscall basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9571 {
9572     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9573
9574     TRACE("(%p %x)\n", this, flags);
9575
9576     if(flags & 2) {
9577         /* we have an array, with the number of elements stored before the first object */
9578         INT_PTR i, *ptr = (INT_PTR *)this-1;
9579
9580         for(i=*ptr-1; i>=0; i--)
9581             basic_ofstream_char_vbase_dtor(this+i);
9582         MSVCRT_operator_delete(ptr);
9583     } else {
9584         basic_ofstream_char_vbase_dtor(this);
9585         if(flags & 1)
9586             MSVCRT_operator_delete(this);
9587     }
9588
9589     return this;
9590 }
9591
9592 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9593 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9594 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
9595 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
9596 {
9597     TRACE("(%p)\n", this);
9598
9599     if(!basic_filebuf_char_close(&this->filebuf)) {
9600         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9601         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9602     }
9603 }
9604
9605 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
9606 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
9607 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
9608 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
9609 {
9610     TRACE("(%p)\n", this);
9611     return basic_filebuf_char_is_open(&this->filebuf);
9612 }
9613
9614 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
9615 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
9616 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 12)
9617 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
9618         const char *name, int mode)
9619 {
9620     TRACE("(%p %s %d)\n", this, name, mode);
9621
9622     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9623         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9624         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9625     }
9626 }
9627
9628 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
9629 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
9630 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
9631 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
9632         const char *name, short mode)
9633 {
9634     basic_ofstream_char_open(this, name, mode);
9635 }
9636
9637 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9638 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9639 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
9640 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
9641 {
9642     TRACE("(%p)\n", this);
9643     return (basic_filebuf_char*)&this->filebuf;
9644 }
9645
9646 static inline basic_ios_wchar* basic_ofstream_wchar_to_basic_ios(basic_ofstream_wchar *ptr)
9647 {
9648     return (basic_ios_wchar*)((char*)ptr+basic_ofstream_wchar_vbtable[1]);
9649 }
9650
9651 static inline basic_ofstream_wchar* basic_ofstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9652 {
9653     return (basic_ofstream_wchar*)((char*)ptr-basic_ofstream_wchar_vbtable[1]);
9654 }
9655
9656 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
9657 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
9658 static basic_ofstream_wchar* basic_ofstream_wchar_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9659 {
9660     basic_ios_wchar *basic_ios;
9661
9662     TRACE("(%p %d)\n", this, virt_init);
9663
9664     if(virt_init) {
9665         this->base.vbtable = basic_ofstream_wchar_vbtable;
9666         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9667         basic_ios_wchar_ctor(basic_ios);
9668     }else {
9669         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9670     }
9671
9672     basic_filebuf_wchar_ctor(&this->filebuf);
9673     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9674     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
9675     return this;
9676 }
9677
9678 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
9679 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
9680 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor, 8)
9681 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9682 {
9683     basic_ofstream_wchar_ctor(this, virt_init);
9684     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
9685     return this;
9686 }
9687
9688 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
9689 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9690 static basic_ofstream_wchar* basic_ofstream_wchar_ctor_file(
9691         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9692 {
9693     basic_ios_wchar *basic_ios;
9694
9695     TRACE("(%p %p %d)\n", this, file, virt_init);
9696
9697     if(virt_init) {
9698         this->base.vbtable = basic_ofstream_wchar_vbtable;
9699         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9700         basic_ios_wchar_ctor(basic_ios);
9701     }else {
9702         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9703     }
9704
9705     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
9706     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9707     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
9708     return this;
9709 }
9710
9711 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
9712 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9713 static basic_ofstream_wchar* basic_ofstream_short_ctor_file(
9714         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9715 {
9716     basic_ofstream_wchar_ctor_file(this, file, virt_init);
9717     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
9718     return this;
9719 }
9720
9721 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
9722 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
9723 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_copy_ctor, 12)
9724 basic_ofstream_wchar* __thiscall basic_ofstream_short_copy_ctor(basic_ofstream_wchar *this,
9725         basic_ofstream_wchar *copy, MSVCP_bool virt_init)
9726 {
9727     TRACE("(%p %p %d)\n", this, copy, virt_init);
9728     return basic_ofstream_short_ctor_file(this, copy->filebuf.file, virt_init);
9729 }
9730
9731 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBDH@Z */
9732 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDH@Z */
9733 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name, 16)
9734 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name(basic_ofstream_wchar *this,
9735         const char *name, int mode, MSVCP_bool virt_init)
9736 {
9737     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9738
9739     basic_ofstream_short_ctor(this, virt_init);
9740
9741     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9742         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9743         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9744     }
9745     return this;
9746 }
9747
9748 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9749 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9750 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9751 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9752 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_dtor, 4)
9753 void __thiscall basic_ofstream_wchar_dtor(basic_ios_wchar *base)
9754 {
9755     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9756
9757     TRACE("(%p)\n", this);
9758
9759     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
9760     basic_filebuf_wchar_dtor(&this->filebuf);
9761 }
9762
9763 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9764 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9765 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9766 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9767 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vbase_dtor, 4)
9768 void __thiscall basic_ofstream_wchar_vbase_dtor(basic_ofstream_wchar *this)
9769 {
9770     TRACE("(%p)\n", this);
9771
9772     basic_ofstream_wchar_dtor(basic_ofstream_wchar_to_basic_ios(this));
9773     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
9774 }
9775
9776 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vector_dtor, 8)
9777 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9778 {
9779     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9780
9781     TRACE("(%p %x)\n", this, flags);
9782
9783     if(flags & 2) {
9784         /* we have an array, with the number of elements stored before the first object */
9785         INT_PTR i, *ptr = (INT_PTR *)this-1;
9786
9787         for(i=*ptr-1; i>=0; i--)
9788             basic_ofstream_wchar_vbase_dtor(this+i);
9789         MSVCRT_operator_delete(ptr);
9790     } else {
9791         basic_ofstream_wchar_vbase_dtor(this);
9792         if(flags & 1)
9793             MSVCRT_operator_delete(this);
9794     }
9795
9796     return this;
9797 }
9798
9799 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9800 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9801 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9802 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9803 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_close, 4)
9804 void __thiscall basic_ofstream_wchar_close(basic_ofstream_wchar *this)
9805 {
9806     TRACE("(%p)\n", this);
9807
9808     if(!basic_filebuf_wchar_close(&this->filebuf)) {
9809         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9810         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9811     }
9812 }
9813
9814 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
9815 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
9816 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
9817 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
9818 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_is_open, 4)
9819 MSVCP_bool __thiscall basic_ofstream_wchar_is_open(const basic_ofstream_wchar *this)
9820 {
9821     TRACE("(%p)\n", this);
9822     return basic_filebuf_wchar_is_open(&this->filebuf);
9823 }
9824
9825 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
9826 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
9827 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open, 12)
9828 void __thiscall basic_ofstream_wchar_open(basic_ofstream_wchar *this,
9829         const char *name, int mode)
9830 {
9831     TRACE("(%p %s %d)\n", this, name, mode);
9832
9833     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9834         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9835         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9836     }
9837 }
9838
9839 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
9840 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
9841 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_old, 12)
9842 void __thiscall basic_ofstream_wchar_open_old(basic_ofstream_wchar *this,
9843         const char *name, int mode)
9844 {
9845     basic_ofstream_wchar_open(this, name, mode);
9846 }
9847
9848 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9849 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9850 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9851 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9852 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_rdbuf, 4)
9853 basic_filebuf_wchar* __thiscall basic_ofstream_wchar_rdbuf(const basic_ofstream_wchar *this)
9854 {
9855     TRACE("(%p)\n", this);
9856     return (basic_filebuf_wchar*)&this->filebuf;
9857 }
9858
9859 static inline basic_ios_char* basic_ifstream_char_to_basic_ios(basic_ifstream_char *ptr)
9860 {
9861     return (basic_ios_char*)((char*)ptr+basic_ifstream_char_vbtable[1]);
9862 }
9863
9864 static inline basic_ifstream_char* basic_ifstream_char_from_basic_ios(basic_ios_char *ptr)
9865 {
9866     return (basic_ifstream_char*)((char*)ptr-basic_ifstream_char_vbtable[1]);
9867 }
9868
9869 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9870 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9871 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
9872 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
9873 {
9874     basic_ios_char *basic_ios;
9875
9876     TRACE("(%p %d)\n", this, virt_init);
9877
9878     if(virt_init) {
9879         this->base.vbtable = basic_ifstream_char_vbtable;
9880         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9881         basic_ios_char_ctor(basic_ios);
9882     }else {
9883         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9884     }
9885
9886     basic_filebuf_char_ctor(&this->filebuf);
9887     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9888     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
9889     return this;
9890 }
9891
9892 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
9893 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9894 static basic_ifstream_char* basic_ifstream_char_ctor_file(
9895         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
9896 {
9897     basic_ios_char *basic_ios;
9898
9899     TRACE("(%p %p %d)\n", this, file, virt_init);
9900
9901     if(virt_init) {
9902         this->base.vbtable = basic_ifstream_char_vbtable;
9903         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9904         basic_ios_char_ctor(basic_ios);
9905     }else {
9906         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9907     }
9908
9909     basic_filebuf_char_ctor_file(&this->filebuf, file);
9910     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9911     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
9912     return this;
9913 }
9914
9915 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
9916 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
9917 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_copy_ctor, 12)
9918 basic_ifstream_char* __thiscall basic_ifstream_char_copy_ctor(basic_ifstream_char *this,
9919         const basic_ifstream_char *copy, MSVCP_bool virt_init)
9920 {
9921     TRACE("(%p %p %d)\n", this, copy, virt_init);
9922     return basic_ifstream_char_ctor_file(this, copy->filebuf.file, virt_init);
9923 }
9924
9925 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
9926 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
9927 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 16)
9928 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
9929         const char *name, int mode, MSVCP_bool virt_init)
9930 {
9931     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9932
9933     basic_ifstream_char_ctor(this, virt_init);
9934
9935     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9936         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9937         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9938     }
9939     return this;
9940 }
9941
9942 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9943 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9944 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
9945 void __thiscall basic_ifstream_char_dtor(basic_ios_char *base)
9946 {
9947     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9948
9949     TRACE("(%p)\n", this);
9950
9951     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
9952     basic_filebuf_char_dtor(&this->filebuf);
9953 }
9954
9955 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9956 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9957 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
9958 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
9959 {
9960     TRACE("(%p)\n", this);
9961
9962     basic_ifstream_char_dtor(basic_ifstream_char_to_basic_ios(this));
9963     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
9964 }
9965
9966 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vector_dtor, 8)
9967 basic_ifstream_char* __thiscall basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9968 {
9969     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9970
9971     TRACE("(%p %x)\n", this, flags);
9972
9973     if(flags & 2) {
9974         /* we have an array, with the number of elements stored before the first object */
9975         INT_PTR i, *ptr = (INT_PTR *)this-1;
9976
9977         for(i=*ptr-1; i>=0; i--)
9978             basic_ifstream_char_vbase_dtor(this+i);
9979         MSVCRT_operator_delete(ptr);
9980     } else {
9981         basic_ifstream_char_vbase_dtor(this);
9982         if(flags & 1)
9983             MSVCRT_operator_delete(this);
9984     }
9985
9986     return this;
9987 }
9988
9989 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9990 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9991 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
9992 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
9993 {
9994     TRACE("(%p)\n", this);
9995
9996     if(!basic_filebuf_char_close(&this->filebuf)) {
9997         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9998         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9999     }
10000 }
10001
10002 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10003 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10004 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
10005 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
10006 {
10007     TRACE("(%p)\n", this);
10008     return basic_filebuf_char_is_open(&this->filebuf);
10009 }
10010
10011 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
10012 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
10013 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 12)
10014 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
10015         const char *name, int mode)
10016 {
10017     TRACE("(%p %s %d)\n", this, name, mode);
10018
10019     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
10020         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10021         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10022     }
10023 }
10024
10025 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
10026 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
10027 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
10028 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
10029         const char *name, short mode)
10030 {
10031     basic_ifstream_char_open(this, name, mode);
10032 }
10033
10034 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10035 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10036 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
10037 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
10038 {
10039     TRACE("(%p)\n", this);
10040     return (basic_filebuf_char*)&this->filebuf;
10041 }
10042
10043 static inline basic_ios_wchar* basic_ifstream_wchar_to_basic_ios(basic_ifstream_wchar *ptr)
10044 {
10045     return (basic_ios_wchar*)((char*)ptr+basic_ifstream_wchar_vbtable[1]);
10046 }
10047
10048 static inline basic_ifstream_wchar* basic_ifstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10049 {
10050     return (basic_ifstream_wchar*)((char*)ptr-basic_ifstream_wchar_vbtable[1]);
10051 }
10052
10053 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10054 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10055 static basic_ifstream_wchar* basic_ifstream_wchar_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10056 {
10057     basic_ios_wchar *basic_ios;
10058
10059     TRACE("(%p %d)\n", this, virt_init);
10060
10061     if(virt_init) {
10062         this->base.vbtable = basic_ifstream_wchar_vbtable;
10063         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10064         basic_ios_wchar_ctor(basic_ios);
10065     }else {
10066         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10067     }
10068
10069     basic_filebuf_wchar_ctor(&this->filebuf);
10070     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10071     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10072     return this;
10073 }
10074
10075 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10076 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10077 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor, 8)
10078 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10079 {
10080     basic_ifstream_wchar_ctor(this, virt_init);
10081     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10082     return this;
10083 }
10084
10085 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10086 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10087 static basic_ifstream_wchar* basic_ifstream_wchar_ctor_file(
10088         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10089 {
10090     basic_ios_wchar *basic_ios;
10091
10092     TRACE("(%p %p %d)\n", this, file, virt_init);
10093
10094     if(virt_init) {
10095         this->base.vbtable = basic_ifstream_wchar_vbtable;
10096         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10097         basic_ios_wchar_ctor(basic_ios);
10098     }else {
10099         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10100     }
10101
10102     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10103     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10104     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10105     return this;
10106 }
10107
10108 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10109 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10110 static basic_ifstream_wchar* basic_ifstream_short_ctor_file(
10111         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10112 {
10113     basic_ifstream_wchar_ctor_file(this, file, virt_init);
10114     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10115     return this;
10116 }
10117
10118 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
10119 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
10120 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_copy_ctor, 12)
10121 basic_ifstream_wchar* __thiscall basic_ifstream_short_copy_ctor(basic_ifstream_wchar *this,
10122         basic_ifstream_wchar *copy, MSVCP_bool virt_init)
10123 {
10124     TRACE("(%p %p %d)\n", this, copy, virt_init);
10125     return basic_ifstream_short_ctor_file(this, copy->filebuf.file, virt_init);
10126 }
10127
10128 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBDH@Z */
10129 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDH@Z */
10130 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name, 16)
10131 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name(basic_ifstream_wchar *this,
10132         const char *name, int mode, MSVCP_bool virt_init)
10133 {
10134     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10135
10136     basic_ifstream_short_ctor(this, virt_init);
10137
10138     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
10139         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10140         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10141     }
10142     return this;
10143 }
10144
10145 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10146 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10147 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10148 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10149 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_dtor, 4)
10150 void __thiscall basic_ifstream_wchar_dtor(basic_ios_wchar *base)
10151 {
10152     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10153
10154     TRACE("(%p)\n", this);
10155
10156     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
10157     basic_filebuf_wchar_dtor(&this->filebuf);
10158 }
10159
10160 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10161 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10162 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10163 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10164 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vbase_dtor, 4)
10165 void __thiscall basic_ifstream_wchar_vbase_dtor(basic_ifstream_wchar *this)
10166 {
10167     TRACE("(%p)\n", this);
10168
10169     basic_ifstream_wchar_dtor(basic_ifstream_wchar_to_basic_ios(this));
10170     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
10171 }
10172
10173 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vector_dtor, 8)
10174 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10175 {
10176     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10177
10178     TRACE("(%p %x)\n", this, flags);
10179
10180     if(flags & 2) {
10181         /* we have an array, with the number of elements stored before the first object */
10182         INT_PTR i, *ptr = (INT_PTR *)this-1;
10183
10184         for(i=*ptr-1; i>=0; i--)
10185             basic_ifstream_wchar_vbase_dtor(this+i);
10186         MSVCRT_operator_delete(ptr);
10187     } else {
10188         basic_ifstream_wchar_vbase_dtor(this);
10189         if(flags & 1)
10190             MSVCRT_operator_delete(this);
10191     }
10192
10193     return this;
10194 }
10195
10196 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10197 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10198 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10199 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10200 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_close, 4)
10201 void __thiscall basic_ifstream_wchar_close(basic_ifstream_wchar *this)
10202 {
10203     TRACE("(%p)\n", this);
10204
10205     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10206         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10207         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10208     }
10209 }
10210
10211 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10212 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10213 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10214 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10215 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_is_open, 4)
10216 MSVCP_bool __thiscall basic_ifstream_wchar_is_open(const basic_ifstream_wchar *this)
10217 {
10218     TRACE("(%p)\n", this);
10219     return basic_filebuf_wchar_is_open(&this->filebuf);
10220 }
10221
10222 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
10223 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
10224 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open, 12)
10225 void __thiscall basic_ifstream_wchar_open(basic_ifstream_wchar *this,
10226         const char *name, int mode)
10227 {
10228     TRACE("(%p %s %d)\n", this, name, mode);
10229
10230     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
10231         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10232         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10233     }
10234 }
10235
10236 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
10237 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
10238 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_old, 12)
10239 void __thiscall basic_ifstream_wchar_open_old(basic_ifstream_wchar *this,
10240         const char *name, short mode)
10241 {
10242     basic_ifstream_wchar_open(this, name, mode);
10243 }
10244
10245 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10246 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10247 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10248 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10249 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_rdbuf, 4)
10250 basic_filebuf_wchar* __thiscall basic_ifstream_wchar_rdbuf(const basic_ifstream_wchar *this)
10251 {
10252     TRACE("(%p)\n", this);
10253     return (basic_filebuf_wchar*)&this->filebuf;
10254 }
10255
10256 static inline basic_ios_char* basic_fstream_char_to_basic_ios(basic_fstream_char *ptr)
10257 {
10258     return (basic_ios_char*)((char*)ptr+basic_fstream_char_vbtable1[1]);
10259 }
10260
10261 static inline basic_fstream_char* basic_fstream_char_from_basic_ios(basic_ios_char *ptr)
10262 {
10263     return (basic_fstream_char*)((char*)ptr-basic_fstream_char_vbtable1[1]);
10264 }
10265
10266 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10267 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10268 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
10269 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
10270 {
10271     basic_ios_char *basic_ios;
10272
10273     TRACE("(%p %d)\n", this, virt_init);
10274
10275     if(virt_init) {
10276         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10277         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10278         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10279         basic_ios_char_ctor(basic_ios);
10280     }else {
10281         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10282     }
10283
10284     basic_filebuf_char_ctor(&this->filebuf);
10285     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10286     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10287     return this;
10288 }
10289
10290 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10291 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10292 static basic_fstream_char* basic_fstream_char_ctor_file(basic_fstream_char *this,
10293         FILE *file, MSVCP_bool virt_init)
10294 {
10295     basic_ios_char *basic_ios;
10296
10297     TRACE("(%p %p %d)\n", this, file, virt_init);
10298
10299     if(virt_init) {
10300         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10301         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10302         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10303         basic_ios_char_ctor(basic_ios);
10304     }else {
10305         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10306     }
10307
10308     basic_filebuf_char_ctor_file(&this->filebuf, file);
10309     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10310     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10311     return this;
10312 }
10313
10314 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
10315 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
10316 DEFINE_THISCALL_WRAPPER(basic_fstream_char_copy_ctor, 12)
10317 basic_fstream_char* __thiscall basic_fstream_char_copy_ctor(basic_fstream_char *this,
10318         basic_fstream_char *copy, MSVCP_bool virt_init)
10319 {
10320     TRACE("(%p %p %d)\n", this, copy, virt_init);
10321     return basic_fstream_char_ctor_file(this, copy->filebuf.file, virt_init);
10322 }
10323
10324 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
10325 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
10326 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 16)
10327 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
10328         const char *name, int mode, MSVCP_bool virt_init)
10329 {
10330     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10331
10332     basic_fstream_char_ctor(this, virt_init);
10333
10334     if(!basic_filebuf_char_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10335         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10336         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10337     }
10338     return this;
10339 }
10340
10341 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10342 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10343 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
10344 void __thiscall basic_fstream_char_dtor(basic_ios_char *base)
10345 {
10346     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10347
10348     TRACE("(%p)\n", this);
10349
10350     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
10351     basic_filebuf_char_dtor(&this->filebuf);
10352 }
10353
10354 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10355 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10356 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
10357 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
10358 {
10359     TRACE("(%p)\n", this);
10360
10361     basic_fstream_char_dtor(basic_fstream_char_to_basic_ios(this));
10362     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
10363 }
10364
10365 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vector_dtor, 8)
10366 basic_fstream_char* __thiscall basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10367 {
10368     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10369
10370     TRACE("(%p %x)\n", this, flags);
10371
10372     if(flags & 2) {
10373         /* we have an array, with the number of elements stored before the first object */
10374         INT_PTR i, *ptr = (INT_PTR *)this-1;
10375
10376         for(i=*ptr-1; i>=0; i--)
10377             basic_fstream_char_vbase_dtor(this+i);
10378         MSVCRT_operator_delete(ptr);
10379     } else {
10380         basic_fstream_char_vbase_dtor(this);
10381         if(flags & 1)
10382             MSVCRT_operator_delete(this);
10383     }
10384
10385     return this;
10386 }
10387
10388 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10389 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10390 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
10391 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
10392 {
10393     TRACE("(%p)\n", this);
10394
10395     if(!basic_filebuf_char_close(&this->filebuf)) {
10396         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10397         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10398     }
10399 }
10400
10401 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10402 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10403 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
10404 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
10405 {
10406     TRACE("(%p)\n", this);
10407     return basic_filebuf_char_is_open(&this->filebuf);
10408 }
10409
10410 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
10411 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
10412 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 12)
10413 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
10414         const char *name, int mode)
10415 {
10416     TRACE("(%p %s %d)\n", this, name, mode);
10417
10418     if(!basic_filebuf_char_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10419         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10420         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10421     }
10422 }
10423
10424 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
10425 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
10426 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
10427 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
10428         const char *name, int mode)
10429 {
10430     basic_fstream_char_open(this, name, mode);
10431 }
10432
10433 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10434 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10435 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
10436 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
10437 {
10438     TRACE("(%p)\n", this);
10439     return (basic_filebuf_char*)&this->filebuf;
10440 }
10441
10442 static inline basic_ios_wchar* basic_fstream_wchar_to_basic_ios(basic_fstream_wchar *ptr)
10443 {
10444     return (basic_ios_wchar*)((char*)ptr+basic_fstream_wchar_vbtable1[1]);
10445 }
10446
10447 static inline basic_fstream_wchar* basic_fstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10448 {
10449     return (basic_fstream_wchar*)((char*)ptr-basic_fstream_wchar_vbtable1[1]);
10450 }
10451
10452 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10453 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10454 static basic_fstream_wchar* basic_fstream_wchar_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10455 {
10456     basic_ios_wchar *basic_ios;
10457
10458     TRACE("(%p %d)\n", this, virt_init);
10459
10460     if(virt_init) {
10461         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10462         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10463         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10464         basic_ios_wchar_ctor(basic_ios);
10465     }else {
10466         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10467     }
10468
10469     basic_filebuf_wchar_ctor(&this->filebuf);
10470     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10471     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10472     return this;
10473 }
10474
10475 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10476 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10477 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor, 8)
10478 basic_fstream_wchar* __thiscall basic_fstream_short_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10479 {
10480     basic_fstream_wchar_ctor(this, virt_init);
10481     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
10482     return this;
10483 }
10484
10485 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10486 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10487 static basic_fstream_wchar* basic_fstream_wchar_ctor_file(basic_fstream_wchar *this,
10488         FILE *file, MSVCP_bool virt_init)
10489 {
10490     basic_ios_wchar *basic_ios;
10491
10492     TRACE("(%p %p %d)\n", this, file, virt_init);
10493
10494     if(virt_init) {
10495         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10496         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10497         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10498         basic_ios_wchar_ctor(basic_ios);
10499     }else {
10500         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10501     }
10502
10503     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10504     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10505     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10506     return this;
10507 }
10508
10509 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10510 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10511 static basic_fstream_wchar* basic_fstream_short_ctor_file(basic_fstream_wchar *this,
10512         FILE *file, MSVCP_bool virt_init)
10513 {
10514     basic_fstream_wchar_ctor_file(this, file, virt_init);
10515     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
10516     return this;
10517 }
10518
10519 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
10520 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
10521 DEFINE_THISCALL_WRAPPER(basic_fstream_short_copy_ctor, 12)
10522 basic_fstream_wchar* __thiscall basic_fstream_short_copy_ctor(basic_fstream_wchar *this,
10523         basic_fstream_wchar *copy, MSVCP_bool virt_init)
10524 {
10525     TRACE("(%p %p %d)\n", this, copy, virt_init);
10526     return basic_fstream_short_ctor_file(this, copy->filebuf.file, virt_init);
10527 }
10528
10529 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10530 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10531 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name, 16)
10532 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name(basic_fstream_wchar *this,
10533         const char *name, int mode, MSVCP_bool virt_init)
10534 {
10535     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10536
10537     basic_fstream_short_ctor(this, virt_init);
10538
10539     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10540         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10541         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10542     }
10543     return this;
10544 }
10545
10546 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10547 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10548 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10549 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10550 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_dtor, 4)
10551 void __thiscall basic_fstream_wchar_dtor(basic_ios_wchar *base)
10552 {
10553     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10554
10555     TRACE("(%p)\n", this);
10556
10557     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
10558     basic_filebuf_wchar_dtor(&this->filebuf);
10559 }
10560
10561 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10562 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10563 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10564 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10565 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vbase_dtor, 4)
10566 void __thiscall basic_fstream_wchar_vbase_dtor(basic_fstream_wchar *this)
10567 {
10568     TRACE("(%p)\n", this);
10569
10570     basic_fstream_wchar_dtor(basic_fstream_wchar_to_basic_ios(this));
10571     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
10572 }
10573
10574 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vector_dtor, 8)
10575 basic_fstream_wchar* __thiscall basic_fstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10576 {
10577     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10578
10579     TRACE("(%p %x)\n", this, flags);
10580
10581     if(flags & 2) {
10582         /* we have an array, with the number of elements stored before the first object */
10583         INT_PTR i, *ptr = (INT_PTR *)this-1;
10584
10585         for(i=*ptr-1; i>=0; i--)
10586             basic_fstream_wchar_vbase_dtor(this+i);
10587         MSVCRT_operator_delete(ptr);
10588     } else {
10589         basic_fstream_wchar_vbase_dtor(this);
10590         if(flags & 1)
10591             MSVCRT_operator_delete(this);
10592     }
10593
10594     return this;
10595 }
10596
10597 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10598 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10599 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10600 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10601 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_close, 4)
10602 void __thiscall basic_fstream_wchar_close(basic_fstream_wchar *this)
10603 {
10604     TRACE("(%p)\n", this);
10605
10606     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10607         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10608         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10609     }
10610 }
10611
10612 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10613 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10614 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10615 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10616 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_is_open, 4)
10617 MSVCP_bool __thiscall basic_fstream_wchar_is_open(const basic_fstream_wchar *this)
10618 {
10619     TRACE("(%p)\n", this);
10620     return basic_filebuf_wchar_is_open(&this->filebuf);
10621 }
10622
10623 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
10624 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
10625 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open, 12)
10626 void __thiscall basic_fstream_wchar_open(basic_fstream_wchar *this,
10627         const char *name, int mode)
10628 {
10629     TRACE("(%p %s %d)\n", this, name, mode);
10630
10631     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10632         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10633         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10634     }
10635 }
10636
10637 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
10638 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
10639 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_old, 12)
10640 void __thiscall basic_fstream_wchar_open_old(basic_fstream_wchar *this,
10641         const char *name, int mode)
10642 {
10643     basic_fstream_wchar_open(this, name, mode);
10644 }
10645
10646 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10647 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10648 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10649 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10650 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_rdbuf, 4)
10651 basic_filebuf_wchar* __thiscall basic_fstream_wchar_rdbuf(const basic_fstream_wchar *this)
10652 {
10653     TRACE("(%p)\n", this);
10654     return (basic_filebuf_wchar*)&this->filebuf;
10655 }
10656
10657 static inline basic_ios_char* basic_ostringstream_char_to_basic_ios(basic_ostringstream_char *ptr)
10658 {
10659     return (basic_ios_char*)((char*)ptr+basic_ostringstream_char_vbtable[1]);
10660 }
10661
10662 static inline basic_ostringstream_char* basic_ostringstream_char_from_basic_ios(basic_ios_char *ptr)
10663 {
10664     return (basic_ostringstream_char*)((char*)ptr-basic_ostringstream_char_vbtable[1]);
10665 }
10666
10667 /* ??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 */
10668 /* ??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 */
10669 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_str, 16)
10670 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_str(basic_ostringstream_char *this,
10671         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10672 {
10673     basic_ios_char *basic_ios;
10674
10675     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10676
10677     if(virt_init) {
10678         this->base.vbtable = basic_ostringstream_char_vbtable;
10679         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10680         basic_ios_char_ctor(basic_ios);
10681     }else {
10682         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10683     }
10684
10685     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10686     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10687     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10688     return this;
10689 }
10690
10691 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
10692 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
10693 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_mode, 12)
10694 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_mode(
10695         basic_ostringstream_char *this, int mode, MSVCP_bool virt_init)
10696 {
10697     basic_ios_char *basic_ios;
10698
10699     TRACE("(%p %d %d)\n", this, mode, virt_init);
10700
10701     if(virt_init) {
10702         this->base.vbtable = basic_ostringstream_char_vbtable;
10703         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10704         basic_ios_char_ctor(basic_ios);
10705     }else {
10706         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10707     }
10708
10709     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10710     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10711     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10712     return this;
10713 }
10714
10715 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10716 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10717 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor, 8)
10718 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor(
10719         basic_ostringstream_char *this, MSVCP_bool virt_init)
10720 {
10721     return basic_ostringstream_char_ctor_mode(this, 0, virt_init);
10722 }
10723
10724 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
10725 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
10726 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_dtor, 4)
10727 void __thiscall basic_ostringstream_char_dtor(basic_ios_char *base)
10728 {
10729     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10730
10731     TRACE("(%p)\n", this);
10732
10733     basic_stringbuf_char_dtor(&this->strbuf);
10734     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
10735 }
10736
10737 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10738 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10739 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vbase_dtor, 4)
10740 void __thiscall basic_ostringstream_char_vbase_dtor(basic_ostringstream_char *this)
10741 {
10742     TRACE("(%p)\n", this);
10743
10744     basic_ostringstream_char_dtor(basic_ostringstream_char_to_basic_ios(this));
10745     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
10746 }
10747
10748 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vector_dtor, 8)
10749 basic_ostringstream_char* __thiscall basic_ostringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10750 {
10751     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10752
10753     TRACE("(%p %x)\n", this, flags);
10754
10755     if(flags & 2) {
10756         /* we have an array, with the number of elements stored before the first object */
10757         INT_PTR i, *ptr = (INT_PTR *)this-1;
10758
10759         for(i=*ptr-1; i>=0; i--)
10760             basic_ostringstream_char_vbase_dtor(this+i);
10761         MSVCRT_operator_delete(ptr);
10762     } else {
10763         basic_ostringstream_char_vbase_dtor(this);
10764         if(flags & 1)
10765             MSVCRT_operator_delete(this);
10766     }
10767
10768     return this;
10769 }
10770
10771 /* ?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 */
10772 /* ?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 */
10773 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_rdbuf, 4)
10774 basic_stringbuf_char* __thiscall basic_ostringstream_char_rdbuf(const basic_ostringstream_char *this)
10775 {
10776     TRACE("(%p)\n", this);
10777     return (basic_stringbuf_char*)&this->strbuf;
10778 }
10779
10780 /* ?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 */
10781 /* ?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 */
10782 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_set, 8)
10783 void __thiscall basic_ostringstream_char_str_set(basic_ostringstream_char *this, const basic_string_char *str)
10784 {
10785     TRACE("(%p %p)\n", this, str);
10786     basic_stringbuf_char_str_set(&this->strbuf, str);
10787 }
10788
10789 /* ?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 */
10790 /* ?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 */
10791 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_get, 8)
10792 basic_string_char* __thiscall basic_ostringstream_char_str_get(const basic_ostringstream_char *this, basic_string_char *ret)
10793 {
10794     TRACE("(%p %p)\n", this, ret);
10795     return basic_stringbuf_char_str_get(&this->strbuf, ret);
10796 }
10797
10798 static inline basic_ios_wchar* basic_ostringstream_wchar_to_basic_ios(basic_ostringstream_wchar *ptr)
10799 {
10800     return (basic_ios_wchar*)((char*)ptr+basic_ostringstream_wchar_vbtable[1]);
10801 }
10802
10803 static inline basic_ostringstream_wchar* basic_ostringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10804 {
10805     return (basic_ostringstream_wchar*)((char*)ptr-basic_ostringstream_wchar_vbtable[1]);
10806 }
10807
10808 /* ??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 */
10809 /* ??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 */
10810 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_str(basic_ostringstream_wchar *this,
10811         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10812 {
10813     basic_ios_wchar *basic_ios;
10814
10815     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10816
10817     if(virt_init) {
10818         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10819         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10820         basic_ios_wchar_ctor(basic_ios);
10821     }else {
10822         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10823     }
10824
10825     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10826     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10827     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10828     return this;
10829 }
10830
10831 /* ??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 */
10832 /* ??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 */
10833 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_str, 16)
10834 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_str(basic_ostringstream_wchar *this,
10835         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10836 {
10837     basic_ostringstream_wchar_ctor_str(this, str, mode, virt_init);
10838     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10839     return this;
10840 }
10841
10842 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
10843 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
10844 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_mode(
10845         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10846 {
10847     basic_ios_wchar *basic_ios;
10848
10849     TRACE("(%p %d %d)\n", this, mode, virt_init);
10850
10851     if(virt_init) {
10852         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10853         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10854         basic_ios_wchar_ctor(basic_ios);
10855     }else {
10856         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10857     }
10858
10859     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10860     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10861     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10862     return this;
10863 }
10864
10865 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
10866 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
10867 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_mode, 12)
10868 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_mode(
10869         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10870 {
10871     basic_ostringstream_wchar_ctor_mode(this, mode, virt_init);
10872     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10873     return this;
10874 }
10875
10876 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10877 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10878 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor, 8)
10879 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor(
10880         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
10881 {
10882     return basic_ostringstream_short_ctor_mode(this, 0, virt_init);
10883 }
10884
10885 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
10886 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
10887 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
10888 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
10889 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_dtor, 4)
10890 void __thiscall basic_ostringstream_wchar_dtor(basic_ios_wchar *base)
10891 {
10892     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10893
10894     TRACE("(%p)\n", this);
10895
10896     basic_stringbuf_wchar_dtor(&this->strbuf);
10897     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
10898 }
10899
10900 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
10901 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
10902 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10903 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10904 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vbase_dtor, 4)
10905 void __thiscall basic_ostringstream_wchar_vbase_dtor(basic_ostringstream_wchar *this)
10906 {
10907     TRACE("(%p)\n", this);
10908
10909     basic_ostringstream_wchar_dtor(basic_ostringstream_wchar_to_basic_ios(this));
10910     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
10911 }
10912
10913 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vector_dtor, 8)
10914 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10915 {
10916     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10917
10918     TRACE("(%p %x)\n", this, flags);
10919
10920     if(flags & 2) {
10921         /* we have an array, with the number of elements stored before the first object */
10922         INT_PTR i, *ptr = (INT_PTR *)this-1;
10923
10924         for(i=*ptr-1; i>=0; i--)
10925             basic_ostringstream_wchar_vbase_dtor(this+i);
10926         MSVCRT_operator_delete(ptr);
10927     } else {
10928         basic_ostringstream_wchar_vbase_dtor(this);
10929         if(flags & 1)
10930             MSVCRT_operator_delete(this);
10931     }
10932
10933     return this;
10934 }
10935
10936 /* ?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 */
10937 /* ?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 */
10938 /* ?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 */
10939 /* ?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 */
10940 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_rdbuf, 4)
10941 basic_stringbuf_wchar* __thiscall basic_ostringstream_wchar_rdbuf(const basic_ostringstream_wchar *this)
10942 {
10943     TRACE("(%p)\n", this);
10944     return (basic_stringbuf_wchar*)&this->strbuf;
10945 }
10946
10947 /* ?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 */
10948 /* ?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 */
10949 /* ?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 */
10950 /* ?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 */
10951 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_set, 8)
10952 void __thiscall basic_ostringstream_wchar_str_set(basic_ostringstream_wchar *this, const basic_string_wchar *str)
10953 {
10954     TRACE("(%p %p)\n", this, str);
10955     basic_stringbuf_wchar_str_set(&this->strbuf, str);
10956 }
10957
10958 /* ?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 */
10959 /* ?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 */
10960 /* ?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 */
10961 /* ?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 */
10962 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_get, 8)
10963 basic_string_wchar* __thiscall basic_ostringstream_wchar_str_get(const basic_ostringstream_wchar *this, basic_string_wchar *ret)
10964 {
10965     TRACE("(%p %p)\n", this, ret);
10966     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
10967 }
10968
10969 static inline basic_ios_char* basic_istringstream_char_to_basic_ios(basic_istringstream_char *ptr)
10970 {
10971     return (basic_ios_char*)((char*)ptr+basic_istringstream_char_vbtable[1]);
10972 }
10973
10974 static inline basic_istringstream_char* basic_istringstream_char_from_basic_ios(basic_ios_char *ptr)
10975 {
10976     return (basic_istringstream_char*)((char*)ptr-basic_istringstream_char_vbtable[1]);
10977 }
10978
10979 /* ??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 */
10980 /* ??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 */
10981 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_str, 16)
10982 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_str(basic_istringstream_char *this,
10983         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10984 {
10985     basic_ios_char *basic_ios;
10986
10987     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10988
10989     if(virt_init) {
10990         this->base.vbtable = basic_istringstream_char_vbtable;
10991         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10992         basic_ios_char_ctor(basic_ios);
10993     }else {
10994         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10995     }
10996
10997     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
10998     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10999     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11000     return this;
11001 }
11002
11003 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11004 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11005 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_mode, 12)
11006 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_mode(
11007         basic_istringstream_char *this, int mode, MSVCP_bool virt_init)
11008 {
11009     basic_ios_char *basic_ios;
11010
11011     TRACE("(%p %d %d)\n", this, mode, virt_init);
11012
11013     if(virt_init) {
11014         this->base.vbtable = basic_istringstream_char_vbtable;
11015         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11016         basic_ios_char_ctor(basic_ios);
11017     }else {
11018         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11019     }
11020
11021     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11022     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11023     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11024     return this;
11025 }
11026
11027 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11028 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11029 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor, 8)
11030 basic_istringstream_char* __thiscall basic_istringstream_char_ctor(
11031         basic_istringstream_char *this, MSVCP_bool virt_init)
11032 {
11033     return basic_istringstream_char_ctor_mode(this, 0, virt_init);
11034 }
11035
11036 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11037 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11038 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_dtor, 4)
11039 void __thiscall basic_istringstream_char_dtor(basic_ios_char *base)
11040 {
11041     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11042
11043     TRACE("(%p)\n", this);
11044
11045     basic_stringbuf_char_dtor(&this->strbuf);
11046     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11047 }
11048
11049 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11050 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11051 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vbase_dtor, 4)
11052 void __thiscall basic_istringstream_char_vbase_dtor(basic_istringstream_char *this)
11053 {
11054     TRACE("(%p)\n", this);
11055
11056     basic_istringstream_char_dtor(basic_istringstream_char_to_basic_ios(this));
11057     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
11058 }
11059
11060 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vector_dtor, 8)
11061 basic_istringstream_char* __thiscall basic_istringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11062 {
11063     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11064
11065     TRACE("(%p %x)\n", this, flags);
11066
11067     if(flags & 2) {
11068         /* we have an array, with the number of elements stored before the first object */
11069         INT_PTR i, *ptr = (INT_PTR *)this-1;
11070
11071         for(i=*ptr-1; i>=0; i--)
11072             basic_istringstream_char_vbase_dtor(this+i);
11073         MSVCRT_operator_delete(ptr);
11074     } else {
11075         basic_istringstream_char_vbase_dtor(this);
11076         if(flags & 1)
11077             MSVCRT_operator_delete(this);
11078     }
11079
11080     return this;
11081 }
11082
11083 /* ?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 */
11084 /* ?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 */
11085 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_rdbuf, 4)
11086 basic_stringbuf_char* __thiscall basic_istringstream_char_rdbuf(const basic_istringstream_char *this)
11087 {
11088     TRACE("(%p)\n", this);
11089     return (basic_stringbuf_char*)&this->strbuf;
11090 }
11091
11092 /* ?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 */
11093 /* ?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 */
11094 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_set, 8)
11095 void __thiscall basic_istringstream_char_str_set(basic_istringstream_char *this, const basic_string_char *str)
11096 {
11097     TRACE("(%p %p)\n", this, str);
11098     basic_stringbuf_char_str_set(&this->strbuf, str);
11099 }
11100
11101 /* ?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 */
11102 /* ?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 */
11103 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_get, 8)
11104 basic_string_char* __thiscall basic_istringstream_char_str_get(const basic_istringstream_char *this, basic_string_char *ret)
11105 {
11106     TRACE("(%p %p)\n", this, ret);
11107     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11108 }
11109
11110 static inline basic_ios_wchar* basic_istringstream_wchar_to_basic_ios(basic_istringstream_wchar *ptr)
11111 {
11112     return (basic_ios_wchar*)((char*)ptr+basic_istringstream_wchar_vbtable[1]);
11113 }
11114
11115 static inline basic_istringstream_wchar* basic_istringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11116 {
11117     return (basic_istringstream_wchar*)((char*)ptr-basic_istringstream_wchar_vbtable[1]);
11118 }
11119
11120 /* ??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 */
11121 /* ??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 */
11122 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_str(basic_istringstream_wchar *this,
11123         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11124 {
11125     basic_ios_wchar *basic_ios;
11126
11127     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11128
11129     if(virt_init) {
11130         this->base.vbtable = basic_istringstream_wchar_vbtable;
11131         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11132         basic_ios_wchar_ctor(basic_ios);
11133     }else {
11134         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11135     }
11136
11137     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
11138     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11139     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11140     return this;
11141 }
11142
11143 /* ??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 */
11144 /* ??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 */
11145 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_str, 16)
11146 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_str(basic_istringstream_wchar *this,
11147         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11148 {
11149     basic_istringstream_wchar_ctor_str(this, str, mode, virt_init);
11150     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11151     return this;
11152 }
11153
11154 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11155 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11156 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_mode(
11157         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11158 {
11159     basic_ios_wchar *basic_ios;
11160
11161     TRACE("(%p %d %d)\n", this, mode, virt_init);
11162
11163     if(virt_init) {
11164         this->base.vbtable = basic_istringstream_wchar_vbtable;
11165         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11166         basic_ios_wchar_ctor(basic_ios);
11167     }else {
11168         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11169     }
11170
11171     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11172     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11173     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11174     return this;
11175 }
11176
11177 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11178 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11179 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_mode, 12)
11180 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_mode(
11181         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11182 {
11183     basic_istringstream_wchar_ctor_mode(this, mode, virt_init);
11184     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11185     return this;
11186 }
11187
11188 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11189 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11190 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor, 8)
11191 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor(
11192         basic_istringstream_wchar *this, MSVCP_bool virt_init)
11193 {
11194     return basic_istringstream_short_ctor_mode(this, 0, virt_init);
11195 }
11196
11197 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11198 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11199 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11200 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11201 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_dtor, 4)
11202 void __thiscall basic_istringstream_wchar_dtor(basic_ios_wchar *base)
11203 {
11204     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11205
11206     TRACE("(%p)\n", this);
11207
11208     basic_stringbuf_wchar_dtor(&this->strbuf);
11209     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
11210 }
11211
11212 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11213 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11214 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11215 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11216 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vbase_dtor, 4)
11217 void __thiscall basic_istringstream_wchar_vbase_dtor(basic_istringstream_wchar *this)
11218 {
11219     TRACE("(%p)\n", this);
11220
11221     basic_istringstream_wchar_dtor(basic_istringstream_wchar_to_basic_ios(this));
11222     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
11223 }
11224
11225 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vector_dtor, 8)
11226 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11227 {
11228     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11229
11230     TRACE("(%p %x)\n", this, flags);
11231
11232     if(flags & 2) {
11233         /* we have an array, with the number of elements stored before the first object */
11234         INT_PTR i, *ptr = (INT_PTR *)this-1;
11235
11236         for(i=*ptr-1; i>=0; i--)
11237             basic_istringstream_wchar_vbase_dtor(this+i);
11238         MSVCRT_operator_delete(ptr);
11239     } else {
11240         basic_istringstream_wchar_vbase_dtor(this);
11241         if(flags & 1)
11242             MSVCRT_operator_delete(this);
11243     }
11244
11245     return this;
11246 }
11247
11248 /* ?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 */
11249 /* ?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 */
11250 /* ?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 */
11251 /* ?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 */
11252 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_rdbuf, 4)
11253 basic_stringbuf_wchar* __thiscall basic_istringstream_wchar_rdbuf(const basic_istringstream_wchar *this)
11254 {
11255     TRACE("(%p)\n", this);
11256     return (basic_stringbuf_wchar*)&this->strbuf;
11257 }
11258
11259 /* ?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 */
11260 /* ?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 */
11261 /* ?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 */
11262 /* ?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 */
11263 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_set, 8)
11264 void __thiscall basic_istringstream_wchar_str_set(basic_istringstream_wchar *this, const basic_string_wchar *str)
11265 {
11266     TRACE("(%p %p)\n", this, str);
11267     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11268 }
11269
11270 /* ?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 */
11271 /* ?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 */
11272 /* ?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 */
11273 /* ?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 */
11274 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_get, 8)
11275 basic_string_wchar* __thiscall basic_istringstream_wchar_str_get(const basic_istringstream_wchar *this, basic_string_wchar *ret)
11276 {
11277     TRACE("(%p %p)\n", this, ret);
11278     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11279 }
11280
11281 static inline basic_ios_char* basic_stringstream_char_to_basic_ios(basic_stringstream_char *ptr)
11282 {
11283     return (basic_ios_char*)((char*)ptr+basic_stringstream_char_vbtable1[1]);
11284 }
11285
11286 static inline basic_stringstream_char* basic_stringstream_char_from_basic_ios(basic_ios_char *ptr)
11287 {
11288     return (basic_stringstream_char*)((char*)ptr-basic_stringstream_char_vbtable1[1]);
11289 }
11290
11291 /* ??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 */
11292 /* ??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 */
11293 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_str, 16)
11294 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_str(basic_stringstream_char *this,
11295         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11296 {
11297     basic_ios_char *basic_ios;
11298
11299     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11300
11301     if(virt_init) {
11302         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11303         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11304         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11305         basic_ios_char_ctor(basic_ios);
11306     }else {
11307         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11308     }
11309
11310     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode);
11311     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11312     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11313     return this;
11314 }
11315
11316 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11317 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11318 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_mode, 12)
11319 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_mode(
11320         basic_stringstream_char *this, int mode, MSVCP_bool virt_init)
11321 {
11322     basic_ios_char *basic_ios;
11323
11324     TRACE("(%p %d %d)\n", this, mode, virt_init);
11325
11326     if(virt_init) {
11327         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11328         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11329         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11330         basic_ios_char_ctor(basic_ios);
11331     }else {
11332         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11333     }
11334
11335     basic_stringbuf_char_ctor_mode(&this->strbuf, mode);
11336     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11337     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11338     return this;
11339 }
11340
11341 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11342 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11343 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor, 8)
11344 basic_stringstream_char* __thiscall basic_stringstream_char_ctor(
11345         basic_stringstream_char *this, MSVCP_bool virt_init)
11346 {
11347     return basic_stringstream_char_ctor_mode(
11348             this, OPENMODE_out|OPENMODE_in, virt_init);
11349 }
11350
11351 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11352 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11353 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_dtor, 4)
11354 void __thiscall basic_stringstream_char_dtor(basic_ios_char *base)
11355 {
11356     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11357
11358     TRACE("(%p)\n", this);
11359
11360     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11361     basic_stringbuf_char_dtor(&this->strbuf);
11362 }
11363
11364 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11365 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11366 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vbase_dtor, 4)
11367 void __thiscall basic_stringstream_char_vbase_dtor(basic_stringstream_char *this)
11368 {
11369     TRACE("(%p)\n", this);
11370
11371     basic_stringstream_char_dtor(basic_stringstream_char_to_basic_ios(this));
11372     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11373 }
11374
11375 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vector_dtor, 8)
11376 basic_stringstream_char* __thiscall basic_stringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11377 {
11378     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11379
11380     TRACE("(%p %x)\n", this, flags);
11381
11382     if(flags & 2) {
11383         /* we have an array, with the number of elements stored before the first object */
11384         INT_PTR i, *ptr = (INT_PTR *)this-1;
11385
11386         for(i=*ptr-1; i>=0; i--)
11387             basic_stringstream_char_vbase_dtor(this+i);
11388         MSVCRT_operator_delete(ptr);
11389     } else {
11390         basic_stringstream_char_vbase_dtor(this);
11391         if(flags & 1)
11392             MSVCRT_operator_delete(this);
11393     }
11394
11395     return this;
11396 }
11397
11398 /* ?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 */
11399 /* ?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 */
11400 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_rdbuf, 4)
11401 basic_stringbuf_char* __thiscall basic_stringstream_char_rdbuf(const basic_stringstream_char *this)
11402 {
11403     TRACE("(%p)\n", this);
11404     return (basic_stringbuf_char*)&this->strbuf;
11405 }
11406
11407 /* ?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 */
11408 /* ?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 */
11409 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_set, 8)
11410 void __thiscall basic_stringstream_char_str_set(basic_stringstream_char *this, const basic_string_char *str)
11411 {
11412     TRACE("(%p %p)\n", this, str);
11413     basic_stringbuf_char_str_set(&this->strbuf, str);
11414 }
11415
11416 /* ?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 */
11417 /* ?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 */
11418 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_get, 8)
11419 basic_string_char* __thiscall basic_stringstream_char_str_get(const basic_stringstream_char *this, basic_string_char *ret)
11420 {
11421     TRACE("(%p %p)\n", this, ret);
11422     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11423 }
11424
11425 static inline basic_ios_wchar* basic_stringstream_wchar_to_basic_ios(basic_stringstream_wchar *ptr)
11426 {
11427     return (basic_ios_wchar*)((char*)ptr+basic_stringstream_wchar_vbtable1[1]);
11428 }
11429
11430 static inline basic_stringstream_wchar* basic_stringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11431 {
11432     return (basic_stringstream_wchar*)((char*)ptr-basic_stringstream_wchar_vbtable1[1]);
11433 }
11434
11435 /* ??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 */
11436 /* ??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 */
11437 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_str(basic_stringstream_wchar *this,
11438         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11439 {
11440     basic_ios_wchar *basic_ios;
11441
11442     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11443
11444     if(virt_init) {
11445         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11446         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11447         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11448         basic_ios_wchar_ctor(basic_ios);
11449     }else {
11450         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11451     }
11452
11453     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode);
11454     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11455     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11456     return this;
11457 }
11458
11459 /* ??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 */
11460 /* ??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 */
11461 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_str, 16)
11462 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_str(basic_stringstream_wchar *this,
11463         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11464 {
11465     basic_stringstream_wchar_ctor_str(this, str, mode, virt_init);
11466     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11467     return this;
11468 }
11469
11470 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11471 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11472 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_mode(
11473         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11474 {
11475     basic_ios_wchar *basic_ios;
11476
11477     TRACE("(%p %d %d)\n", this, mode, virt_init);
11478
11479     if(virt_init) {
11480         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11481         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11482         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11483         basic_ios_wchar_ctor(basic_ios);
11484     }else {
11485         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11486     }
11487
11488     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode);
11489     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11490     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11491     return this;
11492 }
11493
11494 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11495 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11496 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_mode, 12)
11497 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_mode(
11498         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11499 {
11500     basic_stringstream_wchar_ctor_mode(this, mode, virt_init);
11501     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11502     return this;
11503 }
11504
11505 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11506 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11507 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor, 8)
11508 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor(
11509         basic_stringstream_wchar *this, MSVCP_bool virt_init)
11510 {
11511     return basic_stringstream_short_ctor_mode(
11512             this, OPENMODE_out|OPENMODE_in, virt_init);
11513 }
11514
11515 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11516 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11517 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11518 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11519 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_dtor, 4)
11520 void __thiscall basic_stringstream_wchar_dtor(basic_ios_wchar *base)
11521 {
11522     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11523
11524     TRACE("(%p)\n", this);
11525
11526     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
11527     basic_stringbuf_wchar_dtor(&this->strbuf);
11528 }
11529
11530 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11531 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11532 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11533 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11534 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vbase_dtor, 4)
11535 void __thiscall basic_stringstream_wchar_vbase_dtor(basic_stringstream_wchar *this)
11536 {
11537     TRACE("(%p)\n", this);
11538
11539     basic_stringstream_wchar_dtor(basic_stringstream_wchar_to_basic_ios(this));
11540     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
11541 }
11542
11543 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vector_dtor, 8)
11544 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11545 {
11546     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11547
11548     TRACE("(%p %x)\n", this, flags);
11549
11550     if(flags & 2) {
11551         /* we have an array, with the number of elements stored before the first object */
11552         INT_PTR i, *ptr = (INT_PTR *)this-1;
11553
11554         for(i=*ptr-1; i>=0; i--)
11555             basic_stringstream_wchar_vbase_dtor(this+i);
11556         MSVCRT_operator_delete(ptr);
11557     } else {
11558         basic_stringstream_wchar_vbase_dtor(this);
11559         if(flags & 1)
11560             MSVCRT_operator_delete(this);
11561     }
11562
11563     return this;
11564 }
11565
11566 /* ?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 */
11567 /* ?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 */
11568 /* ?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 */
11569 /* ?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 */
11570 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_rdbuf, 4)
11571 basic_stringbuf_wchar* __thiscall basic_stringstream_wchar_rdbuf(const basic_stringstream_wchar *this)
11572 {
11573     TRACE("(%p)\n", this);
11574     return (basic_stringbuf_wchar*)&this->strbuf;
11575 }
11576
11577 /* ?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 */
11578 /* ?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 */
11579 /* ?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 */
11580 /* ?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 */
11581 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_set, 8)
11582 void __thiscall basic_stringstream_wchar_str_set(basic_stringstream_wchar *this, const basic_string_wchar *str)
11583 {
11584     TRACE("(%p %p)\n", this, str);
11585     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11586 }
11587
11588 /* ?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 */
11589 /* ?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 */
11590 /* ?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 */
11591 /* ?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 */
11592 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_get, 8)
11593 basic_string_wchar* __thiscall basic_stringstream_wchar_str_get(const basic_stringstream_wchar *this, basic_string_wchar *ret)
11594 {
11595     TRACE("(%p %p)\n", this, ret);
11596     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11597 }
11598
11599 /* ?_Init@strstreambuf@std@@IAEXHPAD0H@Z */
11600 /* ?_Init@strstreambuf@std@@IEAAX_JPEAD1H@Z */
11601 DEFINE_THISCALL_WRAPPER(strstreambuf__Init, 20)
11602 void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g, char *p, int mode)
11603 {
11604     TRACE("(%p %ld %p %p %d)\n", this, len, g, p, mode);
11605
11606     this->minsize = 32;
11607     this->endsave = NULL;
11608     this->strmode = mode;
11609     this->palloc = NULL;
11610     this->pfree = NULL;
11611
11612     if(!g) {
11613         this->strmode |= STRSTATE_Dynamic;
11614         if(len > this->minsize)
11615             this->minsize = len;
11616         this->seekhigh = NULL;
11617         return;
11618     }
11619
11620     if(len < 0)
11621         len = INT_MAX;
11622     else if(!len)
11623         len = strlen(g);
11624
11625     this->seekhigh = g+len;
11626     basic_streambuf_char_setg(&this->base, g, g, p ? p : this->seekhigh);
11627     if(p)
11628         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
11629 }
11630
11631 /* ??0strstreambuf@std@@QAE@PACH0@Z */
11632 /* ??0strstreambuf@std@@QEAA@PEAC_J0@Z */
11633 /* ??0strstreambuf@std@@QAE@PADH0@Z */
11634 /* ??0strstreambuf@std@@QEAA@PEAD_J0@Z */
11635 /* ??0strstreambuf@std@@QAE@PAEH0@Z */
11636 /* ??0strstreambuf@std@@QEAA@PEAE_J0@Z */
11637 static strstreambuf* strstreambuf_ctor_get_put(strstreambuf *this, char *g, streamsize len, char *p)
11638 {
11639     TRACE("(%p %p %ld %p)\n", this, g, len, p);
11640
11641     basic_streambuf_char_ctor(&this->base);
11642     this->base.vtable = &MSVCP_strstreambuf_vtable;
11643
11644     strstreambuf__Init(this, len, g, p, 0);
11645     return this;
11646 }
11647
11648 /* ?_Tidy@strstreambuf@std@@IAEXXZ */
11649 /* ?_Tidy@strstreambuf@std@@IEAAXXZ */
11650 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
11651 void __thiscall strstreambuf__Tidy(strstreambuf *this)
11652 {
11653     TRACE("(%p)\n", this);
11654
11655     if((this->strmode & STRSTATE_Allocated) && !(this->strmode & STRSTATE_Frozen)) {
11656         if(this->pfree)
11657             this->pfree(basic_streambuf_char_eback(&this->base));
11658         else
11659             MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
11660     }
11661
11662     this->endsave = NULL;
11663     this->seekhigh = NULL;
11664     this->strmode &= ~(STRSTATE_Allocated | STRSTATE_Frozen);
11665     basic_streambuf_char_setg(&this->base, NULL, NULL, NULL);
11666     basic_streambuf_char_setp(&this->base, NULL, NULL);
11667 }
11668
11669 /* ??1strstreambuf@std@@UAE@XZ */
11670 /* ??1strstreambuf@std@@UEAA@XZ */
11671 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor, 4)
11672 void __thiscall strstreambuf_dtor(strstreambuf *this)
11673 {
11674     TRACE("(%p)\n", this);
11675
11676     strstreambuf__Tidy(this);
11677     basic_streambuf_char_dtor(&this->base);
11678 }
11679
11680 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor, 8)
11681 strstreambuf* __thiscall strstreambuf_vector_dtor(strstreambuf *this, unsigned int flags)
11682 {
11683     TRACE("(%p %x)\n", this, flags);
11684     if(flags & 2) {
11685         /* we have an array, with the number of elements stored before the first object */
11686         INT_PTR i, *ptr = (INT_PTR *)this-1;
11687
11688         for(i=*ptr-1; i>=0; i--)
11689             strstreambuf_dtor(this+i);
11690         MSVCRT_operator_delete(ptr);
11691     } else {
11692         strstreambuf_dtor(this);
11693         if(flags & 1)
11694             MSVCRT_operator_delete(this);
11695     }
11696
11697     return this;
11698 }
11699
11700 /* ?freeze@strstreambuf@std@@QAEX_N@Z */
11701 /* ?freeze@strstreambuf@std@@QEAAX_N@Z */
11702 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze, 8)
11703 void __thiscall strstreambuf_freeze(strstreambuf *this, MSVCP_bool freeze)
11704 {
11705     TRACE("(%p %d)\n", this, freeze);
11706
11707     if(!freeze == !(this->strmode *STRSTATE_Frozen))
11708         return;
11709
11710     if(freeze) {
11711         this->strmode |= STRSTATE_Frozen;
11712         this->endsave = basic_streambuf_char_epptr(&this->base);
11713         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11714                 basic_streambuf_char_pptr(&this->base), basic_streambuf_char_eback(&this->base));
11715     }else {
11716         this->strmode &= ~STRSTATE_Frozen;
11717         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11718                 basic_streambuf_char_pptr(&this->base), this->endsave);
11719     }
11720 }
11721
11722 /* ?overflow@strstreambuf@std@@MAEHH@Z */
11723 /* ?overflow@strstreambuf@std@@MEAAHH@Z */
11724 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow, 8)
11725 int __thiscall strstreambuf_overflow(strstreambuf *this, int c)
11726 {
11727     MSVCP_size_t old_size, size;
11728     char *ptr, *buf;
11729
11730     TRACE("(%p %d)\n", this, c);
11731
11732     if(c == EOF)
11733         return !EOF;
11734
11735     if(this->strmode & STRSTATE_Frozen)
11736         return EOF;
11737
11738     ptr = basic_streambuf_char_pptr(&this->base);
11739     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
11740         return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11741
11742     if(!(this->strmode & STRSTATE_Dynamic) || (this->strmode & STRSTATE_Constant))
11743         return EOF;
11744
11745     ptr = basic_streambuf_char_eback(&this->base);
11746     old_size = ptr ? basic_streambuf_char_epptr(&this->base) - ptr : 0;
11747
11748     size = old_size + old_size/2;
11749     if(size < this->minsize)
11750         size = this->minsize;
11751
11752     if(this->palloc)
11753         buf = this->palloc(size);
11754     else
11755         buf = MSVCRT_operator_new(size);
11756     if(!buf)
11757         return EOF;
11758
11759     memcpy(buf, ptr, old_size);
11760     if(this->strmode & STRSTATE_Allocated) {
11761         if(this->pfree)
11762             this->pfree(ptr);
11763         else
11764             MSVCRT_operator_delete(ptr);
11765     }
11766
11767     this->strmode |= STRSTATE_Allocated;
11768     if(!old_size) {
11769         this->seekhigh = buf;
11770         basic_streambuf_char_setp(&this->base, buf, buf+size);
11771         basic_streambuf_char_setg(&this->base, buf, buf, buf);
11772     }else {
11773         this->seekhigh = this->seekhigh-ptr+buf;
11774         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base)-ptr+buf,
11775                 basic_streambuf_char_pptr(&this->base)-ptr+buf, buf+size);
11776         basic_streambuf_char_setg(&this->base, buf, basic_streambuf_char_gptr(&this->base)-ptr+buf,
11777                 basic_streambuf_char_pptr(&this->base));
11778     }
11779
11780     return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11781 }
11782
11783 /* ?pbackfail@strstreambuf@std@@MAEHH@Z */
11784 /* ?pbackfail@strstreambuf@std@@MEAAHH@Z */
11785 DEFINE_THISCALL_WRAPPER(strstreambuf_pbackfail, 8)
11786 int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c)
11787 {
11788     char *ptr = basic_streambuf_char_gptr(&this->base);
11789
11790     TRACE("(%p %d)\n", this, c);
11791
11792     if(ptr<=basic_streambuf_char_eback(&this->base)
11793             || ((this->strmode & STRSTATE_Constant) && c!=ptr[-1]))
11794         return EOF;
11795
11796     basic_streambuf_char_gbump(&this->base, -1);
11797     if(c == EOF)
11798         return !EOF;
11799     if(this->strmode & STRSTATE_Constant)
11800         return (unsigned char)c;
11801
11802     return (unsigned char)(ptr[0] = c);
11803 }
11804
11805 /* ?seekoff@strstreambuf@std@@MAE?AV?$fpos@H@2@JHH@Z */
11806 /* ?seekoff@strstreambuf@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
11807 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20)
11808 fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode)
11809 {
11810     char *eback = basic_streambuf_char_eback(&this->base);
11811     char *pptr = basic_streambuf_char_pptr(&this->base);
11812     char *gptr = basic_streambuf_char_gptr(&this->base);
11813
11814     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
11815
11816     ret->off = 0;
11817     ret->state = 0;
11818
11819     if(pptr > this->seekhigh)
11820         this->seekhigh = pptr;
11821
11822     if((mode & OPENMODE_in) && gptr) {
11823         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
11824             off += gptr-eback;
11825         else if(way == SEEKDIR_end)
11826             off += this->seekhigh-eback;
11827         else if(way != SEEKDIR_beg)
11828             off = -1;
11829
11830         if(off<0 || off>this->seekhigh-eback) {
11831             off = -1;
11832         }else {
11833             basic_streambuf_char_gbump(&this->base, eback-gptr+off);
11834             if((mode & OPENMODE_out) && pptr) {
11835                 basic_streambuf_char_setp_next(&this->base, eback,
11836                         gptr, basic_streambuf_char_epptr(&this->base));
11837             }
11838         }
11839     }else if((mode & OPENMODE_out) && pptr) {
11840         if(way == SEEKDIR_cur)
11841             off += pptr-eback;
11842         else if(way == SEEKDIR_end)
11843             off += this->seekhigh-eback;
11844         else if(way != SEEKDIR_beg)
11845             off = -1;
11846
11847          if(off<0 || off>this->seekhigh-eback)
11848              off = -1;
11849          else
11850              basic_streambuf_char_pbump(&this->base, eback-pptr+off);
11851     }else {
11852         off = -1;
11853     }
11854
11855     ret->pos = off;
11856     return ret;
11857 }
11858
11859 /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */
11860 /* ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
11861 DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36)
11862 fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode)
11863 {
11864     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
11865
11866     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
11867         *ret = pos;
11868         return ret;
11869     }
11870
11871     return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
11872 }
11873
11874 /* ?underflow@strstreambuf@std@@MAEHXZ */
11875 /* ?underflow@strstreambuf@std@@MEAAHXZ */
11876 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow, 4)
11877 int __thiscall strstreambuf_underflow(strstreambuf *this)
11878 {
11879     char *gptr = basic_streambuf_char_gptr(&this->base);
11880     char *pptr;
11881
11882     TRACE("(%p)\n", this);
11883
11884     if(!gptr)
11885         return EOF;
11886
11887     if(gptr < basic_streambuf_char_egptr(&this->base))
11888         return (unsigned char)(*gptr);
11889
11890     pptr = basic_streambuf_char_gptr(&this->base);
11891     if(pptr > this->seekhigh)
11892         this->seekhigh = pptr;
11893
11894     if(this->seekhigh <= gptr)
11895         return EOF;
11896
11897     basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base),
11898             gptr, this->seekhigh);
11899     return (unsigned char)(*gptr);
11900 }
11901
11902 static inline basic_ios_char* ostrstream_to_basic_ios(ostrstream *ptr)
11903 {
11904     return (basic_ios_char*)((char*)ptr+ostrstream_vbtable[1]);
11905 }
11906
11907 static inline ostrstream* ostrstream_from_basic_ios(basic_ios_char *ptr)
11908 {
11909     return (ostrstream*)((char*)ptr-ostrstream_vbtable[1]);
11910 }
11911
11912 /* ??0ostrstream@std@@QAE@PADHH@Z */
11913 DEFINE_THISCALL_WRAPPER(ostrstream_ctor, 20)
11914 ostrstream* __thiscall ostrstream_ctor(ostrstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
11915 {
11916     basic_ios_char *basic_ios;
11917
11918     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
11919
11920     if(virt_init) {
11921         this->base.vbtable = ostrstream_vbtable;
11922         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11923         basic_ios_char_ctor(basic_ios);
11924     }else {
11925         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11926     }
11927
11928     strstreambuf_ctor_get_put(&this->buf, buf, size,
11929             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
11930     basic_ostream_char_ctor(&this->base, &this->buf.base, FALSE, FALSE);
11931     basic_ios->base.vtable = &MSVCP_ostrstream_vtable;
11932     return this;
11933 }
11934
11935 /* ??1ostrstream@std@@UAE@XZ */
11936 /* ??1ostrstream@std@@UEAA@XZ */
11937 DEFINE_THISCALL_WRAPPER(ostrstream_dtor, 4)
11938 void __thiscall ostrstream_dtor(basic_ios_char *base)
11939 {
11940     ostrstream *this = ostrstream_from_basic_ios(base);
11941
11942     TRACE("(%p)\n", this);
11943
11944     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
11945     strstreambuf_dtor(&this->buf);
11946 }
11947
11948 static void ostrstream_vbase_dtor(ostrstream *this)
11949 {
11950     TRACE("(%p)\n", this);
11951
11952     ostrstream_dtor(ostrstream_to_basic_ios(this));
11953     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
11954 }
11955
11956 DEFINE_THISCALL_WRAPPER(ostrstream_vector_dtor, 8)
11957 ostrstream* __thiscall ostrstream_vector_dtor(basic_ios_char *base, unsigned int flags)
11958 {
11959     ostrstream *this = ostrstream_from_basic_ios(base);
11960
11961     TRACE("(%p %x)\n", this, flags);
11962
11963     if(flags & 2) {
11964         /* we have an array, with the number of elements stored before the first object */
11965         INT_PTR i, *ptr = (INT_PTR *)this-1;
11966
11967         for(i=*ptr-1; i>=0; i--)
11968             ostrstream_vbase_dtor(this+i);
11969         MSVCRT_operator_delete(ptr);
11970     } else {
11971         ostrstream_vbase_dtor(this);
11972         if(flags & 1)
11973             MSVCRT_operator_delete(this);
11974     }
11975
11976     return this;
11977 }
11978
11979 static inline istrstream* istrstream_from_basic_ios(basic_ios_char *ptr)
11980 {
11981     return (istrstream*)((char*)ptr-istrstream_vbtable[1]);
11982 }
11983
11984 /* ??1istrstream@std@@UAE@XZ */
11985 /* ??1istrstream@std@@UEAA@XZ */
11986 DEFINE_THISCALL_WRAPPER(istrstream_dtor, 4)
11987 void __thiscall istrstream_dtor(basic_ios_char *base)
11988 {
11989     istrstream *this = istrstream_from_basic_ios(base);
11990
11991     TRACE("(%p)\n", this);
11992
11993     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11994     strstreambuf_dtor(&this->buf);
11995 }
11996
11997 static inline basic_ios_char* strstream_to_basic_ios(strstream *ptr)
11998 {
11999     return (basic_ios_char*)((char*)ptr+strstream_vbtable1[1]);
12000 }
12001
12002 static inline strstream* strstream_from_basic_ios(basic_ios_char *ptr)
12003 {
12004     return (strstream*)((char*)ptr-strstream_vbtable1[1]);
12005 }
12006
12007 /* ??0strstream@std@@QAE@PADHH@Z */
12008 /* ??0strstream@std@@QEAA@PEAD_JH@Z */
12009 DEFINE_THISCALL_WRAPPER(strstream_ctor, 20)
12010 strstream* __thiscall strstream_ctor(strstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
12011 {
12012     basic_ios_char *basic_ios;
12013
12014     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
12015
12016     if(virt_init) {
12017         this->base.base1.vbtable = strstream_vbtable1;
12018         this->base.base2.vbtable = strstream_vbtable2;
12019         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12020         basic_ios_char_ctor(basic_ios);
12021     }else {
12022         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12023     }
12024
12025     strstreambuf_ctor_get_put(&this->buf, buf, size,
12026             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
12027     basic_iostream_char_ctor(&this->base, &this->buf.base, FALSE);
12028     basic_ios->base.vtable = &MSVCP_strstream_vtable;
12029     return this;
12030 }
12031
12032 /* ??1strstream@std@@UAE@XZ */
12033 /* ??1strstream@std@@UEAA@XZ */
12034 DEFINE_THISCALL_WRAPPER(strstream_dtor, 4)
12035 void __thiscall strstream_dtor(basic_ios_char *base)
12036 {
12037     strstream *this = strstream_from_basic_ios(base);
12038
12039     TRACE("(%p)\n", this);
12040
12041     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
12042     strstreambuf_dtor(&this->buf);
12043 }
12044
12045 static void strstream_vbase_dtor(strstream *this)
12046 {
12047     TRACE("(%p)\n", this);
12048
12049     strstream_dtor(strstream_to_basic_ios(this));
12050     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
12051 }
12052
12053 DEFINE_THISCALL_WRAPPER(strstream_vector_dtor, 8)
12054 strstream* __thiscall strstream_vector_dtor(basic_ios_char *base, unsigned int flags)
12055 {
12056     strstream *this = strstream_from_basic_ios(base);
12057
12058     TRACE("(%p %x)\n", this, flags);
12059
12060     if(flags & 2) {
12061         /* we have an array, with the number of elements stored before the first object */
12062         INT_PTR i, *ptr = (INT_PTR *)this-1;
12063
12064         for(i=*ptr-1; i>=0; i--)
12065             strstream_vbase_dtor(this+i);
12066         MSVCRT_operator_delete(ptr);
12067     } else {
12068         strstream_vbase_dtor(this);
12069         if(flags & 1)
12070             MSVCRT_operator_delete(this);
12071     }
12072
12073     return this;
12074 }
12075
12076 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
12077 {
12078     ios_base_precision_set(base, prec);
12079 }
12080
12081 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
12082 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12083 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
12084 {
12085     TRACE("(%p %ld)\n", ret, prec);
12086
12087     ret->pfunc = setprecision_func;
12088     ret->arg = prec;
12089     return ret;
12090 }
12091
12092 static void __cdecl setw_func(ios_base *base, streamsize width)
12093 {
12094     ios_base_width_set(base, width);
12095 }
12096
12097 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
12098 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12099 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
12100 {
12101     TRACE("(%p %ld)\n", ret, width);
12102
12103     ret->pfunc = setw_func;
12104     ret->arg = width;
12105     return ret;
12106 }
12107
12108 static void __cdecl resetioflags_func(ios_base *base, int mask)
12109 {
12110     ios_base_setf_mask(base, 0, mask);
12111 }
12112
12113 /* ?resetiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12114 manip_int* __cdecl resetiosflags(manip_int *ret, int mask)
12115 {
12116     TRACE("(%p %d)\n", ret, mask);
12117
12118     ret->pfunc = resetioflags_func;
12119     ret->arg = mask;
12120     return ret;
12121 }
12122
12123 static void __cdecl setiosflags_func(ios_base *base, int mask)
12124 {
12125     ios_base_setf_mask(base, FMTFLAG_mask, mask);
12126 }
12127
12128 /* ?setiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12129 manip_int* __cdecl setiosflags(manip_int *ret, int mask)
12130 {
12131     TRACE("(%p %d)\n", ret, mask);
12132
12133     ret->pfunc = setiosflags_func;
12134     ret->arg = mask;
12135     return ret;
12136 }
12137
12138 static void __cdecl setbase_func(ios_base *base, int set_base)
12139 {
12140     if(set_base == 10)
12141         set_base = FMTFLAG_dec;
12142     else if(set_base == 8)
12143         set_base = FMTFLAG_oct;
12144     else if(set_base == 16)
12145         set_base = FMTFLAG_hex;
12146     else
12147         set_base = 0;
12148
12149     ios_base_setf_mask(base, set_base, FMTFLAG_basefield);
12150 }
12151
12152 /* ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z */
12153 manip_int* __cdecl setbase(manip_int *ret, int base)
12154 {
12155     TRACE("(%p %d)\n", ret, base);
12156
12157     ret->pfunc = setbase_func;
12158     ret->arg = base;
12159     return ret;
12160 }
12161
12162 static basic_filebuf_char filebuf_char_stdin;
12163 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
12164 struct {
12165     basic_istream_char obj;
12166     basic_ios_char vbase;
12167 } cin = { { 0 } };
12168 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
12169 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
12170 basic_istream_char *_Ptr_cin = &cin.obj;
12171
12172 static basic_filebuf_wchar filebuf_short_stdin;
12173 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
12174 struct {
12175     basic_istream_wchar obj;
12176     basic_ios_wchar vbase;
12177 } ucin = { { 0 } };
12178 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
12179 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
12180 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
12181
12182 static basic_filebuf_wchar filebuf_wchar_stdin;
12183 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12184 struct {
12185     basic_istream_wchar obj;
12186     basic_ios_wchar vbase;
12187 } wcin = { { 0 } };
12188 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12189 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
12190 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
12191
12192 static basic_filebuf_char filebuf_char_stdout;
12193 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12194 struct {
12195     basic_ostream_char obj;
12196     basic_ios_char vbase;
12197 } cout = { { 0 } };
12198 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12199 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12200 basic_ostream_char *_Ptr_cout = &cout.obj;
12201
12202 static basic_filebuf_wchar filebuf_short_stdout;
12203 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12204 struct {
12205     basic_ostream_wchar obj;
12206     basic_ios_wchar vbase;
12207 } ucout = { { 0 } };
12208 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12209 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12210 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
12211
12212 static basic_filebuf_wchar filebuf_wchar_stdout;
12213 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12214 struct {
12215     basic_ostream_wchar obj;
12216     basic_ios_wchar vbase;
12217 } wcout = { { 0 } };
12218 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12219 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12220 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
12221
12222 static basic_filebuf_char filebuf_char_stderr;
12223 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12224 struct {
12225     basic_ostream_char obj;
12226     basic_ios_char vbase;
12227 } cerr = { { 0 } };
12228 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12229 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12230 basic_ostream_char *_Ptr_cerr = &cerr.obj;
12231
12232 static basic_filebuf_wchar filebuf_short_stderr;
12233 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12234 struct {
12235     basic_ostream_wchar obj;
12236     basic_ios_wchar vbase;
12237 } ucerr = { { 0 } };
12238 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12239 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12240 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
12241
12242 static basic_filebuf_wchar filebuf_wchar_stderr;
12243 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12244 struct {
12245     basic_ostream_wchar obj;
12246     basic_ios_wchar vbase;
12247 } wcerr = { { 0 } };
12248 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12249 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12250 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
12251
12252 static basic_filebuf_char filebuf_char_log;
12253 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12254 struct {
12255     basic_ostream_char obj;
12256     basic_ios_char vbase;
12257 } clog = { { 0 } };
12258 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12259 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12260 basic_ostream_char *_Ptr_clog = &clog.obj;
12261
12262 static basic_filebuf_wchar filebuf_short_log;
12263 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12264 struct {
12265     basic_ostream_wchar obj;
12266     basic_ios_wchar vbase;
12267 } uclog = { { 0 } };
12268 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12269 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12270 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
12271
12272 static basic_filebuf_wchar filebuf_wchar_log;
12273 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12274 struct {
12275     basic_ostream_wchar obj;
12276     basic_ios_wchar vbase;
12277 } wclog = { { 0 } };
12278 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12279 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12280 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
12281
12282 /* ?_Init_cnt@Init@ios_base@std@@0HA */
12283 int ios_base_Init__Init_cnt = -1;
12284
12285 /* ?_Init_ctor@Init@ios_base@std@@CAXPAV123@@Z */
12286 /* ?_Init_ctor@Init@ios_base@std@@CAXPEAV123@@Z */
12287 static void ios_base_Init__Init_ctor(void *this)
12288 {
12289     TRACE("(%p)\n", this);
12290
12291     if(ios_base_Init__Init_cnt < 0)
12292         ios_base_Init__Init_cnt = 1;
12293     else
12294         ios_base_Init__Init_cnt++;
12295 }
12296
12297 /* ??0Init@ios_base@std@@QAE@XZ */
12298 /* ??0Init@ios_base@std@@QEAA@XZ */
12299 DEFINE_THISCALL_WRAPPER(ios_base_Init_ctor, 4)
12300 void* __thiscall ios_base_Init_ctor(void *this)
12301 {
12302     ios_base_Init__Init_ctor(this);
12303     return this;
12304 }
12305
12306 /* ?_Init_dtor@Init@ios_base@std@@CAXPAV123@@Z */
12307 /* ?_Init_dtor@Init@ios_base@std@@CAXPEAV123@@Z */
12308 static void ios_base_Init__Init_dtor(void *this)
12309 {
12310     TRACE("(%p)\n", this);
12311
12312     ios_base_Init__Init_cnt--;
12313     if(!ios_base_Init__Init_cnt) {
12314         basic_ostream_char_flush(&cout.obj);
12315         basic_ostream_char_flush(&cerr.obj);
12316         basic_ostream_char_flush(&clog.obj);
12317     }
12318 }
12319
12320 /* ??1Init@ios_base@std@@QAE@XZ */
12321 /* ??1Init@ios_base@std@@QEAA@XZ */
12322 DEFINE_THISCALL_WRAPPER(ios_base_Init_dtor, 4)
12323 void __thiscall ios_base_Init_dtor(void *this)
12324 {
12325     ios_base_Init__Init_dtor(this);
12326 }
12327
12328 /* ??4Init@ios_base@std@@QAEAAV012@ABV012@@Z */
12329 /* ??4Init@ios_base@std@@QEAAAEAV012@AEBV012@@Z */
12330 DEFINE_THISCALL_WRAPPER(ios_base_Init_op_assign, 8)
12331 void* __thiscall ios_base_Init_op_assign(void *this, void *rhs)
12332 {
12333     TRACE("(%p %p)\n", this, rhs);
12334     return this;
12335 }
12336
12337 /* ?_Init_cnt@_Winit@std@@0HA */
12338 int _Winit__Init_cnt = -1;
12339
12340 /* ??0_Winit@std@@QAE@XZ */
12341 /* ??0_Winit@std@@QEAA@XZ */
12342 DEFINE_THISCALL_WRAPPER(_Winit_ctor, 4)
12343 void* __thiscall _Winit_ctor(void *this)
12344 {
12345     TRACE("(%p)\n", this);
12346
12347     if(_Winit__Init_cnt < 0)
12348         _Winit__Init_cnt = 1;
12349     else
12350         _Winit__Init_cnt++;
12351
12352     return this;
12353 }
12354
12355 /* ??1_Winit@std@@QAE@XZ */
12356 /* ??1_Winit@std@@QAE@XZ */
12357 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)
12358 void __thiscall _Winit_dtor(void *this)
12359 {
12360     TRACE("(%p)\n", this);
12361
12362     _Winit__Init_cnt--;
12363     if(!_Winit__Init_cnt) {
12364         basic_ostream_wchar_flush(&wcout.obj);
12365         basic_ostream_wchar_flush(&wcerr.obj);
12366         basic_ostream_wchar_flush(&wclog.obj);
12367     }
12368 }
12369
12370 /* ??4_Winit@std@@QAEAAV01@ABV01@@Z */
12371 /* ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z */
12372 DEFINE_THISCALL_WRAPPER(_Winit_op_assign, 8)
12373 void* __thiscall _Winit_op_assign(void *this, void *rhs)
12374 {
12375     TRACE("(%p %p)\n", this, rhs);
12376     return this;
12377 }
12378
12379 void init_io(void *base)
12380 {
12381 #ifdef __x86_64__
12382     init_iosb_rtti(base);
12383     init_ios_base_rtti(base);
12384     init_basic_ios_char_rtti(base);
12385     init_basic_ios_wchar_rtti(base);
12386     init_basic_ios_short_rtti(base);
12387     init_basic_streambuf_char_rtti(base);
12388     init_basic_streambuf_wchar_rtti(base);
12389     init_basic_streambuf_short_rtti(base);
12390     init_basic_filebuf_char_rtti(base);
12391     init_basic_filebuf_wchar_rtti(base);
12392     init_basic_filebuf_short_rtti(base);
12393     init_basic_stringbuf_char_rtti(base);
12394     init_basic_stringbuf_wchar_rtti(base);
12395     init_basic_stringbuf_short_rtti(base);
12396     init_basic_ostream_char_rtti(base);
12397     init_basic_ostream_wchar_rtti(base);
12398     init_basic_ostream_short_rtti(base);
12399     init_basic_istream_char_rtti(base);
12400     init_basic_istream_wchar_rtti(base);
12401     init_basic_istream_short_rtti(base);
12402     init_basic_iostream_char_rtti(base);
12403     init_basic_iostream_wchar_rtti(base);
12404     init_basic_iostream_short_rtti(base);
12405     init_basic_ofstream_char_rtti(base);
12406     init_basic_ofstream_wchar_rtti(base);
12407     init_basic_ofstream_short_rtti(base);
12408     init_basic_ifstream_char_rtti(base);
12409     init_basic_ifstream_wchar_rtti(base);
12410     init_basic_ifstream_short_rtti(base);
12411     init_basic_fstream_char_rtti(base);
12412     init_basic_fstream_wchar_rtti(base);
12413     init_basic_fstream_short_rtti(base);
12414     init_basic_ostringstream_char_rtti(base);
12415     init_basic_ostringstream_wchar_rtti(base);
12416     init_basic_ostringstream_short_rtti(base);
12417     init_basic_istringstream_char_rtti(base);
12418     init_basic_istringstream_wchar_rtti(base);
12419     init_basic_istringstream_short_rtti(base);
12420     init_basic_stringstream_char_rtti(base);
12421     init_basic_stringstream_wchar_rtti(base);
12422     init_basic_stringstream_short_rtti(base);
12423     init_strstreambuf_rtti(base);
12424     init_strstream_rtti(base);
12425     init_ostrstream_rtti(base);
12426 #endif
12427
12428     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
12429     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
12430
12431     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
12432     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
12433
12434     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
12435     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
12436
12437     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
12438     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE);
12439
12440     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
12441     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE);
12442
12443     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
12444     basic_ostream_wchar_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE);
12445
12446     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
12447     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE);
12448
12449     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
12450     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE);
12451
12452     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
12453     basic_ostream_wchar_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE);
12454
12455     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
12456     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE);
12457
12458     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
12459     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE);
12460
12461     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
12462     basic_ostream_wchar_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE);
12463 }
12464
12465 void free_io(void)
12466 {
12467     basic_istream_char_vbase_dtor(&cin.obj);
12468     basic_filebuf_char_dtor(&filebuf_char_stdin);
12469
12470     basic_istream_wchar_vbase_dtor(&ucin.obj);
12471     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
12472
12473     basic_istream_wchar_vbase_dtor(&wcin.obj);
12474     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
12475
12476     basic_ostream_char_vbase_dtor(&cout.obj);
12477     basic_filebuf_char_dtor(&filebuf_char_stdout);
12478
12479     basic_ostream_wchar_vbase_dtor(&ucout.obj);
12480     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
12481
12482     basic_ostream_wchar_vbase_dtor(&wcout.obj);
12483     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
12484
12485     basic_ostream_char_vbase_dtor(&cerr.obj);
12486     basic_filebuf_char_dtor(&filebuf_char_stderr);
12487
12488     basic_ostream_wchar_vbase_dtor(&ucerr.obj);
12489     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
12490
12491     basic_ostream_wchar_vbase_dtor(&wcerr.obj);
12492     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
12493
12494     basic_ostream_char_vbase_dtor(&clog.obj);
12495     basic_filebuf_char_dtor(&filebuf_char_log);
12496
12497     basic_ostream_wchar_vbase_dtor(&uclog.obj);
12498     basic_filebuf_wchar_dtor(&filebuf_short_log);
12499
12500     basic_ostream_wchar_vbase_dtor(&wclog.obj);
12501     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
12502 }