msvcp90: Update fpos<>::off instead of pos in stringbuf<>::seekoff.
[wine] / dlls / msvcp90 / 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 "msvcp90.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__Xsgetn_s)
641             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
642             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
643             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
644             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
645             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
646             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
647     __ASM_VTABLE(basic_streambuf_wchar,
648             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
649             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
650             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
651             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
652             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
653             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
654             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
655             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
656             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
657             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
658             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
659             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
660             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
661             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
662     __ASM_VTABLE(basic_streambuf_short,
663             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
664             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
665             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
666             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
667             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
668             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
669             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
670             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
671             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
672             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
673             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
674             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
675             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
676             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
677     __ASM_VTABLE(basic_filebuf_char,
678             VTABLE_ADD_FUNC(basic_filebuf_char_vector_dtor)
679             VTABLE_ADD_FUNC(basic_filebuf_char_overflow)
680             VTABLE_ADD_FUNC(basic_filebuf_char_pbackfail)
681             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
682             VTABLE_ADD_FUNC(basic_filebuf_char_underflow)
683             VTABLE_ADD_FUNC(basic_filebuf_char_uflow)
684             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
685             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
686             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
687             VTABLE_ADD_FUNC(basic_filebuf_char_seekoff)
688             VTABLE_ADD_FUNC(basic_filebuf_char_seekpos)
689             VTABLE_ADD_FUNC(basic_filebuf_char_setbuf)
690             VTABLE_ADD_FUNC(basic_filebuf_char_sync)
691             VTABLE_ADD_FUNC(basic_filebuf_char_imbue));
692     __ASM_VTABLE(basic_filebuf_wchar,
693             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
694             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
695             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
696             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
697             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
698             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
699             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
700             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
701             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
702             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
703             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
704             VTABLE_ADD_FUNC(basic_filebuf_wchar_setbuf)
705             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
706             VTABLE_ADD_FUNC(basic_filebuf_wchar_imbue));
707     __ASM_VTABLE(basic_filebuf_short,
708             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
709             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
710             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
711             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
712             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
713             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
714             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
715             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
716             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
717             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
718             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
719             VTABLE_ADD_FUNC(basic_filebuf_short_setbuf)
720             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
721             VTABLE_ADD_FUNC(basic_filebuf_short_imbue));
722     __ASM_VTABLE(basic_stringbuf_char,
723             VTABLE_ADD_FUNC(basic_stringbuf_char_vector_dtor)
724             VTABLE_ADD_FUNC(basic_stringbuf_char_overflow)
725             VTABLE_ADD_FUNC(basic_stringbuf_char_pbackfail)
726             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
727             VTABLE_ADD_FUNC(basic_stringbuf_char_underflow)
728             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
729             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
730             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
731             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
732             VTABLE_ADD_FUNC(basic_stringbuf_char_seekoff)
733             VTABLE_ADD_FUNC(basic_stringbuf_char_seekpos)
734             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
735             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
736             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
737     __ASM_VTABLE(basic_stringbuf_wchar,
738             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
739             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
740             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
741             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
742             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
743             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
744             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
745             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
746             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
747             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
748             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
749             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
750             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
751             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
752     __ASM_VTABLE(basic_stringbuf_short,
753             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
754             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
755             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
756             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
757             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
758             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
759             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
760             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
761             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
762             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
763             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
764             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
765             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
766             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
767     __ASM_VTABLE(basic_ostream_char,
768             VTABLE_ADD_FUNC(basic_ostream_char_vector_dtor));
769     __ASM_VTABLE(basic_ostream_wchar,
770             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
771     __ASM_VTABLE(basic_ostream_short,
772             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
773     __ASM_VTABLE(basic_istream_char,
774             VTABLE_ADD_FUNC(basic_istream_char_vector_dtor));
775     __ASM_VTABLE(basic_istream_wchar,
776             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
777     __ASM_VTABLE(basic_istream_short,
778             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
779     __ASM_VTABLE(basic_iostream_char,
780             VTABLE_ADD_FUNC(basic_iostream_char_vector_dtor));
781     __ASM_VTABLE(basic_iostream_wchar,
782             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
783     __ASM_VTABLE(basic_iostream_short,
784             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
785     __ASM_VTABLE(basic_ofstream_char,
786             VTABLE_ADD_FUNC(basic_ofstream_char_vector_dtor));
787     __ASM_VTABLE(basic_ofstream_wchar,
788             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
789     __ASM_VTABLE(basic_ofstream_short,
790             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
791     __ASM_VTABLE(basic_ifstream_char,
792             VTABLE_ADD_FUNC(basic_ifstream_char_vector_dtor));
793     __ASM_VTABLE(basic_ifstream_wchar,
794             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
795     __ASM_VTABLE(basic_ifstream_short,
796             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
797     __ASM_VTABLE(basic_fstream_char,
798             VTABLE_ADD_FUNC(basic_fstream_char_vector_dtor));
799     __ASM_VTABLE(basic_fstream_wchar,
800             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
801     __ASM_VTABLE(basic_fstream_short,
802             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
803     __ASM_VTABLE(basic_ostringstream_char,
804             VTABLE_ADD_FUNC(basic_ostringstream_char_vector_dtor));
805     __ASM_VTABLE(basic_ostringstream_wchar,
806             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
807     __ASM_VTABLE(basic_ostringstream_short,
808             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
809     __ASM_VTABLE(basic_istringstream_char,
810             VTABLE_ADD_FUNC(basic_istringstream_char_vector_dtor));
811     __ASM_VTABLE(basic_istringstream_wchar,
812             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
813     __ASM_VTABLE(basic_istringstream_short,
814             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
815     __ASM_VTABLE(basic_stringstream_char,
816             VTABLE_ADD_FUNC(basic_stringstream_char_vector_dtor));
817     __ASM_VTABLE(basic_stringstream_wchar,
818             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
819     __ASM_VTABLE(basic_stringstream_short,
820             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
821     __ASM_VTABLE(strstreambuf,
822             VTABLE_ADD_FUNC(strstreambuf_vector_dtor)
823             VTABLE_ADD_FUNC(strstreambuf_overflow)
824             VTABLE_ADD_FUNC(strstreambuf_pbackfail)
825             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
826             VTABLE_ADD_FUNC(strstreambuf_underflow)
827             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
828             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
829             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
830             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
831             VTABLE_ADD_FUNC(strstreambuf_seekoff)
832             VTABLE_ADD_FUNC(strstreambuf_seekpos)
833             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
834             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
835             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
836 #ifndef __GNUC__
837 }
838 #endif
839
840 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
841 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
842 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
843 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
844 {
845     TRACE("(%p %p %p %p)\n", this, first, next, last);
846
847     this->wbuf = first;
848     this->wpos = next;
849     this->wsize = last-next;
850 }
851
852 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
853 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
854 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
855 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
856 {
857     basic_streambuf_char_setp_next(this, first, first, last);
858 }
859
860 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
861 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
862 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
863 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
864 {
865     TRACE("(%p %p %p %p)\n", this, first, next, last);
866
867     this->rbuf = first;
868     this->rpos = next;
869     this->rsize = last-next;
870 }
871
872 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
873 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
874 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
875 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
876 {
877     TRACE("(%p)\n", this);
878
879     this->prbuf = &this->rbuf;
880     this->pwbuf = &this->wbuf;
881     this->prpos = &this->rpos;
882     this->pwpos = &this->wpos;
883     this->prsize = &this->rsize;
884     this->pwsize = &this->wsize;
885
886     basic_streambuf_char_setp(this, NULL, NULL);
887     basic_streambuf_char_setg(this, NULL, NULL, NULL);
888 }
889
890 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
891 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
892 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
893 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
894 {
895     TRACE("(%p %d)\n", this, uninitialized);
896     this->vtable = &MSVCP_basic_streambuf_char_vtable;
897     mutex_ctor(&this->lock);
898     return this;
899 }
900
901 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
902 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
903 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
904 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
905 {
906     TRACE("(%p)\n", this);
907
908     this->vtable = &MSVCP_basic_streambuf_char_vtable;
909     mutex_ctor(&this->lock);
910     this->loc = MSVCRT_operator_new(sizeof(locale));
911     locale_ctor(this->loc);
912     basic_streambuf_char__Init_empty(this);
913
914     return this;
915 }
916
917 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
918 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
919 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
920 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
921 {
922     TRACE("(%p)\n", this);
923
924     mutex_dtor(&this->lock);
925     locale_dtor(this->loc);
926     MSVCRT_operator_delete(this->loc);
927 }
928
929 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_vector_dtor, 8)
930 basic_streambuf_char* __thiscall basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
931 {
932     TRACE("(%p %x)\n", this, flags);
933     if(flags & 2) {
934         /* we have an array, with the number of elements stored before the first object */
935         INT_PTR i, *ptr = (INT_PTR *)this-1;
936
937         for(i=*ptr-1; i>=0; i--)
938             basic_streambuf_char_dtor(this+i);
939         MSVCRT_operator_delete(ptr);
940     } else {
941         basic_streambuf_char_dtor(this);
942         if(flags & 1)
943             MSVCRT_operator_delete(this);
944     }
945
946     return this;
947 }
948
949 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
950 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
951 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnavail, 4)
952 streamsize __thiscall basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
953 {
954     TRACE("(%p)\n", this);
955     return *this->prpos ? *this->prsize : 0;
956 }
957
958 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
959 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
960 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
961 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
962 {
963     TRACE("(%p)\n", this);
964     (*this->prsize)++;
965     (*this->prpos)--;
966     return *this->prpos;
967 }
968
969 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
970 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
971 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
972 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
973 {
974     TRACE("(%p)\n", this);
975     (*this->prsize)--;
976     return (*this->prpos)++;
977 }
978
979 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
980 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
981 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnpreinc, 4)
982 char* __thiscall basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
983 {
984     TRACE("(%p)\n", this);
985     (*this->prsize)--;
986     (*this->prpos)++;
987     return *this->prpos;
988 }
989
990 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
991 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
992 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
993 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
994 {
995     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
996
997     this->prbuf = gf;
998     this->pwbuf = pf;
999     this->prpos = gn;
1000     this->pwpos = pn;
1001     this->prsize = gc;
1002     this->pwsize = pc;
1003 }
1004
1005 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1006 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1007 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Lock, 4)
1008 void __thiscall basic_streambuf_char__Lock(basic_streambuf_char *this)
1009 {
1010     TRACE("(%p)\n", this);
1011     mutex_lock(&this->lock);
1012 }
1013
1014 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
1015 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
1016 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pnavail, 4)
1017 streamsize __thiscall basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
1018 {
1019     TRACE("(%p)\n", this);
1020     return *this->pwpos ? *this->pwsize : 0;
1021 }
1022
1023 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1024 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1025 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
1026 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
1027 {
1028     TRACE("(%p)\n", this);
1029     (*this->pwsize)--;
1030     return (*this->pwpos)++;
1031 }
1032
1033 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1034 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1035 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
1036 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
1037         int, (basic_streambuf_char*), (this))
1038 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
1039 {
1040     TRACE("(%p)\n", this);
1041     return EOF;
1042 }
1043
1044 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1045 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1046 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
1047 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
1048         int, (basic_streambuf_char*), (this))
1049 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
1050 {
1051     int ret;
1052
1053     TRACE("(%p)\n", this);
1054
1055     if(call_basic_streambuf_char_underflow(this)==EOF)
1056         return EOF;
1057
1058     ret = (unsigned char)**this->prpos;
1059     (*this->prsize)--;
1060     (*this->prpos)++;
1061     return ret;
1062 }
1063
1064 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
1065 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
1066 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Xsgetn_s, 16)
1067 #define call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
1068         streamsize, (basic_streambuf_char*, char*, MSVCP_size_t, streamsize), (this, ptr, size, count))
1069 streamsize __thiscall basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1070 {
1071     streamsize copied, chunk;
1072     int c;
1073
1074     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1075
1076     for(copied=0; copied<count && size;) {
1077         chunk = basic_streambuf_char__Gnavail(this);
1078         if(chunk > count-copied)
1079             chunk = count-copied;
1080
1081         if(chunk > 0) {
1082             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1083             *this->prpos += chunk;
1084             *this->prsize -= chunk;
1085             copied += chunk;
1086             size -= chunk;
1087         }else if((c = call_basic_streambuf_char_uflow(this)) != EOF) {
1088             ptr[copied] = c;
1089             copied++;
1090             size--;
1091         }else {
1092             break;
1093         }
1094     }
1095
1096     return copied;
1097 }
1098
1099 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
1100 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
1101 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Sgetn_s, 16)
1102 streamsize __thiscall basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1103 {
1104     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1105     return call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
1106 }
1107
1108 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1109 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1110 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Unlock, 4)
1111 void __thiscall basic_streambuf_char__Unlock(basic_streambuf_char *this)
1112 {
1113     TRACE("(%p)\n", this);
1114     mutex_unlock(&this->lock);
1115 }
1116
1117 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1118 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1119 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
1120 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
1121 {
1122     TRACE("(%p)\n", this);
1123     return *this->prbuf;
1124 }
1125
1126 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1127 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1128 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
1129 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
1130 {
1131     TRACE("(%p)\n", this);
1132     return *this->prpos;
1133 }
1134
1135 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1136 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1137 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
1138 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
1139 {
1140     TRACE("(%p)\n", this);
1141     return *this->prpos+*this->prsize;
1142 }
1143
1144 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1145 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1146 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
1147 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
1148 {
1149     TRACE("(%p)\n", this);
1150     return *this->pwpos+*this->pwsize;
1151 }
1152
1153 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1154 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1155 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
1156 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
1157 {
1158     TRACE("(%p %d)\n", this, off);
1159     *this->prpos += off;
1160     *this->prsize -= off;
1161 }
1162
1163 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QBE?AVlocale@2@XZ */
1164 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ */
1165 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_getloc, 8)
1166 locale* __thiscall basic_streambuf_char_getloc(const basic_streambuf_char *this, locale *ret)
1167 {
1168     TRACE("(%p)\n", this);
1169     return locale_copy_ctor(ret, this->loc);
1170 }
1171
1172 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
1173 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
1174 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
1175 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
1176         void, (basic_streambuf_char*, const locale*), (this, loc))
1177 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
1178 {
1179     TRACE("(%p %p)\n", this, loc);
1180 }
1181
1182 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1183 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1184 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
1185 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1186         int, (basic_streambuf_char*, int), (this, ch))
1187 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
1188 {
1189     TRACE("(%p %d)\n", this, ch);
1190     return EOF;
1191 }
1192
1193 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1194 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1195 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
1196 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1197         int, (basic_streambuf_char*, int), (this, ch))
1198 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
1199 {
1200     TRACE("(%p %d)\n", this, ch);
1201     return EOF;
1202 }
1203
1204 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1205 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1206 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
1207 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
1208 {
1209     TRACE("(%p)\n", this);
1210     return *this->pwbuf;
1211 }
1212
1213 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1214 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1215 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
1216 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
1217 {
1218     TRACE("(%p %d)\n", this, off);
1219     *this->pwpos += off;
1220     *this->pwsize -= off;
1221 }
1222
1223 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1224 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1225 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
1226 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
1227 {
1228     TRACE("(%p)\n", this);
1229     return *this->pwpos;
1230 }
1231
1232 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1233 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1234 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
1235 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
1236 {
1237     TRACE("(%p %p)\n", this, loc);
1238     memcpy(ret, this->loc, sizeof(locale));
1239     call_basic_streambuf_char_imbue(this, loc);
1240     locale_copy_ctor(this->loc, loc);
1241     return ret;
1242 }
1243
1244 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1245 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1246 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
1247 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
1248         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1249 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
1250         fpos_int *ret, streamoff off, int way, int mode)
1251 {
1252     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1253     ret->off = 0;
1254     ret->pos = -1;
1255     ret->state = 0;
1256     return ret;
1257 }
1258
1259 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1260 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1261 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff, 20)
1262 fpos_int* __thiscall basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
1263         fpos_int *ret, streamoff off, int way, int mode)
1264 {
1265     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1266     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
1267 }
1268
1269 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1270 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1271 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff_old, 20)
1272 fpos_int* __thiscall basic_streambuf_char_pubseekoff_old(basic_streambuf_char *this,
1273         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
1274 {
1275     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1276     return basic_streambuf_char_pubseekoff(this, ret, off, way, mode);
1277 }
1278
1279 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1280 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1281 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
1282 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
1283         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1284 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
1285         fpos_int *ret, fpos_int pos, int mode)
1286 {
1287     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1288     ret->off = 0;
1289     ret->pos = -1;
1290     ret->state = 0;
1291     return ret;
1292 }
1293
1294 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1295 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1296 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
1297 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
1298         fpos_int *ret, fpos_int pos, int mode)
1299 {
1300     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1301     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
1302 }
1303
1304 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1305 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1306 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos_old, 36)
1307 fpos_int* __thiscall basic_streambuf_char_pubseekpos_old(basic_streambuf_char *this,
1308         fpos_int *ret, fpos_int pos, unsigned int mode)
1309 {
1310     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1311     return basic_streambuf_char_pubseekpos(this, ret, pos, mode);
1312 }
1313
1314 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
1315 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
1316 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
1317 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
1318         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
1319 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
1320 {
1321     TRACE("(%p %p %ld)\n", this, buf, count);
1322     return this;
1323 }
1324
1325 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
1326 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
1327 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
1328 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
1329 {
1330     TRACE("(%p %p %ld)\n", this, buf, count);
1331     return call_basic_streambuf_char_setbuf(this, buf, count);
1332 }
1333
1334 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1335 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1336 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
1337 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 48, \
1338         int, (basic_streambuf_char*), (this))
1339 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
1340 {
1341     TRACE("(%p)\n", this);
1342     return 0;
1343 }
1344
1345 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1346 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1347 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
1348 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
1349 {
1350     TRACE("(%p)\n", this);
1351     return call_basic_streambuf_char_sync(this);
1352 }
1353
1354 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
1355 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
1356 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
1357 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1358 {
1359     TRACE("(%p %p %ld)\n", this, ptr, count);
1360     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1361 }
1362
1363 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1364 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
1365 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
1366 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1367         streamsize, (basic_streambuf_char*), (this))
1368 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
1369 {
1370     TRACE("(%p)\n", this);
1371     return 0;
1372 }
1373
1374 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1375 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
1376 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
1377 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
1378 {
1379     streamsize ret;
1380
1381     TRACE("(%p)\n", this);
1382
1383     ret = basic_streambuf_char__Gnavail(this);
1384     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
1385 }
1386
1387 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1388 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1389 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
1390 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
1391 {
1392     TRACE("(%p %d)\n", this, ch);
1393     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1394         (*this->prsize)++;
1395         (*this->prpos)--;
1396         return (unsigned char)ch;
1397     }
1398
1399     return call_basic_streambuf_char_pbackfail(this, (unsigned char)ch);
1400 }
1401
1402 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1403 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1404 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
1405 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
1406 {
1407     TRACE("(%p %d)\n", this, ch);
1408     return basic_streambuf_char__Pnavail(this) ?
1409         (*basic_streambuf_char__Pninc(this) = ch) :
1410         call_basic_streambuf_char_overflow(this, (unsigned char)ch);
1411 }
1412
1413 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1414 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1415 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
1416 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
1417 {
1418     TRACE("(%p)\n", this);
1419     if(*this->prpos && *this->prpos>*this->prbuf) {
1420         (*this->prsize)++;
1421         (*this->prpos)--;
1422         return (unsigned char)**this->prpos;
1423     }
1424
1425     return call_basic_streambuf_char_pbackfail(this, EOF);
1426 }
1427
1428 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1429 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1430 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1431 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1432 {
1433     TRACE("(%p)\n", this);
1434     if(basic_streambuf_char__Gnavail(this))
1435         basic_streambuf_char__Gninc(this);
1436     else
1437         call_basic_streambuf_char_uflow(this);
1438 }
1439
1440 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1441 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1442 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1443 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1444 {
1445     TRACE("(%p)\n", this);
1446     return basic_streambuf_char__Gnavail(this) ?
1447         (int)(unsigned char)*basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1448 }
1449
1450 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1451 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1452 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1453 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1454 {
1455     TRACE("(%p)\n", this);
1456     return basic_streambuf_char__Gnavail(this) ?
1457         (int)(unsigned char)*basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1458 }
1459
1460 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1461 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1462 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1463 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1464 {
1465     TRACE("(%p)\n", this);
1466
1467     if(basic_streambuf_char__Gnavail(this) > 1)
1468         return (unsigned char)*basic_streambuf_char__Gnpreinc(this);
1469     return basic_streambuf_char_sbumpc(this)==EOF ?
1470         EOF : basic_streambuf_char_sgetc(this);
1471 }
1472
1473 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1474 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1475 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
1476 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1477         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1478 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1479 {
1480     TRACE("(%p %p %ld)\n", this, ptr, count);
1481     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1482 }
1483
1484 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1485 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1486 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
1487 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
1488         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1489 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1490 {
1491     streamsize copied, chunk;
1492
1493     TRACE("(%p %p %ld)\n", this, ptr, count);
1494
1495     for(copied=0; copied<count;) {
1496         chunk = basic_streambuf_char__Pnavail(this);
1497         if(chunk > count-copied)
1498             chunk = count-copied;
1499
1500         if(chunk > 0) {
1501             memcpy(*this->pwpos, ptr+copied, chunk);
1502             *this->pwpos += chunk;
1503             *this->pwsize -= chunk;
1504             copied += chunk;
1505         }else if(call_basic_streambuf_char_overflow(this, (unsigned char)ptr[copied]) != EOF) {
1506             copied++;
1507         }else {
1508             break;
1509         }
1510     }
1511
1512     return copied;
1513 }
1514
1515 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1516 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1517 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
1518 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1519 {
1520     TRACE("(%p %p %ld)\n", this, ptr, count);
1521     return call_basic_streambuf_char_xsputn(this, ptr, count);
1522 }
1523
1524 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1525 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1526 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1527 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1528 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1529 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1530 {
1531     TRACE("(%p %p %p %p)\n", this, first, next, last);
1532
1533     this->wbuf = first;
1534     this->wpos = next;
1535     this->wsize = last-next;
1536 }
1537
1538 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1539 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1540 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1541 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1542 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1543 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1544 {
1545     basic_streambuf_wchar_setp_next(this, first, first, last);
1546 }
1547
1548 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1549 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1550 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1551 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1552 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1553 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1554 {
1555     TRACE("(%p %p %p %p)\n", this, first, next, last);
1556
1557     this->rbuf = first;
1558     this->rpos = next;
1559     this->rsize = last-next;
1560 }
1561
1562 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1563 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1564 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1565 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1566 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1567 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1568 {
1569     TRACE("(%p)\n", this);
1570
1571     this->prbuf = &this->rbuf;
1572     this->pwbuf = &this->wbuf;
1573     this->prpos = &this->rpos;
1574     this->pwpos = &this->wpos;
1575     this->prsize = &this->rsize;
1576     this->pwsize = &this->wsize;
1577
1578     basic_streambuf_wchar_setp(this, NULL, NULL);
1579     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1580 }
1581
1582 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1583 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1584 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor_uninitialized, 8)
1585 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1586 {
1587     TRACE("(%p %d)\n", this, uninitialized);
1588     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1589     mutex_ctor(&this->lock);
1590     return this;
1591 }
1592
1593 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1594 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1595 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1596 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1597 {
1598     TRACE("(%p %d)\n", this, uninitialized);
1599     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1600     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1601     return this;
1602 }
1603
1604 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1605 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1606 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor, 4)
1607 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1608 {
1609     TRACE("(%p)\n", this);
1610
1611     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1612     mutex_ctor(&this->lock);
1613     this->loc = MSVCRT_operator_new(sizeof(locale));
1614     locale_ctor(this->loc);
1615     basic_streambuf_wchar__Init_empty(this);
1616
1617     return this;
1618 }
1619
1620 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1621 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1622 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1623 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1624 {
1625     TRACE("(%p)\n", this);
1626     basic_streambuf_wchar_ctor(this);
1627     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1628     return this;
1629 }
1630
1631 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1632 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1633 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1634 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1635 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1636 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1637 {
1638     TRACE("(%p)\n", this);
1639
1640     mutex_dtor(&this->lock);
1641     locale_dtor(this->loc);
1642     MSVCRT_operator_delete(this->loc);
1643 }
1644
1645 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_vector_dtor, 8)
1646 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1647 {
1648     TRACE("(%p %x)\n", this, flags);
1649     if(flags & 2) {
1650         /* we have an array, with the number of elements stored before the first object */
1651         INT_PTR i, *ptr = (INT_PTR *)this-1;
1652
1653         for(i=*ptr-1; i>=0; i--)
1654             basic_streambuf_wchar_dtor(this+i);
1655         MSVCRT_operator_delete(ptr);
1656     } else {
1657         basic_streambuf_wchar_dtor(this);
1658         if(flags & 1)
1659             MSVCRT_operator_delete(this);
1660     }
1661
1662     return this;
1663 }
1664
1665 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1666 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1667 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1668 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1669 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnavail, 4)
1670 streamsize __thiscall basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1671 {
1672     TRACE("(%p)\n", this);
1673     return *this->prpos ? *this->prsize : 0;
1674 }
1675
1676 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1677 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1678 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1679 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1680 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1681 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1682 {
1683     TRACE("(%p)\n", this);
1684     (*this->prsize)++;
1685     (*this->prpos)--;
1686     return *this->prpos;
1687 }
1688
1689 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1690 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1691 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1692 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1693 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1694 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1695 {
1696     TRACE("(%p)\n", this);
1697     (*this->prsize)--;
1698     return (*this->prpos)++;
1699 }
1700
1701 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1702 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1703 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1704 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1705 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnpreinc, 4)
1706 wchar_t* __thiscall basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1707 {
1708     TRACE("(%p)\n", this);
1709     (*this->prsize)--;
1710     (*this->prpos)++;
1711     return *this->prpos;
1712 }
1713
1714 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1715 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1716 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1717 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1718 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1719 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)
1720 {
1721     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1722
1723     this->prbuf = gf;
1724     this->pwbuf = pf;
1725     this->prpos = gn;
1726     this->pwpos = pn;
1727     this->prsize = gc;
1728     this->pwsize = pc;
1729 }
1730
1731 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1732 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1733 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1734 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1735 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Lock, 4)
1736 void __thiscall basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1737 {
1738     TRACE("(%p)\n", this);
1739     mutex_lock(&this->lock);
1740 }
1741
1742 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1743 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1744 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1745 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1746 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pnavail, 4)
1747 streamsize __thiscall basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1748 {
1749     TRACE("(%p)\n", this);
1750     return *this->pwpos ? *this->pwsize : 0;
1751 }
1752
1753 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1754 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1755 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1756 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1757 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1758 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1759 {
1760     TRACE("(%p)\n", this);
1761     (*this->pwsize)--;
1762     return (*this->pwpos)++;
1763 }
1764
1765 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1766 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1767 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1768 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1769 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1770 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1771         unsigned short, (basic_streambuf_wchar*), (this))
1772 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1773 {
1774     TRACE("(%p)\n", this);
1775     return WEOF;
1776 }
1777
1778 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1779 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1780 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1781 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1782 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1783 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1784         unsigned short, (basic_streambuf_wchar*), (this))
1785 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1786 {
1787     int ret;
1788
1789     TRACE("(%p)\n", this);
1790
1791     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1792         return WEOF;
1793
1794     ret = **this->prpos;
1795     (*this->prsize)--;
1796     (*this->prpos)++;
1797     return ret;
1798 }
1799
1800 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1801 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1802 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1803 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1804 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Xsgetn_s, 16)
1805 #define call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
1806         streamsize, (basic_streambuf_wchar*, wchar_t*, MSVCP_size_t, streamsize), (this, ptr, size, count))
1807 streamsize __thiscall basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1808 {
1809     streamsize copied, chunk;
1810     unsigned short c;
1811
1812     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1813
1814     for(copied=0; copied<count && size;) {
1815         chunk = basic_streambuf_wchar__Gnavail(this);
1816         if(chunk > count-copied)
1817             chunk = count-copied;
1818
1819         if(chunk > 0) {
1820             memcpy_s(ptr+copied, size, *this->prpos, chunk*sizeof(wchar_t));
1821             *this->prpos += chunk;
1822             *this->prsize -= chunk;
1823             copied += chunk;
1824             size -= chunk*sizeof(wchar_t);
1825         }else if((c = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1826             ptr[copied] = c;
1827             copied++;
1828             size--;
1829         }else {
1830             break;
1831         }
1832     }
1833
1834     return copied;
1835 }
1836
1837 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1838 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1839 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1840 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1841 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Sgetn_s, 16)
1842 streamsize __thiscall basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1843 {
1844     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1845     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1846 }
1847
1848 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1849 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1850 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1851 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1852 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Unlock, 4)
1853 void __thiscall basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1854 {
1855     TRACE("(%p)\n", this);
1856     mutex_unlock(&this->lock);
1857 }
1858
1859 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1860 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1861 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1862 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1863 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1864 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1865 {
1866     TRACE("(%p)\n", this);
1867     return *this->prbuf;
1868 }
1869
1870 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1871 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1872 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1873 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1874 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1875 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1876 {
1877     TRACE("(%p)\n", this);
1878     return *this->prpos;
1879 }
1880
1881 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1882 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1883 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1884 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1885 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1886 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1887 {
1888     TRACE("(%p)\n", this);
1889     return *this->prpos+*this->prsize;
1890 }
1891
1892 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1893 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1894 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1895 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1896 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1897 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1898 {
1899     TRACE("(%p)\n", this);
1900     return *this->pwpos+*this->pwsize;
1901 }
1902
1903 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1904 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1905 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1906 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1907 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1908 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1909 {
1910     TRACE("(%p %d)\n", this, off);
1911     *this->prpos += off;
1912     *this->prsize -= off;
1913 }
1914
1915 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QBE?AVlocale@2@XZ */
1916 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEBA?AVlocale@2@XZ */
1917 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QBE?AVlocale@2@XZ */
1918 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEBA?AVlocale@2@XZ */
1919 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
1920 locale* __thiscall basic_streambuf_wchar_getloc(const basic_streambuf_wchar *this, locale *ret)
1921 {
1922     TRACE("(%p)\n", this);
1923     return locale_copy_ctor(ret, this->loc);
1924 }
1925
1926 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1927 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1928 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1929 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1930 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1931 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
1932         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1933 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1934 {
1935     TRACE("(%p %p)\n", this, loc);
1936 }
1937
1938 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1939 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1940 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1941 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1942 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1943 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1944         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1945 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1946 {
1947     TRACE("(%p %d)\n", this, ch);
1948     return WEOF;
1949 }
1950
1951 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1952 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1953 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1954 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1955 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1956 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1957         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1958 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1959 {
1960     TRACE("(%p %d)\n", this, ch);
1961     return WEOF;
1962 }
1963
1964 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1965 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1966 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1967 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1968 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1969 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1970 {
1971     TRACE("(%p)\n", this);
1972     return *this->pwbuf;
1973 }
1974
1975 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1976 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1977 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1978 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1979 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1980 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1981 {
1982     TRACE("(%p %d)\n", this, off);
1983     *this->pwpos += off;
1984     *this->pwsize -= off;
1985 }
1986
1987 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1988 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1989 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1990 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1991 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1992 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1993 {
1994     TRACE("(%p)\n", this);
1995     return *this->pwpos;
1996 }
1997
1998 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1999 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2000 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2001 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2002 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
2003 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
2004 {
2005     TRACE("(%p %p)\n", this, loc);
2006     memcpy(ret, this->loc, sizeof(locale));
2007     call_basic_streambuf_wchar_imbue(this, loc);
2008     locale_copy_ctor(this->loc, loc);
2009     return ret;
2010 }
2011
2012 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2013 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2014 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2015 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2016 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
2017 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
2018         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
2019 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
2020         fpos_int *ret, streamoff off, int way, int mode)
2021 {
2022     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2023     ret->off = 0;
2024     ret->pos = -1;
2025     ret->state = 0;
2026     return ret;
2027 }
2028
2029 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2030 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2031 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2032 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2033 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff, 20)
2034 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
2035         fpos_int *ret, streamoff off, int way, int mode)
2036 {
2037     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2038     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
2039 }
2040
2041 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
2042 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
2043 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
2044 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
2045 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff_old, 20)
2046 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff_old(basic_streambuf_wchar *this,
2047         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
2048 {
2049     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2050     return basic_streambuf_wchar_pubseekoff(this, ret, off, way, mode);
2051 }
2052
2053 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2054 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2055 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2056 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2057 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
2058 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
2059         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
2060 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
2061         fpos_int *ret, fpos_int pos, int mode)
2062 {
2063     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2064     ret->off = 0;
2065     ret->pos = -1;
2066     ret->state = 0;
2067     return ret;
2068 }
2069
2070 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2071 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2072 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2073 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2074 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
2075 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
2076         fpos_int *ret, fpos_int pos, int mode)
2077 {
2078     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2079     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
2080 }
2081
2082 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
2083 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
2084 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
2085 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
2086 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos_old, 36)
2087 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos_old(basic_streambuf_wchar *this,
2088         fpos_int *ret, fpos_int pos, unsigned int mode)
2089 {
2090     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2091     return basic_streambuf_wchar_pubseekpos(this, ret, pos, mode);
2092 }
2093
2094 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
2095 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
2096 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
2097 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
2098 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
2099 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
2100         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
2101 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2102 {
2103     TRACE("(%p %p %ld)\n", this, buf, count);
2104     return this;
2105 }
2106
2107 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
2108 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
2109 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
2110 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
2111 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
2112 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2113 {
2114     TRACE("(%p %p %ld)\n", this, buf, count);
2115     return call_basic_streambuf_wchar_setbuf(this, buf, count);
2116 }
2117
2118 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2119 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2120 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2121 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2122 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
2123 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 48, \
2124         int, (basic_streambuf_wchar*), (this))
2125 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
2126 {
2127     TRACE("(%p)\n", this);
2128     return 0;
2129 }
2130
2131 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2132 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
2133 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2134 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
2135 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
2136 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
2137 {
2138     TRACE("(%p)\n", this);
2139     return call_basic_streambuf_wchar_sync(this);
2140 }
2141
2142 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
2143 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
2144 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
2145 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
2146 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
2147 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2148 {
2149     TRACE("(%p %p %ld)\n", this, ptr, count);
2150     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2151 }
2152
2153 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2154 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
2155 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2156 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
2157 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
2158 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
2159         streamsize, (basic_streambuf_wchar*), (this))
2160 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
2161 {
2162     TRACE("(%p)\n", this);
2163     return 0;
2164 }
2165
2166 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2167 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
2168 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2169 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
2170 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
2171 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
2172 {
2173     streamsize ret;
2174
2175     TRACE("(%p)\n", this);
2176
2177     ret = basic_streambuf_wchar__Gnavail(this);
2178     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
2179 }
2180
2181 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2182 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2183 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2184 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2185 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
2186 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
2187 {
2188     TRACE("(%p %d)\n", this, ch);
2189     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
2190         (*this->prsize)++;
2191         (*this->prpos)--;
2192         return ch;
2193     }
2194
2195     return call_basic_streambuf_wchar_pbackfail(this, ch);
2196 }
2197
2198 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2199 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2200 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2201 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
2202 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
2203 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
2204 {
2205     TRACE("(%p %d)\n", this, ch);
2206     return basic_streambuf_wchar__Pnavail(this) ?
2207         (*basic_streambuf_wchar__Pninc(this) = ch) :
2208         call_basic_streambuf_wchar_overflow(this, ch);
2209 }
2210
2211 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2212 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2213 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2214 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2215 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
2216 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
2217 {
2218     TRACE("(%p)\n", this);
2219     if(*this->prpos && *this->prpos>*this->prbuf) {
2220         (*this->prsize)++;
2221         (*this->prpos)--;
2222         return **this->prpos;
2223     }
2224
2225     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
2226 }
2227
2228 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2229 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2230 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2231 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2232 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
2233 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
2234 {
2235     TRACE("(%p)\n", this);
2236     if(basic_streambuf_wchar__Gnavail(this))
2237         basic_streambuf_wchar__Gninc(this);
2238     else
2239         call_basic_streambuf_wchar_uflow(this);
2240 }
2241
2242 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2243 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2244 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2245 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2246 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
2247 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
2248 {
2249     TRACE("(%p)\n", this);
2250     return basic_streambuf_wchar__Gnavail(this) ?
2251         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
2252 }
2253
2254 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2255 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2256 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2257 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2258 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
2259 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
2260 {
2261     TRACE("(%p)\n", this);
2262     return basic_streambuf_wchar__Gnavail(this) ?
2263         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
2264 }
2265
2266 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2267 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2268 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2269 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2270 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
2271 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
2272 {
2273     TRACE("(%p)\n", this);
2274
2275     if(basic_streambuf_wchar__Gnavail(this) > 1)
2276         return *basic_streambuf_wchar__Gnpreinc(this);
2277     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
2278         WEOF : basic_streambuf_wchar_sgetc(this);
2279 }
2280
2281 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
2282 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
2283 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
2284 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
2285 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
2286 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
2287         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
2288 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2289 {
2290     TRACE("(%p %p %ld)\n", this, ptr, count);
2291     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2292 }
2293
2294 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
2295 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
2296 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
2297 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
2298 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
2299 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
2300         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
2301 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2302 {
2303     streamsize copied, chunk;
2304
2305     TRACE("(%p %p %ld)\n", this, ptr, count);
2306
2307     for(copied=0; copied<count;) {
2308         chunk = basic_streambuf_wchar__Pnavail(this);
2309         if(chunk > count-copied)
2310             chunk = count-copied;
2311
2312         if(chunk > 0) {
2313             memcpy(*this->pwpos, ptr+copied, chunk*sizeof(wchar_t));
2314             *this->pwpos += chunk;
2315             *this->pwsize -= chunk;
2316             copied += chunk;
2317         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
2318             copied++;
2319         }else {
2320             break;
2321         }
2322     }
2323
2324     return copied;
2325 }
2326
2327 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
2328 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
2329 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
2330 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
2331 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
2332 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2333 {
2334     TRACE("(%p %p %ld)\n", this, ptr, count);
2335     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
2336 }
2337
2338 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2339 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2340 int basic_filebuf_char__Init__Stinit = 0;
2341
2342 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2343 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2344 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
2345 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
2346 {
2347     TRACE("(%p %p %d)\n", this, file, which);
2348
2349     this->cvt = NULL;
2350     this->wrotesome = FALSE;
2351     this->state = basic_filebuf_char__Init__Stinit;
2352     this->close = (which == INITFL_open);
2353     this->file = file;
2354
2355     basic_streambuf_char__Init_empty(&this->base);
2356     if(file)
2357         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
2358                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
2359 }
2360
2361 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAV?$codecvt@DDH@2@@Z */
2362 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$codecvt@DDH@2@@Z */
2363 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Initcvt, 8)
2364 void __thiscall basic_filebuf_char__Initcvt(basic_filebuf_char *this, codecvt_char *cvt)
2365 {
2366     TRACE("(%p %p)\n", this, cvt);
2367
2368     if(codecvt_base_always_noconv(&cvt->base)) {
2369         this->cvt = NULL;
2370     }else {
2371         basic_streambuf_char__Init_empty(&this->base);
2372         this->cvt = cvt;
2373     }
2374 }
2375
2376 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAE_NXZ */
2377 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAA_NXZ */
2378 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Endwrite, 4)
2379 MSVCP_bool __thiscall basic_filebuf_char__Endwrite(basic_filebuf_char *this)
2380 {
2381     TRACE("(%p)\n", this);
2382
2383     if(!this->wrotesome || !this->cvt)
2384         return TRUE;
2385
2386
2387     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2388         return FALSE;
2389
2390     while(1) {
2391         /* TODO: check if we need a dynamic buffer here */
2392         char buf[128];
2393         char *next;
2394         int ret;
2395
2396         ret = codecvt_char_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2397         switch(ret) {
2398         case CODECVT_ok:
2399             this->wrotesome = FALSE;
2400             /* fall through */
2401         case CODECVT_partial:
2402             if(!fwrite(buf, next-buf, 1, this->file))
2403                 return FALSE;
2404             if(this->wrotesome)
2405                 break;
2406             /* fall through */
2407         case CODECVT_noconv:
2408             if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2409                 return FALSE;
2410             return TRUE;
2411         default:
2412             return FALSE;
2413         }
2414     }
2415 }
2416
2417 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2418 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2419 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2420 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2421 {
2422     basic_filebuf_char *ret = this;
2423
2424     TRACE("(%p)\n", this);
2425
2426     if(!this->file)
2427         return NULL;
2428
2429     /* TODO: handle exceptions */
2430     if(!basic_filebuf_char__Endwrite(this))
2431         ret = NULL;
2432     if(fclose(this->file))
2433         ret  = NULL;
2434
2435     basic_filebuf_char__Init(this, NULL, INITFL_close);
2436     return ret;
2437 }
2438
2439 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2440 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2441 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2442 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2443 {
2444     TRACE("(%p %p)\n", this, file);
2445
2446     basic_streambuf_char_ctor(&this->base);
2447     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2448
2449     basic_filebuf_char__Init(this, file, INITFL_new);
2450     return this;
2451 }
2452
2453 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2454 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2455 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2456 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2457 {
2458     return basic_filebuf_char_ctor_file(this, NULL);
2459 }
2460
2461 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2462 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2463 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2464 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2465 {
2466     TRACE("(%p %d)\n", this, uninitialized);
2467
2468     basic_streambuf_char_ctor(&this->base);
2469     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2470     return this;
2471 }
2472
2473 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2474 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2475 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2476 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2477 {
2478     TRACE("(%p)\n", this);
2479
2480     if(this->close)
2481         basic_filebuf_char_close(this);
2482     basic_streambuf_char_dtor(&this->base);
2483 }
2484
2485 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2486 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2487 {
2488     TRACE("(%p %x)\n", this, flags);
2489     if(flags & 2) {
2490         /* we have an array, with the number of elements stored before the first object */
2491         INT_PTR i, *ptr = (INT_PTR *)this-1;
2492
2493         for(i=*ptr-1; i>=0; i--)
2494             basic_filebuf_char_dtor(this+i);
2495         MSVCRT_operator_delete(ptr);
2496     } else {
2497         basic_filebuf_char_dtor(this);
2498         if(flags & 1)
2499             MSVCRT_operator_delete(this);
2500     }
2501
2502     return this;
2503 }
2504
2505 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2506 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2507 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2508 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2509 {
2510     TRACE("(%p)\n", this);
2511     return this->file != NULL;
2512 }
2513
2514 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2515 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2516 FILE* __cdecl _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2517 {
2518     static const wchar_t rW[] = {'r',0};
2519     static const struct {
2520         int mode;
2521         const wchar_t str[4];
2522         const wchar_t str_bin[4];
2523     } str_mode[] = {
2524         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2525         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2526         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2527         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2528         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2529         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2530         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2531         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2532         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2533     };
2534
2535     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2536     int mode_idx;
2537     FILE *f = NULL;
2538
2539     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2540
2541     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2542         if(str_mode[mode_idx].mode == real_mode)
2543             break;
2544     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2545         return NULL;
2546
2547     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2548         return NULL;
2549     else if(f)
2550         fclose(f);
2551
2552     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2553             && (f = _wfopen(name, rW))) {
2554         fclose(f);
2555         return NULL;
2556     }
2557
2558     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2559             : str_mode[mode_idx].str, prot);
2560     if(!f)
2561         return NULL;
2562
2563     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2564         fclose(f);
2565         return NULL;
2566     }
2567
2568     return f;
2569 }
2570
2571 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2572 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2573 FILE* __cdecl _Fiopen(const char *name, int mode, int prot)
2574 {
2575     wchar_t nameW[FILENAME_MAX];
2576
2577     TRACE("(%s %d %d)\n", name, mode, prot);
2578
2579     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2580         return NULL;
2581     return _Fiopen_wchar(nameW, mode, prot);
2582 }
2583
2584 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2585 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2586 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2587 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2588 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_wchar, 16)
2589 basic_filebuf_char* __thiscall basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2590 {
2591     FILE *f = NULL;
2592
2593     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2594
2595     if(basic_filebuf_char_is_open(this))
2596         return NULL;
2597
2598     if(!(f = _Fiopen_wchar(name, mode, prot)))
2599         return NULL;
2600
2601     basic_filebuf_char__Init(this, f, INITFL_open);
2602     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(this->base.loc));
2603     return this;
2604 }
2605
2606 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WI@Z */
2607 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WI@Z */
2608 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGI@Z */
2609 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGI@Z */
2610 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_wchar_mode, 12)
2611 basic_filebuf_char* __thiscall basic_filebuf_char_open_wchar_mode(basic_filebuf_char *this, const wchar_t *name, unsigned int mode)
2612 {
2613     return basic_filebuf_char_open_wchar(this, name, mode, SH_DENYNO);
2614 }
2615
2616 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2617 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2618 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open, 16)
2619 basic_filebuf_char* __thiscall basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2620 {
2621     wchar_t nameW[FILENAME_MAX];
2622
2623     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2624
2625     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2626         return NULL;
2627     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2628 }
2629
2630 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDI@Z */
2631 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDI@Z */
2632 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2633 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, unsigned int mode)
2634 {
2635     return basic_filebuf_char_open(this, name, mode, SH_DENYNO);
2636 }
2637
2638 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2639 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2640 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2641 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2642 {
2643     char buf[8], *dyn_buf;
2644     char ch = c, *to_next;
2645     const char *from_next;
2646     int ret, max_size;
2647
2648
2649     TRACE("(%p %d)\n", this, c);
2650
2651     if(!basic_filebuf_char_is_open(this))
2652         return EOF;
2653     if(c == EOF)
2654         return !c;
2655
2656     if(!this->cvt)
2657         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2658
2659     from_next = &ch;
2660     do {
2661         ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2662                 &from_next, buf, buf+sizeof(buf), &to_next);
2663
2664         switch(ret) {
2665         case CODECVT_partial:
2666             if(to_next == buf)
2667                 break;
2668             /* fall through */
2669         case CODECVT_ok:
2670             if(!fwrite(buf, to_next-buf, 1, this->file))
2671                 return EOF;
2672             if(ret == CODECVT_partial)
2673                 continue;
2674             return c;
2675         case CODECVT_noconv:
2676             return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2677         default:
2678             return EOF;
2679         }
2680
2681         break;
2682     } while(1);
2683
2684     max_size = codecvt_base_max_length(&this->cvt->base);
2685     dyn_buf = malloc(max_size);
2686     if(!dyn_buf)
2687         return EOF;
2688
2689     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2690             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2691
2692     switch(ret) {
2693     case CODECVT_ok:
2694         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2695         free(dyn_buf);
2696         return ret ? c : EOF;
2697     case CODECVT_partial:
2698         ERR("buffer should be big enough to store all output\n");
2699         /* fall through */
2700     default:
2701         free(dyn_buf);
2702         return EOF;
2703     }
2704 }
2705
2706 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2707 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2708 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2709 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2710 {
2711     TRACE("(%p %d)\n", this, c);
2712
2713     if(!basic_filebuf_char_is_open(this))
2714         return EOF;
2715
2716     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2717             && (c==EOF || (int)(unsigned char)basic_streambuf_char_gptr(&this->base)[-1]==c)) {
2718         basic_streambuf_char__Gndec(&this->base);
2719         return c==EOF ? !c : c;
2720     }else if(c!=EOF && !this->cvt) {
2721         return ungetc(c, this->file);
2722     }
2723
2724     return EOF;
2725 }
2726
2727 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2728 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2729 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2730 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2731 {
2732     char ch, buf[128], *to_next;
2733     const char *buf_next;
2734     int c, i;
2735
2736     TRACE("(%p)\n", this);
2737
2738     if(!basic_filebuf_char_is_open(this))
2739         return EOF;
2740
2741     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2742         return (unsigned char)*basic_streambuf_char__Gninc(&this->base);
2743
2744     c = fgetc(this->file);
2745     if(!this->cvt || c==EOF)
2746         return c;
2747
2748     buf_next = buf;
2749     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
2750         buf[i] = c;
2751
2752         switch(codecvt_char_in(this->cvt, &this->state, buf_next,
2753                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2754         case CODECVT_partial:
2755         case CODECVT_ok:
2756             if(to_next == &ch) {
2757                 c = fgetc(this->file);
2758                 if(c == EOF)
2759                     return EOF;
2760                 continue;
2761             }
2762
2763             for(i--; i>=buf_next-buf; i--)
2764                 ungetc(buf[i], this->file);
2765             return ch;
2766         case CODECVT_noconv:
2767             return (unsigned char)buf[0];
2768         default:
2769             return EOF;
2770         }
2771     }
2772
2773     FIXME("buffer is too small\n");
2774     return EOF;
2775 }
2776
2777 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2778 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2779 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2780 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2781 {
2782     int ret;
2783
2784     TRACE("(%p)\n", this);
2785
2786     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2787         return (unsigned char)*basic_streambuf_char_gptr(&this->base);
2788
2789     ret = call_basic_streambuf_char_uflow(&this->base);
2790     if(ret != EOF)
2791         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2792     return ret;
2793 }
2794
2795 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2796 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2797 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2798 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2799         fpos_int *ret, streamoff off, int way, int mode)
2800 {
2801     fpos_t pos;
2802
2803     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2804
2805     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2806             || fseek(this->file, off, way)) {
2807         ret->off = 0;
2808         ret->pos = -1;
2809         ret->state = 0;
2810         return ret;
2811     }
2812
2813     fgetpos(this->file, &pos);
2814     ret->off = 0;
2815     ret->pos = pos;
2816     ret->state = this->state;
2817     return ret;
2818 }
2819
2820 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2821 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2822 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2823 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2824         fpos_int *ret, fpos_int pos, int mode)
2825 {
2826     fpos_t fpos;
2827
2828     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2829
2830     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2831             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2832             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2833         ret->off = 0;
2834         ret->pos = -1;
2835         ret->state = 0;
2836         return ret;
2837     }
2838
2839     fgetpos(this->file, &fpos);
2840     ret->off = 0;
2841     ret->pos = fpos;
2842     ret->state = this->state;
2843     return ret;
2844 }
2845
2846 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2847 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2848 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2849 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2850 {
2851     TRACE("(%p %p %ld)\n", this, buf, count);
2852
2853     if(!basic_filebuf_char_is_open(this))
2854         return NULL;
2855
2856     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2857         return NULL;
2858
2859     basic_filebuf_char__Init(this, this->file, INITFL_open);
2860     return &this->base;
2861 }
2862
2863 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2864 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2865 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2866 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2867 {
2868     TRACE("(%p)\n", this);
2869
2870     if(!basic_filebuf_char_is_open(this))
2871         return 0;
2872
2873     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2874         return 0;
2875     return fflush(this->file);
2876 }
2877
2878 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
2879 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
2880 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_imbue, 8)
2881 void __thiscall basic_filebuf_char_imbue(basic_filebuf_char *this, const locale *loc)
2882 {
2883     TRACE("(%p %p)\n", this, loc);
2884     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(loc));
2885 }
2886
2887 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2888 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2889 int basic_filebuf_wchar__Init__Stinit = 0;
2890
2891 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2892 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2893 int basic_filebuf_short__Init__Stinit = 0;
2894
2895 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2896 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2897 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Init, 12)
2898 void __thiscall basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2899 {
2900     TRACE("(%p %p %d)\n", this, file, which);
2901
2902     this->cvt = NULL;
2903     this->wrotesome = FALSE;
2904     this->state = basic_filebuf_wchar__Init__Stinit;
2905     this->close = (which == INITFL_open);
2906     this->file = file;
2907
2908     basic_streambuf_wchar__Init_empty(&this->base);
2909 }
2910
2911 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2912 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2913 DEFINE_THISCALL_WRAPPER(basic_filebuf_short__Init, 12)
2914 void __thiscall basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2915 {
2916     TRACE("(%p %p %d)\n", this, file, which);
2917
2918     this->cvt = NULL;
2919     this->wrotesome = FALSE;
2920     this->state = basic_filebuf_short__Init__Stinit;
2921     this->close = (which == INITFL_open);
2922     this->file = file;
2923
2924     basic_streambuf_wchar__Init_empty(&this->base);
2925 }
2926
2927 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$codecvt@_WDH@2@@Z */
2928 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$codecvt@_WDH@2@@Z */
2929 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAV?$codecvt@GDH@2@@Z */
2930 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$codecvt@GDH@2@@Z */
2931 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Initcvt, 8)
2932 void __thiscall basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this, codecvt_wchar *cvt)
2933 {
2934     TRACE("(%p %p)\n", this, cvt);
2935
2936     if(codecvt_base_always_noconv(&cvt->base)) {
2937         this->cvt = NULL;
2938     }else {
2939         basic_streambuf_wchar__Init_empty(&this->base);
2940         this->cvt = cvt;
2941     }
2942 }
2943
2944 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAE_NXZ */
2945 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAA_NXZ */
2946 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAE_NXZ */
2947 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAA_NXZ */
2948 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Endwrite, 4)
2949 MSVCP_bool __thiscall basic_filebuf_wchar__Endwrite(basic_filebuf_wchar *this)
2950 {
2951     TRACE("(%p)\n", this);
2952
2953     if(!this->wrotesome || !this->cvt)
2954         return TRUE;
2955
2956     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2957         return FALSE;
2958
2959     while(1) {
2960         /* TODO: check if we need a dynamic buffer here */
2961         char buf[128];
2962         char *next;
2963         int ret;
2964
2965         ret = codecvt_wchar_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2966         switch(ret) {
2967         case CODECVT_ok:
2968             this->wrotesome = FALSE;
2969             /* fall through */
2970         case CODECVT_partial:
2971             if(!fwrite(buf, next-buf, 1, this->file))
2972                 return FALSE;
2973             if(this->wrotesome)
2974                 break;
2975             /* fall through */
2976         case CODECVT_noconv:
2977             if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2978                 return FALSE;
2979             return TRUE;
2980         default:
2981             return FALSE;
2982         }
2983     }
2984 }
2985
2986 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
2987 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
2988 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
2989 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
2990 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_close, 4)
2991 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_close(basic_filebuf_wchar *this)
2992 {
2993     basic_filebuf_wchar *ret = this;
2994
2995     TRACE("(%p)\n", this);
2996
2997     if(!this->file)
2998         return NULL;
2999
3000     /* TODO: handle exceptions */
3001     if(!basic_filebuf_wchar__Endwrite(this))
3002         ret = NULL;
3003     if(fclose(this->file))
3004         ret  = NULL;
3005
3006     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
3007     return ret;
3008 }
3009
3010 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
3011 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
3012 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor_file, 8)
3013 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
3014 {
3015     TRACE("(%p %p)\n", this, file);
3016
3017     basic_streambuf_wchar_ctor(&this->base);
3018     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
3019
3020     basic_filebuf_wchar__Init(this, file, INITFL_new);
3021     return this;
3022 }
3023
3024 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
3025 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
3026 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_file, 8)
3027 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
3028 {
3029     TRACE("(%p %p)\n", this, file);
3030
3031     basic_streambuf_short_ctor(&this->base);
3032     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3033
3034     basic_filebuf_short__Init(this, file, INITFL_new);
3035     return this;
3036 }
3037
3038 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
3039 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
3040 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor, 4)
3041 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor(basic_filebuf_wchar *this)
3042 {
3043     return basic_filebuf_wchar_ctor_file(this, NULL);
3044 }
3045
3046 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
3047 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
3048 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor, 4)
3049 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor(basic_filebuf_wchar *this)
3050 {
3051     return basic_filebuf_short_ctor_file(this, NULL);
3052 }
3053
3054 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3055 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3056 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor_uninitialized, 8)
3057 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
3058 {
3059     TRACE("(%p %d)\n", this, uninitialized);
3060
3061     basic_streambuf_wchar_ctor(&this->base);
3062     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
3063     return this;
3064 }
3065
3066 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3067 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3068 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_uninitialized, 8)
3069 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
3070 {
3071     TRACE("(%p %d)\n", this, uninitialized);
3072
3073     basic_streambuf_short_ctor(&this->base);
3074     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3075     return this;
3076 }
3077
3078 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
3079 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
3080 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
3081 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
3082 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_dtor, 4)
3083 void __thiscall basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
3084 {
3085     TRACE("(%p)\n", this);
3086
3087     if(this->close)
3088         basic_filebuf_wchar_close(this);
3089     basic_streambuf_wchar_dtor(&this->base);
3090 }
3091
3092 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
3093 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
3094 {
3095     TRACE("(%p %x)\n", this, flags);
3096     if(flags & 2) {
3097         /* we have an array, with the number of elements stored before the first object */
3098         INT_PTR i, *ptr = (INT_PTR *)this-1;
3099
3100         for(i=*ptr-1; i>=0; i--)
3101             basic_filebuf_wchar_dtor(this+i);
3102         MSVCRT_operator_delete(ptr);
3103     } else {
3104         basic_filebuf_wchar_dtor(this);
3105         if(flags & 1)
3106             MSVCRT_operator_delete(this);
3107     }
3108
3109     return this;
3110 }
3111
3112 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
3113 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
3114 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
3115 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
3116 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_is_open, 4)
3117 MSVCP_bool __thiscall basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
3118 {
3119     TRACE("(%p)\n", this);
3120     return this->file != NULL;
3121 }
3122
3123 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WHH@Z */
3124 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3125 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGHH@Z */
3126 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3127 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_wchar, 16)
3128 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3129 {
3130     FILE *f = NULL;
3131
3132     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3133
3134     if(basic_filebuf_wchar_is_open(this))
3135         return NULL;
3136
3137     if(!(f = _Fiopen_wchar(name, mode, prot)))
3138         return NULL;
3139
3140     basic_filebuf_wchar__Init(this, f, INITFL_open);
3141     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(this->base.loc));
3142     return this;
3143 }
3144
3145 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PB_WHH@Z */
3146 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3147 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBGHH@Z */
3148 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3149 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_wchar, 16)
3150 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3151 {
3152     FILE *f = NULL;
3153
3154     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3155
3156     if(basic_filebuf_wchar_is_open(this))
3157         return NULL;
3158
3159     if(!(f = _Fiopen_wchar(name, mode, prot)))
3160         return NULL;
3161
3162     basic_filebuf_short__Init(this, f, INITFL_open);
3163     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(this->base.loc));
3164     return this;
3165 }
3166
3167 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WI@Z */
3168 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WI@Z */
3169 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGI@Z */
3170 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGI@Z */
3171 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_wchar_mode, 12)
3172 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_wchar_mode(basic_filebuf_wchar *this, const wchar_t *name, unsigned int mode)
3173 {
3174     return basic_filebuf_wchar_open_wchar(this, name, mode, SH_DENYNO);
3175 }
3176
3177 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PB_WI@Z */
3178 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEB_WI@Z */
3179 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBGI@Z */
3180 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBGI@Z */
3181 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_wchar_mode, 12)
3182 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_wchar_mode(basic_filebuf_wchar *this, const wchar_t *name, unsigned int mode)
3183 {
3184     return basic_filebuf_short_open_wchar(this, name, mode, SH_DENYNO);
3185 }
3186
3187 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDHH@Z */
3188 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3189 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open, 16)
3190 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3191 {
3192     wchar_t nameW[FILENAME_MAX];
3193
3194     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3195
3196     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3197         return NULL;
3198     return basic_filebuf_wchar_open_wchar(this, nameW, mode, prot);
3199 }
3200
3201 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDHH@Z */
3202 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3203 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open, 16)
3204 basic_filebuf_wchar* __thiscall basic_filebuf_short_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3205 {
3206     wchar_t nameW[FILENAME_MAX];
3207
3208     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3209
3210     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3211         return NULL;
3212     return basic_filebuf_short_open_wchar(this, nameW, mode, prot);
3213 }
3214
3215 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDI@Z */
3216 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDI@Z */
3217 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode, 12)
3218 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode(basic_filebuf_wchar *this, const char *name, unsigned int mode)
3219 {
3220     return basic_filebuf_wchar_open(this, name, mode, SH_DENYNO);
3221 }
3222
3223 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDI@Z */
3224 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDI@Z */
3225 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_mode, 12)
3226 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_mode(basic_filebuf_wchar *this, const char *name, unsigned int mode)
3227 {
3228     return basic_filebuf_short_open(this, name, mode, SH_DENYNO);
3229 }
3230
3231 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3232 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3233 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3234 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3235 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
3236 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
3237 {
3238     char buf[8], *dyn_buf, *to_next;
3239     wchar_t ch = c;
3240     const wchar_t *from_next;
3241     int max_size;
3242     unsigned short ret;
3243
3244
3245     TRACE("(%p %d)\n", this, c);
3246
3247     if(!basic_filebuf_wchar_is_open(this))
3248         return WEOF;
3249     if(c == WEOF)
3250         return !c;
3251
3252     if(!this->cvt)
3253         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3254
3255     from_next = &ch;
3256     do {
3257         ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3258                 &from_next, buf, buf+sizeof(buf), &to_next);
3259
3260         switch(ret) {
3261         case CODECVT_partial:
3262             if(to_next == buf)
3263                 break;
3264             /* fall through */
3265         case CODECVT_ok:
3266             if(!fwrite(buf, to_next-buf, 1, this->file))
3267                 return WEOF;
3268             if(ret == CODECVT_partial)
3269                 continue;
3270             return c;
3271         case CODECVT_noconv:
3272             return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3273         default:
3274             return WEOF;
3275         }
3276
3277         break;
3278     } while(1);
3279
3280     max_size = codecvt_base_max_length(&this->cvt->base);
3281     dyn_buf = malloc(max_size);
3282     if(!dyn_buf)
3283         return WEOF;
3284
3285     ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3286             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
3287
3288     switch(ret) {
3289     case CODECVT_ok:
3290         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
3291         free(dyn_buf);
3292         return ret ? c : WEOF;
3293     case CODECVT_partial:
3294         ERR("buffer should be big enough to store all output\n");
3295         /* fall through */
3296     default:
3297         free(dyn_buf);
3298         return WEOF;
3299     }
3300 }
3301
3302 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3303 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3304 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3305 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3306 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
3307 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
3308 {
3309     TRACE("(%p %d)\n", this, c);
3310
3311     if(!basic_filebuf_wchar_is_open(this))
3312         return WEOF;
3313
3314     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
3315             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==c)) {
3316         basic_streambuf_wchar__Gndec(&this->base);
3317         return c==WEOF ? !c : c;
3318     }else if(c!=WEOF && !this->cvt) {
3319         return ungetwc(c, this->file);
3320     }else if(c!=WEOF && basic_streambuf_wchar_gptr(&this->base)!=&this->putback) {
3321         this->putback = c;
3322         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback, &this->putback+1);
3323         return c;
3324     }
3325
3326     return WEOF;
3327 }
3328
3329 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3330 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3331 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3332 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3333 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
3334 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
3335 {
3336     wchar_t ch, *to_next;
3337     char buf[128];
3338     const char *buf_next;
3339     int c, i;
3340
3341     TRACE("(%p)\n", this);
3342
3343     if(!basic_filebuf_wchar_is_open(this))
3344         return WEOF;
3345
3346     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3347         return *basic_streambuf_wchar__Gninc(&this->base);
3348
3349     if(!this->cvt)
3350         return fgetwc(this->file);
3351
3352     buf_next = buf;
3353     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
3354         if((c = fgetc(this->file)) == EOF)
3355             return WEOF;
3356         buf[i] = c;
3357
3358         switch(codecvt_wchar_in(this->cvt, &this->state, buf_next,
3359                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
3360         case CODECVT_partial:
3361         case CODECVT_ok:
3362             if(to_next == &ch)
3363                 continue;
3364
3365             for(i--; i>=buf_next-buf; i--)
3366                 ungetc(buf[i], this->file);
3367             return ch;
3368         case CODECVT_noconv:
3369             if(i+1 < sizeof(wchar_t))
3370                 continue;
3371
3372             memcpy(&ch, buf, sizeof(wchar_t));
3373             return ch;
3374         default:
3375             return WEOF;
3376         }
3377     }
3378
3379     FIXME("buffer is too small\n");
3380     return WEOF;
3381 }
3382
3383 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3384 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3385 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3386 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3387 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
3388 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
3389 {
3390     unsigned short ret;
3391
3392     TRACE("(%p)\n", this);
3393
3394     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3395         return *basic_streambuf_wchar_gptr(&this->base);
3396
3397     ret = call_basic_streambuf_wchar_uflow(&this->base);
3398     if(ret != WEOF)
3399         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
3400     return ret;
3401 }
3402
3403 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3404 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3405 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3406 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3407 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 20)
3408 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
3409         fpos_int *ret, streamoff off, int way, int mode)
3410 {
3411     fpos_t pos;
3412
3413     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3414
3415     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback) {
3416         if(way == SEEKDIR_cur)
3417             off -= sizeof(wchar_t);
3418
3419         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3420     }
3421
3422     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3423             || fseek(this->file, off, way)) {
3424         ret->off = 0;
3425         ret->pos = -1;
3426         ret->state = 0;
3427         return ret;
3428     }
3429
3430     fgetpos(this->file, &pos);
3431     ret->off = 0;
3432     ret->pos = pos;
3433     ret->state = this->state;
3434     return ret;
3435 }
3436
3437 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3438 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3439 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3440 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3441 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
3442 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
3443         fpos_int *ret, fpos_int pos, int mode)
3444 {
3445     fpos_t fpos;
3446
3447     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3448
3449     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3450             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
3451             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
3452         ret->off = 0;
3453         ret->pos = -1;
3454         ret->state = 0;
3455         return ret;
3456     }
3457
3458     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback)
3459         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3460
3461     fgetpos(this->file, &fpos);
3462     ret->off = 0;
3463     ret->pos = fpos;
3464     ret->state = this->state;
3465     return ret;
3466 }
3467
3468 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
3469 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
3470 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 12)
3471 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3472 {
3473     TRACE("(%p %p %ld)\n", this, buf, count);
3474
3475     if(!basic_filebuf_wchar_is_open(this))
3476         return NULL;
3477
3478     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3479         return NULL;
3480
3481     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
3482     return &this->base;
3483 }
3484
3485 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
3486 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
3487 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 12)
3488 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3489 {
3490     TRACE("(%p %p %ld)\n", this, buf, count);
3491
3492     if(!basic_filebuf_wchar_is_open(this))
3493         return NULL;
3494
3495     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3496         return NULL;
3497
3498     basic_filebuf_short__Init(this, this->file, INITFL_open);
3499     return &this->base;
3500 }
3501
3502 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
3503 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
3504 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
3505 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
3506 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
3507 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
3508 {
3509     TRACE("(%p)\n", this);
3510
3511     if(!basic_filebuf_wchar_is_open(this))
3512         return 0;
3513
3514     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
3515         return 0;
3516     return fflush(this->file);
3517 }
3518
3519 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
3520 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
3521 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_imbue, 8)
3522 void __thiscall basic_filebuf_wchar_imbue(basic_filebuf_wchar *this, const locale *loc)
3523 {
3524     TRACE("(%p %p)\n", this, loc);
3525     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(loc));
3526 }
3527
3528 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
3529 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
3530 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_imbue, 8)
3531 void __thiscall basic_filebuf_short_imbue(basic_filebuf_wchar *this, const locale *loc)
3532 {
3533     TRACE("(%p %p)\n", this, loc);
3534     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(loc));
3535 }
3536
3537 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3538 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3539 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Getstate, 8)
3540 int __thiscall basic_stringbuf_char__Getstate(basic_stringbuf_char *this, IOSB_openmode mode)
3541 {
3542     int state = 0;
3543
3544     if(!(mode & OPENMODE_in))
3545         state |= STRINGBUF_no_read;
3546
3547     if(!(mode & OPENMODE_out))
3548         state |= STRINGBUF_no_write;
3549
3550     if(mode & OPENMODE_ate)
3551         state |= STRINGBUF_at_end;
3552
3553     if(mode & OPENMODE_app)
3554         state |= STRINGBUF_append;
3555
3556     return state;
3557 }
3558
3559 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXPBDIH@Z */
3560 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXPEBD_KH@Z */
3561 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Init, 16)
3562 void __thiscall basic_stringbuf_char__Init(basic_stringbuf_char *this, const char *str, MSVCP_size_t count, int state)
3563 {
3564     TRACE("(%p, %p, %ld, %d)\n", this, str, count, state);
3565
3566     basic_streambuf_char__Init_empty(&this->base);
3567
3568     this->state = state;
3569     this->seekhigh = NULL;
3570
3571     if(count && str) {
3572         char *buf = MSVCRT_operator_new(count);
3573         if(!buf) {
3574             ERR("Out of memory\n");
3575             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3576         }
3577
3578         memcpy(buf, str, count);
3579         this->seekhigh = buf + count;
3580
3581         this->state |= STRINGBUF_allocated;
3582
3583         if(!(state & STRINGBUF_no_read))
3584             basic_streambuf_char_setg(&this->base, buf, buf, buf + count);
3585
3586         if(!(state & STRINGBUF_no_write)) {
3587             basic_streambuf_char_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3588
3589             if(!basic_streambuf_char_gptr(&this->base))
3590                 basic_streambuf_char_setg(&this->base, buf, 0, buf);
3591         }
3592     }
3593 }
3594
3595 /* ??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 */
3596 /* ??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 */
3597 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_str, 12)
3598 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_str(basic_stringbuf_char *this,
3599         const basic_string_char *str, IOSB_openmode mode)
3600 {
3601     TRACE("(%p %p %d)\n", this, str, mode);
3602
3603     basic_streambuf_char_ctor(&this->base);
3604     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3605
3606     basic_stringbuf_char__Init(this, MSVCP_basic_string_char_c_str(str),
3607             str->size, basic_stringbuf_char__Getstate(this, mode));
3608     return this;
3609 }
3610
3611 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
3612 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
3613 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_mode, 8)
3614 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_mode(
3615         basic_stringbuf_char *this, IOSB_openmode mode)
3616 {
3617     TRACE("(%p %d)\n", this, mode);
3618
3619     basic_streambuf_char_ctor(&this->base);
3620     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3621
3622     basic_stringbuf_char__Init(this, NULL, 0, basic_stringbuf_char__Getstate(this, mode));
3623     return this;
3624 }
3625
3626 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
3627 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
3628 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor, 4)
3629 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor(basic_stringbuf_char *this)
3630 {
3631     return basic_stringbuf_char_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3632 }
3633
3634 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXXZ */
3635 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXXZ */
3636 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Tidy, 4)
3637 void __thiscall basic_stringbuf_char__Tidy(basic_stringbuf_char *this)
3638 {
3639     TRACE("(%p)\n", this);
3640
3641     if(this->state & STRINGBUF_allocated) {
3642         MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
3643         this->seekhigh = NULL;
3644         this->state &= ~STRINGBUF_allocated;
3645     }
3646
3647     basic_streambuf_char__Init_empty(&this->base);
3648 }
3649
3650 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
3651 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
3652 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_dtor, 4)
3653 void __thiscall basic_stringbuf_char_dtor(basic_stringbuf_char *this)
3654 {
3655     TRACE("(%p)\n", this);
3656
3657     basic_stringbuf_char__Tidy(this);
3658     basic_streambuf_char_dtor(&this->base);
3659 }
3660
3661 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_vector_dtor, 8)
3662 basic_stringbuf_char* __thiscall basic_stringbuf_char_vector_dtor(basic_stringbuf_char *this, unsigned int flags)
3663 {
3664     TRACE("(%p %x)\n", this, flags);
3665
3666     if(flags & 2) {
3667         /* we have an array, with the number of elements stored before the first object */
3668         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3669
3670         for (i = *ptr - 1; i >= 0; i--)
3671             basic_stringbuf_char_dtor(this+i);
3672
3673         MSVCRT_operator_delete(ptr);
3674     }else {
3675         basic_stringbuf_char_dtor(this);
3676
3677         if(flags & 1)
3678             MSVCRT_operator_delete(this);
3679     }
3680
3681     return this;
3682 }
3683
3684 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3685 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3686 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_overflow, 8)
3687 int __thiscall basic_stringbuf_char_overflow(basic_stringbuf_char *this, int meta)
3688 {
3689     MSVCP_size_t oldsize, size;
3690     char *ptr, *buf;
3691
3692     TRACE("(%p %x)\n", this, meta);
3693
3694     if(meta == EOF)
3695         return !EOF;
3696     if(this->state & STRINGBUF_no_write)
3697         return EOF;
3698
3699     ptr = basic_streambuf_char_pptr(&this->base);
3700     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3701         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
3702                 this->seekhigh, basic_streambuf_char_epptr(&this->base));
3703
3704     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
3705         return (*basic_streambuf_char__Pninc(&this->base) = meta);
3706
3707     oldsize = (ptr ? basic_streambuf_char_epptr(&this->base)-basic_streambuf_char_eback(&this->base): 0);
3708     size = oldsize|0xf;
3709     size += size/2;
3710     buf = MSVCRT_operator_new(size);
3711     if(!buf) {
3712         ERR("Out of memory\n");
3713         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3714     }
3715
3716     if(!oldsize) {
3717         this->seekhigh = buf;
3718         basic_streambuf_char_setp(&this->base, buf, buf+size);
3719         if(this->state & STRINGBUF_no_read)
3720             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3721         else
3722             basic_streambuf_char_setg(&this->base, buf, buf, buf+1);
3723
3724         this->state |= STRINGBUF_allocated;
3725     }else {
3726         ptr = basic_streambuf_char_eback(&this->base);
3727         memcpy(buf, ptr, oldsize);
3728
3729         this->seekhigh = buf+(this->seekhigh-ptr);
3730         basic_streambuf_char_setp_next(&this->base, buf,
3731                 buf+(basic_streambuf_char_pptr(&this->base)-ptr), buf+size);
3732         if(this->state & STRINGBUF_no_read)
3733             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3734         else
3735             basic_streambuf_char_setg(&this->base, buf,
3736                     buf+(basic_streambuf_char_gptr(&this->base)-ptr),
3737                     basic_streambuf_char_pptr(&this->base)+1);
3738
3739         MSVCRT_operator_delete(ptr);
3740     }
3741
3742     return (*basic_streambuf_char__Pninc(&this->base) = meta);
3743 }
3744
3745 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3746 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3747 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_pbackfail, 8)
3748 int __thiscall basic_stringbuf_char_pbackfail(basic_stringbuf_char *this, int c)
3749 {
3750     char *cur;
3751
3752     TRACE("(%p %x)\n", this, c);
3753
3754     cur = basic_streambuf_char_gptr(&this->base);
3755     if(!cur || cur==basic_streambuf_char_eback(&this->base)
3756             || (c!=EOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3757         return EOF;
3758
3759     if(c != EOF)
3760         cur[-1] = c;
3761     basic_streambuf_char_gbump(&this->base, -1);
3762     return c==EOF ? !EOF : c;
3763 }
3764
3765 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHXZ */
3766 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHXZ */
3767 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_underflow, 4)
3768 int __thiscall basic_stringbuf_char_underflow(basic_stringbuf_char *this)
3769 {
3770     char *ptr, *cur;
3771
3772     TRACE("(%p)\n", this);
3773
3774     cur = basic_streambuf_char_gptr(&this->base);
3775     if(!cur || this->state&STRINGBUF_no_read)
3776         return EOF;
3777
3778     ptr  = basic_streambuf_char_pptr(&this->base);
3779     if(this->seekhigh < ptr)
3780         this->seekhigh = ptr;
3781
3782     ptr = basic_streambuf_char_egptr(&this->base);
3783     if(this->seekhigh > ptr)
3784         basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base), cur, this->seekhigh);
3785
3786     if(cur < this->seekhigh)
3787         return (unsigned char)*cur;
3788     return EOF;
3789 }
3790
3791 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3792 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3793 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekoff, 20)
3794 fpos_int* __thiscall basic_stringbuf_char_seekoff(basic_stringbuf_char *this,
3795         fpos_int *ret, streamoff off, int way, int mode)
3796 {
3797     char *beg, *cur_r, *cur_w;
3798
3799     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3800
3801     cur_w = basic_streambuf_char_pptr(&this->base);
3802     if(cur_w > this->seekhigh)
3803         this->seekhigh = cur_w;
3804
3805     ret->off = 0;
3806     ret->pos = 0;
3807     ret->state = 0;
3808
3809     beg = basic_streambuf_char_eback(&this->base);
3810     cur_r = basic_streambuf_char_gptr(&this->base);
3811     if((mode & OPENMODE_in) && cur_r) {
3812         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3813             off += cur_r-beg;
3814         else if(way == SEEKDIR_end)
3815             off += this->seekhigh-beg;
3816         else if(way != SEEKDIR_beg)
3817             off = -1;
3818
3819         if(off<0 || off>this->seekhigh-beg) {
3820             off = -1;
3821         }else {
3822             basic_streambuf_char_gbump(&this->base, beg-cur_r+off);
3823             if((mode & OPENMODE_out) && cur_w) {
3824                 basic_streambuf_char_setp_next(&this->base, beg,
3825                         basic_streambuf_char_gptr(&this->base),
3826                         basic_streambuf_char_epptr(&this->base));
3827             }
3828         }
3829     }else if((mode & OPENMODE_out) && cur_w) {
3830         if(way == SEEKDIR_cur)
3831             off += cur_w-beg;
3832         else if(way == SEEKDIR_end)
3833             off += this->seekhigh-beg;
3834         else if(way != SEEKDIR_beg)
3835             off = -1;
3836
3837         if(off<0 || off>this->seekhigh-beg)
3838             off = -1;
3839         else
3840             basic_streambuf_char_pbump(&this->base, beg-cur_w+off);
3841     }else {
3842         off = -1;
3843     }
3844
3845     ret->off = off;
3846     return ret;
3847 }
3848
3849 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3850 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3851 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekpos, 36)
3852 fpos_int* __thiscall basic_stringbuf_char_seekpos(basic_stringbuf_char *this,
3853         fpos_int *ret, fpos_int pos, int mode)
3854 {
3855     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3856
3857     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
3858         *ret = pos;
3859         return ret;
3860     }
3861
3862     return basic_stringbuf_char_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
3863 }
3864
3865 /* ?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 */
3866 /* ?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 */
3867 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_set, 8)
3868 void __thiscall basic_stringbuf_char_str_set(basic_stringbuf_char *this, const basic_string_char *str)
3869 {
3870     TRACE("(%p %p)\n", this, str);
3871
3872     basic_stringbuf_char__Tidy(this);
3873     basic_stringbuf_char__Init(this, MSVCP_basic_string_char_c_str(str), str->size, this->state);
3874 }
3875
3876 /* ?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 */
3877 /* ?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 */
3878 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_get, 8)
3879 basic_string_char* __thiscall basic_stringbuf_char_str_get(const basic_stringbuf_char *this, basic_string_char *ret)
3880 {
3881     char *ptr;
3882
3883     TRACE("(%p)\n", this);
3884
3885     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_char_pptr(&this->base)) {
3886         char *pptr;
3887
3888         ptr = basic_streambuf_char_pbase(&this->base);
3889         pptr = basic_streambuf_char_pptr(&this->base);
3890
3891         return MSVCP_basic_string_char_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
3892     }
3893
3894     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_char_gptr(&this->base)) {
3895         ptr = basic_streambuf_char_eback(&this->base);
3896         return MSVCP_basic_string_char_ctor_cstr_len(ret, ptr, basic_streambuf_char_egptr(&this->base) - ptr);
3897     }
3898
3899     return MSVCP_basic_string_char_ctor(ret);
3900 }
3901
3902 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAEHH@Z */
3903 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAAHH@Z */
3904 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3905 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3906 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Getstate, 8)
3907 int __thiscall basic_stringbuf_wchar__Getstate(basic_stringbuf_wchar *this, IOSB_openmode mode)
3908 {
3909     int state = 0;
3910
3911     if(!(mode & OPENMODE_in))
3912         state |= STRINGBUF_no_read;
3913
3914     if(!(mode & OPENMODE_out))
3915         state |= STRINGBUF_no_write;
3916
3917     if(mode & OPENMODE_ate)
3918         state |= STRINGBUF_at_end;
3919
3920     if(mode & OPENMODE_app)
3921         state |= STRINGBUF_append;
3922
3923     return state;
3924 }
3925
3926 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXPB_WIH@Z */
3927 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXPEB_W_KH@Z */
3928 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXPBGIH@Z */
3929 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXPEBG_KH@Z */
3930 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Init, 16)
3931 void __thiscall basic_stringbuf_wchar__Init(basic_stringbuf_wchar *this, const wchar_t *str, MSVCP_size_t count, int state)
3932 {
3933     TRACE("(%p, %p, %lu, %d)\n", this, str, count, state);
3934
3935     basic_streambuf_wchar__Init_empty(&this->base);
3936
3937     this->state = state;
3938     this->seekhigh = NULL;
3939
3940     if(count && str) {
3941         wchar_t *buf = MSVCRT_operator_new(count*sizeof(wchar_t));
3942         if(!buf) {
3943             ERR("Out of memory\n");
3944             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3945         }
3946
3947         memcpy(buf, str, count*sizeof(wchar_t));
3948         this->seekhigh = buf + count;
3949
3950         this->state |= STRINGBUF_allocated;
3951
3952         if(!(state & STRINGBUF_no_read))
3953             basic_streambuf_wchar_setg(&this->base, buf, buf, buf + count);
3954
3955         if(!(state & STRINGBUF_no_write)) {
3956             basic_streambuf_wchar_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3957
3958             if(!basic_streambuf_wchar_gptr(&this->base))
3959                 basic_streambuf_wchar_setg(&this->base, buf, 0, buf);
3960         }
3961     }
3962 }
3963
3964 /* ??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 */
3965 /* ??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 */
3966 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor_str, 12)
3967 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor_str(basic_stringbuf_wchar *this,
3968         const basic_string_wchar *str, IOSB_openmode mode)
3969 {
3970     TRACE("(%p %p %d)\n", this, str, mode);
3971
3972     basic_streambuf_wchar_ctor(&this->base);
3973     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3974
3975     basic_stringbuf_wchar__Init(this, MSVCP_basic_string_wchar_c_str(str),
3976             str->size, basic_stringbuf_wchar__Getstate(this, mode));
3977     return this;
3978 }
3979
3980 /* ??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 */
3981 /* ??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 */
3982 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_str, 12)
3983 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_str(basic_stringbuf_wchar *this,
3984         const basic_string_wchar *str, IOSB_openmode mode)
3985 {
3986     basic_stringbuf_wchar_ctor_str(this, str, mode);
3987     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3988     return this;
3989 }
3990
3991 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
3992 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
3993 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor_mode, 8)
3994 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor_mode(
3995         basic_stringbuf_wchar *this, IOSB_openmode mode)
3996 {
3997     TRACE("(%p %d)\n", this, mode);
3998
3999     basic_streambuf_wchar_ctor(&this->base);
4000     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
4001
4002     basic_stringbuf_wchar__Init(this, NULL, 0, basic_stringbuf_wchar__Getstate(this, mode));
4003     return this;
4004 }
4005
4006 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
4007 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
4008 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_mode, 8)
4009 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_mode(
4010         basic_stringbuf_wchar *this, IOSB_openmode mode)
4011 {
4012     basic_stringbuf_wchar_ctor_mode(this, mode);
4013     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
4014     return this;
4015 }
4016
4017 /* ??_F?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
4018 /* ??_F?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
4019 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor, 4)
4020 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor(basic_stringbuf_wchar *this)
4021 {
4022     return basic_stringbuf_wchar_ctor_mode(this, OPENMODE_in|OPENMODE_out);
4023 }
4024
4025 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
4026 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
4027 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor, 4)
4028 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor(basic_stringbuf_wchar *this)
4029 {
4030     return basic_stringbuf_short_ctor_mode(this, OPENMODE_in|OPENMODE_out);
4031 }
4032
4033 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXXZ */
4034 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXXZ */
4035 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXXZ */
4036 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXXZ */
4037 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Tidy, 4)
4038 void __thiscall basic_stringbuf_wchar__Tidy(basic_stringbuf_wchar *this)
4039 {
4040     TRACE("(%p)\n", this);
4041
4042     if(this->state & STRINGBUF_allocated) {
4043         MSVCRT_operator_delete(basic_streambuf_wchar_eback(&this->base));
4044         this->seekhigh = NULL;
4045         this->state &= ~STRINGBUF_allocated;
4046     }
4047
4048     basic_streambuf_wchar__Init_empty(&this->base);
4049 }
4050
4051 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
4052 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
4053 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
4054 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
4055 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_dtor, 4)
4056 void __thiscall basic_stringbuf_wchar_dtor(basic_stringbuf_wchar *this)
4057 {
4058     TRACE("(%p)\n", this);
4059
4060     basic_stringbuf_wchar__Tidy(this);
4061     basic_streambuf_wchar_dtor(&this->base);
4062 }
4063
4064 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_vector_dtor, 8)
4065 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_vector_dtor(basic_stringbuf_wchar *this, unsigned int flags)
4066 {
4067     TRACE("(%p %x)\n", this, flags);
4068
4069     if(flags & 2) {
4070         /* we have an array, with the number of elements stored before the first object */
4071         INT_PTR i, *ptr = (INT_PTR *) this - 1;
4072
4073         for (i = *ptr - 1; i >= 0; i--)
4074             basic_stringbuf_wchar_dtor(this+i);
4075
4076         MSVCRT_operator_delete(ptr);
4077     }else {
4078         basic_stringbuf_wchar_dtor(this);
4079
4080         if(flags & 1)
4081             MSVCRT_operator_delete(this);
4082     }
4083
4084     return this;
4085 }
4086
4087 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4088 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4089 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4090 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4091 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_overflow, 8)
4092 unsigned short __thiscall basic_stringbuf_wchar_overflow(basic_stringbuf_wchar *this, unsigned short meta)
4093 {
4094     MSVCP_size_t oldsize, size;
4095     wchar_t *ptr, *buf;
4096
4097     TRACE("(%p %x)\n", this, meta);
4098
4099     if(meta == WEOF)
4100         return !WEOF;
4101     if(this->state & STRINGBUF_no_write)
4102         return WEOF;
4103
4104     ptr = basic_streambuf_wchar_pptr(&this->base);
4105     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
4106         basic_streambuf_wchar_setp_next(&this->base, basic_streambuf_wchar_pbase(&this->base),
4107                 this->seekhigh, basic_streambuf_wchar_epptr(&this->base));
4108
4109     if(ptr && ptr<basic_streambuf_wchar_epptr(&this->base))
4110         return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4111
4112     oldsize = (ptr ? basic_streambuf_wchar_epptr(&this->base)-basic_streambuf_wchar_eback(&this->base): 0);
4113     size = oldsize|0xf;
4114     size += size/2;
4115     buf = MSVCRT_operator_new(size*sizeof(wchar_t));
4116     if(!buf) {
4117         ERR("Out of memory\n");
4118         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
4119     }
4120
4121     if(!oldsize) {
4122         this->seekhigh = buf;
4123         basic_streambuf_wchar_setp(&this->base, buf, buf+size);
4124         if(this->state & STRINGBUF_no_read)
4125             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4126         else
4127             basic_streambuf_wchar_setg(&this->base, buf, buf, buf+1);
4128
4129         this->state |= STRINGBUF_allocated;
4130     }else {
4131         ptr = basic_streambuf_wchar_eback(&this->base);
4132         memcpy(buf, ptr, oldsize*sizeof(wchar_t));
4133
4134         this->seekhigh = buf+(this->seekhigh-ptr);
4135         basic_streambuf_wchar_setp_next(&this->base, buf,
4136                 buf+(basic_streambuf_wchar_pptr(&this->base)-ptr), buf+size);
4137         if(this->state & STRINGBUF_no_read)
4138             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4139         else
4140             basic_streambuf_wchar_setg(&this->base, buf,
4141                     buf+(basic_streambuf_wchar_gptr(&this->base)-ptr),
4142                     basic_streambuf_wchar_pptr(&this->base)+1);
4143
4144         MSVCRT_operator_delete(ptr);
4145     }
4146
4147     return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4148 }
4149
4150 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4151 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4152 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4153 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4154 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_pbackfail, 8)
4155 unsigned short __thiscall basic_stringbuf_wchar_pbackfail(basic_stringbuf_wchar *this, unsigned short c)
4156 {
4157     wchar_t *cur;
4158
4159     TRACE("(%p %x)\n", this, c);
4160
4161     cur = basic_streambuf_wchar_gptr(&this->base);
4162     if(!cur || cur==basic_streambuf_wchar_eback(&this->base)
4163             || (c!=WEOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
4164         return WEOF;
4165
4166     if(c != WEOF)
4167         cur[-1] = c;
4168     basic_streambuf_wchar_gbump(&this->base, -1);
4169     return c==WEOF ? !WEOF : c;
4170 }
4171
4172 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGXZ */
4173 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGXZ */
4174 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGXZ */
4175 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGXZ */
4176 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_underflow, 4)
4177 unsigned short __thiscall basic_stringbuf_wchar_underflow(basic_stringbuf_wchar *this)
4178 {
4179     wchar_t *ptr, *cur;
4180
4181     TRACE("(%p)\n", this);
4182
4183     cur = basic_streambuf_wchar_gptr(&this->base);
4184     if(!cur || this->state&STRINGBUF_no_read)
4185         return WEOF;
4186
4187     ptr  = basic_streambuf_wchar_pptr(&this->base);
4188     if(this->seekhigh < ptr)
4189         this->seekhigh = ptr;
4190
4191     ptr = basic_streambuf_wchar_egptr(&this->base);
4192     if(this->seekhigh > ptr)
4193         basic_streambuf_wchar_setg(&this->base, basic_streambuf_wchar_eback(&this->base), cur, this->seekhigh);
4194
4195     if(cur < this->seekhigh)
4196         return *cur;
4197     return WEOF;
4198 }
4199
4200 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4201 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4202 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4203 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4204 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekoff, 20)
4205 fpos_int* __thiscall basic_stringbuf_wchar_seekoff(basic_stringbuf_wchar *this,
4206         fpos_int *ret, streamoff off, int way, int mode)
4207 {
4208     wchar_t *beg, *cur_r, *cur_w;
4209
4210     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
4211
4212     cur_w = basic_streambuf_wchar_pptr(&this->base);
4213     if(cur_w > this->seekhigh)
4214         this->seekhigh = cur_w;
4215
4216     ret->off = 0;
4217     ret->pos = 0;
4218     ret->state = 0;
4219
4220     beg = basic_streambuf_wchar_eback(&this->base);
4221     cur_r = basic_streambuf_wchar_gptr(&this->base);
4222     if((mode & OPENMODE_in) && cur_r) {
4223         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
4224             off += cur_r-beg;
4225         else if(way == SEEKDIR_end)
4226             off += this->seekhigh-beg;
4227         else if(way != SEEKDIR_beg)
4228             off = -1;
4229
4230         if(off<0 || off>this->seekhigh-beg) {
4231             off = -1;
4232         }else {
4233             basic_streambuf_wchar_gbump(&this->base, beg-cur_r+off);
4234             if((mode & OPENMODE_out) && cur_w) {
4235                 basic_streambuf_wchar_setp_next(&this->base, beg,
4236                         basic_streambuf_wchar_gptr(&this->base),
4237                         basic_streambuf_wchar_epptr(&this->base));
4238             }
4239         }
4240     }else if((mode & OPENMODE_out) && cur_w) {
4241         if(way == SEEKDIR_cur)
4242             off += cur_w-beg;
4243         else if(way == SEEKDIR_end)
4244             off += this->seekhigh-beg;
4245         else if(way != SEEKDIR_beg)
4246             off = -1;
4247
4248         if(off<0 || off>this->seekhigh-beg)
4249             off = -1;
4250         else
4251             basic_streambuf_wchar_pbump(&this->base, beg-cur_w+off);
4252     }else {
4253         off = -1;
4254     }
4255
4256     ret->off = off;
4257     return ret;
4258 }
4259
4260 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4261 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4262 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4263 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4264 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekpos, 36)
4265 fpos_int* __thiscall basic_stringbuf_wchar_seekpos(basic_stringbuf_wchar *this,
4266         fpos_int *ret, fpos_int pos, int mode)
4267 {
4268     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
4269
4270     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
4271         *ret = pos;
4272         return ret;
4273     }
4274
4275     return basic_stringbuf_wchar_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
4276 }
4277
4278 /* ?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 */
4279 /* ?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 */
4280 /* ?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 */
4281 /* ?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 */
4282 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_set, 8)
4283 void __thiscall basic_stringbuf_wchar_str_set(basic_stringbuf_wchar *this, const basic_string_wchar *str)
4284 {
4285     TRACE("(%p %p)\n", this, str);
4286
4287     basic_stringbuf_wchar__Tidy(this);
4288     basic_stringbuf_wchar__Init(this, MSVCP_basic_string_wchar_c_str(str), str->size, this->state);
4289 }
4290
4291 /* ?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 */
4292 /* ?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 */
4293 /* ?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 */
4294 /* ?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 */
4295 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_get, 8)
4296 basic_string_wchar* __thiscall basic_stringbuf_wchar_str_get(const basic_stringbuf_wchar *this, basic_string_wchar *ret)
4297 {
4298     wchar_t *ptr;
4299
4300     TRACE("(%p)\n", this);
4301
4302     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_wchar_pptr(&this->base)) {
4303         wchar_t *pptr;
4304
4305         ptr = basic_streambuf_wchar_pbase(&this->base);
4306         pptr = basic_streambuf_wchar_pptr(&this->base);
4307
4308         return MSVCP_basic_string_wchar_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
4309     }
4310
4311     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_wchar_gptr(&this->base)) {
4312         ptr = basic_streambuf_wchar_eback(&this->base);
4313         return MSVCP_basic_string_wchar_ctor_cstr_len(ret, ptr, basic_streambuf_wchar_egptr(&this->base) - ptr);
4314     }
4315
4316     return MSVCP_basic_string_wchar_ctor(ret);
4317 }
4318
4319 /* ??0ios_base@std@@IAE@XZ */
4320 /* ??0ios_base@std@@IEAA@XZ */
4321 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
4322 ios_base* __thiscall ios_base_ctor(ios_base *this)
4323 {
4324     TRACE("(%p)\n", this);
4325     this->vtable = &MSVCP_ios_base_vtable;
4326     return this;
4327 }
4328
4329 /* ??0ios_base@std@@QAE@ABV01@@Z */
4330 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
4331 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
4332 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
4333 {
4334     TRACE("(%p %p)\n", this, copy);
4335     *this = *copy;
4336     this->vtable = &MSVCP_ios_base_vtable;
4337     return this;
4338 }
4339
4340 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
4341 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
4342 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
4343 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
4344 {
4345     IOS_BASE_fnarray *cur;
4346
4347     TRACE("(%p %x)\n", this, event);
4348
4349     for(cur=this->calls; cur; cur=cur->next)
4350         cur->event_handler(event, this, cur->index);
4351 }
4352
4353 /* ?_Tidy@ios_base@std@@AAAXXZ */
4354 /* ?_Tidy@ios_base@std@@AEAAXXZ */
4355 void CDECL ios_base_Tidy(ios_base *this)
4356 {
4357     IOS_BASE_iosarray *arr_cur, *arr_next;
4358     IOS_BASE_fnarray *event_cur, *event_next;
4359
4360     TRACE("(%p)\n", this);
4361
4362     ios_base_Callfns(this, EVENT_erase_event);
4363
4364     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
4365         arr_next = arr_cur->next;
4366         MSVCRT_operator_delete(arr_cur);
4367     }
4368     this->arr = NULL;
4369
4370     for(event_cur=this->calls; event_cur; event_cur=event_next) {
4371         event_next = event_cur->next;
4372         MSVCRT_operator_delete(event_cur);
4373     }
4374     this->calls = NULL;
4375 }
4376
4377 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
4378 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
4379 void CDECL ios_base_Ios_base_dtor(ios_base *obj)
4380 {
4381     TRACE("(%p)\n", obj);
4382     if(obj->loc) {
4383         locale_dtor(obj->loc);
4384         MSVCRT_operator_delete(obj->loc);
4385     }
4386     ios_base_Tidy(obj);
4387 }
4388
4389 /* ??1ios_base@std@@UAE@XZ */
4390 /* ??1ios_base@std@@UEAA@XZ */
4391 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
4392 void __thiscall ios_base_dtor(ios_base *this)
4393 {
4394     ios_base_Ios_base_dtor(this);
4395 }
4396
4397 DEFINE_THISCALL_WRAPPER(ios_base_vector_dtor, 8)
4398 ios_base* __thiscall ios_base_vector_dtor(ios_base *this, unsigned int flags)
4399 {
4400     TRACE("(%p %x)\n", this, flags);
4401     if(flags & 2) {
4402         /* we have an array, with the number of elements stored before the first object */
4403         INT_PTR i, *ptr = (INT_PTR *)this-1;
4404
4405         for(i=*ptr-1; i>=0; i--)
4406             ios_base_dtor(this+i);
4407         MSVCRT_operator_delete(ptr);
4408     } else {
4409         ios_base_dtor(this);
4410         if(flags & 1)
4411             MSVCRT_operator_delete(this);
4412     }
4413
4414     return this;
4415 }
4416
4417 DEFINE_THISCALL_WRAPPER(iosb_vector_dtor, 8)
4418 void* __thiscall iosb_vector_dtor(void *this, unsigned int flags)
4419 {
4420     TRACE("(%p %x)\n", this, flags);
4421     if(flags & 2) {
4422         INT_PTR *ptr = (INT_PTR *)this-1;
4423         MSVCRT_operator_delete(ptr);
4424     } else {
4425         if(flags & 1)
4426             MSVCRT_operator_delete(this);
4427     }
4428
4429     return this;
4430 }
4431
4432 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
4433 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
4434 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
4435 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
4436 {
4437     IOS_BASE_iosarray *p;
4438
4439     TRACE("(%p %d)\n", this, index);
4440
4441     for(p=this->arr; p; p=p->next) {
4442         if(p->index == index)
4443             return p;
4444     }
4445
4446     for(p=this->arr; p; p=p->next) {
4447         if(!p->long_val && !p->ptr_val) {
4448             p->index = index;
4449             return p;
4450         }
4451     }
4452
4453     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
4454     p->next = this->arr;
4455     p->index = index;
4456     p->long_val = 0;
4457     p->ptr_val = NULL;
4458     this->arr = p;
4459     return p;
4460 }
4461
4462 /* ?iword@ios_base@std@@QAEAAJH@Z */
4463 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
4464 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
4465 LONG* __thiscall ios_base_iword(ios_base *this, int index)
4466 {
4467     TRACE("(%p %d)\n", this, index);
4468     return &ios_base_Findarr(this, index)->long_val;
4469 }
4470
4471 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
4472 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
4473 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
4474 void** __thiscall ios_base_pword(ios_base *this, int index)
4475 {
4476     TRACE("(%p %d)\n", this, index);
4477     return &ios_base_Findarr(this, index)->ptr_val;
4478 }
4479
4480 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
4481 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
4482 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
4483 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
4484 {
4485     IOS_BASE_fnarray *event;
4486
4487     TRACE("(%p %p %d)\n", this, callback, index);
4488
4489     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
4490     event->next = this->calls;
4491     event->index = index;
4492     event->event_handler = callback;
4493     this->calls = event;
4494 }
4495
4496 /* ?clear@ios_base@std@@QAEXH_N@Z */
4497 /* ?clear@ios_base@std@@QEAAXH_N@Z */
4498 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
4499 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4500 {
4501     TRACE("(%p %x %x)\n", this, state, reraise);
4502
4503     this->state = state & IOSTATE_mask;
4504     if(!(this->state & this->except))
4505         return;
4506
4507     if(reraise)
4508         throw_exception(EXCEPTION_RERAISE, NULL);
4509     else if(this->state & this->except & IOSTATE_eofbit)
4510         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
4511     else if(this->state & this->except & IOSTATE_failbit)
4512         throw_exception(EXCEPTION_FAILURE, "failbit is set");
4513     else if(this->state & this->except & IOSTATE_badbit)
4514         throw_exception(EXCEPTION_FAILURE, "badbit is set");
4515     else if(this->state & this->except & IOSTATE__Hardfail)
4516         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
4517 }
4518
4519 /* ?clear@ios_base@std@@QAEXH@Z */
4520 /* ?clear@ios_base@std@@QEAAXH@Z */
4521 DEFINE_THISCALL_WRAPPER(ios_base_clear, 8)
4522 void __thiscall ios_base_clear(ios_base *this, IOSB_iostate state)
4523 {
4524     ios_base_clear_reraise(this, state, FALSE);
4525 }
4526
4527 /* ?clear@ios_base@std@@QAEXI@Z */
4528 /* ?clear@ios_base@std@@QEAAXI@Z */
4529 DEFINE_THISCALL_WRAPPER(ios_base_clear_unsigned, 8)
4530 void __thiscall ios_base_clear_unsigned(ios_base *this, unsigned int state)
4531 {
4532     ios_base_clear_reraise(this, (IOSB_iostate)state, FALSE);
4533 }
4534
4535 /* ?exceptions@ios_base@std@@QAEXH@Z */
4536 /* ?exceptions@ios_base@std@@QEAAXH@Z */
4537 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
4538 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
4539 {
4540     TRACE("(%p %x)\n", this, state);
4541     this->except = state & IOSTATE_mask;
4542     ios_base_clear(this, this->state);
4543 }
4544
4545 /* ?exceptions@ios_base@std@@QAEXI@Z */
4546 /* ?exceptions@ios_base@std@@QEAAXI@Z */
4547 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set_unsigned, 8)
4548 void __thiscall ios_base_exceptions_set_unsigned(ios_base *this, unsigned int state)
4549 {
4550     TRACE("(%p %x)\n", this, state);
4551     ios_base_exceptions_set(this, state);
4552 }
4553
4554 /* ?exceptions@ios_base@std@@QBEHXZ */
4555 /* ?exceptions@ios_base@std@@QEBAHXZ */
4556 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
4557 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
4558 {
4559     TRACE("(%p)\n", this);
4560     return this->except;
4561 }
4562
4563 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
4564 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
4565 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
4566 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
4567 {
4568     TRACE("(%p %p)\n", this, rhs);
4569
4570     if(this != rhs) {
4571         IOS_BASE_iosarray *arr_cur;
4572         IOS_BASE_fnarray *event_cur;
4573
4574         ios_base_Tidy(this);
4575
4576         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
4577             if(arr_cur->long_val)
4578                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
4579             if(arr_cur->ptr_val)
4580                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
4581         }
4582         this->stdstr = rhs->stdstr;
4583         this->fmtfl = rhs->fmtfl;
4584         this->prec = rhs->prec;
4585         this->wide = rhs->wide;
4586         locale_operator_assign(this->loc, rhs->loc);
4587
4588         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
4589             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
4590
4591         ios_base_Callfns(this, EVENT_copyfmt_event);
4592         ios_base_exceptions_set(this, rhs->except);
4593     }
4594
4595     return this;
4596 }
4597
4598 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
4599 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
4600 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
4601 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
4602 {
4603     TRACE("(%p %p)\n", this, right);
4604
4605     if(this != right) {
4606         this->state = right->state;
4607         ios_base_copyfmt(this, right);
4608     }
4609
4610     return this;
4611 }
4612
4613 /* ?fail@ios_base@std@@QBE_NXZ */
4614 /* ?fail@ios_base@std@@QEBA_NXZ */
4615 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
4616 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
4617 {
4618     TRACE("(%p)\n", this);
4619     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
4620 }
4621
4622 /* ??7ios_base@std@@QBE_NXZ */
4623 /* ??7ios_base@std@@QEBA_NXZ */
4624 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
4625 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
4626 {
4627     TRACE("(%p)\n", this);
4628     return ios_base_fail(this);
4629 }
4630
4631 /* ??Bios_base@std@@QBEPAXXZ */
4632 /* ??Bios_base@std@@QEBAPEAXXZ */
4633 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
4634 void* __thiscall ios_base_op_fail(const ios_base *this)
4635 {
4636     TRACE("(%p)\n", this);
4637     return ios_base_fail(this) ? NULL : (void*)this;
4638 }
4639
4640 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
4641 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
4642 void CDECL ios_base_Addstd(ios_base *add)
4643 {
4644     FIXME("(%p) stub\n", add);
4645 }
4646
4647 /* ?_Index_func@ios_base@std@@CAAAHXZ */
4648 /* ?_Index_func@ios_base@std@@CAAEAHXZ */
4649 int* CDECL ios_base_Index_func(void)
4650 {
4651     TRACE("\n");
4652     return &ios_base_Index;
4653 }
4654
4655 /* ?_Init@ios_base@std@@IAEXXZ */
4656 /* ?_Init@ios_base@std@@IEAAXXZ */
4657 DEFINE_THISCALL_WRAPPER(ios_base__Init, 4)
4658 void __thiscall ios_base__Init(ios_base *this)
4659 {
4660     TRACE("(%p)\n", this);
4661
4662     this->stdstr = 0;
4663     this->state = this->except = IOSTATE_goodbit;
4664     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
4665     this->prec = 6;
4666     this->wide = 0;
4667     this->arr = NULL;
4668     this->calls = NULL;
4669     this->loc = MSVCRT_operator_new(sizeof(locale));
4670     locale_ctor(this->loc);
4671 }
4672
4673 /* ?_Sync_func@ios_base@std@@CAAA_NXZ */
4674 /* ?_Sync_func@ios_base@std@@CAAEA_NXZ */
4675 MSVCP_bool* CDECL ios_base_Sync_func(void)
4676 {
4677     TRACE("\n");
4678     return &ios_base_Sync;
4679 }
4680
4681 /* ?bad@ios_base@std@@QBE_NXZ */
4682 /* ?bad@ios_base@std@@QEBA_NXZ */
4683 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
4684 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
4685 {
4686     TRACE("(%p)\n", this);
4687     return (this->state & IOSTATE_badbit) != 0;
4688 }
4689
4690 /* ?eof@ios_base@std@@QBE_NXZ */
4691 /* ?eof@ios_base@std@@QEBA_NXZ */
4692 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
4693 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
4694 {
4695     TRACE("(%p)\n", this);
4696     return (this->state & IOSTATE_eofbit) != 0;
4697 }
4698
4699 /* ?flags@ios_base@std@@QAEHH@Z */
4700 /* ?flags@ios_base@std@@QEAAHH@Z */
4701 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
4702 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
4703 {
4704     IOSB_fmtflags ret = this->fmtfl;
4705
4706     TRACE("(%p %x)\n", this, flags);
4707
4708     this->fmtfl = flags & FMTFLAG_mask;
4709     return ret;
4710 }
4711
4712 /* ?flags@ios_base@std@@QBEHXZ */
4713 /* ?flags@ios_base@std@@QEBAHXZ */
4714 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
4715 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
4716 {
4717     TRACE("(%p)\n", this);
4718     return this->fmtfl;
4719 }
4720
4721 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
4722 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
4723 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
4724 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
4725 {
4726     TRACE("(%p)\n", this);
4727     return locale_copy_ctor(ret, this->loc);
4728 }
4729
4730 /* ?good@ios_base@std@@QBE_NXZ */
4731 /* ?good@ios_base@std@@QEBA_NXZ */
4732 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
4733 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
4734 {
4735     TRACE("(%p)\n", this);
4736     return this->state == IOSTATE_goodbit;
4737 }
4738
4739 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
4740 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
4741 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
4742 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
4743 {
4744     TRACE("(%p %p)\n", this, loc);
4745     *ret = *this->loc;
4746     locale_copy_ctor(this->loc, loc);
4747     return ret;
4748 }
4749
4750 /* ?precision@ios_base@std@@QAEHH@Z */
4751 /* ?precision@ios_base@std@@QEAA_J_J@Z */
4752 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
4753 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
4754 {
4755     streamsize ret = this->prec;
4756
4757     TRACE("(%p %ld)\n", this, precision);
4758
4759     this->prec = precision;
4760     return ret;
4761 }
4762
4763 /* ?precision@ios_base@std@@QBEHXZ */
4764 /* ?precision@ios_base@std@@QEBA_JXZ */
4765 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
4766 streamsize __thiscall ios_base_precision_get(const ios_base *this)
4767 {
4768     TRACE("(%p)\n", this);
4769     return this->prec;
4770 }
4771
4772 /* ?rdstate@ios_base@std@@QBEHXZ */
4773 /* ?rdstate@ios_base@std@@QEBAHXZ */
4774 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
4775 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
4776 {
4777     TRACE("(%p)\n", this);
4778     return this->state;
4779 }
4780
4781 /* ?setf@ios_base@std@@QAEHHH@Z */
4782 /* ?setf@ios_base@std@@QEAAHHH@Z */
4783 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
4784 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
4785 {
4786     IOSB_fmtflags ret = this->fmtfl;
4787
4788     TRACE("(%p %x %x)\n", this, flags, mask);
4789
4790     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
4791     return ret;
4792 }
4793
4794 /* ?setf@ios_base@std@@QAEHH@Z */
4795 /* ?setf@ios_base@std@@QEAAHH@Z */
4796 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
4797 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
4798 {
4799     return ios_base_setf_mask(this, flags, ~0);
4800 }
4801
4802 /* ?setstate@ios_base@std@@QAEXH_N@Z */
4803 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
4804 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
4805 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4806 {
4807     TRACE("(%p %x %x)\n", this, state, reraise);
4808
4809     if(state != IOSTATE_goodbit)
4810         ios_base_clear_reraise(this, this->state | state, reraise);
4811 }
4812
4813 /* ?setstate@ios_base@std@@QAEXH@Z */
4814 /* ?setstate@ios_base@std@@QEAAXH@Z */
4815 DEFINE_THISCALL_WRAPPER(ios_base_setstate, 8)
4816 void __thiscall ios_base_setstate(ios_base *this, IOSB_iostate state)
4817 {
4818     ios_base_setstate_reraise(this, state, FALSE);
4819 }
4820
4821 /* ?setstate@ios_base@std@@QAEXI@Z */
4822 /* ?setstate@ios_base@std@@QEAAXI@Z */
4823 DEFINE_THISCALL_WRAPPER(ios_base_setstate_unsigned, 8)
4824 void __thiscall ios_base_setstate_unsigned(ios_base *this, unsigned int state)
4825 {
4826     ios_base_setstate_reraise(this, (IOSB_iostate)state, FALSE);
4827 }
4828
4829 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
4830 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
4831 {
4832     _Lockit lock;
4833     MSVCP_bool ret;
4834
4835     TRACE("(%x)\n", sync);
4836
4837     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4838     ret = ios_base_Sync;
4839     ios_base_Sync = sync;
4840     _Lockit_dtor(&lock);
4841     return ret;
4842 }
4843
4844 /* ?unsetf@ios_base@std@@QAEXH@Z */
4845 /* ?unsetf@ios_base@std@@QEAAXH@Z */
4846 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
4847 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
4848 {
4849     TRACE("(%p %x)\n", this, flags);
4850     this->fmtfl &= ~flags;
4851 }
4852
4853 /* ?width@ios_base@std@@QAEHH@Z */
4854 /* ?width@ios_base@std@@QEAA_J_J@Z */
4855 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
4856 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
4857 {
4858     streamsize ret = this->wide;
4859
4860     TRACE("(%p %ld)\n", this, width);
4861
4862     this->wide = width;
4863     return ret;
4864 }
4865
4866 /* ?width@ios_base@std@@QBEHXZ */
4867 /* ?width@ios_base@std@@QEBA_JXZ */
4868 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
4869 streamsize __thiscall ios_base_width_get(ios_base *this)
4870 {
4871     TRACE("(%p)\n", this);
4872     return this->wide;
4873 }
4874
4875 /* ?xalloc@ios_base@std@@SAHXZ */
4876 int CDECL ios_base_xalloc(void)
4877 {
4878     _Lockit lock;
4879     int ret;
4880
4881     TRACE("\n");
4882
4883     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4884     ret = ios_base_Index++;
4885     _Lockit_dtor(&lock);
4886     return ret;
4887 }
4888
4889 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
4890 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
4891 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
4892 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
4893 {
4894     TRACE("(%p)\n", this);
4895
4896     ios_base_ctor(&this->base);
4897     this->base.vtable = &MSVCP_basic_ios_char_vtable;
4898     return this;
4899 }
4900
4901 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4902 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4903 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
4904 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
4905 {
4906     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4907     ios_base__Init(&this->base);
4908     this->strbuf = streambuf;
4909     this->stream = NULL;
4910     this->fillch = ' ';
4911
4912     if(!streambuf)
4913         ios_base_setstate(&this->base, IOSTATE_badbit);
4914
4915     if(isstd)
4916         FIXME("standard streams not handled yet\n");
4917 }
4918
4919 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4920 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4921 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
4922 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
4923 {
4924     TRACE("(%p %p)\n", this, strbuf);
4925
4926     basic_ios_char_ctor(this);
4927     basic_ios_char_init(this, strbuf, FALSE);
4928     return this;
4929 }
4930
4931 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
4932 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4933 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
4934 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
4935 {
4936     TRACE("(%p)\n", this);
4937     ios_base_dtor(&this->base);
4938 }
4939
4940 DEFINE_THISCALL_WRAPPER(basic_ios_char_vector_dtor, 8)
4941 basic_ios_char* __thiscall basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
4942 {
4943     TRACE("(%p %x)\n", this, flags);
4944     if(flags & 2) {
4945         /* we have an array, with the number of elements stored before the first object */
4946         INT_PTR i, *ptr = (INT_PTR *)this-1;
4947
4948         for(i=*ptr-1; i>=0; i--)
4949             basic_ios_char_dtor(this+i);
4950         MSVCRT_operator_delete(ptr);
4951     } else {
4952         basic_ios_char_dtor(this);
4953         if(flags & 1)
4954             MSVCRT_operator_delete(this);
4955     }
4956
4957     return this;
4958 }
4959
4960 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4961 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4962 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
4963 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4964 {
4965     TRACE("(%p %x %x)\n", this, state, reraise);
4966     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4967 }
4968
4969 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4970 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4971 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear, 8)
4972 void __thiscall basic_ios_char_clear(basic_ios_char *this, unsigned int state)
4973 {
4974     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
4975 }
4976
4977 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
4978 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4979 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
4980 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
4981 {
4982     TRACE("(%p %p)\n", this, copy);
4983     if(this == copy)
4984         return this;
4985
4986     this->stream = copy->stream;
4987     this->fillch = copy->fillch;
4988     ios_base_copyfmt(&this->base, &copy->base);
4989     return this;
4990 }
4991
4992 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
4993 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
4994 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
4995 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
4996 {
4997     char ret = this->fillch;
4998
4999     TRACE("(%p %c)\n", this, fill);
5000
5001     this->fillch = fill;
5002     return ret;
5003 }
5004
5005 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
5006 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
5007 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
5008 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
5009 {
5010     TRACE("(%p)\n", this);
5011     return this->fillch;
5012 }
5013
5014 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5015 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5016 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
5017 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
5018 {
5019     TRACE("(%p %p %p)\n", this, ret, loc);
5020
5021     if(this->strbuf) {
5022         basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
5023         locale_dtor(ret);
5024     }
5025
5026     return ios_base_imbue(&this->base, ret, loc);
5027 }
5028
5029 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
5030 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
5031 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
5032 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
5033 {
5034     TRACE("(%p %c %c)\n", this, ch, def);
5035     return ctype_char_narrow_ch(ctype_char_use_facet(this->strbuf->loc), ch, def);
5036 }
5037
5038 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
5039 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
5040 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
5041 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
5042 {
5043     basic_streambuf_char *ret = this->strbuf;
5044
5045     TRACE("(%p %p)\n", this, streambuf);
5046
5047     this->strbuf = streambuf;
5048     basic_ios_char_clear(this, IOSTATE_goodbit);
5049     return ret;
5050 }
5051
5052 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
5053 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
5054 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
5055 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
5056 {
5057     TRACE("(%p)\n", this);
5058     return this->strbuf;
5059 }
5060
5061 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
5062 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
5063 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
5064 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
5065 {
5066     TRACE("(%p %x %x)\n", this, state, reraise);
5067
5068     if(state != IOSTATE_goodbit)
5069         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
5070 }
5071
5072 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
5073 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
5074 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate, 8)
5075 void __thiscall basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
5076 {
5077     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
5078 }
5079
5080 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
5081 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
5082 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
5083 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
5084 {
5085     basic_ostream_char *ret = this->stream;
5086
5087     TRACE("(%p %p)\n", this, ostream);
5088
5089     this->stream = ostream;
5090     return ret;
5091 }
5092
5093 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
5094 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
5095 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
5096 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
5097 {
5098     TRACE("(%p)\n", this);
5099     return this->stream;
5100 }
5101
5102 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
5103 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
5104 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
5105 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
5106 {
5107     TRACE("(%p %c)\n", this, ch);
5108     return ctype_char_widen_ch(ctype_char_use_facet(this->strbuf->loc), ch);
5109 }
5110
5111
5112 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
5113 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
5114 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor, 4)
5115 basic_ios_wchar* __thiscall basic_ios_wchar_ctor(basic_ios_wchar *this)
5116 {
5117     TRACE("(%p)\n", this);
5118
5119     ios_base_ctor(&this->base);
5120     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
5121     return this;
5122 }
5123
5124 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
5125 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
5126 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
5127 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
5128 {
5129     basic_ios_wchar_ctor(this);
5130     this->base.vtable = &MSVCP_basic_ios_short_vtable;
5131     return this;
5132 }
5133
5134 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
5135 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
5136 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
5137 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
5138 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
5139 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
5140 {
5141     TRACE("(%p %p %x)\n", this, streambuf, isstd);
5142     ios_base__Init(&this->base);
5143     this->strbuf = streambuf;
5144     this->stream = NULL;
5145     this->fillch = ' ';
5146
5147     if(!streambuf)
5148         ios_base_setstate(&this->base, IOSTATE_badbit);
5149
5150     if(isstd)
5151         FIXME("standard streams not handled yet\n");
5152 }
5153
5154 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5155 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5156 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor_streambuf, 8)
5157 basic_ios_wchar* __thiscall basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
5158 {
5159     TRACE("(%p %p)\n", this, strbuf);
5160
5161     basic_ios_wchar_ctor(this);
5162     basic_ios_wchar_init(this, strbuf, FALSE);
5163     return this;
5164 }
5165
5166 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5167 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5168 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
5169 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
5170 {
5171     basic_ios_wchar_ctor_streambuf(this, strbuf);
5172     this->base.vtable = &MSVCP_basic_ios_short_vtable;
5173     return this;
5174 }
5175
5176 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
5177 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
5178 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
5179 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
5180 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
5181 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
5182 {
5183     TRACE("(%p)\n", this);
5184     ios_base_dtor(&this->base);
5185 }
5186
5187 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_vector_dtor, 8)
5188 basic_ios_wchar* __thiscall basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
5189 {
5190     TRACE("(%p %x)\n", this, flags);
5191     if(flags & 2) {
5192         /* we have an array, with the number of elements stored before the first object */
5193         INT_PTR i, *ptr = (INT_PTR *)this-1;
5194
5195         for(i=*ptr-1; i>=0; i--)
5196             basic_ios_wchar_dtor(this+i);
5197         MSVCRT_operator_delete(ptr);
5198     } else {
5199         basic_ios_wchar_dtor(this);
5200         if(flags & 1)
5201             MSVCRT_operator_delete(this);
5202     }
5203
5204     return this;
5205 }
5206
5207 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5208 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5209 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5210 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5211 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
5212 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5213 {
5214     TRACE("(%p %x %x)\n", this, state, reraise);
5215     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
5216 }
5217
5218 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5219 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5220 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5221 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5222 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear, 8)
5223 void __thiscall basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
5224 {
5225     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
5226 }
5227
5228 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
5229 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5230 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
5231 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5232 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
5233 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
5234 {
5235     TRACE("(%p %p)\n", this, copy);
5236     if(this == copy)
5237         return this;
5238
5239     this->stream = copy->stream;
5240     this->fillch = copy->fillch;
5241     ios_base_copyfmt(&this->base, &copy->base);
5242     return this;
5243 }
5244
5245 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
5246 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
5247 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
5248 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
5249 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
5250 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
5251 {
5252     wchar_t ret = this->fillch;
5253
5254     TRACE("(%p %c)\n", this, fill);
5255
5256     this->fillch = fill;
5257     return ret;
5258 }
5259
5260 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
5261 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
5262 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
5263 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
5264 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
5265 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
5266 {
5267     TRACE("(%p)\n", this);
5268     return this->fillch;
5269 }
5270
5271 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5272 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5273 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5274 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5275 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
5276 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
5277 {
5278     TRACE("(%p %p %p)\n", this, ret, loc);
5279
5280     if(this->strbuf) {
5281         basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
5282         locale_dtor(ret);
5283     }
5284
5285     return ios_base_imbue(&this->base, ret, loc);
5286 }
5287
5288 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
5289 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
5290 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
5291 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
5292 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
5293 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
5294 {
5295     TRACE("(%p %c %c)\n", this, ch, def);
5296     return ctype_wchar_narrow_ch(ctype_wchar_use_facet(this->strbuf->loc), ch, def);
5297 }
5298
5299 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5300 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5301 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
5302 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5303 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
5304 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
5305 {
5306     basic_streambuf_wchar *ret = this->strbuf;
5307
5308     TRACE("(%p %p)\n", this, streambuf);
5309
5310     this->strbuf = streambuf;
5311     basic_ios_wchar_clear(this, IOSTATE_goodbit);
5312     return ret;
5313 }
5314
5315 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5316 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5317 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5318 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5319 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
5320 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
5321 {
5322     TRACE("(%p)\n", this);
5323     return this->strbuf;
5324 }
5325
5326 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5327 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5328 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5329 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5330 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
5331 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5332 {
5333     TRACE("(%p %x %x)\n", this, state, reraise);
5334
5335     if(state != IOSTATE_goodbit)
5336         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
5337 }
5338
5339 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5340 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5341 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5342 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5343 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate, 8)
5344 void __thiscall basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
5345 {
5346     basic_ios_wchar_setstate_reraise(this, state, FALSE);
5347 }
5348
5349 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5350 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5351 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
5352 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5353 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
5354 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
5355 {
5356     basic_ostream_wchar *ret = this->stream;
5357
5358     TRACE("(%p %p)\n", this, ostream);
5359
5360     this->stream = ostream;
5361     return ret;
5362 }
5363
5364 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5365 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5366 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5367 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5368 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
5369 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
5370 {
5371     TRACE("(%p)\n", this);
5372     return this->stream;
5373 }
5374
5375 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
5376 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
5377 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
5378 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
5379 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
5380 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
5381 {
5382     TRACE("(%p %c)\n", this, ch);
5383     return ctype_wchar_widen_ch(ctype_wchar_use_facet(this->strbuf->loc), ch);
5384 }
5385
5386 /* Caution: basic_ostream uses virtual inheritance.
5387  * All constructors have additional parameter that says if base class should be initialized.
5388  * Base class needs to be accessed using vbtable.
5389  */
5390 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
5391 {
5392     return (basic_ios_char*)((char*)this+this->vbtable[1]);
5393 }
5394
5395 static inline basic_ios_char* basic_ostream_char_to_basic_ios(basic_ostream_char *ptr)
5396 {
5397     return (basic_ios_char*)((char*)ptr+basic_ostream_char_vbtable[1]);
5398 }
5399
5400 static inline basic_ostream_char* basic_ostream_char_from_basic_ios(basic_ios_char *ptr)
5401 {
5402     return (basic_ostream_char*)((char*)ptr-basic_ostream_char_vbtable[1]);
5403 }
5404
5405 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5406 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5407 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor, 16)
5408 basic_ostream_char* __thiscall basic_ostream_char_ctor(basic_ostream_char *this,
5409         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5410 {
5411     basic_ios_char *base;
5412
5413     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5414
5415     if(virt_init) {
5416         this->vbtable = basic_ostream_char_vbtable;
5417         base = basic_ostream_char_get_basic_ios(this);
5418         basic_ios_char_ctor(base);
5419     }else {
5420         base = basic_ostream_char_get_basic_ios(this);
5421     }
5422
5423     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5424     basic_ios_char_init(base, strbuf, isstd);
5425     return this;
5426 }
5427
5428 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5429 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5430 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor_uninitialized, 16)
5431 basic_ostream_char* __thiscall basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
5432         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5433 {
5434     basic_ios_char *base;
5435
5436     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5437
5438     if(virt_init) {
5439         this->vbtable = basic_ostream_char_vbtable;
5440         base = basic_ostream_char_get_basic_ios(this);
5441         basic_ios_char_ctor(base);
5442     }else {
5443         base = basic_ostream_char_get_basic_ios(this);
5444     }
5445
5446     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5447     if(addstd)
5448         ios_base_Addstd(&base->base);
5449     return this;
5450 }
5451
5452 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5453 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5454 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
5455 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
5456 {
5457     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5458
5459     /* don't destroy virtual base here */
5460     TRACE("(%p)\n", this);
5461 }
5462
5463 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5464 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5465 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
5466 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
5467 {
5468     TRACE("(%p)\n", this);
5469     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
5470     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
5471 }
5472
5473 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
5474 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5475 {
5476     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5477
5478     TRACE("(%p %x)\n", this, flags);
5479
5480     if(flags & 2) {
5481         /* we have an array, with the number of elements stored before the first object */
5482         INT_PTR i, *ptr = (INT_PTR *)this-1;
5483
5484         for(i=*ptr-1; i>=0; i--)
5485             basic_ostream_char_vbase_dtor(this+i);
5486         MSVCRT_operator_delete(ptr);
5487     } else {
5488         basic_ostream_char_vbase_dtor(this);
5489         if(flags & 1)
5490             MSVCRT_operator_delete(this);
5491     }
5492
5493     return this;
5494 }
5495
5496 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5497 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5498 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
5499 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
5500 {
5501     /* this function is not matching C++ specification */
5502     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5503
5504     TRACE("(%p)\n", this);
5505
5506     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
5507             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
5508         basic_ios_char_setstate(base, IOSTATE_badbit);
5509     return this;
5510 }
5511
5512 /* ?flush@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5513 /* ?flush@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5514 basic_ostream_char* __cdecl flush_ostream_char(basic_ostream_char *ostream)
5515 {
5516     return basic_ostream_char_flush(ostream);
5517 }
5518
5519 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5520 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5521 DEFINE_THISCALL_WRAPPER(basic_ostream_char__Osfx, 4)
5522 void __thiscall basic_ostream_char__Osfx(basic_ostream_char *this)
5523 {
5524     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5525
5526     TRACE("(%p)\n", this);
5527
5528     if(base->base.fmtfl & FMTFLAG_unitbuf)
5529         basic_ostream_char_flush(this);
5530 }
5531
5532 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5533 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5534 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
5535 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
5536 {
5537     TRACE("(%p)\n", this);
5538     basic_ostream_char__Osfx(this);
5539 }
5540
5541 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
5542 {
5543     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5544
5545     if(basic_ios_char_rdbuf_get(base))
5546         basic_streambuf_char__Lock(base->strbuf);
5547
5548     if(ios_base_good(&base->base) && base->stream)
5549         basic_ostream_char_flush(base->stream);
5550
5551     return ios_base_good(&base->base);
5552 }
5553
5554 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
5555 {
5556     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5557
5558     if(ios_base_good(&base->base) && !__uncaught_exception())
5559         basic_ostream_char_osfx(ostr);
5560
5561     if(basic_ios_char_rdbuf_get(base))
5562         basic_streambuf_char__Unlock(base->strbuf);
5563 }
5564
5565 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
5566 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
5567 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
5568 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
5569 {
5570     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5571
5572     TRACE("(%p)\n", this);
5573
5574     if(ios_base_good(&base->base) && base->stream)
5575         basic_ostream_char_flush(base->stream);
5576     return ios_base_good(&base->base);
5577 }
5578
5579 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5580 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5581 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
5582 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
5583 {
5584     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5585
5586     TRACE("(%p %c)\n", this, ch);
5587
5588     if(!basic_ostream_char_sentry_create(this)
5589             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
5590         basic_ostream_char_sentry_destroy(this);
5591         basic_ios_char_setstate(base, IOSTATE_badbit);
5592         return this;
5593     }
5594
5595     basic_ostream_char_sentry_destroy(this);
5596     return this;
5597 }
5598
5599 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
5600 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
5601 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp, 12)
5602 basic_ostream_char* __thiscall basic_ostream_char_seekp(basic_ostream_char *this, streamoff off, int way)
5603 {
5604     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5605
5606     TRACE("(%p %ld %d)\n", this, off, way);
5607
5608     if(!ios_base_fail(&base->base)) {
5609         fpos_int seek;
5610
5611         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5612                 &seek, off, way, OPENMODE_out);
5613         if(seek.off==0 && seek.pos==-1 && seek.state==0)
5614             basic_ios_char_setstate(base, IOSTATE_failbit);
5615     }
5616     return this;
5617 }
5618
5619 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
5620 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
5621 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
5622 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
5623 {
5624     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5625
5626     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
5627
5628     if(!ios_base_fail(&base->base)) {
5629         fpos_int seek;
5630
5631         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
5632                 &seek, pos, OPENMODE_out);
5633         if(seek.off==0 && seek.pos==-1 && seek.state==0)
5634             basic_ios_char_setstate(base, IOSTATE_failbit);
5635     }
5636     return this;
5637 }
5638
5639 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
5640 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
5641 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
5642 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
5643 {
5644     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5645
5646     TRACE("(%p)\n", this);
5647
5648     if(!ios_base_fail(&base->base)) {
5649         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5650                 ret, 0, SEEKDIR_cur, OPENMODE_out);
5651     }else {
5652         ret->off = 0;
5653         ret->pos = -1;
5654         ret->state = 0;
5655     }
5656     return ret;
5657 }
5658
5659 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
5660 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
5661 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
5662 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
5663 {
5664     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5665
5666     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
5667
5668     if(!basic_ostream_char_sentry_create(this)
5669             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
5670         basic_ostream_char_sentry_destroy(this);
5671         basic_ios_char_setstate(base, IOSTATE_badbit);
5672         return this;
5673     }
5674
5675     basic_ostream_char_sentry_destroy(this);
5676     return this;
5677 }
5678
5679 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
5680 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
5681 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
5682 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
5683 {
5684     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5685     int state = IOSTATE_goodbit;
5686
5687     TRACE("(%p %d)\n", this, val);
5688
5689     if(basic_ostream_char_sentry_create(this)) {
5690         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5691         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5692         ostreambuf_iterator_char dest = {0, strbuf};
5693
5694         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
5695                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
5696                 ? (LONG)((unsigned short)val) : (LONG)val);
5697     }
5698     basic_ostream_char_sentry_destroy(this);
5699
5700     basic_ios_char_setstate(base, state);
5701     return this;
5702 }
5703
5704 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
5705 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
5706 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
5707 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
5708 {
5709     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5710     int state = IOSTATE_goodbit;
5711
5712     TRACE("(%p %u)\n", this, val);
5713
5714     if(basic_ostream_char_sentry_create(this)) {
5715         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5716         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5717         ostreambuf_iterator_char dest = {0, strbuf};
5718
5719         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5720     }
5721     basic_ostream_char_sentry_destroy(this);
5722
5723     basic_ios_char_setstate(base, state);
5724     return this;
5725 }
5726
5727 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
5728 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
5729 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
5730 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
5731 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
5732 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
5733 {
5734     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5735     int state = IOSTATE_goodbit;
5736
5737     TRACE("(%p %d)\n", this, val);
5738
5739     if(basic_ostream_char_sentry_create(this)) {
5740         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5741         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5742         ostreambuf_iterator_char dest = {0, strbuf};
5743
5744         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5745     }
5746     basic_ostream_char_sentry_destroy(this);
5747
5748     basic_ios_char_setstate(base, state);
5749     return this;
5750 }
5751
5752 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
5753 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
5754 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
5755 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
5756 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
5757 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
5758 {
5759     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5760     int state = IOSTATE_goodbit;
5761
5762     TRACE("(%p %u)\n", this, val);
5763
5764     if(basic_ostream_char_sentry_create(this)) {
5765         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5766         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5767         ostreambuf_iterator_char dest = {0, strbuf};
5768
5769         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5770     }
5771     basic_ostream_char_sentry_destroy(this);
5772
5773     basic_ios_char_setstate(base, state);
5774     return this;
5775 }
5776
5777 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
5778 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
5779 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
5780 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
5781 {
5782     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5783     int state = IOSTATE_goodbit;
5784
5785     TRACE("(%p %f)\n", this, val);
5786
5787     if(basic_ostream_char_sentry_create(this)) {
5788         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5789         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5790         ostreambuf_iterator_char dest = {0, strbuf};
5791
5792         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5793     }
5794     basic_ostream_char_sentry_destroy(this);
5795
5796     basic_ios_char_setstate(base, state);
5797     return this;
5798 }
5799
5800 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
5801 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
5802 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
5803 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
5804 {
5805     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5806     int state = IOSTATE_goodbit;
5807
5808     TRACE("(%p %lf)\n", this, val);
5809
5810     if(basic_ostream_char_sentry_create(this)) {
5811         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5812         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5813         ostreambuf_iterator_char dest = {0, strbuf};
5814
5815         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5816     }
5817     basic_ostream_char_sentry_destroy(this);
5818
5819     basic_ios_char_setstate(base, state);
5820     return this;
5821 }
5822
5823 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
5824 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
5825 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
5826 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
5827 {
5828     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5829     int state = IOSTATE_goodbit;
5830
5831     TRACE("(%p %lf)\n", this, val);
5832
5833     if(basic_ostream_char_sentry_create(this)) {
5834         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5835         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5836         ostreambuf_iterator_char dest = {0, strbuf};
5837
5838         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5839     }
5840     basic_ostream_char_sentry_destroy(this);
5841
5842     basic_ios_char_setstate(base, state);
5843     return this;
5844 }
5845
5846 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5847 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5848 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
5849 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
5850 {
5851     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5852     IOSB_iostate state = IOSTATE_badbit;
5853     int c = '\n';
5854
5855     TRACE("(%p %p)\n", this, val);
5856
5857     if(basic_ostream_char_sentry_create(this)) {
5858         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
5859                 c = basic_streambuf_char_snextc(val)) {
5860             state = IOSTATE_goodbit;
5861
5862             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
5863                 state = IOSTATE_badbit;
5864                 break;
5865             }
5866         }
5867     }else {
5868         state = IOSTATE_badbit;
5869     }
5870     basic_ostream_char_sentry_destroy(this);
5871
5872     ios_base_width_set(&base->base, 0);
5873     basic_ios_char_setstate(base, state);
5874     return this;
5875 }
5876
5877 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
5878 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
5879 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
5880 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
5881 {
5882     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5883     int state = IOSTATE_goodbit;
5884
5885     TRACE("(%p %p)\n", this, val);
5886
5887     if(basic_ostream_char_sentry_create(this)) {
5888         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5889         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5890         ostreambuf_iterator_char dest = {0, strbuf};
5891
5892         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5893     }
5894     basic_ostream_char_sentry_destroy(this);
5895
5896     basic_ios_char_setstate(base, state);
5897     return this;
5898 }
5899
5900 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
5901 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
5902 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
5903 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
5904 {
5905     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5906     int state = IOSTATE_goodbit;
5907
5908     TRACE("(%p)\n", this);
5909
5910     if(basic_ostream_char_sentry_create(this)) {
5911         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5912         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5913         ostreambuf_iterator_char dest = {0, strbuf};
5914
5915         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5916     }
5917     basic_ostream_char_sentry_destroy(this);
5918
5919     basic_ios_char_setstate(base, state);
5920     return this;
5921 }
5922
5923 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
5924 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
5925 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
5926 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
5927 {
5928     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5929     int state = IOSTATE_goodbit;
5930
5931     TRACE("(%p)\n", this);
5932
5933     if(basic_ostream_char_sentry_create(this)) {
5934         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5935         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5936         ostreambuf_iterator_char dest = {0, strbuf};
5937
5938         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5939     }
5940     basic_ostream_char_sentry_destroy(this);
5941
5942     basic_ios_char_setstate(base, state);
5943     return this;
5944 }
5945
5946 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
5947 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
5948 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
5949 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
5950 {
5951     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5952     int state = IOSTATE_goodbit;
5953
5954     TRACE("(%p %x)\n", this, val);
5955
5956     if(basic_ostream_char_sentry_create(this)) {
5957         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5958         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5959         ostreambuf_iterator_char dest = {0, strbuf};
5960
5961         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5962     }
5963     basic_ostream_char_sentry_destroy(this);
5964
5965     basic_ios_char_setstate(base, state);
5966     return this;
5967 }
5968
5969 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5970 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5971 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
5972 {
5973     TRACE("(%p)\n", ostr);
5974
5975     basic_ostream_char_put(ostr, '\n');
5976     basic_ostream_char_flush(ostr);
5977     return ostr;
5978 }
5979
5980 /* $?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 */
5981 /* ??$?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 */
5982 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
5983 {
5984     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5985     IOSB_iostate state = IOSTATE_goodbit;
5986
5987     TRACE("(%p %p)\n", ostr, str);
5988
5989     if(basic_ostream_char_sentry_create(ostr)) {
5990         MSVCP_size_t len = MSVCP_basic_string_char_length(str);
5991         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5992
5993         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5994             for(; pad!=0; pad--) {
5995                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5996                     state = IOSTATE_badbit;
5997                     break;
5998                 }
5999             }
6000         }
6001
6002         if(state == IOSTATE_goodbit) {
6003             if(basic_streambuf_char_sputn(base->strbuf, MSVCP_basic_string_char_c_str(str), len) != len)
6004                     state = IOSTATE_badbit;
6005         }
6006
6007         if(state == IOSTATE_goodbit) {
6008             for(; pad!=0; pad--) {
6009                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6010                     state = IOSTATE_badbit;
6011                     break;
6012                 }
6013             }
6014         }
6015
6016         base->base.wide = 0;
6017     }else {
6018         state = IOSTATE_badbit;
6019     }
6020     basic_ostream_char_sentry_destroy(ostr);
6021
6022     basic_ios_char_setstate(base, state);
6023     return ostr;
6024 }
6025
6026 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@C@Z */
6027 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@C@Z */
6028 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z */
6029 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z */
6030 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@E@Z */
6031 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@E@Z */
6032 basic_ostream_char* __cdecl basic_ostream_char_print_ch(basic_ostream_char *ostr, char ch)
6033 {
6034     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
6035     IOSB_iostate state = IOSTATE_goodbit;
6036
6037     TRACE("(%p %d)\n", ostr, ch);
6038
6039     if(basic_ostream_char_sentry_create(ostr)) {
6040         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6041
6042         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6043             for(; pad!=0; pad--) {
6044                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6045                     state = IOSTATE_badbit;
6046                     break;
6047                 }
6048             }
6049         }
6050
6051         if(state == IOSTATE_goodbit) {
6052             if(basic_streambuf_char_sputc(base->strbuf, ch) == EOF)
6053                 state = IOSTATE_badbit;
6054         }
6055
6056         if(state == IOSTATE_goodbit) {
6057             for(; pad!=0; pad--) {
6058                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6059                     state = IOSTATE_badbit;
6060                     break;
6061                 }
6062             }
6063         }
6064
6065         base->base.wide = 0;
6066     }else {
6067         state = IOSTATE_badbit;
6068     }
6069     basic_ostream_char_sentry_destroy(ostr);
6070
6071     basic_ios_char_setstate(base, state);
6072     return ostr;
6073 }
6074
6075 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBC@Z */
6076 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBC@Z */
6077 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z */
6078 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z */
6079 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBE@Z */
6080 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBE@Z */
6081 basic_ostream_char* __cdecl basic_ostream_char_print_str(basic_ostream_char *ostr, const char *str)
6082 {
6083     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
6084     IOSB_iostate state = IOSTATE_goodbit;
6085
6086     TRACE("(%p %s)\n", ostr, str);
6087
6088     if(basic_ostream_char_sentry_create(ostr)) {
6089         MSVCP_size_t len = strlen(str);
6090         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6091
6092         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6093             for(; pad!=0; pad--) {
6094                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6095                     state = IOSTATE_badbit;
6096                     break;
6097                 }
6098             }
6099         }
6100
6101         if(state == IOSTATE_goodbit) {
6102             if(basic_streambuf_char_sputn(base->strbuf, str, len) != len)
6103                 state = IOSTATE_badbit;
6104         }
6105
6106         if(state == IOSTATE_goodbit) {
6107             for(; pad!=0; pad--) {
6108                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6109                     state = IOSTATE_badbit;
6110                     break;
6111                 }
6112             }
6113         }
6114
6115         base->base.wide = 0;
6116     }else {
6117         state = IOSTATE_badbit;
6118     }
6119     basic_ostream_char_sentry_destroy(ostr);
6120
6121     basic_ios_char_setstate(base, state);
6122     return ostr;
6123 }
6124
6125 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6126 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6127 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
6128 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
6129         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
6130 {
6131     TRACE("(%p %p)\n", this, pfunc);
6132     pfunc(this);
6133     return this;
6134 }
6135
6136 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
6137 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
6138 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
6139 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
6140         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
6141 {
6142     TRACE("(%p %p)\n", this, pfunc);
6143     pfunc(basic_ostream_char_get_basic_ios(this));
6144     return this;
6145 }
6146
6147 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6148 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6149 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
6150 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
6151         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
6152 {
6153     TRACE("(%p %p)\n", this, pfunc);
6154     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
6155     return this;
6156 }
6157
6158 /* Caution: basic_ostream uses virtual inheritance. */
6159 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
6160 {
6161     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
6162 }
6163
6164 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
6165 {
6166     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
6167 }
6168
6169 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
6170 {
6171     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
6172 }
6173
6174 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6175 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6176 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_ctor, 16)
6177 basic_ostream_wchar* __thiscall basic_ostream_wchar_ctor(basic_ostream_wchar *this,
6178         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6179 {
6180     basic_ios_wchar *base;
6181
6182     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
6183
6184     if(virt_init) {
6185         this->vbtable = basic_ostream_wchar_vbtable;
6186         base = basic_ostream_wchar_get_basic_ios(this);
6187         basic_ios_wchar_ctor(base);
6188     }else {
6189         base = basic_ostream_wchar_get_basic_ios(this);
6190     }
6191
6192     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6193     basic_ios_wchar_init(base, strbuf, isstd);
6194     return this;
6195 }
6196
6197 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6198 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6199 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor, 16)
6200 basic_ostream_wchar* __thiscall basic_ostream_short_ctor(basic_ostream_wchar *this,
6201         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6202 {
6203     basic_ostream_wchar_ctor(this, strbuf, isstd, virt_init);
6204     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
6205     return this;
6206 }
6207
6208 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
6209 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
6210 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_ctor_uninitialized, 16)
6211 basic_ostream_wchar* __thiscall basic_ostream_wchar_ctor_uninitialized(basic_ostream_wchar *this,
6212         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
6213 {
6214     basic_ios_wchar *base;
6215
6216     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
6217
6218     if(virt_init) {
6219         this->vbtable = basic_ostream_wchar_vbtable;
6220         base = basic_ostream_wchar_get_basic_ios(this);
6221         basic_ios_wchar_ctor(base);
6222     }else {
6223         base = basic_ostream_wchar_get_basic_ios(this);
6224     }
6225
6226     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6227     if(addstd)
6228         ios_base_Addstd(&base->base);
6229     return this;
6230 }
6231
6232 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
6233 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
6234 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor_uninitialized, 16)
6235 basic_ostream_wchar* __thiscall basic_ostream_short_ctor_uninitialized(basic_ostream_wchar *this,
6236         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
6237 {
6238     basic_ostream_wchar_ctor_uninitialized(this, uninitialized, addstd, virt_init);
6239     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
6240     return this;
6241 }
6242
6243 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
6244 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
6245 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
6246 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
6247 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
6248 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
6249 {
6250     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6251
6252     /* don't destroy virtual base here */
6253     TRACE("(%p)\n", this);
6254 }
6255
6256 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6257 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6258 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6259 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6260 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
6261 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
6262 {
6263     TRACE("(%p)\n", this);
6264     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
6265     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
6266 }
6267
6268 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
6269 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
6270 {
6271     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6272
6273     TRACE("(%p %x)\n", this, flags);
6274
6275     if(flags & 2) {
6276         /* we have an array, with the number of elements stored before the first object */
6277         INT_PTR i, *ptr = (INT_PTR *)this-1;
6278
6279         for(i=*ptr-1; i>=0; i--)
6280             basic_ostream_wchar_vbase_dtor(this+i);
6281         MSVCRT_operator_delete(ptr);
6282     } else {
6283         basic_ostream_wchar_vbase_dtor(this);
6284         if(flags & 1)
6285             MSVCRT_operator_delete(this);
6286     }
6287
6288     return this;
6289 }
6290
6291 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
6292 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
6293 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
6294 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
6295 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
6296 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
6297 {
6298     /* this function is not matching C++ specification */
6299     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6300
6301     TRACE("(%p)\n", this);
6302
6303     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
6304             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
6305         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6306     return this;
6307 }
6308
6309 /* ?flush@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6310 /* ?flush@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6311 /* ?flush@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6312 /* ?flush@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6313 basic_ostream_wchar* __cdecl flush_ostream_wchar(basic_ostream_wchar *ostream)
6314 {
6315     return basic_ostream_wchar_flush(ostream);
6316 }
6317
6318 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6319 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6320 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6321 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6322 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar__Osfx, 4)
6323 void __thiscall basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
6324 {
6325     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6326
6327     TRACE("(%p)\n", this);
6328
6329     if(base->base.fmtfl & FMTFLAG_unitbuf)
6330         basic_ostream_wchar_flush(this);
6331 }
6332
6333 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6334 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6335 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6336 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6337 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
6338 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
6339 {
6340     TRACE("(%p)\n", this);
6341     basic_ostream_wchar__Osfx(this);
6342 }
6343
6344 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
6345 {
6346     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6347
6348     if(basic_ios_wchar_rdbuf_get(base))
6349         basic_streambuf_wchar__Lock(base->strbuf);
6350
6351     if(ios_base_good(&base->base) && base->stream)
6352         basic_ostream_wchar_flush(base->stream);
6353
6354     return ios_base_good(&base->base);
6355 }
6356
6357 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
6358 {
6359     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6360
6361     if(ios_base_good(&base->base) && !__uncaught_exception())
6362         basic_ostream_wchar_osfx(ostr);
6363
6364     if(basic_ios_wchar_rdbuf_get(base))
6365         basic_streambuf_wchar__Unlock(base->strbuf);
6366 }
6367
6368 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
6369 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
6370 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
6371 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
6372 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
6373 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
6374 {
6375     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6376
6377     TRACE("(%p)\n", this);
6378
6379     if(ios_base_good(&base->base) && base->stream)
6380         basic_ostream_wchar_flush(base->stream);
6381     return ios_base_good(&base->base);
6382 }
6383
6384 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
6385 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
6386 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
6387 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
6388 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
6389 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
6390 {
6391     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6392
6393     TRACE("(%p %c)\n", this, ch);
6394
6395     if(!basic_ostream_wchar_sentry_create(this)
6396             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
6397         basic_ostream_wchar_sentry_destroy(this);
6398         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6399         return this;
6400     }
6401
6402     basic_ostream_wchar_sentry_destroy(this);
6403     return this;
6404 }
6405
6406 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
6407 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
6408 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
6409 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
6410 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp, 12)
6411 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp(basic_ostream_wchar *this, streamoff off, int way)
6412 {
6413     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6414
6415     TRACE("(%p %ld %d)\n", this, off, way);
6416
6417     if(!ios_base_fail(&base->base)) {
6418         fpos_int seek;
6419
6420         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6421                 &seek, off, way, OPENMODE_out);
6422         if(seek.off==0 && seek.pos==-1 && seek.state==0)
6423             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6424     }
6425     return this;
6426 }
6427
6428 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6429 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6430 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6431 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6432 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
6433 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
6434 {
6435     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6436
6437     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6438
6439     if(!ios_base_fail(&base->base)) {
6440         fpos_int seek;
6441
6442         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
6443                 &seek, pos, OPENMODE_out);
6444         if(seek.off==0 && seek.pos==-1 && seek.state==0)
6445             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6446     }
6447     return this;
6448 }
6449
6450 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6451 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6452 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6453 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6454 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
6455 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
6456 {
6457     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6458
6459     TRACE("(%p)\n", this);
6460
6461     if(!ios_base_fail(&base->base)) {
6462         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6463                 ret, 0, SEEKDIR_cur, OPENMODE_out);
6464     }else {
6465         ret->off = 0;
6466         ret->pos = -1;
6467         ret->state = 0;
6468     }
6469     return ret;
6470 }
6471
6472 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
6473 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
6474 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
6475 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
6476 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 12)
6477 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
6478 {
6479     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6480
6481     TRACE("(%p %s %ld)\n", this, debugstr_w(str), count);
6482
6483     if(!basic_ostream_wchar_sentry_create(this)
6484             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
6485         basic_ostream_wchar_sentry_destroy(this);
6486         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6487         return this;
6488     }
6489
6490     basic_ostream_wchar_sentry_destroy(this);
6491     return this;
6492 }
6493
6494 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
6495 {
6496     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6497     int state = IOSTATE_goodbit;
6498
6499     TRACE("(%p %d)\n", this, val);
6500
6501     if(basic_ostream_wchar_sentry_create(this)) {
6502         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6503         ostreambuf_iterator_wchar dest = {0, strbuf};
6504
6505         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
6506                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
6507                 ? (LONG)((unsigned short)val) : (LONG)val);
6508     }
6509     basic_ostream_wchar_sentry_destroy(this);
6510
6511     basic_ios_wchar_setstate(base, state);
6512     return this;
6513 }
6514
6515 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@F@Z */
6516 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@F@Z */
6517 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_short, 8)
6518 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_short(basic_ostream_wchar *this, short val)
6519 {
6520     return basic_ostream_print_short(this, val, num_put_wchar_use_facet(
6521                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6522 }
6523
6524 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
6525 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
6526 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
6527 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
6528 {
6529     return basic_ostream_print_short(this, val, num_put_short_use_facet(
6530                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6531 }
6532
6533 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@G@Z */
6534 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@G@Z */
6535 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ushort, 8)
6536 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ushort(basic_ostream_wchar *this, unsigned short val)
6537 {
6538     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6539     int state = IOSTATE_goodbit;
6540
6541     TRACE("(%p %u)\n", this, val);
6542
6543     if(basic_ostream_wchar_sentry_create(this)) {
6544         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6545         const num_put *numput = num_put_wchar_use_facet(strbuf->loc);
6546         ostreambuf_iterator_wchar dest = {0, strbuf};
6547
6548         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6549     }
6550     basic_ostream_wchar_sentry_destroy(this);
6551
6552     basic_ios_wchar_setstate(base, state);
6553     return this;
6554 }
6555
6556 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
6557 {
6558     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6559     int state = IOSTATE_goodbit;
6560
6561     TRACE("(%p %d)\n", this, val);
6562
6563     if(basic_ostream_wchar_sentry_create(this)) {
6564         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6565         ostreambuf_iterator_wchar dest = {0, strbuf};
6566
6567         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6568     }
6569     basic_ostream_wchar_sentry_destroy(this);
6570
6571     basic_ios_wchar_setstate(base, state);
6572     return this;
6573 }
6574
6575 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@H@Z */
6576 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@H@Z */
6577 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@J@Z */
6578 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@J@Z */
6579 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int, 8)
6580 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int(basic_ostream_wchar *this, int val)
6581 {
6582     return basic_ostream_print_int(this, val, num_put_wchar_use_facet(
6583                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6584 }
6585
6586 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
6587 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
6588 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
6589 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
6590 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
6591 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
6592 {
6593     return basic_ostream_print_int(this, val, num_put_short_use_facet(
6594                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6595 }
6596
6597 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
6598 {
6599     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6600     int state = IOSTATE_goodbit;
6601
6602     TRACE("(%p %u)\n", this, val);
6603
6604     if(basic_ostream_wchar_sentry_create(this)) {
6605         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6606         ostreambuf_iterator_wchar dest = {0, strbuf};
6607
6608         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6609     }
6610     basic_ostream_wchar_sentry_destroy(this);
6611
6612     basic_ios_wchar_setstate(base, state);
6613     return this;
6614 }
6615
6616 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@I@Z */
6617 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@I@Z */
6618 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@K@Z */
6619 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@K@Z */
6620 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint, 8)
6621 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint(basic_ostream_wchar *this, unsigned int val)
6622 {
6623     return basic_ostream_print_uint(this, val, num_put_wchar_use_facet(
6624                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6625 }
6626
6627 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
6628 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
6629 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
6630 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
6631 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
6632 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
6633 {
6634     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
6635                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6636 }
6637
6638 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
6639 {
6640     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6641     int state = IOSTATE_goodbit;
6642
6643     TRACE("(%p %f)\n", this, val);
6644
6645     if(basic_ostream_wchar_sentry_create(this)) {
6646         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6647         ostreambuf_iterator_wchar dest = {0, strbuf};
6648
6649         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6650     }
6651     basic_ostream_wchar_sentry_destroy(this);
6652
6653     basic_ios_wchar_setstate(base, state);
6654     return this;
6655 }
6656
6657 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@M@Z */
6658 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@M@Z */
6659 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_float, 8)
6660 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_float(basic_ostream_wchar *this, float val)
6661 {
6662     return basic_ostream_print_float(this, val, num_put_wchar_use_facet(
6663                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6664 }
6665
6666 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
6667 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
6668 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
6669 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
6670 {
6671     return basic_ostream_print_float(this, val, num_put_short_use_facet(
6672                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6673 }
6674
6675 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
6676 {
6677     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6678     int state = IOSTATE_goodbit;
6679
6680     TRACE("(%p %lf)\n", this, val);
6681
6682     if(basic_ostream_wchar_sentry_create(this)) {
6683         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6684         ostreambuf_iterator_wchar dest = {0, strbuf};
6685
6686         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6687     }
6688     basic_ostream_wchar_sentry_destroy(this);
6689
6690     basic_ios_wchar_setstate(base, state);
6691     return this;
6692 }
6693
6694 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@N@Z */
6695 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@N@Z */
6696 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_double, 12)
6697 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_double(basic_ostream_wchar *this, double val)
6698 {
6699     return basic_ostream_print_double(this, val, num_put_wchar_use_facet(
6700                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6701 }
6702
6703 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
6704 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
6705 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
6706 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
6707 {
6708     return basic_ostream_print_double(this, val, num_put_short_use_facet(
6709                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6710 }
6711
6712 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
6713 {
6714     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6715     int state = IOSTATE_goodbit;
6716
6717     TRACE("(%p %lf)\n", this, val);
6718
6719     if(basic_ostream_wchar_sentry_create(this)) {
6720         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6721         ostreambuf_iterator_wchar dest = {0, strbuf};
6722
6723         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6724     }
6725     basic_ostream_wchar_sentry_destroy(this);
6726
6727     basic_ios_wchar_setstate(base, state);
6728     return this;
6729 }
6730
6731 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@O@Z */
6732 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@O@Z */
6733 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ldouble, 12)
6734 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ldouble(basic_ostream_wchar *this, double val)
6735 {
6736     return basic_ostream_print_ldouble(this, val, num_put_wchar_use_facet(
6737                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6738 }
6739
6740 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
6741 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
6742 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
6743 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
6744 {
6745     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
6746                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6747 }
6748
6749 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6750 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6751 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6752 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6753 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
6754 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
6755 {
6756     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6757     IOSB_iostate state = IOSTATE_badbit;
6758     unsigned short c = '\n';
6759
6760     TRACE("(%p %p)\n", this, val);
6761
6762     if(basic_ostream_wchar_sentry_create(this)) {
6763         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
6764                 c = basic_streambuf_wchar_snextc(val)) {
6765             state = IOSTATE_goodbit;
6766
6767             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
6768                 state = IOSTATE_badbit;
6769                 break;
6770             }
6771         }
6772     }else {
6773         state = IOSTATE_badbit;
6774     }
6775     basic_ostream_wchar_sentry_destroy(this);
6776
6777     ios_base_width_set(&base->base, 0);
6778     basic_ios_wchar_setstate(base, state);
6779     return this;
6780 }
6781
6782 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
6783 {
6784     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6785     int state = IOSTATE_goodbit;
6786
6787     TRACE("(%p %p)\n", this, val);
6788
6789     if(basic_ostream_wchar_sentry_create(this)) {
6790         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6791         ostreambuf_iterator_wchar dest = {0, strbuf};
6792
6793         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6794     }
6795     basic_ostream_wchar_sentry_destroy(this);
6796
6797     basic_ios_wchar_setstate(base, state);
6798     return this;
6799 }
6800
6801 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PBX@Z */
6802 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEBX@Z */
6803 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ptr, 8)
6804 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ptr(basic_ostream_wchar *this, const void *val)
6805 {
6806     return basic_ostream_print_ptr(this, val, num_put_wchar_use_facet(
6807                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6808 }
6809
6810 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
6811 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
6812 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
6813 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
6814 {
6815     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
6816                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6817 }
6818
6819 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
6820 {
6821     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6822     int state = IOSTATE_goodbit;
6823
6824     TRACE("(%p)\n", this);
6825
6826     if(basic_ostream_wchar_sentry_create(this)) {
6827         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6828         ostreambuf_iterator_wchar dest = {0, strbuf};
6829
6830         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6831     }
6832     basic_ostream_wchar_sentry_destroy(this);
6833
6834     basic_ios_wchar_setstate(base, state);
6835     return this;
6836 }
6837
6838 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_J@Z */
6839 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_J@Z */
6840 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int64, 12)
6841 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int64(basic_ostream_wchar *this, __int64 val)
6842 {
6843     return basic_ostream_print_int64(this, val, num_put_wchar_use_facet(
6844                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6845 }
6846
6847 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
6848 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
6849 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
6850 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
6851 {
6852     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
6853                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6854 }
6855
6856 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
6857 {
6858     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6859     int state = IOSTATE_goodbit;
6860
6861     TRACE("(%p)\n", this);
6862
6863     if(basic_ostream_wchar_sentry_create(this)) {
6864         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6865         ostreambuf_iterator_wchar dest = {0, strbuf};
6866
6867         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6868     }
6869     basic_ostream_wchar_sentry_destroy(this);
6870
6871     basic_ios_wchar_setstate(base, state);
6872     return this;
6873 }
6874
6875 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_K@Z */
6876 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_K@Z */
6877 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint64, 12)
6878 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6879 {
6880     return basic_ostream_print_uint64(this, val, num_put_wchar_use_facet(
6881                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6882 }
6883
6884 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
6885 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
6886 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
6887 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6888 {
6889     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
6890                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6891 }
6892
6893 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
6894 {
6895     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6896     int state = IOSTATE_goodbit;
6897
6898     TRACE("(%p %x)\n", this, val);
6899
6900     if(basic_ostream_wchar_sentry_create(this)) {
6901         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6902         ostreambuf_iterator_wchar dest = {0, strbuf};
6903
6904         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6905     }
6906     basic_ostream_wchar_sentry_destroy(this);
6907
6908     basic_ios_wchar_setstate(base, state);
6909     return this;
6910 }
6911
6912 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_N@Z */
6913 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_N@Z */
6914 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_bool, 8)
6915 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6916 {
6917     return basic_ostream_print_bool(this, val, num_put_wchar_use_facet(
6918                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6919 }
6920
6921 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
6922 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
6923 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
6924 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6925 {
6926     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
6927                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6928 }
6929
6930 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6931 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6932 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6933 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6934 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
6935 {
6936     TRACE("(%p)\n", ostr);
6937
6938     basic_ostream_wchar_put(ostr, '\n');
6939     basic_ostream_wchar_flush(ostr);
6940     return ostr;
6941 }
6942
6943 /* ??$?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 */
6944 /* ??$?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 */
6945 /* ??$?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 */
6946 /* ??$?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 */
6947 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_bstr(basic_ostream_wchar *ostr, const basic_string_wchar *str)
6948 {
6949     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6950     IOSB_iostate state = IOSTATE_goodbit;
6951
6952     TRACE("(%p %p)\n", ostr, str);
6953
6954     if(basic_ostream_wchar_sentry_create(ostr)) {
6955         MSVCP_size_t len = MSVCP_basic_string_wchar_length(str);
6956         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6957
6958         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6959             for(; pad!=0; pad--) {
6960                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6961                     state = IOSTATE_badbit;
6962                     break;
6963                 }
6964             }
6965         }
6966
6967         if(state == IOSTATE_goodbit) {
6968             if(basic_streambuf_wchar_sputn(base->strbuf, MSVCP_basic_string_wchar_c_str(str), len) != len)
6969                 state = IOSTATE_badbit;
6970         }
6971
6972         if(state == IOSTATE_goodbit) {
6973             for(; pad!=0; pad--) {
6974                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6975                     state = IOSTATE_badbit;
6976                     break;
6977                 }
6978             }
6979         }
6980
6981         base->base.wide = 0;
6982     }else {
6983         state = IOSTATE_badbit;
6984     }
6985     basic_ostream_wchar_sentry_destroy(ostr);
6986
6987     basic_ios_wchar_setstate(base, state);
6988     return ostr;
6989 }
6990
6991 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@_W@Z */
6992 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@_W@Z */
6993 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@G@Z */
6994 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@G@Z */
6995 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_ch(basic_ostream_wchar *ostr, wchar_t ch)
6996 {
6997     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6998     IOSB_iostate state = IOSTATE_goodbit;
6999
7000     TRACE("(%p %d)\n", ostr, ch);
7001
7002     if(basic_ostream_wchar_sentry_create(ostr)) {
7003         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
7004
7005         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
7006             for(; pad!=0; pad--) {
7007                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7008                     state = IOSTATE_badbit;
7009                     break;
7010                 }
7011             }
7012         }
7013
7014         if(state == IOSTATE_goodbit) {
7015             if(basic_streambuf_wchar_sputc(base->strbuf, ch) == WEOF)
7016                 state = IOSTATE_badbit;
7017         }
7018
7019         if(state == IOSTATE_goodbit) {
7020             for(; pad!=0; pad--) {
7021                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7022                     state = IOSTATE_badbit;
7023                     break;
7024                 }
7025             }
7026         }
7027
7028         base->base.wide = 0;
7029     }else {
7030         state = IOSTATE_badbit;
7031     }
7032     basic_ostream_wchar_sentry_destroy(ostr);
7033
7034     basic_ios_wchar_setstate(base, state);
7035     return ostr;
7036 }
7037
7038 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@PB_W@Z */
7039 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@PEB_W@Z */
7040 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@PBG@Z */
7041 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@PEBG@Z */
7042 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_str(basic_ostream_wchar *ostr, const wchar_t *str)
7043 {
7044     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
7045     IOSB_iostate state = IOSTATE_goodbit;
7046
7047     TRACE("(%p %s)\n", ostr, debugstr_w(str));
7048
7049     if(basic_ostream_wchar_sentry_create(ostr)) {
7050         MSVCP_size_t len = wcslen(str);
7051         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
7052
7053         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
7054             for(; pad!=0; pad--) {
7055                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7056                     state = IOSTATE_badbit;
7057                     break;
7058                 }
7059             }
7060         }
7061
7062         if(state == IOSTATE_goodbit) {
7063             if(basic_streambuf_wchar_sputn(base->strbuf, str, len) != len)
7064                                         state = IOSTATE_badbit;
7065         }
7066
7067         if(state == IOSTATE_goodbit) {
7068             for(; pad!=0; pad--) {
7069                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7070                     state = IOSTATE_badbit;
7071                     break;
7072                 }
7073             }
7074         }
7075
7076         base->base.wide = 0;
7077     }else {
7078         state = IOSTATE_badbit;
7079     }
7080     basic_ostream_wchar_sentry_destroy(ostr);
7081
7082     basic_ios_wchar_setstate(base, state);
7083     return ostr;
7084 }
7085
7086 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7087 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7088 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7089 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7090 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
7091 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
7092         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
7093 {
7094     TRACE("(%p %p)\n", this, pfunc);
7095     pfunc(this);
7096     return this;
7097 }
7098
7099 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
7100 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
7101 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
7102 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
7103 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
7104 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
7105         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
7106 {
7107     TRACE("(%p %p)\n", this, pfunc);
7108     pfunc(basic_ostream_wchar_get_basic_ios(this));
7109     return this;
7110 }
7111
7112 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7113 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7114 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7115 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7116 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
7117 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
7118         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
7119 {
7120     TRACE("(%p %p)\n", this, pfunc);
7121     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
7122     return this;
7123 }
7124
7125 /* Caution: basic_istream uses virtual inheritance. */
7126 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
7127 {
7128     return (basic_ios_char*)((char*)this+this->vbtable[1]);
7129 }
7130
7131 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
7132 {
7133     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
7134 }
7135
7136 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
7137 {
7138     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
7139 }
7140
7141 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
7142 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
7143 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_init, 20)
7144 basic_istream_char* __thiscall basic_istream_char_ctor_init(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7145 {
7146     basic_ios_char *base;
7147
7148     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
7149
7150     if(virt_init) {
7151         this->vbtable = basic_istream_char_vbtable;
7152         base = basic_istream_char_get_basic_ios(this);
7153         basic_ios_char_ctor(base);
7154     }else {
7155         base = basic_istream_char_get_basic_ios(this);
7156     }
7157
7158     base->base.vtable = &MSVCP_basic_istream_char_vtable;
7159     this->count = 0;
7160     if(!noinit)
7161         basic_ios_char_init(base, strbuf, isstd);
7162     return this;
7163 }
7164
7165 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
7166 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
7167 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
7168 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7169 {
7170     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7171 }
7172
7173 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7174 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7175 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
7176 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
7177 {
7178     basic_ios_char *base;
7179
7180     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
7181
7182     if(virt_init) {
7183         this->vbtable = basic_istream_char_vbtable;
7184         base = basic_istream_char_get_basic_ios(this);
7185         basic_ios_char_ctor(base);
7186     }else {
7187         base = basic_istream_char_get_basic_ios(this);
7188     }
7189
7190     base->base.vtable = &MSVCP_basic_istream_char_vtable;
7191     ios_base_Addstd(&base->base);
7192     return this;
7193 }
7194
7195 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
7196 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
7197 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
7198 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
7199 {
7200     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
7201
7202     /* don't destroy virtual base here */
7203     TRACE("(%p)\n", this);
7204 }
7205
7206 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
7207 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
7208 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
7209 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
7210 {
7211     TRACE("(%p)\n", this);
7212     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
7213     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
7214 }
7215
7216 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
7217 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
7218 {
7219     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
7220
7221     TRACE("(%p %x)\n", this, flags);
7222
7223     if(flags & 2) {
7224         /* we have an array, with the number of elements stored before the first object */
7225         INT_PTR i, *ptr = (INT_PTR *)this-1;
7226
7227         for(i=*ptr-1; i>=0; i--)
7228             basic_istream_char_vbase_dtor(this+i);
7229         MSVCRT_operator_delete(ptr);
7230     } else {
7231         basic_istream_char_vbase_dtor(this);
7232         if(flags & 1)
7233             MSVCRT_operator_delete(this);
7234     }
7235
7236     return this;
7237 }
7238
7239 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
7240 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
7241 DEFINE_THISCALL_WRAPPER(basic_istream_char__Ipfx, 8)
7242 MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
7243 {
7244     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7245
7246     TRACE("(%p %d)\n", this, noskip);
7247
7248     if(ios_base_good(&base->base)) {
7249         if(basic_ios_char_tie_get(base))
7250             basic_ostream_char_flush(basic_ios_char_tie_get(base));
7251
7252         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
7253             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7254             const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
7255             int ch;
7256
7257             for(ch = basic_streambuf_char_sgetc(strbuf); ;
7258                     ch = basic_streambuf_char_snextc(strbuf)) {
7259                 if(ch == EOF) {
7260                     basic_ios_char_setstate(base, IOSTATE_eofbit);
7261                     break;
7262                 }
7263
7264                 if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
7265                     break;
7266             }
7267         }
7268     }
7269
7270     if(!ios_base_good(&base->base)) {
7271         basic_ios_char_setstate(base, IOSTATE_failbit);
7272         return FALSE;
7273     }
7274
7275     return TRUE;
7276 }
7277
7278 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
7279 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
7280 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
7281 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
7282 {
7283     return basic_istream_char__Ipfx(this, noskip);
7284 }
7285
7286 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
7287 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
7288 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
7289 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
7290 {
7291     TRACE("(%p)\n", this);
7292 }
7293
7294 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
7295 {
7296     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
7297
7298     if(basic_ios_char_rdbuf_get(base))
7299         basic_streambuf_char__Lock(base->strbuf);
7300
7301     return basic_istream_char_ipfx(istr, noskip);
7302 }
7303
7304 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
7305 {
7306     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
7307
7308     if(basic_ios_char_rdbuf_get(base))
7309         basic_streambuf_char__Unlock(base->strbuf);
7310 }
7311
7312 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
7313 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
7314 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
7315 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
7316 {
7317     TRACE("(%p)\n", this);
7318     return this->count;
7319 }
7320
7321 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7322 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7323 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
7324 int __thiscall basic_istream_char_get(basic_istream_char *this)
7325 {
7326     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7327     int ret;
7328
7329     TRACE("(%p)\n", this);
7330
7331     this->count = 0;
7332
7333     if(!basic_istream_char_sentry_create(this, TRUE)) {
7334         basic_istream_char_sentry_destroy(this);
7335         return EOF;
7336     }
7337
7338     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
7339     basic_istream_char_sentry_destroy(this);
7340     if(ret == EOF)
7341         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
7342     else
7343         this->count++;
7344
7345     return ret;
7346 }
7347
7348 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
7349 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
7350 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
7351 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
7352 {
7353     int ret;
7354
7355     TRACE("(%p %p)\n", this, ch);
7356
7357     ret = basic_istream_char_get(this);
7358     if(ret != EOF)
7359         *ch = (char)ret;
7360     return this;
7361 }
7362
7363 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7364 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7365 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
7366 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7367 {
7368     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7369     int ch = delim;
7370
7371     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7372
7373     this->count = 0;
7374
7375     if(basic_istream_char_sentry_create(this, TRUE)) {
7376         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7377
7378         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
7379                 ch = basic_streambuf_char_snextc(strbuf)) {
7380             if(ch==EOF || ch==delim)
7381                 break;
7382
7383             *str++ = ch;
7384             this->count++;
7385             count--;
7386         }
7387     }
7388     basic_istream_char_sentry_destroy(this);
7389
7390     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7391             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7392     if(count > 0)
7393         *str = 0;
7394     return this;
7395 }
7396
7397 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7398 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7399 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
7400 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
7401 {
7402     return basic_istream_char_get_str_delim(this, str, count, '\n');
7403 }
7404
7405 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7406 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7407 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
7408 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
7409 {
7410     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7411     int ch = delim;
7412
7413     TRACE("(%p %p %c)\n", this, strbuf, delim);
7414
7415     this->count = 0;
7416
7417     if(basic_istream_char_sentry_create(this, TRUE)) {
7418         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
7419
7420         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
7421                 ch = basic_streambuf_char_snextc(strbuf_read)) {
7422             if(ch==EOF || ch==delim)
7423                 break;
7424
7425             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
7426                 break;
7427             this->count++;
7428         }
7429     }
7430     basic_istream_char_sentry_destroy(this);
7431
7432     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7433             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7434     return this;
7435 }
7436
7437 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7438 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7439 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
7440 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
7441 {
7442     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
7443 }
7444
7445 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7446 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7447 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
7448 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7449 {
7450     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7451     int ch = (unsigned char)delim;
7452
7453     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7454
7455     this->count = 0;
7456
7457     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
7458         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7459
7460         while(count > 1) {
7461             ch = basic_streambuf_char_sbumpc(strbuf);
7462
7463             if(ch==EOF || ch==(unsigned char)delim)
7464                 break;
7465
7466             *str++ = ch;
7467             this->count++;
7468             count--;
7469         }
7470
7471         if(ch == (unsigned char)delim)
7472             this->count++;
7473         else if(ch != EOF) {
7474             ch = basic_streambuf_char_sgetc(strbuf);
7475
7476             if(ch == (unsigned char)delim) {
7477                 basic_streambuf_char__Gninc(strbuf);
7478                 this->count++;
7479             }
7480         }
7481     }
7482     basic_istream_char_sentry_destroy(this);
7483
7484     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
7485             (!this->count || (ch!=(unsigned char)delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
7486     if(count > 0)
7487         *str = 0;
7488     return this;
7489 }
7490
7491 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7492 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7493 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
7494 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
7495 {
7496     return basic_istream_char_getline_delim(this, str, count, '\n');
7497 }
7498
7499 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
7500 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7501 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
7502 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
7503 {
7504     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7505     int ch = (unsigned char)delim;
7506     unsigned int state;
7507
7508     TRACE("(%p %ld %d)\n", this, count, delim);
7509
7510     this->count = 0;
7511
7512     if(basic_istream_char_sentry_create(this, TRUE)) {
7513         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7514         state = IOSTATE_goodbit;
7515
7516         while(count > 0) {
7517             ch = basic_streambuf_char_sbumpc(strbuf);
7518
7519             if(ch==EOF) {
7520                 state = IOSTATE_eofbit;
7521                 break;
7522             }
7523
7524             if(ch==(unsigned char)delim)
7525                 break;
7526
7527             this->count++;
7528             if(count != INT_MAX)
7529                 count--;
7530         }
7531     }else
7532         state = IOSTATE_failbit;
7533     basic_istream_char_sentry_destroy(this);
7534
7535     basic_ios_char_setstate(base, state);
7536     return this;
7537 }
7538
7539 /* ?ws@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@1@AAV21@@Z */
7540 /* ?ws@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
7541 basic_istream_char* __cdecl ws_basic_istream_char(basic_istream_char *istream)
7542 {
7543     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7544     int ch = '\n';
7545
7546     TRACE("(%p)\n", istream);
7547
7548     if(basic_istream_char_sentry_create(istream, TRUE)) {
7549         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7550         const ctype_char *ctype = ctype_char_use_facet(strbuf->loc);
7551
7552         for(ch = basic_streambuf_char_sgetc(strbuf); ctype_char_is_ch(ctype, _SPACE, ch);
7553                 ch = basic_streambuf_char_snextc(strbuf)) {
7554             if(ch == EOF)
7555                 break;
7556         }
7557     }
7558     basic_istream_char_sentry_destroy(istream);
7559
7560     if(ch == EOF)
7561         basic_ios_char_setstate(base, IOSTATE_eofbit);
7562     return istream;
7563 }
7564
7565 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7566 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7567 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
7568 int __thiscall basic_istream_char_peek(basic_istream_char *this)
7569 {
7570     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7571     int ret = EOF;
7572
7573     TRACE("(%p)\n", this);
7574
7575     this->count = 0;
7576
7577     if(basic_istream_char_sentry_create(this, TRUE))
7578         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7579     basic_istream_char_sentry_destroy(this);
7580
7581     if (ret == EOF)
7582         basic_ios_char_setstate(base, IOSTATE_eofbit);
7583
7584     return ret;
7585 }
7586
7587 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
7588 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
7589 DEFINE_THISCALL_WRAPPER(basic_istream_char__Read_s, 16)
7590 basic_istream_char* __thiscall basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7591 {
7592     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7593     IOSB_iostate state = IOSTATE_goodbit;
7594
7595     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7596
7597     if(basic_istream_char_sentry_create(this, TRUE)) {
7598         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7599
7600         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
7601         if(this->count != count)
7602             state |= IOSTATE_failbit | IOSTATE_eofbit;
7603     }else {
7604         this->count = 0;
7605     }
7606     basic_istream_char_sentry_destroy(this);
7607
7608     basic_ios_char_setstate(base, state);
7609     return this;
7610 }
7611
7612 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7613 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7614 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
7615 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
7616 {
7617     return basic_istream_char__Read_s(this, str, count, count);
7618 }
7619
7620 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
7621 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
7622 DEFINE_THISCALL_WRAPPER(basic_istream_char__Readsome_s, 16)
7623 streamsize __thiscall basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7624 {
7625     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7626     IOSB_iostate state = IOSTATE_goodbit;
7627
7628     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7629
7630     this->count = 0;
7631
7632     if(basic_istream_char_sentry_create(this, TRUE)) {
7633         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
7634         if(avail > count)
7635             avail = count;
7636
7637         if(avail == -1)
7638             state |= IOSTATE_eofbit;
7639         else if(avail > 0)
7640             basic_istream_char__Read_s(this, str, size, avail);
7641     }else {
7642         state |= IOSTATE_failbit;
7643     }
7644     basic_istream_char_sentry_destroy(this);
7645
7646     basic_ios_char_setstate(base, state);
7647     return this->count;
7648 }
7649
7650 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
7651 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
7652 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
7653 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
7654 {
7655     return basic_istream_char__Readsome_s(this, str, count, count);
7656 }
7657
7658 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
7659 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
7660 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
7661 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
7662 {
7663     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7664     IOSB_iostate state = IOSTATE_goodbit;
7665
7666     TRACE("(%p %c)\n", this, ch);
7667
7668     this->count = 0;
7669
7670     if(basic_istream_char_sentry_create(this, TRUE)) {
7671         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7672
7673         if(!ios_base_good(&base->base))
7674             state |= IOSTATE_failbit;
7675         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
7676             state |= IOSTATE_badbit;
7677     }
7678     basic_istream_char_sentry_destroy(this);
7679
7680     basic_ios_char_setstate(base, state);
7681     return this;
7682 }
7683
7684 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
7685 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
7686 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
7687 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
7688 {
7689     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7690     IOSB_iostate state = IOSTATE_goodbit;
7691
7692     TRACE("(%p)\n", this);
7693
7694     this->count = 0;
7695
7696     if(basic_istream_char_sentry_create(this, TRUE)) {
7697         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7698
7699         if(!ios_base_good(&base->base))
7700             state |= IOSTATE_failbit;
7701         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
7702             state |= IOSTATE_badbit;
7703     }
7704     basic_istream_char_sentry_destroy(this);
7705
7706     basic_ios_char_setstate(base, state);
7707     return this;
7708 }
7709
7710 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7711 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7712 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
7713 int __thiscall basic_istream_char_sync(basic_istream_char *this)
7714 {
7715     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7716     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7717
7718     TRACE("(%p)\n", this);
7719
7720     if(!strbuf)
7721         return -1;
7722
7723     if(basic_istream_char_sentry_create(this, TRUE)) {
7724         if(basic_streambuf_char_pubsync(strbuf) != -1) {
7725             basic_istream_char_sentry_destroy(this);
7726             return 0;
7727         }
7728     }
7729     basic_istream_char_sentry_destroy(this);
7730
7731     basic_ios_char_setstate(base, IOSTATE_badbit);
7732     return -1;
7733 }
7734
7735 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7736 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7737 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
7738 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
7739 {
7740     TRACE("(%p %p)\n", this, ret);
7741
7742     if(basic_istream_char_sentry_create(this, TRUE)) {
7743         basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7744         if(!ios_base_fail(&base->base)) {
7745             basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
7746                     ret, 0, SEEKDIR_cur, OPENMODE_in);
7747             basic_istream_char_sentry_destroy(this);
7748
7749             if(ret->off==0 && ret->pos==-1 && ret->state==0)
7750                 basic_ios_char_setstate(base, IOSTATE_failbit);
7751             return ret;
7752         }
7753     }
7754     basic_istream_char_sentry_destroy(this);
7755
7756     ret->off = 0;
7757     ret->pos = -1;
7758     ret->state = 0;
7759     return ret;
7760 }
7761
7762 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
7763 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7764 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
7765 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
7766 {
7767     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7768
7769     TRACE("(%p %ld %d)\n", this, off, dir);
7770
7771     if(!ios_base_fail(&base->base)) {
7772         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7773         fpos_int ret;
7774
7775         basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
7776
7777         if(ret.off==0 && ret.pos==-1 && ret.state==0)
7778             basic_ios_char_setstate(base, IOSTATE_failbit);
7779         else
7780             basic_ios_char_clear(base, IOSTATE_goodbit);
7781         return this;
7782     }else
7783         basic_ios_char_clear(base, IOSTATE_goodbit);
7784
7785     return this;
7786 }
7787
7788 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7789 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7790 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
7791 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
7792 {
7793     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7794
7795     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7796
7797     if(!ios_base_fail(&base->base)) {
7798         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7799         fpos_int ret;
7800
7801         basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7802         basic_istream_char_sentry_destroy(this);
7803
7804         if(ret.off==0 && ret.pos==-1 && ret.state==0)
7805             basic_ios_char_setstate(base, IOSTATE_failbit);
7806         else
7807             basic_ios_char_clear(base, IOSTATE_goodbit);
7808         return this;
7809     }else
7810         basic_ios_char_clear(base, IOSTATE_goodbit);
7811
7812     return this;
7813 }
7814
7815 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
7816 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
7817 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
7818 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
7819 {
7820     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7821     int state = IOSTATE_goodbit;
7822
7823     TRACE("(%p %p)\n", this, v);
7824
7825     if(basic_istream_char_sentry_create(this, FALSE)) {
7826         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7827         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7828         istreambuf_iterator_char first={0}, last={0};
7829         LONG tmp;
7830
7831         first.strbuf = strbuf;
7832         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7833
7834         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7835             *v = tmp;
7836         else
7837             state |= IOSTATE_failbit;
7838     }
7839     basic_istream_char_sentry_destroy(this);
7840
7841     basic_ios_char_setstate(base, state);
7842     return this;
7843 }
7844
7845 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
7846 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
7847 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
7848 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
7849 {
7850     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7851     int state = IOSTATE_goodbit;
7852
7853     TRACE("(%p %p)\n", this, v);
7854
7855     if(basic_istream_char_sentry_create(this, FALSE)) {
7856         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7857         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7858         istreambuf_iterator_char first={0}, last={0};
7859
7860         first.strbuf = strbuf;
7861         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
7862     }
7863     basic_istream_char_sentry_destroy(this);
7864
7865     basic_ios_char_setstate(base, state);
7866     return this;
7867 }
7868
7869 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
7870 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
7871 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
7872 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
7873 {
7874     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7875     int state = IOSTATE_goodbit;
7876
7877     TRACE("(%p %p)\n", this, v);
7878
7879     if(basic_istream_char_sentry_create(this, FALSE)) {
7880         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7881         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7882         istreambuf_iterator_char first={0}, last={0};
7883
7884         first.strbuf = strbuf;
7885         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7886     }
7887     basic_istream_char_sentry_destroy(this);
7888
7889     basic_ios_char_setstate(base, state);
7890     return this;
7891 }
7892
7893 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
7894 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
7895 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
7896 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *v)
7897 {
7898     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7899     int state = IOSTATE_goodbit;
7900
7901     TRACE("(%p %p)\n", this, v);
7902
7903     if(basic_istream_char_sentry_create(this, FALSE)) {
7904         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7905         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7906         istreambuf_iterator_char first={0}, last={0};
7907
7908         first.strbuf = strbuf;
7909         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
7910     }
7911     basic_istream_char_sentry_destroy(this);
7912
7913     basic_ios_char_setstate(base, state);
7914     return this;
7915 }
7916
7917 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
7918 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
7919 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
7920 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
7921 {
7922     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7923     int state = IOSTATE_goodbit;
7924
7925     TRACE("(%p %p)\n", this, v);
7926
7927     if(basic_istream_char_sentry_create(this, FALSE)) {
7928         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7929         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7930         istreambuf_iterator_char first={0}, last={0};
7931
7932         first.strbuf = strbuf;
7933         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7934     }
7935     basic_istream_char_sentry_destroy(this);
7936
7937     basic_ios_char_setstate(base, state);
7938     return this;
7939 }
7940
7941 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
7942 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
7943 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
7944 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
7945 {
7946     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7947     int state = IOSTATE_goodbit;
7948
7949     TRACE("(%p %p)\n", this, v);
7950
7951     if(basic_istream_char_sentry_create(this, FALSE)) {
7952         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7953         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7954         istreambuf_iterator_char first={0}, last={0};
7955
7956         first.strbuf = strbuf;
7957         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
7958     }
7959     basic_istream_char_sentry_destroy(this);
7960
7961     basic_ios_char_setstate(base, state);
7962     return this;
7963 }
7964
7965 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
7966 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
7967 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
7968 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
7969 {
7970     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7971     int state = IOSTATE_goodbit;
7972
7973     TRACE("(%p %p)\n", this, v);
7974
7975     if(basic_istream_char_sentry_create(this, FALSE)) {
7976         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7977         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7978         istreambuf_iterator_char first={0}, last={0};
7979
7980         first.strbuf = strbuf;
7981         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
7982     }
7983     basic_istream_char_sentry_destroy(this);
7984
7985     basic_ios_char_setstate(base, state);
7986     return this;
7987 }
7988
7989 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
7990 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
7991 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
7992 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
7993 {
7994     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7995     int state = IOSTATE_goodbit;
7996
7997     TRACE("(%p %p)\n", this, v);
7998
7999     if(basic_istream_char_sentry_create(this, FALSE)) {
8000         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8001         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8002         istreambuf_iterator_char first={0}, last={0};
8003
8004         first.strbuf = strbuf;
8005         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
8006     }
8007     basic_istream_char_sentry_destroy(this);
8008
8009     basic_ios_char_setstate(base, state);
8010     return this;
8011 }
8012
8013 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
8014 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
8015 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
8016 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
8017 {
8018     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8019     int state = IOSTATE_goodbit;
8020
8021     TRACE("(%p %p)\n", this, v);
8022
8023     if(basic_istream_char_sentry_create(this, FALSE)) {
8024         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8025         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8026         istreambuf_iterator_char first={0}, last={0};
8027
8028         first.strbuf = strbuf;
8029         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
8030     }
8031     basic_istream_char_sentry_destroy(this);
8032
8033     basic_ios_char_setstate(base, state);
8034     return this;
8035 }
8036
8037 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
8038 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
8039 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
8040 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
8041 {
8042     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8043     int state = IOSTATE_goodbit;
8044
8045     TRACE("(%p %p)\n", this, v);
8046
8047     if(basic_istream_char_sentry_create(this, FALSE)) {
8048         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8049         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8050         istreambuf_iterator_char first={0}, last={0};
8051
8052         first.strbuf = strbuf;
8053         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
8054     }
8055     basic_istream_char_sentry_destroy(this);
8056
8057     basic_ios_char_setstate(base, state);
8058     return this;
8059 }
8060
8061 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
8062 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
8063 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
8064 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
8065 {
8066     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8067     int state = IOSTATE_goodbit;
8068
8069     TRACE("(%p %p)\n", this, v);
8070
8071     if(basic_istream_char_sentry_create(this, FALSE)) {
8072         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8073         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8074         istreambuf_iterator_char first={0}, last={0};
8075
8076         first.strbuf = strbuf;
8077         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
8078     }
8079     basic_istream_char_sentry_destroy(this);
8080
8081     basic_ios_char_setstate(base, state);
8082     return this;
8083 }
8084
8085 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
8086 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
8087 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
8088 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
8089 {
8090     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8091     int state = IOSTATE_goodbit;
8092
8093     TRACE("(%p %p)\n", this, v);
8094
8095     if(basic_istream_char_sentry_create(this, FALSE)) {
8096         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8097         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8098         istreambuf_iterator_char first={0}, last={0};
8099
8100         first.strbuf = strbuf;
8101         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
8102     }
8103     basic_istream_char_sentry_destroy(this);
8104
8105     basic_ios_char_setstate(base, state);
8106     return this;
8107 }
8108
8109 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
8110 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
8111 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
8112 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
8113 {
8114     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8115     int state = IOSTATE_goodbit;
8116
8117     TRACE("(%p %p)\n", this, v);
8118
8119     if(basic_istream_char_sentry_create(this, FALSE)) {
8120         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8121         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8122         istreambuf_iterator_char first={0}, last={0};
8123
8124         first.strbuf = strbuf;
8125         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
8126     }
8127     basic_istream_char_sentry_destroy(this);
8128
8129     basic_ios_char_setstate(base, state);
8130     return this;
8131 }
8132
8133 /* ??$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 */
8134 /* ??$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 */
8135 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
8136         basic_istream_char *istream, basic_string_char *str, char delim)
8137 {
8138     IOSB_iostate state = IOSTATE_failbit;
8139     int c = (unsigned char)delim;
8140
8141     TRACE("(%p %p %c)\n", istream, str, delim);
8142
8143     if(basic_istream_char_sentry_create(istream, TRUE)) {
8144         MSVCP_basic_string_char_clear(str);
8145
8146         c = basic_istream_char_get(istream);
8147         if(c != EOF)
8148             state = IOSTATE_goodbit;
8149
8150         for(; c!=(unsigned char)delim && c!=EOF; c = basic_istream_char_get(istream)) {
8151             state = IOSTATE_goodbit;
8152             MSVCP_basic_string_char_append_ch(str, c);
8153         }
8154     }
8155     basic_istream_char_sentry_destroy(istream);
8156
8157     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
8158         state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8159     return istream;
8160 }
8161
8162 /* ??$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 */
8163 /* ??$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 */
8164 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
8165         basic_istream_char *istream, basic_string_char *str)
8166 {
8167     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
8168 }
8169
8170 /* ??$?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 */
8171 /* ??$?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 */
8172 basic_istream_char* __cdecl basic_istream_char_read_bstr(
8173         basic_istream_char *istream, basic_string_char *str)
8174 {
8175     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
8176     IOSB_iostate state = IOSTATE_failbit;
8177     int c = '\n';
8178
8179     TRACE("(%p %p)\n", istream, str);
8180
8181     if(basic_istream_char_sentry_create(istream, FALSE)) {
8182         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
8183         MSVCP_size_t count = ios_base_width_get(&base->base);
8184
8185         if(!count)
8186             count = -1;
8187
8188         MSVCP_basic_string_char_clear(str);
8189
8190         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
8191                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8192                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
8193             state = IOSTATE_goodbit;
8194             MSVCP_basic_string_char_append_ch(str, c);
8195         }
8196     }
8197     basic_istream_char_sentry_destroy(istream);
8198
8199     ios_base_width_set(&base->base, 0);
8200     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8201     return istream;
8202 }
8203
8204 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z */
8205 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z */
8206 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAC@Z */
8207 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAC@Z */
8208 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAE@Z */
8209 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAE@Z */
8210 basic_istream_char* __cdecl basic_istream_char_read_str(basic_istream_char *istream, char *str)
8211 {
8212     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
8213     IOSB_iostate state = IOSTATE_failbit;
8214     int c = '\n';
8215
8216     TRACE("(%p %p)\n", istream, str);
8217
8218     if(basic_istream_char_sentry_create(istream, FALSE)) {
8219         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
8220         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
8221
8222         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
8223                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8224                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
8225             state = IOSTATE_goodbit;
8226             *str++ = c;
8227         }
8228     }
8229     basic_istream_char_sentry_destroy(istream);
8230
8231     *str = 0;
8232     ios_base_width_set(&base->base, 0);
8233     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8234     return istream;
8235 }
8236
8237 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z */
8238 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAD@Z */
8239 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z */
8240 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAC@Z */
8241 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z */
8242 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAE@Z */
8243 basic_istream_char* __cdecl basic_istream_char_read_ch(basic_istream_char *istream, char *ch)
8244 {
8245     IOSB_iostate state = IOSTATE_failbit;
8246     int c = 0;
8247
8248     TRACE("(%p %p)\n", istream, ch);
8249
8250     if(basic_istream_char_sentry_create(istream, FALSE)) {
8251         c = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(
8252                     basic_istream_char_get_basic_ios(istream)));
8253         if(c != EOF) {
8254             state = IOSTATE_goodbit;
8255             *ch = c;
8256         }
8257     }
8258     basic_istream_char_sentry_destroy(istream);
8259
8260     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
8261             state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8262     return istream;
8263 }
8264
8265 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
8266 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
8267 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
8268 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
8269         basic_istream_char *this, basic_streambuf_char *streambuf)
8270 {
8271     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8272     IOSB_iostate state = IOSTATE_failbit;
8273     int c = '\n';
8274
8275     TRACE("(%p %p)\n", this, streambuf);
8276
8277     if(basic_istream_char_sentry_create(this, FALSE)) {
8278         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
8279                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
8280             state = IOSTATE_goodbit;
8281             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
8282                 break;
8283         }
8284     }
8285     basic_istream_char_sentry_destroy(this);
8286
8287     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8288     return this;
8289 }
8290
8291 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
8292 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
8293 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
8294 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
8295         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
8296 {
8297     TRACE("(%p %p)\n", this, pfunc);
8298     pfunc(this);
8299     return this;
8300 }
8301
8302 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
8303 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
8304 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
8305 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
8306         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
8307 {
8308     TRACE("(%p %p)\n", this, pfunc);
8309     pfunc(basic_istream_char_get_basic_ios(this));
8310     return this;
8311 }
8312
8313 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
8314 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
8315 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
8316 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
8317         ios_base* (__cdecl *pfunc)(ios_base*))
8318 {
8319     TRACE("(%p %p)\n", this, pfunc);
8320     pfunc(&basic_istream_char_get_basic_ios(this)->base);
8321     return this;
8322 }
8323
8324 /* Caution: basic_istream uses virtual inheritance. */
8325 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
8326 {
8327     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
8328 }
8329
8330 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
8331 {
8332     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
8333 }
8334
8335 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
8336 {
8337     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
8338 }
8339
8340 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
8341 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
8342 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_init, 20)
8343 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_init(basic_istream_wchar *this,
8344         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
8345 {
8346     basic_ios_wchar *base;
8347
8348     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
8349
8350     if(virt_init) {
8351         this->vbtable = basic_istream_wchar_vbtable;
8352         base = basic_istream_wchar_get_basic_ios(this);
8353         basic_ios_wchar_ctor(base);
8354     }else {
8355         base = basic_istream_wchar_get_basic_ios(this);
8356     }
8357
8358     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8359     this->count = 0;
8360     if(!noinit)
8361         basic_ios_wchar_init(base, strbuf, isstd);
8362     return this;
8363 }
8364
8365 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
8366 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
8367 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_init, 20)
8368 basic_istream_wchar* __thiscall basic_istream_short_ctor_init(basic_istream_wchar *this,
8369         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
8370 {
8371     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
8372     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8373     return this;
8374 }
8375
8376 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8377 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8378 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor, 16)
8379 basic_istream_wchar* __thiscall basic_istream_wchar_ctor(basic_istream_wchar *this,
8380         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8381 {
8382     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8383 }
8384
8385 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8386 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8387 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor, 16)
8388 basic_istream_wchar* __thiscall basic_istream_short_ctor(basic_istream_wchar *this,
8389         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8390 {
8391     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8392 }
8393
8394 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8395 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8396 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_uninitialized, 12)
8397 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_uninitialized(
8398         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8399 {
8400     basic_ios_wchar *base;
8401
8402     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
8403
8404     if(virt_init) {
8405         this->vbtable = basic_istream_wchar_vbtable;
8406         base = basic_istream_wchar_get_basic_ios(this);
8407         basic_ios_wchar_ctor(base);
8408     }else {
8409         base = basic_istream_wchar_get_basic_ios(this);
8410     }
8411
8412     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8413     ios_base_Addstd(&base->base);
8414     return this;
8415 }
8416
8417 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8418 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8419 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
8420 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
8421         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8422 {
8423     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
8424     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8425     return this;
8426 }
8427
8428 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
8429 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
8430 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
8431 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
8432 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
8433 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
8434 {
8435     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8436
8437     /* don't destroy virtual base here */
8438     TRACE("(%p)\n", this);
8439 }
8440
8441 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8442 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8443 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8444 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8445 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
8446 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
8447 {
8448     TRACE("(%p)\n", this);
8449     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
8450     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
8451 }
8452
8453 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
8454 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
8455 {
8456     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8457
8458     TRACE("(%p %x)\n", this, flags);
8459
8460     if(flags & 2) {
8461         /* we have an array, with the number of elements stored before the first object */
8462         INT_PTR i, *ptr = (INT_PTR *)this-1;
8463
8464         for(i=*ptr-1; i>=0; i--)
8465             basic_istream_wchar_vbase_dtor(this+i);
8466         MSVCRT_operator_delete(ptr);
8467     } else {
8468         basic_istream_wchar_vbase_dtor(this);
8469         if(flags & 1)
8470             MSVCRT_operator_delete(this);
8471     }
8472
8473     return this;
8474 }
8475
8476 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8477 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8478 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8479 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8480 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Ipfx, 8)
8481 MSVCP_bool __thiscall basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8482 {
8483     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8484
8485     TRACE("(%p %d)\n", this, noskip);
8486
8487     if(ios_base_good(&base->base)) {
8488         if(basic_ios_wchar_tie_get(base))
8489             basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
8490
8491         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
8492             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8493             const ctype_wchar *ctype = ctype_wchar_use_facet(base->strbuf->loc);
8494             int ch;
8495
8496             for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
8497                     ch = basic_streambuf_wchar_snextc(strbuf)) {
8498                 if(ch == WEOF) {
8499                     basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8500                     break;
8501                 }
8502
8503                 if(!ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
8504                     break;
8505             }
8506         }
8507     }
8508
8509     if(!ios_base_good(&base->base)) {
8510         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8511         return FALSE;
8512     }
8513     return TRUE;
8514 }
8515
8516 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8517 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8518 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8519 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8520 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
8521 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8522 {
8523     return basic_istream_wchar__Ipfx(this, noskip);
8524 }
8525
8526 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8527 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8528 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8529 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8530 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
8531 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
8532 {
8533     TRACE("(%p)\n", this);
8534 }
8535
8536 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
8537 {
8538     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8539
8540     if(basic_ios_wchar_rdbuf_get(base))
8541         basic_streambuf_wchar__Lock(base->strbuf);
8542
8543     return basic_istream_wchar_ipfx(istr, noskip);
8544 }
8545
8546 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
8547 {
8548     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8549
8550     if(basic_ios_wchar_rdbuf_get(base))
8551         basic_streambuf_wchar__Unlock(base->strbuf);
8552 }
8553
8554 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
8555 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
8556 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
8557 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
8558 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
8559 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
8560 {
8561     TRACE("(%p)\n", this);
8562     return this->count;
8563 }
8564
8565 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8566 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8567 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8568 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8569 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
8570 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
8571 {
8572     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8573     int ret;
8574
8575     TRACE("(%p)\n", this);
8576
8577     this->count = 0;
8578
8579     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
8580         basic_istream_wchar_sentry_destroy(this);
8581         return WEOF;
8582     }
8583
8584     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
8585     basic_istream_wchar_sentry_destroy(this);
8586     if(ret == WEOF)
8587         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
8588     else
8589         this->count++;
8590
8591     return ret;
8592 }
8593
8594 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
8595 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
8596 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
8597 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
8598 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
8599 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
8600 {
8601     unsigned short ret;
8602
8603     TRACE("(%p %p)\n", this, ch);
8604
8605     ret = basic_istream_wchar_get(this);
8606     if(ret != WEOF)
8607         *ch = (wchar_t)ret;
8608     return this;
8609 }
8610
8611 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8612 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8613 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8614 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8615 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 16)
8616 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8617 {
8618     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8619     unsigned short ch = delim;
8620
8621     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8622
8623     this->count = 0;
8624
8625     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8626         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8627
8628         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
8629                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8630             if(ch==WEOF || ch==delim)
8631                 break;
8632
8633             *str++ = ch;
8634             this->count++;
8635             count--;
8636         }
8637     }
8638     basic_istream_wchar_sentry_destroy(this);
8639
8640     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8641             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8642     if(count > 0)
8643         *str = 0;
8644     return this;
8645 }
8646
8647 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8648 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8649 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8650 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8651 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 12)
8652 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
8653 {
8654     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
8655 }
8656
8657 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8658 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8659 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8660 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8661 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
8662 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
8663 {
8664     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8665     unsigned short ch = delim;
8666
8667     TRACE("(%p %p %c)\n", this, strbuf, delim);
8668
8669     this->count = 0;
8670
8671     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8672         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
8673
8674         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
8675                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
8676             if(ch==WEOF || ch==delim)
8677                 break;
8678
8679             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
8680                 break;
8681             this->count++;
8682         }
8683     }
8684     basic_istream_wchar_sentry_destroy(this);
8685
8686     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8687             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8688     return this;
8689 }
8690
8691 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8692 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8693 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8694 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8695 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
8696 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
8697 {
8698     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
8699 }
8700
8701 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8702 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8703 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8704 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8705 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 16)
8706 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8707 {
8708     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8709     unsigned short ch = delim;
8710
8711     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8712
8713     this->count = 0;
8714
8715     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
8716         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8717
8718         while(count > 1) {
8719             ch = basic_streambuf_wchar_sbumpc(strbuf);
8720
8721             if(ch==WEOF || ch==delim)
8722                 break;
8723
8724             *str++ = ch;
8725             this->count++;
8726             count--;
8727         }
8728
8729         if(ch == delim)
8730             this->count++;
8731         else if(ch != WEOF) {
8732             ch = basic_streambuf_wchar_sgetc(strbuf);
8733
8734             if(ch == delim) {
8735                 basic_streambuf_wchar__Gninc(strbuf);
8736                 this->count++;
8737             }
8738         }
8739     }
8740     basic_istream_wchar_sentry_destroy(this);
8741
8742     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
8743             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
8744     if(count > 0)
8745         *str = 0;
8746     return this;
8747 }
8748
8749 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8750 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8751 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8752 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8753 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 12)
8754 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
8755 {
8756     return basic_istream_wchar_getline_delim(this, str, count, '\n');
8757 }
8758
8759 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
8760 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
8761 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
8762 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
8763 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 12)
8764 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
8765 {
8766     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8767     unsigned short ch = delim;
8768     unsigned int state;
8769
8770     TRACE("(%p %ld %d)\n", this, count, delim);
8771
8772     this->count = 0;
8773
8774     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8775         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8776         state = IOSTATE_goodbit;
8777
8778         while(count > 0) {
8779             ch = basic_streambuf_wchar_sbumpc(strbuf);
8780
8781             if(ch==WEOF) {
8782                 state = IOSTATE_eofbit;
8783                 break;
8784             }
8785
8786             if(ch==delim)
8787                 break;
8788
8789             this->count++;
8790             if(count != INT_MAX)
8791                 count--;
8792         }
8793     }else
8794         state = IOSTATE_failbit;
8795     basic_istream_wchar_sentry_destroy(this);
8796
8797     basic_ios_wchar_setstate(base, state);
8798     return this;
8799 }
8800
8801 /* ?ws@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
8802 /* ?ws@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
8803 /* ?ws@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@1@AAV21@@Z */
8804 /* ?ws@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
8805 basic_istream_wchar* __cdecl ws_basic_istream_wchar(basic_istream_wchar *istream)
8806 {
8807     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8808     unsigned short ch = '\n';
8809
8810     TRACE("(%p)\n", istream);
8811
8812     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8813         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8814         const ctype_wchar *ctype = ctype_wchar_use_facet(strbuf->loc);
8815
8816         for(ch = basic_streambuf_wchar_sgetc(strbuf); ctype_wchar_is_ch(ctype, _SPACE, ch);
8817                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8818             if(ch == WEOF)
8819                 break;
8820         }
8821     }
8822     basic_istream_wchar_sentry_destroy(istream);
8823
8824     if(ch == WEOF)
8825         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8826     return istream;
8827 }
8828
8829 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8830 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8831 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8832 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8833 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
8834 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
8835 {
8836     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8837     unsigned short ret = WEOF;
8838
8839     TRACE("(%p)\n", this);
8840
8841     this->count = 0;
8842
8843     if(basic_istream_wchar_sentry_create(this, TRUE))
8844         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8845     basic_istream_wchar_sentry_destroy(this);
8846
8847     if (ret == WEOF)
8848         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8849
8850     return ret;
8851 }
8852
8853 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
8854 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
8855 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
8856 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
8857 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Read_s, 16)
8858 basic_istream_wchar* __thiscall basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8859 {
8860     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8861     IOSB_iostate state = IOSTATE_goodbit;
8862
8863     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8864
8865     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8866         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8867
8868         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
8869         if(this->count != count)
8870             state |= IOSTATE_failbit | IOSTATE_eofbit;
8871     }else {
8872         this->count = 0;
8873     }
8874     basic_istream_wchar_sentry_destroy(this);
8875
8876     basic_ios_wchar_setstate(base, state);
8877     return this;
8878 }
8879
8880 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8881 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8882 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8883 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8884 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 12)
8885 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
8886 {
8887     return basic_istream_wchar__Read_s(this, str, count, count);
8888 }
8889
8890 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
8891 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
8892 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
8893 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
8894 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Readsome_s, 16)
8895 streamsize __thiscall basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8896 {
8897     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8898     IOSB_iostate state = IOSTATE_goodbit;
8899
8900     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8901
8902     this->count = 0;
8903
8904     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8905         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
8906         if(avail > count)
8907             avail = count;
8908
8909         if(avail == -1)
8910             state |= IOSTATE_eofbit;
8911         else if(avail > 0)
8912             basic_istream_wchar__Read_s(this, str, size, avail);
8913     }else {
8914         state |= IOSTATE_failbit;
8915     }
8916     basic_istream_wchar_sentry_destroy(this);
8917
8918     basic_ios_wchar_setstate(base, state);
8919     return this->count;
8920 }
8921
8922 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
8923 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
8924 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
8925 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
8926 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 12)
8927 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
8928 {
8929     return basic_istream_wchar__Readsome_s(this, str, count, count);
8930 }
8931
8932 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
8933 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
8934 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
8935 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
8936 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
8937 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
8938 {
8939     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8940     IOSB_iostate state = IOSTATE_goodbit;
8941
8942     TRACE("(%p %c)\n", this, ch);
8943
8944     this->count = 0;
8945
8946     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8947         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8948
8949         if(!ios_base_good(&base->base))
8950             state |= IOSTATE_failbit;
8951         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
8952             state |= IOSTATE_badbit;
8953     }
8954     basic_istream_wchar_sentry_destroy(this);
8955
8956     basic_ios_wchar_setstate(base, state);
8957     return this;
8958 }
8959
8960 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
8961 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
8962 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
8963 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
8964 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
8965 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
8966 {
8967     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8968     IOSB_iostate state = IOSTATE_goodbit;
8969
8970     TRACE("(%p)\n", this);
8971
8972     this->count = 0;
8973
8974     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8975         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8976
8977         if(!ios_base_good(&base->base))
8978             state |= IOSTATE_failbit;
8979         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
8980             state |= IOSTATE_badbit;
8981     }
8982     basic_istream_wchar_sentry_destroy(this);
8983
8984     basic_ios_wchar_setstate(base, state);
8985     return this;
8986 }
8987
8988 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
8989 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
8990 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
8991 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
8992 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
8993 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
8994 {
8995     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8996     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8997
8998     TRACE("(%p)\n", this);
8999
9000     if(!strbuf)
9001         return -1;
9002
9003     if(basic_istream_wchar_sentry_create(this, TRUE)) {
9004         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
9005             basic_istream_wchar_sentry_destroy(this);
9006             return 0;
9007         }
9008     }
9009     basic_istream_wchar_sentry_destroy(this);
9010
9011     basic_ios_wchar_setstate(base, IOSTATE_badbit);
9012     return -1;
9013 }
9014
9015 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
9016 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
9017 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
9018 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
9019 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
9020 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
9021 {
9022     TRACE("(%p %p)\n", this, ret);
9023
9024     if(basic_istream_wchar_sentry_create(this, TRUE)) {
9025         basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9026         if(!ios_base_fail(&base->base)) {
9027             basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
9028                     ret, 0, SEEKDIR_cur, OPENMODE_in);
9029             basic_istream_wchar_sentry_destroy(this);
9030
9031             if(ret->off==0 && ret->pos==-1 && ret->state==0)
9032                 basic_ios_wchar_setstate(base, IOSTATE_failbit);
9033             return ret;
9034         }
9035     }
9036     basic_istream_wchar_sentry_destroy(this);
9037
9038     ret->off = 0;
9039     ret->pos = -1;
9040     ret->state = 0;
9041     return ret;
9042 }
9043
9044 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
9045 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
9046 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
9047 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
9048 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 12)
9049 basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir)
9050 {
9051     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9052
9053     TRACE("(%p %ld %d)\n", this, off, dir);
9054
9055     if(!ios_base_fail(&base->base)) {
9056         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9057         fpos_int ret;
9058
9059         basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
9060         basic_istream_wchar_sentry_destroy(this);
9061
9062         if(ret.off==0 && ret.pos==-1 && ret.state==0)
9063             basic_ios_wchar_setstate(base, IOSTATE_failbit);
9064         else
9065             basic_ios_wchar_clear(base, IOSTATE_goodbit);
9066         return this;
9067     }else
9068         basic_ios_wchar_clear(base, IOSTATE_goodbit);
9069
9070     return this;
9071 }
9072
9073 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
9074 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
9075 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
9076 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
9077 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
9078 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
9079 {
9080     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9081
9082     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
9083
9084     if(!ios_base_fail(&base->base)) {
9085         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9086         fpos_int ret;
9087
9088         basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
9089         basic_istream_wchar_sentry_destroy(this);
9090
9091         if(ret.off==0 && ret.pos==-1 && ret.state==0)
9092             basic_ios_wchar_setstate(base, IOSTATE_failbit);
9093         else
9094             basic_ios_wchar_clear(base, IOSTATE_goodbit);
9095         return this;
9096     }else
9097         basic_ios_wchar_clear(base, IOSTATE_goodbit);
9098
9099     return this;
9100 }
9101
9102 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
9103 {
9104     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9105     int state = IOSTATE_goodbit;
9106
9107     TRACE("(%p %p)\n", this, v);
9108
9109     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9110         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9111         istreambuf_iterator_wchar first={0}, last={0};
9112         LONG tmp;
9113
9114         first.strbuf = strbuf;
9115         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
9116
9117         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
9118             *v = tmp;
9119         else
9120             state |= IOSTATE_failbit;
9121     }
9122     basic_istream_wchar_sentry_destroy(this);
9123
9124     basic_ios_wchar_setstate(base, state);
9125     return this;
9126 }
9127
9128 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAF@Z */
9129 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAF@Z */
9130 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_short, 8)
9131 basic_istream_wchar* __thiscall basic_istream_wchar_read_short(basic_istream_wchar *this, short *v)
9132 {
9133     return basic_istream_read_short(this, v, num_get_wchar_use_facet(
9134                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9135 }
9136
9137 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
9138 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
9139 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
9140 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
9141 {
9142     return basic_istream_read_short(this, v, num_get_short_use_facet(
9143                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9144 }
9145
9146 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAG@Z */
9147 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAG@Z */
9148 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ushort, 8)
9149 basic_istream_wchar* __thiscall basic_istream_wchar_read_ushort(basic_istream_wchar *this, unsigned short *v)
9150 {
9151     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9152     int state = IOSTATE_goodbit;
9153
9154     TRACE("(%p %p)\n", this, v);
9155
9156     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9157         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9158         const num_get *numget = num_get_wchar_use_facet(strbuf->loc);
9159         istreambuf_iterator_wchar first={0}, last={0};
9160
9161         first.strbuf = strbuf;
9162         num_get_wchar_get_ushort(numget, &last, first, last, &base->base, &state, v);
9163     }
9164     basic_istream_wchar_sentry_destroy(this);
9165
9166     basic_ios_wchar_setstate(base, state);
9167     return this;
9168 }
9169
9170 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
9171 {
9172     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9173     int state = IOSTATE_goodbit;
9174
9175     TRACE("(%p %p)\n", this, v);
9176
9177     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9178         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9179         istreambuf_iterator_wchar first={0}, last={0};
9180
9181         first.strbuf = strbuf;
9182         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
9183     }
9184     basic_istream_wchar_sentry_destroy(this);
9185
9186     basic_ios_wchar_setstate(base, state);
9187     return this;
9188 }
9189
9190 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAH@Z */
9191 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAH@Z */
9192 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int, 8)
9193 basic_istream_wchar* __thiscall basic_istream_wchar_read_int(basic_istream_wchar *this, int *v)
9194 {
9195     return basic_istream_read_int(this, v, num_get_wchar_use_facet(
9196                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9197 }
9198
9199 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
9200 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
9201 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
9202 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
9203 {
9204     return basic_istream_read_int(this, v, num_get_short_use_facet(
9205                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9206 }
9207
9208 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
9209 {
9210     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9211     int state = IOSTATE_goodbit;
9212
9213     TRACE("(%p %p)\n", this, v);
9214
9215     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9216         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9217         istreambuf_iterator_wchar first={0}, last={0};
9218
9219         first.strbuf = strbuf;
9220         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
9221     }
9222     basic_istream_wchar_sentry_destroy(this);
9223
9224     basic_ios_wchar_setstate(base, state);
9225     return this;
9226 }
9227
9228 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAI@Z */
9229 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAI@Z */
9230 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint, 8)
9231 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint(basic_istream_wchar *this, unsigned int *v)
9232 {
9233     return basic_istream_read_uint(this, v, num_get_wchar_use_facet(
9234                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9235 }
9236
9237 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
9238 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
9239 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
9240 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
9241 {
9242     return basic_istream_read_uint(this, v, num_get_short_use_facet(
9243                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9244 }
9245
9246 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
9247 {
9248     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9249     int state = IOSTATE_goodbit;
9250
9251     TRACE("(%p %p)\n", this, v);
9252
9253     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9254         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9255         istreambuf_iterator_wchar first={0}, last={0};
9256
9257         first.strbuf = strbuf;
9258         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
9259     }
9260     basic_istream_wchar_sentry_destroy(this);
9261
9262     basic_ios_wchar_setstate(base, state);
9263     return this;
9264 }
9265
9266 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
9267 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
9268 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_long, 8)
9269 basic_istream_wchar* __thiscall basic_istream_wchar_read_long(basic_istream_wchar *this, LONG *v)
9270 {
9271     return basic_istream_read_long(this, v, num_get_wchar_use_facet(
9272                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9273 }
9274
9275 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
9276 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
9277 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
9278 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
9279 {
9280     return basic_istream_read_long(this, v, num_get_short_use_facet(
9281                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9282 }
9283
9284 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
9285 {
9286     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9287     int state = IOSTATE_goodbit;
9288
9289     TRACE("(%p %p)\n", this, v);
9290
9291     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9292         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9293         istreambuf_iterator_wchar first={0}, last={0};
9294
9295         first.strbuf = strbuf;
9296         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
9297     }
9298     basic_istream_wchar_sentry_destroy(this);
9299
9300     basic_ios_wchar_setstate(base, state);
9301     return this;
9302 }
9303
9304 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAK@Z */
9305 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAK@Z */
9306 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ulong, 8)
9307 basic_istream_wchar* __thiscall basic_istream_wchar_read_ulong(basic_istream_wchar *this, ULONG *v)
9308 {
9309     return basic_istream_read_ulong(this, v, num_get_wchar_use_facet(
9310                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9311 }
9312
9313 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
9314 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
9315 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
9316 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
9317 {
9318     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
9319                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9320 }
9321
9322 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
9323 {
9324     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9325     int state = IOSTATE_goodbit;
9326
9327     TRACE("(%p %p)\n", this, v);
9328
9329     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9330         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9331         istreambuf_iterator_wchar first={0}, last={0};
9332
9333         first.strbuf = strbuf;
9334         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
9335     }
9336     basic_istream_wchar_sentry_destroy(this);
9337
9338     basic_ios_wchar_setstate(base, state);
9339     return this;
9340 }
9341
9342 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAM@Z */
9343 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAM@Z */
9344 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_float, 8)
9345 basic_istream_wchar* __thiscall basic_istream_wchar_read_float(basic_istream_wchar *this, float *v)
9346 {
9347     return basic_istream_read_float(this, v, num_get_wchar_use_facet(
9348                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9349 }
9350
9351 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
9352 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
9353 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
9354 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
9355 {
9356     return basic_istream_read_float(this, v, num_get_short_use_facet(
9357                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9358 }
9359
9360 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
9361 {
9362     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9363     int state = IOSTATE_goodbit;
9364
9365     TRACE("(%p %p)\n", this, v);
9366
9367     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9368         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9369         istreambuf_iterator_wchar first={0}, last={0};
9370
9371         first.strbuf = strbuf;
9372         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
9373     }
9374     basic_istream_wchar_sentry_destroy(this);
9375
9376     basic_ios_wchar_setstate(base, state);
9377     return this;
9378 }
9379
9380 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAN@Z */
9381 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAN@Z */
9382 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_double, 8)
9383 basic_istream_wchar* __thiscall basic_istream_wchar_read_double(basic_istream_wchar *this, double *v)
9384 {
9385     return basic_istream_read_double(this, v, num_get_wchar_use_facet(
9386                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9387 }
9388
9389 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
9390 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
9391 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
9392 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
9393 {
9394     return basic_istream_read_double(this, v, num_get_short_use_facet(
9395                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9396 }
9397
9398 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
9399 {
9400     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9401     int state = IOSTATE_goodbit;
9402
9403     TRACE("(%p %p)\n", this, v);
9404
9405     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9406         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9407         istreambuf_iterator_wchar first={0}, last={0};
9408
9409         first.strbuf = strbuf;
9410         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
9411     }
9412     basic_istream_wchar_sentry_destroy(this);
9413
9414     basic_ios_wchar_setstate(base, state);
9415     return this;
9416 }
9417
9418 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAO@Z */
9419 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAO@Z */
9420 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ldouble, 8)
9421 basic_istream_wchar* __thiscall basic_istream_wchar_read_ldouble(basic_istream_wchar *this, double *v)
9422 {
9423     return basic_istream_read_ldouble(this, v, num_get_wchar_use_facet(
9424                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9425 }
9426
9427 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
9428 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
9429 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
9430 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
9431 {
9432     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
9433                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9434 }
9435
9436 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
9437 {
9438     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9439     int state = IOSTATE_goodbit;
9440
9441     TRACE("(%p %p)\n", this, v);
9442
9443     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9444         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9445         istreambuf_iterator_wchar first={0}, last={0};
9446
9447         first.strbuf = strbuf;
9448         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
9449     }
9450     basic_istream_wchar_sentry_destroy(this);
9451
9452     basic_ios_wchar_setstate(base, state);
9453     return this;
9454 }
9455
9456 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAPAX@Z */
9457 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
9458 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ptr, 8)
9459 basic_istream_wchar* __thiscall basic_istream_wchar_read_ptr(basic_istream_wchar *this, void **v)
9460 {
9461     return basic_istream_read_ptr(this, v, num_get_wchar_use_facet(
9462                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9463 }
9464
9465 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
9466 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
9467 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
9468 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
9469 {
9470     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
9471                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9472 }
9473
9474 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
9475 {
9476     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9477     int state = IOSTATE_goodbit;
9478
9479     TRACE("(%p %p)\n", this, v);
9480
9481     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9482         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9483         istreambuf_iterator_wchar first={0}, last={0};
9484
9485         first.strbuf = strbuf;
9486         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
9487     }
9488     basic_istream_wchar_sentry_destroy(this);
9489
9490     basic_ios_wchar_setstate(base, state);
9491     return this;
9492 }
9493
9494 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_J@Z */
9495 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_J@Z */
9496 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int64, 8)
9497 basic_istream_wchar* __thiscall basic_istream_wchar_read_int64(basic_istream_wchar *this, __int64 *v)
9498 {
9499     return basic_istream_read_int64(this, v, num_get_wchar_use_facet(
9500                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9501 }
9502
9503 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
9504 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
9505 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
9506 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
9507 {
9508     return basic_istream_read_int64(this, v, num_get_short_use_facet(
9509                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9510 }
9511
9512 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
9513 {
9514     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9515     int state = IOSTATE_goodbit;
9516
9517     TRACE("(%p %p)\n", this, v);
9518
9519     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9520         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9521         istreambuf_iterator_wchar first={0}, last={0};
9522
9523         first.strbuf = strbuf;
9524         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
9525     }
9526     basic_istream_wchar_sentry_destroy(this);
9527
9528     basic_ios_wchar_setstate(base, state);
9529     return this;
9530 }
9531
9532 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_K@Z */
9533 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_K@Z */
9534 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint64, 8)
9535 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9536 {
9537     return basic_istream_read_uint64(this, v, num_get_wchar_use_facet(
9538                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9539 }
9540
9541 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
9542 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
9543 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
9544 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9545 {
9546     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
9547                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9548 }
9549
9550 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
9551 {
9552     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9553     int state = IOSTATE_goodbit;
9554
9555     TRACE("(%p %p)\n", this, v);
9556
9557     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9558         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9559         istreambuf_iterator_wchar first={0}, last={0};
9560
9561         first.strbuf = strbuf;
9562         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
9563     }
9564     basic_istream_wchar_sentry_destroy(this);
9565
9566     basic_ios_wchar_setstate(base, state);
9567     return this;
9568 }
9569
9570 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_N@Z */
9571 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_N@Z */
9572 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_bool, 8)
9573 basic_istream_wchar* __thiscall basic_istream_wchar_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9574 {
9575     return basic_istream_read_bool(this, v, num_get_wchar_use_facet(
9576                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9577 }
9578
9579 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
9580 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
9581 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
9582 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9583 {
9584     return basic_istream_read_bool(this, v, num_get_short_use_facet(
9585                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9586 }
9587
9588 /* ??$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 */
9589 /* ??$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 */
9590 /* ??$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 */
9591 /* ??$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 */
9592 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr_delim(
9593         basic_istream_wchar *istream, basic_string_wchar *str, wchar_t delim)
9594 {
9595     IOSB_iostate state = IOSTATE_failbit;
9596     int c = delim;
9597
9598     TRACE("(%p %p %c)\n", istream, str, delim);
9599
9600     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
9601         MSVCP_basic_string_wchar_clear(str);
9602
9603         c = basic_istream_wchar_get(istream);
9604         if(c != WEOF)
9605             state = IOSTATE_goodbit;
9606
9607         for(; c!=delim && c!=WEOF; c = basic_istream_wchar_get(istream)) {
9608             state = IOSTATE_goodbit;
9609             MSVCP_basic_string_wchar_append_ch(str, c);
9610         }
9611     }
9612     basic_istream_wchar_sentry_destroy(istream);
9613
9614     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9615             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9616     return istream;
9617 }
9618
9619 /* ??$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 */
9620 /* ??$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 */
9621 /* ??$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 */
9622 /* ??$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 */
9623 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr(
9624         basic_istream_wchar *istream, basic_string_wchar *str)
9625 {
9626     return basic_istream_wchar_getline_bstr_delim(istream, str, '\n');
9627 }
9628
9629 static basic_istream_wchar* basic_istream_read_bstr(basic_istream_wchar *istream,
9630         basic_string_wchar *str, const ctype_wchar *ctype)
9631 {
9632     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9633     IOSB_iostate state = IOSTATE_failbit;
9634     int c = '\n';
9635
9636     TRACE("(%p %p)\n", istream, str);
9637
9638     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9639         MSVCP_size_t count = ios_base_width_get(&base->base);
9640
9641         if(!count)
9642             count = -1;
9643
9644         MSVCP_basic_string_wchar_clear(str);
9645
9646         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9647                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9648                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9649             state = IOSTATE_goodbit;
9650             MSVCP_basic_string_wchar_append_ch(str, c);
9651         }
9652     }
9653     basic_istream_wchar_sentry_destroy(istream);
9654
9655     ios_base_width_set(&base->base, 0);
9656     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9657     return istream;
9658 }
9659
9660 /* ??$?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 */
9661 /* ??$?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 */
9662 basic_istream_wchar* __cdecl basic_istream_wchar_read_bstr(
9663         basic_istream_wchar *istream, basic_string_wchar *str)
9664 {
9665     return basic_istream_read_bstr(istream, str, ctype_wchar_use_facet(
9666                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9667 }
9668
9669 /* ??$?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 */
9670 /* ??$?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 */
9671 basic_istream_wchar* __cdecl basic_istream_short_read_bstr(
9672         basic_istream_wchar *istream, basic_string_wchar *str)
9673 {
9674     return basic_istream_read_bstr(istream, str, ctype_short_use_facet(
9675                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9676 }
9677
9678 static basic_istream_wchar* basic_istream_read_str(basic_istream_wchar *istream, wchar_t *str, const ctype_wchar *ctype)
9679 {
9680     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9681     IOSB_iostate state = IOSTATE_failbit;
9682     unsigned short c = '\n';
9683
9684     TRACE("(%p %p)\n", istream, str);
9685
9686     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9687         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
9688
9689         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9690                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9691                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9692             state = IOSTATE_goodbit;
9693             *str++ = c;
9694         }
9695     }
9696     basic_istream_wchar_sentry_destroy(istream);
9697
9698     *str = 0;
9699     ios_base_width_set(&base->base, 0);
9700     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9701     return istream;
9702 }
9703
9704 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@PA_W@Z */
9705 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@PEA_W@Z */
9706 basic_istream_wchar* __cdecl basic_istream_wchar_read_str(basic_istream_wchar *istream, wchar_t *str)
9707 {
9708     return basic_istream_read_str(istream, str, ctype_wchar_use_facet(
9709                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9710 }
9711
9712 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@PAG@Z */
9713 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@PEAG@Z */
9714 basic_istream_wchar* __cdecl basic_istream_short_read_str(basic_istream_wchar *istream, wchar_t *str)
9715 {
9716     return basic_istream_read_str(istream, str, ctype_short_use_facet(
9717                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9718 }
9719
9720 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AA_W@Z */
9721 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEA_W@Z */
9722 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAG@Z */
9723 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAG@Z */
9724 basic_istream_wchar* __cdecl basic_istream_wchar_read_ch(basic_istream_wchar *istream, wchar_t *ch)
9725 {
9726     IOSB_iostate state = IOSTATE_failbit;
9727     unsigned short c = 0;
9728
9729     TRACE("(%p %p)\n", istream, ch);
9730
9731     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9732         c = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(
9733                     basic_istream_wchar_get_basic_ios(istream)));
9734         if(c != WEOF) {
9735             state = IOSTATE_goodbit;
9736             *ch = c;
9737         }
9738     }
9739     basic_istream_wchar_sentry_destroy(istream);
9740
9741     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9742             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9743     return istream;
9744 }
9745
9746 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9747 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9748 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9749 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9750 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
9751 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
9752         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
9753 {
9754     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9755     IOSB_iostate state = IOSTATE_failbit;
9756     unsigned short c = '\n';
9757
9758     TRACE("(%p %p)\n", this, streambuf);
9759
9760     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9761         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
9762                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
9763             state = IOSTATE_goodbit;
9764             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
9765                 break;
9766         }
9767     }
9768     basic_istream_wchar_sentry_destroy(this);
9769
9770     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9771     return this;
9772 }
9773
9774 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9775 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9776 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9777 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9778 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
9779 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
9780         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
9781 {
9782     TRACE("(%p %p)\n", this, pfunc);
9783     pfunc(this);
9784     return this;
9785 }
9786
9787 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
9788 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
9789 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
9790 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
9791 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
9792 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
9793         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
9794 {
9795     TRACE("(%p %p)\n", this, pfunc);
9796     pfunc(basic_istream_wchar_get_basic_ios(this));
9797     return this;
9798 }
9799
9800 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9801 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9802 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9803 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9804 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
9805 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
9806         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
9807 {
9808     TRACE("(%p %p)\n", this, pfunc);
9809     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
9810     return this;
9811 }
9812
9813 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
9814 {
9815     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
9816 }
9817
9818 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
9819 {
9820     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
9821 }
9822
9823 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9824 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9825 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
9826 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
9827 {
9828     basic_ios_char *basic_ios;
9829
9830     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9831
9832     if(virt_init) {
9833         this->base1.vbtable = basic_iostream_char_vbtable1;
9834         this->base2.vbtable = basic_iostream_char_vbtable2;
9835         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9836         basic_ios_char_ctor(basic_ios);
9837     }else {
9838         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9839     }
9840
9841     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
9842
9843     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
9844     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9845     return this;
9846 }
9847
9848 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9849 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9850 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
9851 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
9852 {
9853     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9854
9855     TRACE("(%p)\n", this);
9856     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
9857     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
9858 }
9859
9860 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9861 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9862 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
9863 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
9864 {
9865     TRACE("(%p)\n", this);
9866     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
9867     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
9868 }
9869
9870 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
9871 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9872 {
9873     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9874
9875     TRACE("(%p %x)\n", this, flags);
9876
9877     if(flags & 2) {
9878         /* we have an array, with the number of elements stored before the first object */
9879         INT_PTR i, *ptr = (INT_PTR *)this-1;
9880
9881         for(i=*ptr-1; i>=0; i--)
9882             basic_iostream_char_vbase_dtor(this+i);
9883         MSVCRT_operator_delete(ptr);
9884     } else {
9885         basic_iostream_char_vbase_dtor(this);
9886         if(flags & 1)
9887             MSVCRT_operator_delete(this);
9888     }
9889
9890     return this;
9891 }
9892
9893 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
9894 {
9895     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
9896 }
9897
9898 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9899 {
9900     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
9901 }
9902
9903 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9904 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9905 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_ctor, 12)
9906 basic_iostream_wchar* __thiscall basic_iostream_wchar_ctor(basic_iostream_wchar *this,
9907         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9908 {
9909     basic_ios_wchar *basic_ios;
9910
9911     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9912
9913     if(virt_init) {
9914         this->base1.vbtable = basic_iostream_wchar_vbtable1;
9915         this->base2.vbtable = basic_iostream_wchar_vbtable2;
9916         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9917         basic_ios_wchar_ctor(basic_ios);
9918     }else {
9919         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9920     }
9921
9922     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
9923     basic_ostream_wchar_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9924
9925     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
9926     return this;
9927 }
9928
9929 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9930 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9931 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
9932 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
9933         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9934 {
9935     basic_iostream_wchar_ctor(this, strbuf, virt_init);
9936     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
9937     return this;
9938 }
9939
9940 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9941 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9942 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9943 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9944 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
9945 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
9946 {
9947     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9948
9949     TRACE("(%p)\n", this);
9950     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
9951     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
9952 }
9953
9954 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9955 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9956 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9957 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9958 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
9959 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
9960 {
9961     TRACE("(%p)\n", this);
9962     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
9963     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
9964 }
9965
9966 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
9967 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9968 {
9969     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9970
9971     TRACE("(%p %x)\n", this, flags);
9972
9973     if(flags & 2) {
9974         /* we have an array, with the number of elements stored before the first object */
9975         INT_PTR i, *ptr = (INT_PTR *)this-1;
9976
9977         for(i=*ptr-1; i>=0; i--)
9978             basic_iostream_wchar_vbase_dtor(this+i);
9979         MSVCRT_operator_delete(ptr);
9980     } else {
9981         basic_iostream_wchar_vbase_dtor(this);
9982         if(flags & 1)
9983             MSVCRT_operator_delete(this);
9984     }
9985
9986     return this;
9987 }
9988
9989 static inline basic_ios_char* basic_ofstream_char_to_basic_ios(basic_ofstream_char *ptr)
9990 {
9991     return (basic_ios_char*)((char*)ptr+basic_ofstream_char_vbtable[1]);
9992 }
9993
9994 static inline basic_ofstream_char* basic_ofstream_char_from_basic_ios(basic_ios_char *ptr)
9995 {
9996     return (basic_ofstream_char*)((char*)ptr-basic_ofstream_char_vbtable[1]);
9997 }
9998
9999 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10000 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10001 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
10002 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
10003 {
10004     basic_ios_char *basic_ios;
10005
10006     TRACE("(%p %d)\n", this, virt_init);
10007
10008     if(virt_init) {
10009         this->base.vbtable = basic_ofstream_char_vbtable;
10010         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10011         basic_ios_char_ctor(basic_ios);
10012     }else {
10013         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10014     }
10015
10016     basic_filebuf_char_ctor(&this->filebuf);
10017     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10018     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
10019     return this;
10020 }
10021
10022 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10023 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10024 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_file, 12)
10025 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_file(
10026         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
10027 {
10028     basic_ios_char *basic_ios;
10029
10030     TRACE("(%p %p %d)\n", this, file, virt_init);
10031
10032     if(virt_init) {
10033         this->base.vbtable = basic_ofstream_char_vbtable;
10034         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10035         basic_ios_char_ctor(basic_ios);
10036     }else {
10037         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10038     }
10039
10040     basic_filebuf_char_ctor_file(&this->filebuf, file);
10041     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10042     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
10043     return this;
10044 }
10045
10046 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
10047 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
10048 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 20)
10049 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
10050         const char *name, int mode, int prot, MSVCP_bool virt_init)
10051 {
10052     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10053
10054     basic_ofstream_char_ctor(this, virt_init);
10055
10056     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10057         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10058         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10059     }
10060     return this;
10061 }
10062
10063 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
10064 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
10065 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
10066 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
10067 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name_wchar, 20)
10068 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name_wchar(basic_ofstream_char *this,
10069         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10070 {
10071     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10072
10073     basic_ofstream_char_ctor(this, virt_init);
10074
10075     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10076         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10077         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10078     }
10079     return this;
10080 }
10081
10082 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10083 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10084 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
10085 void __thiscall basic_ofstream_char_dtor(basic_ios_char *base)
10086 {
10087     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
10088
10089     TRACE("(%p)\n", this);
10090
10091     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
10092     basic_filebuf_char_dtor(&this->filebuf);
10093 }
10094
10095 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10096 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10097 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
10098 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
10099 {
10100     TRACE("(%p)\n", this);
10101
10102     basic_ofstream_char_dtor(basic_ofstream_char_to_basic_ios(this));
10103     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
10104 }
10105
10106 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vector_dtor, 8)
10107 basic_ofstream_char* __thiscall basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10108 {
10109     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
10110
10111     TRACE("(%p %x)\n", this, flags);
10112
10113     if(flags & 2) {
10114         /* we have an array, with the number of elements stored before the first object */
10115         INT_PTR i, *ptr = (INT_PTR *)this-1;
10116
10117         for(i=*ptr-1; i>=0; i--)
10118             basic_ofstream_char_vbase_dtor(this+i);
10119         MSVCRT_operator_delete(ptr);
10120     } else {
10121         basic_ofstream_char_vbase_dtor(this);
10122         if(flags & 1)
10123             MSVCRT_operator_delete(this);
10124     }
10125
10126     return this;
10127 }
10128
10129 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10130 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10131 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
10132 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
10133 {
10134     TRACE("(%p)\n", this);
10135
10136     if(!basic_filebuf_char_close(&this->filebuf)) {
10137         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10138         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10139     }
10140 }
10141
10142 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10143 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10144 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
10145 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
10146 {
10147     TRACE("(%p)\n", this);
10148     return basic_filebuf_char_is_open(&this->filebuf);
10149 }
10150
10151 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
10152 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
10153 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 16)
10154 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
10155         const char *name, int mode, int prot)
10156 {
10157     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10158
10159     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10160         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10161         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10162     }
10163 }
10164
10165 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
10166 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
10167 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
10168 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
10169         const char *name, unsigned int mode)
10170 {
10171     basic_ofstream_char_open(this, name, mode, _SH_DENYNO);
10172 }
10173
10174 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
10175 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
10176 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
10177 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
10178 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar, 16)
10179 void __thiscall basic_ofstream_char_open_wchar(basic_ofstream_char *this,
10180         const wchar_t *name, int mode, int prot)
10181 {
10182     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10183
10184     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10185         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10186         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10187     }
10188 }
10189
10190 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
10191 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
10192 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
10193 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
10194 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar_old, 12)
10195 void __thiscall basic_ofstream_char_open_wchar_old(basic_ofstream_char *this,
10196         const wchar_t *name, unsigned int mode)
10197 {
10198     basic_ofstream_char_open_wchar(this, name, mode, _SH_DENYNO);
10199 }
10200
10201 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10202 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10203 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
10204 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
10205 {
10206     TRACE("(%p)\n", this);
10207     return (basic_filebuf_char*)&this->filebuf;
10208 }
10209
10210 static inline basic_ios_wchar* basic_ofstream_wchar_to_basic_ios(basic_ofstream_wchar *ptr)
10211 {
10212     return (basic_ios_wchar*)((char*)ptr+basic_ofstream_wchar_vbtable[1]);
10213 }
10214
10215 static inline basic_ofstream_wchar* basic_ofstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10216 {
10217     return (basic_ofstream_wchar*)((char*)ptr-basic_ofstream_wchar_vbtable[1]);
10218 }
10219
10220 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10221 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10222 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor, 8)
10223 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
10224 {
10225     basic_ios_wchar *basic_ios;
10226
10227     TRACE("(%p %d)\n", this, virt_init);
10228
10229     if(virt_init) {
10230         this->base.vbtable = basic_ofstream_wchar_vbtable;
10231         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10232         basic_ios_wchar_ctor(basic_ios);
10233     }else {
10234         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10235     }
10236
10237     basic_filebuf_wchar_ctor(&this->filebuf);
10238     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10239     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
10240     return this;
10241 }
10242
10243 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10244 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10245 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor, 8)
10246 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
10247 {
10248     basic_ofstream_wchar_ctor(this, virt_init);
10249     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10250     return this;
10251 }
10252
10253 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10254 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10255 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_file, 12)
10256 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_file(
10257         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10258 {
10259     basic_ios_wchar *basic_ios;
10260
10261     TRACE("(%p %p %d)\n", this, file, virt_init);
10262
10263     if(virt_init) {
10264         this->base.vbtable = basic_ofstream_wchar_vbtable;
10265         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10266         basic_ios_wchar_ctor(basic_ios);
10267     }else {
10268         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10269     }
10270
10271     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10272     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10273     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
10274     return this;
10275 }
10276
10277 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10278 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10279 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_file, 12)
10280 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_file(
10281         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10282 {
10283     basic_ofstream_wchar_ctor_file(this, file, virt_init);
10284     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10285     return this;
10286 }
10287
10288 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z */
10289 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z */
10290 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_name, 20)
10291 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_name(basic_ofstream_wchar *this,
10292         const char *name, int mode, int prot, MSVCP_bool virt_init)
10293 {
10294     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10295
10296     basic_ofstream_wchar_ctor(this, virt_init);
10297
10298     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10299         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10300         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10301     }
10302     return this;
10303 }
10304
10305 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBDHH@Z */
10306 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDHH@Z */
10307 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name, 20)
10308 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name(basic_ofstream_wchar *this,
10309         const char *name, int mode, int prot, MSVCP_bool virt_init)
10310 {
10311     basic_ofstream_wchar_ctor_name(this, name, mode, prot, virt_init);
10312     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10313     return this;
10314 }
10315
10316 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PBGHH@Z */
10317 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBGHH@Z */
10318 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10319 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10320 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_name_wchar, 20)
10321 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_name_wchar(basic_ofstream_wchar *this,
10322         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10323 {
10324     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10325
10326     basic_ofstream_wchar_ctor(this, virt_init);
10327
10328     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10329         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10330         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10331     }
10332     return this;
10333 }
10334
10335 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
10336 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
10337 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PB_WHH@Z */
10338 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEB_WHH@Z */
10339 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name_wchar, 20)
10340 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name_wchar(basic_ofstream_wchar *this,
10341         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10342 {
10343     basic_ofstream_wchar_ctor_name_wchar(this, name, mode, prot, virt_init);
10344     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10345     return this;
10346 }
10347
10348 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10349 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10350 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10351 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10352 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_dtor, 4)
10353 void __thiscall basic_ofstream_wchar_dtor(basic_ios_wchar *base)
10354 {
10355     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
10356
10357     TRACE("(%p)\n", this);
10358
10359     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
10360     basic_filebuf_wchar_dtor(&this->filebuf);
10361 }
10362
10363 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10364 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10365 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10366 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10367 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vbase_dtor, 4)
10368 void __thiscall basic_ofstream_wchar_vbase_dtor(basic_ofstream_wchar *this)
10369 {
10370     TRACE("(%p)\n", this);
10371
10372     basic_ofstream_wchar_dtor(basic_ofstream_wchar_to_basic_ios(this));
10373     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
10374 }
10375
10376 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vector_dtor, 8)
10377 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10378 {
10379     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
10380
10381     TRACE("(%p %x)\n", this, flags);
10382
10383     if(flags & 2) {
10384         /* we have an array, with the number of elements stored before the first object */
10385         INT_PTR i, *ptr = (INT_PTR *)this-1;
10386
10387         for(i=*ptr-1; i>=0; i--)
10388             basic_ofstream_wchar_vbase_dtor(this+i);
10389         MSVCRT_operator_delete(ptr);
10390     } else {
10391         basic_ofstream_wchar_vbase_dtor(this);
10392         if(flags & 1)
10393             MSVCRT_operator_delete(this);
10394     }
10395
10396     return this;
10397 }
10398
10399 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10400 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10401 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10402 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10403 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_close, 4)
10404 void __thiscall basic_ofstream_wchar_close(basic_ofstream_wchar *this)
10405 {
10406     TRACE("(%p)\n", this);
10407
10408     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10409         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10410         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10411     }
10412 }
10413
10414 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10415 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10416 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10417 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10418 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_is_open, 4)
10419 MSVCP_bool __thiscall basic_ofstream_wchar_is_open(const basic_ofstream_wchar *this)
10420 {
10421     TRACE("(%p)\n", this);
10422     return basic_filebuf_wchar_is_open(&this->filebuf);
10423 }
10424
10425 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
10426 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
10427 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
10428 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
10429 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open, 16)
10430 void __thiscall basic_ofstream_wchar_open(basic_ofstream_wchar *this,
10431         const char *name, int mode, int prot)
10432 {
10433     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10434
10435     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10436         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10437         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10438     }
10439 }
10440
10441 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
10442 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
10443 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
10444 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
10445 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_old, 12)
10446 void __thiscall basic_ofstream_wchar_open_old(basic_ofstream_wchar *this,
10447         const char *name, unsigned int mode)
10448 {
10449     basic_ofstream_wchar_open(this, name, mode, _SH_DENYNO);
10450 }
10451
10452 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGHH@Z */
10453 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGHH@Z */
10454 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WHH@Z */
10455 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WHH@Z */
10456 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBGHH@Z */
10457 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGHH@Z */
10458 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPB_WHH@Z */
10459 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WHH@Z */
10460 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_wchar, 16)
10461 void __thiscall basic_ofstream_wchar_open_wchar(basic_ofstream_wchar *this,
10462         const wchar_t *name, int mode, int prot)
10463 {
10464     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10465
10466     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10467         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10468         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10469     }
10470 }
10471
10472 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGI@Z */
10473 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGI@Z */
10474 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WI@Z */
10475 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WI@Z */
10476 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBGI@Z */
10477 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGI@Z */
10478 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPB_WI@Z */
10479 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WI@Z */
10480 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_wchar_old, 12)
10481 void __thiscall basic_ofstream_wchar_open_wchar_old(basic_ofstream_wchar *this,
10482         const wchar_t *name, unsigned int mode)
10483 {
10484     basic_ofstream_wchar_open_wchar(this, name, mode, _SH_DENYNO);
10485 }
10486
10487 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10488 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10489 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10490 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10491 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_rdbuf, 4)
10492 basic_filebuf_wchar* __thiscall basic_ofstream_wchar_rdbuf(const basic_ofstream_wchar *this)
10493 {
10494     TRACE("(%p)\n", this);
10495     return (basic_filebuf_wchar*)&this->filebuf;
10496 }
10497
10498 static inline basic_ios_char* basic_ifstream_char_to_basic_ios(basic_ifstream_char *ptr)
10499 {
10500     return (basic_ios_char*)((char*)ptr+basic_ifstream_char_vbtable[1]);
10501 }
10502
10503 static inline basic_ifstream_char* basic_ifstream_char_from_basic_ios(basic_ios_char *ptr)
10504 {
10505     return (basic_ifstream_char*)((char*)ptr-basic_ifstream_char_vbtable[1]);
10506 }
10507
10508 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10509 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10510 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
10511 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
10512 {
10513     basic_ios_char *basic_ios;
10514
10515     TRACE("(%p %d)\n", this, virt_init);
10516
10517     if(virt_init) {
10518         this->base.vbtable = basic_ifstream_char_vbtable;
10519         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10520         basic_ios_char_ctor(basic_ios);
10521     }else {
10522         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10523     }
10524
10525     basic_filebuf_char_ctor(&this->filebuf);
10526     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10527     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
10528     return this;
10529 }
10530
10531 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10532 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10533 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_file, 12)
10534 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_file(
10535         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
10536 {
10537     basic_ios_char *basic_ios;
10538
10539     TRACE("(%p %p %d)\n", this, file, virt_init);
10540
10541     if(virt_init) {
10542         this->base.vbtable = basic_ifstream_char_vbtable;
10543         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10544         basic_ios_char_ctor(basic_ios);
10545     }else {
10546         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10547     }
10548
10549     basic_filebuf_char_ctor_file(&this->filebuf, file);
10550     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10551     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
10552     return this;
10553 }
10554
10555 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
10556 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
10557 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 20)
10558 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
10559         const char *name, int mode, int prot, MSVCP_bool virt_init)
10560 {
10561     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10562
10563     basic_ifstream_char_ctor(this, virt_init);
10564
10565     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10566         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10567         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10568     }
10569     return this;
10570 }
10571
10572 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
10573 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
10574 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
10575 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
10576 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name_wchar, 20)
10577 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name_wchar(basic_ifstream_char *this,
10578         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10579 {
10580     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10581
10582     basic_ifstream_char_ctor(this, virt_init);
10583
10584     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10585         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10586         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10587     }
10588     return this;
10589 }
10590
10591 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10592 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10593 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
10594 void __thiscall basic_ifstream_char_dtor(basic_ios_char *base)
10595 {
10596     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
10597
10598     TRACE("(%p)\n", this);
10599
10600     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
10601     basic_filebuf_char_dtor(&this->filebuf);
10602 }
10603
10604 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10605 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10606 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
10607 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
10608 {
10609     TRACE("(%p)\n", this);
10610
10611     basic_ifstream_char_dtor(basic_ifstream_char_to_basic_ios(this));
10612     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
10613 }
10614
10615 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vector_dtor, 8)
10616 basic_ifstream_char* __thiscall basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10617 {
10618     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
10619
10620     TRACE("(%p %x)\n", this, flags);
10621
10622     if(flags & 2) {
10623         /* we have an array, with the number of elements stored before the first object */
10624         INT_PTR i, *ptr = (INT_PTR *)this-1;
10625
10626         for(i=*ptr-1; i>=0; i--)
10627             basic_ifstream_char_vbase_dtor(this+i);
10628         MSVCRT_operator_delete(ptr);
10629     } else {
10630         basic_ifstream_char_vbase_dtor(this);
10631         if(flags & 1)
10632             MSVCRT_operator_delete(this);
10633     }
10634
10635     return this;
10636 }
10637
10638 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10639 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10640 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
10641 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
10642 {
10643     TRACE("(%p)\n", this);
10644
10645     if(!basic_filebuf_char_close(&this->filebuf)) {
10646         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10647         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10648     }
10649 }
10650
10651 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10652 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10653 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
10654 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
10655 {
10656     TRACE("(%p)\n", this);
10657     return basic_filebuf_char_is_open(&this->filebuf);
10658 }
10659
10660 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
10661 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
10662 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 16)
10663 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
10664         const char *name, int mode, int prot)
10665 {
10666     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10667
10668     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10669         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10670         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10671     }
10672 }
10673
10674 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
10675 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
10676 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
10677 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
10678         const char *name, unsigned int mode)
10679 {
10680     basic_ifstream_char_open(this, name, mode, _SH_DENYNO);
10681 }
10682
10683 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
10684 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
10685 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
10686 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
10687 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar, 16)
10688 void __thiscall basic_ifstream_char_open_wchar(basic_ifstream_char *this,
10689         const wchar_t *name, int mode, int prot)
10690 {
10691     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10692
10693     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10694         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10695         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10696     }
10697 }
10698
10699 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
10700 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
10701 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
10702 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
10703 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar_old, 12)
10704 void __thiscall basic_ifstream_char_open_wchar_old(basic_ifstream_char *this,
10705         const wchar_t *name, unsigned int mode)
10706 {
10707     basic_ifstream_char_open_wchar(this, name, mode, _SH_DENYNO);
10708 }
10709
10710 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10711 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10712 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
10713 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
10714 {
10715     TRACE("(%p)\n", this);
10716     return (basic_filebuf_char*)&this->filebuf;
10717 }
10718
10719 static inline basic_ios_wchar* basic_ifstream_wchar_to_basic_ios(basic_ifstream_wchar *ptr)
10720 {
10721     return (basic_ios_wchar*)((char*)ptr+basic_ifstream_wchar_vbtable[1]);
10722 }
10723
10724 static inline basic_ifstream_wchar* basic_ifstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10725 {
10726     return (basic_ifstream_wchar*)((char*)ptr-basic_ifstream_wchar_vbtable[1]);
10727 }
10728
10729 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10730 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10731 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor, 8)
10732 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10733 {
10734     basic_ios_wchar *basic_ios;
10735
10736     TRACE("(%p %d)\n", this, virt_init);
10737
10738     if(virt_init) {
10739         this->base.vbtable = basic_ifstream_wchar_vbtable;
10740         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10741         basic_ios_wchar_ctor(basic_ios);
10742     }else {
10743         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10744     }
10745
10746     basic_filebuf_wchar_ctor(&this->filebuf);
10747     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10748     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10749     return this;
10750 }
10751
10752 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10753 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10754 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor, 8)
10755 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10756 {
10757     basic_ifstream_wchar_ctor(this, virt_init);
10758     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10759     return this;
10760 }
10761
10762 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10763 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10764 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_file, 12)
10765 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_file(
10766         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10767 {
10768     basic_ios_wchar *basic_ios;
10769
10770     TRACE("(%p %p %d)\n", this, file, virt_init);
10771
10772     if(virt_init) {
10773         this->base.vbtable = basic_ifstream_wchar_vbtable;
10774         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10775         basic_ios_wchar_ctor(basic_ios);
10776     }else {
10777         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10778     }
10779
10780     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10781     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10782     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10783     return this;
10784 }
10785
10786 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10787 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10788 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_file, 12)
10789 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_file(
10790         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10791 {
10792     basic_ifstream_wchar_ctor_file(this, file, virt_init);
10793     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10794     return this;
10795 }
10796
10797 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z */
10798 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z */
10799 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_name, 20)
10800 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_name(basic_ifstream_wchar *this,
10801         const char *name, int mode, int prot, MSVCP_bool virt_init)
10802 {
10803     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10804
10805     basic_ifstream_wchar_ctor(this, virt_init);
10806
10807     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10808         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10809         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10810     }
10811     return this;
10812 }
10813
10814 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBDHH@Z */
10815 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDHH@Z */
10816 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name, 20)
10817 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name(basic_ifstream_wchar *this,
10818         const char *name, int mode, int prot, MSVCP_bool virt_init)
10819 {
10820     basic_ifstream_wchar_ctor_name(this, name, mode, prot, virt_init);
10821     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10822     return this;
10823 }
10824
10825 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PBGHH@Z */
10826 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBGHH@Z */
10827 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10828 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10829 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_name_wchar, 20)
10830 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_name_wchar(basic_ifstream_wchar *this,
10831         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10832 {
10833     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10834
10835     basic_ifstream_wchar_ctor(this, virt_init);
10836
10837     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10838         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10839         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10840     }
10841     return this;
10842 }
10843
10844 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
10845 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
10846 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PB_WHH@Z */
10847 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEB_WHH@Z */
10848 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name_wchar, 20)
10849 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name_wchar(basic_ifstream_wchar *this,
10850         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10851 {
10852     basic_ifstream_wchar_ctor_name_wchar(this, name, mode, prot, virt_init);
10853     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10854     return this;
10855 }
10856
10857 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10858 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10859 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10860 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10861 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_dtor, 4)
10862 void __thiscall basic_ifstream_wchar_dtor(basic_ios_wchar *base)
10863 {
10864     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10865
10866     TRACE("(%p)\n", this);
10867
10868     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
10869     basic_filebuf_wchar_dtor(&this->filebuf);
10870 }
10871
10872 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10873 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10874 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10875 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10876 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vbase_dtor, 4)
10877 void __thiscall basic_ifstream_wchar_vbase_dtor(basic_ifstream_wchar *this)
10878 {
10879     TRACE("(%p)\n", this);
10880
10881     basic_ifstream_wchar_dtor(basic_ifstream_wchar_to_basic_ios(this));
10882     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
10883 }
10884
10885 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vector_dtor, 8)
10886 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10887 {
10888     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10889
10890     TRACE("(%p %x)\n", this, flags);
10891
10892     if(flags & 2) {
10893         /* we have an array, with the number of elements stored before the first object */
10894         INT_PTR i, *ptr = (INT_PTR *)this-1;
10895
10896         for(i=*ptr-1; i>=0; i--)
10897             basic_ifstream_wchar_vbase_dtor(this+i);
10898         MSVCRT_operator_delete(ptr);
10899     } else {
10900         basic_ifstream_wchar_vbase_dtor(this);
10901         if(flags & 1)
10902             MSVCRT_operator_delete(this);
10903     }
10904
10905     return this;
10906 }
10907
10908 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10909 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10910 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10911 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10912 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_close, 4)
10913 void __thiscall basic_ifstream_wchar_close(basic_ifstream_wchar *this)
10914 {
10915     TRACE("(%p)\n", this);
10916
10917     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10918         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10919         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10920     }
10921 }
10922
10923 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10924 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10925 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10926 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10927 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_is_open, 4)
10928 MSVCP_bool __thiscall basic_ifstream_wchar_is_open(const basic_ifstream_wchar *this)
10929 {
10930     TRACE("(%p)\n", this);
10931     return basic_filebuf_wchar_is_open(&this->filebuf);
10932 }
10933
10934 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
10935 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
10936 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
10937 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
10938 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open, 16)
10939 void __thiscall basic_ifstream_wchar_open(basic_ifstream_wchar *this,
10940         const char *name, int mode, int prot)
10941 {
10942     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10943
10944     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10945         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10946         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10947     }
10948 }
10949
10950 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
10951 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
10952 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
10953 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
10954 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_old, 12)
10955 void __thiscall basic_ifstream_wchar_open_old(basic_ifstream_wchar *this,
10956         const char *name, unsigned int mode)
10957 {
10958     basic_ifstream_wchar_open(this, name, mode, _SH_DENYNO);
10959 }
10960
10961 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGHH@Z */
10962 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGHH@Z */
10963 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WHH@Z */
10964 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WHH@Z */
10965 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBGHH@Z */
10966 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGHH@Z */
10967 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPB_WHH@Z */
10968 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WHH@Z */
10969 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_wchar, 16)
10970 void __thiscall basic_ifstream_wchar_open_wchar(basic_ifstream_wchar *this,
10971         const wchar_t *name, int mode, int prot)
10972 {
10973     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10974
10975     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10976         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10977         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10978     }
10979 }
10980
10981 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGI@Z */
10982 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGI@Z */
10983 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WI@Z */
10984 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WI@Z */
10985 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBGI@Z */
10986 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGI@Z */
10987 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPB_WI@Z */
10988 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WI@Z */
10989 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_wchar_old, 12)
10990 void __thiscall basic_ifstream_wchar_open_wchar_old(basic_ifstream_wchar *this,
10991         const wchar_t *name, unsigned int mode)
10992 {
10993     basic_ifstream_wchar_open_wchar(this, name, mode, _SH_DENYNO);
10994 }
10995
10996 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10997 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10998 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10999 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
11000 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_rdbuf, 4)
11001 basic_filebuf_wchar* __thiscall basic_ifstream_wchar_rdbuf(const basic_ifstream_wchar *this)
11002 {
11003     TRACE("(%p)\n", this);
11004     return (basic_filebuf_wchar*)&this->filebuf;
11005 }
11006
11007 static inline basic_ios_char* basic_fstream_char_to_basic_ios(basic_fstream_char *ptr)
11008 {
11009     return (basic_ios_char*)((char*)ptr+basic_fstream_char_vbtable1[1]);
11010 }
11011
11012 static inline basic_fstream_char* basic_fstream_char_from_basic_ios(basic_ios_char *ptr)
11013 {
11014     return (basic_fstream_char*)((char*)ptr-basic_fstream_char_vbtable1[1]);
11015 }
11016
11017 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
11018 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
11019 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
11020 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
11021 {
11022     basic_ios_char *basic_ios;
11023
11024     TRACE("(%p %d)\n", this, virt_init);
11025
11026     if(virt_init) {
11027         this->base.base1.vbtable = basic_fstream_char_vbtable1;
11028         this->base.base2.vbtable = basic_fstream_char_vbtable2;
11029         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11030         basic_ios_char_ctor(basic_ios);
11031     }else {
11032         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11033     }
11034
11035     basic_filebuf_char_ctor(&this->filebuf);
11036     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
11037     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
11038     return this;
11039 }
11040
11041 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
11042 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11043 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_file, 12)
11044 basic_fstream_char* __thiscall basic_fstream_char_ctor_file(basic_fstream_char *this,
11045         FILE *file, MSVCP_bool virt_init)
11046 {
11047     basic_ios_char *basic_ios;
11048
11049     TRACE("(%p %p %d)\n", this, file, virt_init);
11050
11051     if(virt_init) {
11052         this->base.base1.vbtable = basic_fstream_char_vbtable1;
11053         this->base.base2.vbtable = basic_fstream_char_vbtable2;
11054         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11055         basic_ios_char_ctor(basic_ios);
11056     }else {
11057         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11058     }
11059
11060     basic_filebuf_char_ctor_file(&this->filebuf, file);
11061     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
11062     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
11063     return this;
11064 }
11065
11066 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
11067 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
11068 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 20)
11069 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
11070         const char *name, int mode, int prot, MSVCP_bool virt_init)
11071 {
11072     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
11073
11074     basic_fstream_char_ctor(this, virt_init);
11075
11076     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
11077         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11078         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11079     }
11080     return this;
11081 }
11082
11083 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
11084 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
11085 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
11086 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
11087 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name_wchar, 20)
11088 basic_fstream_char* __thiscall basic_fstream_char_ctor_name_wchar(basic_fstream_char *this,
11089         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
11090 {
11091     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
11092
11093     basic_fstream_char_ctor(this, virt_init);
11094
11095     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
11096         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11097         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11098     }
11099     return this;
11100 }
11101
11102 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
11103 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
11104 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
11105 void __thiscall basic_fstream_char_dtor(basic_ios_char *base)
11106 {
11107     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
11108
11109     TRACE("(%p)\n", this);
11110
11111     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11112     basic_filebuf_char_dtor(&this->filebuf);
11113 }
11114
11115 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
11116 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
11117 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
11118 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
11119 {
11120     TRACE("(%p)\n", this);
11121
11122     basic_fstream_char_dtor(basic_fstream_char_to_basic_ios(this));
11123     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11124 }
11125
11126 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vector_dtor, 8)
11127 basic_fstream_char* __thiscall basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11128 {
11129     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
11130
11131     TRACE("(%p %x)\n", this, flags);
11132
11133     if(flags & 2) {
11134         /* we have an array, with the number of elements stored before the first object */
11135         INT_PTR i, *ptr = (INT_PTR *)this-1;
11136
11137         for(i=*ptr-1; i>=0; i--)
11138             basic_fstream_char_vbase_dtor(this+i);
11139         MSVCRT_operator_delete(ptr);
11140     } else {
11141         basic_fstream_char_vbase_dtor(this);
11142         if(flags & 1)
11143             MSVCRT_operator_delete(this);
11144     }
11145
11146     return this;
11147 }
11148
11149 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
11150 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
11151 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
11152 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
11153 {
11154     TRACE("(%p)\n", this);
11155
11156     if(!basic_filebuf_char_close(&this->filebuf)) {
11157         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11158         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11159     }
11160 }
11161
11162 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
11163 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
11164 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
11165 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
11166 {
11167     TRACE("(%p)\n", this);
11168     return basic_filebuf_char_is_open(&this->filebuf);
11169 }
11170
11171 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
11172 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
11173 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 16)
11174 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
11175         const char *name, int mode, int prot)
11176 {
11177     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
11178
11179     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
11180         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11181         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11182     }
11183 }
11184
11185 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
11186 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
11187 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
11188 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
11189         const char *name, unsigned int mode)
11190 {
11191     basic_fstream_char_open(this, name, mode, _SH_DENYNO);
11192 }
11193
11194 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
11195 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
11196 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
11197 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
11198 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar, 16)
11199 void __thiscall basic_fstream_char_open_wchar(basic_fstream_char *this,
11200         const wchar_t *name, int mode, int prot)
11201 {
11202     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
11203
11204     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
11205         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11206         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11207     }
11208 }
11209
11210 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
11211 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
11212 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
11213 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
11214 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar_old, 12)
11215 void __thiscall basic_fstream_char_open_wchar_old(basic_fstream_char *this,
11216         const wchar_t *name, unsigned int mode)
11217 {
11218     basic_fstream_char_open_wchar(this, name, mode, _SH_DENYNO);
11219 }
11220
11221 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
11222 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
11223 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
11224 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
11225 {
11226     TRACE("(%p)\n", this);
11227     return (basic_filebuf_char*)&this->filebuf;
11228 }
11229
11230 static inline basic_ios_wchar* basic_fstream_wchar_to_basic_ios(basic_fstream_wchar *ptr)
11231 {
11232     return (basic_ios_wchar*)((char*)ptr+basic_fstream_wchar_vbtable1[1]);
11233 }
11234
11235 static inline basic_fstream_wchar* basic_fstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11236 {
11237     return (basic_fstream_wchar*)((char*)ptr-basic_fstream_wchar_vbtable1[1]);
11238 }
11239
11240 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
11241 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
11242 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor, 8)
11243 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
11244 {
11245     basic_ios_wchar *basic_ios;
11246
11247     TRACE("(%p %d)\n", this, virt_init);
11248
11249     if(virt_init) {
11250         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
11251         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
11252         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11253         basic_ios_wchar_ctor(basic_ios);
11254     }else {
11255         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11256     }
11257
11258     basic_filebuf_wchar_ctor(&this->filebuf);
11259     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
11260     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
11261     return this;
11262 }
11263
11264 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
11265 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
11266 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor, 8)
11267 basic_fstream_wchar* __thiscall basic_fstream_short_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
11268 {
11269     basic_fstream_wchar_ctor(this, virt_init);
11270     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11271     return this;
11272 }
11273
11274 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
11275 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11276 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_file, 12)
11277 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_file(basic_fstream_wchar *this,
11278         FILE *file, MSVCP_bool virt_init)
11279 {
11280     basic_ios_wchar *basic_ios;
11281
11282     TRACE("(%p %p %d)\n", this, file, virt_init);
11283
11284     if(virt_init) {
11285         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
11286         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
11287         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11288         basic_ios_wchar_ctor(basic_ios);
11289     }else {
11290         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11291     }
11292
11293     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
11294     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
11295     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
11296     return this;
11297 }
11298
11299 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
11300 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11301 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_file, 12)
11302 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_file(basic_fstream_wchar *this,
11303         FILE *file, MSVCP_bool virt_init)
11304 {
11305     basic_fstream_wchar_ctor_file(this, file, virt_init);
11306     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11307     return this;
11308 }
11309
11310 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
11311 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
11312 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_name, 20)
11313 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_name(basic_fstream_wchar *this,
11314         const char *name, int mode, int prot, MSVCP_bool virt_init)
11315 {
11316     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
11317
11318     basic_fstream_wchar_ctor(this, virt_init);
11319
11320     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, prot)) {
11321         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11322         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11323     }
11324     return this;
11325 }
11326
11327 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
11328 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
11329 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name, 20)
11330 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name(basic_fstream_wchar *this,
11331         const char *name, int mode, int prot, MSVCP_bool virt_init)
11332 {
11333     basic_fstream_wchar_ctor_name(this, name, mode, prot, virt_init);
11334     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11335     return this;
11336 }
11337
11338 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PBGHH@Z */
11339 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBGHH@Z */
11340 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
11341 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
11342 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_name_wchar, 20)
11343 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_name_wchar(basic_fstream_wchar *this,
11344         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
11345 {
11346     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
11347
11348     basic_fstream_wchar_ctor(this, virt_init);
11349
11350     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode, prot)) {
11351         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11352         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11353     }
11354     return this;
11355 }
11356
11357 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
11358 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
11359 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PB_WHH@Z */
11360 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEB_WHH@Z */
11361 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name_wchar, 20)
11362 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name_wchar(basic_fstream_wchar *this,
11363         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
11364 {
11365     basic_fstream_wchar_ctor_name_wchar(this, name, mode, prot, virt_init);
11366     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11367     return this;
11368 }
11369
11370 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
11371 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
11372 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
11373 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
11374 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_dtor, 4)
11375 void __thiscall basic_fstream_wchar_dtor(basic_ios_wchar *base)
11376 {
11377     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
11378
11379     TRACE("(%p)\n", this);
11380
11381     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
11382     basic_filebuf_wchar_dtor(&this->filebuf);
11383 }
11384
11385 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
11386 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
11387 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
11388 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
11389 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vbase_dtor, 4)
11390 void __thiscall basic_fstream_wchar_vbase_dtor(basic_fstream_wchar *this)
11391 {
11392     TRACE("(%p)\n", this);
11393
11394     basic_fstream_wchar_dtor(basic_fstream_wchar_to_basic_ios(this));
11395     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
11396 }
11397
11398 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vector_dtor, 8)
11399 basic_fstream_wchar* __thiscall basic_fstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11400 {
11401     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
11402
11403     TRACE("(%p %x)\n", this, flags);
11404
11405     if(flags & 2) {
11406         /* we have an array, with the number of elements stored before the first object */
11407         INT_PTR i, *ptr = (INT_PTR *)this-1;
11408
11409         for(i=*ptr-1; i>=0; i--)
11410             basic_fstream_wchar_vbase_dtor(this+i);
11411         MSVCRT_operator_delete(ptr);
11412     } else {
11413         basic_fstream_wchar_vbase_dtor(this);
11414         if(flags & 1)
11415             MSVCRT_operator_delete(this);
11416     }
11417
11418     return this;
11419 }
11420
11421 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
11422 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
11423 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
11424 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
11425 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_close, 4)
11426 void __thiscall basic_fstream_wchar_close(basic_fstream_wchar *this)
11427 {
11428     TRACE("(%p)\n", this);
11429
11430     if(!basic_filebuf_wchar_close(&this->filebuf)) {
11431         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11432         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11433     }
11434 }
11435
11436 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
11437 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
11438 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
11439 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
11440 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_is_open, 4)
11441 MSVCP_bool __thiscall basic_fstream_wchar_is_open(const basic_fstream_wchar *this)
11442 {
11443     TRACE("(%p)\n", this);
11444     return basic_filebuf_wchar_is_open(&this->filebuf);
11445 }
11446
11447 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
11448 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
11449 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
11450 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
11451 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open, 16)
11452 void __thiscall basic_fstream_wchar_open(basic_fstream_wchar *this,
11453         const char *name, int mode, int prot)
11454 {
11455     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
11456
11457     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, prot)) {
11458         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11459         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11460     }
11461 }
11462
11463 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
11464 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
11465 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
11466 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
11467 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_old, 12)
11468 void __thiscall basic_fstream_wchar_open_old(basic_fstream_wchar *this,
11469         const char *name, unsigned int mode)
11470 {
11471     basic_fstream_wchar_open(this, name, mode, _SH_DENYNO);
11472 }
11473
11474 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGHH@Z */
11475 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGHH@Z */
11476 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WHH@Z */
11477 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WHH@Z */
11478 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBGHH@Z */
11479 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGHH@Z */
11480 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPB_WHH@Z */
11481 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WHH@Z */
11482 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_wchar, 16)
11483 void __thiscall basic_fstream_wchar_open_wchar(basic_fstream_wchar *this,
11484         const wchar_t *name, int mode, int prot)
11485 {
11486     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
11487
11488     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode, prot)) {
11489         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11490         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11491     }
11492 }
11493
11494 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGI@Z */
11495 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGI@Z */
11496 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WI@Z */
11497 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WI@Z */
11498 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBGI@Z */
11499 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGI@Z */
11500 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPB_WI@Z */
11501 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WI@Z */
11502 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_wchar_old, 12)
11503 void __thiscall basic_fstream_wchar_open_wchar_old(basic_fstream_wchar *this,
11504         const wchar_t *name, unsigned int mode)
11505 {
11506     basic_fstream_wchar_open_wchar(this, name, mode, _SH_DENYNO);
11507 }
11508
11509 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
11510 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
11511 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
11512 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
11513 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_rdbuf, 4)
11514 basic_filebuf_wchar* __thiscall basic_fstream_wchar_rdbuf(const basic_fstream_wchar *this)
11515 {
11516     TRACE("(%p)\n", this);
11517     return (basic_filebuf_wchar*)&this->filebuf;
11518 }
11519
11520 static inline basic_ios_char* basic_ostringstream_char_to_basic_ios(basic_ostringstream_char *ptr)
11521 {
11522     return (basic_ios_char*)((char*)ptr+basic_ostringstream_char_vbtable[1]);
11523 }
11524
11525 static inline basic_ostringstream_char* basic_ostringstream_char_from_basic_ios(basic_ios_char *ptr)
11526 {
11527     return (basic_ostringstream_char*)((char*)ptr-basic_ostringstream_char_vbtable[1]);
11528 }
11529
11530 /* ??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 */
11531 /* ??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 */
11532 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_str, 16)
11533 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_str(basic_ostringstream_char *this,
11534         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11535 {
11536     basic_ios_char *basic_ios;
11537
11538     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11539
11540     if(virt_init) {
11541         this->base.vbtable = basic_ostringstream_char_vbtable;
11542         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11543         basic_ios_char_ctor(basic_ios);
11544     }else {
11545         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11546     }
11547
11548     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
11549     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11550     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
11551     return this;
11552 }
11553
11554 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11555 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11556 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_mode, 12)
11557 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_mode(
11558         basic_ostringstream_char *this, int mode, MSVCP_bool virt_init)
11559 {
11560     basic_ios_char *basic_ios;
11561
11562     TRACE("(%p %d %d)\n", this, mode, virt_init);
11563
11564     if(virt_init) {
11565         this->base.vbtable = basic_ostringstream_char_vbtable;
11566         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11567         basic_ios_char_ctor(basic_ios);
11568     }else {
11569         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11570     }
11571
11572     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_out);
11573     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11574     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
11575     return this;
11576 }
11577
11578 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11579 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11580 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor, 8)
11581 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor(
11582         basic_ostringstream_char *this, MSVCP_bool virt_init)
11583 {
11584     return basic_ostringstream_char_ctor_mode(this, 0, virt_init);
11585 }
11586
11587 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11588 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11589 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_dtor, 4)
11590 void __thiscall basic_ostringstream_char_dtor(basic_ios_char *base)
11591 {
11592     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
11593
11594     TRACE("(%p)\n", this);
11595
11596     basic_stringbuf_char_dtor(&this->strbuf);
11597     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
11598 }
11599
11600 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11601 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11602 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vbase_dtor, 4)
11603 void __thiscall basic_ostringstream_char_vbase_dtor(basic_ostringstream_char *this)
11604 {
11605     TRACE("(%p)\n", this);
11606
11607     basic_ostringstream_char_dtor(basic_ostringstream_char_to_basic_ios(this));
11608     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
11609 }
11610
11611 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vector_dtor, 8)
11612 basic_ostringstream_char* __thiscall basic_ostringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11613 {
11614     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
11615
11616     TRACE("(%p %x)\n", this, flags);
11617
11618     if(flags & 2) {
11619         /* we have an array, with the number of elements stored before the first object */
11620         INT_PTR i, *ptr = (INT_PTR *)this-1;
11621
11622         for(i=*ptr-1; i>=0; i--)
11623             basic_ostringstream_char_vbase_dtor(this+i);
11624         MSVCRT_operator_delete(ptr);
11625     } else {
11626         basic_ostringstream_char_vbase_dtor(this);
11627         if(flags & 1)
11628             MSVCRT_operator_delete(this);
11629     }
11630
11631     return this;
11632 }
11633
11634 /* ?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 */
11635 /* ?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 */
11636 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_rdbuf, 4)
11637 basic_stringbuf_char* __thiscall basic_ostringstream_char_rdbuf(const basic_ostringstream_char *this)
11638 {
11639     TRACE("(%p)\n", this);
11640     return (basic_stringbuf_char*)&this->strbuf;
11641 }
11642
11643 /* ?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 */
11644 /* ?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 */
11645 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_set, 8)
11646 void __thiscall basic_ostringstream_char_str_set(basic_ostringstream_char *this, const basic_string_char *str)
11647 {
11648     TRACE("(%p %p)\n", this, str);
11649     basic_stringbuf_char_str_set(&this->strbuf, str);
11650 }
11651
11652 /* ?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 */
11653 /* ?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 */
11654 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_get, 8)
11655 basic_string_char* __thiscall basic_ostringstream_char_str_get(const basic_ostringstream_char *this, basic_string_char *ret)
11656 {
11657     TRACE("(%p %p)\n", this, ret);
11658     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11659 }
11660
11661 static inline basic_ios_wchar* basic_ostringstream_wchar_to_basic_ios(basic_ostringstream_wchar *ptr)
11662 {
11663     return (basic_ios_wchar*)((char*)ptr+basic_ostringstream_wchar_vbtable[1]);
11664 }
11665
11666 static inline basic_ostringstream_wchar* basic_ostringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11667 {
11668     return (basic_ostringstream_wchar*)((char*)ptr-basic_ostringstream_wchar_vbtable[1]);
11669 }
11670
11671 /* ??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 */
11672 /* ??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 */
11673 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor_str, 16)
11674 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor_str(basic_ostringstream_wchar *this,
11675         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11676 {
11677     basic_ios_wchar *basic_ios;
11678
11679     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11680
11681     if(virt_init) {
11682         this->base.vbtable = basic_ostringstream_wchar_vbtable;
11683         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11684         basic_ios_wchar_ctor(basic_ios);
11685     }else {
11686         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11687     }
11688
11689     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
11690     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11691     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
11692     return this;
11693 }
11694
11695 /* ??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 */
11696 /* ??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 */
11697 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_str, 16)
11698 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_str(basic_ostringstream_wchar *this,
11699         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11700 {
11701     basic_ostringstream_wchar_ctor_str(this, str, mode, virt_init);
11702     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
11703     return this;
11704 }
11705
11706 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11707 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11708 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor_mode, 12)
11709 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor_mode(
11710         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
11711 {
11712     basic_ios_wchar *basic_ios;
11713
11714     TRACE("(%p %d %d)\n", this, mode, virt_init);
11715
11716     if(virt_init) {
11717         this->base.vbtable = basic_ostringstream_wchar_vbtable;
11718         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11719         basic_ios_wchar_ctor(basic_ios);
11720     }else {
11721         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11722     }
11723
11724     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_out);
11725     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11726     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
11727     return this;
11728 }
11729
11730 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11731 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11732 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_mode, 12)
11733 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_mode(
11734         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
11735 {
11736     basic_ostringstream_wchar_ctor_mode(this, mode, virt_init);
11737     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
11738     return this;
11739 }
11740
11741 /* ??_F?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11742 /* ??_F?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11743 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor, 8)
11744 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor(
11745         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
11746 {
11747     return basic_ostringstream_wchar_ctor_mode(this, 0, virt_init);
11748 }
11749
11750 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11751 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11752 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor, 8)
11753 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor(
11754         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
11755 {
11756     return basic_ostringstream_short_ctor_mode(this, 0, virt_init);
11757 }
11758
11759 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11760 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11761 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11762 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11763 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_dtor, 4)
11764 void __thiscall basic_ostringstream_wchar_dtor(basic_ios_wchar *base)
11765 {
11766     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
11767
11768     TRACE("(%p)\n", this);
11769
11770     basic_stringbuf_wchar_dtor(&this->strbuf);
11771     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
11772 }
11773
11774 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11775 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11776 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11777 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11778 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vbase_dtor, 4)
11779 void __thiscall basic_ostringstream_wchar_vbase_dtor(basic_ostringstream_wchar *this)
11780 {
11781     TRACE("(%p)\n", this);
11782
11783     basic_ostringstream_wchar_dtor(basic_ostringstream_wchar_to_basic_ios(this));
11784     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
11785 }
11786
11787 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vector_dtor, 8)
11788 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11789 {
11790     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
11791
11792     TRACE("(%p %x)\n", this, flags);
11793
11794     if(flags & 2) {
11795         /* we have an array, with the number of elements stored before the first object */
11796         INT_PTR i, *ptr = (INT_PTR *)this-1;
11797
11798         for(i=*ptr-1; i>=0; i--)
11799             basic_ostringstream_wchar_vbase_dtor(this+i);
11800         MSVCRT_operator_delete(ptr);
11801     } else {
11802         basic_ostringstream_wchar_vbase_dtor(this);
11803         if(flags & 1)
11804             MSVCRT_operator_delete(this);
11805     }
11806
11807     return this;
11808 }
11809
11810 /* ?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 */
11811 /* ?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 */
11812 /* ?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 */
11813 /* ?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 */
11814 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_rdbuf, 4)
11815 basic_stringbuf_wchar* __thiscall basic_ostringstream_wchar_rdbuf(const basic_ostringstream_wchar *this)
11816 {
11817     TRACE("(%p)\n", this);
11818     return (basic_stringbuf_wchar*)&this->strbuf;
11819 }
11820
11821 /* ?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 */
11822 /* ?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 */
11823 /* ?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 */
11824 /* ?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 */
11825 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_set, 8)
11826 void __thiscall basic_ostringstream_wchar_str_set(basic_ostringstream_wchar *this, const basic_string_wchar *str)
11827 {
11828     TRACE("(%p %p)\n", this, str);
11829     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11830 }
11831
11832 /* ?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 */
11833 /* ?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 */
11834 /* ?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 */
11835 /* ?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 */
11836 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_get, 8)
11837 basic_string_wchar* __thiscall basic_ostringstream_wchar_str_get(const basic_ostringstream_wchar *this, basic_string_wchar *ret)
11838 {
11839     TRACE("(%p %p)\n", this, ret);
11840     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11841 }
11842
11843 static inline basic_ios_char* basic_istringstream_char_to_basic_ios(basic_istringstream_char *ptr)
11844 {
11845     return (basic_ios_char*)((char*)ptr+basic_istringstream_char_vbtable[1]);
11846 }
11847
11848 static inline basic_istringstream_char* basic_istringstream_char_from_basic_ios(basic_ios_char *ptr)
11849 {
11850     return (basic_istringstream_char*)((char*)ptr-basic_istringstream_char_vbtable[1]);
11851 }
11852
11853 /* ??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 */
11854 /* ??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 */
11855 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_str, 16)
11856 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_str(basic_istringstream_char *this,
11857         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11858 {
11859     basic_ios_char *basic_ios;
11860
11861     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11862
11863     if(virt_init) {
11864         this->base.vbtable = basic_istringstream_char_vbtable;
11865         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11866         basic_ios_char_ctor(basic_ios);
11867     }else {
11868         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11869     }
11870
11871     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
11872     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11873     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11874     return this;
11875 }
11876
11877 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11878 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11879 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_mode, 12)
11880 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_mode(
11881         basic_istringstream_char *this, int mode, MSVCP_bool virt_init)
11882 {
11883     basic_ios_char *basic_ios;
11884
11885     TRACE("(%p %d %d)\n", this, mode, virt_init);
11886
11887     if(virt_init) {
11888         this->base.vbtable = basic_istringstream_char_vbtable;
11889         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11890         basic_ios_char_ctor(basic_ios);
11891     }else {
11892         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11893     }
11894
11895     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11896     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11897     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11898     return this;
11899 }
11900
11901 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11902 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11903 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor, 8)
11904 basic_istringstream_char* __thiscall basic_istringstream_char_ctor(
11905         basic_istringstream_char *this, MSVCP_bool virt_init)
11906 {
11907     return basic_istringstream_char_ctor_mode(this, 0, virt_init);
11908 }
11909
11910 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11911 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11912 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_dtor, 4)
11913 void __thiscall basic_istringstream_char_dtor(basic_ios_char *base)
11914 {
11915     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11916
11917     TRACE("(%p)\n", this);
11918
11919     basic_stringbuf_char_dtor(&this->strbuf);
11920     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11921 }
11922
11923 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11924 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11925 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vbase_dtor, 4)
11926 void __thiscall basic_istringstream_char_vbase_dtor(basic_istringstream_char *this)
11927 {
11928     TRACE("(%p)\n", this);
11929
11930     basic_istringstream_char_dtor(basic_istringstream_char_to_basic_ios(this));
11931     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
11932 }
11933
11934 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vector_dtor, 8)
11935 basic_istringstream_char* __thiscall basic_istringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11936 {
11937     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11938
11939     TRACE("(%p %x)\n", this, flags);
11940
11941     if(flags & 2) {
11942         /* we have an array, with the number of elements stored before the first object */
11943         INT_PTR i, *ptr = (INT_PTR *)this-1;
11944
11945         for(i=*ptr-1; i>=0; i--)
11946             basic_istringstream_char_vbase_dtor(this+i);
11947         MSVCRT_operator_delete(ptr);
11948     } else {
11949         basic_istringstream_char_vbase_dtor(this);
11950         if(flags & 1)
11951             MSVCRT_operator_delete(this);
11952     }
11953
11954     return this;
11955 }
11956
11957 /* ?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 */
11958 /* ?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 */
11959 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_rdbuf, 4)
11960 basic_stringbuf_char* __thiscall basic_istringstream_char_rdbuf(const basic_istringstream_char *this)
11961 {
11962     TRACE("(%p)\n", this);
11963     return (basic_stringbuf_char*)&this->strbuf;
11964 }
11965
11966 /* ?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 */
11967 /* ?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 */
11968 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_set, 8)
11969 void __thiscall basic_istringstream_char_str_set(basic_istringstream_char *this, const basic_string_char *str)
11970 {
11971     TRACE("(%p %p)\n", this, str);
11972     basic_stringbuf_char_str_set(&this->strbuf, str);
11973 }
11974
11975 /* ?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 */
11976 /* ?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 */
11977 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_get, 8)
11978 basic_string_char* __thiscall basic_istringstream_char_str_get(const basic_istringstream_char *this, basic_string_char *ret)
11979 {
11980     TRACE("(%p %p)\n", this, ret);
11981     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11982 }
11983
11984 static inline basic_ios_wchar* basic_istringstream_wchar_to_basic_ios(basic_istringstream_wchar *ptr)
11985 {
11986     return (basic_ios_wchar*)((char*)ptr+basic_istringstream_wchar_vbtable[1]);
11987 }
11988
11989 static inline basic_istringstream_wchar* basic_istringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11990 {
11991     return (basic_istringstream_wchar*)((char*)ptr-basic_istringstream_wchar_vbtable[1]);
11992 }
11993
11994 /* ??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 */
11995 /* ??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 */
11996 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor_str, 16)
11997 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor_str(basic_istringstream_wchar *this,
11998         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11999 {
12000     basic_ios_wchar *basic_ios;
12001
12002     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
12003
12004     if(virt_init) {
12005         this->base.vbtable = basic_istringstream_wchar_vbtable;
12006         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
12007         basic_ios_wchar_ctor(basic_ios);
12008     }else {
12009         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
12010     }
12011
12012     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
12013     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
12014     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
12015     return this;
12016 }
12017
12018 /* ??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 */
12019 /* ??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 */
12020 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_str, 16)
12021 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_str(basic_istringstream_wchar *this,
12022         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
12023 {
12024     basic_istringstream_wchar_ctor_str(this, str, mode, virt_init);
12025     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
12026     return this;
12027 }
12028
12029 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
12030 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
12031 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor_mode, 12)
12032 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor_mode(
12033         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
12034 {
12035     basic_ios_wchar *basic_ios;
12036
12037     TRACE("(%p %d %d)\n", this, mode, virt_init);
12038
12039     if(virt_init) {
12040         this->base.vbtable = basic_istringstream_wchar_vbtable;
12041         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
12042         basic_ios_wchar_ctor(basic_ios);
12043     }else {
12044         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
12045     }
12046
12047     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_in);
12048     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
12049     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
12050     return this;
12051 }
12052
12053 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
12054 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
12055 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_mode, 12)
12056 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_mode(
12057         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
12058 {
12059     basic_istringstream_wchar_ctor_mode(this, mode, virt_init);
12060     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
12061     return this;
12062 }
12063
12064 /* ??_F?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12065 /* ??_F?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12066 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor, 8)
12067 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor(
12068         basic_istringstream_wchar *this, MSVCP_bool virt_init)
12069 {
12070     return basic_istringstream_wchar_ctor_mode(this, 0, virt_init);
12071 }
12072
12073 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12074 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12075 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor, 8)
12076 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor(
12077         basic_istringstream_wchar *this, MSVCP_bool virt_init)
12078 {
12079     return basic_istringstream_short_ctor_mode(this, 0, virt_init);
12080 }
12081
12082 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
12083 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
12084 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
12085 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
12086 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_dtor, 4)
12087 void __thiscall basic_istringstream_wchar_dtor(basic_ios_wchar *base)
12088 {
12089     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
12090
12091     TRACE("(%p)\n", this);
12092
12093     basic_stringbuf_wchar_dtor(&this->strbuf);
12094     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
12095 }
12096
12097 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12098 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12099 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12100 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12101 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vbase_dtor, 4)
12102 void __thiscall basic_istringstream_wchar_vbase_dtor(basic_istringstream_wchar *this)
12103 {
12104     TRACE("(%p)\n", this);
12105
12106     basic_istringstream_wchar_dtor(basic_istringstream_wchar_to_basic_ios(this));
12107     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
12108 }
12109
12110 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vector_dtor, 8)
12111 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
12112 {
12113     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
12114
12115     TRACE("(%p %x)\n", this, flags);
12116
12117     if(flags & 2) {
12118         /* we have an array, with the number of elements stored before the first object */
12119         INT_PTR i, *ptr = (INT_PTR *)this-1;
12120
12121         for(i=*ptr-1; i>=0; i--)
12122             basic_istringstream_wchar_vbase_dtor(this+i);
12123         MSVCRT_operator_delete(ptr);
12124     } else {
12125         basic_istringstream_wchar_vbase_dtor(this);
12126         if(flags & 1)
12127             MSVCRT_operator_delete(this);
12128     }
12129
12130     return this;
12131 }
12132
12133 /* ?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 */
12134 /* ?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 */
12135 /* ?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 */
12136 /* ?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 */
12137 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_rdbuf, 4)
12138 basic_stringbuf_wchar* __thiscall basic_istringstream_wchar_rdbuf(const basic_istringstream_wchar *this)
12139 {
12140     TRACE("(%p)\n", this);
12141     return (basic_stringbuf_wchar*)&this->strbuf;
12142 }
12143
12144 /* ?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 */
12145 /* ?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 */
12146 /* ?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 */
12147 /* ?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 */
12148 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_set, 8)
12149 void __thiscall basic_istringstream_wchar_str_set(basic_istringstream_wchar *this, const basic_string_wchar *str)
12150 {
12151     TRACE("(%p %p)\n", this, str);
12152     basic_stringbuf_wchar_str_set(&this->strbuf, str);
12153 }
12154
12155 /* ?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 */
12156 /* ?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 */
12157 /* ?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 */
12158 /* ?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 */
12159 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_get, 8)
12160 basic_string_wchar* __thiscall basic_istringstream_wchar_str_get(const basic_istringstream_wchar *this, basic_string_wchar *ret)
12161 {
12162     TRACE("(%p %p)\n", this, ret);
12163     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
12164 }
12165
12166 static inline basic_ios_char* basic_stringstream_char_to_basic_ios(basic_stringstream_char *ptr)
12167 {
12168     return (basic_ios_char*)((char*)ptr+basic_stringstream_char_vbtable1[1]);
12169 }
12170
12171 static inline basic_stringstream_char* basic_stringstream_char_from_basic_ios(basic_ios_char *ptr)
12172 {
12173     return (basic_stringstream_char*)((char*)ptr-basic_stringstream_char_vbtable1[1]);
12174 }
12175
12176 /* ??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 */
12177 /* ??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 */
12178 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_str, 16)
12179 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_str(basic_stringstream_char *this,
12180         const basic_string_char *str, int mode, MSVCP_bool virt_init)
12181 {
12182     basic_ios_char *basic_ios;
12183
12184     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
12185
12186     if(virt_init) {
12187         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
12188         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
12189         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12190         basic_ios_char_ctor(basic_ios);
12191     }else {
12192         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12193     }
12194
12195     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode);
12196     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
12197     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
12198     return this;
12199 }
12200
12201 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
12202 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
12203 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_mode, 12)
12204 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_mode(
12205         basic_stringstream_char *this, int mode, MSVCP_bool virt_init)
12206 {
12207     basic_ios_char *basic_ios;
12208
12209     TRACE("(%p %d %d)\n", this, mode, virt_init);
12210
12211     if(virt_init) {
12212         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
12213         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
12214         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12215         basic_ios_char_ctor(basic_ios);
12216     }else {
12217         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12218     }
12219
12220     basic_stringbuf_char_ctor_mode(&this->strbuf, mode);
12221     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
12222     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
12223     return this;
12224 }
12225
12226 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
12227 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
12228 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor, 8)
12229 basic_stringstream_char* __thiscall basic_stringstream_char_ctor(
12230         basic_stringstream_char *this, MSVCP_bool virt_init)
12231 {
12232     return basic_stringstream_char_ctor_mode(
12233             this, OPENMODE_out|OPENMODE_in, virt_init);
12234 }
12235
12236 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
12237 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
12238 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_dtor, 4)
12239 void __thiscall basic_stringstream_char_dtor(basic_ios_char *base)
12240 {
12241     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
12242
12243     TRACE("(%p)\n", this);
12244
12245     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
12246     basic_stringbuf_char_dtor(&this->strbuf);
12247 }
12248
12249 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
12250 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
12251 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vbase_dtor, 4)
12252 void __thiscall basic_stringstream_char_vbase_dtor(basic_stringstream_char *this)
12253 {
12254     TRACE("(%p)\n", this);
12255
12256     basic_stringstream_char_dtor(basic_stringstream_char_to_basic_ios(this));
12257     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
12258 }
12259
12260 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vector_dtor, 8)
12261 basic_stringstream_char* __thiscall basic_stringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
12262 {
12263     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
12264
12265     TRACE("(%p %x)\n", this, flags);
12266
12267     if(flags & 2) {
12268         /* we have an array, with the number of elements stored before the first object */
12269         INT_PTR i, *ptr = (INT_PTR *)this-1;
12270
12271         for(i=*ptr-1; i>=0; i--)
12272             basic_stringstream_char_vbase_dtor(this+i);
12273         MSVCRT_operator_delete(ptr);
12274     } else {
12275         basic_stringstream_char_vbase_dtor(this);
12276         if(flags & 1)
12277             MSVCRT_operator_delete(this);
12278     }
12279
12280     return this;
12281 }
12282
12283 /* ?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 */
12284 /* ?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 */
12285 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_rdbuf, 4)
12286 basic_stringbuf_char* __thiscall basic_stringstream_char_rdbuf(const basic_stringstream_char *this)
12287 {
12288     TRACE("(%p)\n", this);
12289     return (basic_stringbuf_char*)&this->strbuf;
12290 }
12291
12292 /* ?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 */
12293 /* ?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 */
12294 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_set, 8)
12295 void __thiscall basic_stringstream_char_str_set(basic_stringstream_char *this, const basic_string_char *str)
12296 {
12297     TRACE("(%p %p)\n", this, str);
12298     basic_stringbuf_char_str_set(&this->strbuf, str);
12299 }
12300
12301 /* ?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 */
12302 /* ?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 */
12303 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_get, 8)
12304 basic_string_char* __thiscall basic_stringstream_char_str_get(const basic_stringstream_char *this, basic_string_char *ret)
12305 {
12306     TRACE("(%p %p)\n", this, ret);
12307     return basic_stringbuf_char_str_get(&this->strbuf, ret);
12308 }
12309
12310 static inline basic_ios_wchar* basic_stringstream_wchar_to_basic_ios(basic_stringstream_wchar *ptr)
12311 {
12312     return (basic_ios_wchar*)((char*)ptr+basic_stringstream_wchar_vbtable1[1]);
12313 }
12314
12315 static inline basic_stringstream_wchar* basic_stringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
12316 {
12317     return (basic_stringstream_wchar*)((char*)ptr-basic_stringstream_wchar_vbtable1[1]);
12318 }
12319
12320 /* ??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 */
12321 /* ??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 */
12322 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor_str, 16)
12323 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor_str(basic_stringstream_wchar *this,
12324         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
12325 {
12326     basic_ios_wchar *basic_ios;
12327
12328     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
12329
12330     if(virt_init) {
12331         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
12332         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
12333         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12334         basic_ios_wchar_ctor(basic_ios);
12335     }else {
12336         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12337     }
12338
12339     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode);
12340     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
12341     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
12342     return this;
12343 }
12344
12345 /* ??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 */
12346 /* ??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 */
12347 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_str, 16)
12348 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_str(basic_stringstream_wchar *this,
12349         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
12350 {
12351     basic_stringstream_wchar_ctor_str(this, str, mode, virt_init);
12352     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
12353     return this;
12354 }
12355
12356 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
12357 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
12358 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor_mode, 12)
12359 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor_mode(
12360         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
12361 {
12362     basic_ios_wchar *basic_ios;
12363
12364     TRACE("(%p %d %d)\n", this, mode, virt_init);
12365
12366     if(virt_init) {
12367         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
12368         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
12369         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12370         basic_ios_wchar_ctor(basic_ios);
12371     }else {
12372         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12373     }
12374
12375     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode);
12376     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
12377     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
12378     return this;
12379 }
12380
12381 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
12382 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
12383 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_mode, 12)
12384 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_mode(
12385         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
12386 {
12387     basic_stringstream_wchar_ctor_mode(this, mode, virt_init);
12388     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
12389     return this;
12390 }
12391
12392 /* ??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12393 /* ??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12394 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor, 8)
12395 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor(
12396         basic_stringstream_wchar *this, MSVCP_bool virt_init)
12397 {
12398     return basic_stringstream_wchar_ctor_mode(
12399             this, OPENMODE_out|OPENMODE_in, virt_init);
12400 }
12401
12402 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12403 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12404 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor, 8)
12405 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor(
12406         basic_stringstream_wchar *this, MSVCP_bool virt_init)
12407 {
12408     return basic_stringstream_short_ctor_mode(
12409             this, OPENMODE_out|OPENMODE_in, virt_init);
12410 }
12411
12412 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
12413 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
12414 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
12415 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
12416 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_dtor, 4)
12417 void __thiscall basic_stringstream_wchar_dtor(basic_ios_wchar *base)
12418 {
12419     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
12420
12421     TRACE("(%p)\n", this);
12422
12423     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
12424     basic_stringbuf_wchar_dtor(&this->strbuf);
12425 }
12426
12427 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12428 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12429 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12430 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12431 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vbase_dtor, 4)
12432 void __thiscall basic_stringstream_wchar_vbase_dtor(basic_stringstream_wchar *this)
12433 {
12434     TRACE("(%p)\n", this);
12435
12436     basic_stringstream_wchar_dtor(basic_stringstream_wchar_to_basic_ios(this));
12437     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
12438 }
12439
12440 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vector_dtor, 8)
12441 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
12442 {
12443     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
12444
12445     TRACE("(%p %x)\n", this, flags);
12446
12447     if(flags & 2) {
12448         /* we have an array, with the number of elements stored before the first object */
12449         INT_PTR i, *ptr = (INT_PTR *)this-1;
12450
12451         for(i=*ptr-1; i>=0; i--)
12452             basic_stringstream_wchar_vbase_dtor(this+i);
12453         MSVCRT_operator_delete(ptr);
12454     } else {
12455         basic_stringstream_wchar_vbase_dtor(this);
12456         if(flags & 1)
12457             MSVCRT_operator_delete(this);
12458     }
12459
12460     return this;
12461 }
12462
12463 /* ?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 */
12464 /* ?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 */
12465 /* ?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 */
12466 /* ?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 */
12467 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_rdbuf, 4)
12468 basic_stringbuf_wchar* __thiscall basic_stringstream_wchar_rdbuf(const basic_stringstream_wchar *this)
12469 {
12470     TRACE("(%p)\n", this);
12471     return (basic_stringbuf_wchar*)&this->strbuf;
12472 }
12473
12474 /* ?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 */
12475 /* ?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 */
12476 /* ?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 */
12477 /* ?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 */
12478 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_set, 8)
12479 void __thiscall basic_stringstream_wchar_str_set(basic_stringstream_wchar *this, const basic_string_wchar *str)
12480 {
12481     TRACE("(%p %p)\n", this, str);
12482     basic_stringbuf_wchar_str_set(&this->strbuf, str);
12483 }
12484
12485 /* ?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 */
12486 /* ?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 */
12487 /* ?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 */
12488 /* ?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 */
12489 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_get, 8)
12490 basic_string_wchar* __thiscall basic_stringstream_wchar_str_get(const basic_stringstream_wchar *this, basic_string_wchar *ret)
12491 {
12492     TRACE("(%p %p)\n", this, ret);
12493     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
12494 }
12495
12496 /* ?_Init@strstreambuf@std@@IAEXHPAD0H@Z */
12497 /* ?_Init@strstreambuf@std@@IEAAX_JPEAD1H@Z */
12498 DEFINE_THISCALL_WRAPPER(strstreambuf__Init, 20)
12499 void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g, char *p, int mode)
12500 {
12501     TRACE("(%p %ld %p %p %d)\n", this, len, g, p, mode);
12502
12503     this->minsize = 32;
12504     this->endsave = NULL;
12505     this->strmode = mode;
12506     this->palloc = NULL;
12507     this->pfree = NULL;
12508
12509     if(!g) {
12510         this->strmode |= STRSTATE_Dynamic;
12511         if(len > this->minsize)
12512             this->minsize = len;
12513         this->seekhigh = NULL;
12514         return;
12515     }
12516
12517     if(len < 0)
12518         len = INT_MAX;
12519     else if(!len)
12520         len = strlen(g);
12521
12522     this->seekhigh = g+len;
12523     basic_streambuf_char_setg(&this->base, g, g, p ? p : this->seekhigh);
12524     if(p)
12525         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
12526 }
12527
12528 /* ??0strstreambuf@std@@QAE@PACH0@Z */
12529 /* ??0strstreambuf@std@@QEAA@PEAC_J0@Z */
12530 /* ??0strstreambuf@std@@QAE@PADH0@Z */
12531 /* ??0strstreambuf@std@@QEAA@PEAD_J0@Z */
12532 /* ??0strstreambuf@std@@QAE@PAEH0@Z */
12533 /* ??0strstreambuf@std@@QEAA@PEAE_J0@Z */
12534 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_get_put, 16)
12535 strstreambuf* __thiscall strstreambuf_ctor_get_put(strstreambuf *this, char *g, streamsize len, char *p)
12536 {
12537     TRACE("(%p %p %ld %p)\n", this, g, len, p);
12538
12539     basic_streambuf_char_ctor(&this->base);
12540     this->base.vtable = &MSVCP_strstreambuf_vtable;
12541
12542     strstreambuf__Init(this, len, g, p, 0);
12543     return this;
12544 }
12545
12546 /* ??0strstreambuf@std@@QAE@H@Z */
12547 /* ??0strstreambuf@std@@QEAA@_J@Z */
12548 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_len, 8)
12549 strstreambuf* __thiscall strstreambuf_ctor_len(strstreambuf *this, streamsize len)
12550 {
12551     return strstreambuf_ctor_get_put(this, NULL, len, NULL);
12552 }
12553
12554 /* ??0strstreambuf@std@@QAE@P6APAXI@ZP6AXPAX@Z@Z */
12555 /* ??0strstreambuf@std@@QEAA@P6APEAX_K@ZP6AXPEAX@Z@Z */
12556 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_alloc, 12)
12557 strstreambuf* __thiscall strstreambuf_ctor_alloc(strstreambuf *this, void* (__cdecl *palloc)(MSVCP_size_t), void (__cdecl *pfree)(void*))
12558 {
12559     TRACE("(%p %p %p)\n", this, palloc, pfree);
12560
12561     strstreambuf_ctor_get_put(this, NULL, 0, NULL);
12562     this->palloc = palloc;
12563     this->pfree = pfree;
12564     return this;
12565 }
12566
12567 /* ??0strstreambuf@std@@QAE@PBCH@Z */
12568 /* ??0strstreambuf@std@@QEAA@PEBC_J@Z */
12569 /* ??0strstreambuf@std@@QAE@PBDH@Z */
12570 /* ??0strstreambuf@std@@QEAA@PEBD_J@Z */
12571 /* ??0strstreambuf@std@@QAE@PBEH@Z */
12572 /* ??0strstreambuf@std@@QEAA@PEBE_J@Z */
12573 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_get, 12)
12574 strstreambuf* __thiscall strstreambuf_ctor_get(strstreambuf *this, const char *g, streamsize len)
12575 {
12576     TRACE("(%p %p %ld)\n", this, g, len);
12577
12578     strstreambuf_ctor_get_put(this, (char*)g, len, NULL);
12579     this->strmode |= STRSTATE_Constant;
12580     return this;
12581 }
12582
12583 /* ??_Fstrstreambuf@std@@QAEXXZ */
12584 /* ??_Fstrstreambuf@std@@QEAAXXZ */
12585 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor, 4)
12586 strstreambuf* __thiscall strstreambuf_ctor(strstreambuf *this)
12587 {
12588     return strstreambuf_ctor_get_put(this, NULL, 0, NULL);
12589 }
12590
12591 /* ?_Tidy@strstreambuf@std@@IAEXXZ */
12592 /* ?_Tidy@strstreambuf@std@@IEAAXXZ */
12593 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
12594 void __thiscall strstreambuf__Tidy(strstreambuf *this)
12595 {
12596     TRACE("(%p)\n", this);
12597
12598     if((this->strmode & STRSTATE_Allocated) && !(this->strmode & STRSTATE_Frozen)) {
12599         if(this->pfree)
12600             this->pfree(basic_streambuf_char_eback(&this->base));
12601         else
12602             MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
12603     }
12604
12605     this->endsave = NULL;
12606     this->seekhigh = NULL;
12607     this->strmode &= ~(STRSTATE_Allocated | STRSTATE_Frozen);
12608     basic_streambuf_char_setg(&this->base, NULL, NULL, NULL);
12609     basic_streambuf_char_setp(&this->base, NULL, NULL);
12610 }
12611
12612 /* ??1strstreambuf@std@@UAE@XZ */
12613 /* ??1strstreambuf@std@@UEAA@XZ */
12614 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor, 4)
12615 void __thiscall strstreambuf_dtor(strstreambuf *this)
12616 {
12617     TRACE("(%p)\n", this);
12618
12619     strstreambuf__Tidy(this);
12620     basic_streambuf_char_dtor(&this->base);
12621 }
12622
12623 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor, 8)
12624 strstreambuf* __thiscall strstreambuf_vector_dtor(strstreambuf *this, unsigned int flags)
12625 {
12626     TRACE("(%p %x)\n", this, flags);
12627     if(flags & 2) {
12628         /* we have an array, with the number of elements stored before the first object */
12629         INT_PTR i, *ptr = (INT_PTR *)this-1;
12630
12631         for(i=*ptr-1; i>=0; i--)
12632             strstreambuf_dtor(this+i);
12633         MSVCRT_operator_delete(ptr);
12634     } else {
12635         strstreambuf_dtor(this);
12636         if(flags & 1)
12637             MSVCRT_operator_delete(this);
12638     }
12639
12640     return this;
12641 }
12642
12643 /* ?freeze@strstreambuf@std@@QAEX_N@Z */
12644 /* ?freeze@strstreambuf@std@@QEAAX_N@Z */
12645 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze, 8)
12646 void __thiscall strstreambuf_freeze(strstreambuf *this, MSVCP_bool freeze)
12647 {
12648     TRACE("(%p %d)\n", this, freeze);
12649
12650     if(!freeze == !(this->strmode *STRSTATE_Frozen))
12651         return;
12652
12653     if(freeze) {
12654         this->strmode |= STRSTATE_Frozen;
12655         this->endsave = basic_streambuf_char_epptr(&this->base);
12656         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
12657                 basic_streambuf_char_pptr(&this->base), basic_streambuf_char_eback(&this->base));
12658     }else {
12659         this->strmode &= ~STRSTATE_Frozen;
12660         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
12661                 basic_streambuf_char_pptr(&this->base), this->endsave);
12662     }
12663 }
12664
12665 /* ?str@strstreambuf@std@@QAEPADXZ */
12666 /* ?str@strstreambuf@std@@QEAAPEADXZ */
12667 DEFINE_THISCALL_WRAPPER(strstreambuf_str, 4)
12668 char* __thiscall strstreambuf_str(strstreambuf *this)
12669 {
12670     TRACE("(%p)\n", this);
12671
12672     strstreambuf_freeze(this, TRUE);
12673     return basic_streambuf_char_gptr(&this->base);
12674 }
12675
12676 /* ?pcount@strstreambuf@std@@QBEHXZ */
12677 /* ?pcount@strstreambuf@std@@QEBA_JXZ */
12678 DEFINE_THISCALL_WRAPPER(strstreambuf_pcount, 4)
12679 streamsize __thiscall strstreambuf_pcount(const strstreambuf *this)
12680 {
12681     char *ppos = basic_streambuf_char_pptr(&this->base);
12682
12683     TRACE("(%p)\n", this);
12684
12685     return ppos ? ppos-basic_streambuf_char_pbase(&this->base) : 0;
12686 }
12687
12688 /* ?overflow@strstreambuf@std@@MAEHH@Z */
12689 /* ?overflow@strstreambuf@std@@MEAAHH@Z */
12690 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow, 8)
12691 int __thiscall strstreambuf_overflow(strstreambuf *this, int c)
12692 {
12693     MSVCP_size_t old_size, size;
12694     char *ptr, *buf;
12695
12696     TRACE("(%p %d)\n", this, c);
12697
12698     if(c == EOF)
12699         return !EOF;
12700
12701     if(this->strmode & STRSTATE_Frozen)
12702         return EOF;
12703
12704     ptr = basic_streambuf_char_pptr(&this->base);
12705     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
12706         return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
12707
12708     if(!(this->strmode & STRSTATE_Dynamic) || (this->strmode & STRSTATE_Constant))
12709         return EOF;
12710
12711     ptr = basic_streambuf_char_eback(&this->base);
12712     old_size = ptr ? basic_streambuf_char_epptr(&this->base) - ptr : 0;
12713
12714     size = old_size + old_size/2;
12715     if(size < this->minsize)
12716         size = this->minsize;
12717
12718     if(this->palloc)
12719         buf = this->palloc(size);
12720     else
12721         buf = MSVCRT_operator_new(size);
12722     if(!buf)
12723         return EOF;
12724
12725     memcpy(buf, ptr, old_size);
12726     if(this->strmode & STRSTATE_Allocated) {
12727         if(this->pfree)
12728             this->pfree(ptr);
12729         else
12730             MSVCRT_operator_delete(ptr);
12731     }
12732
12733     this->strmode |= STRSTATE_Allocated;
12734     if(!old_size) {
12735         this->seekhigh = buf;
12736         basic_streambuf_char_setp(&this->base, buf, buf+size);
12737         basic_streambuf_char_setg(&this->base, buf, buf, buf);
12738     }else {
12739         this->seekhigh = this->seekhigh-ptr+buf;
12740         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base)-ptr+buf,
12741                 basic_streambuf_char_pptr(&this->base)-ptr+buf, buf+size);
12742         basic_streambuf_char_setg(&this->base, buf, basic_streambuf_char_gptr(&this->base)-ptr+buf,
12743                 basic_streambuf_char_pptr(&this->base));
12744     }
12745
12746     return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
12747 }
12748
12749 /* ?pbackfail@strstreambuf@std@@MAEHH@Z */
12750 /* ?pbackfail@strstreambuf@std@@MEAAHH@Z */
12751 DEFINE_THISCALL_WRAPPER(strstreambuf_pbackfail, 8)
12752 int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c)
12753 {
12754     char *ptr = basic_streambuf_char_gptr(&this->base);
12755
12756     TRACE("(%p %d)\n", this, c);
12757
12758     if(ptr<=basic_streambuf_char_eback(&this->base)
12759             || ((this->strmode & STRSTATE_Constant) && c!=ptr[-1]))
12760         return EOF;
12761
12762     basic_streambuf_char_gbump(&this->base, -1);
12763     if(c == EOF)
12764         return !EOF;
12765     if(this->strmode & STRSTATE_Constant)
12766         return (unsigned char)c;
12767
12768     return (unsigned char)(ptr[0] = c);
12769 }
12770
12771 /* ?seekoff@strstreambuf@std@@MAE?AV?$fpos@H@2@JHH@Z */
12772 /* ?seekoff@strstreambuf@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
12773 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20)
12774 fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode)
12775 {
12776     char *eback = basic_streambuf_char_eback(&this->base);
12777     char *pptr = basic_streambuf_char_pptr(&this->base);
12778     char *gptr = basic_streambuf_char_gptr(&this->base);
12779
12780     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
12781
12782     ret->off = 0;
12783     ret->state = 0;
12784
12785     if(pptr > this->seekhigh)
12786         this->seekhigh = pptr;
12787
12788     if((mode & OPENMODE_in) && gptr) {
12789         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
12790             off += gptr-eback;
12791         else if(way == SEEKDIR_end)
12792             off += this->seekhigh-eback;
12793         else if(way != SEEKDIR_beg)
12794             off = -1;
12795
12796         if(off<0 || off>this->seekhigh-eback) {
12797             off = -1;
12798         }else {
12799             basic_streambuf_char_gbump(&this->base, eback-gptr+off);
12800             if((mode & OPENMODE_out) && pptr) {
12801                 basic_streambuf_char_setp_next(&this->base, eback,
12802                         gptr, basic_streambuf_char_epptr(&this->base));
12803             }
12804         }
12805     }else if((mode & OPENMODE_out) && pptr) {
12806         if(way == SEEKDIR_cur)
12807             off += pptr-eback;
12808         else if(way == SEEKDIR_end)
12809             off += this->seekhigh-eback;
12810         else if(way != SEEKDIR_beg)
12811             off = -1;
12812
12813          if(off<0 || off>this->seekhigh-eback)
12814              off = -1;
12815          else
12816              basic_streambuf_char_pbump(&this->base, eback-pptr+off);
12817     }else {
12818         off = -1;
12819     }
12820
12821     ret->pos = off;
12822     return ret;
12823 }
12824
12825 /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */
12826 /* ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
12827 DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36)
12828 fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode)
12829 {
12830     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
12831
12832     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
12833         *ret = pos;
12834         return ret;
12835     }
12836
12837     return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
12838 }
12839
12840 /* ?underflow@strstreambuf@std@@MAEHXZ */
12841 /* ?underflow@strstreambuf@std@@MEAAHXZ */
12842 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow, 4)
12843 int __thiscall strstreambuf_underflow(strstreambuf *this)
12844 {
12845     char *gptr = basic_streambuf_char_gptr(&this->base);
12846     char *pptr;
12847
12848     TRACE("(%p)\n", this);
12849
12850     if(!gptr)
12851         return EOF;
12852
12853     if(gptr < basic_streambuf_char_egptr(&this->base))
12854         return (unsigned char)(*gptr);
12855
12856     pptr = basic_streambuf_char_gptr(&this->base);
12857     if(pptr > this->seekhigh)
12858         this->seekhigh = pptr;
12859
12860     if(this->seekhigh <= gptr)
12861         return EOF;
12862
12863     basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base),
12864             gptr, this->seekhigh);
12865     return (unsigned char)(*gptr);
12866 }
12867
12868 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
12869 {
12870     ios_base_precision_set(base, prec);
12871 }
12872
12873 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
12874 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12875 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
12876 {
12877     TRACE("(%p %ld)\n", ret, prec);
12878
12879     ret->pfunc = setprecision_func;
12880     ret->arg = prec;
12881     return ret;
12882 }
12883
12884 static void __cdecl setw_func(ios_base *base, streamsize width)
12885 {
12886     ios_base_width_set(base, width);
12887 }
12888
12889 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
12890 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12891 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
12892 {
12893     TRACE("(%p %ld)\n", ret, width);
12894
12895     ret->pfunc = setw_func;
12896     ret->arg = width;
12897     return ret;
12898 }
12899
12900 static void __cdecl resetioflags_func(ios_base *base, int mask)
12901 {
12902     ios_base_setf_mask(base, 0, mask);
12903 }
12904
12905 /* ?resetiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12906 manip_int* __cdecl resetiosflags(manip_int *ret, int mask)
12907 {
12908     TRACE("(%p %d)\n", ret, mask);
12909
12910     ret->pfunc = resetioflags_func;
12911     ret->arg = mask;
12912     return ret;
12913 }
12914
12915 static void __cdecl setiosflags_func(ios_base *base, int mask)
12916 {
12917     ios_base_setf_mask(base, FMTFLAG_mask, mask);
12918 }
12919
12920 /* ?setiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12921 manip_int* __cdecl setiosflags(manip_int *ret, int mask)
12922 {
12923     TRACE("(%p %d)\n", ret, mask);
12924
12925     ret->pfunc = setiosflags_func;
12926     ret->arg = mask;
12927     return ret;
12928 }
12929
12930 static void __cdecl setbase_func(ios_base *base, int set_base)
12931 {
12932     if(set_base == 10)
12933         set_base = FMTFLAG_dec;
12934     else if(set_base == 8)
12935         set_base = FMTFLAG_oct;
12936     else if(set_base == 16)
12937         set_base = FMTFLAG_hex;
12938     else
12939         set_base = 0;
12940
12941     ios_base_setf_mask(base, set_base, FMTFLAG_basefield);
12942 }
12943
12944 /* ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z */
12945 manip_int* __cdecl setbase(manip_int *ret, int base)
12946 {
12947     TRACE("(%p %d)\n", ret, base);
12948
12949     ret->pfunc = setbase_func;
12950     ret->arg = base;
12951     return ret;
12952 }
12953
12954 static basic_filebuf_char filebuf_char_stdin;
12955 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
12956 struct {
12957     basic_istream_char obj;
12958     basic_ios_char vbase;
12959 } cin = { { 0 } };
12960 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
12961 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
12962 basic_istream_char *_Ptr_cin = &cin.obj;
12963
12964 static basic_filebuf_wchar filebuf_short_stdin;
12965 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
12966 struct {
12967     basic_istream_wchar obj;
12968     basic_ios_wchar vbase;
12969 } ucin = { { 0 } };
12970 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
12971 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
12972 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
12973
12974 static basic_filebuf_wchar filebuf_wchar_stdin;
12975 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12976 struct {
12977     basic_istream_wchar obj;
12978     basic_ios_wchar vbase;
12979 } wcin = { { 0 } };
12980 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12981 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
12982 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
12983
12984 static basic_filebuf_char filebuf_char_stdout;
12985 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12986 struct {
12987     basic_ostream_char obj;
12988     basic_ios_char vbase;
12989 } cout = { { 0 } };
12990 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12991 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12992 basic_ostream_char *_Ptr_cout = &cout.obj;
12993
12994 static basic_filebuf_wchar filebuf_short_stdout;
12995 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12996 struct {
12997     basic_ostream_wchar obj;
12998     basic_ios_wchar vbase;
12999 } ucout = { { 0 } };
13000 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
13001 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
13002 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
13003
13004 static basic_filebuf_wchar filebuf_wchar_stdout;
13005 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13006 struct {
13007     basic_ostream_wchar obj;
13008     basic_ios_wchar vbase;
13009 } wcout = { { 0 } };
13010 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13011 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
13012 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
13013
13014 static basic_filebuf_char filebuf_char_stderr;
13015 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
13016 struct {
13017     basic_ostream_char obj;
13018     basic_ios_char vbase;
13019 } cerr = { { 0 } };
13020 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
13021 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
13022 basic_ostream_char *_Ptr_cerr = &cerr.obj;
13023
13024 static basic_filebuf_wchar filebuf_short_stderr;
13025 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
13026 struct {
13027     basic_ostream_wchar obj;
13028     basic_ios_wchar vbase;
13029 } ucerr = { { 0 } };
13030 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
13031 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
13032 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
13033
13034 static basic_filebuf_wchar filebuf_wchar_stderr;
13035 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13036 struct {
13037     basic_ostream_wchar obj;
13038     basic_ios_wchar vbase;
13039 } wcerr = { { 0 } };
13040 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13041 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
13042 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
13043
13044 static basic_filebuf_char filebuf_char_log;
13045 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
13046 struct {
13047     basic_ostream_char obj;
13048     basic_ios_char vbase;
13049 } clog = { { 0 } };
13050 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
13051 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
13052 basic_ostream_char *_Ptr_clog = &clog.obj;
13053
13054 static basic_filebuf_wchar filebuf_short_log;
13055 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
13056 struct {
13057     basic_ostream_wchar obj;
13058     basic_ios_wchar vbase;
13059 } uclog = { { 0 } };
13060 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
13061 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
13062 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
13063
13064 static basic_filebuf_wchar filebuf_wchar_log;
13065 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13066 struct {
13067     basic_ostream_wchar obj;
13068     basic_ios_wchar vbase;
13069 } wclog = { { 0 } };
13070 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13071 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
13072 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
13073
13074 /* ?_Init_cnt@Init@ios_base@std@@0HA */
13075 int ios_base_Init__Init_cnt = -1;
13076
13077 /* ?_Init_cnt_func@Init@ios_base@std@@CAAAHXZ */
13078 /* ?_Init_cnt_func@Init@ios_base@std@@CAAEAHXZ */
13079 int* __cdecl ios_base_Init__Init_cnt_func(void)
13080 {
13081     return &ios_base_Init__Init_cnt;
13082 }
13083
13084 /* ?_Init_ctor@Init@ios_base@std@@CAXPAV123@@Z */
13085 /* ?_Init_ctor@Init@ios_base@std@@CAXPEAV123@@Z */
13086 void __cdecl ios_base_Init__Init_ctor(void *this)
13087 {
13088     TRACE("(%p)\n", this);
13089
13090     if(ios_base_Init__Init_cnt < 0)
13091         ios_base_Init__Init_cnt = 1;
13092     else
13093         ios_base_Init__Init_cnt++;
13094 }
13095
13096 /* ??0Init@ios_base@std@@QAE@XZ */
13097 /* ??0Init@ios_base@std@@QEAA@XZ */
13098 DEFINE_THISCALL_WRAPPER(ios_base_Init_ctor, 4)
13099 void* __thiscall ios_base_Init_ctor(void *this)
13100 {
13101     ios_base_Init__Init_ctor(this);
13102     return this;
13103 }
13104
13105 /* ?_Init_dtor@Init@ios_base@std@@CAXPAV123@@Z */
13106 /* ?_Init_dtor@Init@ios_base@std@@CAXPEAV123@@Z */
13107 void __cdecl ios_base_Init__Init_dtor(void *this)
13108 {
13109     TRACE("(%p)\n", this);
13110
13111     ios_base_Init__Init_cnt--;
13112     if(!ios_base_Init__Init_cnt) {
13113         basic_ostream_char_flush(&cout.obj);
13114         basic_ostream_char_flush(&cerr.obj);
13115         basic_ostream_char_flush(&clog.obj);
13116     }
13117 }
13118
13119 /* ??1Init@ios_base@std@@QAE@XZ */
13120 /* ??1Init@ios_base@std@@QEAA@XZ */
13121 DEFINE_THISCALL_WRAPPER(ios_base_Init_dtor, 4)
13122 void __thiscall ios_base_Init_dtor(void *this)
13123 {
13124     ios_base_Init__Init_dtor(this);
13125 }
13126
13127 /* ??4Init@ios_base@std@@QAEAAV012@ABV012@@Z */
13128 /* ??4Init@ios_base@std@@QEAAAEAV012@AEBV012@@Z */
13129 DEFINE_THISCALL_WRAPPER(ios_base_Init_op_assign, 8)
13130 void* __thiscall ios_base_Init_op_assign(void *this, void *rhs)
13131 {
13132     TRACE("(%p %p)\n", this, rhs);
13133     return this;
13134 }
13135
13136 /* ?_Init_cnt@_Winit@std@@0HA */
13137 int _Winit__Init_cnt = -1;
13138
13139 /* ??0_Winit@std@@QAE@XZ */
13140 /* ??0_Winit@std@@QEAA@XZ */
13141 DEFINE_THISCALL_WRAPPER(_Winit_ctor, 4)
13142 void* __thiscall _Winit_ctor(void *this)
13143 {
13144     TRACE("(%p)\n", this);
13145
13146     if(_Winit__Init_cnt < 0)
13147         _Winit__Init_cnt = 1;
13148     else
13149         _Winit__Init_cnt++;
13150
13151     return this;
13152 }
13153
13154 /* ??1_Winit@std@@QAE@XZ */
13155 /* ??1_Winit@std@@QAE@XZ */
13156 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)
13157 void __thiscall _Winit_dtor(void *this)
13158 {
13159     TRACE("(%p)\n", this);
13160
13161     _Winit__Init_cnt--;
13162     if(!_Winit__Init_cnt) {
13163         basic_ostream_wchar_flush(&wcout.obj);
13164         basic_ostream_wchar_flush(&wcerr.obj);
13165         basic_ostream_wchar_flush(&wclog.obj);
13166     }
13167 }
13168
13169 /* ??4_Winit@std@@QAEAAV01@ABV01@@Z */
13170 /* ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z */
13171 DEFINE_THISCALL_WRAPPER(_Winit_op_assign, 8)
13172 void* __thiscall _Winit_op_assign(void *this, void *rhs)
13173 {
13174     TRACE("(%p %p)\n", this, rhs);
13175     return this;
13176 }
13177
13178 void init_io(void *base)
13179 {
13180 #ifdef __x86_64__
13181     init_iosb_rtti(base);
13182     init_ios_base_rtti(base);
13183     init_basic_ios_char_rtti(base);
13184     init_basic_ios_wchar_rtti(base);
13185     init_basic_ios_short_rtti(base);
13186     init_basic_streambuf_char_rtti(base);
13187     init_basic_streambuf_wchar_rtti(base);
13188     init_basic_streambuf_short_rtti(base);
13189     init_basic_filebuf_char_rtti(base);
13190     init_basic_filebuf_wchar_rtti(base);
13191     init_basic_filebuf_short_rtti(base);
13192     init_basic_stringbuf_char_rtti(base);
13193     init_basic_stringbuf_wchar_rtti(base);
13194     init_basic_stringbuf_short_rtti(base);
13195     init_basic_ostream_char_rtti(base);
13196     init_basic_ostream_wchar_rtti(base);
13197     init_basic_ostream_short_rtti(base);
13198     init_basic_istream_char_rtti(base);
13199     init_basic_istream_wchar_rtti(base);
13200     init_basic_istream_short_rtti(base);
13201     init_basic_iostream_char_rtti(base);
13202     init_basic_iostream_wchar_rtti(base);
13203     init_basic_iostream_short_rtti(base);
13204     init_basic_ofstream_char_rtti(base);
13205     init_basic_ofstream_wchar_rtti(base);
13206     init_basic_ofstream_short_rtti(base);
13207     init_basic_ifstream_char_rtti(base);
13208     init_basic_ifstream_wchar_rtti(base);
13209     init_basic_ifstream_short_rtti(base);
13210     init_basic_fstream_char_rtti(base);
13211     init_basic_fstream_wchar_rtti(base);
13212     init_basic_fstream_short_rtti(base);
13213     init_basic_ostringstream_char_rtti(base);
13214     init_basic_ostringstream_wchar_rtti(base);
13215     init_basic_ostringstream_short_rtti(base);
13216     init_basic_istringstream_char_rtti(base);
13217     init_basic_istringstream_wchar_rtti(base);
13218     init_basic_istringstream_short_rtti(base);
13219     init_basic_stringstream_char_rtti(base);
13220     init_basic_stringstream_wchar_rtti(base);
13221     init_basic_stringstream_short_rtti(base);
13222     init_strstreambuf_rtti(base);
13223 #endif
13224
13225     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
13226     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
13227
13228     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
13229     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
13230
13231     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
13232     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
13233
13234     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
13235     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE);
13236
13237     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
13238     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE);
13239
13240     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
13241     basic_ostream_wchar_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE);
13242
13243     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
13244     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE);
13245
13246     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
13247     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE);
13248
13249     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
13250     basic_ostream_wchar_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE);
13251
13252     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
13253     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE);
13254
13255     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
13256     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE);
13257
13258     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
13259     basic_ostream_wchar_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE);
13260 }
13261
13262 void free_io(void)
13263 {
13264     basic_istream_char_vbase_dtor(&cin.obj);
13265     basic_filebuf_char_dtor(&filebuf_char_stdin);
13266
13267     basic_istream_wchar_vbase_dtor(&ucin.obj);
13268     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
13269
13270     basic_istream_wchar_vbase_dtor(&wcin.obj);
13271     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
13272
13273     basic_ostream_char_vbase_dtor(&cout.obj);
13274     basic_filebuf_char_dtor(&filebuf_char_stdout);
13275
13276     basic_ostream_wchar_vbase_dtor(&ucout.obj);
13277     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
13278
13279     basic_ostream_wchar_vbase_dtor(&wcout.obj);
13280     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
13281
13282     basic_ostream_char_vbase_dtor(&cerr.obj);
13283     basic_filebuf_char_dtor(&filebuf_char_stderr);
13284
13285     basic_ostream_wchar_vbase_dtor(&ucerr.obj);
13286     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
13287
13288     basic_ostream_wchar_vbase_dtor(&wcerr.obj);
13289     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
13290
13291     basic_ostream_char_vbase_dtor(&clog.obj);
13292     basic_filebuf_char_dtor(&filebuf_char_log);
13293
13294     basic_ostream_wchar_vbase_dtor(&uclog.obj);
13295     basic_filebuf_wchar_dtor(&filebuf_short_log);
13296
13297     basic_ostream_wchar_vbase_dtor(&wclog.obj);
13298     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
13299 }