msvcp60: Added basic_fstream::open implementation.
[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 *seekhigh;
95     int state;
96     char allocator; /* empty struct */
97 } basic_stringbuf_char;
98
99 typedef struct {
100     basic_streambuf_wchar base;
101     wchar_t *seekhigh;
102     int state;
103     char allocator; /* empty struct */
104 } basic_stringbuf_wchar;
105
106 typedef struct {
107     ios_base base;
108     basic_streambuf_char *strbuf;
109     struct _basic_ostream_char *stream;
110     char fillch;
111 } basic_ios_char;
112
113 typedef struct {
114     ios_base base;
115     basic_streambuf_wchar *strbuf;
116     struct _basic_ostream_wchar *stream;
117     wchar_t fillch;
118 } basic_ios_wchar;
119
120 typedef struct _basic_ostream_char {
121     const int *vbtable;
122     /* virtual inheritance
123      * basic_ios_char basic_ios;
124      */
125 } basic_ostream_char;
126
127 typedef struct _basic_ostream_wchar {
128     const int *vbtable;
129     /* virtual inheritance
130      * basic_ios_wchar basic_ios;
131      */
132 } basic_ostream_wchar;
133
134 typedef struct {
135     const int *vbtable;
136     streamsize count;
137     /* virtual inheritance
138      * basic_ios_char basic_ios;
139      */
140 } basic_istream_char;
141
142 typedef struct {
143     const int *vbtable;
144     streamsize count;
145     /* virtual inheritance
146      * basic_ios_wchar basic_ios;
147      */
148 } basic_istream_wchar;
149
150 typedef struct {
151     basic_istream_char base1;
152     basic_ostream_char base2;
153     /* virtual inheritance
154      * basic_ios_char basic_ios;
155      */
156 } basic_iostream_char;
157
158 typedef struct {
159     basic_istream_wchar base1;
160     basic_ostream_wchar base2;
161     /* virtual inheritance
162      * basic_ios_wchar basic_ios;
163      */
164 } basic_iostream_wchar;
165
166 typedef struct {
167     basic_ostream_char base;
168     basic_filebuf_char filebuf;
169     /* virtual inheritance
170      * basic_ios_char basic_ios;
171      */
172 } basic_ofstream_char;
173
174 typedef struct {
175     basic_ostream_wchar base;
176     basic_filebuf_wchar filebuf;
177     /* virtual inheritance
178      * basic_ios_wchar basic_ios;
179      */
180 } basic_ofstream_wchar;
181
182 typedef struct {
183     basic_istream_char base;
184     basic_filebuf_char filebuf;
185     /* virtual inheritance
186      * basic_ios_char basic_ios;
187      */
188 } basic_ifstream_char;
189
190 typedef struct {
191     basic_istream_wchar base;
192     basic_filebuf_wchar filebuf;
193     /* virtual inheritance
194      * basic_ios_wchar basic_ios;
195      */
196 } basic_ifstream_wchar;
197
198 typedef struct {
199     basic_iostream_char base;
200     basic_filebuf_char filebuf;
201     /* virtual inheritance
202      * basic_ios_char basic_ios;
203      */
204 } basic_fstream_char;
205
206 typedef struct {
207     basic_iostream_wchar base;
208     basic_filebuf_wchar filebuf;
209     /* virtual inheritance
210      * basic_ios_char basic_ios;
211      */
212 } basic_fstream_wchar;
213
214 typedef struct {
215     basic_ostream_char base;
216     basic_stringbuf_char strbuf;
217     /* virtual inheritance
218      * basic_ios_char basic_ios;
219      */
220 } basic_ostringstream_char;
221
222 typedef struct {
223     basic_ostream_wchar base;
224     basic_stringbuf_wchar strbuf;
225     /* virtual inheritance
226      * basic_ios_wchar basic_ios;
227      */
228 } basic_ostringstream_wchar;
229
230 typedef struct {
231     basic_istream_char base;
232     basic_stringbuf_char strbuf;
233     /* virtual inheritance
234      * basic_ios_char basic_ios;
235      */
236 } basic_istringstream_char;
237
238 typedef struct {
239     basic_istream_wchar base;
240     basic_stringbuf_wchar strbuf;
241     /* virtual inheritance
242      * basic_ios_wchar basic_ios;
243      */
244 } basic_istringstream_wchar;
245
246 typedef struct {
247     basic_iostream_char base;
248     basic_stringbuf_char strbuf;
249     /* virtual inheritance
250      * basic_ios_char basic_ios;
251      */
252 } basic_stringstream_char;
253
254 typedef struct {
255     basic_iostream_wchar base;
256     basic_stringbuf_wchar strbuf;
257     /* virtual inheritance
258      * basic_ios_wchar basic_ios;
259      */
260 } basic_stringstream_wchar;
261
262 typedef enum {
263     STRSTATE_Allocated = 1,
264     STRSTATE_Constant = 2,
265     STRSTATE_Dynamic = 4,
266     STRSTATE_Frozen = 8
267 } strstreambuf__Strstate;
268
269 typedef struct {
270     basic_streambuf_char base;
271     streamsize minsize;
272     char *endsave;
273     char *seekhigh;
274     int strmode;
275     void* (__cdecl *palloc)(MSVCP_size_t);
276     void (__cdecl *pfree)(void*);
277 } strstreambuf;
278
279 extern const vtable_ptr MSVCP_iosb_vtable;
280
281 /* ??_7ios_base@std@@6B@ */
282 extern const vtable_ptr MSVCP_ios_base_vtable;
283
284 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
285 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
286
287 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
288 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
289
290 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
291 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
292
293 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
294 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
295
296 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
297 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
298
299 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
300 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
301
302 /* ??_7?$basic_filebuf@DU?$char_traits@D@std@@@std@@6B@ */
303 extern const vtable_ptr MSVCP_basic_filebuf_char_vtable;
304
305 /* ??_7?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@6B@ */
306 extern const vtable_ptr MSVCP_basic_filebuf_wchar_vtable;
307
308 /* ??_7?$basic_filebuf@GU?$char_traits@G@std@@@std@@6B@ */
309 extern const vtable_ptr MSVCP_basic_filebuf_short_vtable;
310
311 /* ??_7?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
312 extern const vtable_ptr MSVCP_basic_stringbuf_char_vtable;
313
314 /* ??_7?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
315 extern const vtable_ptr MSVCP_basic_stringbuf_wchar_vtable;
316
317 /* ??_7?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
318 extern const vtable_ptr MSVCP_basic_stringbuf_short_vtable;
319
320 /* ??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@ */
321 const int basic_ostream_char_vbtable[] = {0, sizeof(basic_ostream_char)};
322 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
323 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
324
325 /* ??_8?$basic_ostream@_WU?$char_traits@_W@std@@@std@@7B@ */
326 const int basic_ostream_wchar_vbtable[] = {0, sizeof(basic_ostream_wchar)};
327 /* ??_7?$basic_ostream@_WU?$char_traits@_W@std@@@std@@6B@ */
328 extern const vtable_ptr MSVCP_basic_ostream_wchar_vtable;
329
330 /* ??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@ */
331 const int basic_ostream_short_vbtable[] = {0, sizeof(basic_ostream_wchar)};
332 /* ??_7?$basic_ostream@GU?$char_traits@G@std@@@std@@6B@ */
333 extern const vtable_ptr MSVCP_basic_ostream_short_vtable;
334
335 /* ??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@ */
336 const int basic_istream_char_vbtable[] = {0, sizeof(basic_istream_char)};
337 /* ??_7?$basic_istream@DU?$char_traits@D@std@@@std@@6B@ */
338 extern const vtable_ptr MSVCP_basic_istream_char_vtable;
339
340 /* ??_8?$basic_istream@_WU?$char_traits@_W@std@@@std@@7B@ */
341 const int basic_istream_wchar_vbtable[] = {0, sizeof(basic_istream_wchar)};
342 /* ??_7?$basic_istream@_WU?$char_traits@_W@std@@@std@@6B@ */
343 extern const vtable_ptr MSVCP_basic_istream_wchar_vtable;
344
345 /* ??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@ */
346 const int basic_istream_short_vbtable[] = {0, sizeof(basic_istream_wchar)};
347 /* ??_7?$basic_istream@GU?$char_traits@G@std@@@std@@6B@ */
348 extern const vtable_ptr MSVCP_basic_istream_short_vtable;
349
350 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
351 const int basic_iostream_char_vbtable1[] = {0, sizeof(basic_iostream_char)};
352 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
353 const int basic_iostream_char_vbtable2[] = {0, sizeof(basic_iostream_char)-FIELD_OFFSET(basic_iostream_char, base2)};
354 /* ??_7?$basic_iostream@DU?$char_traits@D@std@@@std@@6B@ */
355 extern const vtable_ptr MSVCP_basic_iostream_char_vtable;
356
357 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
358 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
359 const int basic_iostream_wchar_vbtable1[] = {0, sizeof(basic_iostream_wchar)};
360 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
361 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
362 const int basic_iostream_wchar_vbtable2[] = {0, sizeof(basic_iostream_wchar)-FIELD_OFFSET(basic_iostream_wchar, base2)};
363 /* ??_7?$basic_iostream@_WU?$char_traits@_W@std@@@std@@6B@ */
364 extern const vtable_ptr MSVCP_basic_iostream_wchar_vtable;
365 /* ??_7?$basic_iostream@GU?$char_traits@G@std@@@std@@6B@ */
366 extern const vtable_ptr MSVCP_basic_iostream_short_vtable;
367
368 /* ??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@ */
369 const int basic_ofstream_char_vbtable[] = {0, sizeof(basic_ofstream_char)};
370 /* ??_7?$basic_ofstream@DU?$char_traits@D@std@@@std@@6B@ */
371 extern const vtable_ptr MSVCP_basic_ofstream_char_vtable;
372
373 /* ??_8?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@7B@ */
374 const int basic_ofstream_wchar_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
375 /* ??_7?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@6B@ */
376 extern const vtable_ptr MSVCP_basic_ofstream_wchar_vtable;
377
378 /* ??_8?$basic_ofstream@GU?$char_traits@G@std@@@std@@7B@ */
379 const int basic_ofstream_short_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
380 /* ??_7?$basic_ofstream@GU?$char_traits@G@std@@@std@@6B@ */
381 extern const vtable_ptr MSVCP_basic_ofstream_short_vtable;
382
383 /* ??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@ */
384 const int basic_ifstream_char_vbtable[] = {0, sizeof(basic_ifstream_char)};
385 /* ??_7?$basic_ifstream@DU?$char_traits@D@std@@@std@@6B@ */
386 extern const vtable_ptr MSVCP_basic_ifstream_char_vtable;
387
388 /* ??_8?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@7B@ */
389 const int basic_ifstream_wchar_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
390 /* ??_7?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@6B@ */
391 extern const vtable_ptr MSVCP_basic_ifstream_wchar_vtable;
392
393 /* ??_8?$basic_ifstream@GU?$char_traits@G@std@@@std@@7B@ */
394 const int basic_ifstream_short_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
395 /* ??_7?$basic_ifstream@GU?$char_traits@G@std@@@std@@6B@ */
396 extern const vtable_ptr MSVCP_basic_ifstream_short_vtable;
397
398 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
399 const int basic_fstream_char_vbtable1[] = {0, sizeof(basic_fstream_char)};
400 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
401 const int basic_fstream_char_vbtable2[] = {0, sizeof(basic_fstream_char)-FIELD_OFFSET(basic_fstream_char, base.base2)};
402 /* ??_7?$basic_fstream@DU?$char_traits@D@std@@@std@@6B@ */
403 extern const vtable_ptr MSVCP_basic_fstream_char_vtable;
404
405 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
406 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
407 const int basic_fstream_wchar_vbtable1[] = {0, sizeof(basic_fstream_wchar)};
408 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
409 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
410 const int basic_fstream_wchar_vbtable2[] = {0, sizeof(basic_fstream_wchar)-FIELD_OFFSET(basic_fstream_wchar, base.base2)};
411 /* ??_7?$basic_fstream@_WU?$char_traits@_W@std@@@std@@6B@ */
412 extern const vtable_ptr MSVCP_basic_fstream_wchar_vtable;
413 /* ??_7?$basic_fstream@GU?$char_traits@G@std@@@std@@6B@ */
414 extern const vtable_ptr MSVCP_basic_fstream_short_vtable;
415
416 /* ??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
417 const int basic_ostringstream_char_vbtable[] = {0, sizeof(basic_ostringstream_char)};
418 /* ??_7?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
419 extern const vtable_ptr MSVCP_basic_ostringstream_char_vtable;
420
421 /* ??_8?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
422 const int basic_ostringstream_wchar_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
423 /* ??_7?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
424 extern const vtable_ptr MSVCP_basic_ostringstream_wchar_vtable;
425
426 /* ??_8?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
427 const int basic_ostringstream_short_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
428 /* ??_7?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
429 extern const vtable_ptr MSVCP_basic_ostringstream_short_vtable;
430
431 /* ??_8?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
432 const int basic_istringstream_char_vbtable[] = {0, sizeof(basic_istringstream_char)};
433 /* ??_7?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
434 extern const vtable_ptr MSVCP_basic_istringstream_char_vtable;
435
436 /* ??_8?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
437 const int basic_istringstream_wchar_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
438 /* ??_7?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
439 extern const vtable_ptr MSVCP_basic_istringstream_wchar_vtable;
440
441 /* ??_8?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
442 const int basic_istringstream_short_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
443 /* ??_7?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
444 extern const vtable_ptr MSVCP_basic_istringstream_short_vtable;
445
446 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
447 const int basic_stringstream_char_vbtable1[] = {0, sizeof(basic_stringstream_char)};
448 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
449 const int basic_stringstream_char_vbtable2[] = {0, sizeof(basic_stringstream_char)-FIELD_OFFSET(basic_stringstream_char, base.base2)};
450 /* ??_7?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
451 extern const vtable_ptr MSVCP_basic_stringstream_char_vtable;
452
453 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
454 const int basic_stringstream_wchar_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
455 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
456 const int basic_stringstream_wchar_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
457 /* ??_7?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
458 extern const vtable_ptr MSVCP_basic_stringstream_wchar_vtable;
459
460 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
461 const int basic_stringstream_short_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
462 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
463 const int basic_stringstream_short_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
464 /* ??_7?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
465 extern const vtable_ptr MSVCP_basic_stringstream_short_vtable;
466
467 /* ??_7strstreambuf@std@@6B */
468 extern const vtable_ptr MSVCP_strstreambuf_vtable;
469
470 DEFINE_RTTI_DATA0(iosb, 0, ".?AV?$_Iosb@H@std@@");
471 DEFINE_RTTI_DATA1(ios_base, 0, &iosb_rtti_base_descriptor, ".?AV?$_Iosb@H@std@@");
472 DEFINE_RTTI_DATA2(basic_ios_char, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
473         ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@");
474 DEFINE_RTTI_DATA2(basic_ios_wchar, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
475         ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@");
476 DEFINE_RTTI_DATA2(basic_ios_short, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
477         ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@");
478 DEFINE_RTTI_DATA0(basic_streambuf_char, 0,
479         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@");
480 DEFINE_RTTI_DATA0(basic_streambuf_wchar, 0,
481         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@");
482 DEFINE_RTTI_DATA0(basic_streambuf_short, 0,
483         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@");
484 DEFINE_RTTI_DATA1(basic_filebuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
485         ".?AV?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@");
486 DEFINE_RTTI_DATA1(basic_filebuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
487         ".?AV?$basic_filebuf@GU?$char_traits@G@std@@@std@@");
488 DEFINE_RTTI_DATA1(basic_filebuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
489         ".?AV?$basic_filebuf@DU?$char_traits@D@std@@@std@@");
490 DEFINE_RTTI_DATA1(basic_stringbuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
491         ".?AV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
492 DEFINE_RTTI_DATA1(basic_stringbuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
493         ".?AV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
494 DEFINE_RTTI_DATA1(basic_stringbuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
495         ".?AV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
496 DEFINE_RTTI_DATA3(basic_ostream_char, sizeof(basic_ostream_char), &basic_ios_char_rtti_base_descriptor,
497         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
498         ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@");
499 DEFINE_RTTI_DATA3(basic_ostream_wchar, sizeof(basic_ostream_wchar), &basic_ios_wchar_rtti_base_descriptor,
500         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
501         ".?AV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@");
502 DEFINE_RTTI_DATA3(basic_ostream_short, sizeof(basic_ostream_wchar), &basic_ios_short_rtti_base_descriptor,
503         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
504         ".?AV?$basic_ostream@GU?$char_traits@G@std@@@std@@");
505 DEFINE_RTTI_DATA3(basic_istream_char, sizeof(basic_istream_char), &basic_ios_char_rtti_base_descriptor,
506         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
507         ".?AV?$basic_istream@DU?$char_traits@D@std@@@std@@");
508 DEFINE_RTTI_DATA3(basic_istream_wchar, sizeof(basic_istream_wchar), &basic_ios_wchar_rtti_base_descriptor,
509         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
510         ".?AV?$basic_istream@_WU?$char_traits@_W@std@@@std@@");
511 DEFINE_RTTI_DATA3(basic_istream_short, sizeof(basic_istream_wchar), &basic_ios_short_rtti_base_descriptor,
512         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
513         ".?AV?$basic_istream@GU?$char_traits@G@std@@@std@@");
514 DEFINE_RTTI_DATA8(basic_iostream_char, sizeof(basic_iostream_char),
515         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
516         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
517         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
518         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
519         ".?AV?$basic_iostream@DU?$char_traits@D@std@@@std@@");
520 DEFINE_RTTI_DATA8(basic_iostream_wchar, sizeof(basic_iostream_wchar),
521         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
522         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
523         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
524         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
525         ".?AV?$basic_iostream@_WU?$char_traits@_W@std@@@std@@");
526 DEFINE_RTTI_DATA8(basic_iostream_short, sizeof(basic_iostream_wchar),
527         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
528         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
529         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
530         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
531         ".?AV?$basic_iostream@GU?$char_traits@G@std@@@std@@");
532 DEFINE_RTTI_DATA4(basic_ofstream_char, sizeof(basic_ofstream_char),
533         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
534         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
535         ".?AV?$basic_ofstream@DU?$char_traits@D@std@@@std@@");
536 DEFINE_RTTI_DATA4(basic_ofstream_wchar, sizeof(basic_ofstream_wchar),
537         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
538         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
539         ".?AV?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@");
540 DEFINE_RTTI_DATA4(basic_ofstream_short, sizeof(basic_ofstream_wchar),
541         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
542         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
543         ".?AV?$basic_ofstream@GU?$char_traits@G@std@@@std@@");
544 DEFINE_RTTI_DATA4(basic_ifstream_char, sizeof(basic_ifstream_char),
545         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
546         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
547         ".?AV?$basic_ifstream@DU?$char_traits@D@std@@@std@@");
548 DEFINE_RTTI_DATA4(basic_ifstream_wchar, sizeof(basic_ifstream_wchar),
549         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
550         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
551         ".?AV?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@");
552 DEFINE_RTTI_DATA4(basic_ifstream_short, sizeof(basic_ifstream_wchar),
553         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
554         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
555         ".?AV?$basic_ifstream@GU?$char_traits@G@std@@@std@@");
556 DEFINE_RTTI_DATA8(basic_fstream_char, sizeof(basic_fstream_char),
557         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
558         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
559         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
560         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
561         ".?AV?$basic_fstream@DU?$char_traits@D@std@@@std@@");
562 DEFINE_RTTI_DATA8(basic_fstream_wchar, sizeof(basic_fstream_wchar),
563         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
564         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
565         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
566         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
567         ".?AV?$basic_fstream@_WU?$char_traits@_W@std@@@std@@");
568 DEFINE_RTTI_DATA8(basic_fstream_short, sizeof(basic_fstream_wchar),
569         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
570         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
571         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
572         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
573         ".?AV?$basic_fstream@GU?$char_traits@G@std@@@std@@");
574 DEFINE_RTTI_DATA4(basic_ostringstream_char, sizeof(basic_ostringstream_char),
575         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
576         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
577         ".?AV?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
578 DEFINE_RTTI_DATA4(basic_ostringstream_wchar, sizeof(basic_ostringstream_wchar),
579         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
580         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
581         ".?AV?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
582 DEFINE_RTTI_DATA4(basic_ostringstream_short, sizeof(basic_ostringstream_wchar),
583         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
584         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
585         ".?AV?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
586 DEFINE_RTTI_DATA4(basic_istringstream_char, sizeof(basic_istringstream_char),
587         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
588         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
589         ".?AV?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
590 DEFINE_RTTI_DATA4(basic_istringstream_wchar, sizeof(basic_istringstream_wchar),
591         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
592         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
593         ".?AV?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
594 DEFINE_RTTI_DATA4(basic_istringstream_short, sizeof(basic_istringstream_wchar),
595         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
596         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
597         ".?AV?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
598 DEFINE_RTTI_DATA8(basic_stringstream_char, sizeof(basic_stringstream_char),
599         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
600         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
601         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
602         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
603         ".?AV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
604 DEFINE_RTTI_DATA8(basic_stringstream_wchar, sizeof(basic_stringstream_wchar),
605         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
606         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
607         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
608         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
609         ".?AV?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
610 DEFINE_RTTI_DATA8(basic_stringstream_short, sizeof(basic_stringstream_wchar),
611         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
612         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
613         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
614         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
615         ".?AV?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
616 DEFINE_RTTI_DATA1(strstreambuf, sizeof(strstreambuf),
617         &basic_streambuf_char_rtti_base_descriptor, ".?AVstrstreambuf@std@@");
618
619 #ifndef __GNUC__
620 void __asm_dummy_vtables(void) {
621 #endif
622     __ASM_VTABLE(iosb,
623             VTABLE_ADD_FUNC(iosb_vector_dtor));
624     __ASM_VTABLE(ios_base,
625             VTABLE_ADD_FUNC(ios_base_vector_dtor));
626     __ASM_VTABLE(basic_ios_char,
627             VTABLE_ADD_FUNC(basic_ios_char_vector_dtor));
628     __ASM_VTABLE(basic_ios_wchar,
629             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
630     __ASM_VTABLE(basic_ios_short,
631             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
632     __ASM_VTABLE(basic_streambuf_char,
633             VTABLE_ADD_FUNC(basic_streambuf_char_vector_dtor)
634             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
635             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
636             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
637             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
638             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
639             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
640             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
641             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
642             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
643             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
644             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
645             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
646     __ASM_VTABLE(basic_streambuf_wchar,
647             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
648             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
649             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
650             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
651             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
652             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
653             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
654             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
655             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
656             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
657             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
658             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
659             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
660     __ASM_VTABLE(basic_streambuf_short,
661             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
662             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
663             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
664             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
665             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
666             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
667             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
668             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
669             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
670             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
671             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
672             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
673             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
674     __ASM_VTABLE(basic_filebuf_char,
675             VTABLE_ADD_FUNC(basic_filebuf_char_vector_dtor)
676             VTABLE_ADD_FUNC(basic_filebuf_char_overflow)
677             VTABLE_ADD_FUNC(basic_filebuf_char_pbackfail)
678             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
679             VTABLE_ADD_FUNC(basic_filebuf_char_underflow)
680             VTABLE_ADD_FUNC(basic_filebuf_char_uflow)
681             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
682             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
683             VTABLE_ADD_FUNC(basic_filebuf_char_seekoff)
684             VTABLE_ADD_FUNC(basic_filebuf_char_seekpos)
685             VTABLE_ADD_FUNC(basic_filebuf_char_setbuf)
686             VTABLE_ADD_FUNC(basic_filebuf_char_sync)
687             VTABLE_ADD_FUNC(basic_filebuf_char_imbue));
688     __ASM_VTABLE(basic_filebuf_wchar,
689             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
690             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
691             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
692             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
693             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
694             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
695             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
696             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
697             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
698             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
699             VTABLE_ADD_FUNC(basic_filebuf_wchar_setbuf)
700             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
701             VTABLE_ADD_FUNC(basic_filebuf_wchar_imbue));
702     __ASM_VTABLE(basic_filebuf_short,
703             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
704             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
705             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
706             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
707             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
708             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
709             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
710             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
711             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
712             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
713             VTABLE_ADD_FUNC(basic_filebuf_short_setbuf)
714             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
715             VTABLE_ADD_FUNC(basic_filebuf_short_imbue));
716     __ASM_VTABLE(basic_stringbuf_char,
717             VTABLE_ADD_FUNC(basic_stringbuf_char_vector_dtor)
718             VTABLE_ADD_FUNC(basic_stringbuf_char_overflow)
719             VTABLE_ADD_FUNC(basic_stringbuf_char_pbackfail)
720             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
721             VTABLE_ADD_FUNC(basic_stringbuf_char_underflow)
722             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
723             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
724             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
725             VTABLE_ADD_FUNC(basic_stringbuf_char_seekoff)
726             VTABLE_ADD_FUNC(basic_stringbuf_char_seekpos)
727             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
728             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
729             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
730     __ASM_VTABLE(basic_stringbuf_wchar,
731             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
732             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
733             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
734             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
735             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
736             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
737             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
738             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
739             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
740             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
741             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
742             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
743             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
744     __ASM_VTABLE(basic_stringbuf_short,
745             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
746             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
747             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
748             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
749             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
750             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
751             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
752             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
753             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
754             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
755             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
756             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
757             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
758     __ASM_VTABLE(basic_ostream_char,
759             VTABLE_ADD_FUNC(basic_ostream_char_vector_dtor));
760     __ASM_VTABLE(basic_ostream_wchar,
761             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
762     __ASM_VTABLE(basic_ostream_short,
763             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
764     __ASM_VTABLE(basic_istream_char,
765             VTABLE_ADD_FUNC(basic_istream_char_vector_dtor));
766     __ASM_VTABLE(basic_istream_wchar,
767             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
768     __ASM_VTABLE(basic_istream_short,
769             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
770     __ASM_VTABLE(basic_iostream_char,
771             VTABLE_ADD_FUNC(basic_iostream_char_vector_dtor));
772     __ASM_VTABLE(basic_iostream_wchar,
773             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
774     __ASM_VTABLE(basic_iostream_short,
775             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
776     __ASM_VTABLE(basic_ofstream_char,
777             VTABLE_ADD_FUNC(basic_ofstream_char_vector_dtor));
778     __ASM_VTABLE(basic_ofstream_wchar,
779             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
780     __ASM_VTABLE(basic_ofstream_short,
781             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
782     __ASM_VTABLE(basic_ifstream_char,
783             VTABLE_ADD_FUNC(basic_ifstream_char_vector_dtor));
784     __ASM_VTABLE(basic_ifstream_wchar,
785             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
786     __ASM_VTABLE(basic_ifstream_short,
787             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
788     __ASM_VTABLE(basic_fstream_char,
789             VTABLE_ADD_FUNC(basic_fstream_char_vector_dtor));
790     __ASM_VTABLE(basic_fstream_wchar,
791             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
792     __ASM_VTABLE(basic_fstream_short,
793             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
794     __ASM_VTABLE(basic_ostringstream_char,
795             VTABLE_ADD_FUNC(basic_ostringstream_char_vector_dtor));
796     __ASM_VTABLE(basic_ostringstream_wchar,
797             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
798     __ASM_VTABLE(basic_ostringstream_short,
799             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
800     __ASM_VTABLE(basic_istringstream_char,
801             VTABLE_ADD_FUNC(basic_istringstream_char_vector_dtor));
802     __ASM_VTABLE(basic_istringstream_wchar,
803             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
804     __ASM_VTABLE(basic_istringstream_short,
805             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
806     __ASM_VTABLE(basic_stringstream_char,
807             VTABLE_ADD_FUNC(basic_stringstream_char_vector_dtor));
808     __ASM_VTABLE(basic_stringstream_wchar,
809             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
810     __ASM_VTABLE(basic_stringstream_short,
811             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
812     __ASM_VTABLE(strstreambuf,
813             VTABLE_ADD_FUNC(strstreambuf_vector_dtor)
814             VTABLE_ADD_FUNC(strstreambuf_overflow)
815             VTABLE_ADD_FUNC(strstreambuf_pbackfail)
816             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
817             VTABLE_ADD_FUNC(strstreambuf_underflow)
818             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
819             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
820             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
821             VTABLE_ADD_FUNC(strstreambuf_seekoff)
822             VTABLE_ADD_FUNC(strstreambuf_seekpos)
823             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
824             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
825             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
826 #ifndef __GNUC__
827 }
828 #endif
829
830 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
831 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
832 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
833 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
834 {
835     TRACE("(%p %p %p %p)\n", this, first, next, last);
836
837     this->wbuf = first;
838     this->wpos = next;
839     this->wsize = last-next;
840 }
841
842 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
843 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
844 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
845 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
846 {
847     basic_streambuf_char_setp_next(this, first, first, last);
848 }
849
850 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
851 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
852 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
853 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
854 {
855     TRACE("(%p %p %p %p)\n", this, first, next, last);
856
857     this->rbuf = first;
858     this->rpos = next;
859     this->rsize = last-next;
860 }
861
862 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
863 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
864 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
865 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
866 {
867     TRACE("(%p)\n", this);
868
869     this->prbuf = &this->rbuf;
870     this->pwbuf = &this->wbuf;
871     this->prpos = &this->rpos;
872     this->pwpos = &this->wpos;
873     this->prsize = &this->rsize;
874     this->pwsize = &this->wsize;
875
876     basic_streambuf_char_setp(this, NULL, NULL);
877     basic_streambuf_char_setg(this, NULL, NULL, NULL);
878 }
879
880 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
881 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
882 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
883 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
884 {
885     TRACE("(%p %d)\n", this, uninitialized);
886     this->vtable = &MSVCP_basic_streambuf_char_vtable;
887     mutex_ctor(&this->lock);
888     return this;
889 }
890
891 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
892 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
893 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
894 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
895 {
896     TRACE("(%p)\n", this);
897
898     this->vtable = &MSVCP_basic_streambuf_char_vtable;
899     mutex_ctor(&this->lock);
900     this->loc = MSVCRT_operator_new(sizeof(locale));
901     locale_ctor(this->loc);
902     basic_streambuf_char__Init_empty(this);
903
904     return this;
905 }
906
907 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
908 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
909 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
910 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
911 {
912     TRACE("(%p)\n", this);
913
914     mutex_dtor(&this->lock);
915     locale_dtor(this->loc);
916     MSVCRT_operator_delete(this->loc);
917 }
918
919 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_vector_dtor, 8)
920 basic_streambuf_char* __thiscall basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
921 {
922     TRACE("(%p %x)\n", this, flags);
923     if(flags & 2) {
924         /* we have an array, with the number of elements stored before the first object */
925         INT_PTR i, *ptr = (INT_PTR *)this-1;
926
927         for(i=*ptr-1; i>=0; i--)
928             basic_streambuf_char_dtor(this+i);
929         MSVCRT_operator_delete(ptr);
930     } else {
931         basic_streambuf_char_dtor(this);
932         if(flags & 1)
933             MSVCRT_operator_delete(this);
934     }
935
936     return this;
937 }
938
939 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
940 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
941 static streamsize basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
942 {
943     TRACE("(%p)\n", this);
944     return *this->prpos ? *this->prsize : 0;
945 }
946
947 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
948 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
949 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
950 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
951 {
952     TRACE("(%p)\n", this);
953     (*this->prsize)++;
954     (*this->prpos)--;
955     return *this->prpos;
956 }
957
958 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
959 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
960 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
961 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
962 {
963     TRACE("(%p)\n", this);
964     (*this->prsize)--;
965     return (*this->prpos)++;
966 }
967
968 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
969 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
970 static char* basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
971 {
972     TRACE("(%p)\n", this);
973     (*this->prsize)--;
974     (*this->prpos)++;
975     return *this->prpos;
976 }
977
978 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
979 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
980 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
981 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
982 {
983     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
984
985     this->prbuf = gf;
986     this->pwbuf = pf;
987     this->prpos = gn;
988     this->pwpos = pn;
989     this->prsize = gc;
990     this->pwsize = pc;
991 }
992
993 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
994 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
995 static void basic_streambuf_char__Lock(basic_streambuf_char *this)
996 {
997     TRACE("(%p)\n", this);
998     mutex_lock(&this->lock);
999 }
1000
1001 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
1002 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
1003 static streamsize basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
1004 {
1005     TRACE("(%p)\n", this);
1006     return *this->pwpos ? *this->pwsize : 0;
1007 }
1008
1009 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1010 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1011 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
1012 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
1013 {
1014     TRACE("(%p)\n", this);
1015     (*this->pwsize)--;
1016     return (*this->pwpos)++;
1017 }
1018
1019 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1020 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1021 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
1022 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
1023         int, (basic_streambuf_char*), (this))
1024 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
1025 {
1026     TRACE("(%p)\n", this);
1027     return EOF;
1028 }
1029
1030 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1031 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1032 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
1033 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
1034         int, (basic_streambuf_char*), (this))
1035 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
1036 {
1037     int ret;
1038
1039     TRACE("(%p)\n", this);
1040
1041     if(call_basic_streambuf_char_underflow(this)==EOF)
1042         return EOF;
1043
1044     ret = **this->prpos;
1045     (*this->prsize)--;
1046     (*this->prpos)++;
1047     return ret;
1048 }
1049
1050 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
1051 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
1052 static streamsize basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1053 {
1054     streamsize copied, chunk;
1055     int c;
1056
1057     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1058
1059     for(copied=0; copied<count && size;) {
1060         chunk = basic_streambuf_char__Gnavail(this);
1061         if(chunk > count-copied)
1062             chunk = count-copied;
1063
1064         if(chunk > 0) {
1065             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1066             *this->prpos += chunk;
1067             *this->prsize -= chunk;
1068             copied += chunk;
1069             size -= chunk;
1070         }else if((c = call_basic_streambuf_char_uflow(this)) != EOF) {
1071             ptr[copied] = c;
1072             copied++;
1073             size--;
1074         }else {
1075             break;
1076         }
1077     }
1078
1079     return copied;
1080 }
1081
1082 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
1083 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
1084 static streamsize basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1085 {
1086     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1087     return basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
1088 }
1089
1090 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1091 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1092 static void basic_streambuf_char__Unlock(basic_streambuf_char *this)
1093 {
1094     TRACE("(%p)\n", this);
1095     mutex_unlock(&this->lock);
1096 }
1097
1098 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1099 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1100 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
1101 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
1102 {
1103     TRACE("(%p)\n", this);
1104     return *this->prbuf;
1105 }
1106
1107 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1108 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1109 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
1110 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
1111 {
1112     TRACE("(%p)\n", this);
1113     return *this->prpos;
1114 }
1115
1116 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1117 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1118 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
1119 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
1120 {
1121     TRACE("(%p)\n", this);
1122     return *this->prpos+*this->prsize;
1123 }
1124
1125 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1126 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1127 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
1128 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
1129 {
1130     TRACE("(%p)\n", this);
1131     return *this->pwpos+*this->pwsize;
1132 }
1133
1134 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1135 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1136 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
1137 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
1138 {
1139     TRACE("(%p %d)\n", this, off);
1140     *this->prpos += off;
1141     *this->prsize -= off;
1142 }
1143
1144 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
1145 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
1146 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
1147 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1148         void, (basic_streambuf_char*, const locale*), (this, loc))
1149 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
1150 {
1151     TRACE("(%p %p)\n", this, loc);
1152 }
1153
1154 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1155 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1156 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
1157 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1158         int, (basic_streambuf_char*, int), (this, ch))
1159 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
1160 {
1161     TRACE("(%p %d)\n", this, ch);
1162     return EOF;
1163 }
1164
1165 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1166 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1167 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
1168 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1169         int, (basic_streambuf_char*, int), (this, ch))
1170 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
1171 {
1172     TRACE("(%p %d)\n", this, ch);
1173     return EOF;
1174 }
1175
1176 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1177 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1178 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
1179 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
1180 {
1181     TRACE("(%p)\n", this);
1182     return *this->pwbuf;
1183 }
1184
1185 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1186 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1187 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
1188 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
1189 {
1190     TRACE("(%p %d)\n", this, off);
1191     *this->pwpos += off;
1192     *this->pwsize -= off;
1193 }
1194
1195 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1196 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1197 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
1198 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
1199 {
1200     TRACE("(%p)\n", this);
1201     return *this->pwpos;
1202 }
1203
1204 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1205 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1206 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
1207 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
1208 {
1209     TRACE("(%p %p)\n", this, loc);
1210     memcpy(ret, this->loc, sizeof(locale));
1211     call_basic_streambuf_char_imbue(this, loc);
1212     locale_copy_ctor(this->loc, loc);
1213     return ret;
1214 }
1215
1216 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1217 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1218 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
1219 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1220         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1221 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
1222         fpos_int *ret, streamoff off, int way, int mode)
1223 {
1224     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1225     ret->off = 0;
1226     ret->pos = -1;
1227     ret->state = 0;
1228     return ret;
1229 }
1230
1231 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1232 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1233 static fpos_int* basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
1234         fpos_int *ret, streamoff off, int way, int mode)
1235 {
1236     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1237     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
1238 }
1239
1240 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1241 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1242 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
1243 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
1244         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1245 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
1246         fpos_int *ret, fpos_int pos, int mode)
1247 {
1248     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1249     ret->off = 0;
1250     ret->pos = -1;
1251     ret->state = 0;
1252     return ret;
1253 }
1254
1255 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1256 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1257 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
1258 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
1259         fpos_int *ret, fpos_int pos, int mode)
1260 {
1261     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1262     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
1263 }
1264
1265 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
1266 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
1267 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
1268 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
1269         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
1270 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
1271 {
1272     TRACE("(%p %p %ld)\n", this, buf, count);
1273     return this;
1274 }
1275
1276 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
1277 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
1278 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
1279 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
1280 {
1281     TRACE("(%p %p %ld)\n", this, buf, count);
1282     return call_basic_streambuf_char_setbuf(this, buf, count);
1283 }
1284
1285 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1286 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1287 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
1288 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 44, \
1289         int, (basic_streambuf_char*), (this))
1290 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
1291 {
1292     TRACE("(%p)\n", this);
1293     return 0;
1294 }
1295
1296 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1297 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1298 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
1299 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
1300 {
1301     TRACE("(%p)\n", this);
1302     return call_basic_streambuf_char_sync(this);
1303 }
1304
1305 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
1306 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
1307 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
1308 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1309 {
1310     TRACE("(%p %p %ld)\n", this, ptr, count);
1311     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1312 }
1313
1314 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1315 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
1316 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
1317 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1318         streamsize, (basic_streambuf_char*), (this))
1319 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
1320 {
1321     TRACE("(%p)\n", this);
1322     return 0;
1323 }
1324
1325 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1326 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
1327 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
1328 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
1329 {
1330     streamsize ret;
1331
1332     TRACE("(%p)\n", this);
1333
1334     ret = basic_streambuf_char__Gnavail(this);
1335     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
1336 }
1337
1338 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1339 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1340 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
1341 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
1342 {
1343     TRACE("(%p %d)\n", this, ch);
1344     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1345         (*this->prsize)++;
1346         (*this->prpos)--;
1347         return ch;
1348     }
1349
1350     return call_basic_streambuf_char_pbackfail(this, ch);
1351 }
1352
1353 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1354 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1355 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
1356 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
1357 {
1358     TRACE("(%p %d)\n", this, ch);
1359     return basic_streambuf_char__Pnavail(this) ?
1360         (*basic_streambuf_char__Pninc(this) = ch) :
1361         call_basic_streambuf_char_overflow(this, ch);
1362 }
1363
1364 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1365 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1366 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
1367 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
1368 {
1369     TRACE("(%p)\n", this);
1370     if(*this->prpos && *this->prpos>*this->prbuf) {
1371         (*this->prsize)++;
1372         (*this->prpos)--;
1373         return **this->prpos;
1374     }
1375
1376     return call_basic_streambuf_char_pbackfail(this, EOF);
1377 }
1378
1379 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1380 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1381 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1382 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1383 {
1384     TRACE("(%p)\n", this);
1385     if(basic_streambuf_char__Gnavail(this))
1386         basic_streambuf_char__Gninc(this);
1387     else
1388         call_basic_streambuf_char_uflow(this);
1389 }
1390
1391 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1392 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1393 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1394 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1395 {
1396     TRACE("(%p)\n", this);
1397     return basic_streambuf_char__Gnavail(this) ?
1398         *basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1399 }
1400
1401 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1402 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1403 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1404 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1405 {
1406     TRACE("(%p)\n", this);
1407     return basic_streambuf_char__Gnavail(this) ?
1408         *basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1409 }
1410
1411 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1412 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1413 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1414 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1415 {
1416     TRACE("(%p)\n", this);
1417
1418     if(basic_streambuf_char__Gnavail(this) > 1)
1419         return *basic_streambuf_char__Gnpreinc(this);
1420     return basic_streambuf_char_sbumpc(this)==EOF ?
1421         EOF : basic_streambuf_char_sgetc(this);
1422 }
1423
1424 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1425 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1426 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
1427 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1428         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1429 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1430 {
1431     TRACE("(%p %p %ld)\n", this, ptr, count);
1432     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1433 }
1434
1435 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1436 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1437 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
1438 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
1439         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1440 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1441 {
1442     streamsize copied, chunk;
1443
1444     TRACE("(%p %p %ld)\n", this, ptr, count);
1445
1446     for(copied=0; copied<count;) {
1447         chunk = basic_streambuf_char__Pnavail(this);
1448         if(chunk > count-copied)
1449             chunk = count-copied;
1450
1451         if(chunk > 0) {
1452             memcpy(*this->pwpos, ptr+copied, chunk);
1453             *this->pwpos += chunk;
1454             *this->pwsize -= chunk;
1455             copied += chunk;
1456         }else if(call_basic_streambuf_char_overflow(this, ptr[copied]) != EOF) {
1457             copied++;
1458         }else {
1459             break;
1460         }
1461     }
1462
1463     return copied;
1464 }
1465
1466 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1467 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1468 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
1469 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1470 {
1471     TRACE("(%p %p %ld)\n", this, ptr, count);
1472     return call_basic_streambuf_char_xsputn(this, ptr, count);
1473 }
1474
1475 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1476 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1477 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1478 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1479 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1480 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1481 {
1482     TRACE("(%p %p %p %p)\n", this, first, next, last);
1483
1484     this->wbuf = first;
1485     this->wpos = next;
1486     this->wsize = last-next;
1487 }
1488
1489 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1490 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1491 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1492 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1493 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1494 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1495 {
1496     basic_streambuf_wchar_setp_next(this, first, first, last);
1497 }
1498
1499 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1500 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1501 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1502 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1503 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1504 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1505 {
1506     TRACE("(%p %p %p %p)\n", this, first, next, last);
1507
1508     this->rbuf = first;
1509     this->rpos = next;
1510     this->rsize = last-next;
1511 }
1512
1513 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1514 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1515 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1516 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1517 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1518 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1519 {
1520     TRACE("(%p)\n", this);
1521
1522     this->prbuf = &this->rbuf;
1523     this->pwbuf = &this->wbuf;
1524     this->prpos = &this->rpos;
1525     this->pwpos = &this->wpos;
1526     this->prsize = &this->rsize;
1527     this->pwsize = &this->wsize;
1528
1529     basic_streambuf_wchar_setp(this, NULL, NULL);
1530     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1531 }
1532
1533 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1534 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1535 static basic_streambuf_wchar* basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1536 {
1537     TRACE("(%p %d)\n", this, uninitialized);
1538     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1539     mutex_ctor(&this->lock);
1540     return this;
1541 }
1542
1543 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1544 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1545 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1546 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1547 {
1548     TRACE("(%p %d)\n", this, uninitialized);
1549     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1550     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1551     return this;
1552 }
1553
1554 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1555 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1556 static basic_streambuf_wchar* basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1557 {
1558     TRACE("(%p)\n", this);
1559
1560     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1561     mutex_ctor(&this->lock);
1562     this->loc = MSVCRT_operator_new(sizeof(locale));
1563     locale_ctor(this->loc);
1564     basic_streambuf_wchar__Init_empty(this);
1565
1566     return this;
1567 }
1568
1569 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1570 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1571 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1572 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1573 {
1574     TRACE("(%p)\n", this);
1575     basic_streambuf_wchar_ctor(this);
1576     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1577     return this;
1578 }
1579
1580 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1581 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1582 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1583 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1584 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1585 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1586 {
1587     TRACE("(%p)\n", this);
1588
1589     mutex_dtor(&this->lock);
1590     locale_dtor(this->loc);
1591     MSVCRT_operator_delete(this->loc);
1592 }
1593
1594 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_vector_dtor, 8)
1595 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1596 {
1597     TRACE("(%p %x)\n", this, flags);
1598     if(flags & 2) {
1599         /* we have an array, with the number of elements stored before the first object */
1600         INT_PTR i, *ptr = (INT_PTR *)this-1;
1601
1602         for(i=*ptr-1; i>=0; i--)
1603             basic_streambuf_wchar_dtor(this+i);
1604         MSVCRT_operator_delete(ptr);
1605     } else {
1606         basic_streambuf_wchar_dtor(this);
1607         if(flags & 1)
1608             MSVCRT_operator_delete(this);
1609     }
1610
1611     return this;
1612 }
1613
1614 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1615 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1616 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1617 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1618 static streamsize basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1619 {
1620     TRACE("(%p)\n", this);
1621     return *this->prpos ? *this->prsize : 0;
1622 }
1623
1624 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1625 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1626 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1627 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1628 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1629 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1630 {
1631     TRACE("(%p)\n", this);
1632     (*this->prsize)++;
1633     (*this->prpos)--;
1634     return *this->prpos;
1635 }
1636
1637 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1638 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1639 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1640 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1641 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1642 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1643 {
1644     TRACE("(%p)\n", this);
1645     (*this->prsize)--;
1646     return (*this->prpos)++;
1647 }
1648
1649 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1650 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1651 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1652 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1653 static wchar_t* basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1654 {
1655     TRACE("(%p)\n", this);
1656     (*this->prsize)--;
1657     (*this->prpos)++;
1658     return *this->prpos;
1659 }
1660
1661 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1662 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1663 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1664 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1665 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1666 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)
1667 {
1668     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1669
1670     this->prbuf = gf;
1671     this->pwbuf = pf;
1672     this->prpos = gn;
1673     this->pwpos = pn;
1674     this->prsize = gc;
1675     this->pwsize = pc;
1676 }
1677
1678 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1679 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1680 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1681 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1682 static void basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1683 {
1684     TRACE("(%p)\n", this);
1685     mutex_lock(&this->lock);
1686 }
1687
1688 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1689 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1690 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1691 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1692 static streamsize basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1693 {
1694     TRACE("(%p)\n", this);
1695     return *this->pwpos ? *this->pwsize : 0;
1696 }
1697
1698 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1699 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1700 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1701 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1702 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1703 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1704 {
1705     TRACE("(%p)\n", this);
1706     (*this->pwsize)--;
1707     return (*this->pwpos)++;
1708 }
1709
1710 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1711 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1712 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1713 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1714 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1715 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1716         unsigned short, (basic_streambuf_wchar*), (this))
1717 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1718 {
1719     TRACE("(%p)\n", this);
1720     return WEOF;
1721 }
1722
1723 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1724 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1725 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1726 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1727 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1728 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1729         unsigned short, (basic_streambuf_wchar*), (this))
1730 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1731 {
1732     int ret;
1733
1734     TRACE("(%p)\n", this);
1735
1736     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1737         return WEOF;
1738
1739     ret = **this->prpos;
1740     (*this->prsize)--;
1741     (*this->prpos)++;
1742     return ret;
1743 }
1744
1745 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1746 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1747 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1748 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1749 static streamsize basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1750 {
1751     streamsize copied, chunk;
1752     unsigned short c;
1753
1754     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1755
1756     for(copied=0; copied<count && size;) {
1757         chunk = basic_streambuf_wchar__Gnavail(this);
1758         if(chunk > count-copied)
1759             chunk = count-copied;
1760
1761         if(chunk > 0) {
1762             memcpy_s(ptr+copied, size, *this->prpos, chunk*sizeof(wchar_t));
1763             *this->prpos += chunk;
1764             *this->prsize -= chunk;
1765             copied += chunk;
1766             size -= chunk*sizeof(wchar_t);
1767         }else if((c = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1768             ptr[copied] = c;
1769             copied++;
1770             size--;
1771         }else {
1772             break;
1773         }
1774     }
1775
1776     return copied;
1777 }
1778
1779 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1780 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1781 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1782 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1783 static streamsize basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1784 {
1785     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1786     return basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1787 }
1788
1789 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1790 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1791 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1792 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1793 static void basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1794 {
1795     TRACE("(%p)\n", this);
1796     mutex_unlock(&this->lock);
1797 }
1798
1799 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1800 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1801 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1802 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1803 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1804 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1805 {
1806     TRACE("(%p)\n", this);
1807     return *this->prbuf;
1808 }
1809
1810 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1811 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1812 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1813 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1814 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1815 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1816 {
1817     TRACE("(%p)\n", this);
1818     return *this->prpos;
1819 }
1820
1821 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1822 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1823 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1824 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1825 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1826 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1827 {
1828     TRACE("(%p)\n", this);
1829     return *this->prpos+*this->prsize;
1830 }
1831
1832 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1833 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1834 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1835 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1836 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1837 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1838 {
1839     TRACE("(%p)\n", this);
1840     return *this->pwpos+*this->pwsize;
1841 }
1842
1843 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1844 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1845 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1846 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1847 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1848 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1849 {
1850     TRACE("(%p %d)\n", this, off);
1851     *this->prpos += off;
1852     *this->prsize -= off;
1853 }
1854
1855 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1856 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1857 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1858 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1859 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1860 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1861         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1862 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1863 {
1864     TRACE("(%p %p)\n", this, loc);
1865 }
1866
1867 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1868 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1869 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1870 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1871 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1872 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1873         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1874 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1875 {
1876     TRACE("(%p %d)\n", this, ch);
1877     return WEOF;
1878 }
1879
1880 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1881 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1882 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1883 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1884 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1885 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1886         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1887 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1888 {
1889     TRACE("(%p %d)\n", this, ch);
1890     return WEOF;
1891 }
1892
1893 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1894 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1895 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1896 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1897 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1898 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1899 {
1900     TRACE("(%p)\n", this);
1901     return *this->pwbuf;
1902 }
1903
1904 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1905 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1906 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1907 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1908 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1909 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1910 {
1911     TRACE("(%p %d)\n", this, off);
1912     *this->pwpos += off;
1913     *this->pwsize -= off;
1914 }
1915
1916 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1917 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1918 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1919 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1920 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1921 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1922 {
1923     TRACE("(%p)\n", this);
1924     return *this->pwpos;
1925 }
1926
1927 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1928 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1929 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1930 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1931 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
1932 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
1933 {
1934     TRACE("(%p %p)\n", this, loc);
1935     memcpy(ret, this->loc, sizeof(locale));
1936     call_basic_streambuf_wchar_imbue(this, loc);
1937     locale_copy_ctor(this->loc, loc);
1938     return ret;
1939 }
1940
1941 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1942 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1943 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1944 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1945 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
1946 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1947         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1948 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
1949         fpos_int *ret, streamoff off, int way, int mode)
1950 {
1951     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1952     ret->off = 0;
1953     ret->pos = -1;
1954     ret->state = 0;
1955     return ret;
1956 }
1957
1958 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1959 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1960 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1961 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1962 static fpos_int* basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
1963         fpos_int *ret, streamoff off, int way, int mode)
1964 {
1965     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1966     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
1967 }
1968
1969 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1970 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1971 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1972 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1973 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
1974 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
1975         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1976 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
1977         fpos_int *ret, fpos_int pos, int mode)
1978 {
1979     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1980     ret->off = 0;
1981     ret->pos = -1;
1982     ret->state = 0;
1983     return ret;
1984 }
1985
1986 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1987 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1988 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1989 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1990 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
1991 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
1992         fpos_int *ret, fpos_int pos, int mode)
1993 {
1994     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1995     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
1996 }
1997
1998 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
1999 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
2000 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
2001 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
2002 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
2003 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
2004         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
2005 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2006 {
2007     TRACE("(%p %p %ld)\n", this, buf, count);
2008     return this;
2009 }
2010
2011 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
2012 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
2013 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
2014 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
2015 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
2016 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2017 {
2018     TRACE("(%p %p %ld)\n", this, buf, count);
2019     return call_basic_streambuf_wchar_setbuf(this, buf, count);
2020 }
2021
2022 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2023 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2024 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2025 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2026 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
2027 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 44, \
2028         int, (basic_streambuf_wchar*), (this))
2029 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
2030 {
2031     TRACE("(%p)\n", this);
2032     return 0;
2033 }
2034
2035 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2036 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
2037 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2038 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
2039 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
2040 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
2041 {
2042     TRACE("(%p)\n", this);
2043     return call_basic_streambuf_wchar_sync(this);
2044 }
2045
2046 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
2047 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
2048 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
2049 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
2050 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
2051 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2052 {
2053     TRACE("(%p %p %ld)\n", this, ptr, count);
2054     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2055 }
2056
2057 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2058 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
2059 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2060 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
2061 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
2062 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
2063         streamsize, (basic_streambuf_wchar*), (this))
2064 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
2065 {
2066     TRACE("(%p)\n", this);
2067     return 0;
2068 }
2069
2070 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2071 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
2072 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2073 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
2074 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
2075 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
2076 {
2077     streamsize ret;
2078
2079     TRACE("(%p)\n", this);
2080
2081     ret = basic_streambuf_wchar__Gnavail(this);
2082     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
2083 }
2084
2085 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2086 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2087 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2088 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2089 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
2090 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
2091 {
2092     TRACE("(%p %d)\n", this, ch);
2093     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
2094         (*this->prsize)++;
2095         (*this->prpos)--;
2096         return ch;
2097     }
2098
2099     return call_basic_streambuf_wchar_pbackfail(this, ch);
2100 }
2101
2102 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2103 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2104 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2105 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
2106 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
2107 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
2108 {
2109     TRACE("(%p %d)\n", this, ch);
2110     return basic_streambuf_wchar__Pnavail(this) ?
2111         (*basic_streambuf_wchar__Pninc(this) = ch) :
2112         call_basic_streambuf_wchar_overflow(this, ch);
2113 }
2114
2115 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2116 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2117 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2118 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2119 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
2120 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
2121 {
2122     TRACE("(%p)\n", this);
2123     if(*this->prpos && *this->prpos>*this->prbuf) {
2124         (*this->prsize)++;
2125         (*this->prpos)--;
2126         return **this->prpos;
2127     }
2128
2129     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
2130 }
2131
2132 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2133 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2134 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2135 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2136 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
2137 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
2138 {
2139     TRACE("(%p)\n", this);
2140     if(basic_streambuf_wchar__Gnavail(this))
2141         basic_streambuf_wchar__Gninc(this);
2142     else
2143         call_basic_streambuf_wchar_uflow(this);
2144 }
2145
2146 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2147 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2148 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2149 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2150 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
2151 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
2152 {
2153     TRACE("(%p)\n", this);
2154     return basic_streambuf_wchar__Gnavail(this) ?
2155         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
2156 }
2157
2158 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2159 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2160 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2161 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2162 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
2163 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
2164 {
2165     TRACE("(%p)\n", this);
2166     return basic_streambuf_wchar__Gnavail(this) ?
2167         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
2168 }
2169
2170 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2171 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2172 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2173 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2174 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
2175 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
2176 {
2177     TRACE("(%p)\n", this);
2178
2179     if(basic_streambuf_wchar__Gnavail(this) > 1)
2180         return *basic_streambuf_wchar__Gnpreinc(this);
2181     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
2182         WEOF : basic_streambuf_wchar_sgetc(this);
2183 }
2184
2185 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
2186 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
2187 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
2188 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
2189 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
2190 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
2191         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
2192 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2193 {
2194     TRACE("(%p %p %ld)\n", this, ptr, count);
2195     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2196 }
2197
2198 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
2199 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
2200 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
2201 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
2202 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
2203 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
2204         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
2205 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2206 {
2207     streamsize copied, chunk;
2208
2209     TRACE("(%p %p %ld)\n", this, ptr, count);
2210
2211     for(copied=0; copied<count;) {
2212         chunk = basic_streambuf_wchar__Pnavail(this);
2213         if(chunk > count-copied)
2214             chunk = count-copied;
2215
2216         if(chunk > 0) {
2217             memcpy(*this->pwpos, ptr+copied, chunk*sizeof(wchar_t));
2218             *this->pwpos += chunk;
2219             *this->pwsize -= chunk;
2220             copied += chunk;
2221         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
2222             copied++;
2223         }else {
2224             break;
2225         }
2226     }
2227
2228     return copied;
2229 }
2230
2231 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
2232 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
2233 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
2234 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
2235 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
2236 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2237 {
2238     TRACE("(%p %p %ld)\n", this, ptr, count);
2239     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
2240 }
2241
2242 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2243 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2244 int basic_filebuf_char__Init__Stinit = 0;
2245
2246 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2247 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2248 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
2249 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
2250 {
2251     TRACE("(%p %p %d)\n", this, file, which);
2252
2253     this->cvt = NULL;
2254     this->wrotesome = FALSE;
2255     this->state = basic_filebuf_char__Init__Stinit;
2256     this->close = (which == INITFL_open);
2257     this->file = file;
2258
2259     basic_streambuf_char__Init_empty(&this->base);
2260     if(file)
2261         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
2262                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
2263 }
2264
2265 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAV?$codecvt@DDH@2@@Z */
2266 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$codecvt@DDH@2@@Z */
2267 static void basic_filebuf_char__Initcvt(basic_filebuf_char *this, codecvt_char *cvt)
2268 {
2269     TRACE("(%p %p)\n", this, cvt);
2270
2271     if(codecvt_base_always_noconv(&cvt->base)) {
2272         this->cvt = NULL;
2273     }else {
2274         basic_streambuf_char__Init_empty(&this->base);
2275         this->cvt = cvt;
2276     }
2277 }
2278
2279 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAE_NXZ */
2280 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAA_NXZ */
2281 static MSVCP_bool basic_filebuf_char__Endwrite(basic_filebuf_char *this)
2282 {
2283     TRACE("(%p)\n", this);
2284
2285     if(!this->wrotesome || !this->cvt)
2286         return TRUE;
2287
2288
2289     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2290         return FALSE;
2291
2292     while(1) {
2293         /* TODO: check if we need a dynamic buffer here */
2294         char buf[128];
2295         char *next;
2296         int ret;
2297
2298         ret = codecvt_char_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2299         switch(ret) {
2300         case CODECVT_ok:
2301             this->wrotesome = FALSE;
2302             /* fall through */
2303         case CODECVT_partial:
2304             if(!fwrite(buf, next-buf, 1, this->file))
2305                 return FALSE;
2306             if(this->wrotesome)
2307                 break;
2308             /* fall through */
2309         case CODECVT_noconv:
2310             if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2311                 return FALSE;
2312             return TRUE;
2313         default:
2314             return FALSE;
2315         }
2316     }
2317 }
2318
2319 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2320 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2321 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2322 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2323 {
2324     basic_filebuf_char *ret = this;
2325
2326     TRACE("(%p)\n", this);
2327
2328     if(!this->file)
2329         return NULL;
2330
2331     /* TODO: handle exceptions */
2332     if(!basic_filebuf_char__Endwrite(this))
2333         ret = NULL;
2334     if(!fclose(this->file))
2335         ret  = NULL;
2336
2337     basic_filebuf_char__Init(this, NULL, INITFL_close);
2338     return ret;
2339 }
2340
2341 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2342 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2343 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2344 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2345 {
2346     TRACE("(%p %p)\n", this, file);
2347
2348     basic_streambuf_char_ctor(&this->base);
2349     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2350
2351     basic_filebuf_char__Init(this, file, INITFL_new);
2352     return this;
2353 }
2354
2355 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2356 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2357 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2358 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2359 {
2360     return basic_filebuf_char_ctor_file(this, NULL);
2361 }
2362
2363 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2364 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2365 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2366 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2367 {
2368     TRACE("(%p %d)\n", this, uninitialized);
2369
2370     basic_streambuf_char_ctor(&this->base);
2371     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2372     return this;
2373 }
2374
2375 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2376 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2377 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2378 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2379 {
2380     TRACE("(%p)\n", this);
2381
2382     if(this->close)
2383         basic_filebuf_char_close(this);
2384     basic_streambuf_char_dtor(&this->base);
2385 }
2386
2387 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2388 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2389 {
2390     TRACE("(%p %x)\n", this, flags);
2391     if(flags & 2) {
2392         /* we have an array, with the number of elements stored before the first object */
2393         INT_PTR i, *ptr = (INT_PTR *)this-1;
2394
2395         for(i=*ptr-1; i>=0; i--)
2396             basic_filebuf_char_dtor(this+i);
2397         MSVCRT_operator_delete(ptr);
2398     } else {
2399         basic_filebuf_char_dtor(this);
2400         if(flags & 1)
2401             MSVCRT_operator_delete(this);
2402     }
2403
2404     return this;
2405 }
2406
2407 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2408 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2409 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2410 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2411 {
2412     TRACE("(%p)\n", this);
2413     return this->file != NULL;
2414 }
2415
2416 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2417 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2418 static FILE* _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2419 {
2420     static const wchar_t rW[] = {'r',0};
2421     static const struct {
2422         int mode;
2423         const wchar_t str[4];
2424         const wchar_t str_bin[4];
2425     } str_mode[] = {
2426         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2427         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2428         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2429         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2430         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2431         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2432         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2433         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2434         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2435     };
2436
2437     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2438     int mode_idx;
2439     FILE *f = NULL;
2440
2441     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2442
2443     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2444         if(str_mode[mode_idx].mode == real_mode)
2445             break;
2446     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2447         return NULL;
2448
2449     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2450         return NULL;
2451     else if(f)
2452         fclose(f);
2453
2454     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2455             && (f = _wfopen(name, rW))) {
2456         fclose(f);
2457         return NULL;
2458     }
2459
2460     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2461             : str_mode[mode_idx].str, prot);
2462     if(!f)
2463         return NULL;
2464
2465     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2466         fclose(f);
2467         return NULL;
2468     }
2469
2470     return f;
2471 }
2472
2473 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2474 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2475 static FILE* _Fiopen(const char *name, int mode, int prot)
2476 {
2477     wchar_t nameW[FILENAME_MAX];
2478
2479     TRACE("(%s %d %d)\n", name, mode, prot);
2480
2481     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2482         return NULL;
2483     return _Fiopen_wchar(nameW, mode, prot);
2484 }
2485
2486 /* ?__Fiopen@std@@YAPAU_iobuf@@PBDH@Z */
2487 /* ?__Fiopen@std@@YAPEAU_iobuf@@PEBDH@Z */
2488 FILE* __cdecl ___Fiopen(const char *name, int mode)
2489 {
2490     TRACE("(%p %d)\n", name, mode);
2491     return _Fiopen(name, mode, _SH_DENYNO);
2492 }
2493
2494 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2495 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2496 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2497 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2498 static basic_filebuf_char* basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2499 {
2500     FILE *f = NULL;
2501
2502     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2503
2504     if(basic_filebuf_char_is_open(this))
2505         return NULL;
2506
2507     if(!(f = _Fiopen_wchar(name, mode, prot)))
2508         return NULL;
2509
2510     basic_filebuf_char__Init(this, f, INITFL_open);
2511     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(this->base.loc));
2512     return this;
2513 }
2514
2515 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2516 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2517 static basic_filebuf_char* basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2518 {
2519     wchar_t nameW[FILENAME_MAX];
2520
2521     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2522
2523     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2524         return NULL;
2525     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2526 }
2527
2528 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDF@Z */
2529 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDF@Z */
2530 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode_old, 12)
2531 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode_old(basic_filebuf_char *this, const char *name, short mode)
2532 {
2533     TRACE("(%p %p %d)\n", this, name, mode);
2534     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2535 }
2536
2537 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDH@Z */
2538 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDH@Z */
2539 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2540 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, int mode)
2541 {
2542     TRACE("(%p %p %d)\n", this, name, mode);
2543     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2544 }
2545
2546 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2547 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2548 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2549 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2550 {
2551     char buf[8], *dyn_buf;
2552     char ch = c, *to_next;
2553     const char *from_next;
2554     int ret, max_size;
2555
2556
2557     TRACE("(%p %d)\n", this, c);
2558
2559     if(!basic_filebuf_char_is_open(this))
2560         return EOF;
2561     if(c == EOF)
2562         return !c;
2563
2564     if(!this->cvt)
2565         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2566
2567     from_next = &ch;
2568     do {
2569         ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2570                 &from_next, buf, buf+sizeof(buf), &to_next);
2571
2572         switch(ret) {
2573         case CODECVT_partial:
2574             if(to_next == buf)
2575                 break;
2576             /* fall through */
2577         case CODECVT_ok:
2578             if(!fwrite(buf, to_next-buf, 1, this->file))
2579                 return EOF;
2580             if(ret == CODECVT_partial)
2581                 continue;
2582             return c;
2583         case CODECVT_noconv:
2584             return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2585         default:
2586             return EOF;
2587         }
2588
2589         break;
2590     } while(1);
2591
2592     max_size = codecvt_base_max_length(&this->cvt->base);
2593     dyn_buf = malloc(max_size);
2594     if(!dyn_buf)
2595         return EOF;
2596
2597     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2598             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2599
2600     switch(ret) {
2601     case CODECVT_ok:
2602         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2603         free(dyn_buf);
2604         return ret ? c : EOF;
2605     case CODECVT_partial:
2606         ERR("buffer should be big enough to store all output\n");
2607         /* fall through */
2608     default:
2609         free(dyn_buf);
2610         return EOF;
2611     }
2612 }
2613
2614 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2615 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2616 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2617 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2618 {
2619     TRACE("(%p %d)\n", this, c);
2620
2621     if(!basic_filebuf_char_is_open(this))
2622         return EOF;
2623
2624     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2625             && (c==EOF || basic_streambuf_char_gptr(&this->base)[-1]==(char)c)) {
2626         basic_streambuf_char__Gndec(&this->base);
2627         return c==EOF ? !c : c;
2628     }else if(c!=EOF && !this->cvt) {
2629         return ungetc(c, this->file);
2630     }
2631
2632     return EOF;
2633 }
2634
2635 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2636 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2637 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2638 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2639 {
2640     char ch, buf[128], *to_next;
2641     const char *buf_next;
2642     int c, i;
2643
2644     TRACE("(%p)\n", this);
2645
2646     if(!basic_filebuf_char_is_open(this))
2647         return EOF;
2648
2649     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2650         return *basic_streambuf_char__Gninc(&this->base);
2651
2652     c = fgetc(this->file);
2653     if(!this->cvt || c==EOF)
2654         return c;
2655
2656     buf_next = buf;
2657     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
2658         buf[i] = c;
2659
2660         switch(codecvt_char_in(this->cvt, &this->state, buf_next,
2661                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2662         case CODECVT_partial:
2663         case CODECVT_ok:
2664             if(to_next == &ch) {
2665                 c = fgetc(this->file);
2666                 if(c == EOF)
2667                     return EOF;
2668                 continue;
2669             }
2670
2671             for(i--; i>=buf_next-buf; i--)
2672                 ungetc(buf[i], this->file);
2673             return ch;
2674         case CODECVT_noconv:
2675             return buf[0];
2676         default:
2677             return EOF;
2678         }
2679     }
2680
2681     FIXME("buffer is too small\n");
2682     return EOF;
2683 }
2684
2685 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2686 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2687 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2688 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2689 {
2690     int ret;
2691
2692     TRACE("(%p)\n", this);
2693
2694     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2695         return *basic_streambuf_char_gptr(&this->base);
2696
2697     ret = call_basic_streambuf_char_uflow(&this->base);
2698     if(ret != EOF)
2699         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2700     return ret;
2701 }
2702
2703 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2704 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2705 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2706 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2707         fpos_int *ret, streamoff off, int way, int mode)
2708 {
2709     fpos_t pos;
2710
2711     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2712
2713     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2714             || fseek(this->file, off, way)) {
2715         ret->off = 0;
2716         ret->pos = -1;
2717         ret->state = 0;
2718         return ret;
2719     }
2720
2721     fgetpos(this->file, &pos);
2722     ret->off = 0;
2723     ret->pos = pos;
2724     ret->state = this->state;
2725     return ret;
2726 }
2727
2728 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2729 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2730 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2731 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2732         fpos_int *ret, fpos_int pos, int mode)
2733 {
2734     fpos_t fpos;
2735
2736     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2737
2738     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2739             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2740             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2741         ret->off = 0;
2742         ret->pos = -1;
2743         ret->state = 0;
2744         return ret;
2745     }
2746
2747     fgetpos(this->file, &fpos);
2748     ret->off = 0;
2749     ret->pos = fpos;
2750     ret->state = this->state;
2751     return ret;
2752 }
2753
2754 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2755 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2756 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2757 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2758 {
2759     TRACE("(%p %p %ld)\n", this, buf, count);
2760
2761     if(!basic_filebuf_char_is_open(this))
2762         return NULL;
2763
2764     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2765         return NULL;
2766
2767     basic_filebuf_char__Init(this, this->file, INITFL_open);
2768     return &this->base;
2769 }
2770
2771 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2772 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2773 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2774 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2775 {
2776     TRACE("(%p)\n", this);
2777
2778     if(!basic_filebuf_char_is_open(this))
2779         return 0;
2780
2781     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2782         return 0;
2783     return fflush(this->file);
2784 }
2785
2786 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
2787 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
2788 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_imbue, 8)
2789 void __thiscall basic_filebuf_char_imbue(basic_filebuf_char *this, const locale *loc)
2790 {
2791     TRACE("(%p %p)\n", this, loc);
2792     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(loc));
2793 }
2794
2795 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2796 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2797 int basic_filebuf_short__Init__Stinit = 0;
2798
2799 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2800 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2801 static void basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2802 {
2803     TRACE("(%p %p %d)\n", this, file, which);
2804
2805     this->cvt = NULL;
2806     this->wrotesome = FALSE;
2807     this->state = 0;
2808     this->close = (which == INITFL_open);
2809     this->file = file;
2810
2811     basic_streambuf_wchar__Init_empty(&this->base);
2812 }
2813
2814 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2815 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2816 DEFINE_THISCALL_WRAPPER(basic_filebuf_short__Init, 12)
2817 void __thiscall basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2818 {
2819     TRACE("(%p %p %d)\n", this, file, which);
2820
2821     this->cvt = NULL;
2822     this->wrotesome = FALSE;
2823     this->state = basic_filebuf_short__Init__Stinit;
2824     this->close = (which == INITFL_open);
2825     this->file = file;
2826
2827     basic_streambuf_wchar__Init_empty(&this->base);
2828 }
2829
2830 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$codecvt@_WDH@2@@Z */
2831 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$codecvt@_WDH@2@@Z */
2832 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAV?$codecvt@GDH@2@@Z */
2833 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$codecvt@GDH@2@@Z */
2834 static void basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this, codecvt_wchar *cvt)
2835 {
2836     TRACE("(%p %p)\n", this, cvt);
2837
2838     if(codecvt_base_always_noconv(&cvt->base)) {
2839         this->cvt = NULL;
2840     }else {
2841         basic_streambuf_wchar__Init_empty(&this->base);
2842         this->cvt = cvt;
2843     }
2844 }
2845
2846 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAE_NXZ */
2847 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAA_NXZ */
2848 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAE_NXZ */
2849 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAA_NXZ */
2850 static MSVCP_bool basic_filebuf_wchar__Endwrite(basic_filebuf_wchar *this)
2851 {
2852     TRACE("(%p)\n", this);
2853
2854     if(!this->wrotesome || !this->cvt)
2855         return TRUE;
2856
2857     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2858         return FALSE;
2859
2860     while(1) {
2861         /* TODO: check if we need a dynamic buffer here */
2862         char buf[128];
2863         char *next;
2864         int ret;
2865
2866         ret = codecvt_wchar_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2867         switch(ret) {
2868         case CODECVT_ok:
2869             this->wrotesome = FALSE;
2870             /* fall through */
2871         case CODECVT_partial:
2872             if(!fwrite(buf, next-buf, 1, this->file))
2873                 return FALSE;
2874             if(this->wrotesome)
2875                 break;
2876             /* fall through */
2877         case CODECVT_noconv:
2878             if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2879                 return FALSE;
2880             return TRUE;
2881         default:
2882             return FALSE;
2883         }
2884     }
2885 }
2886
2887 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
2888 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
2889 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
2890 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
2891 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_close, 4)
2892 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_close(basic_filebuf_wchar *this)
2893 {
2894     basic_filebuf_wchar *ret = this;
2895
2896     TRACE("(%p)\n", this);
2897
2898     if(!this->file)
2899         return NULL;
2900
2901     /* TODO: handle exceptions */
2902     if(!basic_filebuf_wchar__Endwrite(this))
2903         ret = NULL;
2904     if(!fclose(this->file))
2905         ret  = NULL;
2906
2907     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
2908     return ret;
2909 }
2910
2911 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
2912 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2913 static basic_filebuf_wchar* basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
2914 {
2915     TRACE("(%p %p)\n", this, file);
2916
2917     basic_streambuf_wchar_ctor(&this->base);
2918     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
2919
2920     basic_filebuf_wchar__Init(this, file, INITFL_new);
2921     return this;
2922 }
2923
2924 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
2925 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2926 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_file, 8)
2927 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
2928 {
2929     TRACE("(%p %p)\n", this, file);
2930
2931     basic_streambuf_short_ctor(&this->base);
2932     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
2933
2934     basic_filebuf_short__Init(this, file, INITFL_new);
2935     return this;
2936 }
2937
2938 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2939 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2940 static basic_filebuf_wchar* basic_filebuf_wchar_ctor(basic_filebuf_wchar *this)
2941 {
2942     return basic_filebuf_wchar_ctor_file(this, NULL);
2943 }
2944
2945 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2946 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2947 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor, 4)
2948 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor(basic_filebuf_wchar *this)
2949 {
2950     return basic_filebuf_short_ctor_file(this, NULL);
2951 }
2952
2953 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2954 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2955 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_uninitialized, 8)
2956 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
2957 {
2958     TRACE("(%p %d)\n", this, uninitialized);
2959
2960     basic_streambuf_short_ctor(&this->base);
2961     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
2962     return this;
2963 }
2964
2965 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
2966 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
2967 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
2968 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
2969 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_dtor, 4)
2970 void __thiscall basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
2971 {
2972     TRACE("(%p)\n", this);
2973
2974     if(this->close)
2975         basic_filebuf_wchar_close(this);
2976     basic_streambuf_wchar_dtor(&this->base);
2977 }
2978
2979 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
2980 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
2981 {
2982     TRACE("(%p %x)\n", this, flags);
2983     if(flags & 2) {
2984         /* we have an array, with the number of elements stored before the first object */
2985         INT_PTR i, *ptr = (INT_PTR *)this-1;
2986
2987         for(i=*ptr-1; i>=0; i--)
2988             basic_filebuf_wchar_dtor(this+i);
2989         MSVCRT_operator_delete(ptr);
2990     } else {
2991         basic_filebuf_wchar_dtor(this);
2992         if(flags & 1)
2993             MSVCRT_operator_delete(this);
2994     }
2995
2996     return this;
2997 }
2998
2999 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
3000 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
3001 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
3002 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
3003 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_is_open, 4)
3004 MSVCP_bool __thiscall basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
3005 {
3006     TRACE("(%p)\n", this);
3007     return this->file != NULL;
3008 }
3009
3010 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WHH@Z */
3011 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3012 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGHH@Z */
3013 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3014 static basic_filebuf_wchar* basic_filebuf_wchar_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3015 {
3016     FILE *f = NULL;
3017
3018     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3019
3020     if(basic_filebuf_wchar_is_open(this))
3021         return NULL;
3022
3023     if(!(f = _Fiopen_wchar(name, mode, prot)))
3024         return NULL;
3025
3026     basic_filebuf_wchar__Init(this, f, INITFL_open);
3027     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(this->base.loc));
3028     return this;
3029 }
3030
3031 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDHH@Z */
3032 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3033 static basic_filebuf_wchar* basic_filebuf_wchar_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3034 {
3035     wchar_t nameW[FILENAME_MAX];
3036
3037     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3038
3039     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3040         return NULL;
3041     return basic_filebuf_wchar_open_wchar(this, nameW, mode, prot);
3042 }
3043
3044 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
3045 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
3046 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode_old, 12)
3047 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode_old(basic_filebuf_wchar *this, const char *name, short mode)
3048 {
3049     TRACE("(%p %p %d)\n", this, name, mode);
3050     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3051 }
3052
3053 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
3054 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
3055 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode, 12)
3056 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode(basic_filebuf_wchar *this, const char *name, int mode)
3057 {
3058     TRACE("(%p %p %d)\n", this, name, mode);
3059     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3060 }
3061
3062 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3063 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3064 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3065 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3066 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
3067 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
3068 {
3069     char buf[8], *dyn_buf, *to_next;
3070     wchar_t ch = c;
3071     const wchar_t *from_next;
3072     int max_size;
3073     unsigned short ret;
3074
3075
3076     TRACE("(%p %d)\n", this, c);
3077
3078     if(!basic_filebuf_wchar_is_open(this))
3079         return WEOF;
3080     if(c == WEOF)
3081         return !c;
3082
3083     if(!this->cvt)
3084         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3085
3086     from_next = &ch;
3087     do {
3088         ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3089                 &from_next, buf, buf+sizeof(buf), &to_next);
3090
3091         switch(ret) {
3092         case CODECVT_partial:
3093             if(to_next == buf)
3094                 break;
3095             /* fall through */
3096         case CODECVT_ok:
3097             if(!fwrite(buf, to_next-buf, 1, this->file))
3098                 return WEOF;
3099             if(ret == CODECVT_partial)
3100                 continue;
3101             return c;
3102         case CODECVT_noconv:
3103             return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3104         default:
3105             return WEOF;
3106         }
3107
3108         break;
3109     } while(1);
3110
3111     max_size = codecvt_base_max_length(&this->cvt->base);
3112     dyn_buf = malloc(max_size);
3113     if(!dyn_buf)
3114         return WEOF;
3115
3116     ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3117             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
3118
3119     switch(ret) {
3120     case CODECVT_ok:
3121         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
3122         free(dyn_buf);
3123         return ret ? c : WEOF;
3124     case CODECVT_partial:
3125         ERR("buffer should be big enough to store all output\n");
3126         /* fall through */
3127     default:
3128         free(dyn_buf);
3129         return WEOF;
3130     }
3131 }
3132
3133 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3134 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3135 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3136 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3137 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
3138 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
3139 {
3140     TRACE("(%p %d)\n", this, c);
3141
3142     if(!basic_filebuf_wchar_is_open(this))
3143         return WEOF;
3144
3145     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
3146             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==(wchar_t)c)) {
3147         basic_streambuf_wchar__Gndec(&this->base);
3148         return c==WEOF ? !c : c;
3149     }else if(c!=WEOF && !this->cvt) {
3150         return ungetwc(c, this->file);
3151     }else if(c!=WEOF && basic_streambuf_wchar_gptr(&this->base)!=&this->putback) {
3152         this->putback = c;
3153         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback, &this->putback+1);
3154         return c;
3155     }
3156
3157     return WEOF;
3158 }
3159
3160 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3161 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3162 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3163 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3164 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
3165 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
3166 {
3167     wchar_t ch, *to_next;
3168     char buf[128];
3169     const char *buf_next;
3170     int c, i;
3171
3172     TRACE("(%p)\n", this);
3173
3174     if(!basic_filebuf_wchar_is_open(this))
3175         return WEOF;
3176
3177     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3178         return *basic_streambuf_wchar__Gninc(&this->base);
3179
3180     if(!this->cvt)
3181         return fgetwc(this->file);
3182
3183     buf_next = buf;
3184     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
3185         if((c = fgetc(this->file)) == EOF)
3186             return WEOF;
3187         buf[i] = c;
3188
3189         switch(codecvt_wchar_in(this->cvt, &this->state, buf_next,
3190                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
3191         case CODECVT_partial:
3192         case CODECVT_ok:
3193             if(to_next == &ch)
3194                 continue;
3195
3196             for(i--; i>=buf_next-buf; i--)
3197                 ungetc(buf[i], this->file);
3198             return ch;
3199         case CODECVT_noconv:
3200             if(i+1 < sizeof(wchar_t))
3201                 continue;
3202
3203             memcpy(&ch, buf, sizeof(wchar_t));
3204             return ch;
3205         default:
3206             return WEOF;
3207         }
3208     }
3209
3210     FIXME("buffer is too small\n");
3211     return WEOF;
3212 }
3213
3214 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3215 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3216 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3217 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3218 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
3219 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
3220 {
3221     unsigned short ret;
3222
3223     TRACE("(%p)\n", this);
3224
3225     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3226         return *basic_streambuf_wchar_gptr(&this->base);
3227
3228     ret = call_basic_streambuf_wchar_uflow(&this->base);
3229     if(ret != WEOF)
3230         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
3231     return ret;
3232 }
3233
3234 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3235 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3236 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3237 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3238 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 20)
3239 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
3240         fpos_int *ret, streamoff off, int way, int mode)
3241 {
3242     fpos_t pos;
3243
3244     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3245
3246     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback) {
3247         if(way == SEEKDIR_cur)
3248             off -= sizeof(wchar_t);
3249
3250         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3251     }
3252
3253     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3254             || fseek(this->file, off, way)) {
3255         ret->off = 0;
3256         ret->pos = -1;
3257         ret->state = 0;
3258         return ret;
3259     }
3260
3261     fgetpos(this->file, &pos);
3262     ret->off = 0;
3263     ret->pos = pos;
3264     ret->state = this->state;
3265     return ret;
3266 }
3267
3268 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3269 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3270 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3271 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3272 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
3273 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
3274         fpos_int *ret, fpos_int pos, int mode)
3275 {
3276     fpos_t fpos;
3277
3278     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3279
3280     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3281             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
3282             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
3283         ret->off = 0;
3284         ret->pos = -1;
3285         ret->state = 0;
3286         return ret;
3287     }
3288
3289     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback)
3290         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3291
3292     fgetpos(this->file, &fpos);
3293     ret->off = 0;
3294     ret->pos = fpos;
3295     ret->state = this->state;
3296     return ret;
3297 }
3298
3299 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
3300 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
3301 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 12)
3302 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3303 {
3304     TRACE("(%p %p %ld)\n", this, buf, count);
3305
3306     if(!basic_filebuf_wchar_is_open(this))
3307         return NULL;
3308
3309     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3310         return NULL;
3311
3312     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
3313     return &this->base;
3314 }
3315
3316 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
3317 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
3318 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 12)
3319 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3320 {
3321     TRACE("(%p %p %ld)\n", this, buf, count);
3322
3323     if(!basic_filebuf_wchar_is_open(this))
3324         return NULL;
3325
3326     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3327         return NULL;
3328
3329     basic_filebuf_short__Init(this, this->file, INITFL_open);
3330     return &this->base;
3331 }
3332
3333 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
3334 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
3335 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
3336 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
3337 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
3338 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
3339 {
3340     TRACE("(%p)\n", this);
3341
3342     if(!basic_filebuf_wchar_is_open(this))
3343         return 0;
3344
3345     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
3346         return 0;
3347     return fflush(this->file);
3348 }
3349
3350 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
3351 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
3352 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_imbue, 8)
3353 void __thiscall basic_filebuf_wchar_imbue(basic_filebuf_wchar *this, const locale *loc)
3354 {
3355     TRACE("(%p %p)\n", this, loc);
3356     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(loc));
3357 }
3358
3359 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
3360 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
3361 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_imbue, 8)
3362 void __thiscall basic_filebuf_short_imbue(basic_filebuf_wchar *this, const locale *loc)
3363 {
3364     TRACE("(%p %p)\n", this, loc);
3365     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(loc));
3366 }
3367
3368 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3369 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3370 static int basic_stringbuf_char__Getstate(basic_stringbuf_char *this, IOSB_openmode mode)
3371 {
3372     int state = 0;
3373
3374     if(!(mode & OPENMODE_in))
3375         state |= STRINGBUF_no_read;
3376
3377     if(!(mode & OPENMODE_out))
3378         state |= STRINGBUF_no_write;
3379
3380     if(mode & OPENMODE_ate)
3381         state |= STRINGBUF_at_end;
3382
3383     if(mode & OPENMODE_app)
3384         state |= STRINGBUF_append;
3385
3386     return state;
3387 }
3388
3389 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXPBDIH@Z */
3390 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXPEBD_KH@Z */
3391 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Init, 16)
3392 void __thiscall basic_stringbuf_char__Init(basic_stringbuf_char *this, const char *str, MSVCP_size_t count, int state)
3393 {
3394     TRACE("(%p, %p, %ld, %d)\n", this, str, count, state);
3395
3396     basic_streambuf_char__Init_empty(&this->base);
3397
3398     this->state = state;
3399     this->seekhigh = NULL;
3400
3401     if(count && str) {
3402         char *buf = MSVCRT_operator_new(count);
3403         if(!buf) {
3404             ERR("Out of memory\n");
3405             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3406         }
3407
3408         memcpy(buf, str, count);
3409         this->seekhigh = buf + count;
3410
3411         this->state |= STRINGBUF_allocated;
3412
3413         if(!(state & STRINGBUF_no_read))
3414             basic_streambuf_char_setg(&this->base, buf, buf, buf + count);
3415
3416         if(!(state & STRINGBUF_no_write)) {
3417             basic_streambuf_char_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3418
3419             if(!basic_streambuf_char_gptr(&this->base))
3420                 basic_streambuf_char_setg(&this->base, buf, 0, buf);
3421         }
3422     }
3423 }
3424
3425 /* ??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 */
3426 /* ??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 */
3427 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_str, 12)
3428 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_str(basic_stringbuf_char *this,
3429         const basic_string_char *str, IOSB_openmode mode)
3430 {
3431     TRACE("(%p %p %d)\n", this, str, mode);
3432
3433     basic_streambuf_char_ctor(&this->base);
3434     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3435
3436     basic_stringbuf_char__Init(this, basic_string_char_c_str(str),
3437             str->size, basic_stringbuf_char__Getstate(this, mode));
3438     return this;
3439 }
3440
3441 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
3442 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
3443 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_mode, 8)
3444 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_mode(
3445         basic_stringbuf_char *this, IOSB_openmode mode)
3446 {
3447     TRACE("(%p %d)\n", this, mode);
3448
3449     basic_streambuf_char_ctor(&this->base);
3450     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3451
3452     basic_stringbuf_char__Init(this, NULL, 0, basic_stringbuf_char__Getstate(this, mode));
3453     return this;
3454 }
3455
3456 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
3457 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
3458 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor, 4)
3459 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor(basic_stringbuf_char *this)
3460 {
3461     return basic_stringbuf_char_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3462 }
3463
3464 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXXZ */
3465 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXXZ */
3466 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Tidy, 4)
3467 void __thiscall basic_stringbuf_char__Tidy(basic_stringbuf_char *this)
3468 {
3469     TRACE("(%p)\n", this);
3470
3471     if(this->state & STRINGBUF_allocated) {
3472         MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
3473         this->seekhigh = NULL;
3474         this->state &= ~STRINGBUF_allocated;
3475     }
3476
3477     basic_streambuf_char__Init_empty(&this->base);
3478 }
3479
3480 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
3481 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
3482 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_dtor, 4)
3483 void __thiscall basic_stringbuf_char_dtor(basic_stringbuf_char *this)
3484 {
3485     TRACE("(%p)\n", this);
3486
3487     basic_stringbuf_char__Tidy(this);
3488     basic_streambuf_char_dtor(&this->base);
3489 }
3490
3491 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_vector_dtor, 8)
3492 basic_stringbuf_char* __thiscall basic_stringbuf_char_vector_dtor(basic_stringbuf_char *this, unsigned int flags)
3493 {
3494     TRACE("(%p %x)\n", this, flags);
3495
3496     if(flags & 2) {
3497         /* we have an array, with the number of elements stored before the first object */
3498         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3499
3500         for (i = *ptr - 1; i >= 0; i--)
3501             basic_stringbuf_char_dtor(this+i);
3502
3503         MSVCRT_operator_delete(ptr);
3504     }else {
3505         basic_stringbuf_char_dtor(this);
3506
3507         if(flags & 1)
3508             MSVCRT_operator_delete(this);
3509     }
3510
3511     return this;
3512 }
3513
3514 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3515 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3516 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_overflow, 8)
3517 int __thiscall basic_stringbuf_char_overflow(basic_stringbuf_char *this, int meta)
3518 {
3519     MSVCP_size_t oldsize, size;
3520     char *ptr, *buf;
3521
3522     TRACE("(%p %x)\n", this, meta);
3523
3524     if(meta == EOF)
3525         return !EOF;
3526     if(this->state & STRINGBUF_no_write)
3527         return EOF;
3528
3529     ptr = basic_streambuf_char_pptr(&this->base);
3530     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3531         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
3532                 this->seekhigh, basic_streambuf_char_epptr(&this->base));
3533
3534     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
3535         return (*basic_streambuf_char__Pninc(&this->base) = meta);
3536
3537     oldsize = (ptr ? basic_streambuf_char_epptr(&this->base)-basic_streambuf_char_eback(&this->base): 0);
3538     size = oldsize|0xf;
3539     size += size/2;
3540     buf = MSVCRT_operator_new(size);
3541     if(!buf) {
3542         ERR("Out of memory\n");
3543         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3544     }
3545
3546     if(!oldsize) {
3547         this->seekhigh = buf;
3548         basic_streambuf_char_setp(&this->base, buf, buf+size);
3549         if(this->state & STRINGBUF_no_read)
3550             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3551         else
3552             basic_streambuf_char_setg(&this->base, buf, buf, buf+1);
3553
3554         this->state |= STRINGBUF_allocated;
3555     }else {
3556         ptr = basic_streambuf_char_eback(&this->base);
3557         memcpy(buf, ptr, oldsize);
3558
3559         this->seekhigh = buf+(this->seekhigh-ptr);
3560         basic_streambuf_char_setp_next(&this->base, buf,
3561                 buf+(basic_streambuf_char_pptr(&this->base)-ptr), buf+size);
3562         if(this->state & STRINGBUF_no_read)
3563             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3564         else
3565             basic_streambuf_char_setg(&this->base, buf,
3566                     buf+(basic_streambuf_char_gptr(&this->base)-ptr),
3567                     basic_streambuf_char_pptr(&this->base)+1);
3568
3569         MSVCRT_operator_delete(ptr);
3570     }
3571
3572     return (*basic_streambuf_char__Pninc(&this->base) = meta);
3573 }
3574
3575 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3576 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3577 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_pbackfail, 8)
3578 int __thiscall basic_stringbuf_char_pbackfail(basic_stringbuf_char *this, int c)
3579 {
3580     char *cur;
3581
3582     TRACE("(%p %x)\n", this, c);
3583
3584     cur = basic_streambuf_char_gptr(&this->base);
3585     if(!cur || cur==basic_streambuf_char_eback(&this->base)
3586             || (c!=EOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3587         return EOF;
3588
3589     if(c != EOF)
3590         cur[-1] = c;
3591     basic_streambuf_char_gbump(&this->base, -1);
3592     return c==EOF ? !EOF : c;
3593 }
3594
3595 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHXZ */
3596 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHXZ */
3597 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_underflow, 4)
3598 int __thiscall basic_stringbuf_char_underflow(basic_stringbuf_char *this)
3599 {
3600     char *ptr, *cur;
3601
3602     TRACE("(%p)\n", this);
3603
3604     cur = basic_streambuf_char_gptr(&this->base);
3605     if(!cur || this->state&STRINGBUF_no_read)
3606         return EOF;
3607
3608     ptr  = basic_streambuf_char_pptr(&this->base);
3609     if(this->seekhigh < ptr)
3610         this->seekhigh = ptr;
3611
3612     ptr = basic_streambuf_char_egptr(&this->base);
3613     if(this->seekhigh > ptr)
3614         basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base), cur, this->seekhigh);
3615
3616     if(cur < this->seekhigh)
3617         return *cur;
3618     return EOF;
3619 }
3620
3621 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3622 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3623 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekoff, 20)
3624 fpos_int* __thiscall basic_stringbuf_char_seekoff(basic_stringbuf_char *this,
3625         fpos_int *ret, streamoff off, int way, int mode)
3626 {
3627     char *beg, *cur_r, *cur_w;
3628
3629     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3630
3631     cur_w = basic_streambuf_char_pptr(&this->base);
3632     if(cur_w > this->seekhigh)
3633         this->seekhigh = cur_w;
3634
3635     ret->off = 0;
3636     ret->state = 0;
3637
3638     beg = basic_streambuf_char_eback(&this->base);
3639     cur_r = basic_streambuf_char_gptr(&this->base);
3640     if((mode & OPENMODE_in) && cur_r) {
3641         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3642             off += cur_r-beg;
3643         else if(way == SEEKDIR_end)
3644             off += this->seekhigh-beg;
3645         else if(way != SEEKDIR_beg)
3646             off = -1;
3647
3648         if(off<0 || off>this->seekhigh-beg) {
3649             off = -1;
3650         }else {
3651             basic_streambuf_char_gbump(&this->base, beg-cur_r+off);
3652             if((mode & OPENMODE_out) && cur_w) {
3653                 basic_streambuf_char_setp_next(&this->base, beg,
3654                         basic_streambuf_char_gptr(&this->base),
3655                         basic_streambuf_char_epptr(&this->base));
3656             }
3657         }
3658     }else if((mode & OPENMODE_out) && cur_w) {
3659         if(way == SEEKDIR_cur)
3660             off += cur_w-beg;
3661         else if(way == SEEKDIR_end)
3662             off += this->seekhigh-beg;
3663         else if(way != SEEKDIR_beg)
3664             off = -1;
3665
3666         if(off<0 || off>this->seekhigh-beg)
3667             off = -1;
3668         else
3669             basic_streambuf_char_pbump(&this->base, beg-cur_w+off);
3670     }else {
3671         off = -1;
3672     }
3673
3674     ret->pos = off;
3675     return ret;
3676 }
3677
3678 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3679 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3680 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekpos, 36)
3681 fpos_int* __thiscall basic_stringbuf_char_seekpos(basic_stringbuf_char *this,
3682         fpos_int *ret, fpos_int pos, int mode)
3683 {
3684     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3685
3686     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
3687         *ret = pos;
3688         return ret;
3689     }
3690
3691     return basic_stringbuf_char_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
3692 }
3693
3694 /* ?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 */
3695 /* ?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 */
3696 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_set, 8)
3697 void __thiscall basic_stringbuf_char_str_set(basic_stringbuf_char *this, const basic_string_char *str)
3698 {
3699     TRACE("(%p %p)\n", this, str);
3700
3701     basic_stringbuf_char__Tidy(this);
3702     basic_stringbuf_char__Init(this, basic_string_char_c_str(str), str->size, this->state);
3703 }
3704
3705 /* ?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 */
3706 /* ?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 */
3707 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_get, 8)
3708 basic_string_char* __thiscall basic_stringbuf_char_str_get(const basic_stringbuf_char *this, basic_string_char *ret)
3709 {
3710     char *ptr;
3711
3712     TRACE("(%p)\n", this);
3713
3714     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_char_pptr(&this->base)) {
3715         char *pptr;
3716
3717         ptr = basic_streambuf_char_pbase(&this->base);
3718         pptr = basic_streambuf_char_pptr(&this->base);
3719
3720         return basic_string_char_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
3721     }
3722
3723     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_char_gptr(&this->base)) {
3724         ptr = basic_streambuf_char_eback(&this->base);
3725         return basic_string_char_ctor_cstr_len(ret, ptr, basic_streambuf_char_egptr(&this->base) - ptr);
3726     }
3727
3728     return basic_string_char_ctor(ret);
3729 }
3730
3731 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAEHH@Z */
3732 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAAHH@Z */
3733 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3734 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3735 static int basic_stringbuf_wchar__Getstate(basic_stringbuf_wchar *this, IOSB_openmode mode)
3736 {
3737     int state = 0;
3738
3739     if(!(mode & OPENMODE_in))
3740         state |= STRINGBUF_no_read;
3741
3742     if(!(mode & OPENMODE_out))
3743         state |= STRINGBUF_no_write;
3744
3745     if(mode & OPENMODE_ate)
3746         state |= STRINGBUF_at_end;
3747
3748     if(mode & OPENMODE_app)
3749         state |= STRINGBUF_append;
3750
3751     return state;
3752 }
3753
3754 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXPB_WIH@Z */
3755 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXPEB_W_KH@Z */
3756 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXPBGIH@Z */
3757 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXPEBG_KH@Z */
3758 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Init, 16)
3759 void __thiscall basic_stringbuf_wchar__Init(basic_stringbuf_wchar *this, const wchar_t *str, MSVCP_size_t count, int state)
3760 {
3761     TRACE("(%p, %p, %lu, %d)\n", this, str, count, state);
3762
3763     basic_streambuf_wchar__Init_empty(&this->base);
3764
3765     this->state = state;
3766     this->seekhigh = NULL;
3767
3768     if(count && str) {
3769         wchar_t *buf = MSVCRT_operator_new(count*sizeof(wchar_t));
3770         if(!buf) {
3771             ERR("Out of memory\n");
3772             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3773         }
3774
3775         memcpy(buf, str, count*sizeof(wchar_t));
3776         this->seekhigh = buf + count;
3777
3778         this->state |= STRINGBUF_allocated;
3779
3780         if(!(state & STRINGBUF_no_read))
3781             basic_streambuf_wchar_setg(&this->base, buf, buf, buf + count);
3782
3783         if(!(state & STRINGBUF_no_write)) {
3784             basic_streambuf_wchar_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3785
3786             if(!basic_streambuf_wchar_gptr(&this->base))
3787                 basic_streambuf_wchar_setg(&this->base, buf, 0, buf);
3788         }
3789     }
3790 }
3791
3792 /* ??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 */
3793 /* ??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 */
3794 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_str(basic_stringbuf_wchar *this,
3795         const basic_string_wchar *str, IOSB_openmode mode)
3796 {
3797     TRACE("(%p %p %d)\n", this, str, mode);
3798
3799     basic_streambuf_wchar_ctor(&this->base);
3800     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3801
3802     basic_stringbuf_wchar__Init(this, basic_string_wchar_c_str(str),
3803             str->size, basic_stringbuf_wchar__Getstate(this, mode));
3804     return this;
3805 }
3806
3807 /* ??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 */
3808 /* ??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 */
3809 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_str, 12)
3810 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_str(basic_stringbuf_wchar *this,
3811         const basic_string_wchar *str, IOSB_openmode mode)
3812 {
3813     basic_stringbuf_wchar_ctor_str(this, str, mode);
3814     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3815     return this;
3816 }
3817
3818 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
3819 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
3820 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_mode(
3821         basic_stringbuf_wchar *this, IOSB_openmode mode)
3822 {
3823     TRACE("(%p %d)\n", this, mode);
3824
3825     basic_streambuf_wchar_ctor(&this->base);
3826     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3827
3828     basic_stringbuf_wchar__Init(this, NULL, 0, basic_stringbuf_wchar__Getstate(this, mode));
3829     return this;
3830 }
3831
3832 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
3833 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
3834 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_mode, 8)
3835 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_mode(
3836         basic_stringbuf_wchar *this, IOSB_openmode mode)
3837 {
3838     basic_stringbuf_wchar_ctor_mode(this, mode);
3839     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3840     return this;
3841 }
3842
3843 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
3844 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
3845 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor, 4)
3846 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor(basic_stringbuf_wchar *this)
3847 {
3848     return basic_stringbuf_short_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3849 }
3850
3851 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXXZ */
3852 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXXZ */
3853 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXXZ */
3854 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXXZ */
3855 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Tidy, 4)
3856 void __thiscall basic_stringbuf_wchar__Tidy(basic_stringbuf_wchar *this)
3857 {
3858     TRACE("(%p)\n", this);
3859
3860     if(this->state & STRINGBUF_allocated) {
3861         MSVCRT_operator_delete(basic_streambuf_wchar_eback(&this->base));
3862         this->seekhigh = NULL;
3863         this->state &= ~STRINGBUF_allocated;
3864     }
3865
3866     basic_streambuf_wchar__Init_empty(&this->base);
3867 }
3868
3869 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
3870 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
3871 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
3872 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
3873 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_dtor, 4)
3874 void __thiscall basic_stringbuf_wchar_dtor(basic_stringbuf_wchar *this)
3875 {
3876     TRACE("(%p)\n", this);
3877
3878     basic_stringbuf_wchar__Tidy(this);
3879     basic_streambuf_wchar_dtor(&this->base);
3880 }
3881
3882 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_vector_dtor, 8)
3883 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_vector_dtor(basic_stringbuf_wchar *this, unsigned int flags)
3884 {
3885     TRACE("(%p %x)\n", this, flags);
3886
3887     if(flags & 2) {
3888         /* we have an array, with the number of elements stored before the first object */
3889         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3890
3891         for (i = *ptr - 1; i >= 0; i--)
3892             basic_stringbuf_wchar_dtor(this+i);
3893
3894         MSVCRT_operator_delete(ptr);
3895     }else {
3896         basic_stringbuf_wchar_dtor(this);
3897
3898         if(flags & 1)
3899             MSVCRT_operator_delete(this);
3900     }
3901
3902     return this;
3903 }
3904
3905 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
3906 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
3907 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
3908 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
3909 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_overflow, 8)
3910 unsigned short __thiscall basic_stringbuf_wchar_overflow(basic_stringbuf_wchar *this, unsigned short meta)
3911 {
3912     MSVCP_size_t oldsize, size;
3913     wchar_t *ptr, *buf;
3914
3915     TRACE("(%p %x)\n", this, meta);
3916
3917     if(meta == WEOF)
3918         return !WEOF;
3919     if(this->state & STRINGBUF_no_write)
3920         return WEOF;
3921
3922     ptr = basic_streambuf_wchar_pptr(&this->base);
3923     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3924         basic_streambuf_wchar_setp_next(&this->base, basic_streambuf_wchar_pbase(&this->base),
3925                 this->seekhigh, basic_streambuf_wchar_epptr(&this->base));
3926
3927     if(ptr && ptr<basic_streambuf_wchar_epptr(&this->base))
3928         return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
3929
3930     oldsize = (ptr ? basic_streambuf_wchar_epptr(&this->base)-basic_streambuf_wchar_eback(&this->base): 0);
3931     size = oldsize|0xf;
3932     size += size/2;
3933     buf = MSVCRT_operator_new(size*sizeof(wchar_t));
3934     if(!buf) {
3935         ERR("Out of memory\n");
3936         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3937     }
3938
3939     if(!oldsize) {
3940         this->seekhigh = buf;
3941         basic_streambuf_wchar_setp(&this->base, buf, buf+size);
3942         if(this->state & STRINGBUF_no_read)
3943             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
3944         else
3945             basic_streambuf_wchar_setg(&this->base, buf, buf, buf+1);
3946
3947         this->state |= STRINGBUF_allocated;
3948     }else {
3949         ptr = basic_streambuf_wchar_eback(&this->base);
3950         memcpy(buf, ptr, oldsize*sizeof(wchar_t));
3951
3952         this->seekhigh = buf+(this->seekhigh-ptr);
3953         basic_streambuf_wchar_setp_next(&this->base, buf,
3954                 buf+(basic_streambuf_wchar_pptr(&this->base)-ptr), buf+size);
3955         if(this->state & STRINGBUF_no_read)
3956             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
3957         else
3958             basic_streambuf_wchar_setg(&this->base, buf,
3959                     buf+(basic_streambuf_wchar_gptr(&this->base)-ptr),
3960                     basic_streambuf_wchar_pptr(&this->base)+1);
3961
3962         MSVCRT_operator_delete(ptr);
3963     }
3964
3965     return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
3966 }
3967
3968 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
3969 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
3970 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
3971 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
3972 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_pbackfail, 8)
3973 unsigned short __thiscall basic_stringbuf_wchar_pbackfail(basic_stringbuf_wchar *this, unsigned short c)
3974 {
3975     wchar_t *cur;
3976
3977     TRACE("(%p %x)\n", this, c);
3978
3979     cur = basic_streambuf_wchar_gptr(&this->base);
3980     if(!cur || cur==basic_streambuf_wchar_eback(&this->base)
3981             || (c!=WEOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3982         return WEOF;
3983
3984     if(c != WEOF)
3985         cur[-1] = c;
3986     basic_streambuf_wchar_gbump(&this->base, -1);
3987     return c==WEOF ? !WEOF : c;
3988 }
3989
3990 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGXZ */
3991 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGXZ */
3992 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGXZ */
3993 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGXZ */
3994 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_underflow, 4)
3995 unsigned short __thiscall basic_stringbuf_wchar_underflow(basic_stringbuf_wchar *this)
3996 {
3997     wchar_t *ptr, *cur;
3998
3999     TRACE("(%p)\n", this);
4000
4001     cur = basic_streambuf_wchar_gptr(&this->base);
4002     if(!cur || this->state&STRINGBUF_no_read)
4003         return WEOF;
4004
4005     ptr  = basic_streambuf_wchar_pptr(&this->base);
4006     if(this->seekhigh < ptr)
4007         this->seekhigh = ptr;
4008
4009     ptr = basic_streambuf_wchar_egptr(&this->base);
4010     if(this->seekhigh > ptr)
4011         basic_streambuf_wchar_setg(&this->base, basic_streambuf_wchar_eback(&this->base), cur, this->seekhigh);
4012
4013     if(cur < this->seekhigh)
4014         return *cur;
4015     return WEOF;
4016 }
4017
4018 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4019 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4020 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4021 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4022 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekoff, 20)
4023 fpos_int* __thiscall basic_stringbuf_wchar_seekoff(basic_stringbuf_wchar *this,
4024         fpos_int *ret, streamoff off, int way, int mode)
4025 {
4026     wchar_t *beg, *cur_r, *cur_w;
4027
4028     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
4029
4030     cur_w = basic_streambuf_wchar_pptr(&this->base);
4031     if(cur_w > this->seekhigh)
4032         this->seekhigh = cur_w;
4033
4034     ret->off = 0;
4035     ret->state = 0;
4036
4037     beg = basic_streambuf_wchar_eback(&this->base);
4038     cur_r = basic_streambuf_wchar_gptr(&this->base);
4039     if((mode & OPENMODE_in) && cur_r) {
4040         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
4041             off += cur_r-beg;
4042         else if(way == SEEKDIR_end)
4043             off += this->seekhigh-beg;
4044         else if(way != SEEKDIR_beg)
4045             off = -1;
4046
4047         if(off<0 || off>this->seekhigh-beg) {
4048             off = -1;
4049         }else {
4050             basic_streambuf_wchar_gbump(&this->base, beg-cur_r+off);
4051             if((mode & OPENMODE_out) && cur_w) {
4052                 basic_streambuf_wchar_setp_next(&this->base, beg,
4053                         basic_streambuf_wchar_gptr(&this->base),
4054                         basic_streambuf_wchar_epptr(&this->base));
4055             }
4056         }
4057     }else if((mode & OPENMODE_out) && cur_w) {
4058         if(way == SEEKDIR_cur)
4059             off += cur_w-beg;
4060         else if(way == SEEKDIR_end)
4061             off += this->seekhigh-beg;
4062         else if(way != SEEKDIR_beg)
4063             off = -1;
4064
4065         if(off<0 || off>this->seekhigh-beg)
4066             off = -1;
4067         else
4068             basic_streambuf_wchar_pbump(&this->base, beg-cur_w+off);
4069     }else {
4070         off = -1;
4071     }
4072
4073     ret->pos = off;
4074     return ret;
4075 }
4076
4077 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4078 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4079 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4080 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4081 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekpos, 36)
4082 fpos_int* __thiscall basic_stringbuf_wchar_seekpos(basic_stringbuf_wchar *this,
4083         fpos_int *ret, fpos_int pos, int mode)
4084 {
4085     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
4086
4087     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
4088         *ret = pos;
4089         return ret;
4090     }
4091
4092     return basic_stringbuf_wchar_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
4093 }
4094
4095 /* ?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 */
4096 /* ?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 */
4097 /* ?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 */
4098 /* ?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 */
4099 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_set, 8)
4100 void __thiscall basic_stringbuf_wchar_str_set(basic_stringbuf_wchar *this, const basic_string_wchar *str)
4101 {
4102     TRACE("(%p %p)\n", this, str);
4103
4104     basic_stringbuf_wchar__Tidy(this);
4105     basic_stringbuf_wchar__Init(this, basic_string_wchar_c_str(str), str->size, this->state);
4106 }
4107
4108 /* ?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 */
4109 /* ?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 */
4110 /* ?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 */
4111 /* ?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 */
4112 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_get, 8)
4113 basic_string_wchar* __thiscall basic_stringbuf_wchar_str_get(const basic_stringbuf_wchar *this, basic_string_wchar *ret)
4114 {
4115     wchar_t *ptr;
4116
4117     TRACE("(%p)\n", this);
4118
4119     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_wchar_pptr(&this->base)) {
4120         wchar_t *pptr;
4121
4122         ptr = basic_streambuf_wchar_pbase(&this->base);
4123         pptr = basic_streambuf_wchar_pptr(&this->base);
4124
4125         return basic_string_wchar_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
4126     }
4127
4128     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_wchar_gptr(&this->base)) {
4129         ptr = basic_streambuf_wchar_eback(&this->base);
4130         return basic_string_wchar_ctor_cstr_len(ret, ptr, basic_streambuf_wchar_egptr(&this->base) - ptr);
4131     }
4132
4133     return basic_string_wchar_ctor(ret);
4134 }
4135
4136 /* ??0ios_base@std@@IAE@XZ */
4137 /* ??0ios_base@std@@IEAA@XZ */
4138 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
4139 ios_base* __thiscall ios_base_ctor(ios_base *this)
4140 {
4141     TRACE("(%p)\n", this);
4142     this->vtable = &MSVCP_ios_base_vtable;
4143     return this;
4144 }
4145
4146 /* ??0ios_base@std@@QAE@ABV01@@Z */
4147 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
4148 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
4149 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
4150 {
4151     TRACE("(%p %p)\n", this, copy);
4152     *this = *copy;
4153     this->vtable = &MSVCP_ios_base_vtable;
4154     return this;
4155 }
4156
4157 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
4158 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
4159 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
4160 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
4161 {
4162     IOS_BASE_fnarray *cur;
4163
4164     TRACE("(%p %x)\n", this, event);
4165
4166     for(cur=this->calls; cur; cur=cur->next)
4167         cur->event_handler(event, this, cur->index);
4168 }
4169
4170 /* ?_Tidy@ios_base@std@@AAAXXZ */
4171 /* ?_Tidy@ios_base@std@@AEAAXXZ */
4172 void CDECL ios_base_Tidy(ios_base *this)
4173 {
4174     IOS_BASE_iosarray *arr_cur, *arr_next;
4175     IOS_BASE_fnarray *event_cur, *event_next;
4176
4177     TRACE("(%p)\n", this);
4178
4179     ios_base_Callfns(this, EVENT_erase_event);
4180
4181     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
4182         arr_next = arr_cur->next;
4183         MSVCRT_operator_delete(arr_cur);
4184     }
4185     this->arr = NULL;
4186
4187     for(event_cur=this->calls; event_cur; event_cur=event_next) {
4188         event_next = event_cur->next;
4189         MSVCRT_operator_delete(event_cur);
4190     }
4191     this->calls = NULL;
4192 }
4193
4194 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
4195 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
4196 static void ios_base_Ios_base_dtor(ios_base *obj)
4197 {
4198     TRACE("(%p)\n", obj);
4199     if(obj->loc) {
4200         locale_dtor(obj->loc);
4201         MSVCRT_operator_delete(obj->loc);
4202     }
4203     ios_base_Tidy(obj);
4204 }
4205
4206 /* ??1ios_base@std@@UAE@XZ */
4207 /* ??1ios_base@std@@UEAA@XZ */
4208 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
4209 void __thiscall ios_base_dtor(ios_base *this)
4210 {
4211     ios_base_Ios_base_dtor(this);
4212 }
4213
4214 DEFINE_THISCALL_WRAPPER(ios_base_vector_dtor, 8)
4215 ios_base* __thiscall ios_base_vector_dtor(ios_base *this, unsigned int flags)
4216 {
4217     TRACE("(%p %x)\n", this, flags);
4218     if(flags & 2) {
4219         /* we have an array, with the number of elements stored before the first object */
4220         INT_PTR i, *ptr = (INT_PTR *)this-1;
4221
4222         for(i=*ptr-1; i>=0; i--)
4223             ios_base_dtor(this+i);
4224         MSVCRT_operator_delete(ptr);
4225     } else {
4226         ios_base_dtor(this);
4227         if(flags & 1)
4228             MSVCRT_operator_delete(this);
4229     }
4230
4231     return this;
4232 }
4233
4234 DEFINE_THISCALL_WRAPPER(iosb_vector_dtor, 8)
4235 void* __thiscall iosb_vector_dtor(void *this, unsigned int flags)
4236 {
4237     TRACE("(%p %x)\n", this, flags);
4238     if(flags & 2) {
4239         INT_PTR *ptr = (INT_PTR *)this-1;
4240         MSVCRT_operator_delete(ptr);
4241     } else {
4242         if(flags & 1)
4243             MSVCRT_operator_delete(this);
4244     }
4245
4246     return this;
4247 }
4248
4249 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
4250 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
4251 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
4252 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
4253 {
4254     IOS_BASE_iosarray *p;
4255
4256     TRACE("(%p %d)\n", this, index);
4257
4258     for(p=this->arr; p; p=p->next) {
4259         if(p->index == index)
4260             return p;
4261     }
4262
4263     for(p=this->arr; p; p=p->next) {
4264         if(!p->long_val && !p->ptr_val) {
4265             p->index = index;
4266             return p;
4267         }
4268     }
4269
4270     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
4271     p->next = this->arr;
4272     p->index = index;
4273     p->long_val = 0;
4274     p->ptr_val = NULL;
4275     this->arr = p;
4276     return p;
4277 }
4278
4279 /* ?iword@ios_base@std@@QAEAAJH@Z */
4280 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
4281 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
4282 LONG* __thiscall ios_base_iword(ios_base *this, int index)
4283 {
4284     TRACE("(%p %d)\n", this, index);
4285     return &ios_base_Findarr(this, index)->long_val;
4286 }
4287
4288 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
4289 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
4290 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
4291 void** __thiscall ios_base_pword(ios_base *this, int index)
4292 {
4293     TRACE("(%p %d)\n", this, index);
4294     return &ios_base_Findarr(this, index)->ptr_val;
4295 }
4296
4297 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
4298 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
4299 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
4300 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
4301 {
4302     IOS_BASE_fnarray *event;
4303
4304     TRACE("(%p %p %d)\n", this, callback, index);
4305
4306     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
4307     event->next = this->calls;
4308     event->index = index;
4309     event->event_handler = callback;
4310     this->calls = event;
4311 }
4312
4313 /* ?clear@ios_base@std@@QAEXH_N@Z */
4314 /* ?clear@ios_base@std@@QEAAXH_N@Z */
4315 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
4316 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4317 {
4318     TRACE("(%p %x %x)\n", this, state, reraise);
4319
4320     this->state = state & IOSTATE_mask;
4321     if(!(this->state & this->except))
4322         return;
4323
4324     if(reraise)
4325         throw_exception(EXCEPTION_RERAISE, NULL);
4326     else if(this->state & this->except & IOSTATE_eofbit)
4327         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
4328     else if(this->state & this->except & IOSTATE_failbit)
4329         throw_exception(EXCEPTION_FAILURE, "failbit is set");
4330     else if(this->state & this->except & IOSTATE_badbit)
4331         throw_exception(EXCEPTION_FAILURE, "badbit is set");
4332     else if(this->state & this->except & IOSTATE__Hardfail)
4333         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
4334 }
4335
4336 /* ?clear@ios_base@std@@QAEXH@Z */
4337 /* ?clear@ios_base@std@@QEAAXH@Z */
4338 static void ios_base_clear(ios_base *this, IOSB_iostate state)
4339 {
4340     ios_base_clear_reraise(this, state, FALSE);
4341 }
4342
4343 /* ?exceptions@ios_base@std@@QAEXH@Z */
4344 /* ?exceptions@ios_base@std@@QEAAXH@Z */
4345 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
4346 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
4347 {
4348     TRACE("(%p %x)\n", this, state);
4349     this->except = state & IOSTATE_mask;
4350     ios_base_clear(this, this->state);
4351 }
4352
4353 /* ?exceptions@ios_base@std@@QBEHXZ */
4354 /* ?exceptions@ios_base@std@@QEBAHXZ */
4355 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
4356 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
4357 {
4358     TRACE("(%p)\n", this);
4359     return this->except;
4360 }
4361
4362 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
4363 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
4364 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
4365 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
4366 {
4367     TRACE("(%p %p)\n", this, rhs);
4368
4369     if(this != rhs) {
4370         IOS_BASE_iosarray *arr_cur;
4371         IOS_BASE_fnarray *event_cur;
4372
4373         ios_base_Tidy(this);
4374
4375         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
4376             if(arr_cur->long_val)
4377                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
4378             if(arr_cur->ptr_val)
4379                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
4380         }
4381         this->stdstr = rhs->stdstr;
4382         this->fmtfl = rhs->fmtfl;
4383         this->prec = rhs->prec;
4384         this->wide = rhs->wide;
4385         locale_operator_assign(this->loc, rhs->loc);
4386
4387         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
4388             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
4389
4390         ios_base_Callfns(this, EVENT_copyfmt_event);
4391         ios_base_exceptions_set(this, rhs->except);
4392     }
4393
4394     return this;
4395 }
4396
4397 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
4398 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
4399 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
4400 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
4401 {
4402     TRACE("(%p %p)\n", this, right);
4403
4404     if(this != right) {
4405         this->state = right->state;
4406         ios_base_copyfmt(this, right);
4407     }
4408
4409     return this;
4410 }
4411
4412 /* ?fail@ios_base@std@@QBE_NXZ */
4413 /* ?fail@ios_base@std@@QEBA_NXZ */
4414 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
4415 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
4416 {
4417     TRACE("(%p)\n", this);
4418     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
4419 }
4420
4421 /* ??7ios_base@std@@QBE_NXZ */
4422 /* ??7ios_base@std@@QEBA_NXZ */
4423 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
4424 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
4425 {
4426     TRACE("(%p)\n", this);
4427     return ios_base_fail(this);
4428 }
4429
4430 /* ??Bios_base@std@@QBEPAXXZ */
4431 /* ??Bios_base@std@@QEBAPEAXXZ */
4432 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
4433 void* __thiscall ios_base_op_fail(const ios_base *this)
4434 {
4435     TRACE("(%p)\n", this);
4436     return ios_base_fail(this) ? NULL : (void*)this;
4437 }
4438
4439 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
4440 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
4441 static void ios_base_Addstd(ios_base *add)
4442 {
4443     FIXME("(%p) stub\n", add);
4444 }
4445
4446 /* ?_Init@ios_base@std@@IAEXXZ */
4447 /* ?_Init@ios_base@std@@IEAAXXZ */
4448 DEFINE_THISCALL_WRAPPER(ios_base__Init, 4)
4449 void __thiscall ios_base__Init(ios_base *this)
4450 {
4451     TRACE("(%p)\n", this);
4452
4453     this->stdstr = 0;
4454     this->state = this->except = IOSTATE_goodbit;
4455     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
4456     this->prec = 6;
4457     this->wide = 0;
4458     this->arr = NULL;
4459     this->calls = NULL;
4460     this->loc = MSVCRT_operator_new(sizeof(locale));
4461     locale_ctor(this->loc);
4462 }
4463
4464 /* ?bad@ios_base@std@@QBE_NXZ */
4465 /* ?bad@ios_base@std@@QEBA_NXZ */
4466 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
4467 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
4468 {
4469     TRACE("(%p)\n", this);
4470     return (this->state & IOSTATE_badbit) != 0;
4471 }
4472
4473 /* ?eof@ios_base@std@@QBE_NXZ */
4474 /* ?eof@ios_base@std@@QEBA_NXZ */
4475 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
4476 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
4477 {
4478     TRACE("(%p)\n", this);
4479     return (this->state & IOSTATE_eofbit) != 0;
4480 }
4481
4482 /* ?flags@ios_base@std@@QAEHH@Z */
4483 /* ?flags@ios_base@std@@QEAAHH@Z */
4484 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
4485 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
4486 {
4487     IOSB_fmtflags ret = this->fmtfl;
4488
4489     TRACE("(%p %x)\n", this, flags);
4490
4491     this->fmtfl = flags & FMTFLAG_mask;
4492     return ret;
4493 }
4494
4495 /* ?flags@ios_base@std@@QBEHXZ */
4496 /* ?flags@ios_base@std@@QEBAHXZ */
4497 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
4498 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
4499 {
4500     TRACE("(%p)\n", this);
4501     return this->fmtfl;
4502 }
4503
4504 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
4505 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
4506 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
4507 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
4508 {
4509     TRACE("(%p)\n", this);
4510     return locale_copy_ctor(ret, this->loc);
4511 }
4512
4513 /* ?good@ios_base@std@@QBE_NXZ */
4514 /* ?good@ios_base@std@@QEBA_NXZ */
4515 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
4516 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
4517 {
4518     TRACE("(%p)\n", this);
4519     return this->state == IOSTATE_goodbit;
4520 }
4521
4522 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
4523 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
4524 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
4525 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
4526 {
4527     TRACE("(%p %p)\n", this, loc);
4528     *ret = *this->loc;
4529     locale_copy_ctor(this->loc, loc);
4530     return ret;
4531 }
4532
4533 /* ?precision@ios_base@std@@QAEHH@Z */
4534 /* ?precision@ios_base@std@@QEAA_J_J@Z */
4535 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
4536 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
4537 {
4538     streamsize ret = this->prec;
4539
4540     TRACE("(%p %ld)\n", this, precision);
4541
4542     this->prec = precision;
4543     return ret;
4544 }
4545
4546 /* ?precision@ios_base@std@@QBEHXZ */
4547 /* ?precision@ios_base@std@@QEBA_JXZ */
4548 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
4549 streamsize __thiscall ios_base_precision_get(const ios_base *this)
4550 {
4551     TRACE("(%p)\n", this);
4552     return this->prec;
4553 }
4554
4555 /* ?rdstate@ios_base@std@@QBEHXZ */
4556 /* ?rdstate@ios_base@std@@QEBAHXZ */
4557 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
4558 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
4559 {
4560     TRACE("(%p)\n", this);
4561     return this->state;
4562 }
4563
4564 /* ?setf@ios_base@std@@QAEHHH@Z */
4565 /* ?setf@ios_base@std@@QEAAHHH@Z */
4566 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
4567 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
4568 {
4569     IOSB_fmtflags ret = this->fmtfl;
4570
4571     TRACE("(%p %x %x)\n", this, flags, mask);
4572
4573     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
4574     return ret;
4575 }
4576
4577 /* ?setf@ios_base@std@@QAEHH@Z */
4578 /* ?setf@ios_base@std@@QEAAHH@Z */
4579 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
4580 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
4581 {
4582     return ios_base_setf_mask(this, flags, ~0);
4583 }
4584
4585 /* ?setstate@ios_base@std@@QAEXH_N@Z */
4586 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
4587 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
4588 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4589 {
4590     TRACE("(%p %x %x)\n", this, state, reraise);
4591
4592     if(state != IOSTATE_goodbit)
4593         ios_base_clear_reraise(this, this->state | state, reraise);
4594 }
4595
4596 /* ?setstate@ios_base@std@@QAEXH@Z */
4597 /* ?setstate@ios_base@std@@QEAAXH@Z */
4598 static void ios_base_setstate(ios_base *this, IOSB_iostate state)
4599 {
4600     ios_base_setstate_reraise(this, state, FALSE);
4601 }
4602
4603 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
4604 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
4605 {
4606     _Lockit lock;
4607     MSVCP_bool ret;
4608
4609     TRACE("(%x)\n", sync);
4610
4611     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4612     ret = ios_base_Sync;
4613     ios_base_Sync = sync;
4614     _Lockit_dtor(&lock);
4615     return ret;
4616 }
4617
4618 /* ?unsetf@ios_base@std@@QAEXH@Z */
4619 /* ?unsetf@ios_base@std@@QEAAXH@Z */
4620 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
4621 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
4622 {
4623     TRACE("(%p %x)\n", this, flags);
4624     this->fmtfl &= ~flags;
4625 }
4626
4627 /* ?width@ios_base@std@@QAEHH@Z */
4628 /* ?width@ios_base@std@@QEAA_J_J@Z */
4629 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
4630 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
4631 {
4632     streamsize ret = this->wide;
4633
4634     TRACE("(%p %ld)\n", this, width);
4635
4636     this->wide = width;
4637     return ret;
4638 }
4639
4640 /* ?width@ios_base@std@@QBEHXZ */
4641 /* ?width@ios_base@std@@QEBA_JXZ */
4642 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
4643 streamsize __thiscall ios_base_width_get(ios_base *this)
4644 {
4645     TRACE("(%p)\n", this);
4646     return this->wide;
4647 }
4648
4649 /* ?xalloc@ios_base@std@@SAHXZ */
4650 int CDECL ios_base_xalloc(void)
4651 {
4652     _Lockit lock;
4653     int ret;
4654
4655     TRACE("\n");
4656
4657     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4658     ret = ios_base_Index++;
4659     _Lockit_dtor(&lock);
4660     return ret;
4661 }
4662
4663 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
4664 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
4665 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
4666 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
4667 {
4668     TRACE("(%p)\n", this);
4669
4670     ios_base_ctor(&this->base);
4671     this->base.vtable = &MSVCP_basic_ios_char_vtable;
4672     return this;
4673 }
4674
4675 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4676 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4677 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
4678 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
4679 {
4680     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4681     ios_base__Init(&this->base);
4682     this->strbuf = streambuf;
4683     this->stream = NULL;
4684     this->fillch = ' ';
4685
4686     if(!streambuf)
4687         ios_base_setstate(&this->base, IOSTATE_badbit);
4688
4689     if(isstd)
4690         FIXME("standard streams not handled yet\n");
4691 }
4692
4693 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4694 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4695 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
4696 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
4697 {
4698     TRACE("(%p %p)\n", this, strbuf);
4699
4700     basic_ios_char_ctor(this);
4701     basic_ios_char_init(this, strbuf, FALSE);
4702     return this;
4703 }
4704
4705 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
4706 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4707 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
4708 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
4709 {
4710     TRACE("(%p)\n", this);
4711     ios_base_dtor(&this->base);
4712 }
4713
4714 DEFINE_THISCALL_WRAPPER(basic_ios_char_vector_dtor, 8)
4715 basic_ios_char* __thiscall basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
4716 {
4717     TRACE("(%p %x)\n", this, flags);
4718     if(flags & 2) {
4719         /* we have an array, with the number of elements stored before the first object */
4720         INT_PTR i, *ptr = (INT_PTR *)this-1;
4721
4722         for(i=*ptr-1; i>=0; i--)
4723             basic_ios_char_dtor(this+i);
4724         MSVCRT_operator_delete(ptr);
4725     } else {
4726         basic_ios_char_dtor(this);
4727         if(flags & 1)
4728             MSVCRT_operator_delete(this);
4729     }
4730
4731     return this;
4732 }
4733
4734 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4735 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4736 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
4737 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4738 {
4739     TRACE("(%p %x %x)\n", this, state, reraise);
4740     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4741 }
4742
4743 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4744 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4745 static void basic_ios_char_clear(basic_ios_char *this, unsigned int state)
4746 {
4747     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
4748 }
4749
4750 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
4751 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4752 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
4753 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
4754 {
4755     TRACE("(%p %p)\n", this, copy);
4756     if(this == copy)
4757         return this;
4758
4759     this->stream = copy->stream;
4760     this->fillch = copy->fillch;
4761     ios_base_copyfmt(&this->base, &copy->base);
4762     return this;
4763 }
4764
4765 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
4766 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
4767 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
4768 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
4769 {
4770     char ret = this->fillch;
4771
4772     TRACE("(%p %c)\n", this, fill);
4773
4774     this->fillch = fill;
4775     return ret;
4776 }
4777
4778 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
4779 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
4780 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
4781 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
4782 {
4783     TRACE("(%p)\n", this);
4784     return this->fillch;
4785 }
4786
4787 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
4788 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
4789 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
4790 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
4791 {
4792     TRACE("(%p %p %p)\n", this, ret, loc);
4793
4794     if(this->strbuf) {
4795         basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
4796         locale_dtor(ret);
4797     }
4798
4799     return ios_base_imbue(&this->base, ret, loc);
4800 }
4801
4802 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
4803 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
4804 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
4805 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
4806 {
4807     TRACE("(%p %c %c)\n", this, ch, def);
4808     return ctype_char_narrow_ch(ctype_char_use_facet(this->strbuf->loc), ch, def);
4809 }
4810
4811 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
4812 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
4813 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
4814 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
4815 {
4816     basic_streambuf_char *ret = this->strbuf;
4817
4818     TRACE("(%p %p)\n", this, streambuf);
4819
4820     this->strbuf = streambuf;
4821     basic_ios_char_clear(this, IOSTATE_goodbit);
4822     return ret;
4823 }
4824
4825 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
4826 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
4827 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
4828 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
4829 {
4830     TRACE("(%p)\n", this);
4831     return this->strbuf;
4832 }
4833
4834 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4835 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4836 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
4837 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4838 {
4839     TRACE("(%p %x %x)\n", this, state, reraise);
4840
4841     if(state != IOSTATE_goodbit)
4842         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
4843 }
4844
4845 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4846 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4847 static void basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
4848 {
4849     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
4850 }
4851
4852 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
4853 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
4854 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
4855 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
4856 {
4857     basic_ostream_char *ret = this->stream;
4858
4859     TRACE("(%p %p)\n", this, ostream);
4860
4861     this->stream = ostream;
4862     return ret;
4863 }
4864
4865 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
4866 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
4867 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
4868 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
4869 {
4870     TRACE("(%p)\n", this);
4871     return this->stream;
4872 }
4873
4874 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
4875 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
4876 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
4877 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
4878 {
4879     TRACE("(%p %c)\n", this, ch);
4880     return ctype_char_widen_ch(ctype_char_use_facet(this->strbuf->loc), ch);
4881 }
4882
4883
4884 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
4885 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
4886 static basic_ios_wchar* basic_ios_wchar_ctor(basic_ios_wchar *this)
4887 {
4888     TRACE("(%p)\n", this);
4889
4890     ios_base_ctor(&this->base);
4891     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
4892     return this;
4893 }
4894
4895 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
4896 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
4897 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
4898 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
4899 {
4900     basic_ios_wchar_ctor(this);
4901     this->base.vtable = &MSVCP_basic_ios_short_vtable;
4902     return this;
4903 }
4904
4905 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
4906 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
4907 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
4908 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
4909 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
4910 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
4911 {
4912     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4913     ios_base__Init(&this->base);
4914     this->strbuf = streambuf;
4915     this->stream = NULL;
4916     this->fillch = ' ';
4917
4918     if(!streambuf)
4919         ios_base_setstate(&this->base, IOSTATE_badbit);
4920
4921     if(isstd)
4922         FIXME("standard streams not handled yet\n");
4923 }
4924
4925 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
4926 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
4927 static basic_ios_wchar* basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
4928 {
4929     TRACE("(%p %p)\n", this, strbuf);
4930
4931     basic_ios_wchar_ctor(this);
4932     basic_ios_wchar_init(this, strbuf, FALSE);
4933     return this;
4934 }
4935
4936 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
4937 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
4938 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
4939 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
4940 {
4941     basic_ios_wchar_ctor_streambuf(this, strbuf);
4942     this->base.vtable = &MSVCP_basic_ios_short_vtable;
4943     return this;
4944 }
4945
4946 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
4947 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
4948 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
4949 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
4950 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
4951 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
4952 {
4953     TRACE("(%p)\n", this);
4954     ios_base_dtor(&this->base);
4955 }
4956
4957 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_vector_dtor, 8)
4958 basic_ios_wchar* __thiscall basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
4959 {
4960     TRACE("(%p %x)\n", this, flags);
4961     if(flags & 2) {
4962         /* we have an array, with the number of elements stored before the first object */
4963         INT_PTR i, *ptr = (INT_PTR *)this-1;
4964
4965         for(i=*ptr-1; i>=0; i--)
4966             basic_ios_wchar_dtor(this+i);
4967         MSVCRT_operator_delete(ptr);
4968     } else {
4969         basic_ios_wchar_dtor(this);
4970         if(flags & 1)
4971             MSVCRT_operator_delete(this);
4972     }
4973
4974     return this;
4975 }
4976
4977 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
4978 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
4979 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
4980 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
4981 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
4982 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
4983 {
4984     TRACE("(%p %x %x)\n", this, state, reraise);
4985     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4986 }
4987
4988 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
4989 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
4990 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
4991 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
4992 static void basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
4993 {
4994     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
4995 }
4996
4997 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
4998 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4999 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
5000 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5001 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
5002 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
5003 {
5004     TRACE("(%p %p)\n", this, copy);
5005     if(this == copy)
5006         return this;
5007
5008     this->stream = copy->stream;
5009     this->fillch = copy->fillch;
5010     ios_base_copyfmt(&this->base, &copy->base);
5011     return this;
5012 }
5013
5014 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
5015 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
5016 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
5017 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
5018 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
5019 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
5020 {
5021     wchar_t ret = this->fillch;
5022
5023     TRACE("(%p %c)\n", this, fill);
5024
5025     this->fillch = fill;
5026     return ret;
5027 }
5028
5029 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
5030 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
5031 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
5032 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
5033 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
5034 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
5035 {
5036     TRACE("(%p)\n", this);
5037     return this->fillch;
5038 }
5039
5040 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5041 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5042 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5043 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5044 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
5045 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
5046 {
5047     TRACE("(%p %p %p)\n", this, ret, loc);
5048
5049     if(this->strbuf)
5050         return basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
5051
5052     locale_copy_ctor(ret, loc);
5053     return ret;
5054 }
5055
5056 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
5057 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
5058 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
5059 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
5060 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
5061 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
5062 {
5063     TRACE("(%p %c %c)\n", this, ch, def);
5064     return ctype_wchar_narrow_ch(ctype_wchar_use_facet(this->strbuf->loc), ch, def);
5065 }
5066
5067 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5068 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5069 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
5070 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5071 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
5072 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
5073 {
5074     basic_streambuf_wchar *ret = this->strbuf;
5075
5076     TRACE("(%p %p)\n", this, streambuf);
5077
5078     this->strbuf = streambuf;
5079     basic_ios_wchar_clear(this, IOSTATE_goodbit);
5080     return ret;
5081 }
5082
5083 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5084 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5085 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5086 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5087 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
5088 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
5089 {
5090     TRACE("(%p)\n", this);
5091     return this->strbuf;
5092 }
5093
5094 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5095 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5096 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5097 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5098 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
5099 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5100 {
5101     TRACE("(%p %x %x)\n", this, state, reraise);
5102
5103     if(state != IOSTATE_goodbit)
5104         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
5105 }
5106
5107 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5108 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5109 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5110 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5111 static void basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
5112 {
5113     basic_ios_wchar_setstate_reraise(this, state, FALSE);
5114 }
5115
5116 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5117 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5118 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
5119 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5120 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
5121 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
5122 {
5123     basic_ostream_wchar *ret = this->stream;
5124
5125     TRACE("(%p %p)\n", this, ostream);
5126
5127     this->stream = ostream;
5128     return ret;
5129 }
5130
5131 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5132 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5133 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5134 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5135 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
5136 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
5137 {
5138     TRACE("(%p)\n", this);
5139     return this->stream;
5140 }
5141
5142 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
5143 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
5144 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
5145 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
5146 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
5147 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
5148 {
5149     TRACE("(%p %c)\n", this, ch);
5150     return ctype_wchar_widen_ch(ctype_wchar_use_facet(this->strbuf->loc), ch);
5151 }
5152
5153 /* Caution: basic_ostream uses virtual inheritance.
5154  * All constructors have additional parameter that says if base class should be initialized.
5155  * Base class needs to be accessed using vbtable.
5156  */
5157 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
5158 {
5159     return (basic_ios_char*)((char*)this+this->vbtable[1]);
5160 }
5161
5162 static inline basic_ios_char* basic_ostream_char_to_basic_ios(basic_ostream_char *ptr)
5163 {
5164     return (basic_ios_char*)((char*)ptr+basic_ostream_char_vbtable[1]);
5165 }
5166
5167 static inline basic_ostream_char* basic_ostream_char_from_basic_ios(basic_ios_char *ptr)
5168 {
5169     return (basic_ostream_char*)((char*)ptr-basic_ostream_char_vbtable[1]);
5170 }
5171
5172 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5173 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5174 static basic_ostream_char* basic_ostream_char_ctor(basic_ostream_char *this,
5175         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5176 {
5177     basic_ios_char *base;
5178
5179     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5180
5181     if(virt_init) {
5182         this->vbtable = basic_ostream_char_vbtable;
5183         base = basic_ostream_char_get_basic_ios(this);
5184         basic_ios_char_ctor(base);
5185     }else {
5186         base = basic_ostream_char_get_basic_ios(this);
5187     }
5188
5189     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5190     basic_ios_char_init(base, strbuf, isstd);
5191     return this;
5192 }
5193
5194 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5195 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5196 static basic_ostream_char* basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
5197         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5198 {
5199     basic_ios_char *base;
5200
5201     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5202
5203     if(virt_init) {
5204         this->vbtable = basic_ostream_char_vbtable;
5205         base = basic_ostream_char_get_basic_ios(this);
5206         basic_ios_char_ctor(base);
5207     }else {
5208         base = basic_ostream_char_get_basic_ios(this);
5209     }
5210
5211     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5212     if(addstd)
5213         ios_base_Addstd(&base->base);
5214     return this;
5215 }
5216
5217 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5218 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5219 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
5220 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
5221 {
5222     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5223
5224     /* don't destroy virtual base here */
5225     TRACE("(%p)\n", this);
5226 }
5227
5228 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5229 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5230 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
5231 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
5232 {
5233     TRACE("(%p)\n", this);
5234     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
5235     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
5236 }
5237
5238 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
5239 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5240 {
5241     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5242
5243     TRACE("(%p %x)\n", this, flags);
5244
5245     if(flags & 2) {
5246         /* we have an array, with the number of elements stored before the first object */
5247         INT_PTR i, *ptr = (INT_PTR *)this-1;
5248
5249         for(i=*ptr-1; i>=0; i--)
5250             basic_ostream_char_vbase_dtor(this+i);
5251         MSVCRT_operator_delete(ptr);
5252     } else {
5253         basic_ostream_char_vbase_dtor(this);
5254         if(flags & 1)
5255             MSVCRT_operator_delete(this);
5256     }
5257
5258     return this;
5259 }
5260
5261 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5262 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5263 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
5264 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
5265 {
5266     /* this function is not matching C++ specification */
5267     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5268
5269     TRACE("(%p)\n", this);
5270
5271     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
5272             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
5273         basic_ios_char_setstate(base, IOSTATE_badbit);
5274     return this;
5275 }
5276
5277 /* ?flush@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5278 /* ?flush@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5279 basic_ostream_char* __cdecl flush_ostream_char(basic_ostream_char *ostream)
5280 {
5281     return basic_ostream_char_flush(ostream);
5282 }
5283
5284 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5285 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5286 static void basic_ostream_char__Osfx(basic_ostream_char *this)
5287 {
5288     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5289
5290     TRACE("(%p)\n", this);
5291
5292     if(base->base.fmtfl & FMTFLAG_unitbuf)
5293         basic_ostream_char_flush(this);
5294 }
5295
5296 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5297 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5298 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
5299 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
5300 {
5301     TRACE("(%p)\n", this);
5302     basic_ostream_char__Osfx(this);
5303 }
5304
5305 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
5306 {
5307     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5308
5309     if(basic_ios_char_rdbuf_get(base))
5310         basic_streambuf_char__Lock(base->strbuf);
5311
5312     if(ios_base_good(&base->base) && base->stream)
5313         basic_ostream_char_flush(base->stream);
5314
5315     return ios_base_good(&base->base);
5316 }
5317
5318 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
5319 {
5320     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5321
5322     if(ios_base_good(&base->base) && !__uncaught_exception())
5323         basic_ostream_char_osfx(ostr);
5324
5325     if(basic_ios_char_rdbuf_get(base))
5326         basic_streambuf_char__Unlock(base->strbuf);
5327 }
5328
5329 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
5330 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
5331 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
5332 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
5333 {
5334     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5335
5336     TRACE("(%p)\n", this);
5337
5338     if(ios_base_good(&base->base) && base->stream)
5339         basic_ostream_char_flush(base->stream);
5340     return ios_base_good(&base->base);
5341 }
5342
5343 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5344 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5345 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
5346 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
5347 {
5348     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5349
5350     TRACE("(%p %c)\n", this, ch);
5351
5352     if(!basic_ostream_char_sentry_create(this)
5353             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
5354         basic_ostream_char_sentry_destroy(this);
5355         basic_ios_char_setstate(base, IOSTATE_badbit);
5356         return this;
5357     }
5358
5359     basic_ostream_char_sentry_destroy(this);
5360     return this;
5361 }
5362
5363 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
5364 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
5365 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
5366 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
5367 {
5368     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5369
5370     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
5371
5372     if(!ios_base_fail(&base->base)) {
5373         fpos_int seek;
5374
5375         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
5376                 &seek, pos, OPENMODE_out);
5377         if(seek.off==0 && seek.pos==-1 && seek.state==0)
5378             basic_ios_char_setstate(base, IOSTATE_failbit);
5379     }
5380     return this;
5381 }
5382
5383 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
5384 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
5385 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
5386 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
5387 {
5388     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5389
5390     TRACE("(%p)\n", this);
5391
5392     if(!ios_base_fail(&base->base)) {
5393         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5394                 ret, 0, SEEKDIR_cur, OPENMODE_out);
5395     }else {
5396         ret->off = 0;
5397         ret->pos = -1;
5398         ret->state = 0;
5399     }
5400     return ret;
5401 }
5402
5403 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
5404 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
5405 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
5406 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
5407 {
5408     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5409
5410     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
5411
5412     if(!basic_ostream_char_sentry_create(this)
5413             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
5414         basic_ostream_char_sentry_destroy(this);
5415         basic_ios_char_setstate(base, IOSTATE_badbit);
5416         return this;
5417     }
5418
5419     basic_ostream_char_sentry_destroy(this);
5420     return this;
5421 }
5422
5423 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
5424 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
5425 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
5426 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
5427 {
5428     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5429     int state = IOSTATE_goodbit;
5430
5431     TRACE("(%p %d)\n", this, val);
5432
5433     if(basic_ostream_char_sentry_create(this)) {
5434         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5435         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5436         ostreambuf_iterator_char dest = {0, strbuf};
5437
5438         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
5439                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
5440                 ? (LONG)((unsigned short)val) : (LONG)val);
5441     }
5442     basic_ostream_char_sentry_destroy(this);
5443
5444     basic_ios_char_setstate(base, state);
5445     return this;
5446 }
5447
5448 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
5449 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
5450 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
5451 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
5452 {
5453     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5454     int state = IOSTATE_goodbit;
5455
5456     TRACE("(%p %u)\n", this, val);
5457
5458     if(basic_ostream_char_sentry_create(this)) {
5459         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5460         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5461         ostreambuf_iterator_char dest = {0, strbuf};
5462
5463         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5464     }
5465     basic_ostream_char_sentry_destroy(this);
5466
5467     basic_ios_char_setstate(base, state);
5468     return this;
5469 }
5470
5471 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
5472 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
5473 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
5474 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
5475 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
5476 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
5477 {
5478     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5479     int state = IOSTATE_goodbit;
5480
5481     TRACE("(%p %d)\n", this, val);
5482
5483     if(basic_ostream_char_sentry_create(this)) {
5484         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5485         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5486         ostreambuf_iterator_char dest = {0, strbuf};
5487
5488         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5489     }
5490     basic_ostream_char_sentry_destroy(this);
5491
5492     basic_ios_char_setstate(base, state);
5493     return this;
5494 }
5495
5496 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
5497 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
5498 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
5499 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
5500 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
5501 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
5502 {
5503     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5504     int state = IOSTATE_goodbit;
5505
5506     TRACE("(%p %u)\n", this, val);
5507
5508     if(basic_ostream_char_sentry_create(this)) {
5509         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5510         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5511         ostreambuf_iterator_char dest = {0, strbuf};
5512
5513         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5514     }
5515     basic_ostream_char_sentry_destroy(this);
5516
5517     basic_ios_char_setstate(base, state);
5518     return this;
5519 }
5520
5521 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
5522 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
5523 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
5524 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
5525 {
5526     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5527     int state = IOSTATE_goodbit;
5528
5529     TRACE("(%p %f)\n", this, val);
5530
5531     if(basic_ostream_char_sentry_create(this)) {
5532         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5533         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5534         ostreambuf_iterator_char dest = {0, strbuf};
5535
5536         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5537     }
5538     basic_ostream_char_sentry_destroy(this);
5539
5540     basic_ios_char_setstate(base, state);
5541     return this;
5542 }
5543
5544 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
5545 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
5546 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
5547 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
5548 {
5549     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5550     int state = IOSTATE_goodbit;
5551
5552     TRACE("(%p %lf)\n", this, val);
5553
5554     if(basic_ostream_char_sentry_create(this)) {
5555         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5556         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5557         ostreambuf_iterator_char dest = {0, strbuf};
5558
5559         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5560     }
5561     basic_ostream_char_sentry_destroy(this);
5562
5563     basic_ios_char_setstate(base, state);
5564     return this;
5565 }
5566
5567 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
5568 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
5569 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
5570 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
5571 {
5572     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5573     int state = IOSTATE_goodbit;
5574
5575     TRACE("(%p %lf)\n", this, val);
5576
5577     if(basic_ostream_char_sentry_create(this)) {
5578         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5579         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5580         ostreambuf_iterator_char dest = {0, strbuf};
5581
5582         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5583     }
5584     basic_ostream_char_sentry_destroy(this);
5585
5586     basic_ios_char_setstate(base, state);
5587     return this;
5588 }
5589
5590 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5591 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5592 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
5593 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
5594 {
5595     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5596     IOSB_iostate state = IOSTATE_badbit;
5597     int c = '\n';
5598
5599     TRACE("(%p %p)\n", this, val);
5600
5601     if(basic_ostream_char_sentry_create(this)) {
5602         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
5603                 c = basic_streambuf_char_snextc(val)) {
5604             state = IOSTATE_goodbit;
5605
5606             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
5607                 state = IOSTATE_badbit;
5608                 break;
5609             }
5610         }
5611     }else {
5612         state = IOSTATE_badbit;
5613     }
5614     basic_ostream_char_sentry_destroy(this);
5615
5616     ios_base_width_set(&base->base, 0);
5617     basic_ios_char_setstate(base, state);
5618     return this;
5619 }
5620
5621 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
5622 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
5623 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
5624 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
5625 {
5626     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5627     int state = IOSTATE_goodbit;
5628
5629     TRACE("(%p %p)\n", this, val);
5630
5631     if(basic_ostream_char_sentry_create(this)) {
5632         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5633         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5634         ostreambuf_iterator_char dest = {0, strbuf};
5635
5636         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5637     }
5638     basic_ostream_char_sentry_destroy(this);
5639
5640     basic_ios_char_setstate(base, state);
5641     return this;
5642 }
5643
5644 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
5645 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
5646 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
5647 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
5648 {
5649     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5650     int state = IOSTATE_goodbit;
5651
5652     TRACE("(%p)\n", this);
5653
5654     if(basic_ostream_char_sentry_create(this)) {
5655         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5656         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5657         ostreambuf_iterator_char dest = {0, strbuf};
5658
5659         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5660     }
5661     basic_ostream_char_sentry_destroy(this);
5662
5663     basic_ios_char_setstate(base, state);
5664     return this;
5665 }
5666
5667 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
5668 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
5669 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
5670 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
5671 {
5672     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5673     int state = IOSTATE_goodbit;
5674
5675     TRACE("(%p)\n", this);
5676
5677     if(basic_ostream_char_sentry_create(this)) {
5678         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5679         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5680         ostreambuf_iterator_char dest = {0, strbuf};
5681
5682         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5683     }
5684     basic_ostream_char_sentry_destroy(this);
5685
5686     basic_ios_char_setstate(base, state);
5687     return this;
5688 }
5689
5690 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
5691 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
5692 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
5693 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
5694 {
5695     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5696     int state = IOSTATE_goodbit;
5697
5698     TRACE("(%p %x)\n", this, val);
5699
5700     if(basic_ostream_char_sentry_create(this)) {
5701         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5702         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5703         ostreambuf_iterator_char dest = {0, strbuf};
5704
5705         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5706     }
5707     basic_ostream_char_sentry_destroy(this);
5708
5709     basic_ios_char_setstate(base, state);
5710     return this;
5711 }
5712
5713 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5714 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5715 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
5716 {
5717     TRACE("(%p)\n", ostr);
5718
5719     basic_ostream_char_put(ostr, '\n');
5720     basic_ostream_char_flush(ostr);
5721     return ostr;
5722 }
5723
5724 /* $?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 */
5725 /* ??$?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 */
5726 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
5727 {
5728     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5729     IOSB_iostate state = IOSTATE_goodbit;
5730
5731     TRACE("(%p %p)\n", ostr, str);
5732
5733     if(basic_ostream_char_sentry_create(ostr)) {
5734         MSVCP_size_t len = basic_string_char_length(str);
5735         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5736
5737         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5738             for(; pad!=0; pad--) {
5739                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5740                     state = IOSTATE_badbit;
5741                     break;
5742                 }
5743             }
5744         }
5745
5746         if(state == IOSTATE_goodbit) {
5747             if(basic_streambuf_char_sputn(base->strbuf, basic_string_char_c_str(str), len) != len)
5748                     state = IOSTATE_badbit;
5749         }
5750
5751         if(state == IOSTATE_goodbit) {
5752             for(; pad!=0; pad--) {
5753                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5754                     state = IOSTATE_badbit;
5755                     break;
5756                 }
5757             }
5758         }
5759
5760         base->base.wide = 0;
5761     }else {
5762         state = IOSTATE_badbit;
5763     }
5764     basic_ostream_char_sentry_destroy(ostr);
5765
5766     basic_ios_char_setstate(base, state);
5767     return ostr;
5768 }
5769
5770 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@C@Z */
5771 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@C@Z */
5772 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z */
5773 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z */
5774 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@E@Z */
5775 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@E@Z */
5776 basic_ostream_char* __cdecl basic_ostream_char_print_ch(basic_ostream_char *ostr, char ch)
5777 {
5778     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5779     IOSB_iostate state = IOSTATE_goodbit;
5780
5781     TRACE("(%p %d)\n", ostr, ch);
5782
5783     if(basic_ostream_char_sentry_create(ostr)) {
5784         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
5785
5786         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5787             for(; pad!=0; pad--) {
5788                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5789                     state = IOSTATE_badbit;
5790                     break;
5791                 }
5792             }
5793         }
5794
5795         if(state == IOSTATE_goodbit) {
5796             if(basic_streambuf_char_sputc(base->strbuf, ch) == EOF)
5797                 state = IOSTATE_badbit;
5798         }
5799
5800         if(state == IOSTATE_goodbit) {
5801             for(; pad!=0; pad--) {
5802                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5803                     state = IOSTATE_badbit;
5804                     break;
5805                 }
5806             }
5807         }
5808
5809         base->base.wide = 0;
5810     }else {
5811         state = IOSTATE_badbit;
5812     }
5813     basic_ostream_char_sentry_destroy(ostr);
5814
5815     basic_ios_char_setstate(base, state);
5816     return ostr;
5817 }
5818
5819 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBC@Z */
5820 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBC@Z */
5821 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z */
5822 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z */
5823 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBE@Z */
5824 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBE@Z */
5825 basic_ostream_char* __cdecl basic_ostream_char_print_str(basic_ostream_char *ostr, const char *str)
5826 {
5827     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5828     IOSB_iostate state = IOSTATE_goodbit;
5829
5830     TRACE("(%p %s)\n", ostr, str);
5831
5832     if(basic_ostream_char_sentry_create(ostr)) {
5833         MSVCP_size_t len = strlen(str);
5834         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5835
5836         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5837             for(; pad!=0; pad--) {
5838                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5839                     state = IOSTATE_badbit;
5840                     break;
5841                 }
5842             }
5843         }
5844
5845         if(state == IOSTATE_goodbit) {
5846             if(basic_streambuf_char_sputn(base->strbuf, str, len) != len)
5847                 state = IOSTATE_badbit;
5848         }
5849
5850         if(state == IOSTATE_goodbit) {
5851             for(; pad!=0; pad--) {
5852                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5853                     state = IOSTATE_badbit;
5854                     break;
5855                 }
5856             }
5857         }
5858
5859         base->base.wide = 0;
5860     }else {
5861         state = IOSTATE_badbit;
5862     }
5863     basic_ostream_char_sentry_destroy(ostr);
5864
5865     basic_ios_char_setstate(base, state);
5866     return ostr;
5867 }
5868
5869 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
5870 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
5871 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
5872 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
5873         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
5874 {
5875     TRACE("(%p %p)\n", this, pfunc);
5876     pfunc(this);
5877     return this;
5878 }
5879
5880 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
5881 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
5882 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
5883 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
5884         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
5885 {
5886     TRACE("(%p %p)\n", this, pfunc);
5887     pfunc(basic_ostream_char_get_basic_ios(this));
5888     return this;
5889 }
5890
5891 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
5892 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
5893 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
5894 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
5895         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
5896 {
5897     TRACE("(%p %p)\n", this, pfunc);
5898     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
5899     return this;
5900 }
5901
5902 /* Caution: basic_ostream uses virtual inheritance. */
5903 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
5904 {
5905     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
5906 }
5907
5908 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
5909 {
5910     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
5911 }
5912
5913 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
5914 {
5915     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
5916 }
5917
5918 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
5919 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
5920 static basic_ostream_wchar* basic_ostream_wchar_ctor(basic_ostream_wchar *this,
5921         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5922 {
5923     basic_ios_wchar *base;
5924
5925     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5926
5927     if(virt_init) {
5928         this->vbtable = basic_ostream_wchar_vbtable;
5929         base = basic_ostream_wchar_get_basic_ios(this);
5930         basic_ios_wchar_ctor(base);
5931     }else {
5932         base = basic_ostream_wchar_get_basic_ios(this);
5933     }
5934
5935     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
5936     basic_ios_wchar_init(base, strbuf, isstd);
5937     return this;
5938 }
5939
5940 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
5941 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
5942 static basic_ostream_wchar* basic_ostream_short_ctor(basic_ostream_wchar *this,
5943         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5944 {
5945     basic_ostream_wchar_ctor(this, strbuf, isstd, virt_init);
5946     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
5947     return this;
5948 }
5949
5950 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5951 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5952 static basic_ostream_wchar* basic_ostream_wchar_ctor_uninitialized(basic_ostream_wchar *this,
5953         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5954 {
5955     basic_ios_wchar *base;
5956
5957     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5958
5959     if(virt_init) {
5960         this->vbtable = basic_ostream_wchar_vbtable;
5961         base = basic_ostream_wchar_get_basic_ios(this);
5962         basic_ios_wchar_ctor(base);
5963     }else {
5964         base = basic_ostream_wchar_get_basic_ios(this);
5965     }
5966
5967     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
5968     if(addstd)
5969         ios_base_Addstd(&base->base);
5970     return this;
5971 }
5972
5973 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
5974 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
5975 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
5976 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
5977 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
5978 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
5979 {
5980     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
5981
5982     /* don't destroy virtual base here */
5983     TRACE("(%p)\n", this);
5984 }
5985
5986 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
5987 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
5988 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
5989 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
5990 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
5991 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
5992 {
5993     TRACE("(%p)\n", this);
5994     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
5995     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
5996 }
5997
5998 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
5999 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
6000 {
6001     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6002
6003     TRACE("(%p %x)\n", this, flags);
6004
6005     if(flags & 2) {
6006         /* we have an array, with the number of elements stored before the first object */
6007         INT_PTR i, *ptr = (INT_PTR *)this-1;
6008
6009         for(i=*ptr-1; i>=0; i--)
6010             basic_ostream_wchar_vbase_dtor(this+i);
6011         MSVCRT_operator_delete(ptr);
6012     } else {
6013         basic_ostream_wchar_vbase_dtor(this);
6014         if(flags & 1)
6015             MSVCRT_operator_delete(this);
6016     }
6017
6018     return this;
6019 }
6020
6021 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
6022 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
6023 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
6024 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
6025 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
6026 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
6027 {
6028     /* this function is not matching C++ specification */
6029     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6030
6031     TRACE("(%p)\n", this);
6032
6033     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
6034             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
6035         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6036     return this;
6037 }
6038
6039 /* ?flush@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6040 /* ?flush@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6041 /* ?flush@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6042 /* ?flush@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6043 basic_ostream_wchar* __cdecl flush_ostream_wchar(basic_ostream_wchar *ostream)
6044 {
6045     return basic_ostream_wchar_flush(ostream);
6046 }
6047
6048 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6049 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6050 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6051 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6052 static void basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
6053 {
6054     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6055
6056     TRACE("(%p)\n", this);
6057
6058     if(base->base.fmtfl & FMTFLAG_unitbuf)
6059         basic_ostream_wchar_flush(this);
6060 }
6061
6062 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6063 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6064 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6065 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6066 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
6067 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
6068 {
6069     TRACE("(%p)\n", this);
6070     basic_ostream_wchar__Osfx(this);
6071 }
6072
6073 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
6074 {
6075     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6076
6077     if(basic_ios_wchar_rdbuf_get(base))
6078         basic_streambuf_wchar__Lock(base->strbuf);
6079
6080     if(ios_base_good(&base->base) && base->stream)
6081         basic_ostream_wchar_flush(base->stream);
6082
6083     return ios_base_good(&base->base);
6084 }
6085
6086 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
6087 {
6088     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6089
6090     if(ios_base_good(&base->base) && !__uncaught_exception())
6091         basic_ostream_wchar_osfx(ostr);
6092
6093     if(basic_ios_wchar_rdbuf_get(base))
6094         basic_streambuf_wchar__Unlock(base->strbuf);
6095 }
6096
6097 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
6098 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
6099 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
6100 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
6101 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
6102 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
6103 {
6104     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6105
6106     TRACE("(%p)\n", this);
6107
6108     if(ios_base_good(&base->base) && base->stream)
6109         basic_ostream_wchar_flush(base->stream);
6110     return ios_base_good(&base->base);
6111 }
6112
6113 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
6114 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
6115 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
6116 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
6117 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
6118 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
6119 {
6120     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6121
6122     TRACE("(%p %c)\n", this, ch);
6123
6124     if(!basic_ostream_wchar_sentry_create(this)
6125             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
6126         basic_ostream_wchar_sentry_destroy(this);
6127         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6128         return this;
6129     }
6130
6131     basic_ostream_wchar_sentry_destroy(this);
6132     return this;
6133 }
6134
6135 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6136 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6137 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6138 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6139 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
6140 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
6141 {
6142     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6143
6144     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6145
6146     if(!ios_base_fail(&base->base)) {
6147         fpos_int seek;
6148
6149         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
6150                 &seek, pos, OPENMODE_out);
6151         if(seek.off==0 && seek.pos==-1 && seek.state==0)
6152             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6153     }
6154     return this;
6155 }
6156
6157 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6158 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6159 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6160 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6161 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
6162 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
6163 {
6164     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6165
6166     TRACE("(%p)\n", this);
6167
6168     if(!ios_base_fail(&base->base)) {
6169         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6170                 ret, 0, SEEKDIR_cur, OPENMODE_out);
6171     }else {
6172         ret->off = 0;
6173         ret->pos = -1;
6174         ret->state = 0;
6175     }
6176     return ret;
6177 }
6178
6179 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
6180 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
6181 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
6182 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
6183 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 12)
6184 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
6185 {
6186     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6187
6188     TRACE("(%p %s %ld)\n", this, debugstr_w(str), count);
6189
6190     if(!basic_ostream_wchar_sentry_create(this)
6191             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
6192         basic_ostream_wchar_sentry_destroy(this);
6193         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6194         return this;
6195     }
6196
6197     basic_ostream_wchar_sentry_destroy(this);
6198     return this;
6199 }
6200
6201 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
6202 {
6203     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6204     int state = IOSTATE_goodbit;
6205
6206     TRACE("(%p %d)\n", this, val);
6207
6208     if(basic_ostream_wchar_sentry_create(this)) {
6209         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6210         ostreambuf_iterator_wchar dest = {0, strbuf};
6211
6212         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
6213                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
6214                 ? (LONG)((unsigned short)val) : (LONG)val);
6215     }
6216     basic_ostream_wchar_sentry_destroy(this);
6217
6218     basic_ios_wchar_setstate(base, state);
6219     return this;
6220 }
6221
6222 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
6223 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
6224 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
6225 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
6226 {
6227     return basic_ostream_print_short(this, val, num_put_short_use_facet(
6228                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6229 }
6230
6231 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
6232 {
6233     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6234     int state = IOSTATE_goodbit;
6235
6236     TRACE("(%p %d)\n", this, val);
6237
6238     if(basic_ostream_wchar_sentry_create(this)) {
6239         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6240         ostreambuf_iterator_wchar dest = {0, strbuf};
6241
6242         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6243     }
6244     basic_ostream_wchar_sentry_destroy(this);
6245
6246     basic_ios_wchar_setstate(base, state);
6247     return this;
6248 }
6249
6250 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
6251 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
6252 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
6253 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
6254 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
6255 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
6256 {
6257     return basic_ostream_print_int(this, val, num_put_short_use_facet(
6258                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6259 }
6260
6261 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
6262 {
6263     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6264     int state = IOSTATE_goodbit;
6265
6266     TRACE("(%p %u)\n", this, val);
6267
6268     if(basic_ostream_wchar_sentry_create(this)) {
6269         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6270         ostreambuf_iterator_wchar dest = {0, strbuf};
6271
6272         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6273     }
6274     basic_ostream_wchar_sentry_destroy(this);
6275
6276     basic_ios_wchar_setstate(base, state);
6277     return this;
6278 }
6279
6280 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
6281 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
6282 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
6283 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
6284 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
6285 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
6286 {
6287     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
6288                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6289 }
6290
6291 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
6292 {
6293     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6294     int state = IOSTATE_goodbit;
6295
6296     TRACE("(%p %f)\n", this, val);
6297
6298     if(basic_ostream_wchar_sentry_create(this)) {
6299         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6300         ostreambuf_iterator_wchar dest = {0, strbuf};
6301
6302         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6303     }
6304     basic_ostream_wchar_sentry_destroy(this);
6305
6306     basic_ios_wchar_setstate(base, state);
6307     return this;
6308 }
6309
6310 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
6311 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
6312 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
6313 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
6314 {
6315     return basic_ostream_print_float(this, val, num_put_short_use_facet(
6316                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6317 }
6318
6319 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
6320 {
6321     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6322     int state = IOSTATE_goodbit;
6323
6324     TRACE("(%p %lf)\n", this, val);
6325
6326     if(basic_ostream_wchar_sentry_create(this)) {
6327         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6328         ostreambuf_iterator_wchar dest = {0, strbuf};
6329
6330         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6331     }
6332     basic_ostream_wchar_sentry_destroy(this);
6333
6334     basic_ios_wchar_setstate(base, state);
6335     return this;
6336 }
6337
6338 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
6339 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
6340 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
6341 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
6342 {
6343     return basic_ostream_print_double(this, val, num_put_short_use_facet(
6344                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6345 }
6346
6347 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
6348 {
6349     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6350     int state = IOSTATE_goodbit;
6351
6352     TRACE("(%p %lf)\n", this, val);
6353
6354     if(basic_ostream_wchar_sentry_create(this)) {
6355         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6356         ostreambuf_iterator_wchar dest = {0, strbuf};
6357
6358         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6359     }
6360     basic_ostream_wchar_sentry_destroy(this);
6361
6362     basic_ios_wchar_setstate(base, state);
6363     return this;
6364 }
6365
6366 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
6367 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
6368 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
6369 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
6370 {
6371     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
6372                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6373 }
6374
6375 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6376 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6377 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6378 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6379 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
6380 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
6381 {
6382     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6383     IOSB_iostate state = IOSTATE_badbit;
6384     unsigned short c = '\n';
6385
6386     TRACE("(%p %p)\n", this, val);
6387
6388     if(basic_ostream_wchar_sentry_create(this)) {
6389         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
6390                 c = basic_streambuf_wchar_snextc(val)) {
6391             state = IOSTATE_goodbit;
6392
6393             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
6394                 state = IOSTATE_badbit;
6395                 break;
6396             }
6397         }
6398     }else {
6399         state = IOSTATE_badbit;
6400     }
6401     basic_ostream_wchar_sentry_destroy(this);
6402
6403     ios_base_width_set(&base->base, 0);
6404     basic_ios_wchar_setstate(base, state);
6405     return this;
6406 }
6407
6408 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
6409 {
6410     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6411     int state = IOSTATE_goodbit;
6412
6413     TRACE("(%p %p)\n", this, val);
6414
6415     if(basic_ostream_wchar_sentry_create(this)) {
6416         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6417         ostreambuf_iterator_wchar dest = {0, strbuf};
6418
6419         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6420     }
6421     basic_ostream_wchar_sentry_destroy(this);
6422
6423     basic_ios_wchar_setstate(base, state);
6424     return this;
6425 }
6426
6427 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
6428 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
6429 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
6430 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
6431 {
6432     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
6433                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6434 }
6435
6436 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
6437 {
6438     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6439     int state = IOSTATE_goodbit;
6440
6441     TRACE("(%p)\n", this);
6442
6443     if(basic_ostream_wchar_sentry_create(this)) {
6444         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6445         ostreambuf_iterator_wchar dest = {0, strbuf};
6446
6447         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6448     }
6449     basic_ostream_wchar_sentry_destroy(this);
6450
6451     basic_ios_wchar_setstate(base, state);
6452     return this;
6453 }
6454
6455 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
6456 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
6457 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
6458 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
6459 {
6460     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
6461                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6462 }
6463
6464 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
6465 {
6466     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6467     int state = IOSTATE_goodbit;
6468
6469     TRACE("(%p)\n", this);
6470
6471     if(basic_ostream_wchar_sentry_create(this)) {
6472         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6473         ostreambuf_iterator_wchar dest = {0, strbuf};
6474
6475         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6476     }
6477     basic_ostream_wchar_sentry_destroy(this);
6478
6479     basic_ios_wchar_setstate(base, state);
6480     return this;
6481 }
6482
6483 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
6484 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
6485 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
6486 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6487 {
6488     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
6489                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6490 }
6491
6492 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
6493 {
6494     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6495     int state = IOSTATE_goodbit;
6496
6497     TRACE("(%p %x)\n", this, val);
6498
6499     if(basic_ostream_wchar_sentry_create(this)) {
6500         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6501         ostreambuf_iterator_wchar dest = {0, strbuf};
6502
6503         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6504     }
6505     basic_ostream_wchar_sentry_destroy(this);
6506
6507     basic_ios_wchar_setstate(base, state);
6508     return this;
6509 }
6510
6511 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
6512 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
6513 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
6514 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6515 {
6516     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
6517                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6518 }
6519
6520 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6521 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6522 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6523 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6524 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
6525 {
6526     TRACE("(%p)\n", ostr);
6527
6528     basic_ostream_wchar_put(ostr, '\n');
6529     basic_ostream_wchar_flush(ostr);
6530     return ostr;
6531 }
6532
6533 /* ??$?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 */
6534 /* ??$?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 */
6535 /* ??$?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 */
6536 /* ??$?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 */
6537 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_bstr(basic_ostream_wchar *ostr, const basic_string_wchar *str)
6538 {
6539     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6540     IOSB_iostate state = IOSTATE_goodbit;
6541
6542     TRACE("(%p %p)\n", ostr, str);
6543
6544     if(basic_ostream_wchar_sentry_create(ostr)) {
6545         MSVCP_size_t len = basic_string_wchar_length(str);
6546         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6547
6548         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6549             for(; pad!=0; pad--) {
6550                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6551                     state = IOSTATE_badbit;
6552                     break;
6553                 }
6554             }
6555         }
6556
6557         if(state == IOSTATE_goodbit) {
6558             if(basic_streambuf_wchar_sputn(base->strbuf, basic_string_wchar_c_str(str), len) != len)
6559                 state = IOSTATE_badbit;
6560         }
6561
6562         if(state == IOSTATE_goodbit) {
6563             for(; pad!=0; pad--) {
6564                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6565                     state = IOSTATE_badbit;
6566                     break;
6567                 }
6568             }
6569         }
6570
6571         base->base.wide = 0;
6572     }else {
6573         state = IOSTATE_badbit;
6574     }
6575     basic_ostream_wchar_sentry_destroy(ostr);
6576
6577     basic_ios_wchar_setstate(base, state);
6578     return ostr;
6579 }
6580
6581 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@_W@Z */
6582 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@_W@Z */
6583 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@G@Z */
6584 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@G@Z */
6585 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_ch(basic_ostream_wchar *ostr, wchar_t ch)
6586 {
6587     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6588     IOSB_iostate state = IOSTATE_goodbit;
6589
6590     TRACE("(%p %d)\n", ostr, ch);
6591
6592     if(basic_ostream_wchar_sentry_create(ostr)) {
6593         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6594
6595         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6596             for(; pad!=0; pad--) {
6597                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6598                     state = IOSTATE_badbit;
6599                     break;
6600                 }
6601             }
6602         }
6603
6604         if(state == IOSTATE_goodbit) {
6605             if(basic_streambuf_wchar_sputc(base->strbuf, ch) == WEOF)
6606                 state = IOSTATE_badbit;
6607         }
6608
6609         if(state == IOSTATE_goodbit) {
6610             for(; pad!=0; pad--) {
6611                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6612                     state = IOSTATE_badbit;
6613                     break;
6614                 }
6615             }
6616         }
6617
6618         base->base.wide = 0;
6619     }else {
6620         state = IOSTATE_badbit;
6621     }
6622     basic_ostream_wchar_sentry_destroy(ostr);
6623
6624     basic_ios_wchar_setstate(base, state);
6625     return ostr;
6626 }
6627
6628 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@PB_W@Z */
6629 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@PEB_W@Z */
6630 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@PBG@Z */
6631 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@PEBG@Z */
6632 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_str(basic_ostream_wchar *ostr, const wchar_t *str)
6633 {
6634     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6635     IOSB_iostate state = IOSTATE_goodbit;
6636
6637     TRACE("(%p %s)\n", ostr, debugstr_w(str));
6638
6639     if(basic_ostream_wchar_sentry_create(ostr)) {
6640         MSVCP_size_t len = wcslen(str);
6641         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6642
6643         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6644             for(; pad!=0; pad--) {
6645                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6646                     state = IOSTATE_badbit;
6647                     break;
6648                 }
6649             }
6650         }
6651
6652         if(state == IOSTATE_goodbit) {
6653             if(basic_streambuf_wchar_sputn(base->strbuf, str, len) != len)
6654                                         state = IOSTATE_badbit;
6655         }
6656
6657         if(state == IOSTATE_goodbit) {
6658             for(; pad!=0; pad--) {
6659                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6660                     state = IOSTATE_badbit;
6661                     break;
6662                 }
6663             }
6664         }
6665
6666         base->base.wide = 0;
6667     }else {
6668         state = IOSTATE_badbit;
6669     }
6670     basic_ostream_wchar_sentry_destroy(ostr);
6671
6672     basic_ios_wchar_setstate(base, state);
6673     return ostr;
6674 }
6675
6676 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6677 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6678 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6679 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6680 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
6681 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
6682         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
6683 {
6684     TRACE("(%p %p)\n", this, pfunc);
6685     pfunc(this);
6686     return this;
6687 }
6688
6689 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
6690 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
6691 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
6692 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
6693 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
6694 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
6695         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
6696 {
6697     TRACE("(%p %p)\n", this, pfunc);
6698     pfunc(basic_ostream_wchar_get_basic_ios(this));
6699     return this;
6700 }
6701
6702 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6703 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6704 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6705 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6706 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
6707 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
6708         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
6709 {
6710     TRACE("(%p %p)\n", this, pfunc);
6711     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
6712     return this;
6713 }
6714
6715 /* Caution: basic_istream uses virtual inheritance. */
6716 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
6717 {
6718     return (basic_ios_char*)((char*)this+this->vbtable[1]);
6719 }
6720
6721 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
6722 {
6723     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
6724 }
6725
6726 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
6727 {
6728     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
6729 }
6730
6731 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6732 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6733 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)
6734 {
6735     basic_ios_char *base;
6736
6737     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
6738
6739     if(virt_init) {
6740         this->vbtable = basic_istream_char_vbtable;
6741         base = basic_istream_char_get_basic_ios(this);
6742         basic_ios_char_ctor(base);
6743     }else {
6744         base = basic_istream_char_get_basic_ios(this);
6745     }
6746
6747     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6748     this->count = 0;
6749     if(!noinit)
6750         basic_ios_char_init(base, strbuf, isstd);
6751     return this;
6752 }
6753
6754 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6755 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6756 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
6757 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6758 {
6759     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
6760 }
6761
6762 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
6763 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
6764 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
6765 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
6766 {
6767     basic_ios_char *base;
6768
6769     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
6770
6771     if(virt_init) {
6772         this->vbtable = basic_istream_char_vbtable;
6773         base = basic_istream_char_get_basic_ios(this);
6774         basic_ios_char_ctor(base);
6775     }else {
6776         base = basic_istream_char_get_basic_ios(this);
6777     }
6778
6779     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6780     ios_base_Addstd(&base->base);
6781     return this;
6782 }
6783
6784 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
6785 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
6786 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
6787 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
6788 {
6789     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6790
6791     /* don't destroy virtual base here */
6792     TRACE("(%p)\n", this);
6793 }
6794
6795 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6796 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6797 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
6798 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
6799 {
6800     TRACE("(%p)\n", this);
6801     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
6802     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
6803 }
6804
6805 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
6806 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
6807 {
6808     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6809
6810     TRACE("(%p %x)\n", this, flags);
6811
6812     if(flags & 2) {
6813         /* we have an array, with the number of elements stored before the first object */
6814         INT_PTR i, *ptr = (INT_PTR *)this-1;
6815
6816         for(i=*ptr-1; i>=0; i--)
6817             basic_istream_char_vbase_dtor(this+i);
6818         MSVCRT_operator_delete(ptr);
6819     } else {
6820         basic_istream_char_vbase_dtor(this);
6821         if(flags & 1)
6822             MSVCRT_operator_delete(this);
6823     }
6824
6825     return this;
6826 }
6827
6828 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6829 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6830 static MSVCP_bool basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
6831 {
6832     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6833
6834     TRACE("(%p %d)\n", this, noskip);
6835
6836     if(!ios_base_good(&base->base)) {
6837         basic_ios_char_setstate(base, IOSTATE_failbit);
6838         return FALSE;
6839     }
6840
6841     if(basic_ios_char_tie_get(base))
6842         basic_ostream_char_flush(basic_ios_char_tie_get(base));
6843
6844     if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
6845         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6846         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
6847         int ch;
6848
6849         for(ch = basic_streambuf_char_sgetc(strbuf); ;
6850                 ch = basic_streambuf_char_snextc(strbuf)) {
6851             if(ch == EOF) {
6852                 basic_ios_char_setstate(base, IOSTATE_eofbit);
6853                 return FALSE;
6854             }
6855
6856             if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
6857                 break;
6858         }
6859     }
6860
6861     return TRUE;
6862 }
6863
6864 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6865 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6866 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
6867 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
6868 {
6869     return basic_istream_char__Ipfx(this, noskip);
6870 }
6871
6872 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6873 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6874 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
6875 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
6876 {
6877     TRACE("(%p)\n", this);
6878 }
6879
6880 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
6881 {
6882     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6883
6884     if(basic_ios_char_rdbuf_get(base))
6885         basic_streambuf_char__Lock(base->strbuf);
6886
6887     return basic_istream_char_ipfx(istr, noskip);
6888 }
6889
6890 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
6891 {
6892     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6893
6894     if(basic_ios_char_rdbuf_get(base))
6895         basic_streambuf_char__Unlock(base->strbuf);
6896 }
6897
6898 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
6899 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
6900 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
6901 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
6902 {
6903     TRACE("(%p)\n", this);
6904     return this->count;
6905 }
6906
6907 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
6908 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
6909 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
6910 int __thiscall basic_istream_char_get(basic_istream_char *this)
6911 {
6912     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6913     int ret;
6914
6915     TRACE("(%p)\n", this);
6916
6917     this->count = 0;
6918
6919     if(!basic_istream_char_sentry_create(this, TRUE)) {
6920         basic_istream_char_sentry_destroy(this);
6921         return EOF;
6922     }
6923
6924     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
6925     basic_istream_char_sentry_destroy(this);
6926     if(ret == EOF)
6927         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
6928     else
6929         this->count++;
6930
6931     return ret;
6932 }
6933
6934 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
6935 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
6936 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
6937 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
6938 {
6939     int ret;
6940
6941     TRACE("(%p %p)\n", this, ch);
6942
6943     ret = basic_istream_char_get(this);
6944     if(ret != EOF)
6945         *ch = (char)ret;
6946     return this;
6947 }
6948
6949 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
6950 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
6951 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
6952 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
6953 {
6954     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6955     int ch = delim;
6956
6957     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
6958
6959     this->count = 0;
6960
6961     if(basic_istream_char_sentry_create(this, TRUE)) {
6962         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6963
6964         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
6965                 ch = basic_streambuf_char_snextc(strbuf)) {
6966             if(ch==EOF || ch==delim)
6967                 break;
6968
6969             *str++ = ch;
6970             this->count++;
6971             count--;
6972         }
6973     }
6974     basic_istream_char_sentry_destroy(this);
6975
6976     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
6977             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
6978     if(count > 0)
6979         *str = 0;
6980     return this;
6981 }
6982
6983 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
6984 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
6985 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
6986 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
6987 {
6988     return basic_istream_char_get_str_delim(this, str, count, '\n');
6989 }
6990
6991 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
6992 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
6993 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
6994 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
6995 {
6996     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6997     int ch = delim;
6998
6999     TRACE("(%p %p %c)\n", this, strbuf, delim);
7000
7001     this->count = 0;
7002
7003     if(basic_istream_char_sentry_create(this, TRUE)) {
7004         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
7005
7006         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
7007                 ch = basic_streambuf_char_snextc(strbuf_read)) {
7008             if(ch==EOF || ch==delim)
7009                 break;
7010
7011             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
7012                 break;
7013             this->count++;
7014         }
7015     }
7016     basic_istream_char_sentry_destroy(this);
7017
7018     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7019             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7020     return this;
7021 }
7022
7023 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7024 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7025 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
7026 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
7027 {
7028     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
7029 }
7030
7031 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7032 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7033 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
7034 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7035 {
7036     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7037     int ch = delim;
7038
7039     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7040
7041     this->count = 0;
7042
7043     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
7044         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7045
7046         while(count > 1) {
7047             ch = basic_streambuf_char_sbumpc(strbuf);
7048
7049             if(ch==EOF || ch==delim)
7050                 break;
7051
7052             *str++ = ch;
7053             this->count++;
7054             count--;
7055         }
7056
7057         if(ch == delim)
7058             this->count++;
7059         else if(ch != EOF) {
7060             ch = basic_streambuf_char_sgetc(strbuf);
7061
7062             if(ch == delim) {
7063                 basic_streambuf_char__Gninc(strbuf);
7064                 this->count++;
7065             }
7066         }
7067     }
7068     basic_istream_char_sentry_destroy(this);
7069
7070     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
7071             (!this->count || (ch!=delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
7072     if(count > 0)
7073         *str = 0;
7074     return this;
7075 }
7076
7077 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7078 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7079 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
7080 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
7081 {
7082     return basic_istream_char_getline_delim(this, str, count, '\n');
7083 }
7084
7085 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
7086 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7087 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
7088 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
7089 {
7090     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7091     int ch = delim;
7092
7093     TRACE("(%p %ld %d)\n", this, count, delim);
7094
7095     this->count = 0;
7096
7097     if(basic_istream_char_sentry_create(this, TRUE)) {
7098         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7099
7100         while(count > 0) {
7101             ch = basic_streambuf_char_sbumpc(strbuf);
7102
7103             if(ch==EOF || ch==delim)
7104                 break;
7105
7106             this->count++;
7107             if(count != INT_MAX)
7108                 count--;
7109         }
7110     }
7111     basic_istream_char_sentry_destroy(this);
7112
7113     if(ch == EOF)
7114         basic_ios_char_setstate(base, IOSTATE_eofbit);
7115     return this;
7116 }
7117
7118 /* ?ws@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@1@AAV21@@Z */
7119 /* ?ws@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
7120 basic_istream_char* __cdecl ws_basic_istream_char(basic_istream_char *istream)
7121 {
7122     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7123     int ch = '\n';
7124
7125     TRACE("(%p)\n", istream);
7126
7127     if(basic_istream_char_sentry_create(istream, TRUE)) {
7128         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7129         const ctype_char *ctype = ctype_char_use_facet(strbuf->loc);
7130
7131         for(ch = basic_streambuf_char_sgetc(strbuf); ctype_char_is_ch(ctype, _SPACE, ch);
7132                 ch = basic_streambuf_char_snextc(strbuf)) {
7133             if(ch == EOF)
7134                 break;
7135         }
7136     }
7137     basic_istream_char_sentry_destroy(istream);
7138
7139     if(ch == EOF)
7140         basic_ios_char_setstate(base, IOSTATE_eofbit);
7141     return istream;
7142 }
7143
7144 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7145 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7146 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
7147 int __thiscall basic_istream_char_peek(basic_istream_char *this)
7148 {
7149     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7150     int ret = EOF;
7151
7152     TRACE("(%p)\n", this);
7153
7154     this->count = 0;
7155
7156     if(basic_istream_char_sentry_create(this, TRUE))
7157         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7158     basic_istream_char_sentry_destroy(this);
7159     return ret;
7160 }
7161
7162 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
7163 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
7164 static basic_istream_char* basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7165 {
7166     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7167     IOSB_iostate state = IOSTATE_goodbit;
7168
7169     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7170
7171     if(basic_istream_char_sentry_create(this, TRUE)) {
7172         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7173
7174         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
7175         if(this->count != count)
7176             state |= IOSTATE_failbit | IOSTATE_eofbit;
7177     }else {
7178         this->count = 0;
7179     }
7180     basic_istream_char_sentry_destroy(this);
7181
7182     basic_ios_char_setstate(base, state);
7183     return this;
7184 }
7185
7186 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7187 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7188 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
7189 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
7190 {
7191     return basic_istream_char__Read_s(this, str, count, count);
7192 }
7193
7194 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
7195 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
7196 static streamsize basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7197 {
7198     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7199     IOSB_iostate state = IOSTATE_goodbit;
7200
7201     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7202
7203     this->count = 0;
7204
7205     if(basic_istream_char_sentry_create(this, TRUE)) {
7206         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
7207         if(avail > count)
7208             avail = count;
7209
7210         if(avail == -1)
7211             state |= IOSTATE_eofbit;
7212         else if(avail > 0)
7213             basic_istream_char__Read_s(this, str, size, avail);
7214     }else {
7215         state |= IOSTATE_failbit;
7216     }
7217     basic_istream_char_sentry_destroy(this);
7218
7219     basic_ios_char_setstate(base, state);
7220     return this->count;
7221 }
7222
7223 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
7224 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
7225 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
7226 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
7227 {
7228     return basic_istream_char__Readsome_s(this, str, count, count);
7229 }
7230
7231 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
7232 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
7233 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
7234 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
7235 {
7236     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7237     IOSB_iostate state = IOSTATE_goodbit;
7238
7239     TRACE("(%p %c)\n", this, ch);
7240
7241     this->count = 0;
7242
7243     if(basic_istream_char_sentry_create(this, TRUE)) {
7244         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7245
7246         if(!ios_base_good(&base->base))
7247             state |= IOSTATE_failbit;
7248         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
7249             state |= IOSTATE_badbit;
7250     }
7251     basic_istream_char_sentry_destroy(this);
7252
7253     basic_ios_char_setstate(base, state);
7254     return this;
7255 }
7256
7257 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
7258 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
7259 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
7260 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
7261 {
7262     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7263     IOSB_iostate state = IOSTATE_goodbit;
7264
7265     TRACE("(%p)\n", this);
7266
7267     this->count = 0;
7268
7269     if(basic_istream_char_sentry_create(this, TRUE)) {
7270         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7271
7272         if(!ios_base_good(&base->base))
7273             state |= IOSTATE_failbit;
7274         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
7275             state |= IOSTATE_badbit;
7276     }
7277     basic_istream_char_sentry_destroy(this);
7278
7279     basic_ios_char_setstate(base, state);
7280     return this;
7281 }
7282
7283 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7284 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7285 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
7286 int __thiscall basic_istream_char_sync(basic_istream_char *this)
7287 {
7288     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7289     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7290
7291     TRACE("(%p)\n", this);
7292
7293     if(!strbuf)
7294         return -1;
7295
7296     if(basic_istream_char_sentry_create(this, TRUE)) {
7297         if(basic_streambuf_char_pubsync(strbuf) != -1) {
7298             basic_istream_char_sentry_destroy(this);
7299             return 0;
7300         }
7301     }
7302     basic_istream_char_sentry_destroy(this);
7303
7304     basic_ios_char_setstate(base, IOSTATE_badbit);
7305     return -1;
7306 }
7307
7308 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7309 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7310 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
7311 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
7312 {
7313     TRACE("(%p %p)\n", this, ret);
7314
7315     if(basic_istream_char_sentry_create(this, TRUE)) {
7316         basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7317         if(!ios_base_fail(&base->base)) {
7318             basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
7319                     ret, 0, SEEKDIR_cur, OPENMODE_in);
7320             basic_istream_char_sentry_destroy(this);
7321
7322             if(ret->off==0 && ret->pos==-1 && ret->state==0)
7323                 basic_ios_char_setstate(base, IOSTATE_failbit);
7324             return ret;
7325         }
7326     }
7327     basic_istream_char_sentry_destroy(this);
7328
7329     ret->off = 0;
7330     ret->pos = -1;
7331     ret->state = 0;
7332     return ret;
7333 }
7334
7335 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7336 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7337 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
7338 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
7339 {
7340     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7341
7342     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7343
7344     if(basic_istream_char_sentry_create(this, TRUE)) {
7345         if(!ios_base_fail(&base->base)) {
7346             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7347             fpos_int ret;
7348
7349             basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7350             basic_istream_char_sentry_destroy(this);
7351
7352             if(ret.off==0 && ret.pos==-1 && ret.state==0)
7353                 basic_ios_char_setstate(base, IOSTATE_failbit);
7354             else
7355                 basic_ios_char_clear(base, IOSTATE_goodbit);
7356             return this;
7357         }
7358     }
7359     basic_istream_char_sentry_destroy(this);
7360
7361     basic_ios_char_setstate(base, IOSTATE_failbit);
7362     return this;
7363 }
7364
7365 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
7366 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
7367 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
7368 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
7369 {
7370     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7371     int state = IOSTATE_goodbit;
7372
7373     TRACE("(%p %p)\n", this, v);
7374
7375     if(basic_istream_char_sentry_create(this, FALSE)) {
7376         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7377         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7378         istreambuf_iterator_char first={0}, last={0};
7379         LONG tmp;
7380
7381         first.strbuf = strbuf;
7382         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7383
7384         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7385             *v = tmp;
7386         else
7387             state |= IOSTATE_failbit;
7388     }
7389     basic_istream_char_sentry_destroy(this);
7390
7391     basic_ios_char_setstate(base, state);
7392     return this;
7393 }
7394
7395 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
7396 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
7397 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
7398 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
7399 {
7400     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7401     int state = IOSTATE_goodbit;
7402
7403     TRACE("(%p %p)\n", this, v);
7404
7405     if(basic_istream_char_sentry_create(this, FALSE)) {
7406         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7407         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7408         istreambuf_iterator_char first={0}, last={0};
7409
7410         first.strbuf = strbuf;
7411         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
7412     }
7413     basic_istream_char_sentry_destroy(this);
7414
7415     basic_ios_char_setstate(base, state);
7416     return this;
7417 }
7418
7419 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
7420 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
7421 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
7422 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
7423 {
7424     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7425     int state = IOSTATE_goodbit;
7426
7427     TRACE("(%p %p)\n", this, v);
7428
7429     if(basic_istream_char_sentry_create(this, FALSE)) {
7430         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7431         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7432         istreambuf_iterator_char first={0}, last={0};
7433
7434         first.strbuf = strbuf;
7435         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7436     }
7437     basic_istream_char_sentry_destroy(this);
7438
7439     basic_ios_char_setstate(base, state);
7440     return this;
7441 }
7442
7443 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
7444 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
7445 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
7446 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *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
7458         first.strbuf = strbuf;
7459         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
7460     }
7461     basic_istream_char_sentry_destroy(this);
7462
7463     basic_ios_char_setstate(base, state);
7464     return this;
7465 }
7466
7467 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
7468 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
7469 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
7470 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
7471 {
7472     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7473     int state = IOSTATE_goodbit;
7474
7475     TRACE("(%p %p)\n", this, v);
7476
7477     if(basic_istream_char_sentry_create(this, FALSE)) {
7478         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7479         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7480         istreambuf_iterator_char first={0}, last={0};
7481
7482         first.strbuf = strbuf;
7483         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7484     }
7485     basic_istream_char_sentry_destroy(this);
7486
7487     basic_ios_char_setstate(base, state);
7488     return this;
7489 }
7490
7491 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
7492 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
7493 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
7494 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
7495 {
7496     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7497     int state = IOSTATE_goodbit;
7498
7499     TRACE("(%p %p)\n", this, v);
7500
7501     if(basic_istream_char_sentry_create(this, FALSE)) {
7502         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7503         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7504         istreambuf_iterator_char first={0}, last={0};
7505
7506         first.strbuf = strbuf;
7507         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
7508     }
7509     basic_istream_char_sentry_destroy(this);
7510
7511     basic_ios_char_setstate(base, state);
7512     return this;
7513 }
7514
7515 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
7516 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
7517 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
7518 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
7519 {
7520     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7521     int state = IOSTATE_goodbit;
7522
7523     TRACE("(%p %p)\n", this, v);
7524
7525     if(basic_istream_char_sentry_create(this, FALSE)) {
7526         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7527         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7528         istreambuf_iterator_char first={0}, last={0};
7529
7530         first.strbuf = strbuf;
7531         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
7532     }
7533     basic_istream_char_sentry_destroy(this);
7534
7535     basic_ios_char_setstate(base, state);
7536     return this;
7537 }
7538
7539 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
7540 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
7541 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
7542 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
7543 {
7544     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7545     int state = IOSTATE_goodbit;
7546
7547     TRACE("(%p %p)\n", this, v);
7548
7549     if(basic_istream_char_sentry_create(this, FALSE)) {
7550         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7551         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7552         istreambuf_iterator_char first={0}, last={0};
7553
7554         first.strbuf = strbuf;
7555         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
7556     }
7557     basic_istream_char_sentry_destroy(this);
7558
7559     basic_ios_char_setstate(base, state);
7560     return this;
7561 }
7562
7563 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
7564 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
7565 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
7566 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
7567 {
7568     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7569     int state = IOSTATE_goodbit;
7570
7571     TRACE("(%p %p)\n", this, v);
7572
7573     if(basic_istream_char_sentry_create(this, FALSE)) {
7574         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7575         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7576         istreambuf_iterator_char first={0}, last={0};
7577
7578         first.strbuf = strbuf;
7579         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
7580     }
7581     basic_istream_char_sentry_destroy(this);
7582
7583     basic_ios_char_setstate(base, state);
7584     return this;
7585 }
7586
7587 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
7588 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
7589 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
7590 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
7591 {
7592     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7593     int state = IOSTATE_goodbit;
7594
7595     TRACE("(%p %p)\n", this, v);
7596
7597     if(basic_istream_char_sentry_create(this, FALSE)) {
7598         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7599         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7600         istreambuf_iterator_char first={0}, last={0};
7601
7602         first.strbuf = strbuf;
7603         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
7604     }
7605     basic_istream_char_sentry_destroy(this);
7606
7607     basic_ios_char_setstate(base, state);
7608     return this;
7609 }
7610
7611 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
7612 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
7613 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
7614 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
7615 {
7616     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7617     int state = IOSTATE_goodbit;
7618
7619     TRACE("(%p %p)\n", this, v);
7620
7621     if(basic_istream_char_sentry_create(this, FALSE)) {
7622         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7623         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7624         istreambuf_iterator_char first={0}, last={0};
7625
7626         first.strbuf = strbuf;
7627         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
7628     }
7629     basic_istream_char_sentry_destroy(this);
7630
7631     basic_ios_char_setstate(base, state);
7632     return this;
7633 }
7634
7635 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
7636 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
7637 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
7638 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
7639 {
7640     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7641     int state = IOSTATE_goodbit;
7642
7643     TRACE("(%p %p)\n", this, v);
7644
7645     if(basic_istream_char_sentry_create(this, FALSE)) {
7646         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7647         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7648         istreambuf_iterator_char first={0}, last={0};
7649
7650         first.strbuf = strbuf;
7651         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
7652     }
7653     basic_istream_char_sentry_destroy(this);
7654
7655     basic_ios_char_setstate(base, state);
7656     return this;
7657 }
7658
7659 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
7660 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
7661 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
7662 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
7663 {
7664     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7665     int state = IOSTATE_goodbit;
7666
7667     TRACE("(%p %p)\n", this, v);
7668
7669     if(basic_istream_char_sentry_create(this, FALSE)) {
7670         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7671         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7672         istreambuf_iterator_char first={0}, last={0};
7673
7674         first.strbuf = strbuf;
7675         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
7676     }
7677     basic_istream_char_sentry_destroy(this);
7678
7679     basic_ios_char_setstate(base, state);
7680     return this;
7681 }
7682
7683 /* ??$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 */
7684 /* ??$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 */
7685 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
7686         basic_istream_char *istream, basic_string_char *str, char delim)
7687 {
7688     IOSB_iostate state = IOSTATE_failbit;
7689     int c = delim;
7690
7691     TRACE("(%p %p %c)\n", istream, str, delim);
7692
7693     if(basic_istream_char_sentry_create(istream, TRUE)) {
7694         basic_string_char_clear(str);
7695
7696         c = basic_istream_char_get(istream);
7697         if(c != EOF)
7698             state = IOSTATE_goodbit;
7699
7700         for(; c!=delim && c!=EOF; c = basic_istream_char_get(istream)) {
7701             state = IOSTATE_goodbit;
7702             basic_string_char_append_ch(str, c);
7703         }
7704     }
7705     basic_istream_char_sentry_destroy(istream);
7706
7707     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
7708         state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7709     return istream;
7710 }
7711
7712 /* ??$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 */
7713 /* ??$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 */
7714 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
7715         basic_istream_char *istream, basic_string_char *str)
7716 {
7717     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
7718 }
7719
7720 /* ??$?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 */
7721 /* ??$?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 */
7722 basic_istream_char* __cdecl basic_istream_char_read_bstr(
7723         basic_istream_char *istream, basic_string_char *str)
7724 {
7725     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7726     IOSB_iostate state = IOSTATE_failbit;
7727     int c = '\n';
7728
7729     TRACE("(%p %p)\n", istream, str);
7730
7731     if(basic_istream_char_sentry_create(istream, FALSE)) {
7732         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
7733         MSVCP_size_t count = ios_base_width_get(&base->base);
7734
7735         if(!count)
7736             count = -1;
7737
7738         basic_string_char_clear(str);
7739
7740         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7741                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7742                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7743             state = IOSTATE_goodbit;
7744             basic_string_char_append_ch(str, c);
7745         }
7746     }
7747     basic_istream_char_sentry_destroy(istream);
7748
7749     ios_base_width_set(&base->base, 0);
7750     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7751     return istream;
7752 }
7753
7754 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z */
7755 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z */
7756 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAC@Z */
7757 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAC@Z */
7758 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAE@Z */
7759 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAE@Z */
7760 basic_istream_char* __cdecl basic_istream_char_read_str(basic_istream_char *istream, char *str)
7761 {
7762     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7763     IOSB_iostate state = IOSTATE_failbit;
7764     int c = '\n';
7765
7766     TRACE("(%p %p)\n", istream, str);
7767
7768     if(basic_istream_char_sentry_create(istream, FALSE)) {
7769         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
7770         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
7771
7772         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7773                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7774                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7775             state = IOSTATE_goodbit;
7776             *str++ = c;
7777         }
7778     }
7779     basic_istream_char_sentry_destroy(istream);
7780
7781     *str = 0;
7782     ios_base_width_set(&base->base, 0);
7783     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7784     return istream;
7785 }
7786
7787 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z */
7788 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAD@Z */
7789 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z */
7790 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAC@Z */
7791 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z */
7792 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAE@Z */
7793 basic_istream_char* __cdecl basic_istream_char_read_ch(basic_istream_char *istream, char *ch)
7794 {
7795     IOSB_iostate state = IOSTATE_failbit;
7796     int c = 0;
7797
7798     TRACE("(%p %p)\n", istream, ch);
7799
7800     if(basic_istream_char_sentry_create(istream, FALSE)) {
7801         c = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(
7802                     basic_istream_char_get_basic_ios(istream)));
7803         if(c != EOF) {
7804             state = IOSTATE_goodbit;
7805             *ch = c;
7806         }
7807     }
7808     basic_istream_char_sentry_destroy(istream);
7809
7810     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
7811             state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7812     return istream;
7813 }
7814
7815 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7816 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7817 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
7818 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
7819         basic_istream_char *this, basic_streambuf_char *streambuf)
7820 {
7821     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7822     IOSB_iostate state = IOSTATE_failbit;
7823     int c = '\n';
7824
7825     TRACE("(%p %p)\n", this, streambuf);
7826
7827     if(basic_istream_char_sentry_create(this, FALSE)) {
7828         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
7829                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
7830             state = IOSTATE_goodbit;
7831             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
7832                 break;
7833         }
7834     }
7835     basic_istream_char_sentry_destroy(this);
7836
7837     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7838     return this;
7839 }
7840
7841 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7842 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7843 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
7844 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
7845         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
7846 {
7847     TRACE("(%p %p)\n", this, pfunc);
7848     pfunc(this);
7849     return this;
7850 }
7851
7852 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
7853 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
7854 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
7855 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
7856         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
7857 {
7858     TRACE("(%p %p)\n", this, pfunc);
7859     pfunc(basic_istream_char_get_basic_ios(this));
7860     return this;
7861 }
7862
7863 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7864 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7865 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
7866 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
7867         ios_base* (__cdecl *pfunc)(ios_base*))
7868 {
7869     TRACE("(%p %p)\n", this, pfunc);
7870     pfunc(&basic_istream_char_get_basic_ios(this)->base);
7871     return this;
7872 }
7873
7874 /* Caution: basic_istream uses virtual inheritance. */
7875 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
7876 {
7877     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
7878 }
7879
7880 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
7881 {
7882     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
7883 }
7884
7885 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
7886 {
7887     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
7888 }
7889
7890 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7891 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7892 static basic_istream_wchar* basic_istream_wchar_ctor_init(basic_istream_wchar *this,
7893         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7894 {
7895     basic_ios_wchar *base;
7896
7897     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
7898
7899     if(virt_init) {
7900         this->vbtable = basic_istream_wchar_vbtable;
7901         base = basic_istream_wchar_get_basic_ios(this);
7902         basic_ios_wchar_ctor(base);
7903     }else {
7904         base = basic_istream_wchar_get_basic_ios(this);
7905     }
7906
7907     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
7908     this->count = 0;
7909     if(!noinit)
7910         basic_ios_wchar_init(base, strbuf, isstd);
7911     return this;
7912 }
7913
7914 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7915 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7916 static basic_istream_wchar* basic_istream_short_ctor_init(basic_istream_wchar *this,
7917         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7918 {
7919     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
7920     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
7921     return this;
7922 }
7923
7924 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
7925 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
7926 static basic_istream_wchar* basic_istream_wchar_ctor(basic_istream_wchar *this,
7927         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7928 {
7929     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7930 }
7931
7932 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
7933 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
7934 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor, 16)
7935 basic_istream_wchar* __thiscall basic_istream_short_ctor(basic_istream_wchar *this,
7936         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7937 {
7938     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7939 }
7940
7941 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7942 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7943 static basic_istream_wchar* basic_istream_wchar_ctor_uninitialized(
7944         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
7945 {
7946     basic_ios_wchar *base;
7947
7948     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
7949
7950     if(virt_init) {
7951         this->vbtable = basic_istream_wchar_vbtable;
7952         base = basic_istream_wchar_get_basic_ios(this);
7953         basic_ios_wchar_ctor(base);
7954     }else {
7955         base = basic_istream_wchar_get_basic_ios(this);
7956     }
7957
7958     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
7959     ios_base_Addstd(&base->base);
7960     return this;
7961 }
7962
7963 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7964 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7965 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
7966 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
7967         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
7968 {
7969     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
7970     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
7971     return this;
7972 }
7973
7974 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
7975 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
7976 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
7977 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
7978 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
7979 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
7980 {
7981     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
7982
7983     /* don't destroy virtual base here */
7984     TRACE("(%p)\n", this);
7985 }
7986
7987 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
7988 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
7989 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
7990 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
7991 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
7992 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
7993 {
7994     TRACE("(%p)\n", this);
7995     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
7996     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
7997 }
7998
7999 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
8000 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
8001 {
8002     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8003
8004     TRACE("(%p %x)\n", this, flags);
8005
8006     if(flags & 2) {
8007         /* we have an array, with the number of elements stored before the first object */
8008         INT_PTR i, *ptr = (INT_PTR *)this-1;
8009
8010         for(i=*ptr-1; i>=0; i--)
8011             basic_istream_wchar_vbase_dtor(this+i);
8012         MSVCRT_operator_delete(ptr);
8013     } else {
8014         basic_istream_wchar_vbase_dtor(this);
8015         if(flags & 1)
8016             MSVCRT_operator_delete(this);
8017     }
8018
8019     return this;
8020 }
8021
8022 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8023 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8024 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8025 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8026 static MSVCP_bool basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8027 {
8028     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8029
8030     TRACE("(%p %d)\n", this, noskip);
8031
8032     if(!ios_base_good(&base->base)) {
8033         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8034         return FALSE;
8035     }
8036
8037     if(basic_ios_wchar_tie_get(base))
8038         basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
8039
8040     if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
8041         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8042         const ctype_wchar *ctype = ctype_wchar_use_facet(base->strbuf->loc);
8043         int ch;
8044
8045         for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
8046                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8047             if(ch == WEOF) {
8048                 basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8049                 return FALSE;
8050             }
8051
8052             if(!ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
8053                 break;
8054         }
8055     }
8056
8057     return TRUE;
8058 }
8059
8060 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8061 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8062 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8063 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8064 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
8065 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8066 {
8067     return basic_istream_wchar__Ipfx(this, noskip);
8068 }
8069
8070 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8071 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8072 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8073 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8074 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
8075 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
8076 {
8077     TRACE("(%p)\n", this);
8078 }
8079
8080 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
8081 {
8082     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8083
8084     if(basic_ios_wchar_rdbuf_get(base))
8085         basic_streambuf_wchar__Lock(base->strbuf);
8086
8087     return basic_istream_wchar_ipfx(istr, noskip);
8088 }
8089
8090 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
8091 {
8092     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8093
8094     if(basic_ios_wchar_rdbuf_get(base))
8095         basic_streambuf_wchar__Unlock(base->strbuf);
8096 }
8097
8098 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
8099 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
8100 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
8101 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
8102 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
8103 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
8104 {
8105     TRACE("(%p)\n", this);
8106     return this->count;
8107 }
8108
8109 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8110 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8111 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8112 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8113 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
8114 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
8115 {
8116     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8117     int ret;
8118
8119     TRACE("(%p)\n", this);
8120
8121     this->count = 0;
8122
8123     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
8124         basic_istream_wchar_sentry_destroy(this);
8125         return WEOF;
8126     }
8127
8128     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
8129     basic_istream_wchar_sentry_destroy(this);
8130     if(ret == WEOF)
8131         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
8132     else
8133         this->count++;
8134
8135     return ret;
8136 }
8137
8138 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
8139 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
8140 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
8141 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
8142 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
8143 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
8144 {
8145     unsigned short ret;
8146
8147     TRACE("(%p %p)\n", this, ch);
8148
8149     ret = basic_istream_wchar_get(this);
8150     if(ret != WEOF)
8151         *ch = (wchar_t)ret;
8152     return this;
8153 }
8154
8155 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8156 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8157 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8158 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8159 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 16)
8160 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8161 {
8162     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8163     unsigned short ch = delim;
8164
8165     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8166
8167     this->count = 0;
8168
8169     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8170         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8171
8172         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
8173                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8174             if(ch==WEOF || ch==delim)
8175                 break;
8176
8177             *str++ = ch;
8178             this->count++;
8179             count--;
8180         }
8181     }
8182     basic_istream_wchar_sentry_destroy(this);
8183
8184     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8185             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8186     if(count > 0)
8187         *str = 0;
8188     return this;
8189 }
8190
8191 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8192 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8193 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8194 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8195 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 12)
8196 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
8197 {
8198     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
8199 }
8200
8201 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8202 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8203 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8204 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8205 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
8206 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
8207 {
8208     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8209     unsigned short ch = delim;
8210
8211     TRACE("(%p %p %c)\n", this, strbuf, delim);
8212
8213     this->count = 0;
8214
8215     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8216         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
8217
8218         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
8219                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
8220             if(ch==WEOF || ch==delim)
8221                 break;
8222
8223             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
8224                 break;
8225             this->count++;
8226         }
8227     }
8228     basic_istream_wchar_sentry_destroy(this);
8229
8230     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8231             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8232     return this;
8233 }
8234
8235 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8236 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8237 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8238 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8239 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
8240 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
8241 {
8242     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
8243 }
8244
8245 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8246 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8247 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8248 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8249 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 16)
8250 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8251 {
8252     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8253     unsigned short ch = delim;
8254
8255     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8256
8257     this->count = 0;
8258
8259     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
8260         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8261
8262         while(count > 1) {
8263             ch = basic_streambuf_wchar_sbumpc(strbuf);
8264
8265             if(ch==WEOF || ch==delim)
8266                 break;
8267
8268             *str++ = ch;
8269             this->count++;
8270             count--;
8271         }
8272
8273         if(ch == delim)
8274             this->count++;
8275         else if(ch != WEOF) {
8276             ch = basic_streambuf_wchar_sgetc(strbuf);
8277
8278             if(ch == delim) {
8279                 basic_streambuf_wchar__Gninc(strbuf);
8280                 this->count++;
8281             }
8282         }
8283     }
8284     basic_istream_wchar_sentry_destroy(this);
8285
8286     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
8287             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
8288     if(count > 0)
8289         *str = 0;
8290     return this;
8291 }
8292
8293 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8294 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8295 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8296 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8297 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 12)
8298 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
8299 {
8300     return basic_istream_wchar_getline_delim(this, str, count, '\n');
8301 }
8302
8303 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
8304 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
8305 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
8306 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
8307 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 12)
8308 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
8309 {
8310     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8311     unsigned short ch = delim;
8312
8313     TRACE("(%p %ld %d)\n", this, count, delim);
8314
8315     this->count = 0;
8316
8317     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8318         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8319
8320         while(count > 0) {
8321             ch = basic_streambuf_wchar_sbumpc(strbuf);
8322
8323             if(ch==WEOF || ch==delim)
8324                 break;
8325
8326             this->count++;
8327             if(count != INT_MAX)
8328                 count--;
8329         }
8330     }
8331     basic_istream_wchar_sentry_destroy(this);
8332
8333     if(ch == WEOF)
8334         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8335     return this;
8336 }
8337
8338 /* ?ws@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
8339 /* ?ws@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
8340 /* ?ws@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@1@AAV21@@Z */
8341 /* ?ws@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
8342 basic_istream_wchar* __cdecl ws_basic_istream_wchar(basic_istream_wchar *istream)
8343 {
8344     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8345     unsigned short ch = '\n';
8346
8347     TRACE("(%p)\n", istream);
8348
8349     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8350         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8351         const ctype_wchar *ctype = ctype_wchar_use_facet(strbuf->loc);
8352
8353         for(ch = basic_streambuf_wchar_sgetc(strbuf); ctype_wchar_is_ch(ctype, _SPACE, ch);
8354                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8355             if(ch == WEOF)
8356                 break;
8357         }
8358     }
8359     basic_istream_wchar_sentry_destroy(istream);
8360
8361     if(ch == WEOF)
8362         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8363     return istream;
8364 }
8365
8366 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8367 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8368 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8369 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8370 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
8371 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
8372 {
8373     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8374     unsigned short ret = WEOF;
8375
8376     TRACE("(%p)\n", this);
8377
8378     this->count = 0;
8379
8380     if(basic_istream_wchar_sentry_create(this, TRUE))
8381         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8382     basic_istream_wchar_sentry_destroy(this);
8383     return ret;
8384 }
8385
8386 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
8387 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
8388 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
8389 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
8390 static basic_istream_wchar* basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8391 {
8392     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8393     IOSB_iostate state = IOSTATE_goodbit;
8394
8395     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8396
8397     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8398         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8399
8400         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
8401         if(this->count != count)
8402             state |= IOSTATE_failbit | IOSTATE_eofbit;
8403     }else {
8404         this->count = 0;
8405     }
8406     basic_istream_wchar_sentry_destroy(this);
8407
8408     basic_ios_wchar_setstate(base, state);
8409     return this;
8410 }
8411
8412 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8413 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8414 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8415 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8416 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 12)
8417 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
8418 {
8419     return basic_istream_wchar__Read_s(this, str, count, count);
8420 }
8421
8422 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
8423 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
8424 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
8425 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
8426 static streamsize basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8427 {
8428     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8429     IOSB_iostate state = IOSTATE_goodbit;
8430
8431     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8432
8433     this->count = 0;
8434
8435     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8436         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
8437         if(avail > count)
8438             avail = count;
8439
8440         if(avail == -1)
8441             state |= IOSTATE_eofbit;
8442         else if(avail > 0)
8443             basic_istream_wchar__Read_s(this, str, size, avail);
8444     }else {
8445         state |= IOSTATE_failbit;
8446     }
8447     basic_istream_wchar_sentry_destroy(this);
8448
8449     basic_ios_wchar_setstate(base, state);
8450     return this->count;
8451 }
8452
8453 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
8454 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
8455 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
8456 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
8457 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 12)
8458 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
8459 {
8460     return basic_istream_wchar__Readsome_s(this, str, count, count);
8461 }
8462
8463 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
8464 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
8465 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
8466 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
8467 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
8468 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
8469 {
8470     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8471     IOSB_iostate state = IOSTATE_goodbit;
8472
8473     TRACE("(%p %c)\n", this, ch);
8474
8475     this->count = 0;
8476
8477     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8478         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8479
8480         if(!ios_base_good(&base->base))
8481             state |= IOSTATE_failbit;
8482         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
8483             state |= IOSTATE_badbit;
8484     }
8485     basic_istream_wchar_sentry_destroy(this);
8486
8487     basic_ios_wchar_setstate(base, state);
8488     return this;
8489 }
8490
8491 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
8492 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
8493 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
8494 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
8495 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
8496 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
8497 {
8498     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8499     IOSB_iostate state = IOSTATE_goodbit;
8500
8501     TRACE("(%p)\n", this);
8502
8503     this->count = 0;
8504
8505     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8506         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8507
8508         if(!ios_base_good(&base->base))
8509             state |= IOSTATE_failbit;
8510         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
8511             state |= IOSTATE_badbit;
8512     }
8513     basic_istream_wchar_sentry_destroy(this);
8514
8515     basic_ios_wchar_setstate(base, state);
8516     return this;
8517 }
8518
8519 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
8520 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
8521 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
8522 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
8523 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
8524 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
8525 {
8526     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8527     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8528
8529     TRACE("(%p)\n", this);
8530
8531     if(!strbuf)
8532         return -1;
8533
8534     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8535         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
8536             basic_istream_wchar_sentry_destroy(this);
8537             return 0;
8538         }
8539     }
8540     basic_istream_wchar_sentry_destroy(this);
8541
8542     basic_ios_wchar_setstate(base, IOSTATE_badbit);
8543     return -1;
8544 }
8545
8546 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8547 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8548 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8549 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8550 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
8551 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
8552 {
8553     TRACE("(%p %p)\n", this, ret);
8554
8555     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8556         basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8557         if(!ios_base_fail(&base->base)) {
8558             basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
8559                     ret, 0, SEEKDIR_cur, OPENMODE_in);
8560             basic_istream_wchar_sentry_destroy(this);
8561
8562             if(ret->off==0 && ret->pos==-1 && ret->state==0)
8563                 basic_ios_wchar_setstate(base, IOSTATE_failbit);
8564             return ret;
8565         }
8566     }
8567     basic_istream_wchar_sentry_destroy(this);
8568
8569     ret->off = 0;
8570     ret->pos = -1;
8571     ret->state = 0;
8572     return ret;
8573 }
8574
8575 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8576 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8577 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8578 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8579 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
8580 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
8581 {
8582     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8583
8584     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
8585
8586     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8587         if(!ios_base_fail(&base->base)) {
8588             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8589             fpos_int ret;
8590
8591             basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
8592             basic_istream_wchar_sentry_destroy(this);
8593
8594             if(ret.off==0 && ret.pos==-1 && ret.state==0)
8595                 basic_ios_wchar_setstate(base, IOSTATE_failbit);
8596             else
8597                 basic_ios_wchar_clear(base, IOSTATE_goodbit);
8598             return this;
8599         }
8600     }
8601     basic_istream_wchar_sentry_destroy(this);
8602
8603     basic_ios_wchar_setstate(base, IOSTATE_failbit);
8604     return this;
8605 }
8606
8607 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
8608 {
8609     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8610     int state = IOSTATE_goodbit;
8611
8612     TRACE("(%p %p)\n", this, v);
8613
8614     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8615         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8616         istreambuf_iterator_wchar first={0}, last={0};
8617         LONG tmp;
8618
8619         first.strbuf = strbuf;
8620         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
8621
8622         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
8623             *v = tmp;
8624         else
8625             state |= IOSTATE_failbit;
8626     }
8627     basic_istream_wchar_sentry_destroy(this);
8628
8629     basic_ios_wchar_setstate(base, state);
8630     return this;
8631 }
8632
8633 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
8634 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
8635 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
8636 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
8637 {
8638     return basic_istream_read_short(this, v, num_get_short_use_facet(
8639                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8640 }
8641
8642 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
8643 {
8644     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8645     int state = IOSTATE_goodbit;
8646
8647     TRACE("(%p %p)\n", this, v);
8648
8649     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8650         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8651         istreambuf_iterator_wchar first={0}, last={0};
8652
8653         first.strbuf = strbuf;
8654         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8655     }
8656     basic_istream_wchar_sentry_destroy(this);
8657
8658     basic_ios_wchar_setstate(base, state);
8659     return this;
8660 }
8661
8662 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
8663 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
8664 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
8665 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
8666 {
8667     return basic_istream_read_int(this, v, num_get_short_use_facet(
8668                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8669 }
8670
8671 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
8672 {
8673     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8674     int state = IOSTATE_goodbit;
8675
8676     TRACE("(%p %p)\n", this, v);
8677
8678     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8679         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8680         istreambuf_iterator_wchar first={0}, last={0};
8681
8682         first.strbuf = strbuf;
8683         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
8684     }
8685     basic_istream_wchar_sentry_destroy(this);
8686
8687     basic_ios_wchar_setstate(base, state);
8688     return this;
8689 }
8690
8691 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
8692 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
8693 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
8694 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
8695 {
8696     return basic_istream_read_uint(this, v, num_get_short_use_facet(
8697                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8698 }
8699
8700 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
8701 {
8702     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8703     int state = IOSTATE_goodbit;
8704
8705     TRACE("(%p %p)\n", this, v);
8706
8707     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8708         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8709         istreambuf_iterator_wchar first={0}, last={0};
8710
8711         first.strbuf = strbuf;
8712         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8713     }
8714     basic_istream_wchar_sentry_destroy(this);
8715
8716     basic_ios_wchar_setstate(base, state);
8717     return this;
8718 }
8719
8720 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
8721 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
8722 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
8723 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
8724 {
8725     return basic_istream_read_long(this, v, num_get_short_use_facet(
8726                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8727 }
8728
8729 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
8730 {
8731     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8732     int state = IOSTATE_goodbit;
8733
8734     TRACE("(%p %p)\n", this, v);
8735
8736     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8737         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8738         istreambuf_iterator_wchar first={0}, last={0};
8739
8740         first.strbuf = strbuf;
8741         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
8742     }
8743     basic_istream_wchar_sentry_destroy(this);
8744
8745     basic_ios_wchar_setstate(base, state);
8746     return this;
8747 }
8748
8749 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
8750 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
8751 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
8752 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
8753 {
8754     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
8755                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8756 }
8757
8758 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
8759 {
8760     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8761     int state = IOSTATE_goodbit;
8762
8763     TRACE("(%p %p)\n", this, v);
8764
8765     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8766         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8767         istreambuf_iterator_wchar first={0}, last={0};
8768
8769         first.strbuf = strbuf;
8770         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
8771     }
8772     basic_istream_wchar_sentry_destroy(this);
8773
8774     basic_ios_wchar_setstate(base, state);
8775     return this;
8776 }
8777
8778 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
8779 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
8780 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
8781 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
8782 {
8783     return basic_istream_read_float(this, v, num_get_short_use_facet(
8784                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8785 }
8786
8787 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
8788 {
8789     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8790     int state = IOSTATE_goodbit;
8791
8792     TRACE("(%p %p)\n", this, v);
8793
8794     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8795         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8796         istreambuf_iterator_wchar first={0}, last={0};
8797
8798         first.strbuf = strbuf;
8799         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
8800     }
8801     basic_istream_wchar_sentry_destroy(this);
8802
8803     basic_ios_wchar_setstate(base, state);
8804     return this;
8805 }
8806
8807 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
8808 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
8809 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
8810 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
8811 {
8812     return basic_istream_read_double(this, v, num_get_short_use_facet(
8813                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8814 }
8815
8816 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
8817 {
8818     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8819     int state = IOSTATE_goodbit;
8820
8821     TRACE("(%p %p)\n", this, v);
8822
8823     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8824         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8825         istreambuf_iterator_wchar first={0}, last={0};
8826
8827         first.strbuf = strbuf;
8828         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
8829     }
8830     basic_istream_wchar_sentry_destroy(this);
8831
8832     basic_ios_wchar_setstate(base, state);
8833     return this;
8834 }
8835
8836 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
8837 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
8838 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
8839 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
8840 {
8841     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
8842                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8843 }
8844
8845 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
8846 {
8847     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8848     int state = IOSTATE_goodbit;
8849
8850     TRACE("(%p %p)\n", this, v);
8851
8852     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8853         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8854         istreambuf_iterator_wchar first={0}, last={0};
8855
8856         first.strbuf = strbuf;
8857         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
8858     }
8859     basic_istream_wchar_sentry_destroy(this);
8860
8861     basic_ios_wchar_setstate(base, state);
8862     return this;
8863 }
8864
8865 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
8866 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
8867 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
8868 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
8869 {
8870     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
8871                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8872 }
8873
8874 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
8875 {
8876     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8877     int state = IOSTATE_goodbit;
8878
8879     TRACE("(%p %p)\n", this, v);
8880
8881     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8882         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8883         istreambuf_iterator_wchar first={0}, last={0};
8884
8885         first.strbuf = strbuf;
8886         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
8887     }
8888     basic_istream_wchar_sentry_destroy(this);
8889
8890     basic_ios_wchar_setstate(base, state);
8891     return this;
8892 }
8893
8894 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
8895 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
8896 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
8897 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
8898 {
8899     return basic_istream_read_int64(this, v, num_get_short_use_facet(
8900                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8901 }
8902
8903 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
8904 {
8905     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8906     int state = IOSTATE_goodbit;
8907
8908     TRACE("(%p %p)\n", this, v);
8909
8910     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8911         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8912         istreambuf_iterator_wchar first={0}, last={0};
8913
8914         first.strbuf = strbuf;
8915         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
8916     }
8917     basic_istream_wchar_sentry_destroy(this);
8918
8919     basic_ios_wchar_setstate(base, state);
8920     return this;
8921 }
8922
8923 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
8924 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
8925 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
8926 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
8927 {
8928     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
8929                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8930 }
8931
8932 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
8933 {
8934     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8935     int state = IOSTATE_goodbit;
8936
8937     TRACE("(%p %p)\n", this, v);
8938
8939     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8940         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8941         istreambuf_iterator_wchar first={0}, last={0};
8942
8943         first.strbuf = strbuf;
8944         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
8945     }
8946     basic_istream_wchar_sentry_destroy(this);
8947
8948     basic_ios_wchar_setstate(base, state);
8949     return this;
8950 }
8951
8952 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
8953 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
8954 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
8955 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
8956 {
8957     return basic_istream_read_bool(this, v, num_get_short_use_facet(
8958                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8959 }
8960
8961 /* ??$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 */
8962 /* ??$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 */
8963 /* ??$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 */
8964 /* ??$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 */
8965 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr_delim(
8966         basic_istream_wchar *istream, basic_string_wchar *str, wchar_t delim)
8967 {
8968     IOSB_iostate state = IOSTATE_failbit;
8969     int c = delim;
8970
8971     TRACE("(%p %p %c)\n", istream, str, delim);
8972
8973     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8974         basic_string_wchar_clear(str);
8975
8976         c = basic_istream_wchar_get(istream);
8977         if(c != WEOF)
8978             state = IOSTATE_goodbit;
8979
8980         for(; c!=delim && c!=WEOF; c = basic_istream_wchar_get(istream)) {
8981             state = IOSTATE_goodbit;
8982             basic_string_wchar_append_ch(str, c);
8983         }
8984     }
8985     basic_istream_wchar_sentry_destroy(istream);
8986
8987     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
8988             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8989     return istream;
8990 }
8991
8992 /* ??$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 */
8993 /* ??$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 */
8994 /* ??$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 */
8995 /* ??$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 */
8996 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr(
8997         basic_istream_wchar *istream, basic_string_wchar *str)
8998 {
8999     return basic_istream_wchar_getline_bstr_delim(istream, str, '\n');
9000 }
9001
9002 static basic_istream_wchar* basic_istream_read_bstr(basic_istream_wchar *istream,
9003         basic_string_wchar *str, const ctype_wchar *ctype)
9004 {
9005     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9006     IOSB_iostate state = IOSTATE_failbit;
9007     int c = '\n';
9008
9009     TRACE("(%p %p)\n", istream, str);
9010
9011     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9012         MSVCP_size_t count = ios_base_width_get(&base->base);
9013
9014         if(!count)
9015             count = -1;
9016
9017         basic_string_wchar_clear(str);
9018
9019         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9020                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9021                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9022             state = IOSTATE_goodbit;
9023             basic_string_wchar_append_ch(str, c);
9024         }
9025     }
9026     basic_istream_wchar_sentry_destroy(istream);
9027
9028     ios_base_width_set(&base->base, 0);
9029     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9030     return istream;
9031 }
9032
9033 /* ??$?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 */
9034 /* ??$?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 */
9035 basic_istream_wchar* __cdecl basic_istream_wchar_read_bstr(
9036         basic_istream_wchar *istream, basic_string_wchar *str)
9037 {
9038     return basic_istream_read_bstr(istream, str, ctype_wchar_use_facet(
9039                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9040 }
9041
9042 /* ??$?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 */
9043 /* ??$?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 */
9044 basic_istream_wchar* __cdecl basic_istream_short_read_bstr(
9045         basic_istream_wchar *istream, basic_string_wchar *str)
9046 {
9047     return basic_istream_read_bstr(istream, str, ctype_short_use_facet(
9048                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9049 }
9050
9051 static basic_istream_wchar* basic_istream_read_str(basic_istream_wchar *istream, wchar_t *str, const ctype_wchar *ctype)
9052 {
9053     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9054     IOSB_iostate state = IOSTATE_failbit;
9055     unsigned short c = '\n';
9056
9057     TRACE("(%p %p)\n", istream, str);
9058
9059     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9060         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
9061
9062         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9063                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9064                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9065             state = IOSTATE_goodbit;
9066             *str++ = c;
9067         }
9068     }
9069     basic_istream_wchar_sentry_destroy(istream);
9070
9071     *str = 0;
9072     ios_base_width_set(&base->base, 0);
9073     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9074     return istream;
9075 }
9076
9077 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@PAG@Z */
9078 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@PEAG@Z */
9079 basic_istream_wchar* __cdecl basic_istream_short_read_str(basic_istream_wchar *istream, wchar_t *str)
9080 {
9081     return basic_istream_read_str(istream, str, ctype_short_use_facet(
9082                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9083 }
9084
9085 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AA_W@Z */
9086 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEA_W@Z */
9087 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAG@Z */
9088 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAG@Z */
9089 basic_istream_wchar* __cdecl basic_istream_wchar_read_ch(basic_istream_wchar *istream, wchar_t *ch)
9090 {
9091     IOSB_iostate state = IOSTATE_failbit;
9092     unsigned short c = 0;
9093
9094     TRACE("(%p %p)\n", istream, ch);
9095
9096     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9097         c = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(
9098                     basic_istream_wchar_get_basic_ios(istream)));
9099         if(c != WEOF) {
9100             state = IOSTATE_goodbit;
9101             *ch = c;
9102         }
9103     }
9104     basic_istream_wchar_sentry_destroy(istream);
9105
9106     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9107             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9108     return istream;
9109 }
9110
9111 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9112 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9113 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9114 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9115 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
9116 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
9117         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
9118 {
9119     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9120     IOSB_iostate state = IOSTATE_failbit;
9121     unsigned short c = '\n';
9122
9123     TRACE("(%p %p)\n", this, streambuf);
9124
9125     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9126         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
9127                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
9128             state = IOSTATE_goodbit;
9129             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
9130                 break;
9131         }
9132     }
9133     basic_istream_wchar_sentry_destroy(this);
9134
9135     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9136     return this;
9137 }
9138
9139 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9140 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9141 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9142 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9143 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
9144 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
9145         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
9146 {
9147     TRACE("(%p %p)\n", this, pfunc);
9148     pfunc(this);
9149     return this;
9150 }
9151
9152 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
9153 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
9154 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
9155 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
9156 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
9157 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
9158         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
9159 {
9160     TRACE("(%p %p)\n", this, pfunc);
9161     pfunc(basic_istream_wchar_get_basic_ios(this));
9162     return this;
9163 }
9164
9165 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9166 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9167 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9168 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9169 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
9170 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
9171         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
9172 {
9173     TRACE("(%p %p)\n", this, pfunc);
9174     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
9175     return this;
9176 }
9177
9178 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
9179 {
9180     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
9181 }
9182
9183 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
9184 {
9185     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
9186 }
9187
9188 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9189 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9190 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
9191 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
9192 {
9193     basic_ios_char *basic_ios;
9194
9195     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9196
9197     if(virt_init) {
9198         this->base1.vbtable = basic_iostream_char_vbtable1;
9199         this->base2.vbtable = basic_iostream_char_vbtable2;
9200         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9201         basic_ios_char_ctor(basic_ios);
9202     }else {
9203         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9204     }
9205
9206     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
9207
9208     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
9209     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9210     return this;
9211 }
9212
9213 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9214 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9215 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
9216 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
9217 {
9218     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9219
9220     TRACE("(%p)\n", this);
9221     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
9222     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
9223 }
9224
9225 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9226 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9227 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
9228 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
9229 {
9230     TRACE("(%p)\n", this);
9231     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
9232     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
9233 }
9234
9235 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
9236 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9237 {
9238     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9239
9240     TRACE("(%p %x)\n", this, flags);
9241
9242     if(flags & 2) {
9243         /* we have an array, with the number of elements stored before the first object */
9244         INT_PTR i, *ptr = (INT_PTR *)this-1;
9245
9246         for(i=*ptr-1; i>=0; i--)
9247             basic_iostream_char_vbase_dtor(this+i);
9248         MSVCRT_operator_delete(ptr);
9249     } else {
9250         basic_iostream_char_vbase_dtor(this);
9251         if(flags & 1)
9252             MSVCRT_operator_delete(this);
9253     }
9254
9255     return this;
9256 }
9257
9258 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
9259 {
9260     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
9261 }
9262
9263 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9264 {
9265     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
9266 }
9267
9268 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9269 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9270 static basic_iostream_wchar* basic_iostream_wchar_ctor(basic_iostream_wchar *this,
9271         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9272 {
9273     basic_ios_wchar *basic_ios;
9274
9275     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9276
9277     if(virt_init) {
9278         this->base1.vbtable = basic_iostream_wchar_vbtable1;
9279         this->base2.vbtable = basic_iostream_wchar_vbtable2;
9280         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9281         basic_ios_wchar_ctor(basic_ios);
9282     }else {
9283         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9284     }
9285
9286     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
9287     basic_ostream_wchar_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9288
9289     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
9290     return this;
9291 }
9292
9293 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9294 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9295 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
9296 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
9297         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9298 {
9299     basic_iostream_wchar_ctor(this, strbuf, virt_init);
9300     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
9301     return this;
9302 }
9303
9304 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9305 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9306 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9307 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9308 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
9309 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
9310 {
9311     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9312
9313     TRACE("(%p)\n", this);
9314     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
9315     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
9316 }
9317
9318 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9319 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9320 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9321 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9322 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
9323 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
9324 {
9325     TRACE("(%p)\n", this);
9326     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
9327     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
9328 }
9329
9330 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
9331 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9332 {
9333     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9334
9335     TRACE("(%p %x)\n", this, flags);
9336
9337     if(flags & 2) {
9338         /* we have an array, with the number of elements stored before the first object */
9339         INT_PTR i, *ptr = (INT_PTR *)this-1;
9340
9341         for(i=*ptr-1; i>=0; i--)
9342             basic_iostream_wchar_vbase_dtor(this+i);
9343         MSVCRT_operator_delete(ptr);
9344     } else {
9345         basic_iostream_wchar_vbase_dtor(this);
9346         if(flags & 1)
9347             MSVCRT_operator_delete(this);
9348     }
9349
9350     return this;
9351 }
9352
9353 static inline basic_ios_char* basic_ofstream_char_to_basic_ios(basic_ofstream_char *ptr)
9354 {
9355     return (basic_ios_char*)((char*)ptr+basic_ofstream_char_vbtable[1]);
9356 }
9357
9358 static inline basic_ofstream_char* basic_ofstream_char_from_basic_ios(basic_ios_char *ptr)
9359 {
9360     return (basic_ofstream_char*)((char*)ptr-basic_ofstream_char_vbtable[1]);
9361 }
9362
9363 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9364 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9365 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
9366 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
9367 {
9368     basic_ios_char *basic_ios;
9369
9370     TRACE("(%p %d)\n", this, virt_init);
9371
9372     if(virt_init) {
9373         this->base.vbtable = basic_ofstream_char_vbtable;
9374         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9375         basic_ios_char_ctor(basic_ios);
9376     }else {
9377         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9378     }
9379
9380     basic_filebuf_char_ctor(&this->filebuf);
9381     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9382     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9383     return this;
9384 }
9385
9386 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9387 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9388 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
9389 void __thiscall basic_ofstream_char_dtor(basic_ios_char *base)
9390 {
9391     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9392
9393     TRACE("(%p)\n", this);
9394
9395     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
9396     basic_filebuf_char_dtor(&this->filebuf);
9397 }
9398
9399 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9400 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9401 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
9402 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
9403 {
9404     TRACE("(%p)\n", this);
9405
9406     basic_ofstream_char_dtor(basic_ofstream_char_to_basic_ios(this));
9407     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
9408 }
9409
9410 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vector_dtor, 8)
9411 basic_ofstream_char* __thiscall basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9412 {
9413     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9414
9415     TRACE("(%p %x)\n", this, flags);
9416
9417     if(flags & 2) {
9418         /* we have an array, with the number of elements stored before the first object */
9419         INT_PTR i, *ptr = (INT_PTR *)this-1;
9420
9421         for(i=*ptr-1; i>=0; i--)
9422             basic_ofstream_char_vbase_dtor(this+i);
9423         MSVCRT_operator_delete(ptr);
9424     } else {
9425         basic_ofstream_char_vbase_dtor(this);
9426         if(flags & 1)
9427             MSVCRT_operator_delete(this);
9428     }
9429
9430     return this;
9431 }
9432
9433 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9434 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9435 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
9436 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
9437 {
9438     TRACE("(%p)\n", this);
9439
9440     if(!basic_filebuf_char_close(&this->filebuf)) {
9441         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9442         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9443     }
9444 }
9445
9446 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
9447 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
9448 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
9449 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
9450 {
9451     TRACE("(%p)\n", this);
9452     return basic_filebuf_char_is_open(&this->filebuf);
9453 }
9454
9455 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
9456 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
9457 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 12)
9458 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
9459         const char *name, int mode)
9460 {
9461     TRACE("(%p %s %d)\n", this, name, mode);
9462
9463     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9464         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9465         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9466     }
9467 }
9468
9469 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
9470 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
9471 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
9472 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
9473         const char *name, short mode)
9474 {
9475     basic_ofstream_char_open(this, name, mode);
9476 }
9477
9478 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9479 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9480 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
9481 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
9482 {
9483     TRACE("(%p)\n", this);
9484     return (basic_filebuf_char*)&this->filebuf;
9485 }
9486
9487 static inline basic_ios_wchar* basic_ofstream_wchar_to_basic_ios(basic_ofstream_wchar *ptr)
9488 {
9489     return (basic_ios_wchar*)((char*)ptr+basic_ofstream_wchar_vbtable[1]);
9490 }
9491
9492 static inline basic_ofstream_wchar* basic_ofstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9493 {
9494     return (basic_ofstream_wchar*)((char*)ptr-basic_ofstream_wchar_vbtable[1]);
9495 }
9496
9497 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
9498 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
9499 static basic_ofstream_wchar* basic_ofstream_wchar_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9500 {
9501     basic_ios_wchar *basic_ios;
9502
9503     TRACE("(%p %d)\n", this, virt_init);
9504
9505     if(virt_init) {
9506         this->base.vbtable = basic_ofstream_wchar_vbtable;
9507         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9508         basic_ios_wchar_ctor(basic_ios);
9509     }else {
9510         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9511     }
9512
9513     basic_filebuf_wchar_ctor(&this->filebuf);
9514     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9515     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
9516     return this;
9517 }
9518
9519 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
9520 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
9521 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor, 8)
9522 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9523 {
9524     basic_ofstream_wchar_ctor(this, virt_init);
9525     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
9526     return this;
9527 }
9528
9529 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9530 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9531 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9532 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9533 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_dtor, 4)
9534 void __thiscall basic_ofstream_wchar_dtor(basic_ios_wchar *base)
9535 {
9536     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9537
9538     TRACE("(%p)\n", this);
9539
9540     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
9541     basic_filebuf_wchar_dtor(&this->filebuf);
9542 }
9543
9544 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9545 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9546 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9547 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9548 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vbase_dtor, 4)
9549 void __thiscall basic_ofstream_wchar_vbase_dtor(basic_ofstream_wchar *this)
9550 {
9551     TRACE("(%p)\n", this);
9552
9553     basic_ofstream_wchar_dtor(basic_ofstream_wchar_to_basic_ios(this));
9554     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
9555 }
9556
9557 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vector_dtor, 8)
9558 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9559 {
9560     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9561
9562     TRACE("(%p %x)\n", this, flags);
9563
9564     if(flags & 2) {
9565         /* we have an array, with the number of elements stored before the first object */
9566         INT_PTR i, *ptr = (INT_PTR *)this-1;
9567
9568         for(i=*ptr-1; i>=0; i--)
9569             basic_ofstream_wchar_vbase_dtor(this+i);
9570         MSVCRT_operator_delete(ptr);
9571     } else {
9572         basic_ofstream_wchar_vbase_dtor(this);
9573         if(flags & 1)
9574             MSVCRT_operator_delete(this);
9575     }
9576
9577     return this;
9578 }
9579
9580 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9581 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9582 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9583 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9584 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_close, 4)
9585 void __thiscall basic_ofstream_wchar_close(basic_ofstream_wchar *this)
9586 {
9587     TRACE("(%p)\n", this);
9588
9589     if(!basic_filebuf_wchar_close(&this->filebuf)) {
9590         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9591         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9592     }
9593 }
9594
9595 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
9596 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
9597 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
9598 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
9599 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_is_open, 4)
9600 MSVCP_bool __thiscall basic_ofstream_wchar_is_open(const basic_ofstream_wchar *this)
9601 {
9602     TRACE("(%p)\n", this);
9603     return basic_filebuf_wchar_is_open(&this->filebuf);
9604 }
9605
9606 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
9607 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
9608 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open, 12)
9609 void __thiscall basic_ofstream_wchar_open(basic_ofstream_wchar *this,
9610         const char *name, int mode)
9611 {
9612     TRACE("(%p %s %d)\n", this, name, mode);
9613
9614     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9615         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9616         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9617     }
9618 }
9619
9620 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
9621 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
9622 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_old, 12)
9623 void __thiscall basic_ofstream_wchar_open_old(basic_ofstream_wchar *this,
9624         const char *name, int mode)
9625 {
9626     basic_ofstream_wchar_open(this, name, mode);
9627 }
9628
9629 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9630 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9631 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9632 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9633 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_rdbuf, 4)
9634 basic_filebuf_wchar* __thiscall basic_ofstream_wchar_rdbuf(const basic_ofstream_wchar *this)
9635 {
9636     TRACE("(%p)\n", this);
9637     return (basic_filebuf_wchar*)&this->filebuf;
9638 }
9639
9640 static inline basic_ios_char* basic_ifstream_char_to_basic_ios(basic_ifstream_char *ptr)
9641 {
9642     return (basic_ios_char*)((char*)ptr+basic_ifstream_char_vbtable[1]);
9643 }
9644
9645 static inline basic_ifstream_char* basic_ifstream_char_from_basic_ios(basic_ios_char *ptr)
9646 {
9647     return (basic_ifstream_char*)((char*)ptr-basic_ifstream_char_vbtable[1]);
9648 }
9649
9650 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9651 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9652 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
9653 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
9654 {
9655     basic_ios_char *basic_ios;
9656
9657     TRACE("(%p %d)\n", this, virt_init);
9658
9659     if(virt_init) {
9660         this->base.vbtable = basic_ifstream_char_vbtable;
9661         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9662         basic_ios_char_ctor(basic_ios);
9663     }else {
9664         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9665     }
9666
9667     basic_filebuf_char_ctor(&this->filebuf);
9668     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9669     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
9670     return this;
9671 }
9672
9673 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9674 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9675 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
9676 void __thiscall basic_ifstream_char_dtor(basic_ios_char *base)
9677 {
9678     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9679
9680     TRACE("(%p)\n", this);
9681
9682     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
9683     basic_filebuf_char_dtor(&this->filebuf);
9684 }
9685
9686 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9687 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9688 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
9689 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
9690 {
9691     TRACE("(%p)\n", this);
9692
9693     basic_ifstream_char_dtor(basic_ifstream_char_to_basic_ios(this));
9694     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
9695 }
9696
9697 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vector_dtor, 8)
9698 basic_ifstream_char* __thiscall basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9699 {
9700     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9701
9702     TRACE("(%p %x)\n", this, flags);
9703
9704     if(flags & 2) {
9705         /* we have an array, with the number of elements stored before the first object */
9706         INT_PTR i, *ptr = (INT_PTR *)this-1;
9707
9708         for(i=*ptr-1; i>=0; i--)
9709             basic_ifstream_char_vbase_dtor(this+i);
9710         MSVCRT_operator_delete(ptr);
9711     } else {
9712         basic_ifstream_char_vbase_dtor(this);
9713         if(flags & 1)
9714             MSVCRT_operator_delete(this);
9715     }
9716
9717     return this;
9718 }
9719
9720 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9721 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9722 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
9723 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
9724 {
9725     TRACE("(%p)\n", this);
9726
9727     if(!basic_filebuf_char_close(&this->filebuf)) {
9728         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9729         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9730     }
9731 }
9732
9733 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
9734 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
9735 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
9736 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
9737 {
9738     TRACE("(%p)\n", this);
9739     return basic_filebuf_char_is_open(&this->filebuf);
9740 }
9741
9742 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
9743 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
9744 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 12)
9745 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
9746         const char *name, int mode)
9747 {
9748     TRACE("(%p %s %d)\n", this, name, mode);
9749
9750     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9751         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9752         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9753     }
9754 }
9755
9756 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
9757 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
9758 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
9759 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
9760         const char *name, short mode)
9761 {
9762     basic_ifstream_char_open(this, name, mode);
9763 }
9764
9765 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9766 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9767 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
9768 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
9769 {
9770     TRACE("(%p)\n", this);
9771     return (basic_filebuf_char*)&this->filebuf;
9772 }
9773
9774 static inline basic_ios_wchar* basic_ifstream_wchar_to_basic_ios(basic_ifstream_wchar *ptr)
9775 {
9776     return (basic_ios_wchar*)((char*)ptr+basic_ifstream_wchar_vbtable[1]);
9777 }
9778
9779 static inline basic_ifstream_wchar* basic_ifstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9780 {
9781     return (basic_ifstream_wchar*)((char*)ptr-basic_ifstream_wchar_vbtable[1]);
9782 }
9783
9784 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
9785 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
9786 static basic_ifstream_wchar* basic_ifstream_wchar_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
9787 {
9788     basic_ios_wchar *basic_ios;
9789
9790     TRACE("(%p %d)\n", this, virt_init);
9791
9792     if(virt_init) {
9793         this->base.vbtable = basic_ifstream_wchar_vbtable;
9794         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9795         basic_ios_wchar_ctor(basic_ios);
9796     }else {
9797         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9798     }
9799
9800     basic_filebuf_wchar_ctor(&this->filebuf);
9801     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9802     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
9803     return this;
9804 }
9805
9806 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
9807 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
9808 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor, 8)
9809 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
9810 {
9811     basic_ifstream_wchar_ctor(this, virt_init);
9812     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
9813     return this;
9814 }
9815
9816 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9817 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9818 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9819 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9820 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_dtor, 4)
9821 void __thiscall basic_ifstream_wchar_dtor(basic_ios_wchar *base)
9822 {
9823     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
9824
9825     TRACE("(%p)\n", this);
9826
9827     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
9828     basic_filebuf_wchar_dtor(&this->filebuf);
9829 }
9830
9831 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9832 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9833 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9834 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9835 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vbase_dtor, 4)
9836 void __thiscall basic_ifstream_wchar_vbase_dtor(basic_ifstream_wchar *this)
9837 {
9838     TRACE("(%p)\n", this);
9839
9840     basic_ifstream_wchar_dtor(basic_ifstream_wchar_to_basic_ios(this));
9841     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
9842 }
9843
9844 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vector_dtor, 8)
9845 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9846 {
9847     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
9848
9849     TRACE("(%p %x)\n", this, flags);
9850
9851     if(flags & 2) {
9852         /* we have an array, with the number of elements stored before the first object */
9853         INT_PTR i, *ptr = (INT_PTR *)this-1;
9854
9855         for(i=*ptr-1; i>=0; i--)
9856             basic_ifstream_wchar_vbase_dtor(this+i);
9857         MSVCRT_operator_delete(ptr);
9858     } else {
9859         basic_ifstream_wchar_vbase_dtor(this);
9860         if(flags & 1)
9861             MSVCRT_operator_delete(this);
9862     }
9863
9864     return this;
9865 }
9866
9867 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9868 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9869 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9870 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9871 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_close, 4)
9872 void __thiscall basic_ifstream_wchar_close(basic_ifstream_wchar *this)
9873 {
9874     TRACE("(%p)\n", this);
9875
9876     if(!basic_filebuf_wchar_close(&this->filebuf)) {
9877         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9878         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9879     }
9880 }
9881
9882 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
9883 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
9884 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
9885 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
9886 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_is_open, 4)
9887 MSVCP_bool __thiscall basic_ifstream_wchar_is_open(const basic_ifstream_wchar *this)
9888 {
9889     TRACE("(%p)\n", this);
9890     return basic_filebuf_wchar_is_open(&this->filebuf);
9891 }
9892
9893 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
9894 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
9895 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open, 12)
9896 void __thiscall basic_ifstream_wchar_open(basic_ifstream_wchar *this,
9897         const char *name, int mode)
9898 {
9899     TRACE("(%p %s %d)\n", this, name, mode);
9900
9901     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9902         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9903         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9904     }
9905 }
9906
9907 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
9908 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
9909 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_old, 12)
9910 void __thiscall basic_ifstream_wchar_open_old(basic_ifstream_wchar *this,
9911         const char *name, short mode)
9912 {
9913     basic_ifstream_wchar_open(this, name, mode);
9914 }
9915
9916 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9917 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9918 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9919 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9920 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_rdbuf, 4)
9921 basic_filebuf_wchar* __thiscall basic_ifstream_wchar_rdbuf(const basic_ifstream_wchar *this)
9922 {
9923     TRACE("(%p)\n", this);
9924     return (basic_filebuf_wchar*)&this->filebuf;
9925 }
9926
9927 static inline basic_ios_char* basic_fstream_char_to_basic_ios(basic_fstream_char *ptr)
9928 {
9929     return (basic_ios_char*)((char*)ptr+basic_fstream_char_vbtable1[1]);
9930 }
9931
9932 static inline basic_fstream_char* basic_fstream_char_from_basic_ios(basic_ios_char *ptr)
9933 {
9934     return (basic_fstream_char*)((char*)ptr-basic_fstream_char_vbtable1[1]);
9935 }
9936
9937 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9938 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9939 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
9940 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
9941 {
9942     basic_ios_char *basic_ios;
9943
9944     TRACE("(%p %d)\n", this, virt_init);
9945
9946     if(virt_init) {
9947         this->base.base1.vbtable = basic_fstream_char_vbtable1;
9948         this->base.base2.vbtable = basic_fstream_char_vbtable2;
9949         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
9950         basic_ios_char_ctor(basic_ios);
9951     }else {
9952         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
9953     }
9954
9955     basic_filebuf_char_ctor(&this->filebuf);
9956     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
9957     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
9958     return this;
9959 }
9960
9961 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9962 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9963 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
9964 void __thiscall basic_fstream_char_dtor(basic_ios_char *base)
9965 {
9966     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
9967
9968     TRACE("(%p)\n", this);
9969
9970     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
9971     basic_filebuf_char_dtor(&this->filebuf);
9972 }
9973
9974 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9975 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9976 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
9977 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
9978 {
9979     TRACE("(%p)\n", this);
9980
9981     basic_fstream_char_dtor(basic_fstream_char_to_basic_ios(this));
9982     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
9983 }
9984
9985 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vector_dtor, 8)
9986 basic_fstream_char* __thiscall basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9987 {
9988     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
9989
9990     TRACE("(%p %x)\n", this, flags);
9991
9992     if(flags & 2) {
9993         /* we have an array, with the number of elements stored before the first object */
9994         INT_PTR i, *ptr = (INT_PTR *)this-1;
9995
9996         for(i=*ptr-1; i>=0; i--)
9997             basic_fstream_char_vbase_dtor(this+i);
9998         MSVCRT_operator_delete(ptr);
9999     } else {
10000         basic_fstream_char_vbase_dtor(this);
10001         if(flags & 1)
10002             MSVCRT_operator_delete(this);
10003     }
10004
10005     return this;
10006 }
10007
10008 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10009 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10010 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
10011 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
10012 {
10013     TRACE("(%p)\n", this);
10014
10015     if(!basic_filebuf_char_close(&this->filebuf)) {
10016         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10017         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10018     }
10019 }
10020
10021 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10022 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10023 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
10024 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
10025 {
10026     TRACE("(%p)\n", this);
10027     return basic_filebuf_char_is_open(&this->filebuf);
10028 }
10029
10030 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
10031 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
10032 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 12)
10033 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
10034         const char *name, int mode)
10035 {
10036     TRACE("(%p %s %d)\n", this, name, mode);
10037
10038     if(!basic_filebuf_char_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10039         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10040         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10041     }
10042 }
10043
10044 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
10045 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
10046 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
10047 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
10048         const char *name, int mode)
10049 {
10050     basic_fstream_char_open(this, name, mode);
10051 }
10052
10053 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10054 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10055 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
10056 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
10057 {
10058     TRACE("(%p)\n", this);
10059     return (basic_filebuf_char*)&this->filebuf;
10060 }
10061
10062 static inline basic_ios_wchar* basic_fstream_wchar_to_basic_ios(basic_fstream_wchar *ptr)
10063 {
10064     return (basic_ios_wchar*)((char*)ptr+basic_fstream_wchar_vbtable1[1]);
10065 }
10066
10067 static inline basic_fstream_wchar* basic_fstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10068 {
10069     return (basic_fstream_wchar*)((char*)ptr-basic_fstream_wchar_vbtable1[1]);
10070 }
10071
10072 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10073 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10074 static basic_fstream_wchar* basic_fstream_wchar_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10075 {
10076     basic_ios_wchar *basic_ios;
10077
10078     TRACE("(%p %d)\n", this, virt_init);
10079
10080     if(virt_init) {
10081         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10082         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10083         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10084         basic_ios_wchar_ctor(basic_ios);
10085     }else {
10086         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10087     }
10088
10089     basic_filebuf_wchar_ctor(&this->filebuf);
10090     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10091     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10092     return this;
10093 }
10094
10095 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10096 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10097 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor, 8)
10098 basic_fstream_wchar* __thiscall basic_fstream_short_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10099 {
10100     basic_fstream_wchar_ctor(this, virt_init);
10101     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
10102     return this;
10103 }
10104
10105 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10106 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10107 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10108 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10109 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_dtor, 4)
10110 void __thiscall basic_fstream_wchar_dtor(basic_ios_wchar *base)
10111 {
10112     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10113
10114     TRACE("(%p)\n", this);
10115
10116     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
10117     basic_filebuf_wchar_dtor(&this->filebuf);
10118 }
10119
10120 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10121 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10122 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10123 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10124 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vbase_dtor, 4)
10125 void __thiscall basic_fstream_wchar_vbase_dtor(basic_fstream_wchar *this)
10126 {
10127     TRACE("(%p)\n", this);
10128
10129     basic_fstream_wchar_dtor(basic_fstream_wchar_to_basic_ios(this));
10130     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
10131 }
10132
10133 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vector_dtor, 8)
10134 basic_fstream_wchar* __thiscall basic_fstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10135 {
10136     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10137
10138     TRACE("(%p %x)\n", this, flags);
10139
10140     if(flags & 2) {
10141         /* we have an array, with the number of elements stored before the first object */
10142         INT_PTR i, *ptr = (INT_PTR *)this-1;
10143
10144         for(i=*ptr-1; i>=0; i--)
10145             basic_fstream_wchar_vbase_dtor(this+i);
10146         MSVCRT_operator_delete(ptr);
10147     } else {
10148         basic_fstream_wchar_vbase_dtor(this);
10149         if(flags & 1)
10150             MSVCRT_operator_delete(this);
10151     }
10152
10153     return this;
10154 }
10155
10156 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10157 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10158 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10159 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10160 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_close, 4)
10161 void __thiscall basic_fstream_wchar_close(basic_fstream_wchar *this)
10162 {
10163     TRACE("(%p)\n", this);
10164
10165     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10166         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10167         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10168     }
10169 }
10170
10171 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10172 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10173 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10174 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10175 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_is_open, 4)
10176 MSVCP_bool __thiscall basic_fstream_wchar_is_open(const basic_fstream_wchar *this)
10177 {
10178     TRACE("(%p)\n", this);
10179     return basic_filebuf_wchar_is_open(&this->filebuf);
10180 }
10181
10182 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
10183 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
10184 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open, 12)
10185 void __thiscall basic_fstream_wchar_open(basic_fstream_wchar *this,
10186         const char *name, int mode)
10187 {
10188     TRACE("(%p %s %d)\n", this, name, mode);
10189
10190     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10191         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10192         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10193     }
10194 }
10195
10196 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
10197 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
10198 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_old, 12)
10199 void __thiscall basic_fstream_wchar_open_old(basic_fstream_wchar *this,
10200         const char *name, int mode)
10201 {
10202     basic_fstream_wchar_open(this, name, mode);
10203 }
10204
10205 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10206 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10207 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10208 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10209 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_rdbuf, 4)
10210 basic_filebuf_wchar* __thiscall basic_fstream_wchar_rdbuf(const basic_fstream_wchar *this)
10211 {
10212     TRACE("(%p)\n", this);
10213     return (basic_filebuf_wchar*)&this->filebuf;
10214 }
10215
10216 static inline basic_ios_char* basic_ostringstream_char_to_basic_ios(basic_ostringstream_char *ptr)
10217 {
10218     return (basic_ios_char*)((char*)ptr+basic_ostringstream_char_vbtable[1]);
10219 }
10220
10221 static inline basic_ostringstream_char* basic_ostringstream_char_from_basic_ios(basic_ios_char *ptr)
10222 {
10223     return (basic_ostringstream_char*)((char*)ptr-basic_ostringstream_char_vbtable[1]);
10224 }
10225
10226 /* ??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 */
10227 /* ??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 */
10228 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_str, 16)
10229 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_str(basic_ostringstream_char *this,
10230         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10231 {
10232     basic_ios_char *basic_ios;
10233
10234     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10235
10236     if(virt_init) {
10237         this->base.vbtable = basic_ostringstream_char_vbtable;
10238         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10239         basic_ios_char_ctor(basic_ios);
10240     }else {
10241         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10242     }
10243
10244     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10245     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10246     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10247     return this;
10248 }
10249
10250 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
10251 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
10252 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_mode, 12)
10253 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_mode(
10254         basic_ostringstream_char *this, int mode, MSVCP_bool virt_init)
10255 {
10256     basic_ios_char *basic_ios;
10257
10258     TRACE("(%p %d %d)\n", this, mode, virt_init);
10259
10260     if(virt_init) {
10261         this->base.vbtable = basic_ostringstream_char_vbtable;
10262         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10263         basic_ios_char_ctor(basic_ios);
10264     }else {
10265         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10266     }
10267
10268     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10269     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10270     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10271     return this;
10272 }
10273
10274 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10275 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10276 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor, 8)
10277 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor(
10278         basic_ostringstream_char *this, MSVCP_bool virt_init)
10279 {
10280     return basic_ostringstream_char_ctor_mode(this, 0, virt_init);
10281 }
10282
10283 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
10284 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
10285 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_dtor, 4)
10286 void __thiscall basic_ostringstream_char_dtor(basic_ios_char *base)
10287 {
10288     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10289
10290     TRACE("(%p)\n", this);
10291
10292     basic_stringbuf_char_dtor(&this->strbuf);
10293     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
10294 }
10295
10296 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10297 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10298 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vbase_dtor, 4)
10299 void __thiscall basic_ostringstream_char_vbase_dtor(basic_ostringstream_char *this)
10300 {
10301     TRACE("(%p)\n", this);
10302
10303     basic_ostringstream_char_dtor(basic_ostringstream_char_to_basic_ios(this));
10304     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
10305 }
10306
10307 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vector_dtor, 8)
10308 basic_ostringstream_char* __thiscall basic_ostringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10309 {
10310     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10311
10312     TRACE("(%p %x)\n", this, flags);
10313
10314     if(flags & 2) {
10315         /* we have an array, with the number of elements stored before the first object */
10316         INT_PTR i, *ptr = (INT_PTR *)this-1;
10317
10318         for(i=*ptr-1; i>=0; i--)
10319             basic_ostringstream_char_vbase_dtor(this+i);
10320         MSVCRT_operator_delete(ptr);
10321     } else {
10322         basic_ostringstream_char_vbase_dtor(this);
10323         if(flags & 1)
10324             MSVCRT_operator_delete(this);
10325     }
10326
10327     return this;
10328 }
10329
10330 /* ?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 */
10331 /* ?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 */
10332 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_rdbuf, 4)
10333 basic_stringbuf_char* __thiscall basic_ostringstream_char_rdbuf(const basic_ostringstream_char *this)
10334 {
10335     TRACE("(%p)\n", this);
10336     return (basic_stringbuf_char*)&this->strbuf;
10337 }
10338
10339 /* ?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 */
10340 /* ?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 */
10341 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_set, 8)
10342 void __thiscall basic_ostringstream_char_str_set(basic_ostringstream_char *this, const basic_string_char *str)
10343 {
10344     TRACE("(%p %p)\n", this, str);
10345     basic_stringbuf_char_str_set(&this->strbuf, str);
10346 }
10347
10348 /* ?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 */
10349 /* ?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 */
10350 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_get, 8)
10351 basic_string_char* __thiscall basic_ostringstream_char_str_get(const basic_ostringstream_char *this, basic_string_char *ret)
10352 {
10353     TRACE("(%p %p)\n", this, ret);
10354     return basic_stringbuf_char_str_get(&this->strbuf, ret);
10355 }
10356
10357 static inline basic_ios_wchar* basic_ostringstream_wchar_to_basic_ios(basic_ostringstream_wchar *ptr)
10358 {
10359     return (basic_ios_wchar*)((char*)ptr+basic_ostringstream_wchar_vbtable[1]);
10360 }
10361
10362 static inline basic_ostringstream_wchar* basic_ostringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10363 {
10364     return (basic_ostringstream_wchar*)((char*)ptr-basic_ostringstream_wchar_vbtable[1]);
10365 }
10366
10367 /* ??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 */
10368 /* ??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 */
10369 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_str(basic_ostringstream_wchar *this,
10370         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10371 {
10372     basic_ios_wchar *basic_ios;
10373
10374     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10375
10376     if(virt_init) {
10377         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10378         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10379         basic_ios_wchar_ctor(basic_ios);
10380     }else {
10381         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10382     }
10383
10384     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10385     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10386     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10387     return this;
10388 }
10389
10390 /* ??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 */
10391 /* ??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 */
10392 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_str, 16)
10393 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_str(basic_ostringstream_wchar *this,
10394         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10395 {
10396     basic_ostringstream_wchar_ctor_str(this, str, mode, virt_init);
10397     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10398     return this;
10399 }
10400
10401 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
10402 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
10403 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_mode(
10404         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10405 {
10406     basic_ios_wchar *basic_ios;
10407
10408     TRACE("(%p %d %d)\n", this, mode, virt_init);
10409
10410     if(virt_init) {
10411         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10412         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10413         basic_ios_wchar_ctor(basic_ios);
10414     }else {
10415         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10416     }
10417
10418     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10419     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10420     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10421     return this;
10422 }
10423
10424 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
10425 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
10426 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_mode, 12)
10427 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_mode(
10428         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10429 {
10430     basic_ostringstream_wchar_ctor_mode(this, mode, virt_init);
10431     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10432     return this;
10433 }
10434
10435 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10436 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10437 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor, 8)
10438 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor(
10439         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
10440 {
10441     return basic_ostringstream_short_ctor_mode(this, 0, virt_init);
10442 }
10443
10444 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
10445 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
10446 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
10447 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
10448 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_dtor, 4)
10449 void __thiscall basic_ostringstream_wchar_dtor(basic_ios_wchar *base)
10450 {
10451     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10452
10453     TRACE("(%p)\n", this);
10454
10455     basic_stringbuf_wchar_dtor(&this->strbuf);
10456     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
10457 }
10458
10459 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
10460 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
10461 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10462 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10463 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vbase_dtor, 4)
10464 void __thiscall basic_ostringstream_wchar_vbase_dtor(basic_ostringstream_wchar *this)
10465 {
10466     TRACE("(%p)\n", this);
10467
10468     basic_ostringstream_wchar_dtor(basic_ostringstream_wchar_to_basic_ios(this));
10469     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
10470 }
10471
10472 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vector_dtor, 8)
10473 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10474 {
10475     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10476
10477     TRACE("(%p %x)\n", this, flags);
10478
10479     if(flags & 2) {
10480         /* we have an array, with the number of elements stored before the first object */
10481         INT_PTR i, *ptr = (INT_PTR *)this-1;
10482
10483         for(i=*ptr-1; i>=0; i--)
10484             basic_ostringstream_wchar_vbase_dtor(this+i);
10485         MSVCRT_operator_delete(ptr);
10486     } else {
10487         basic_ostringstream_wchar_vbase_dtor(this);
10488         if(flags & 1)
10489             MSVCRT_operator_delete(this);
10490     }
10491
10492     return this;
10493 }
10494
10495 /* ?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 */
10496 /* ?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 */
10497 /* ?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 */
10498 /* ?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 */
10499 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_rdbuf, 4)
10500 basic_stringbuf_wchar* __thiscall basic_ostringstream_wchar_rdbuf(const basic_ostringstream_wchar *this)
10501 {
10502     TRACE("(%p)\n", this);
10503     return (basic_stringbuf_wchar*)&this->strbuf;
10504 }
10505
10506 /* ?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 */
10507 /* ?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 */
10508 /* ?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 */
10509 /* ?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 */
10510 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_set, 8)
10511 void __thiscall basic_ostringstream_wchar_str_set(basic_ostringstream_wchar *this, const basic_string_wchar *str)
10512 {
10513     TRACE("(%p %p)\n", this, str);
10514     basic_stringbuf_wchar_str_set(&this->strbuf, str);
10515 }
10516
10517 /* ?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 */
10518 /* ?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 */
10519 /* ?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 */
10520 /* ?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 */
10521 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_get, 8)
10522 basic_string_wchar* __thiscall basic_ostringstream_wchar_str_get(const basic_ostringstream_wchar *this, basic_string_wchar *ret)
10523 {
10524     TRACE("(%p %p)\n", this, ret);
10525     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
10526 }
10527
10528 static inline basic_ios_char* basic_istringstream_char_to_basic_ios(basic_istringstream_char *ptr)
10529 {
10530     return (basic_ios_char*)((char*)ptr+basic_istringstream_char_vbtable[1]);
10531 }
10532
10533 static inline basic_istringstream_char* basic_istringstream_char_from_basic_ios(basic_ios_char *ptr)
10534 {
10535     return (basic_istringstream_char*)((char*)ptr-basic_istringstream_char_vbtable[1]);
10536 }
10537
10538 /* ??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 */
10539 /* ??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 */
10540 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_str, 16)
10541 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_str(basic_istringstream_char *this,
10542         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10543 {
10544     basic_ios_char *basic_ios;
10545
10546     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10547
10548     if(virt_init) {
10549         this->base.vbtable = basic_istringstream_char_vbtable;
10550         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10551         basic_ios_char_ctor(basic_ios);
10552     }else {
10553         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10554     }
10555
10556     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
10557     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10558     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
10559     return this;
10560 }
10561
10562 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
10563 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
10564 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_mode, 12)
10565 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_mode(
10566         basic_istringstream_char *this, int mode, MSVCP_bool virt_init)
10567 {
10568     basic_ios_char *basic_ios;
10569
10570     TRACE("(%p %d %d)\n", this, mode, virt_init);
10571
10572     if(virt_init) {
10573         this->base.vbtable = basic_istringstream_char_vbtable;
10574         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10575         basic_ios_char_ctor(basic_ios);
10576     }else {
10577         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10578     }
10579
10580     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_in);
10581     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10582     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
10583     return this;
10584 }
10585
10586 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10587 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10588 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor, 8)
10589 basic_istringstream_char* __thiscall basic_istringstream_char_ctor(
10590         basic_istringstream_char *this, MSVCP_bool virt_init)
10591 {
10592     return basic_istringstream_char_ctor_mode(this, 0, virt_init);
10593 }
10594
10595 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
10596 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
10597 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_dtor, 4)
10598 void __thiscall basic_istringstream_char_dtor(basic_ios_char *base)
10599 {
10600     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
10601
10602     TRACE("(%p)\n", this);
10603
10604     basic_stringbuf_char_dtor(&this->strbuf);
10605     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
10606 }
10607
10608 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10609 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10610 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vbase_dtor, 4)
10611 void __thiscall basic_istringstream_char_vbase_dtor(basic_istringstream_char *this)
10612 {
10613     TRACE("(%p)\n", this);
10614
10615     basic_istringstream_char_dtor(basic_istringstream_char_to_basic_ios(this));
10616     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
10617 }
10618
10619 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vector_dtor, 8)
10620 basic_istringstream_char* __thiscall basic_istringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10621 {
10622     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
10623
10624     TRACE("(%p %x)\n", this, flags);
10625
10626     if(flags & 2) {
10627         /* we have an array, with the number of elements stored before the first object */
10628         INT_PTR i, *ptr = (INT_PTR *)this-1;
10629
10630         for(i=*ptr-1; i>=0; i--)
10631             basic_istringstream_char_vbase_dtor(this+i);
10632         MSVCRT_operator_delete(ptr);
10633     } else {
10634         basic_istringstream_char_vbase_dtor(this);
10635         if(flags & 1)
10636             MSVCRT_operator_delete(this);
10637     }
10638
10639     return this;
10640 }
10641
10642 /* ?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 */
10643 /* ?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 */
10644 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_rdbuf, 4)
10645 basic_stringbuf_char* __thiscall basic_istringstream_char_rdbuf(const basic_istringstream_char *this)
10646 {
10647     TRACE("(%p)\n", this);
10648     return (basic_stringbuf_char*)&this->strbuf;
10649 }
10650
10651 /* ?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 */
10652 /* ?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 */
10653 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_set, 8)
10654 void __thiscall basic_istringstream_char_str_set(basic_istringstream_char *this, const basic_string_char *str)
10655 {
10656     TRACE("(%p %p)\n", this, str);
10657     basic_stringbuf_char_str_set(&this->strbuf, str);
10658 }
10659
10660 /* ?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 */
10661 /* ?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 */
10662 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_get, 8)
10663 basic_string_char* __thiscall basic_istringstream_char_str_get(const basic_istringstream_char *this, basic_string_char *ret)
10664 {
10665     TRACE("(%p %p)\n", this, ret);
10666     return basic_stringbuf_char_str_get(&this->strbuf, ret);
10667 }
10668
10669 static inline basic_ios_wchar* basic_istringstream_wchar_to_basic_ios(basic_istringstream_wchar *ptr)
10670 {
10671     return (basic_ios_wchar*)((char*)ptr+basic_istringstream_wchar_vbtable[1]);
10672 }
10673
10674 static inline basic_istringstream_wchar* basic_istringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10675 {
10676     return (basic_istringstream_wchar*)((char*)ptr-basic_istringstream_wchar_vbtable[1]);
10677 }
10678
10679 /* ??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 */
10680 /* ??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 */
10681 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_str(basic_istringstream_wchar *this,
10682         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10683 {
10684     basic_ios_wchar *basic_ios;
10685
10686     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10687
10688     if(virt_init) {
10689         this->base.vbtable = basic_istringstream_wchar_vbtable;
10690         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10691         basic_ios_wchar_ctor(basic_ios);
10692     }else {
10693         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10694     }
10695
10696     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
10697     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10698     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
10699     return this;
10700 }
10701
10702 /* ??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 */
10703 /* ??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 */
10704 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_str, 16)
10705 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_str(basic_istringstream_wchar *this,
10706         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10707 {
10708     basic_istringstream_wchar_ctor_str(this, str, mode, virt_init);
10709     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
10710     return this;
10711 }
10712
10713 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
10714 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
10715 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_mode(
10716         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
10717 {
10718     basic_ios_wchar *basic_ios;
10719
10720     TRACE("(%p %d %d)\n", this, mode, virt_init);
10721
10722     if(virt_init) {
10723         this->base.vbtable = basic_istringstream_wchar_vbtable;
10724         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10725         basic_ios_wchar_ctor(basic_ios);
10726     }else {
10727         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10728     }
10729
10730     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_in);
10731     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10732     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
10733     return this;
10734 }
10735
10736 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
10737 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
10738 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_mode, 12)
10739 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_mode(
10740         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
10741 {
10742     basic_istringstream_wchar_ctor_mode(this, mode, virt_init);
10743     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
10744     return this;
10745 }
10746
10747 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10748 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10749 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor, 8)
10750 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor(
10751         basic_istringstream_wchar *this, MSVCP_bool virt_init)
10752 {
10753     return basic_istringstream_short_ctor_mode(this, 0, virt_init);
10754 }
10755
10756 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
10757 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
10758 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
10759 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
10760 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_dtor, 4)
10761 void __thiscall basic_istringstream_wchar_dtor(basic_ios_wchar *base)
10762 {
10763     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
10764
10765     TRACE("(%p)\n", this);
10766
10767     basic_stringbuf_wchar_dtor(&this->strbuf);
10768     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
10769 }
10770
10771 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
10772 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
10773 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10774 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10775 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vbase_dtor, 4)
10776 void __thiscall basic_istringstream_wchar_vbase_dtor(basic_istringstream_wchar *this)
10777 {
10778     TRACE("(%p)\n", this);
10779
10780     basic_istringstream_wchar_dtor(basic_istringstream_wchar_to_basic_ios(this));
10781     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
10782 }
10783
10784 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vector_dtor, 8)
10785 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10786 {
10787     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
10788
10789     TRACE("(%p %x)\n", this, flags);
10790
10791     if(flags & 2) {
10792         /* we have an array, with the number of elements stored before the first object */
10793         INT_PTR i, *ptr = (INT_PTR *)this-1;
10794
10795         for(i=*ptr-1; i>=0; i--)
10796             basic_istringstream_wchar_vbase_dtor(this+i);
10797         MSVCRT_operator_delete(ptr);
10798     } else {
10799         basic_istringstream_wchar_vbase_dtor(this);
10800         if(flags & 1)
10801             MSVCRT_operator_delete(this);
10802     }
10803
10804     return this;
10805 }
10806
10807 /* ?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 */
10808 /* ?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 */
10809 /* ?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 */
10810 /* ?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 */
10811 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_rdbuf, 4)
10812 basic_stringbuf_wchar* __thiscall basic_istringstream_wchar_rdbuf(const basic_istringstream_wchar *this)
10813 {
10814     TRACE("(%p)\n", this);
10815     return (basic_stringbuf_wchar*)&this->strbuf;
10816 }
10817
10818 /* ?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 */
10819 /* ?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 */
10820 /* ?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 */
10821 /* ?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 */
10822 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_set, 8)
10823 void __thiscall basic_istringstream_wchar_str_set(basic_istringstream_wchar *this, const basic_string_wchar *str)
10824 {
10825     TRACE("(%p %p)\n", this, str);
10826     basic_stringbuf_wchar_str_set(&this->strbuf, str);
10827 }
10828
10829 /* ?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 */
10830 /* ?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 */
10831 /* ?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 */
10832 /* ?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 */
10833 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_get, 8)
10834 basic_string_wchar* __thiscall basic_istringstream_wchar_str_get(const basic_istringstream_wchar *this, basic_string_wchar *ret)
10835 {
10836     TRACE("(%p %p)\n", this, ret);
10837     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
10838 }
10839
10840 static inline basic_ios_char* basic_stringstream_char_to_basic_ios(basic_stringstream_char *ptr)
10841 {
10842     return (basic_ios_char*)((char*)ptr+basic_stringstream_char_vbtable1[1]);
10843 }
10844
10845 static inline basic_stringstream_char* basic_stringstream_char_from_basic_ios(basic_ios_char *ptr)
10846 {
10847     return (basic_stringstream_char*)((char*)ptr-basic_stringstream_char_vbtable1[1]);
10848 }
10849
10850 /* ??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 */
10851 /* ??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 */
10852 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_str, 16)
10853 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_str(basic_stringstream_char *this,
10854         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10855 {
10856     basic_ios_char *basic_ios;
10857
10858     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10859
10860     if(virt_init) {
10861         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
10862         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
10863         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10864         basic_ios_char_ctor(basic_ios);
10865     }else {
10866         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10867     }
10868
10869     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode);
10870     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
10871     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
10872     return this;
10873 }
10874
10875 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
10876 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
10877 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_mode, 12)
10878 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_mode(
10879         basic_stringstream_char *this, int mode, MSVCP_bool virt_init)
10880 {
10881     basic_ios_char *basic_ios;
10882
10883     TRACE("(%p %d %d)\n", this, mode, virt_init);
10884
10885     if(virt_init) {
10886         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
10887         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
10888         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10889         basic_ios_char_ctor(basic_ios);
10890     }else {
10891         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10892     }
10893
10894     basic_stringbuf_char_ctor_mode(&this->strbuf, mode);
10895     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
10896     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
10897     return this;
10898 }
10899
10900 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10901 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10902 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor, 8)
10903 basic_stringstream_char* __thiscall basic_stringstream_char_ctor(
10904         basic_stringstream_char *this, MSVCP_bool virt_init)
10905 {
10906     return basic_stringstream_char_ctor_mode(
10907             this, OPENMODE_out|OPENMODE_in, virt_init);
10908 }
10909
10910 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
10911 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
10912 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_dtor, 4)
10913 void __thiscall basic_stringstream_char_dtor(basic_ios_char *base)
10914 {
10915     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
10916
10917     TRACE("(%p)\n", this);
10918
10919     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
10920     basic_stringbuf_char_dtor(&this->strbuf);
10921 }
10922
10923 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10924 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10925 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vbase_dtor, 4)
10926 void __thiscall basic_stringstream_char_vbase_dtor(basic_stringstream_char *this)
10927 {
10928     TRACE("(%p)\n", this);
10929
10930     basic_stringstream_char_dtor(basic_stringstream_char_to_basic_ios(this));
10931     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
10932 }
10933
10934 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vector_dtor, 8)
10935 basic_stringstream_char* __thiscall basic_stringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10936 {
10937     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
10938
10939     TRACE("(%p %x)\n", this, flags);
10940
10941     if(flags & 2) {
10942         /* we have an array, with the number of elements stored before the first object */
10943         INT_PTR i, *ptr = (INT_PTR *)this-1;
10944
10945         for(i=*ptr-1; i>=0; i--)
10946             basic_stringstream_char_vbase_dtor(this+i);
10947         MSVCRT_operator_delete(ptr);
10948     } else {
10949         basic_stringstream_char_vbase_dtor(this);
10950         if(flags & 1)
10951             MSVCRT_operator_delete(this);
10952     }
10953
10954     return this;
10955 }
10956
10957 /* ?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 */
10958 /* ?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 */
10959 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_rdbuf, 4)
10960 basic_stringbuf_char* __thiscall basic_stringstream_char_rdbuf(const basic_stringstream_char *this)
10961 {
10962     TRACE("(%p)\n", this);
10963     return (basic_stringbuf_char*)&this->strbuf;
10964 }
10965
10966 /* ?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 */
10967 /* ?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 */
10968 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_set, 8)
10969 void __thiscall basic_stringstream_char_str_set(basic_stringstream_char *this, const basic_string_char *str)
10970 {
10971     TRACE("(%p %p)\n", this, str);
10972     basic_stringbuf_char_str_set(&this->strbuf, str);
10973 }
10974
10975 /* ?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 */
10976 /* ?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 */
10977 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_get, 8)
10978 basic_string_char* __thiscall basic_stringstream_char_str_get(const basic_stringstream_char *this, basic_string_char *ret)
10979 {
10980     TRACE("(%p %p)\n", this, ret);
10981     return basic_stringbuf_char_str_get(&this->strbuf, ret);
10982 }
10983
10984 static inline basic_ios_wchar* basic_stringstream_wchar_to_basic_ios(basic_stringstream_wchar *ptr)
10985 {
10986     return (basic_ios_wchar*)((char*)ptr+basic_stringstream_wchar_vbtable1[1]);
10987 }
10988
10989 static inline basic_stringstream_wchar* basic_stringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10990 {
10991     return (basic_stringstream_wchar*)((char*)ptr-basic_stringstream_wchar_vbtable1[1]);
10992 }
10993
10994 /* ??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 */
10995 /* ??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 */
10996 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_str(basic_stringstream_wchar *this,
10997         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10998 {
10999     basic_ios_wchar *basic_ios;
11000
11001     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11002
11003     if(virt_init) {
11004         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11005         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11006         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11007         basic_ios_wchar_ctor(basic_ios);
11008     }else {
11009         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11010     }
11011
11012     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode);
11013     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11014     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11015     return this;
11016 }
11017
11018 /* ??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 */
11019 /* ??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 */
11020 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_str, 16)
11021 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_str(basic_stringstream_wchar *this,
11022         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11023 {
11024     basic_stringstream_wchar_ctor_str(this, str, mode, virt_init);
11025     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11026     return this;
11027 }
11028
11029 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11030 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11031 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_mode(
11032         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11033 {
11034     basic_ios_wchar *basic_ios;
11035
11036     TRACE("(%p %d %d)\n", this, mode, virt_init);
11037
11038     if(virt_init) {
11039         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11040         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11041         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11042         basic_ios_wchar_ctor(basic_ios);
11043     }else {
11044         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11045     }
11046
11047     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode);
11048     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11049     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11050     return this;
11051 }
11052
11053 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11054 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11055 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_mode, 12)
11056 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_mode(
11057         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11058 {
11059     basic_stringstream_wchar_ctor_mode(this, mode, virt_init);
11060     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11061     return this;
11062 }
11063
11064 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11065 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11066 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor, 8)
11067 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor(
11068         basic_stringstream_wchar *this, MSVCP_bool virt_init)
11069 {
11070     return basic_stringstream_short_ctor_mode(
11071             this, OPENMODE_out|OPENMODE_in, virt_init);
11072 }
11073
11074 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11075 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11076 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11077 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11078 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_dtor, 4)
11079 void __thiscall basic_stringstream_wchar_dtor(basic_ios_wchar *base)
11080 {
11081     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11082
11083     TRACE("(%p)\n", this);
11084
11085     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
11086     basic_stringbuf_wchar_dtor(&this->strbuf);
11087 }
11088
11089 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11090 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11091 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11092 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11093 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vbase_dtor, 4)
11094 void __thiscall basic_stringstream_wchar_vbase_dtor(basic_stringstream_wchar *this)
11095 {
11096     TRACE("(%p)\n", this);
11097
11098     basic_stringstream_wchar_dtor(basic_stringstream_wchar_to_basic_ios(this));
11099     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
11100 }
11101
11102 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vector_dtor, 8)
11103 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11104 {
11105     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11106
11107     TRACE("(%p %x)\n", this, flags);
11108
11109     if(flags & 2) {
11110         /* we have an array, with the number of elements stored before the first object */
11111         INT_PTR i, *ptr = (INT_PTR *)this-1;
11112
11113         for(i=*ptr-1; i>=0; i--)
11114             basic_stringstream_wchar_vbase_dtor(this+i);
11115         MSVCRT_operator_delete(ptr);
11116     } else {
11117         basic_stringstream_wchar_vbase_dtor(this);
11118         if(flags & 1)
11119             MSVCRT_operator_delete(this);
11120     }
11121
11122     return this;
11123 }
11124
11125 /* ?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 */
11126 /* ?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 */
11127 /* ?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 */
11128 /* ?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 */
11129 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_rdbuf, 4)
11130 basic_stringbuf_wchar* __thiscall basic_stringstream_wchar_rdbuf(const basic_stringstream_wchar *this)
11131 {
11132     TRACE("(%p)\n", this);
11133     return (basic_stringbuf_wchar*)&this->strbuf;
11134 }
11135
11136 /* ?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 */
11137 /* ?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 */
11138 /* ?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 */
11139 /* ?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 */
11140 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_set, 8)
11141 void __thiscall basic_stringstream_wchar_str_set(basic_stringstream_wchar *this, const basic_string_wchar *str)
11142 {
11143     TRACE("(%p %p)\n", this, str);
11144     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11145 }
11146
11147 /* ?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 */
11148 /* ?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 */
11149 /* ?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 */
11150 /* ?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 */
11151 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_get, 8)
11152 basic_string_wchar* __thiscall basic_stringstream_wchar_str_get(const basic_stringstream_wchar *this, basic_string_wchar *ret)
11153 {
11154     TRACE("(%p %p)\n", this, ret);
11155     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11156 }
11157
11158 /* ?_Init@strstreambuf@std@@IAEXHPAD0H@Z */
11159 /* ?_Init@strstreambuf@std@@IEAAX_JPEAD1H@Z */
11160 DEFINE_THISCALL_WRAPPER(strstreambuf__Init, 20)
11161 void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g, char *p, int mode)
11162 {
11163     TRACE("(%p %ld %p %p %d)\n", this, len, g, p, mode);
11164
11165     this->minsize = 32;
11166     this->endsave = NULL;
11167     this->strmode = mode;
11168     this->palloc = NULL;
11169     this->pfree = NULL;
11170
11171     if(!g) {
11172         this->strmode |= STRSTATE_Dynamic;
11173         if(len > this->minsize)
11174             this->minsize = len;
11175         this->seekhigh = NULL;
11176         return;
11177     }
11178
11179     if(len < 0)
11180         len = INT_MAX;
11181     else if(!len)
11182         len = strlen(g);
11183
11184     this->seekhigh = g+len;
11185     basic_streambuf_char_setg(&this->base, g, g, p ? p : this->seekhigh);
11186     if(p)
11187         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
11188 }
11189
11190 /* ?_Tidy@strstreambuf@std@@IAEXXZ */
11191 /* ?_Tidy@strstreambuf@std@@IEAAXXZ */
11192 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
11193 void __thiscall strstreambuf__Tidy(strstreambuf *this)
11194 {
11195     TRACE("(%p)\n", this);
11196
11197     if((this->strmode & STRSTATE_Allocated) && !(this->strmode & STRSTATE_Frozen)) {
11198         if(this->pfree)
11199             this->pfree(basic_streambuf_char_eback(&this->base));
11200         else
11201             MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
11202     }
11203
11204     this->endsave = NULL;
11205     this->seekhigh = NULL;
11206     this->strmode &= ~(STRSTATE_Allocated | STRSTATE_Frozen);
11207     basic_streambuf_char_setg(&this->base, NULL, NULL, NULL);
11208     basic_streambuf_char_setp(&this->base, NULL, NULL);
11209 }
11210
11211 /* ??1strstreambuf@std@@UAE@XZ */
11212 /* ??1strstreambuf@std@@UEAA@XZ */
11213 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor, 4)
11214 void __thiscall strstreambuf_dtor(strstreambuf *this)
11215 {
11216     TRACE("(%p)\n", this);
11217
11218     strstreambuf__Tidy(this);
11219     basic_streambuf_char_dtor(&this->base);
11220 }
11221
11222 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor, 8)
11223 strstreambuf* __thiscall strstreambuf_vector_dtor(strstreambuf *this, unsigned int flags)
11224 {
11225     TRACE("(%p %x)\n", this, flags);
11226     if(flags & 2) {
11227         /* we have an array, with the number of elements stored before the first object */
11228         INT_PTR i, *ptr = (INT_PTR *)this-1;
11229
11230         for(i=*ptr-1; i>=0; i--)
11231             strstreambuf_dtor(this+i);
11232         MSVCRT_operator_delete(ptr);
11233     } else {
11234         strstreambuf_dtor(this);
11235         if(flags & 1)
11236             MSVCRT_operator_delete(this);
11237     }
11238
11239     return this;
11240 }
11241
11242 /* ?freeze@strstreambuf@std@@QAEX_N@Z */
11243 /* ?freeze@strstreambuf@std@@QEAAX_N@Z */
11244 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze, 8)
11245 void __thiscall strstreambuf_freeze(strstreambuf *this, MSVCP_bool freeze)
11246 {
11247     TRACE("(%p %d)\n", this, freeze);
11248
11249     if(!freeze == !(this->strmode *STRSTATE_Frozen))
11250         return;
11251
11252     if(freeze) {
11253         this->strmode |= STRSTATE_Frozen;
11254         this->endsave = basic_streambuf_char_epptr(&this->base);
11255         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11256                 basic_streambuf_char_pptr(&this->base), basic_streambuf_char_eback(&this->base));
11257     }else {
11258         this->strmode &= ~STRSTATE_Frozen;
11259         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11260                 basic_streambuf_char_pptr(&this->base), this->endsave);
11261     }
11262 }
11263
11264 /* ?overflow@strstreambuf@std@@MAEHH@Z */
11265 /* ?overflow@strstreambuf@std@@MEAAHH@Z */
11266 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow, 8)
11267 int __thiscall strstreambuf_overflow(strstreambuf *this, int c)
11268 {
11269     MSVCP_size_t old_size, size;
11270     char *ptr, *buf;
11271
11272     TRACE("(%p %d)\n", this, c);
11273
11274     if(c == EOF)
11275         return !EOF;
11276
11277     if(this->strmode & STRSTATE_Frozen)
11278         return EOF;
11279
11280     ptr = basic_streambuf_char_pptr(&this->base);
11281     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
11282         return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11283
11284     if(!(this->strmode & STRSTATE_Dynamic) || (this->strmode & STRSTATE_Constant))
11285         return EOF;
11286
11287     ptr = basic_streambuf_char_eback(&this->base);
11288     old_size = ptr ? basic_streambuf_char_epptr(&this->base) - ptr : 0;
11289
11290     size = old_size + old_size/2;
11291     if(size < this->minsize)
11292         size = this->minsize;
11293
11294     if(this->palloc)
11295         buf = this->palloc(size);
11296     else
11297         buf = MSVCRT_operator_new(size);
11298     if(!buf)
11299         return EOF;
11300
11301     memcpy(buf, ptr, old_size);
11302     if(this->strmode & STRSTATE_Allocated) {
11303         if(this->pfree)
11304             this->pfree(ptr);
11305         else
11306             MSVCRT_operator_delete(ptr);
11307     }
11308
11309     this->strmode |= STRSTATE_Allocated;
11310     if(!old_size) {
11311         this->seekhigh = buf;
11312         basic_streambuf_char_setp(&this->base, buf, buf+size);
11313         basic_streambuf_char_setg(&this->base, buf, buf, buf);
11314     }else {
11315         this->seekhigh = this->seekhigh-ptr+buf;
11316         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base)-ptr+buf,
11317                 basic_streambuf_char_pptr(&this->base)-ptr+buf, buf+size);
11318         basic_streambuf_char_setg(&this->base, buf, basic_streambuf_char_gptr(&this->base)-ptr+buf,
11319                 basic_streambuf_char_pptr(&this->base));
11320     }
11321
11322     return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11323 }
11324
11325 /* ?pbackfail@strstreambuf@std@@MAEHH@Z */
11326 /* ?pbackfail@strstreambuf@std@@MEAAHH@Z */
11327 DEFINE_THISCALL_WRAPPER(strstreambuf_pbackfail, 8)
11328 int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c)
11329 {
11330     char *ptr = basic_streambuf_char_gptr(&this->base);
11331
11332     TRACE("(%p %d)\n", this, c);
11333
11334     if(ptr<=basic_streambuf_char_eback(&this->base)
11335             || ((this->strmode & STRSTATE_Constant) && c!=ptr[-1]))
11336         return EOF;
11337
11338     basic_streambuf_char_gbump(&this->base, -1);
11339     if(c == EOF)
11340         return !EOF;
11341     if(this->strmode & STRSTATE_Constant)
11342         return (unsigned char)c;
11343
11344     return (unsigned char)(ptr[0] = c);
11345 }
11346
11347 /* ?seekoff@strstreambuf@std@@MAE?AV?$fpos@H@2@JHH@Z */
11348 /* ?seekoff@strstreambuf@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
11349 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20)
11350 fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode)
11351 {
11352     char *eback = basic_streambuf_char_eback(&this->base);
11353     char *pptr = basic_streambuf_char_pptr(&this->base);
11354     char *gptr = basic_streambuf_char_gptr(&this->base);
11355
11356     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
11357
11358     ret->off = 0;
11359     ret->state = 0;
11360
11361     if(pptr > this->seekhigh)
11362         this->seekhigh = pptr;
11363
11364     if((mode & OPENMODE_in) && gptr) {
11365         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
11366             off += gptr-eback;
11367         else if(way == SEEKDIR_end)
11368             off += this->seekhigh-eback;
11369         else if(way != SEEKDIR_beg)
11370             off = -1;
11371
11372         if(off<0 || off>this->seekhigh-eback) {
11373             off = -1;
11374         }else {
11375             basic_streambuf_char_gbump(&this->base, eback-gptr+off);
11376             if((mode & OPENMODE_out) && pptr) {
11377                 basic_streambuf_char_setp_next(&this->base, eback,
11378                         gptr, basic_streambuf_char_epptr(&this->base));
11379             }
11380         }
11381     }else if((mode & OPENMODE_out) && pptr) {
11382         if(way == SEEKDIR_cur)
11383             off += pptr-eback;
11384         else if(way == SEEKDIR_end)
11385             off += this->seekhigh-eback;
11386         else if(way != SEEKDIR_beg)
11387             off = -1;
11388
11389          if(off<0 || off>this->seekhigh-eback)
11390              off = -1;
11391          else
11392              basic_streambuf_char_pbump(&this->base, eback-pptr+off);
11393     }else {
11394         off = -1;
11395     }
11396
11397     ret->pos = off;
11398     return ret;
11399 }
11400
11401 /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */
11402 /* ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
11403 DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36)
11404 fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode)
11405 {
11406     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
11407
11408     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
11409         *ret = pos;
11410         return ret;
11411     }
11412
11413     return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
11414 }
11415
11416 /* ?underflow@strstreambuf@std@@MAEHXZ */
11417 /* ?underflow@strstreambuf@std@@MEAAHXZ */
11418 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow, 4)
11419 int __thiscall strstreambuf_underflow(strstreambuf *this)
11420 {
11421     char *gptr = basic_streambuf_char_gptr(&this->base);
11422     char *pptr;
11423
11424     TRACE("(%p)\n", this);
11425
11426     if(!gptr)
11427         return EOF;
11428
11429     if(gptr < basic_streambuf_char_egptr(&this->base))
11430         return (unsigned char)(*gptr);
11431
11432     pptr = basic_streambuf_char_gptr(&this->base);
11433     if(pptr > this->seekhigh)
11434         this->seekhigh = pptr;
11435
11436     if(this->seekhigh <= gptr)
11437         return EOF;
11438
11439     basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base),
11440             gptr, this->seekhigh);
11441     return (unsigned char)(*gptr);
11442 }
11443
11444 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
11445 {
11446     ios_base_precision_set(base, prec);
11447 }
11448
11449 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
11450 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
11451 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
11452 {
11453     TRACE("(%p %ld)\n", ret, prec);
11454
11455     ret->pfunc = setprecision_func;
11456     ret->arg = prec;
11457     return ret;
11458 }
11459
11460 static void __cdecl setw_func(ios_base *base, streamsize width)
11461 {
11462     ios_base_width_set(base, width);
11463 }
11464
11465 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
11466 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
11467 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
11468 {
11469     TRACE("(%p %ld)\n", ret, width);
11470
11471     ret->pfunc = setw_func;
11472     ret->arg = width;
11473     return ret;
11474 }
11475
11476 static void __cdecl resetioflags_func(ios_base *base, int mask)
11477 {
11478     ios_base_setf_mask(base, 0, mask);
11479 }
11480
11481 /* ?resetiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
11482 manip_int* __cdecl resetiosflags(manip_int *ret, int mask)
11483 {
11484     TRACE("(%p %d)\n", ret, mask);
11485
11486     ret->pfunc = resetioflags_func;
11487     ret->arg = mask;
11488     return ret;
11489 }
11490
11491 static void __cdecl setiosflags_func(ios_base *base, int mask)
11492 {
11493     ios_base_setf_mask(base, FMTFLAG_mask, mask);
11494 }
11495
11496 /* ?setiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
11497 manip_int* __cdecl setiosflags(manip_int *ret, int mask)
11498 {
11499     TRACE("(%p %d)\n", ret, mask);
11500
11501     ret->pfunc = setiosflags_func;
11502     ret->arg = mask;
11503     return ret;
11504 }
11505
11506 static void __cdecl setbase_func(ios_base *base, int set_base)
11507 {
11508     if(set_base == 10)
11509         set_base = FMTFLAG_dec;
11510     else if(set_base == 8)
11511         set_base = FMTFLAG_oct;
11512     else if(set_base == 16)
11513         set_base = FMTFLAG_hex;
11514     else
11515         set_base = 0;
11516
11517     ios_base_setf_mask(base, set_base, FMTFLAG_basefield);
11518 }
11519
11520 /* ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z */
11521 manip_int* __cdecl setbase(manip_int *ret, int base)
11522 {
11523     TRACE("(%p %d)\n", ret, base);
11524
11525     ret->pfunc = setbase_func;
11526     ret->arg = base;
11527     return ret;
11528 }
11529
11530 static basic_filebuf_char filebuf_char_stdin;
11531 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
11532 struct {
11533     basic_istream_char obj;
11534     basic_ios_char vbase;
11535 } cin = { { 0 } };
11536 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
11537 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
11538 basic_istream_char *_Ptr_cin = &cin.obj;
11539
11540 static basic_filebuf_wchar filebuf_short_stdin;
11541 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
11542 struct {
11543     basic_istream_wchar obj;
11544     basic_ios_wchar vbase;
11545 } ucin = { { 0 } };
11546 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
11547 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
11548 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
11549
11550 static basic_filebuf_wchar filebuf_wchar_stdin;
11551 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
11552 struct {
11553     basic_istream_wchar obj;
11554     basic_ios_wchar vbase;
11555 } wcin = { { 0 } };
11556 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
11557 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
11558 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
11559
11560 static basic_filebuf_char filebuf_char_stdout;
11561 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
11562 struct {
11563     basic_ostream_char obj;
11564     basic_ios_char vbase;
11565 } cout = { { 0 } };
11566 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
11567 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
11568 basic_ostream_char *_Ptr_cout = &cout.obj;
11569
11570 static basic_filebuf_wchar filebuf_short_stdout;
11571 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
11572 struct {
11573     basic_ostream_wchar obj;
11574     basic_ios_wchar vbase;
11575 } ucout = { { 0 } };
11576 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
11577 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
11578 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
11579
11580 static basic_filebuf_wchar filebuf_wchar_stdout;
11581 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
11582 struct {
11583     basic_ostream_wchar obj;
11584     basic_ios_wchar vbase;
11585 } wcout = { { 0 } };
11586 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
11587 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
11588 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
11589
11590 static basic_filebuf_char filebuf_char_stderr;
11591 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
11592 struct {
11593     basic_ostream_char obj;
11594     basic_ios_char vbase;
11595 } cerr = { { 0 } };
11596 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
11597 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
11598 basic_ostream_char *_Ptr_cerr = &cerr.obj;
11599
11600 static basic_filebuf_wchar filebuf_short_stderr;
11601 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
11602 struct {
11603     basic_ostream_wchar obj;
11604     basic_ios_wchar vbase;
11605 } ucerr = { { 0 } };
11606 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
11607 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
11608 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
11609
11610 static basic_filebuf_wchar filebuf_wchar_stderr;
11611 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
11612 struct {
11613     basic_ostream_wchar obj;
11614     basic_ios_wchar vbase;
11615 } wcerr = { { 0 } };
11616 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
11617 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
11618 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
11619
11620 static basic_filebuf_char filebuf_char_log;
11621 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
11622 struct {
11623     basic_ostream_char obj;
11624     basic_ios_char vbase;
11625 } clog = { { 0 } };
11626 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
11627 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
11628 basic_ostream_char *_Ptr_clog = &clog.obj;
11629
11630 static basic_filebuf_wchar filebuf_short_log;
11631 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
11632 struct {
11633     basic_ostream_wchar obj;
11634     basic_ios_wchar vbase;
11635 } uclog = { { 0 } };
11636 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
11637 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
11638 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
11639
11640 static basic_filebuf_wchar filebuf_wchar_log;
11641 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
11642 struct {
11643     basic_ostream_wchar obj;
11644     basic_ios_wchar vbase;
11645 } wclog = { { 0 } };
11646 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
11647 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
11648 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
11649
11650 /* ?_Init_cnt@Init@ios_base@std@@0HA */
11651 int ios_base_Init__Init_cnt = -1;
11652
11653 /* ?_Init_ctor@Init@ios_base@std@@CAXPAV123@@Z */
11654 /* ?_Init_ctor@Init@ios_base@std@@CAXPEAV123@@Z */
11655 static void ios_base_Init__Init_ctor(void *this)
11656 {
11657     TRACE("(%p)\n", this);
11658
11659     if(ios_base_Init__Init_cnt < 0)
11660         ios_base_Init__Init_cnt = 1;
11661     else
11662         ios_base_Init__Init_cnt++;
11663 }
11664
11665 /* ??0Init@ios_base@std@@QAE@XZ */
11666 /* ??0Init@ios_base@std@@QEAA@XZ */
11667 DEFINE_THISCALL_WRAPPER(ios_base_Init_ctor, 4)
11668 void* __thiscall ios_base_Init_ctor(void *this)
11669 {
11670     ios_base_Init__Init_ctor(this);
11671     return this;
11672 }
11673
11674 /* ?_Init_dtor@Init@ios_base@std@@CAXPAV123@@Z */
11675 /* ?_Init_dtor@Init@ios_base@std@@CAXPEAV123@@Z */
11676 static void ios_base_Init__Init_dtor(void *this)
11677 {
11678     TRACE("(%p)\n", this);
11679
11680     ios_base_Init__Init_cnt--;
11681     if(!ios_base_Init__Init_cnt) {
11682         basic_ostream_char_flush(&cout.obj);
11683         basic_ostream_char_flush(&cerr.obj);
11684         basic_ostream_char_flush(&clog.obj);
11685     }
11686 }
11687
11688 /* ??1Init@ios_base@std@@QAE@XZ */
11689 /* ??1Init@ios_base@std@@QEAA@XZ */
11690 DEFINE_THISCALL_WRAPPER(ios_base_Init_dtor, 4)
11691 void __thiscall ios_base_Init_dtor(void *this)
11692 {
11693     ios_base_Init__Init_dtor(this);
11694 }
11695
11696 /* ??4Init@ios_base@std@@QAEAAV012@ABV012@@Z */
11697 /* ??4Init@ios_base@std@@QEAAAEAV012@AEBV012@@Z */
11698 DEFINE_THISCALL_WRAPPER(ios_base_Init_op_assign, 8)
11699 void* __thiscall ios_base_Init_op_assign(void *this, void *rhs)
11700 {
11701     TRACE("(%p %p)\n", this, rhs);
11702     return this;
11703 }
11704
11705 /* ?_Init_cnt@_Winit@std@@0HA */
11706 int _Winit__Init_cnt = -1;
11707
11708 /* ??0_Winit@std@@QAE@XZ */
11709 /* ??0_Winit@std@@QEAA@XZ */
11710 DEFINE_THISCALL_WRAPPER(_Winit_ctor, 4)
11711 void* __thiscall _Winit_ctor(void *this)
11712 {
11713     TRACE("(%p)\n", this);
11714
11715     if(_Winit__Init_cnt < 0)
11716         _Winit__Init_cnt = 1;
11717     else
11718         _Winit__Init_cnt++;
11719
11720     return this;
11721 }
11722
11723 /* ??1_Winit@std@@QAE@XZ */
11724 /* ??1_Winit@std@@QAE@XZ */
11725 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)
11726 void __thiscall _Winit_dtor(void *this)
11727 {
11728     TRACE("(%p)\n", this);
11729
11730     _Winit__Init_cnt--;
11731     if(!_Winit__Init_cnt) {
11732         basic_ostream_wchar_flush(&wcout.obj);
11733         basic_ostream_wchar_flush(&wcerr.obj);
11734         basic_ostream_wchar_flush(&wclog.obj);
11735     }
11736 }
11737
11738 /* ??4_Winit@std@@QAEAAV01@ABV01@@Z */
11739 /* ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z */
11740 DEFINE_THISCALL_WRAPPER(_Winit_op_assign, 8)
11741 void* __thiscall _Winit_op_assign(void *this, void *rhs)
11742 {
11743     TRACE("(%p %p)\n", this, rhs);
11744     return this;
11745 }
11746
11747 void init_io(void *base)
11748 {
11749 #ifdef __x86_64__
11750     init_iosb_rtti(base);
11751     init_ios_base_rtti(base);
11752     init_basic_ios_char_rtti(base);
11753     init_basic_ios_wchar_rtti(base);
11754     init_basic_ios_short_rtti(base);
11755     init_basic_streambuf_char_rtti(base);
11756     init_basic_streambuf_wchar_rtti(base);
11757     init_basic_streambuf_short_rtti(base);
11758     init_basic_filebuf_char_rtti(base);
11759     init_basic_filebuf_wchar_rtti(base);
11760     init_basic_filebuf_short_rtti(base);
11761     init_basic_stringbuf_char_rtti(base);
11762     init_basic_stringbuf_wchar_rtti(base);
11763     init_basic_stringbuf_short_rtti(base);
11764     init_basic_ostream_char_rtti(base);
11765     init_basic_ostream_wchar_rtti(base);
11766     init_basic_ostream_short_rtti(base);
11767     init_basic_istream_char_rtti(base);
11768     init_basic_istream_wchar_rtti(base);
11769     init_basic_istream_short_rtti(base);
11770     init_basic_iostream_char_rtti(base);
11771     init_basic_iostream_wchar_rtti(base);
11772     init_basic_iostream_short_rtti(base);
11773     init_basic_ofstream_char_rtti(base);
11774     init_basic_ofstream_wchar_rtti(base);
11775     init_basic_ofstream_short_rtti(base);
11776     init_basic_ifstream_char_rtti(base);
11777     init_basic_ifstream_wchar_rtti(base);
11778     init_basic_ifstream_short_rtti(base);
11779     init_basic_fstream_char_rtti(base);
11780     init_basic_fstream_wchar_rtti(base);
11781     init_basic_fstream_short_rtti(base);
11782     init_basic_ostringstream_char_rtti(base);
11783     init_basic_ostringstream_wchar_rtti(base);
11784     init_basic_ostringstream_short_rtti(base);
11785     init_basic_istringstream_char_rtti(base);
11786     init_basic_istringstream_wchar_rtti(base);
11787     init_basic_istringstream_short_rtti(base);
11788     init_basic_stringstream_char_rtti(base);
11789     init_basic_stringstream_wchar_rtti(base);
11790     init_basic_stringstream_short_rtti(base);
11791     init_strstreambuf_rtti(base);
11792 #endif
11793
11794     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
11795     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
11796
11797     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
11798     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
11799
11800     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
11801     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
11802
11803     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
11804     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE);
11805
11806     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
11807     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE);
11808
11809     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
11810     basic_ostream_wchar_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE);
11811
11812     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
11813     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE);
11814
11815     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
11816     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE);
11817
11818     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
11819     basic_ostream_wchar_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE);
11820
11821     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
11822     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE);
11823
11824     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
11825     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE);
11826
11827     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
11828     basic_ostream_wchar_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE);
11829 }
11830
11831 void free_io(void)
11832 {
11833     basic_istream_char_vbase_dtor(&cin.obj);
11834     basic_filebuf_char_dtor(&filebuf_char_stdin);
11835
11836     basic_istream_wchar_vbase_dtor(&ucin.obj);
11837     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
11838
11839     basic_istream_wchar_vbase_dtor(&wcin.obj);
11840     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
11841
11842     basic_ostream_char_vbase_dtor(&cout.obj);
11843     basic_filebuf_char_dtor(&filebuf_char_stdout);
11844
11845     basic_ostream_wchar_vbase_dtor(&ucout.obj);
11846     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
11847
11848     basic_ostream_wchar_vbase_dtor(&wcout.obj);
11849     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
11850
11851     basic_ostream_char_vbase_dtor(&cerr.obj);
11852     basic_filebuf_char_dtor(&filebuf_char_stderr);
11853
11854     basic_ostream_wchar_vbase_dtor(&ucerr.obj);
11855     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
11856
11857     basic_ostream_wchar_vbase_dtor(&wcerr.obj);
11858     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
11859
11860     basic_ostream_char_vbase_dtor(&clog.obj);
11861     basic_filebuf_char_dtor(&filebuf_char_log);
11862
11863     basic_ostream_wchar_vbase_dtor(&uclog.obj);
11864     basic_filebuf_wchar_dtor(&filebuf_short_log);
11865
11866     basic_ostream_wchar_vbase_dtor(&wclog.obj);
11867     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
11868 }