msvcp90: Fixed RTTI structure on 64-bit systems.
[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 enum {
54     INITFL_new   = 0,
55     INITFL_open  = 1,
56     INITFL_close = 2
57 } basic_filebuf__Initfl;
58
59 typedef struct {
60     basic_streambuf_char base;
61     codecvt_char *cvt;
62     char putback;
63     MSVCP_bool wrotesome;
64     int state;
65     MSVCP_bool close;
66     FILE *file;
67 } basic_filebuf_char;
68
69 typedef struct {
70     basic_streambuf_wchar base;
71     codecvt_wchar *cvt;
72     wchar_t putback;
73     MSVCP_bool wrotesome;
74     int state;
75     MSVCP_bool close;
76     FILE *file;
77 } basic_filebuf_wchar;
78
79 typedef enum {
80     STRINGBUF_allocated = 1,
81     STRINGBUF_no_write = 2,
82     STRINGBUF_no_read = 4,
83     STRINGBUF_append = 8,
84     STRINGBUF_at_end = 16
85 } basic_stringbuf_state;
86
87 typedef struct {
88     basic_streambuf_char base;
89     char *seekhigh;
90     int state;
91     char allocator; /* empty struct */
92 } basic_stringbuf_char;
93
94 typedef struct {
95     basic_streambuf_wchar base;
96     wchar_t *seekhigh;
97     int state;
98     char allocator; /* empty struct */
99 } basic_stringbuf_wchar;
100
101 typedef struct {
102     ios_base base;
103     basic_streambuf_char *strbuf;
104     struct _basic_ostream_char *stream;
105     char fillch;
106 } basic_ios_char;
107
108 typedef struct {
109     ios_base base;
110     basic_streambuf_wchar *strbuf;
111     struct _basic_ostream_wchar *stream;
112     wchar_t fillch;
113 } basic_ios_wchar;
114
115 typedef struct _basic_ostream_char {
116     const int *vbtable;
117     /* virtual inheritance
118      * basic_ios_char basic_ios;
119      */
120 } basic_ostream_char;
121
122 typedef struct _basic_ostream_wchar {
123     const int *vbtable;
124     /* virtual inheritance
125      * basic_ios_wchar basic_ios;
126      */
127 } basic_ostream_wchar;
128
129 typedef struct {
130     const int *vbtable;
131     streamsize count;
132     /* virtual inheritance
133      * basic_ios_char basic_ios;
134      */
135 } basic_istream_char;
136
137 typedef struct {
138     const int *vbtable;
139     streamsize count;
140     /* virtual inheritance
141      * basic_ios_wchar basic_ios;
142      */
143 } basic_istream_wchar;
144
145 typedef struct {
146     basic_istream_char base1;
147     basic_ostream_char base2;
148     /* virtual inheritance
149      * basic_ios_char basic_ios;
150      */
151 } basic_iostream_char;
152
153 typedef struct {
154     basic_istream_wchar base1;
155     basic_ostream_wchar base2;
156     /* virtual inheritance
157      * basic_ios_wchar basic_ios;
158      */
159 } basic_iostream_wchar;
160
161 typedef struct {
162     basic_ostream_char base;
163     basic_filebuf_char filebuf;
164     /* virtual inheritance
165      * basic_ios_char basic_ios;
166      */
167 } basic_ofstream_char;
168
169 typedef struct {
170     basic_ostream_wchar base;
171     basic_filebuf_wchar filebuf;
172     /* virtual inheritance
173      * basic_ios_wchar basic_ios;
174      */
175 } basic_ofstream_wchar;
176
177 typedef struct {
178     basic_istream_char base;
179     basic_filebuf_char filebuf;
180     /* virtual inheritance
181      * basic_ios_char basic_ios;
182      */
183 } basic_ifstream_char;
184
185 typedef struct {
186     basic_istream_wchar base;
187     basic_filebuf_wchar filebuf;
188     /* virtual inheritance
189      * basic_ios_wchar basic_ios;
190      */
191 } basic_ifstream_wchar;
192
193 typedef struct {
194     basic_iostream_char base;
195     basic_filebuf_char filebuf;
196     /* virtual inheritance
197      * basic_ios_char basic_ios;
198      */
199 } basic_fstream_char;
200
201 typedef struct {
202     basic_iostream_wchar base;
203     basic_filebuf_wchar filebuf;
204     /* virtual inheritance
205      * basic_ios_char basic_ios;
206      */
207 } basic_fstream_wchar;
208
209 typedef struct {
210     basic_ostream_char base;
211     basic_stringbuf_char strbuf;
212     /* virtual inheritance
213      * basic_ios_char basic_ios;
214      */
215 } basic_ostringstream_char;
216
217 typedef struct {
218     basic_ostream_wchar base;
219     basic_stringbuf_wchar strbuf;
220     /* virtual inheritance
221      * basic_ios_wchar basic_ios;
222      */
223 } basic_ostringstream_wchar;
224
225 typedef struct {
226     basic_istream_char base;
227     basic_stringbuf_char strbuf;
228     /* virtual inheritance
229      * basic_ios_char basic_ios;
230      */
231 } basic_istringstream_char;
232
233 typedef struct {
234     basic_istream_wchar base;
235     basic_stringbuf_wchar strbuf;
236     /* virtual inheritance
237      * basic_ios_wchar basic_ios;
238      */
239 } basic_istringstream_wchar;
240
241 typedef struct {
242     basic_iostream_char base;
243     basic_stringbuf_char strbuf;
244     /* virtual inheritance
245      * basic_ios_char basic_ios;
246      */
247 } basic_stringstream_char;
248
249 typedef struct {
250     basic_iostream_wchar base;
251     basic_stringbuf_wchar strbuf;
252     /* virtual inheritance
253      * basic_ios_wchar basic_ios;
254      */
255 } basic_stringstream_wchar;
256
257 typedef enum {
258     STRSTATE_Allocated = 1,
259     STRSTATE_Constant = 2,
260     STRSTATE_Dynamic = 4,
261     STRSTATE_Frozen = 8
262 } strstreambuf__Strstate;
263
264 typedef struct {
265     basic_streambuf_char base;
266     streamsize minsize;
267     char *endsave;
268     char *seekhigh;
269     int strmode;
270     void* (__cdecl *palloc)(MSVCP_size_t);
271     void (__cdecl *pfree)(void*);
272 } strstreambuf;
273
274 extern const vtable_ptr MSVCP_iosb_vtable;
275
276 /* ??_7ios_base@std@@6B@ */
277 extern const vtable_ptr MSVCP_ios_base_vtable;
278
279 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
280 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
281
282 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
283 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
284
285 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
286 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
287
288 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
289 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
290
291 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
292 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
293
294 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
295 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
296
297 /* ??_7?$basic_filebuf@DU?$char_traits@D@std@@@std@@6B@ */
298 extern const vtable_ptr MSVCP_basic_filebuf_char_vtable;
299
300 /* ??_7?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@6B@ */
301 extern const vtable_ptr MSVCP_basic_filebuf_wchar_vtable;
302
303 /* ??_7?$basic_filebuf@GU?$char_traits@G@std@@@std@@6B@ */
304 extern const vtable_ptr MSVCP_basic_filebuf_short_vtable;
305
306 /* ??_7?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
307 extern const vtable_ptr MSVCP_basic_stringbuf_char_vtable;
308
309 /* ??_7?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
310 extern const vtable_ptr MSVCP_basic_stringbuf_wchar_vtable;
311
312 /* ??_7?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
313 extern const vtable_ptr MSVCP_basic_stringbuf_short_vtable;
314
315 /* ??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@ */
316 const int basic_ostream_char_vbtable[] = {0, sizeof(basic_ostream_char)};
317 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
318 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
319
320 /* ??_8?$basic_ostream@_WU?$char_traits@_W@std@@@std@@7B@ */
321 const int basic_ostream_wchar_vbtable[] = {0, sizeof(basic_ostream_wchar)};
322 /* ??_7?$basic_ostream@_WU?$char_traits@_W@std@@@std@@6B@ */
323 extern const vtable_ptr MSVCP_basic_ostream_wchar_vtable;
324
325 /* ??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@ */
326 const int basic_ostream_short_vbtable[] = {0, sizeof(basic_ostream_wchar)};
327 /* ??_7?$basic_ostream@GU?$char_traits@G@std@@@std@@6B@ */
328 extern const vtable_ptr MSVCP_basic_ostream_short_vtable;
329
330 /* ??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@ */
331 const int basic_istream_char_vbtable[] = {0, sizeof(basic_istream_char)};
332 /* ??_7?$basic_istream@DU?$char_traits@D@std@@@std@@6B@ */
333 extern const vtable_ptr MSVCP_basic_istream_char_vtable;
334
335 /* ??_8?$basic_istream@_WU?$char_traits@_W@std@@@std@@7B@ */
336 const int basic_istream_wchar_vbtable[] = {0, sizeof(basic_istream_wchar)};
337 /* ??_7?$basic_istream@_WU?$char_traits@_W@std@@@std@@6B@ */
338 extern const vtable_ptr MSVCP_basic_istream_wchar_vtable;
339
340 /* ??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@ */
341 const int basic_istream_short_vbtable[] = {0, sizeof(basic_istream_wchar)};
342 /* ??_7?$basic_istream@GU?$char_traits@G@std@@@std@@6B@ */
343 extern const vtable_ptr MSVCP_basic_istream_short_vtable;
344
345 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
346 const int basic_iostream_char_vbtable1[] = {0, sizeof(basic_iostream_char)};
347 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
348 const int basic_iostream_char_vbtable2[] = {0, sizeof(basic_iostream_char)-FIELD_OFFSET(basic_iostream_char, base2)};
349 /* ??_7?$basic_iostream@DU?$char_traits@D@std@@@std@@6B@ */
350 extern const vtable_ptr MSVCP_basic_iostream_char_vtable;
351
352 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
353 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
354 const int basic_iostream_wchar_vbtable1[] = {0, sizeof(basic_iostream_wchar)};
355 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
356 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
357 const int basic_iostream_wchar_vbtable2[] = {0, sizeof(basic_iostream_wchar)-FIELD_OFFSET(basic_iostream_wchar, base2)};
358 /* ??_7?$basic_iostream@_WU?$char_traits@_W@std@@@std@@6B@ */
359 extern const vtable_ptr MSVCP_basic_iostream_wchar_vtable;
360 /* ??_7?$basic_iostream@GU?$char_traits@G@std@@@std@@6B@ */
361 extern const vtable_ptr MSVCP_basic_iostream_short_vtable;
362
363 /* ??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@ */
364 const int basic_ofstream_char_vbtable[] = {0, sizeof(basic_ofstream_char)};
365 /* ??_7?$basic_ofstream@DU?$char_traits@D@std@@@std@@6B@ */
366 extern const vtable_ptr MSVCP_basic_ofstream_char_vtable;
367
368 /* ??_8?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@7B@ */
369 const int basic_ofstream_wchar_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
370 /* ??_7?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@6B@ */
371 extern const vtable_ptr MSVCP_basic_ofstream_wchar_vtable;
372
373 /* ??_8?$basic_ofstream@GU?$char_traits@G@std@@@std@@7B@ */
374 const int basic_ofstream_short_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
375 /* ??_7?$basic_ofstream@GU?$char_traits@G@std@@@std@@6B@ */
376 extern const vtable_ptr MSVCP_basic_ofstream_short_vtable;
377
378 /* ??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@ */
379 const int basic_ifstream_char_vbtable[] = {0, sizeof(basic_ifstream_char)};
380 /* ??_7?$basic_ifstream@DU?$char_traits@D@std@@@std@@6B@ */
381 extern const vtable_ptr MSVCP_basic_ifstream_char_vtable;
382
383 /* ??_8?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@7B@ */
384 const int basic_ifstream_wchar_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
385 /* ??_7?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@6B@ */
386 extern const vtable_ptr MSVCP_basic_ifstream_wchar_vtable;
387
388 /* ??_8?$basic_ifstream@GU?$char_traits@G@std@@@std@@7B@ */
389 const int basic_ifstream_short_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
390 /* ??_7?$basic_ifstream@GU?$char_traits@G@std@@@std@@6B@ */
391 extern const vtable_ptr MSVCP_basic_ifstream_short_vtable;
392
393 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
394 const int basic_fstream_char_vbtable1[] = {0, sizeof(basic_fstream_char)};
395 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
396 const int basic_fstream_char_vbtable2[] = {0, sizeof(basic_fstream_char)-FIELD_OFFSET(basic_fstream_char, base.base2)};
397 /* ??_7?$basic_fstream@DU?$char_traits@D@std@@@std@@6B@ */
398 extern const vtable_ptr MSVCP_basic_fstream_char_vtable;
399
400 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
401 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
402 const int basic_fstream_wchar_vbtable1[] = {0, sizeof(basic_fstream_wchar)};
403 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
404 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
405 const int basic_fstream_wchar_vbtable2[] = {0, sizeof(basic_fstream_wchar)-FIELD_OFFSET(basic_fstream_wchar, base.base2)};
406 /* ??_7?$basic_fstream@_WU?$char_traits@_W@std@@@std@@6B@ */
407 extern const vtable_ptr MSVCP_basic_fstream_wchar_vtable;
408 /* ??_7?$basic_fstream@GU?$char_traits@G@std@@@std@@6B@ */
409 extern const vtable_ptr MSVCP_basic_fstream_short_vtable;
410
411 /* ??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
412 const int basic_ostringstream_char_vbtable[] = {0, sizeof(basic_ostringstream_char)};
413 /* ??_7?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
414 extern const vtable_ptr MSVCP_basic_ostringstream_char_vtable;
415
416 /* ??_8?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
417 const int basic_ostringstream_wchar_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
418 /* ??_7?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
419 extern const vtable_ptr MSVCP_basic_ostringstream_wchar_vtable;
420
421 /* ??_8?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
422 const int basic_ostringstream_short_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
423 /* ??_7?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
424 extern const vtable_ptr MSVCP_basic_ostringstream_short_vtable;
425
426 /* ??_8?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
427 const int basic_istringstream_char_vbtable[] = {0, sizeof(basic_istringstream_char)};
428 /* ??_7?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
429 extern const vtable_ptr MSVCP_basic_istringstream_char_vtable;
430
431 /* ??_8?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
432 const int basic_istringstream_wchar_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
433 /* ??_7?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
434 extern const vtable_ptr MSVCP_basic_istringstream_wchar_vtable;
435
436 /* ??_8?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
437 const int basic_istringstream_short_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
438 /* ??_7?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
439 extern const vtable_ptr MSVCP_basic_istringstream_short_vtable;
440
441 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
442 const int basic_stringstream_char_vbtable1[] = {0, sizeof(basic_stringstream_char)};
443 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
444 const int basic_stringstream_char_vbtable2[] = {0, sizeof(basic_stringstream_char)-FIELD_OFFSET(basic_stringstream_char, base.base2)};
445 /* ??_7?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
446 extern const vtable_ptr MSVCP_basic_stringstream_char_vtable;
447
448 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
449 const int basic_stringstream_wchar_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
450 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
451 const int basic_stringstream_wchar_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
452 /* ??_7?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
453 extern const vtable_ptr MSVCP_basic_stringstream_wchar_vtable;
454
455 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
456 const int basic_stringstream_short_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
457 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
458 const int basic_stringstream_short_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
459 /* ??_7?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
460 extern const vtable_ptr MSVCP_basic_stringstream_short_vtable;
461
462 /* ??_7strstreambuf@std@@6B */
463 extern const vtable_ptr MSVCP_strstreambuf_vtable;
464
465 DEFINE_RTTI_DATA0(iosb, 0, ".?AV?$_Iosb@H@std@@");
466 DEFINE_RTTI_DATA1(ios_base, 0, &iosb_rtti_base_descriptor, ".?AV?$_Iosb@H@std@@");
467 DEFINE_RTTI_DATA2(basic_ios_char, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
468         ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@");
469 DEFINE_RTTI_DATA2(basic_ios_wchar, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
470         ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@");
471 DEFINE_RTTI_DATA2(basic_ios_short, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
472         ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@");
473 DEFINE_RTTI_DATA0(basic_streambuf_char, 0,
474         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@");
475 DEFINE_RTTI_DATA0(basic_streambuf_wchar, 0,
476         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@");
477 DEFINE_RTTI_DATA0(basic_streambuf_short, 0,
478         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@");
479 DEFINE_RTTI_DATA1(basic_filebuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
480         ".?AV?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@");
481 DEFINE_RTTI_DATA1(basic_filebuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
482         ".?AV?$basic_filebuf@GU?$char_traits@G@std@@@std@@");
483 DEFINE_RTTI_DATA1(basic_filebuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
484         ".?AV?$basic_filebuf@DU?$char_traits@D@std@@@std@@");
485 DEFINE_RTTI_DATA1(basic_stringbuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
486         ".?AV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
487 DEFINE_RTTI_DATA1(basic_stringbuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
488         ".?AV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
489 DEFINE_RTTI_DATA1(basic_stringbuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
490         ".?AV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
491 DEFINE_RTTI_DATA3(basic_ostream_char, sizeof(basic_ostream_char), &basic_ios_char_rtti_base_descriptor,
492         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
493         ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@");
494 DEFINE_RTTI_DATA3(basic_ostream_wchar, sizeof(basic_ostream_wchar), &basic_ios_wchar_rtti_base_descriptor,
495         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
496         ".?AV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@");
497 DEFINE_RTTI_DATA3(basic_ostream_short, sizeof(basic_ostream_wchar), &basic_ios_short_rtti_base_descriptor,
498         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
499         ".?AV?$basic_ostream@GU?$char_traits@G@std@@@std@@");
500 DEFINE_RTTI_DATA3(basic_istream_char, sizeof(basic_istream_char), &basic_ios_char_rtti_base_descriptor,
501         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
502         ".?AV?$basic_istream@DU?$char_traits@D@std@@@std@@");
503 DEFINE_RTTI_DATA3(basic_istream_wchar, sizeof(basic_istream_wchar), &basic_ios_wchar_rtti_base_descriptor,
504         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
505         ".?AV?$basic_istream@_WU?$char_traits@_W@std@@@std@@");
506 DEFINE_RTTI_DATA3(basic_istream_short, sizeof(basic_istream_wchar), &basic_ios_short_rtti_base_descriptor,
507         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
508         ".?AV?$basic_istream@GU?$char_traits@G@std@@@std@@");
509 DEFINE_RTTI_DATA8(basic_iostream_char, sizeof(basic_iostream_char),
510         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
511         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
512         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
513         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
514         ".?AV?$basic_iostream@DU?$char_traits@D@std@@@std@@");
515 DEFINE_RTTI_DATA8(basic_iostream_wchar, sizeof(basic_iostream_wchar),
516         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
517         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
518         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
519         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
520         ".?AV?$basic_iostream@_WU?$char_traits@_W@std@@@std@@");
521 DEFINE_RTTI_DATA8(basic_iostream_short, sizeof(basic_iostream_wchar),
522         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
523         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
524         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
525         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
526         ".?AV?$basic_iostream@GU?$char_traits@G@std@@@std@@");
527 DEFINE_RTTI_DATA4(basic_ofstream_char, sizeof(basic_ofstream_char),
528         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
529         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
530         ".?AV?$basic_ofstream@DU?$char_traits@D@std@@@std@@");
531 DEFINE_RTTI_DATA4(basic_ofstream_wchar, sizeof(basic_ofstream_wchar),
532         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
533         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
534         ".?AV?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@");
535 DEFINE_RTTI_DATA4(basic_ofstream_short, sizeof(basic_ofstream_wchar),
536         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
537         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
538         ".?AV?$basic_ofstream@GU?$char_traits@G@std@@@std@@");
539 DEFINE_RTTI_DATA4(basic_ifstream_char, sizeof(basic_ifstream_char),
540         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
541         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
542         ".?AV?$basic_ifstream@DU?$char_traits@D@std@@@std@@");
543 DEFINE_RTTI_DATA4(basic_ifstream_wchar, sizeof(basic_ifstream_wchar),
544         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
545         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
546         ".?AV?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@");
547 DEFINE_RTTI_DATA4(basic_ifstream_short, sizeof(basic_ifstream_wchar),
548         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
549         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
550         ".?AV?$basic_ifstream@GU?$char_traits@G@std@@@std@@");
551 DEFINE_RTTI_DATA8(basic_fstream_char, sizeof(basic_fstream_char),
552         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
553         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
554         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
555         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
556         ".?AV?$basic_fstream@DU?$char_traits@D@std@@@std@@");
557 DEFINE_RTTI_DATA8(basic_fstream_wchar, sizeof(basic_fstream_wchar),
558         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
559         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
560         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
561         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
562         ".?AV?$basic_fstream@_WU?$char_traits@_W@std@@@std@@");
563 DEFINE_RTTI_DATA8(basic_fstream_short, sizeof(basic_fstream_wchar),
564         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
565         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
566         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
567         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
568         ".?AV?$basic_fstream@GU?$char_traits@G@std@@@std@@");
569 DEFINE_RTTI_DATA4(basic_ostringstream_char, sizeof(basic_ostringstream_char),
570         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
571         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
572         ".?AV?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
573 DEFINE_RTTI_DATA4(basic_ostringstream_wchar, sizeof(basic_ostringstream_wchar),
574         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
575         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
576         ".?AV?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
577 DEFINE_RTTI_DATA4(basic_ostringstream_short, sizeof(basic_ostringstream_wchar),
578         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
579         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
580         ".?AV?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
581 DEFINE_RTTI_DATA4(basic_istringstream_char, sizeof(basic_istringstream_char),
582         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
583         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
584         ".?AV?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
585 DEFINE_RTTI_DATA4(basic_istringstream_wchar, sizeof(basic_istringstream_wchar),
586         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
587         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
588         ".?AV?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
589 DEFINE_RTTI_DATA4(basic_istringstream_short, sizeof(basic_istringstream_wchar),
590         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
591         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
592         ".?AV?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
593 DEFINE_RTTI_DATA8(basic_stringstream_char, sizeof(basic_stringstream_char),
594         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
595         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
596         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
597         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
598         ".?AV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
599 DEFINE_RTTI_DATA8(basic_stringstream_wchar, sizeof(basic_stringstream_wchar),
600         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
601         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
602         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
603         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
604         ".?AV?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
605 DEFINE_RTTI_DATA8(basic_stringstream_short, sizeof(basic_stringstream_wchar),
606         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
607         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
608         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
609         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
610         ".?AV?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
611 DEFINE_RTTI_DATA1(strstreambuf, sizeof(strstreambuf),
612         &basic_streambuf_char_rtti_base_descriptor, ".?AVstrstreambuf@std@@");
613
614 #ifndef __GNUC__
615 void __asm_dummy_vtables(void) {
616 #endif
617     __ASM_VTABLE(iosb,
618             VTABLE_ADD_FUNC(iosb_vector_dtor));
619     __ASM_VTABLE(ios_base,
620             VTABLE_ADD_FUNC(ios_base_vector_dtor));
621     __ASM_VTABLE(basic_ios_char,
622             VTABLE_ADD_FUNC(basic_ios_char_vector_dtor));
623     __ASM_VTABLE(basic_ios_wchar,
624             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
625     __ASM_VTABLE(basic_ios_short,
626             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
627     __ASM_VTABLE(basic_streambuf_char,
628             VTABLE_ADD_FUNC(basic_streambuf_char_vector_dtor)
629             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
630             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
631             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
632             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
633             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
634             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
635             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
636             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
637             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
638             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
639             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
640             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
641             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
642     __ASM_VTABLE(basic_streambuf_wchar,
643             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
644             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
645             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
646             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
647             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
648             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
649             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
650             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
651             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
652             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
653             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
654             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
655             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
656             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
657     __ASM_VTABLE(basic_streambuf_short,
658             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
659             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
660             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
661             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
662             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
663             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
664             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
665             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
666             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
667             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
668             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
669             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
670             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
671             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
672     __ASM_VTABLE(basic_filebuf_char,
673             VTABLE_ADD_FUNC(basic_filebuf_char_vector_dtor)
674             VTABLE_ADD_FUNC(basic_filebuf_char_overflow)
675             VTABLE_ADD_FUNC(basic_filebuf_char_pbackfail)
676             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
677             VTABLE_ADD_FUNC(basic_filebuf_char_underflow)
678             VTABLE_ADD_FUNC(basic_filebuf_char_uflow)
679             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
680             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
681             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
682             VTABLE_ADD_FUNC(basic_filebuf_char_seekoff)
683             VTABLE_ADD_FUNC(basic_filebuf_char_seekpos)
684             VTABLE_ADD_FUNC(basic_filebuf_char_setbuf)
685             VTABLE_ADD_FUNC(basic_filebuf_char_sync)
686             VTABLE_ADD_FUNC(basic_filebuf_char_imbue));
687     __ASM_VTABLE(basic_filebuf_wchar,
688             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
689             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
690             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
691             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
692             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
693             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
694             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
695             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
696             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
697             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
698             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
699             VTABLE_ADD_FUNC(basic_filebuf_wchar_setbuf)
700             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
701             VTABLE_ADD_FUNC(basic_filebuf_wchar_imbue));
702     __ASM_VTABLE(basic_filebuf_short,
703             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
704             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
705             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
706             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
707             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
708             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
709             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
710             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
711             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
712             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
713             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
714             VTABLE_ADD_FUNC(basic_filebuf_short_setbuf)
715             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
716             VTABLE_ADD_FUNC(basic_filebuf_short_imbue));
717     __ASM_VTABLE(basic_stringbuf_char,
718             VTABLE_ADD_FUNC(basic_stringbuf_char_vector_dtor)
719             VTABLE_ADD_FUNC(basic_stringbuf_char_overflow)
720             VTABLE_ADD_FUNC(basic_stringbuf_char_pbackfail)
721             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
722             VTABLE_ADD_FUNC(basic_stringbuf_char_underflow)
723             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
724             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
725             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
726             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
727             VTABLE_ADD_FUNC(basic_stringbuf_char_seekoff)
728             VTABLE_ADD_FUNC(basic_stringbuf_char_seekpos)
729             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
730             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
731             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
732     __ASM_VTABLE(basic_stringbuf_wchar,
733             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
734             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
735             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
736             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
737             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
738             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
739             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
740             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
741             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
742             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
743             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
744             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
745             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
746             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
747     __ASM_VTABLE(basic_stringbuf_short,
748             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
749             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
750             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
751             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
752             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
753             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
754             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
755             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
756             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
757             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
758             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
759             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
760             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
761             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
762     __ASM_VTABLE(basic_ostream_char,
763             VTABLE_ADD_FUNC(basic_ostream_char_vector_dtor));
764     __ASM_VTABLE(basic_ostream_wchar,
765             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
766     __ASM_VTABLE(basic_ostream_short,
767             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
768     __ASM_VTABLE(basic_istream_char,
769             VTABLE_ADD_FUNC(basic_istream_char_vector_dtor));
770     __ASM_VTABLE(basic_istream_wchar,
771             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
772     __ASM_VTABLE(basic_istream_short,
773             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
774     __ASM_VTABLE(basic_iostream_char,
775             VTABLE_ADD_FUNC(basic_iostream_char_vector_dtor));
776     __ASM_VTABLE(basic_iostream_wchar,
777             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
778     __ASM_VTABLE(basic_iostream_short,
779             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
780     __ASM_VTABLE(basic_ofstream_char,
781             VTABLE_ADD_FUNC(basic_ofstream_char_vector_dtor));
782     __ASM_VTABLE(basic_ofstream_wchar,
783             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
784     __ASM_VTABLE(basic_ofstream_short,
785             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
786     __ASM_VTABLE(basic_ifstream_char,
787             VTABLE_ADD_FUNC(basic_ifstream_char_vector_dtor));
788     __ASM_VTABLE(basic_ifstream_wchar,
789             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
790     __ASM_VTABLE(basic_ifstream_short,
791             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
792     __ASM_VTABLE(basic_fstream_char,
793             VTABLE_ADD_FUNC(basic_fstream_char_vector_dtor));
794     __ASM_VTABLE(basic_fstream_wchar,
795             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
796     __ASM_VTABLE(basic_fstream_short,
797             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
798     __ASM_VTABLE(basic_ostringstream_char,
799             VTABLE_ADD_FUNC(basic_ostringstream_char_vector_dtor));
800     __ASM_VTABLE(basic_ostringstream_wchar,
801             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
802     __ASM_VTABLE(basic_ostringstream_short,
803             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
804     __ASM_VTABLE(basic_istringstream_char,
805             VTABLE_ADD_FUNC(basic_istringstream_char_vector_dtor));
806     __ASM_VTABLE(basic_istringstream_wchar,
807             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
808     __ASM_VTABLE(basic_istringstream_short,
809             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
810     __ASM_VTABLE(basic_stringstream_char,
811             VTABLE_ADD_FUNC(basic_stringstream_char_vector_dtor));
812     __ASM_VTABLE(basic_stringstream_wchar,
813             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
814     __ASM_VTABLE(basic_stringstream_short,
815             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
816     __ASM_VTABLE(strstreambuf,
817             VTABLE_ADD_FUNC(strstreambuf_vector_dtor)
818             VTABLE_ADD_FUNC(strstreambuf_overflow)
819             VTABLE_ADD_FUNC(strstreambuf_pbackfail)
820             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
821             VTABLE_ADD_FUNC(strstreambuf_underflow)
822             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
823             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
824             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
825             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
826             VTABLE_ADD_FUNC(strstreambuf_seekoff)
827             VTABLE_ADD_FUNC(strstreambuf_seekpos)
828             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
829             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
830             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
831 #ifndef __GNUC__
832 }
833 #endif
834
835 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
836 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
837 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
838 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
839 {
840     TRACE("(%p %p %p %p)\n", this, first, next, last);
841
842     this->wbuf = first;
843     this->wpos = next;
844     this->wsize = last-next;
845 }
846
847 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
848 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
849 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
850 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
851 {
852     basic_streambuf_char_setp_next(this, first, first, last);
853 }
854
855 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
856 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
857 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
858 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
859 {
860     TRACE("(%p %p %p %p)\n", this, first, next, last);
861
862     this->rbuf = first;
863     this->rpos = next;
864     this->rsize = last-next;
865 }
866
867 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
868 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
869 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
870 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
871 {
872     TRACE("(%p)\n", this);
873
874     this->prbuf = &this->rbuf;
875     this->pwbuf = &this->wbuf;
876     this->prpos = &this->rpos;
877     this->pwpos = &this->wpos;
878     this->prsize = &this->rsize;
879     this->pwsize = &this->wsize;
880
881     basic_streambuf_char_setp(this, NULL, NULL);
882     basic_streambuf_char_setg(this, NULL, NULL, NULL);
883 }
884
885 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
886 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
887 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
888 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
889 {
890     TRACE("(%p %d)\n", this, uninitialized);
891     this->vtable = &MSVCP_basic_streambuf_char_vtable;
892     mutex_ctor(&this->lock);
893     return this;
894 }
895
896 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
897 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
898 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
899 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
900 {
901     TRACE("(%p)\n", this);
902
903     this->vtable = &MSVCP_basic_streambuf_char_vtable;
904     mutex_ctor(&this->lock);
905     this->loc = MSVCRT_operator_new(sizeof(locale));
906     locale_ctor(this->loc);
907     basic_streambuf_char__Init_empty(this);
908
909     return this;
910 }
911
912 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
913 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
914 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
915 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
916 {
917     TRACE("(%p)\n", this);
918
919     mutex_dtor(&this->lock);
920     locale_dtor(this->loc);
921     MSVCRT_operator_delete(this->loc);
922 }
923
924 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_vector_dtor, 8)
925 basic_streambuf_char* __thiscall basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
926 {
927     TRACE("(%p %x)\n", this, flags);
928     if(flags & 2) {
929         /* we have an array, with the number of elements stored before the first object */
930         INT_PTR i, *ptr = (INT_PTR *)this-1;
931
932         for(i=*ptr-1; i>=0; i--)
933             basic_streambuf_char_dtor(this+i);
934         MSVCRT_operator_delete(ptr);
935     } else {
936         basic_streambuf_char_dtor(this);
937         if(flags & 1)
938             MSVCRT_operator_delete(this);
939     }
940
941     return this;
942 }
943
944 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
945 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
946 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnavail, 4)
947 streamsize __thiscall basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
948 {
949     TRACE("(%p)\n", this);
950     return *this->prpos ? *this->prsize : 0;
951 }
952
953 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
954 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
955 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
956 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
957 {
958     TRACE("(%p)\n", this);
959     (*this->prsize)++;
960     (*this->prpos)--;
961     return *this->prpos;
962 }
963
964 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
965 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
966 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
967 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
968 {
969     TRACE("(%p)\n", this);
970     (*this->prsize)--;
971     return (*this->prpos)++;
972 }
973
974 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
975 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
976 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnpreinc, 4)
977 char* __thiscall basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
978 {
979     TRACE("(%p)\n", this);
980     (*this->prsize)--;
981     (*this->prpos)++;
982     return *this->prpos;
983 }
984
985 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
986 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
987 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
988 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
989 {
990     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
991
992     this->prbuf = gf;
993     this->pwbuf = pf;
994     this->prpos = gn;
995     this->pwpos = pn;
996     this->prsize = gc;
997     this->pwsize = pc;
998 }
999
1000 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1001 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1002 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Lock, 4)
1003 void __thiscall basic_streambuf_char__Lock(basic_streambuf_char *this)
1004 {
1005     TRACE("(%p)\n", this);
1006     mutex_lock(&this->lock);
1007 }
1008
1009 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
1010 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
1011 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pnavail, 4)
1012 streamsize __thiscall basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
1013 {
1014     TRACE("(%p)\n", this);
1015     return *this->pwpos ? *this->pwsize : 0;
1016 }
1017
1018 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1019 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1020 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
1021 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
1022 {
1023     TRACE("(%p)\n", this);
1024     (*this->pwsize)--;
1025     return (*this->pwpos)++;
1026 }
1027
1028 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1029 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1030 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
1031 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
1032         int, (basic_streambuf_char*), (this))
1033 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
1034 {
1035     TRACE("(%p)\n", this);
1036     return EOF;
1037 }
1038
1039 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1040 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1041 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
1042 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
1043         int, (basic_streambuf_char*), (this))
1044 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
1045 {
1046     int ret;
1047
1048     TRACE("(%p)\n", this);
1049
1050     if(call_basic_streambuf_char_underflow(this)==EOF)
1051         return EOF;
1052
1053     ret = **this->prpos;
1054     (*this->prsize)--;
1055     (*this->prpos)++;
1056     return ret;
1057 }
1058
1059 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
1060 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
1061 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Xsgetn_s, 16)
1062 #define call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
1063         streamsize, (basic_streambuf_char*, char*, MSVCP_size_t, streamsize), (this, ptr, size, count))
1064 streamsize __thiscall basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1065 {
1066     streamsize copied, chunk;
1067     int c;
1068
1069     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1070
1071     for(copied=0; copied<count && size;) {
1072         chunk = basic_streambuf_char__Gnavail(this);
1073         if(chunk > count-copied)
1074             chunk = count-copied;
1075
1076         if(chunk > 0) {
1077             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1078             *this->prpos += chunk;
1079             *this->prsize -= chunk;
1080             copied += chunk;
1081             size -= chunk;
1082         }else if((c = call_basic_streambuf_char_uflow(this)) != EOF) {
1083             ptr[copied] = c;
1084             copied++;
1085             size--;
1086         }else {
1087             break;
1088         }
1089     }
1090
1091     return copied;
1092 }
1093
1094 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
1095 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
1096 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Sgetn_s, 16)
1097 streamsize __thiscall basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1098 {
1099     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1100     return call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
1101 }
1102
1103 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1104 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1105 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Unlock, 4)
1106 void __thiscall basic_streambuf_char__Unlock(basic_streambuf_char *this)
1107 {
1108     TRACE("(%p)\n", this);
1109     mutex_unlock(&this->lock);
1110 }
1111
1112 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1113 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1114 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
1115 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
1116 {
1117     TRACE("(%p)\n", this);
1118     return *this->prbuf;
1119 }
1120
1121 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1122 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1123 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
1124 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
1125 {
1126     TRACE("(%p)\n", this);
1127     return *this->prpos;
1128 }
1129
1130 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1131 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1132 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
1133 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
1134 {
1135     TRACE("(%p)\n", this);
1136     return *this->prpos+*this->prsize;
1137 }
1138
1139 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1140 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1141 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
1142 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
1143 {
1144     TRACE("(%p)\n", this);
1145     return *this->pwpos+*this->pwsize;
1146 }
1147
1148 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1149 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1150 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
1151 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
1152 {
1153     TRACE("(%p %d)\n", this, off);
1154     *this->prpos += off;
1155     *this->prsize -= off;
1156 }
1157
1158 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QBE?AVlocale@2@XZ */
1159 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ */
1160 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_getloc, 8)
1161 locale* __thiscall basic_streambuf_char_getloc(const basic_streambuf_char *this, locale *ret)
1162 {
1163     TRACE("(%p)\n", this);
1164     return locale_copy_ctor(ret, this->loc);
1165 }
1166
1167 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
1168 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
1169 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
1170 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
1171         void, (basic_streambuf_char*, const locale*), (this, loc))
1172 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
1173 {
1174     TRACE("(%p %p)\n", this, loc);
1175 }
1176
1177 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1178 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1179 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
1180 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1181         int, (basic_streambuf_char*, int), (this, ch))
1182 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
1183 {
1184     TRACE("(%p %d)\n", this, ch);
1185     return EOF;
1186 }
1187
1188 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1189 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1190 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
1191 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1192         int, (basic_streambuf_char*, int), (this, ch))
1193 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
1194 {
1195     TRACE("(%p %d)\n", this, ch);
1196     return EOF;
1197 }
1198
1199 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1200 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1201 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
1202 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
1203 {
1204     TRACE("(%p)\n", this);
1205     return *this->pwbuf;
1206 }
1207
1208 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1209 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1210 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
1211 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
1212 {
1213     TRACE("(%p %d)\n", this, off);
1214     *this->pwpos += off;
1215     *this->pwsize -= off;
1216 }
1217
1218 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1219 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1220 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
1221 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
1222 {
1223     TRACE("(%p)\n", this);
1224     return *this->pwpos;
1225 }
1226
1227 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1228 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1229 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
1230 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
1231 {
1232     TRACE("(%p %p)\n", this, loc);
1233     memcpy(ret, this->loc, sizeof(locale));
1234     call_basic_streambuf_char_imbue(this, loc);
1235     locale_copy_ctor(this->loc, loc);
1236     return ret;
1237 }
1238
1239 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1240 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1241 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
1242 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
1243         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1244 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
1245         fpos_int *ret, streamoff off, int way, int mode)
1246 {
1247     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1248     ret->off = 0;
1249     ret->pos = -1;
1250     ret->state = 0;
1251     return ret;
1252 }
1253
1254 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1255 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1256 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff, 20)
1257 fpos_int* __thiscall basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
1258         fpos_int *ret, streamoff off, int way, int mode)
1259 {
1260     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1261     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
1262 }
1263
1264 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1265 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1266 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff_old, 20)
1267 fpos_int* __thiscall basic_streambuf_char_pubseekoff_old(basic_streambuf_char *this,
1268         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
1269 {
1270     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1271     return basic_streambuf_char_pubseekoff(this, ret, off, way, mode);
1272 }
1273
1274 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1275 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1276 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
1277 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
1278         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1279 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
1280         fpos_int *ret, fpos_int pos, int mode)
1281 {
1282     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1283     ret->off = 0;
1284     ret->pos = -1;
1285     ret->state = 0;
1286     return ret;
1287 }
1288
1289 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1290 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1291 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
1292 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
1293         fpos_int *ret, fpos_int pos, int mode)
1294 {
1295     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1296     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
1297 }
1298
1299 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1300 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1301 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos_old, 36)
1302 fpos_int* __thiscall basic_streambuf_char_pubseekpos_old(basic_streambuf_char *this,
1303         fpos_int *ret, fpos_int pos, unsigned int mode)
1304 {
1305     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1306     return basic_streambuf_char_pubseekpos(this, ret, pos, mode);
1307 }
1308
1309 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
1310 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
1311 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
1312 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
1313         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
1314 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
1315 {
1316     TRACE("(%p %p %ld)\n", this, buf, count);
1317     return this;
1318 }
1319
1320 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
1321 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
1322 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
1323 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
1324 {
1325     TRACE("(%p %p %ld)\n", this, buf, count);
1326     return call_basic_streambuf_char_setbuf(this, buf, count);
1327 }
1328
1329 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1330 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1331 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
1332 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 48, \
1333         int, (basic_streambuf_char*), (this))
1334 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
1335 {
1336     TRACE("(%p)\n", this);
1337     return 0;
1338 }
1339
1340 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1341 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1342 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
1343 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
1344 {
1345     TRACE("(%p)\n", this);
1346     return call_basic_streambuf_char_sync(this);
1347 }
1348
1349 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
1350 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
1351 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
1352 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1353 {
1354     TRACE("(%p %p %ld)\n", this, ptr, count);
1355     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1356 }
1357
1358 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1359 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
1360 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
1361 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1362         streamsize, (basic_streambuf_char*), (this))
1363 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
1364 {
1365     TRACE("(%p)\n", this);
1366     return 0;
1367 }
1368
1369 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1370 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
1371 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
1372 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
1373 {
1374     streamsize ret;
1375
1376     TRACE("(%p)\n", this);
1377
1378     ret = basic_streambuf_char__Gnavail(this);
1379     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
1380 }
1381
1382 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1383 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1384 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
1385 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
1386 {
1387     TRACE("(%p %d)\n", this, ch);
1388     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1389         (*this->prsize)++;
1390         (*this->prpos)--;
1391         return ch;
1392     }
1393
1394     return call_basic_streambuf_char_pbackfail(this, ch);
1395 }
1396
1397 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1398 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1399 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
1400 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
1401 {
1402     TRACE("(%p %d)\n", this, ch);
1403     return basic_streambuf_char__Pnavail(this) ?
1404         (*basic_streambuf_char__Pninc(this) = ch) :
1405         call_basic_streambuf_char_overflow(this, ch);
1406 }
1407
1408 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1409 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1410 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
1411 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
1412 {
1413     TRACE("(%p)\n", this);
1414     if(*this->prpos && *this->prpos>*this->prbuf) {
1415         (*this->prsize)++;
1416         (*this->prpos)--;
1417         return **this->prpos;
1418     }
1419
1420     return call_basic_streambuf_char_pbackfail(this, EOF);
1421 }
1422
1423 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1424 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1425 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1426 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1427 {
1428     TRACE("(%p)\n", this);
1429     if(basic_streambuf_char__Gnavail(this))
1430         basic_streambuf_char__Gninc(this);
1431     else
1432         call_basic_streambuf_char_uflow(this);
1433 }
1434
1435 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1436 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1437 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1438 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1439 {
1440     TRACE("(%p)\n", this);
1441     return basic_streambuf_char__Gnavail(this) ?
1442         *basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1443 }
1444
1445 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1446 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1447 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1448 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1449 {
1450     TRACE("(%p)\n", this);
1451     return basic_streambuf_char__Gnavail(this) ?
1452         *basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1453 }
1454
1455 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1456 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1457 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1458 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1459 {
1460     TRACE("(%p)\n", this);
1461
1462     if(basic_streambuf_char__Gnavail(this) > 1)
1463         return *basic_streambuf_char__Gnpreinc(this);
1464     return basic_streambuf_char_sbumpc(this)==EOF ?
1465         EOF : basic_streambuf_char_sgetc(this);
1466 }
1467
1468 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1469 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1470 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
1471 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1472         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1473 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1474 {
1475     TRACE("(%p %p %ld)\n", this, ptr, count);
1476     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1477 }
1478
1479 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1480 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1481 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
1482 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
1483         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1484 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1485 {
1486     streamsize copied, chunk;
1487
1488     TRACE("(%p %p %ld)\n", this, ptr, count);
1489
1490     for(copied=0; copied<count;) {
1491         chunk = basic_streambuf_char__Pnavail(this);
1492         if(chunk > count-copied)
1493             chunk = count-copied;
1494
1495         if(chunk > 0) {
1496             memcpy(*this->pwpos, ptr+copied, chunk);
1497             *this->pwpos += chunk;
1498             *this->pwsize -= chunk;
1499             copied += chunk;
1500         }else if(call_basic_streambuf_char_overflow(this, ptr[copied]) != EOF) {
1501             copied++;
1502         }else {
1503             break;
1504         }
1505     }
1506
1507     return copied;
1508 }
1509
1510 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1511 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1512 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
1513 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1514 {
1515     TRACE("(%p %p %ld)\n", this, ptr, count);
1516     return call_basic_streambuf_char_xsputn(this, ptr, count);
1517 }
1518
1519 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1520 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1521 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1522 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1523 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1524 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1525 {
1526     TRACE("(%p %p %p %p)\n", this, first, next, last);
1527
1528     this->wbuf = first;
1529     this->wpos = next;
1530     this->wsize = last-next;
1531 }
1532
1533 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1534 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1535 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1536 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1537 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1538 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1539 {
1540     basic_streambuf_wchar_setp_next(this, first, first, last);
1541 }
1542
1543 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1544 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1545 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1546 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1547 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1548 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1549 {
1550     TRACE("(%p %p %p %p)\n", this, first, next, last);
1551
1552     this->rbuf = first;
1553     this->rpos = next;
1554     this->rsize = last-next;
1555 }
1556
1557 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1558 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1559 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1560 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1561 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1562 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1563 {
1564     TRACE("(%p)\n", this);
1565
1566     this->prbuf = &this->rbuf;
1567     this->pwbuf = &this->wbuf;
1568     this->prpos = &this->rpos;
1569     this->pwpos = &this->wpos;
1570     this->prsize = &this->rsize;
1571     this->pwsize = &this->wsize;
1572
1573     basic_streambuf_wchar_setp(this, NULL, NULL);
1574     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1575 }
1576
1577 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1578 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1579 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor_uninitialized, 8)
1580 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1581 {
1582     TRACE("(%p %d)\n", this, uninitialized);
1583     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1584     mutex_ctor(&this->lock);
1585     return this;
1586 }
1587
1588 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1589 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1590 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1591 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1592 {
1593     TRACE("(%p %d)\n", this, uninitialized);
1594     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1595     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1596     return this;
1597 }
1598
1599 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1600 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1601 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor, 4)
1602 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1603 {
1604     TRACE("(%p)\n", this);
1605
1606     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1607     mutex_ctor(&this->lock);
1608     this->loc = MSVCRT_operator_new(sizeof(locale));
1609     locale_ctor(this->loc);
1610     basic_streambuf_wchar__Init_empty(this);
1611
1612     return this;
1613 }
1614
1615 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1616 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1617 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1618 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1619 {
1620     TRACE("(%p)\n", this);
1621     basic_streambuf_wchar_ctor(this);
1622     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1623     return this;
1624 }
1625
1626 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1627 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1628 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1629 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1630 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1631 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1632 {
1633     TRACE("(%p)\n", this);
1634
1635     mutex_dtor(&this->lock);
1636     locale_dtor(this->loc);
1637     MSVCRT_operator_delete(this->loc);
1638 }
1639
1640 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_vector_dtor, 8)
1641 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1642 {
1643     TRACE("(%p %x)\n", this, flags);
1644     if(flags & 2) {
1645         /* we have an array, with the number of elements stored before the first object */
1646         INT_PTR i, *ptr = (INT_PTR *)this-1;
1647
1648         for(i=*ptr-1; i>=0; i--)
1649             basic_streambuf_wchar_dtor(this+i);
1650         MSVCRT_operator_delete(ptr);
1651     } else {
1652         basic_streambuf_wchar_dtor(this);
1653         if(flags & 1)
1654             MSVCRT_operator_delete(this);
1655     }
1656
1657     return this;
1658 }
1659
1660 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1661 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1662 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1663 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1664 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnavail, 4)
1665 streamsize __thiscall basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1666 {
1667     TRACE("(%p)\n", this);
1668     return *this->prpos ? *this->prsize : 0;
1669 }
1670
1671 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1672 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1673 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1674 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1675 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1676 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1677 {
1678     TRACE("(%p)\n", this);
1679     (*this->prsize)++;
1680     (*this->prpos)--;
1681     return *this->prpos;
1682 }
1683
1684 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1685 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1686 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1687 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1688 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1689 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1690 {
1691     TRACE("(%p)\n", this);
1692     (*this->prsize)--;
1693     return (*this->prpos)++;
1694 }
1695
1696 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1697 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1698 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1699 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1700 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnpreinc, 4)
1701 wchar_t* __thiscall basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1702 {
1703     TRACE("(%p)\n", this);
1704     (*this->prsize)--;
1705     (*this->prpos)++;
1706     return *this->prpos;
1707 }
1708
1709 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1710 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1711 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1712 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1713 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1714 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)
1715 {
1716     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1717
1718     this->prbuf = gf;
1719     this->pwbuf = pf;
1720     this->prpos = gn;
1721     this->pwpos = pn;
1722     this->prsize = gc;
1723     this->pwsize = pc;
1724 }
1725
1726 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1727 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1728 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1729 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1730 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Lock, 4)
1731 void __thiscall basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1732 {
1733     TRACE("(%p)\n", this);
1734     mutex_lock(&this->lock);
1735 }
1736
1737 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1738 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1739 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1740 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1741 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pnavail, 4)
1742 streamsize __thiscall basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1743 {
1744     TRACE("(%p)\n", this);
1745     return *this->pwpos ? *this->pwsize : 0;
1746 }
1747
1748 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1749 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1750 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1751 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1752 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1753 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1754 {
1755     TRACE("(%p)\n", this);
1756     (*this->pwsize)--;
1757     return (*this->pwpos)++;
1758 }
1759
1760 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1761 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1762 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1763 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1764 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1765 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1766         unsigned short, (basic_streambuf_wchar*), (this))
1767 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1768 {
1769     TRACE("(%p)\n", this);
1770     return WEOF;
1771 }
1772
1773 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1774 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1775 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1776 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1777 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1778 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1779         unsigned short, (basic_streambuf_wchar*), (this))
1780 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1781 {
1782     int ret;
1783
1784     TRACE("(%p)\n", this);
1785
1786     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1787         return WEOF;
1788
1789     ret = **this->prpos;
1790     (*this->prsize)--;
1791     (*this->prpos)++;
1792     return ret;
1793 }
1794
1795 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1796 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1797 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1798 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1799 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Xsgetn_s, 16)
1800 #define call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
1801         streamsize, (basic_streambuf_wchar*, wchar_t*, MSVCP_size_t, streamsize), (this, ptr, size, count))
1802 streamsize __thiscall basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1803 {
1804     streamsize copied, chunk;
1805     unsigned short c;
1806
1807     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1808
1809     for(copied=0; copied<count && size;) {
1810         chunk = basic_streambuf_wchar__Gnavail(this);
1811         if(chunk > count-copied)
1812             chunk = count-copied;
1813
1814         if(chunk > 0) {
1815             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1816             *this->prpos += chunk;
1817             *this->prsize -= chunk;
1818             copied += chunk;
1819             size -= chunk;
1820         }else if((c = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1821             ptr[copied] = c;
1822             copied++;
1823             size--;
1824         }else {
1825             break;
1826         }
1827     }
1828
1829     return copied;
1830 }
1831
1832 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1833 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1834 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1835 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1836 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Sgetn_s, 16)
1837 streamsize __thiscall basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1838 {
1839     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1840     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1841 }
1842
1843 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1844 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1845 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1846 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1847 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Unlock, 4)
1848 void __thiscall basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1849 {
1850     TRACE("(%p)\n", this);
1851     mutex_unlock(&this->lock);
1852 }
1853
1854 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1855 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1856 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1857 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1858 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1859 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1860 {
1861     TRACE("(%p)\n", this);
1862     return *this->prbuf;
1863 }
1864
1865 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1866 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1867 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1868 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1869 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1870 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1871 {
1872     TRACE("(%p)\n", this);
1873     return *this->prpos;
1874 }
1875
1876 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1877 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1878 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1879 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1880 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1881 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1882 {
1883     TRACE("(%p)\n", this);
1884     return *this->prpos+*this->prsize;
1885 }
1886
1887 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1888 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1889 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1890 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1891 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1892 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1893 {
1894     TRACE("(%p)\n", this);
1895     return *this->pwpos+*this->pwsize;
1896 }
1897
1898 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1899 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1900 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1901 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1902 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1903 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1904 {
1905     TRACE("(%p %d)\n", this, off);
1906     *this->prpos += off;
1907     *this->prsize -= off;
1908 }
1909
1910 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QBE?AVlocale@2@XZ */
1911 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEBA?AVlocale@2@XZ */
1912 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QBE?AVlocale@2@XZ */
1913 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEBA?AVlocale@2@XZ */
1914 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
1915 locale* __thiscall basic_streambuf_wchar_getloc(const basic_streambuf_wchar *this, locale *ret)
1916 {
1917     TRACE("(%p)\n", this);
1918     return locale_copy_ctor(ret, this->loc);
1919 }
1920
1921 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1922 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1923 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1924 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1925 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1926 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
1927         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1928 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1929 {
1930     TRACE("(%p %p)\n", this, loc);
1931 }
1932
1933 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1934 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1935 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1936 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1937 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1938 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1939         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1940 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1941 {
1942     TRACE("(%p %d)\n", this, ch);
1943     return WEOF;
1944 }
1945
1946 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1947 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1948 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1949 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1950 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1951 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1952         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1953 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1954 {
1955     TRACE("(%p %d)\n", this, ch);
1956     return WEOF;
1957 }
1958
1959 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1960 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1961 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1962 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1963 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1964 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1965 {
1966     TRACE("(%p)\n", this);
1967     return *this->pwbuf;
1968 }
1969
1970 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1971 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1972 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1973 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1974 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1975 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1976 {
1977     TRACE("(%p %d)\n", this, off);
1978     *this->pwpos += off;
1979     *this->pwsize -= off;
1980 }
1981
1982 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1983 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1984 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1985 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1986 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1987 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1988 {
1989     TRACE("(%p)\n", this);
1990     return *this->pwpos;
1991 }
1992
1993 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1994 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1995 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1996 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1997 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
1998 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
1999 {
2000     TRACE("(%p %p)\n", this, loc);
2001     memcpy(ret, this->loc, sizeof(locale));
2002     call_basic_streambuf_wchar_imbue(this, loc);
2003     locale_copy_ctor(this->loc, loc);
2004     return ret;
2005 }
2006
2007 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2008 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2009 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2010 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2011 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
2012 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
2013         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
2014 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
2015         fpos_int *ret, streamoff off, int way, int mode)
2016 {
2017     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2018     ret->off = 0;
2019     ret->pos = -1;
2020     ret->state = 0;
2021     return ret;
2022 }
2023
2024 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2025 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2026 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2027 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2028 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff, 20)
2029 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
2030         fpos_int *ret, streamoff off, int way, int mode)
2031 {
2032     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2033     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
2034 }
2035
2036 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
2037 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
2038 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
2039 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
2040 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff_old, 20)
2041 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff_old(basic_streambuf_wchar *this,
2042         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
2043 {
2044     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2045     return basic_streambuf_wchar_pubseekoff(this, ret, off, way, mode);
2046 }
2047
2048 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2049 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2050 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2051 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2052 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
2053 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
2054         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
2055 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
2056         fpos_int *ret, fpos_int pos, int mode)
2057 {
2058     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2059     ret->off = 0;
2060     ret->pos = -1;
2061     ret->state = 0;
2062     return ret;
2063 }
2064
2065 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2066 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2067 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2068 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2069 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
2070 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
2071         fpos_int *ret, fpos_int pos, int mode)
2072 {
2073     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2074     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
2075 }
2076
2077 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
2078 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
2079 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
2080 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
2081 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos_old, 36)
2082 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos_old(basic_streambuf_wchar *this,
2083         fpos_int *ret, fpos_int pos, unsigned int mode)
2084 {
2085     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2086     return basic_streambuf_wchar_pubseekpos(this, ret, pos, mode);
2087 }
2088
2089 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
2090 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
2091 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
2092 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
2093 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
2094 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
2095         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
2096 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2097 {
2098     TRACE("(%p %p %ld)\n", this, buf, count);
2099     return this;
2100 }
2101
2102 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
2103 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
2104 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
2105 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
2106 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
2107 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2108 {
2109     TRACE("(%p %p %ld)\n", this, buf, count);
2110     return call_basic_streambuf_wchar_setbuf(this, buf, count);
2111 }
2112
2113 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2114 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2115 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2116 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2117 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
2118 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 48, \
2119         int, (basic_streambuf_wchar*), (this))
2120 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
2121 {
2122     TRACE("(%p)\n", this);
2123     return 0;
2124 }
2125
2126 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2127 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
2128 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2129 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
2130 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
2131 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
2132 {
2133     TRACE("(%p)\n", this);
2134     return call_basic_streambuf_wchar_sync(this);
2135 }
2136
2137 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
2138 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
2139 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
2140 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
2141 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
2142 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2143 {
2144     TRACE("(%p %p %ld)\n", this, ptr, count);
2145     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2146 }
2147
2148 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2149 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
2150 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2151 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
2152 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
2153 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
2154         streamsize, (basic_streambuf_wchar*), (this))
2155 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
2156 {
2157     TRACE("(%p)\n", this);
2158     return 0;
2159 }
2160
2161 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2162 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
2163 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2164 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
2165 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
2166 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
2167 {
2168     streamsize ret;
2169
2170     TRACE("(%p)\n", this);
2171
2172     ret = basic_streambuf_wchar__Gnavail(this);
2173     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
2174 }
2175
2176 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2177 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2178 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2179 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2180 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
2181 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
2182 {
2183     TRACE("(%p %d)\n", this, ch);
2184     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
2185         (*this->prsize)++;
2186         (*this->prpos)--;
2187         return ch;
2188     }
2189
2190     return call_basic_streambuf_wchar_pbackfail(this, ch);
2191 }
2192
2193 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2194 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2195 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2196 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
2197 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
2198 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
2199 {
2200     TRACE("(%p %d)\n", this, ch);
2201     return basic_streambuf_wchar__Pnavail(this) ?
2202         (*basic_streambuf_wchar__Pninc(this) = ch) :
2203         call_basic_streambuf_wchar_overflow(this, ch);
2204 }
2205
2206 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2207 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2208 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2209 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2210 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
2211 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
2212 {
2213     TRACE("(%p)\n", this);
2214     if(*this->prpos && *this->prpos>*this->prbuf) {
2215         (*this->prsize)++;
2216         (*this->prpos)--;
2217         return **this->prpos;
2218     }
2219
2220     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
2221 }
2222
2223 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2224 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2225 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2226 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2227 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
2228 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
2229 {
2230     TRACE("(%p)\n", this);
2231     if(basic_streambuf_wchar__Gnavail(this))
2232         basic_streambuf_wchar__Gninc(this);
2233     else
2234         call_basic_streambuf_wchar_uflow(this);
2235 }
2236
2237 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2238 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2239 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2240 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2241 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
2242 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
2243 {
2244     TRACE("(%p)\n", this);
2245     return basic_streambuf_wchar__Gnavail(this) ?
2246         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
2247 }
2248
2249 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2250 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2251 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2252 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2253 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
2254 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
2255 {
2256     TRACE("(%p)\n", this);
2257     return basic_streambuf_wchar__Gnavail(this) ?
2258         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
2259 }
2260
2261 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2262 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2263 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2264 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2265 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
2266 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
2267 {
2268     TRACE("(%p)\n", this);
2269
2270     if(basic_streambuf_wchar__Gnavail(this) > 1)
2271         return *basic_streambuf_wchar__Gnpreinc(this);
2272     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
2273         WEOF : basic_streambuf_wchar_sgetc(this);
2274 }
2275
2276 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
2277 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
2278 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
2279 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
2280 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
2281 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
2282         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
2283 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2284 {
2285     TRACE("(%p %p %ld)\n", this, ptr, count);
2286     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2287 }
2288
2289 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
2290 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
2291 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
2292 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
2293 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
2294 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
2295         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
2296 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2297 {
2298     streamsize copied, chunk;
2299
2300     TRACE("(%p %p %ld)\n", this, ptr, count);
2301
2302     for(copied=0; copied<count;) {
2303         chunk = basic_streambuf_wchar__Pnavail(this);
2304         if(chunk > count-copied)
2305             chunk = count-copied;
2306
2307         if(chunk > 0) {
2308             memcpy(*this->pwpos, ptr+copied, chunk);
2309             *this->pwpos += chunk;
2310             *this->pwsize -= chunk;
2311             copied += chunk;
2312         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
2313             copied++;
2314         }else {
2315             break;
2316         }
2317     }
2318
2319     return copied;
2320 }
2321
2322 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
2323 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
2324 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
2325 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
2326 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
2327 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2328 {
2329     TRACE("(%p %p %ld)\n", this, ptr, count);
2330     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
2331 }
2332
2333 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2334 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2335 int basic_filebuf_char__Init__Stinit = 0;
2336
2337 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2338 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2339 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
2340 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
2341 {
2342     TRACE("(%p %p %d)\n", this, file, which);
2343
2344     this->cvt = NULL;
2345     this->wrotesome = FALSE;
2346     this->state = basic_filebuf_char__Init__Stinit;
2347     this->close = (which == INITFL_open);
2348     this->file = file;
2349
2350     basic_streambuf_char__Init_empty(&this->base);
2351     if(file)
2352         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
2353                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
2354 }
2355
2356 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAV?$codecvt@DDH@2@@Z */
2357 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$codecvt@DDH@2@@Z */
2358 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Initcvt, 8)
2359 void __thiscall basic_filebuf_char__Initcvt(basic_filebuf_char *this, codecvt_char *cvt)
2360 {
2361     TRACE("(%p %p)\n", this, cvt);
2362
2363     if(codecvt_base_always_noconv(&cvt->base)) {
2364         this->cvt = NULL;
2365     }else {
2366         basic_streambuf_char__Init_empty(&this->base);
2367         this->cvt = cvt;
2368     }
2369 }
2370
2371 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAE_NXZ */
2372 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAA_NXZ */
2373 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Endwrite, 4)
2374 MSVCP_bool __thiscall basic_filebuf_char__Endwrite(basic_filebuf_char *this)
2375 {
2376     TRACE("(%p)\n", this);
2377
2378     if(!this->wrotesome || !this->cvt)
2379         return TRUE;
2380
2381
2382     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2383         return FALSE;
2384
2385     while(1) {
2386         /* TODO: check if we need a dynamic buffer here */
2387         char buf[128];
2388         char *next;
2389         int ret;
2390
2391         ret = codecvt_char_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2392         switch(ret) {
2393         case CODECVT_ok:
2394             this->wrotesome = FALSE;
2395             /* fall through */
2396         case CODECVT_partial:
2397             if(!fwrite(buf, next-buf, 1, this->file))
2398                 return FALSE;
2399             if(this->wrotesome)
2400                 break;
2401             /* fall through */
2402         case CODECVT_noconv:
2403             if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2404                 return FALSE;
2405             return TRUE;
2406         default:
2407             return FALSE;
2408         }
2409     }
2410 }
2411
2412 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2413 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2414 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2415 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2416 {
2417     basic_filebuf_char *ret = this;
2418
2419     TRACE("(%p)\n", this);
2420
2421     if(!this->file)
2422         return NULL;
2423
2424     /* TODO: handle exceptions */
2425     if(!basic_filebuf_char__Endwrite(this))
2426         ret = NULL;
2427     if(!fclose(this->file))
2428         ret  = NULL;
2429
2430     basic_filebuf_char__Init(this, NULL, INITFL_close);
2431     return ret;
2432 }
2433
2434 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2435 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2436 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2437 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2438 {
2439     TRACE("(%p %p)\n", this, file);
2440
2441     basic_streambuf_char_ctor(&this->base);
2442     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2443
2444     basic_filebuf_char__Init(this, file, INITFL_new);
2445     return this;
2446 }
2447
2448 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2449 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2450 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2451 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2452 {
2453     return basic_filebuf_char_ctor_file(this, NULL);
2454 }
2455
2456 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2457 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2458 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2459 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2460 {
2461     TRACE("(%p %d)\n", this, uninitialized);
2462
2463     basic_streambuf_char_ctor(&this->base);
2464     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2465     return this;
2466 }
2467
2468 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2469 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2470 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2471 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2472 {
2473     TRACE("(%p)\n", this);
2474
2475     if(this->close)
2476         basic_filebuf_char_close(this);
2477     basic_streambuf_char_dtor(&this->base);
2478 }
2479
2480 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2481 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2482 {
2483     TRACE("(%p %x)\n", this, flags);
2484     if(flags & 2) {
2485         /* we have an array, with the number of elements stored before the first object */
2486         INT_PTR i, *ptr = (INT_PTR *)this-1;
2487
2488         for(i=*ptr-1; i>=0; i--)
2489             basic_filebuf_char_dtor(this+i);
2490         MSVCRT_operator_delete(ptr);
2491     } else {
2492         basic_filebuf_char_dtor(this);
2493         if(flags & 1)
2494             MSVCRT_operator_delete(this);
2495     }
2496
2497     return this;
2498 }
2499
2500 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2501 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2502 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2503 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2504 {
2505     TRACE("(%p)\n", this);
2506     return this->file != NULL;
2507 }
2508
2509 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2510 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2511 FILE* __cdecl _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2512 {
2513     static const wchar_t rW[] = {'r',0};
2514     static const struct {
2515         int mode;
2516         const wchar_t str[4];
2517         const wchar_t str_bin[4];
2518     } str_mode[] = {
2519         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2520         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2521         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2522         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2523         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2524         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2525         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2526         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2527         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2528     };
2529
2530     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2531     int mode_idx;
2532     FILE *f = NULL;
2533
2534     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2535
2536     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2537         if(str_mode[mode_idx].mode == real_mode)
2538             break;
2539     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2540         return NULL;
2541
2542     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2543         return NULL;
2544     else if(f)
2545         fclose(f);
2546
2547     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2548             && (f = _wfopen(name, rW))) {
2549         fclose(f);
2550         return NULL;
2551     }
2552
2553     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2554             : str_mode[mode_idx].str, prot);
2555     if(!f)
2556         return NULL;
2557
2558     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2559         fclose(f);
2560         return NULL;
2561     }
2562
2563     return f;
2564 }
2565
2566 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2567 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2568 FILE* __cdecl _Fiopen(const char *name, int mode, int prot)
2569 {
2570     wchar_t nameW[FILENAME_MAX];
2571
2572     TRACE("(%s %d %d)\n", name, mode, prot);
2573
2574     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2575         return NULL;
2576     return _Fiopen_wchar(nameW, mode, prot);
2577 }
2578
2579 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2580 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2581 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2582 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2583 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_wchar, 16)
2584 basic_filebuf_char* __thiscall basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2585 {
2586     FILE *f = NULL;
2587
2588     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2589
2590     if(basic_filebuf_char_is_open(this))
2591         return NULL;
2592
2593     if(!(f = _Fiopen_wchar(name, mode, prot)))
2594         return NULL;
2595
2596     basic_filebuf_char__Init(this, f, INITFL_open);
2597     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(this->base.loc));
2598     return this;
2599 }
2600
2601 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WI@Z */
2602 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WI@Z */
2603 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGI@Z */
2604 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGI@Z */
2605 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_wchar_mode, 12)
2606 basic_filebuf_char* __thiscall basic_filebuf_char_open_wchar_mode(basic_filebuf_char *this, const wchar_t *name, unsigned int mode)
2607 {
2608     return basic_filebuf_char_open_wchar(this, name, mode, SH_DENYNO);
2609 }
2610
2611 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2612 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2613 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open, 16)
2614 basic_filebuf_char* __thiscall basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2615 {
2616     wchar_t nameW[FILENAME_MAX];
2617
2618     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2619
2620     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2621         return NULL;
2622     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2623 }
2624
2625 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDI@Z */
2626 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDI@Z */
2627 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2628 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, unsigned int mode)
2629 {
2630     return basic_filebuf_char_open(this, name, mode, SH_DENYNO);
2631 }
2632
2633 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2634 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2635 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2636 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2637 {
2638     char buf[8], *dyn_buf;
2639     char ch = c, *to_next;
2640     const char *from_next;
2641     int ret, max_size;
2642
2643
2644     TRACE("(%p %d)\n", this, c);
2645
2646     if(!basic_filebuf_char_is_open(this))
2647         return EOF;
2648     if(c == EOF)
2649         return !c;
2650
2651     if(!this->cvt)
2652         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2653
2654     from_next = &ch;
2655     do {
2656         ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2657                 &from_next, buf, buf+sizeof(buf), &to_next);
2658
2659         switch(ret) {
2660         case CODECVT_partial:
2661             if(to_next == buf)
2662                 break;
2663             /* fall through */
2664         case CODECVT_ok:
2665             if(!fwrite(buf, to_next-buf, 1, this->file))
2666                 return EOF;
2667             if(ret == CODECVT_partial)
2668                 continue;
2669             return c;
2670         case CODECVT_noconv:
2671             return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2672         default:
2673             return EOF;
2674         }
2675
2676         break;
2677     } while(1);
2678
2679     max_size = codecvt_base_max_length(&this->cvt->base);
2680     dyn_buf = malloc(max_size);
2681     if(!dyn_buf)
2682         return EOF;
2683
2684     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2685             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2686
2687     switch(ret) {
2688     case CODECVT_ok:
2689         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2690         free(dyn_buf);
2691         return ret ? c : EOF;
2692     case CODECVT_partial:
2693         ERR("buffer should be big enough to store all output\n");
2694         /* fall through */
2695     default:
2696         free(dyn_buf);
2697         return EOF;
2698     }
2699 }
2700
2701 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2702 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2703 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2704 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2705 {
2706     TRACE("(%p %d)\n", this, c);
2707
2708     if(!basic_filebuf_char_is_open(this))
2709         return EOF;
2710
2711     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2712             && (c==EOF || basic_streambuf_char_gptr(&this->base)[-1]==(char)c)) {
2713         basic_streambuf_char__Gndec(&this->base);
2714         return c==EOF ? !c : c;
2715     }else if(c!=EOF && !this->cvt) {
2716         return ungetc(c, this->file);
2717     }
2718
2719     return EOF;
2720 }
2721
2722 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2723 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2724 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2725 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2726 {
2727     char ch, buf[128], *to_next;
2728     const char *buf_next;
2729     int c, i;
2730
2731     TRACE("(%p)\n", this);
2732
2733     if(!basic_filebuf_char_is_open(this))
2734         return EOF;
2735
2736     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2737         return *basic_streambuf_char__Gninc(&this->base);
2738
2739     c = fgetc(this->file);
2740     if(!this->cvt || c==EOF)
2741         return c;
2742
2743     buf_next = buf;
2744     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
2745         buf[i] = c;
2746
2747         switch(codecvt_char_in(this->cvt, &this->state, buf_next,
2748                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2749         case CODECVT_partial:
2750         case CODECVT_ok:
2751             if(to_next == &ch) {
2752                 c = fgetc(this->file);
2753                 if(c == EOF)
2754                     return EOF;
2755                 continue;
2756             }
2757
2758             for(i--; i>=buf_next-buf; i--)
2759                 ungetc(buf[i], this->file);
2760             return ch;
2761         case CODECVT_noconv:
2762             return buf[0];
2763         default:
2764             return EOF;
2765         }
2766     }
2767
2768     FIXME("buffer is too small\n");
2769     return EOF;
2770 }
2771
2772 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2773 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2774 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2775 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2776 {
2777     int ret;
2778
2779     TRACE("(%p)\n", this);
2780
2781     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2782         return *basic_streambuf_char_gptr(&this->base);
2783
2784     ret = call_basic_streambuf_char_uflow(&this->base);
2785     if(ret != EOF)
2786         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2787     return ret;
2788 }
2789
2790 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2791 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2792 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2793 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2794         fpos_int *ret, streamoff off, int way, int mode)
2795 {
2796     fpos_t pos;
2797
2798     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2799
2800     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2801             || fseek(this->file, off, way)) {
2802         ret->off = 0;
2803         ret->pos = -1;
2804         ret->state = 0;
2805         return ret;
2806     }
2807
2808     fgetpos(this->file, &pos);
2809     ret->off = 0;
2810     ret->pos = pos;
2811     ret->state = this->state;
2812     return ret;
2813 }
2814
2815 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2816 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2817 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2818 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2819         fpos_int *ret, fpos_int pos, int mode)
2820 {
2821     fpos_t fpos;
2822
2823     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2824
2825     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2826             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2827             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2828         ret->off = 0;
2829         ret->pos = -1;
2830         ret->state = 0;
2831         return ret;
2832     }
2833
2834     fgetpos(this->file, &fpos);
2835     ret->off = 0;
2836     ret->pos = fpos;
2837     ret->state = this->state;
2838     return ret;
2839 }
2840
2841 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2842 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2843 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2844 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2845 {
2846     TRACE("(%p %p %ld)\n", this, buf, count);
2847
2848     if(!basic_filebuf_char_is_open(this))
2849         return NULL;
2850
2851     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2852         return NULL;
2853
2854     basic_filebuf_char__Init(this, this->file, INITFL_open);
2855     return &this->base;
2856 }
2857
2858 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2859 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2860 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2861 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2862 {
2863     TRACE("(%p)\n", this);
2864
2865     if(!basic_filebuf_char_is_open(this))
2866         return 0;
2867
2868     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2869         return 0;
2870     return fflush(this->file);
2871 }
2872
2873 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
2874 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
2875 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_imbue, 8)
2876 void __thiscall basic_filebuf_char_imbue(basic_filebuf_char *this, const locale *loc)
2877 {
2878     TRACE("(%p %p)\n", this, loc);
2879     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(loc));
2880 }
2881
2882 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2883 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2884 int basic_filebuf_wchar__Init__Stinit = 0;
2885
2886 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2887 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2888 int basic_filebuf_short__Init__Stinit = 0;
2889
2890 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2891 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2892 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Init, 12)
2893 void __thiscall basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2894 {
2895     TRACE("(%p %p %d)\n", this, file, which);
2896
2897     this->cvt = NULL;
2898     this->wrotesome = FALSE;
2899     this->state = basic_filebuf_wchar__Init__Stinit;
2900     this->close = (which == INITFL_open);
2901     this->file = file;
2902
2903     basic_streambuf_wchar__Init_empty(&this->base);
2904 }
2905
2906 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2907 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2908 DEFINE_THISCALL_WRAPPER(basic_filebuf_short__Init, 12)
2909 void __thiscall basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2910 {
2911     TRACE("(%p %p %d)\n", this, file, which);
2912
2913     this->cvt = NULL;
2914     this->wrotesome = FALSE;
2915     this->state = basic_filebuf_short__Init__Stinit;
2916     this->close = (which == INITFL_open);
2917     this->file = file;
2918
2919     basic_streambuf_wchar__Init_empty(&this->base);
2920 }
2921
2922 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$codecvt@_WDH@2@@Z */
2923 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$codecvt@_WDH@2@@Z */
2924 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAV?$codecvt@GDH@2@@Z */
2925 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$codecvt@GDH@2@@Z */
2926 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Initcvt, 8)
2927 void __thiscall basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this, codecvt_wchar *cvt)
2928 {
2929     TRACE("(%p %p)\n", this, cvt);
2930
2931     if(codecvt_base_always_noconv(&cvt->base)) {
2932         this->cvt = NULL;
2933     }else {
2934         basic_streambuf_wchar__Init_empty(&this->base);
2935         this->cvt = cvt;
2936     }
2937 }
2938
2939 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAE_NXZ */
2940 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAA_NXZ */
2941 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAE_NXZ */
2942 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAA_NXZ */
2943 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Endwrite, 4)
2944 MSVCP_bool __thiscall basic_filebuf_wchar__Endwrite(basic_filebuf_wchar *this)
2945 {
2946     TRACE("(%p)\n", this);
2947
2948     if(!this->wrotesome || !this->cvt)
2949         return TRUE;
2950
2951     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2952         return FALSE;
2953
2954     while(1) {
2955         /* TODO: check if we need a dynamic buffer here */
2956         char buf[128];
2957         char *next;
2958         int ret;
2959
2960         ret = codecvt_wchar_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2961         switch(ret) {
2962         case CODECVT_ok:
2963             this->wrotesome = FALSE;
2964             /* fall through */
2965         case CODECVT_partial:
2966             if(!fwrite(buf, next-buf, 1, this->file))
2967                 return FALSE;
2968             if(this->wrotesome)
2969                 break;
2970             /* fall through */
2971         case CODECVT_noconv:
2972             if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2973                 return FALSE;
2974             return TRUE;
2975         default:
2976             return FALSE;
2977         }
2978     }
2979 }
2980
2981 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
2982 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
2983 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
2984 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
2985 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_close, 4)
2986 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_close(basic_filebuf_wchar *this)
2987 {
2988     basic_filebuf_wchar *ret = this;
2989
2990     TRACE("(%p)\n", this);
2991
2992     if(!this->file)
2993         return NULL;
2994
2995     /* TODO: handle exceptions */
2996     if(!basic_filebuf_wchar__Endwrite(this))
2997         ret = NULL;
2998     if(!fclose(this->file))
2999         ret  = NULL;
3000
3001     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
3002     return ret;
3003 }
3004
3005 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
3006 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
3007 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor_file, 8)
3008 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
3009 {
3010     TRACE("(%p %p)\n", this, file);
3011
3012     basic_streambuf_wchar_ctor(&this->base);
3013     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
3014
3015     basic_filebuf_wchar__Init(this, file, INITFL_new);
3016     return this;
3017 }
3018
3019 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
3020 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
3021 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_file, 8)
3022 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
3023 {
3024     TRACE("(%p %p)\n", this, file);
3025
3026     basic_streambuf_short_ctor(&this->base);
3027     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3028
3029     basic_filebuf_short__Init(this, file, INITFL_new);
3030     return this;
3031 }
3032
3033 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
3034 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
3035 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor, 4)
3036 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor(basic_filebuf_wchar *this)
3037 {
3038     return basic_filebuf_wchar_ctor_file(this, NULL);
3039 }
3040
3041 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
3042 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
3043 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor, 4)
3044 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor(basic_filebuf_wchar *this)
3045 {
3046     return basic_filebuf_short_ctor_file(this, NULL);
3047 }
3048
3049 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3050 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3051 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor_uninitialized, 8)
3052 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
3053 {
3054     TRACE("(%p %d)\n", this, uninitialized);
3055
3056     basic_streambuf_wchar_ctor(&this->base);
3057     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
3058     return this;
3059 }
3060
3061 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3062 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3063 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_uninitialized, 8)
3064 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
3065 {
3066     TRACE("(%p %d)\n", this, uninitialized);
3067
3068     basic_streambuf_short_ctor(&this->base);
3069     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3070     return this;
3071 }
3072
3073 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
3074 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
3075 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
3076 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
3077 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_dtor, 4)
3078 void __thiscall basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
3079 {
3080     TRACE("(%p)\n", this);
3081
3082     if(this->close)
3083         basic_filebuf_wchar_close(this);
3084     basic_streambuf_wchar_dtor(&this->base);
3085 }
3086
3087 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
3088 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
3089 {
3090     TRACE("(%p %x)\n", this, flags);
3091     if(flags & 2) {
3092         /* we have an array, with the number of elements stored before the first object */
3093         INT_PTR i, *ptr = (INT_PTR *)this-1;
3094
3095         for(i=*ptr-1; i>=0; i--)
3096             basic_filebuf_wchar_dtor(this+i);
3097         MSVCRT_operator_delete(ptr);
3098     } else {
3099         basic_filebuf_wchar_dtor(this);
3100         if(flags & 1)
3101             MSVCRT_operator_delete(this);
3102     }
3103
3104     return this;
3105 }
3106
3107 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
3108 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
3109 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
3110 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
3111 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_is_open, 4)
3112 MSVCP_bool __thiscall basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
3113 {
3114     TRACE("(%p)\n", this);
3115     return this->file != NULL;
3116 }
3117
3118 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WHH@Z */
3119 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3120 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGHH@Z */
3121 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3122 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_wchar, 16)
3123 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3124 {
3125     FILE *f = NULL;
3126
3127     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3128
3129     if(basic_filebuf_wchar_is_open(this))
3130         return NULL;
3131
3132     if(!(f = _Fiopen_wchar(name, mode, prot)))
3133         return NULL;
3134
3135     basic_filebuf_wchar__Init(this, f, INITFL_open);
3136     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(this->base.loc));
3137     return this;
3138 }
3139
3140 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PB_WHH@Z */
3141 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3142 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBGHH@Z */
3143 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3144 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_wchar, 16)
3145 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3146 {
3147     FILE *f = NULL;
3148
3149     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3150
3151     if(basic_filebuf_wchar_is_open(this))
3152         return NULL;
3153
3154     if(!(f = _Fiopen_wchar(name, mode, prot)))
3155         return NULL;
3156
3157     basic_filebuf_short__Init(this, f, INITFL_open);
3158     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(this->base.loc));
3159     return this;
3160 }
3161
3162 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WI@Z */
3163 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WI@Z */
3164 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGI@Z */
3165 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGI@Z */
3166 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_wchar_mode, 12)
3167 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_wchar_mode(basic_filebuf_wchar *this, const wchar_t *name, unsigned int mode)
3168 {
3169     return basic_filebuf_wchar_open_wchar(this, name, mode, SH_DENYNO);
3170 }
3171
3172 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PB_WI@Z */
3173 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEB_WI@Z */
3174 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBGI@Z */
3175 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBGI@Z */
3176 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_wchar_mode, 12)
3177 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_wchar_mode(basic_filebuf_wchar *this, const wchar_t *name, unsigned int mode)
3178 {
3179     return basic_filebuf_short_open_wchar(this, name, mode, SH_DENYNO);
3180 }
3181
3182 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDHH@Z */
3183 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3184 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open, 16)
3185 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3186 {
3187     wchar_t nameW[FILENAME_MAX];
3188
3189     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3190
3191     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3192         return NULL;
3193     return basic_filebuf_wchar_open_wchar(this, nameW, mode, prot);
3194 }
3195
3196 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDHH@Z */
3197 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3198 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open, 16)
3199 basic_filebuf_wchar* __thiscall basic_filebuf_short_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3200 {
3201     wchar_t nameW[FILENAME_MAX];
3202
3203     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3204
3205     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3206         return NULL;
3207     return basic_filebuf_short_open_wchar(this, nameW, mode, prot);
3208 }
3209
3210 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDI@Z */
3211 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDI@Z */
3212 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode, 12)
3213 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode(basic_filebuf_wchar *this, const char *name, unsigned int mode)
3214 {
3215     return basic_filebuf_wchar_open(this, name, mode, SH_DENYNO);
3216 }
3217
3218 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDI@Z */
3219 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDI@Z */
3220 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_mode, 12)
3221 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_mode(basic_filebuf_wchar *this, const char *name, unsigned int mode)
3222 {
3223     return basic_filebuf_short_open(this, name, mode, SH_DENYNO);
3224 }
3225
3226 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3227 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3228 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3229 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3230 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
3231 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
3232 {
3233     char buf[8], *dyn_buf, *to_next;
3234     wchar_t ch = c;
3235     const wchar_t *from_next;
3236     int max_size;
3237     unsigned short ret;
3238
3239
3240     TRACE("(%p %d)\n", this, c);
3241
3242     if(!basic_filebuf_wchar_is_open(this))
3243         return WEOF;
3244     if(c == WEOF)
3245         return !c;
3246
3247     if(!this->cvt)
3248         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3249
3250     from_next = &ch;
3251     do {
3252         ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3253                 &from_next, buf, buf+sizeof(buf), &to_next);
3254
3255         switch(ret) {
3256         case CODECVT_partial:
3257             if(to_next == buf)
3258                 break;
3259             /* fall through */
3260         case CODECVT_ok:
3261             if(!fwrite(buf, to_next-buf, 1, this->file))
3262                 return WEOF;
3263             if(ret == CODECVT_partial)
3264                 continue;
3265             return c;
3266         case CODECVT_noconv:
3267             return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3268         default:
3269             return WEOF;
3270         }
3271
3272         break;
3273     } while(1);
3274
3275     max_size = codecvt_base_max_length(&this->cvt->base);
3276     dyn_buf = malloc(max_size);
3277     if(!dyn_buf)
3278         return WEOF;
3279
3280     ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3281             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
3282
3283     switch(ret) {
3284     case CODECVT_ok:
3285         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
3286         free(dyn_buf);
3287         return ret ? c : WEOF;
3288     case CODECVT_partial:
3289         ERR("buffer should be big enough to store all output\n");
3290         /* fall through */
3291     default:
3292         free(dyn_buf);
3293         return WEOF;
3294     }
3295 }
3296
3297 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3298 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3299 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3300 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3301 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
3302 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
3303 {
3304     TRACE("(%p %d)\n", this, c);
3305
3306     if(!basic_filebuf_wchar_is_open(this))
3307         return WEOF;
3308
3309     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
3310             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==(wchar_t)c)) {
3311         basic_streambuf_wchar__Gndec(&this->base);
3312         return c==WEOF ? !c : c;
3313     }else if(c!=WEOF && !this->cvt) {
3314         return ungetwc(c, this->file);
3315     }else if(c!=WEOF && basic_streambuf_wchar_gptr(&this->base)!=&this->putback) {
3316         this->putback = c;
3317         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback, &this->putback+1);
3318         return c;
3319     }
3320
3321     return WEOF;
3322 }
3323
3324 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3325 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3326 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3327 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3328 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
3329 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
3330 {
3331     wchar_t ch, *to_next;
3332     char buf[128];
3333     const char *buf_next;
3334     int c, i;
3335
3336     TRACE("(%p)\n", this);
3337
3338     if(!basic_filebuf_wchar_is_open(this))
3339         return WEOF;
3340
3341     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3342         return *basic_streambuf_wchar__Gninc(&this->base);
3343
3344     if(!this->cvt)
3345         return fgetwc(this->file);
3346
3347     buf_next = buf;
3348     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
3349         if((c = fgetc(this->file)) == EOF)
3350             return WEOF;
3351         buf[i] = c;
3352
3353         switch(codecvt_wchar_in(this->cvt, &this->state, buf_next,
3354                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
3355         case CODECVT_partial:
3356         case CODECVT_ok:
3357             if(to_next == &ch)
3358                 continue;
3359
3360             for(i--; i>=buf_next-buf; i--)
3361                 ungetc(buf[i], this->file);
3362             return ch;
3363         case CODECVT_noconv:
3364             if(i+1 < sizeof(wchar_t))
3365                 continue;
3366
3367             memcpy(&ch, buf, sizeof(wchar_t));
3368             return ch;
3369         default:
3370             return WEOF;
3371         }
3372     }
3373
3374     FIXME("buffer is too small\n");
3375     return WEOF;
3376 }
3377
3378 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3379 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3380 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3381 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3382 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
3383 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
3384 {
3385     unsigned short ret;
3386
3387     TRACE("(%p)\n", this);
3388
3389     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3390         return *basic_streambuf_wchar_gptr(&this->base);
3391
3392     ret = call_basic_streambuf_wchar_uflow(&this->base);
3393     if(ret != WEOF)
3394         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
3395     return ret;
3396 }
3397
3398 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3399 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3400 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3401 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3402 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 20)
3403 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
3404         fpos_int *ret, streamoff off, int way, int mode)
3405 {
3406     fpos_t pos;
3407
3408     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3409
3410     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback) {
3411         if(way == SEEKDIR_cur)
3412             off -= sizeof(wchar_t);
3413
3414         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3415     }
3416
3417     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3418             || fseek(this->file, off, way)) {
3419         ret->off = 0;
3420         ret->pos = -1;
3421         ret->state = 0;
3422         return ret;
3423     }
3424
3425     fgetpos(this->file, &pos);
3426     ret->off = 0;
3427     ret->pos = pos;
3428     ret->state = this->state;
3429     return ret;
3430 }
3431
3432 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3433 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3434 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3435 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3436 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
3437 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
3438         fpos_int *ret, fpos_int pos, int mode)
3439 {
3440     fpos_t fpos;
3441
3442     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3443
3444     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3445             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
3446             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
3447         ret->off = 0;
3448         ret->pos = -1;
3449         ret->state = 0;
3450         return ret;
3451     }
3452
3453     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback)
3454         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3455
3456     fgetpos(this->file, &fpos);
3457     ret->off = 0;
3458     ret->pos = fpos;
3459     ret->state = this->state;
3460     return ret;
3461 }
3462
3463 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
3464 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
3465 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 12)
3466 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3467 {
3468     TRACE("(%p %p %ld)\n", this, buf, count);
3469
3470     if(!basic_filebuf_wchar_is_open(this))
3471         return NULL;
3472
3473     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3474         return NULL;
3475
3476     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
3477     return &this->base;
3478 }
3479
3480 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
3481 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
3482 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 12)
3483 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3484 {
3485     TRACE("(%p %p %ld)\n", this, buf, count);
3486
3487     if(!basic_filebuf_wchar_is_open(this))
3488         return NULL;
3489
3490     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3491         return NULL;
3492
3493     basic_filebuf_short__Init(this, this->file, INITFL_open);
3494     return &this->base;
3495 }
3496
3497 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
3498 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
3499 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
3500 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
3501 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
3502 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
3503 {
3504     TRACE("(%p)\n", this);
3505
3506     if(!basic_filebuf_wchar_is_open(this))
3507         return 0;
3508
3509     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
3510         return 0;
3511     return fflush(this->file);
3512 }
3513
3514 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
3515 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
3516 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_imbue, 8)
3517 void __thiscall basic_filebuf_wchar_imbue(basic_filebuf_wchar *this, const locale *loc)
3518 {
3519     TRACE("(%p %p)\n", this, loc);
3520     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(loc));
3521 }
3522
3523 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
3524 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
3525 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_imbue, 8)
3526 void __thiscall basic_filebuf_short_imbue(basic_filebuf_wchar *this, const locale *loc)
3527 {
3528     TRACE("(%p %p)\n", this, loc);
3529     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(loc));
3530 }
3531
3532 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3533 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3534 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Getstate, 8)
3535 int __thiscall basic_stringbuf_char__Getstate(basic_stringbuf_char *this, IOSB_openmode mode)
3536 {
3537     int state = 0;
3538
3539     if(!(mode & OPENMODE_in))
3540         state |= STRINGBUF_no_read;
3541
3542     if(!(mode & OPENMODE_out))
3543         state |= STRINGBUF_no_write;
3544
3545     if(mode & OPENMODE_ate)
3546         state |= STRINGBUF_at_end;
3547
3548     if(mode & OPENMODE_app)
3549         state |= STRINGBUF_append;
3550
3551     return state;
3552 }
3553
3554 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXPBDIH@Z */
3555 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXPEBD_KH@Z */
3556 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Init, 16)
3557 void __thiscall basic_stringbuf_char__Init(basic_stringbuf_char *this, const char *str, MSVCP_size_t count, int state)
3558 {
3559     TRACE("(%p, %p, %ld, %d)\n", this, str, count, state);
3560
3561     basic_streambuf_char__Init_empty(&this->base);
3562
3563     this->state = state;
3564     this->seekhigh = NULL;
3565
3566     if(count && str) {
3567         char *buf = MSVCRT_operator_new(count);
3568         if(!buf) {
3569             ERR("Out of memory\n");
3570             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3571         }
3572
3573         memcpy(buf, str, count);
3574         this->seekhigh = buf + count;
3575
3576         this->state |= STRINGBUF_allocated;
3577
3578         if(!(state & STRINGBUF_no_read))
3579             basic_streambuf_char_setg(&this->base, buf, buf, buf + count);
3580
3581         if(!(state & STRINGBUF_no_write)) {
3582             basic_streambuf_char_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3583
3584             if(!basic_streambuf_char_gptr(&this->base))
3585                 basic_streambuf_char_setg(&this->base, buf, 0, buf);
3586         }
3587     }
3588 }
3589
3590 /* ??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 */
3591 /* ??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 */
3592 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_str, 12)
3593 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_str(basic_stringbuf_char *this,
3594         const basic_string_char *str, IOSB_openmode mode)
3595 {
3596     TRACE("(%p %p %d)\n", this, str, mode);
3597
3598     basic_streambuf_char_ctor(&this->base);
3599     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3600
3601     basic_stringbuf_char__Init(this, MSVCP_basic_string_char_c_str(str),
3602             str->size, basic_stringbuf_char__Getstate(this, mode));
3603     return this;
3604 }
3605
3606 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
3607 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
3608 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_mode, 8)
3609 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_mode(
3610         basic_stringbuf_char *this, IOSB_openmode mode)
3611 {
3612     TRACE("(%p %d)\n", this, mode);
3613
3614     basic_streambuf_char_ctor(&this->base);
3615     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3616
3617     basic_stringbuf_char__Init(this, NULL, 0, basic_stringbuf_char__Getstate(this, mode));
3618     return this;
3619 }
3620
3621 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
3622 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
3623 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor, 4)
3624 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor(basic_stringbuf_char *this)
3625 {
3626     return basic_stringbuf_char_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3627 }
3628
3629 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXXZ */
3630 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXXZ */
3631 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Tidy, 4)
3632 void __thiscall basic_stringbuf_char__Tidy(basic_stringbuf_char *this)
3633 {
3634     TRACE("(%p)\n", this);
3635
3636     if(this->state & STRINGBUF_allocated) {
3637         MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
3638         this->seekhigh = NULL;
3639         this->state &= ~STRINGBUF_allocated;
3640     }
3641
3642     basic_streambuf_char__Init_empty(&this->base);
3643 }
3644
3645 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
3646 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
3647 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_dtor, 4)
3648 void __thiscall basic_stringbuf_char_dtor(basic_stringbuf_char *this)
3649 {
3650     TRACE("(%p)\n", this);
3651
3652     basic_stringbuf_char__Tidy(this);
3653     basic_streambuf_char_dtor(&this->base);
3654 }
3655
3656 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_vector_dtor, 8)
3657 basic_stringbuf_char* __thiscall basic_stringbuf_char_vector_dtor(basic_stringbuf_char *this, unsigned int flags)
3658 {
3659     TRACE("(%p %x)\n", this, flags);
3660
3661     if(flags & 2) {
3662         /* we have an array, with the number of elements stored before the first object */
3663         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3664
3665         for (i = *ptr - 1; i >= 0; i--)
3666             basic_stringbuf_char_dtor(this+i);
3667
3668         MSVCRT_operator_delete(ptr);
3669     }else {
3670         basic_stringbuf_char_dtor(this);
3671
3672         if(flags & 1)
3673             MSVCRT_operator_delete(this);
3674     }
3675
3676     return this;
3677 }
3678
3679 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3680 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3681 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_overflow, 8)
3682 int __thiscall basic_stringbuf_char_overflow(basic_stringbuf_char *this, int meta)
3683 {
3684     MSVCP_size_t oldsize, size;
3685     char *ptr, *buf;
3686
3687     TRACE("(%p %x)\n", this, meta);
3688
3689     if(meta == EOF)
3690         return !EOF;
3691     if(this->state & STRINGBUF_no_write)
3692         return EOF;
3693
3694     ptr = basic_streambuf_char_pptr(&this->base);
3695     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3696         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
3697                 this->seekhigh, basic_streambuf_char_epptr(&this->base));
3698
3699     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
3700         return (*basic_streambuf_char__Pninc(&this->base) = meta);
3701
3702     oldsize = (ptr ? basic_streambuf_char_epptr(&this->base)-basic_streambuf_char_eback(&this->base): 0);
3703     size = oldsize|0xf;
3704     size += size/2;
3705     buf = MSVCRT_operator_new(size);
3706     if(!buf) {
3707         ERR("Out of memory\n");
3708         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3709     }
3710
3711     if(!oldsize) {
3712         this->seekhigh = buf;
3713         basic_streambuf_char_setp(&this->base, buf, buf+size);
3714         if(this->state & STRINGBUF_no_read)
3715             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3716         else
3717             basic_streambuf_char_setg(&this->base, buf, buf, buf+1);
3718
3719         this->state |= STRINGBUF_allocated;
3720     }else {
3721         ptr = basic_streambuf_char_eback(&this->base);
3722         memcpy(buf, ptr, oldsize);
3723
3724         this->seekhigh = buf+(this->seekhigh-ptr);
3725         basic_streambuf_char_setp_next(&this->base, buf,
3726                 buf+(basic_streambuf_char_pptr(&this->base)-ptr), buf+size);
3727         if(this->state & STRINGBUF_no_read)
3728             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3729         else
3730             basic_streambuf_char_setg(&this->base, buf,
3731                     buf+(basic_streambuf_char_gptr(&this->base)-ptr),
3732                     basic_streambuf_char_pptr(&this->base)+1);
3733
3734         MSVCRT_operator_delete(ptr);
3735     }
3736
3737     return (*basic_streambuf_char__Pninc(&this->base) = meta);
3738 }
3739
3740 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3741 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3742 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_pbackfail, 8)
3743 int __thiscall basic_stringbuf_char_pbackfail(basic_stringbuf_char *this, int c)
3744 {
3745     char *cur;
3746
3747     TRACE("(%p %x)\n", this, c);
3748
3749     cur = basic_streambuf_char_gptr(&this->base);
3750     if(!cur || cur==basic_streambuf_char_eback(&this->base)
3751             || (c!=EOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3752         return EOF;
3753
3754     if(c != EOF)
3755         cur[-1] = c;
3756     basic_streambuf_char_gbump(&this->base, -1);
3757     return c==EOF ? !EOF : c;
3758 }
3759
3760 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHXZ */
3761 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHXZ */
3762 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_underflow, 4)
3763 int __thiscall basic_stringbuf_char_underflow(basic_stringbuf_char *this)
3764 {
3765     char *ptr, *cur;
3766
3767     TRACE("(%p)\n", this);
3768
3769     cur = basic_streambuf_char_gptr(&this->base);
3770     if(!cur || this->state&STRINGBUF_no_read)
3771         return EOF;
3772
3773     ptr  = basic_streambuf_char_pptr(&this->base);
3774     if(this->seekhigh < ptr)
3775         this->seekhigh = ptr;
3776
3777     ptr = basic_streambuf_char_egptr(&this->base);
3778     if(this->seekhigh > ptr)
3779         basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base), cur, this->seekhigh);
3780
3781     if(cur < this->seekhigh)
3782         return *cur;
3783     return EOF;
3784 }
3785
3786 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3787 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3788 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekoff, 20)
3789 fpos_int* __thiscall basic_stringbuf_char_seekoff(basic_stringbuf_char *this,
3790         fpos_int *ret, streamoff off, int way, int mode)
3791 {
3792     char *beg, *cur_r, *cur_w;
3793
3794     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3795
3796     cur_w = basic_streambuf_char_pptr(&this->base);
3797     if(cur_w > this->seekhigh)
3798         this->seekhigh = cur_w;
3799
3800     ret->off = 0;
3801     ret->state = 0;
3802
3803     beg = basic_streambuf_char_eback(&this->base);
3804     cur_r = basic_streambuf_char_gptr(&this->base);
3805     if((mode & OPENMODE_in) && cur_r) {
3806         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3807             off += cur_r-beg;
3808         else if(way == SEEKDIR_end)
3809             off += this->seekhigh-beg;
3810         else if(way != SEEKDIR_beg)
3811             off = -1;
3812
3813         if(off<0 || off>this->seekhigh-beg) {
3814             off = -1;
3815         }else {
3816             basic_streambuf_char_gbump(&this->base, beg-cur_r+off);
3817             if((mode & OPENMODE_out) && cur_w) {
3818                 basic_streambuf_char_setp_next(&this->base, beg,
3819                         basic_streambuf_char_gptr(&this->base),
3820                         basic_streambuf_char_epptr(&this->base));
3821             }
3822         }
3823     }else if((mode & OPENMODE_out) && cur_w) {
3824         if(way == SEEKDIR_cur)
3825             off += cur_w-beg;
3826         else if(way == SEEKDIR_end)
3827             off += this->seekhigh-beg;
3828         else if(way != SEEKDIR_beg)
3829             off = -1;
3830
3831         if(off<0 || off>this->seekhigh-beg)
3832             off = -1;
3833         else
3834             basic_streambuf_char_pbump(&this->base, beg-cur_w+off);
3835     }else {
3836         off = -1;
3837     }
3838
3839     ret->pos = off;
3840     return ret;
3841 }
3842
3843 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3844 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3845 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekpos, 36)
3846 fpos_int* __thiscall basic_stringbuf_char_seekpos(basic_stringbuf_char *this,
3847         fpos_int *ret, fpos_int pos, int mode)
3848 {
3849     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3850
3851     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
3852         *ret = pos;
3853         return ret;
3854     }
3855
3856     return basic_stringbuf_char_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
3857 }
3858
3859 /* ?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 */
3860 /* ?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 */
3861 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_set, 8)
3862 void __thiscall basic_stringbuf_char_str_set(basic_stringbuf_char *this, const basic_string_char *str)
3863 {
3864     TRACE("(%p %p)\n", this, str);
3865
3866     basic_stringbuf_char__Tidy(this);
3867     basic_stringbuf_char__Init(this, MSVCP_basic_string_char_c_str(str), str->size, this->state);
3868 }
3869
3870 /* ?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 */
3871 /* ?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 */
3872 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_get, 8)
3873 basic_string_char* __thiscall basic_stringbuf_char_str_get(const basic_stringbuf_char *this, basic_string_char *ret)
3874 {
3875     char *ptr;
3876
3877     TRACE("(%p)\n", this);
3878
3879     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_char_pptr(&this->base)) {
3880         char *pptr;
3881
3882         ptr = basic_streambuf_char_pbase(&this->base);
3883         pptr = basic_streambuf_char_pptr(&this->base);
3884
3885         return MSVCP_basic_string_char_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
3886     }
3887
3888     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_char_gptr(&this->base)) {
3889         ptr = basic_streambuf_char_eback(&this->base);
3890         return MSVCP_basic_string_char_ctor_cstr_len(ret, ptr, basic_streambuf_char_egptr(&this->base) - ptr);
3891     }
3892
3893     return MSVCP_basic_string_char_ctor(ret);
3894 }
3895
3896 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAEHH@Z */
3897 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAAHH@Z */
3898 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3899 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3900 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Getstate, 8)
3901 int __thiscall basic_stringbuf_wchar__Getstate(basic_stringbuf_wchar *this, IOSB_openmode mode)
3902 {
3903     int state = 0;
3904
3905     if(!(mode & OPENMODE_in))
3906         state |= STRINGBUF_no_read;
3907
3908     if(!(mode & OPENMODE_out))
3909         state |= STRINGBUF_no_write;
3910
3911     if(mode & OPENMODE_ate)
3912         state |= STRINGBUF_at_end;
3913
3914     if(mode & OPENMODE_app)
3915         state |= STRINGBUF_append;
3916
3917     return state;
3918 }
3919
3920 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXPB_WIH@Z */
3921 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXPEB_W_KH@Z */
3922 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXPBGIH@Z */
3923 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXPEBG_KH@Z */
3924 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Init, 16)
3925 void __thiscall basic_stringbuf_wchar__Init(basic_stringbuf_wchar *this, const wchar_t *str, MSVCP_size_t count, int state)
3926 {
3927     TRACE("(%p, %p, %lu, %d)\n", this, str, count, state);
3928
3929     basic_streambuf_wchar__Init_empty(&this->base);
3930
3931     this->state = state;
3932     this->seekhigh = NULL;
3933
3934     if(count && str) {
3935         wchar_t *buf = MSVCRT_operator_new(count*sizeof(wchar_t));
3936         if(!buf) {
3937             ERR("Out of memory\n");
3938             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3939         }
3940
3941         memcpy(buf, str, count);
3942         this->seekhigh = buf + count;
3943
3944         this->state |= STRINGBUF_allocated;
3945
3946         if(!(state & STRINGBUF_no_read))
3947             basic_streambuf_wchar_setg(&this->base, buf, buf, buf + count);
3948
3949         if(!(state & STRINGBUF_no_write)) {
3950             basic_streambuf_wchar_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3951
3952             if(!basic_streambuf_wchar_gptr(&this->base))
3953                 basic_streambuf_wchar_setg(&this->base, buf, 0, buf);
3954         }
3955     }
3956 }
3957
3958 /* ??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 */
3959 /* ??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 */
3960 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor_str, 12)
3961 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor_str(basic_stringbuf_wchar *this,
3962         const basic_string_wchar *str, IOSB_openmode mode)
3963 {
3964     TRACE("(%p %p %d)\n", this, str, mode);
3965
3966     basic_streambuf_wchar_ctor(&this->base);
3967     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3968
3969     basic_stringbuf_wchar__Init(this, MSVCP_basic_string_wchar_c_str(str),
3970             str->size, basic_stringbuf_wchar__Getstate(this, mode));
3971     return this;
3972 }
3973
3974 /* ??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 */
3975 /* ??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 */
3976 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_str, 12)
3977 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_str(basic_stringbuf_wchar *this,
3978         const basic_string_wchar *str, IOSB_openmode mode)
3979 {
3980     basic_stringbuf_wchar_ctor_str(this, str, mode);
3981     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3982     return this;
3983 }
3984
3985 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
3986 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
3987 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor_mode, 8)
3988 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor_mode(
3989         basic_stringbuf_wchar *this, IOSB_openmode mode)
3990 {
3991     TRACE("(%p %d)\n", this, mode);
3992
3993     basic_streambuf_wchar_ctor(&this->base);
3994     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3995
3996     basic_stringbuf_wchar__Init(this, NULL, 0, basic_stringbuf_wchar__Getstate(this, mode));
3997     return this;
3998 }
3999
4000 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
4001 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
4002 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_mode, 8)
4003 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_mode(
4004         basic_stringbuf_wchar *this, IOSB_openmode mode)
4005 {
4006     basic_stringbuf_wchar_ctor_mode(this, mode);
4007     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
4008     return this;
4009 }
4010
4011 /* ??_F?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
4012 /* ??_F?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
4013 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor, 4)
4014 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor(basic_stringbuf_wchar *this)
4015 {
4016     return basic_stringbuf_wchar_ctor_mode(this, OPENMODE_in|OPENMODE_out);
4017 }
4018
4019 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
4020 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
4021 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor, 4)
4022 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor(basic_stringbuf_wchar *this)
4023 {
4024     return basic_stringbuf_short_ctor_mode(this, OPENMODE_in|OPENMODE_out);
4025 }
4026
4027 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXXZ */
4028 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXXZ */
4029 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXXZ */
4030 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXXZ */
4031 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Tidy, 4)
4032 void __thiscall basic_stringbuf_wchar__Tidy(basic_stringbuf_wchar *this)
4033 {
4034     TRACE("(%p)\n", this);
4035
4036     if(this->state & STRINGBUF_allocated) {
4037         MSVCRT_operator_delete(basic_streambuf_wchar_eback(&this->base));
4038         this->seekhigh = NULL;
4039         this->state &= ~STRINGBUF_allocated;
4040     }
4041
4042     basic_streambuf_wchar__Init_empty(&this->base);
4043 }
4044
4045 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
4046 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
4047 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
4048 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
4049 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_dtor, 4)
4050 void __thiscall basic_stringbuf_wchar_dtor(basic_stringbuf_wchar *this)
4051 {
4052     TRACE("(%p)\n", this);
4053
4054     basic_stringbuf_wchar__Tidy(this);
4055     basic_streambuf_wchar_dtor(&this->base);
4056 }
4057
4058 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_vector_dtor, 8)
4059 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_vector_dtor(basic_stringbuf_wchar *this, unsigned int flags)
4060 {
4061     TRACE("(%p %x)\n", this, flags);
4062
4063     if(flags & 2) {
4064         /* we have an array, with the number of elements stored before the first object */
4065         INT_PTR i, *ptr = (INT_PTR *) this - 1;
4066
4067         for (i = *ptr - 1; i >= 0; i--)
4068             basic_stringbuf_wchar_dtor(this+i);
4069
4070         MSVCRT_operator_delete(ptr);
4071     }else {
4072         basic_stringbuf_wchar_dtor(this);
4073
4074         if(flags & 1)
4075             MSVCRT_operator_delete(this);
4076     }
4077
4078     return this;
4079 }
4080
4081 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4082 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4083 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4084 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4085 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_overflow, 8)
4086 unsigned short __thiscall basic_stringbuf_wchar_overflow(basic_stringbuf_wchar *this, unsigned short meta)
4087 {
4088     MSVCP_size_t oldsize, size;
4089     wchar_t *ptr, *buf;
4090
4091     TRACE("(%p %x)\n", this, meta);
4092
4093     if(meta == WEOF)
4094         return !WEOF;
4095     if(this->state & STRINGBUF_no_write)
4096         return WEOF;
4097
4098     ptr = basic_streambuf_wchar_pptr(&this->base);
4099     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
4100         basic_streambuf_wchar_setp_next(&this->base, basic_streambuf_wchar_pbase(&this->base),
4101                 this->seekhigh, basic_streambuf_wchar_epptr(&this->base));
4102
4103     if(ptr && ptr<basic_streambuf_wchar_epptr(&this->base))
4104         return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4105
4106     oldsize = (ptr ? basic_streambuf_wchar_epptr(&this->base)-basic_streambuf_wchar_eback(&this->base): 0);
4107     size = oldsize|0xf;
4108     size += size/2;
4109     buf = MSVCRT_operator_new(size*sizeof(wchar_t));
4110     if(!buf) {
4111         ERR("Out of memory\n");
4112         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
4113     }
4114
4115     if(!oldsize) {
4116         this->seekhigh = buf;
4117         basic_streambuf_wchar_setp(&this->base, buf, buf+size);
4118         if(this->state & STRINGBUF_no_read)
4119             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4120         else
4121             basic_streambuf_wchar_setg(&this->base, buf, buf, buf+1);
4122
4123         this->state |= STRINGBUF_allocated;
4124     }else {
4125         ptr = basic_streambuf_wchar_eback(&this->base);
4126         memcpy(buf, ptr, oldsize);
4127
4128         this->seekhigh = buf+(this->seekhigh-ptr);
4129         basic_streambuf_wchar_setp_next(&this->base, buf,
4130                 buf+(basic_streambuf_wchar_pptr(&this->base)-ptr), buf+size);
4131         if(this->state & STRINGBUF_no_read)
4132             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4133         else
4134             basic_streambuf_wchar_setg(&this->base, buf,
4135                     buf+(basic_streambuf_wchar_gptr(&this->base)-ptr),
4136                     basic_streambuf_wchar_pptr(&this->base)+1);
4137
4138         MSVCRT_operator_delete(ptr);
4139     }
4140
4141     return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4142 }
4143
4144 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4145 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4146 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4147 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4148 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_pbackfail, 8)
4149 unsigned short __thiscall basic_stringbuf_wchar_pbackfail(basic_stringbuf_wchar *this, unsigned short c)
4150 {
4151     wchar_t *cur;
4152
4153     TRACE("(%p %x)\n", this, c);
4154
4155     cur = basic_streambuf_wchar_gptr(&this->base);
4156     if(!cur || cur==basic_streambuf_wchar_eback(&this->base)
4157             || (c!=WEOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
4158         return WEOF;
4159
4160     if(c != WEOF)
4161         cur[-1] = c;
4162     basic_streambuf_wchar_gbump(&this->base, -1);
4163     return c==WEOF ? !WEOF : c;
4164 }
4165
4166 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGXZ */
4167 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGXZ */
4168 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGXZ */
4169 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGXZ */
4170 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_underflow, 4)
4171 unsigned short __thiscall basic_stringbuf_wchar_underflow(basic_stringbuf_wchar *this)
4172 {
4173     wchar_t *ptr, *cur;
4174
4175     TRACE("(%p)\n", this);
4176
4177     cur = basic_streambuf_wchar_gptr(&this->base);
4178     if(!cur || this->state&STRINGBUF_no_read)
4179         return WEOF;
4180
4181     ptr  = basic_streambuf_wchar_pptr(&this->base);
4182     if(this->seekhigh < ptr)
4183         this->seekhigh = ptr;
4184
4185     ptr = basic_streambuf_wchar_egptr(&this->base);
4186     if(this->seekhigh > ptr)
4187         basic_streambuf_wchar_setg(&this->base, basic_streambuf_wchar_eback(&this->base), cur, this->seekhigh);
4188
4189     if(cur < this->seekhigh)
4190         return *cur;
4191     return WEOF;
4192 }
4193
4194 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4195 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4196 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4197 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4198 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekoff, 20)
4199 fpos_int* __thiscall basic_stringbuf_wchar_seekoff(basic_stringbuf_wchar *this,
4200         fpos_int *ret, streamoff off, int way, int mode)
4201 {
4202     wchar_t *beg, *cur_r, *cur_w;
4203
4204     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
4205
4206     cur_w = basic_streambuf_wchar_pptr(&this->base);
4207     if(cur_w > this->seekhigh)
4208         this->seekhigh = cur_w;
4209
4210     ret->off = 0;
4211     ret->state = 0;
4212
4213     beg = basic_streambuf_wchar_eback(&this->base);
4214     cur_r = basic_streambuf_wchar_gptr(&this->base);
4215     if((mode & OPENMODE_in) && cur_r) {
4216         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
4217             off += cur_r-beg;
4218         else if(way == SEEKDIR_end)
4219             off += this->seekhigh-beg;
4220         else if(way != SEEKDIR_beg)
4221             off = -1;
4222
4223         if(off<0 || off>this->seekhigh-beg) {
4224             off = -1;
4225         }else {
4226             basic_streambuf_wchar_gbump(&this->base, beg-cur_r+off);
4227             if((mode & OPENMODE_out) && cur_w) {
4228                 basic_streambuf_wchar_setp_next(&this->base, beg,
4229                         basic_streambuf_wchar_gptr(&this->base),
4230                         basic_streambuf_wchar_epptr(&this->base));
4231             }
4232         }
4233     }else if((mode & OPENMODE_out) && cur_w) {
4234         if(way == SEEKDIR_cur)
4235             off += cur_w-beg;
4236         else if(way == SEEKDIR_end)
4237             off += this->seekhigh-beg;
4238         else if(way != SEEKDIR_beg)
4239             off = -1;
4240
4241         if(off<0 || off>this->seekhigh-beg)
4242             off = -1;
4243         else
4244             basic_streambuf_wchar_pbump(&this->base, beg-cur_w+off);
4245     }else {
4246         off = -1;
4247     }
4248
4249     ret->pos = off;
4250     return ret;
4251 }
4252
4253 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4254 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4255 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4256 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4257 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekpos, 36)
4258 fpos_int* __thiscall basic_stringbuf_wchar_seekpos(basic_stringbuf_wchar *this,
4259         fpos_int *ret, fpos_int pos, int mode)
4260 {
4261     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
4262
4263     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
4264         *ret = pos;
4265         return ret;
4266     }
4267
4268     return basic_stringbuf_wchar_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
4269 }
4270
4271 /* ?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 */
4272 /* ?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 */
4273 /* ?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 */
4274 /* ?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 */
4275 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_set, 8)
4276 void __thiscall basic_stringbuf_wchar_str_set(basic_stringbuf_wchar *this, const basic_string_wchar *str)
4277 {
4278     TRACE("(%p %p)\n", this, str);
4279
4280     basic_stringbuf_wchar__Tidy(this);
4281     basic_stringbuf_wchar__Init(this, MSVCP_basic_string_wchar_c_str(str), str->size, this->state);
4282 }
4283
4284 /* ?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 */
4285 /* ?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 */
4286 /* ?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 */
4287 /* ?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 */
4288 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_get, 8)
4289 basic_string_wchar* __thiscall basic_stringbuf_wchar_str_get(const basic_stringbuf_wchar *this, basic_string_wchar *ret)
4290 {
4291     wchar_t *ptr;
4292
4293     TRACE("(%p)\n", this);
4294
4295     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_wchar_pptr(&this->base)) {
4296         wchar_t *pptr;
4297
4298         ptr = basic_streambuf_wchar_pbase(&this->base);
4299         pptr = basic_streambuf_wchar_pptr(&this->base);
4300
4301         return MSVCP_basic_string_wchar_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
4302     }
4303
4304     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_wchar_gptr(&this->base)) {
4305         ptr = basic_streambuf_wchar_eback(&this->base);
4306         return MSVCP_basic_string_wchar_ctor_cstr_len(ret, ptr, basic_streambuf_wchar_egptr(&this->base) - ptr);
4307     }
4308
4309     return MSVCP_basic_string_wchar_ctor(ret);
4310 }
4311
4312 /* ??0ios_base@std@@IAE@XZ */
4313 /* ??0ios_base@std@@IEAA@XZ */
4314 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
4315 ios_base* __thiscall ios_base_ctor(ios_base *this)
4316 {
4317     TRACE("(%p)\n", this);
4318     this->vtable = &MSVCP_ios_base_vtable;
4319     return this;
4320 }
4321
4322 /* ??0ios_base@std@@QAE@ABV01@@Z */
4323 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
4324 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
4325 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
4326 {
4327     TRACE("(%p %p)\n", this, copy);
4328     *this = *copy;
4329     this->vtable = &MSVCP_ios_base_vtable;
4330     return this;
4331 }
4332
4333 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
4334 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
4335 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
4336 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
4337 {
4338     IOS_BASE_fnarray *cur;
4339
4340     TRACE("(%p %x)\n", this, event);
4341
4342     for(cur=this->calls; cur; cur=cur->next)
4343         cur->event_handler(event, this, cur->index);
4344 }
4345
4346 /* ?_Tidy@ios_base@std@@AAAXXZ */
4347 /* ?_Tidy@ios_base@std@@AEAAXXZ */
4348 void CDECL ios_base_Tidy(ios_base *this)
4349 {
4350     IOS_BASE_iosarray *arr_cur, *arr_next;
4351     IOS_BASE_fnarray *event_cur, *event_next;
4352
4353     TRACE("(%p)\n", this);
4354
4355     ios_base_Callfns(this, EVENT_erase_event);
4356
4357     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
4358         arr_next = arr_cur->next;
4359         MSVCRT_operator_delete(arr_cur);
4360     }
4361     this->arr = NULL;
4362
4363     for(event_cur=this->calls; event_cur; event_cur=event_next) {
4364         event_next = event_cur->next;
4365         MSVCRT_operator_delete(event_cur);
4366     }
4367     this->calls = NULL;
4368 }
4369
4370 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
4371 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
4372 void CDECL ios_base_Ios_base_dtor(ios_base *obj)
4373 {
4374     TRACE("(%p)\n", obj);
4375     if(obj->loc) {
4376         locale_dtor(obj->loc);
4377         MSVCRT_operator_delete(obj->loc);
4378     }
4379     ios_base_Tidy(obj);
4380 }
4381
4382 /* ??1ios_base@std@@UAE@XZ */
4383 /* ??1ios_base@std@@UEAA@XZ */
4384 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
4385 void __thiscall ios_base_dtor(ios_base *this)
4386 {
4387     ios_base_Ios_base_dtor(this);
4388 }
4389
4390 DEFINE_THISCALL_WRAPPER(ios_base_vector_dtor, 8)
4391 ios_base* __thiscall ios_base_vector_dtor(ios_base *this, unsigned int flags)
4392 {
4393     TRACE("(%p %x)\n", this, flags);
4394     if(flags & 2) {
4395         /* we have an array, with the number of elements stored before the first object */
4396         INT_PTR i, *ptr = (INT_PTR *)this-1;
4397
4398         for(i=*ptr-1; i>=0; i--)
4399             ios_base_dtor(this+i);
4400         MSVCRT_operator_delete(ptr);
4401     } else {
4402         ios_base_dtor(this);
4403         if(flags & 1)
4404             MSVCRT_operator_delete(this);
4405     }
4406
4407     return this;
4408 }
4409
4410 DEFINE_THISCALL_WRAPPER(iosb_vector_dtor, 8)
4411 void* __thiscall iosb_vector_dtor(void *this, unsigned int flags)
4412 {
4413     TRACE("(%p %x)\n", this, flags);
4414     if(flags & 2) {
4415         INT_PTR *ptr = (INT_PTR *)this-1;
4416         MSVCRT_operator_delete(ptr);
4417     } else {
4418         if(flags & 1)
4419             MSVCRT_operator_delete(this);
4420     }
4421
4422     return this;
4423 }
4424
4425 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
4426 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
4427 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
4428 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
4429 {
4430     IOS_BASE_iosarray *p;
4431
4432     TRACE("(%p %d)\n", this, index);
4433
4434     for(p=this->arr; p; p=p->next) {
4435         if(p->index == index)
4436             return p;
4437     }
4438
4439     for(p=this->arr; p; p=p->next) {
4440         if(!p->long_val && !p->ptr_val) {
4441             p->index = index;
4442             return p;
4443         }
4444     }
4445
4446     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
4447     p->next = this->arr;
4448     p->index = index;
4449     p->long_val = 0;
4450     p->ptr_val = NULL;
4451     this->arr = p;
4452     return p;
4453 }
4454
4455 /* ?iword@ios_base@std@@QAEAAJH@Z */
4456 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
4457 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
4458 LONG* __thiscall ios_base_iword(ios_base *this, int index)
4459 {
4460     TRACE("(%p %d)\n", this, index);
4461     return &ios_base_Findarr(this, index)->long_val;
4462 }
4463
4464 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
4465 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
4466 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
4467 void** __thiscall ios_base_pword(ios_base *this, int index)
4468 {
4469     TRACE("(%p %d)\n", this, index);
4470     return &ios_base_Findarr(this, index)->ptr_val;
4471 }
4472
4473 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
4474 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
4475 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
4476 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
4477 {
4478     IOS_BASE_fnarray *event;
4479
4480     TRACE("(%p %p %d)\n", this, callback, index);
4481
4482     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
4483     event->next = this->calls;
4484     event->index = index;
4485     event->event_handler = callback;
4486     this->calls = event;
4487 }
4488
4489 /* ?clear@ios_base@std@@QAEXH_N@Z */
4490 /* ?clear@ios_base@std@@QEAAXH_N@Z */
4491 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
4492 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4493 {
4494     TRACE("(%p %x %x)\n", this, state, reraise);
4495
4496     this->state = state & IOSTATE_mask;
4497     if(!(this->state & this->except))
4498         return;
4499
4500     if(reraise)
4501         throw_exception(EXCEPTION_RERAISE, NULL);
4502     else if(this->state & this->except & IOSTATE_eofbit)
4503         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
4504     else if(this->state & this->except & IOSTATE_failbit)
4505         throw_exception(EXCEPTION_FAILURE, "failbit is set");
4506     else if(this->state & this->except & IOSTATE_badbit)
4507         throw_exception(EXCEPTION_FAILURE, "badbit is set");
4508     else if(this->state & this->except & IOSTATE__Hardfail)
4509         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
4510 }
4511
4512 /* ?clear@ios_base@std@@QAEXH@Z */
4513 /* ?clear@ios_base@std@@QEAAXH@Z */
4514 DEFINE_THISCALL_WRAPPER(ios_base_clear, 8)
4515 void __thiscall ios_base_clear(ios_base *this, IOSB_iostate state)
4516 {
4517     ios_base_clear_reraise(this, state, FALSE);
4518 }
4519
4520 /* ?clear@ios_base@std@@QAEXI@Z */
4521 /* ?clear@ios_base@std@@QEAAXI@Z */
4522 DEFINE_THISCALL_WRAPPER(ios_base_clear_unsigned, 8)
4523 void __thiscall ios_base_clear_unsigned(ios_base *this, unsigned int state)
4524 {
4525     ios_base_clear_reraise(this, (IOSB_iostate)state, FALSE);
4526 }
4527
4528 /* ?exceptions@ios_base@std@@QAEXH@Z */
4529 /* ?exceptions@ios_base@std@@QEAAXH@Z */
4530 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
4531 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
4532 {
4533     TRACE("(%p %x)\n", this, state);
4534     this->except = state & IOSTATE_mask;
4535     ios_base_clear(this, this->state);
4536 }
4537
4538 /* ?exceptions@ios_base@std@@QAEXI@Z */
4539 /* ?exceptions@ios_base@std@@QEAAXI@Z */
4540 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set_unsigned, 8)
4541 void __thiscall ios_base_exceptions_set_unsigned(ios_base *this, unsigned int state)
4542 {
4543     TRACE("(%p %x)\n", this, state);
4544     ios_base_exceptions_set(this, state);
4545 }
4546
4547 /* ?exceptions@ios_base@std@@QBEHXZ */
4548 /* ?exceptions@ios_base@std@@QEBAHXZ */
4549 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
4550 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
4551 {
4552     TRACE("(%p)\n", this);
4553     return this->except;
4554 }
4555
4556 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
4557 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
4558 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
4559 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
4560 {
4561     TRACE("(%p %p)\n", this, rhs);
4562
4563     if(this != rhs) {
4564         IOS_BASE_iosarray *arr_cur;
4565         IOS_BASE_fnarray *event_cur;
4566
4567         ios_base_Tidy(this);
4568
4569         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
4570             if(arr_cur->long_val)
4571                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
4572             if(arr_cur->ptr_val)
4573                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
4574         }
4575         this->stdstr = rhs->stdstr;
4576         this->fmtfl = rhs->fmtfl;
4577         this->prec = rhs->prec;
4578         this->wide = rhs->wide;
4579         locale_operator_assign(this->loc, rhs->loc);
4580
4581         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
4582             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
4583
4584         ios_base_Callfns(this, EVENT_copyfmt_event);
4585         ios_base_exceptions_set(this, rhs->except);
4586     }
4587
4588     return this;
4589 }
4590
4591 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
4592 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
4593 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
4594 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
4595 {
4596     TRACE("(%p %p)\n", this, right);
4597
4598     if(this != right) {
4599         this->state = right->state;
4600         ios_base_copyfmt(this, right);
4601     }
4602
4603     return this;
4604 }
4605
4606 /* ?fail@ios_base@std@@QBE_NXZ */
4607 /* ?fail@ios_base@std@@QEBA_NXZ */
4608 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
4609 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
4610 {
4611     TRACE("(%p)\n", this);
4612     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
4613 }
4614
4615 /* ??7ios_base@std@@QBE_NXZ */
4616 /* ??7ios_base@std@@QEBA_NXZ */
4617 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
4618 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
4619 {
4620     TRACE("(%p)\n", this);
4621     return ios_base_fail(this);
4622 }
4623
4624 /* ??Bios_base@std@@QBEPAXXZ */
4625 /* ??Bios_base@std@@QEBAPEAXXZ */
4626 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
4627 void* __thiscall ios_base_op_fail(const ios_base *this)
4628 {
4629     TRACE("(%p)\n", this);
4630     return ios_base_fail(this) ? NULL : (void*)this;
4631 }
4632
4633 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
4634 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
4635 void CDECL ios_base_Addstd(ios_base *add)
4636 {
4637     FIXME("(%p) stub\n", add);
4638 }
4639
4640 /* ?_Index_func@ios_base@std@@CAAAHXZ */
4641 /* ?_Index_func@ios_base@std@@CAAEAHXZ */
4642 int* CDECL ios_base_Index_func(void)
4643 {
4644     TRACE("\n");
4645     return &ios_base_Index;
4646 }
4647
4648 /* ?_Init@ios_base@std@@IAEXXZ */
4649 /* ?_Init@ios_base@std@@IEAAXXZ */
4650 DEFINE_THISCALL_WRAPPER(ios_base_Init, 4)
4651 void __thiscall ios_base_Init(ios_base *this)
4652 {
4653     TRACE("(%p)\n", this);
4654
4655     this->stdstr = 0;
4656     this->state = this->except = IOSTATE_goodbit;
4657     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
4658     this->prec = 6;
4659     this->wide = 0;
4660     this->arr = NULL;
4661     this->calls = NULL;
4662     this->loc = MSVCRT_operator_new(sizeof(locale));
4663     locale_ctor(this->loc);
4664 }
4665
4666 /* ?_Sync_func@ios_base@std@@CAAA_NXZ */
4667 /* ?_Sync_func@ios_base@std@@CAAEA_NXZ */
4668 MSVCP_bool* CDECL ios_base_Sync_func(void)
4669 {
4670     TRACE("\n");
4671     return &ios_base_Sync;
4672 }
4673
4674 /* ?bad@ios_base@std@@QBE_NXZ */
4675 /* ?bad@ios_base@std@@QEBA_NXZ */
4676 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
4677 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
4678 {
4679     TRACE("(%p)\n", this);
4680     return (this->state & IOSTATE_badbit) != 0;
4681 }
4682
4683 /* ?eof@ios_base@std@@QBE_NXZ */
4684 /* ?eof@ios_base@std@@QEBA_NXZ */
4685 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
4686 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
4687 {
4688     TRACE("(%p)\n", this);
4689     return (this->state & IOSTATE_eofbit) != 0;
4690 }
4691
4692 /* ?flags@ios_base@std@@QAEHH@Z */
4693 /* ?flags@ios_base@std@@QEAAHH@Z */
4694 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
4695 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
4696 {
4697     IOSB_fmtflags ret = this->fmtfl;
4698
4699     TRACE("(%p %x)\n", this, flags);
4700
4701     this->fmtfl = flags & FMTFLAG_mask;
4702     return ret;
4703 }
4704
4705 /* ?flags@ios_base@std@@QBEHXZ */
4706 /* ?flags@ios_base@std@@QEBAHXZ */
4707 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
4708 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
4709 {
4710     TRACE("(%p)\n", this);
4711     return this->fmtfl;
4712 }
4713
4714 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
4715 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
4716 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
4717 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
4718 {
4719     TRACE("(%p)\n", this);
4720     return locale_copy_ctor(ret, this->loc);
4721 }
4722
4723 /* ?good@ios_base@std@@QBE_NXZ */
4724 /* ?good@ios_base@std@@QEBA_NXZ */
4725 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
4726 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
4727 {
4728     TRACE("(%p)\n", this);
4729     return this->state == IOSTATE_goodbit;
4730 }
4731
4732 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
4733 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
4734 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
4735 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
4736 {
4737     TRACE("(%p %p)\n", this, loc);
4738     *ret = *this->loc;
4739     locale_copy_ctor(this->loc, loc);
4740     return ret;
4741 }
4742
4743 /* ?precision@ios_base@std@@QAEHH@Z */
4744 /* ?precision@ios_base@std@@QEAA_J_J@Z */
4745 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
4746 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
4747 {
4748     streamsize ret = this->prec;
4749
4750     TRACE("(%p %ld)\n", this, precision);
4751
4752     this->prec = precision;
4753     return ret;
4754 }
4755
4756 /* ?precision@ios_base@std@@QBEHXZ */
4757 /* ?precision@ios_base@std@@QEBA_JXZ */
4758 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
4759 streamsize __thiscall ios_base_precision_get(const ios_base *this)
4760 {
4761     TRACE("(%p)\n", this);
4762     return this->prec;
4763 }
4764
4765 /* ?rdstate@ios_base@std@@QBEHXZ */
4766 /* ?rdstate@ios_base@std@@QEBAHXZ */
4767 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
4768 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
4769 {
4770     TRACE("(%p)\n", this);
4771     return this->state;
4772 }
4773
4774 /* ?setf@ios_base@std@@QAEHHH@Z */
4775 /* ?setf@ios_base@std@@QEAAHHH@Z */
4776 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
4777 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
4778 {
4779     IOSB_fmtflags ret = this->fmtfl;
4780
4781     TRACE("(%p %x %x)\n", this, flags, mask);
4782
4783     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
4784     return ret;
4785 }
4786
4787 /* ?setf@ios_base@std@@QAEHH@Z */
4788 /* ?setf@ios_base@std@@QEAAHH@Z */
4789 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
4790 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
4791 {
4792     return ios_base_setf_mask(this, flags, ~0);
4793 }
4794
4795 /* ?setstate@ios_base@std@@QAEXH_N@Z */
4796 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
4797 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
4798 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4799 {
4800     TRACE("(%p %x %x)\n", this, state, reraise);
4801
4802     if(state != IOSTATE_goodbit)
4803         ios_base_clear_reraise(this, this->state | state, reraise);
4804 }
4805
4806 /* ?setstate@ios_base@std@@QAEXH@Z */
4807 /* ?setstate@ios_base@std@@QEAAXH@Z */
4808 DEFINE_THISCALL_WRAPPER(ios_base_setstate, 8)
4809 void __thiscall ios_base_setstate(ios_base *this, IOSB_iostate state)
4810 {
4811     ios_base_setstate_reraise(this, state, FALSE);
4812 }
4813
4814 /* ?setstate@ios_base@std@@QAEXI@Z */
4815 /* ?setstate@ios_base@std@@QEAAXI@Z */
4816 DEFINE_THISCALL_WRAPPER(ios_base_setstate_unsigned, 8)
4817 void __thiscall ios_base_setstate_unsigned(ios_base *this, unsigned int state)
4818 {
4819     ios_base_setstate_reraise(this, (IOSB_iostate)state, FALSE);
4820 }
4821
4822 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
4823 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
4824 {
4825     _Lockit lock;
4826     MSVCP_bool ret;
4827
4828     TRACE("(%x)\n", sync);
4829
4830     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4831     ret = ios_base_Sync;
4832     ios_base_Sync = sync;
4833     _Lockit_dtor(&lock);
4834     return ret;
4835 }
4836
4837 /* ?unsetf@ios_base@std@@QAEXH@Z */
4838 /* ?unsetf@ios_base@std@@QEAAXH@Z */
4839 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
4840 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
4841 {
4842     TRACE("(%p %x)\n", this, flags);
4843     this->fmtfl &= ~flags;
4844 }
4845
4846 /* ?width@ios_base@std@@QAEHH@Z */
4847 /* ?width@ios_base@std@@QEAA_J_J@Z */
4848 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
4849 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
4850 {
4851     streamsize ret = this->wide;
4852
4853     TRACE("(%p %ld)\n", this, width);
4854
4855     this->wide = width;
4856     return ret;
4857 }
4858
4859 /* ?width@ios_base@std@@QBEHXZ */
4860 /* ?width@ios_base@std@@QEBA_JXZ */
4861 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
4862 streamsize __thiscall ios_base_width_get(ios_base *this)
4863 {
4864     TRACE("(%p)\n", this);
4865     return this->wide;
4866 }
4867
4868 /* ?xalloc@ios_base@std@@SAHXZ */
4869 int CDECL ios_base_xalloc(void)
4870 {
4871     _Lockit lock;
4872     int ret;
4873
4874     TRACE("\n");
4875
4876     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4877     ret = ios_base_Index++;
4878     _Lockit_dtor(&lock);
4879     return ret;
4880 }
4881
4882 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
4883 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
4884 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
4885 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
4886 {
4887     TRACE("(%p)\n", this);
4888
4889     ios_base_ctor(&this->base);
4890     this->base.vtable = &MSVCP_basic_ios_char_vtable;
4891     return this;
4892 }
4893
4894 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4895 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4896 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
4897 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
4898 {
4899     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4900     ios_base_Init(&this->base);
4901     this->strbuf = streambuf;
4902     this->stream = NULL;
4903     this->fillch = ' ';
4904
4905     if(!streambuf)
4906         ios_base_setstate(&this->base, IOSTATE_badbit);
4907
4908     if(isstd)
4909         FIXME("standard streams not handled yet\n");
4910 }
4911
4912 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4913 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4914 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
4915 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
4916 {
4917     TRACE("(%p %p)\n", this, strbuf);
4918
4919     basic_ios_char_ctor(this);
4920     basic_ios_char_init(this, strbuf, FALSE);
4921     return this;
4922 }
4923
4924 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
4925 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4926 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
4927 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
4928 {
4929     TRACE("(%p)\n", this);
4930     ios_base_dtor(&this->base);
4931 }
4932
4933 DEFINE_THISCALL_WRAPPER(basic_ios_char_vector_dtor, 8)
4934 basic_ios_char* __thiscall basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
4935 {
4936     TRACE("(%p %x)\n", this, flags);
4937     if(flags & 2) {
4938         /* we have an array, with the number of elements stored before the first object */
4939         INT_PTR i, *ptr = (INT_PTR *)this-1;
4940
4941         for(i=*ptr-1; i>=0; i--)
4942             basic_ios_char_dtor(this+i);
4943         MSVCRT_operator_delete(ptr);
4944     } else {
4945         basic_ios_char_dtor(this);
4946         if(flags & 1)
4947             MSVCRT_operator_delete(this);
4948     }
4949
4950     return this;
4951 }
4952
4953 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4954 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4955 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
4956 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4957 {
4958     TRACE("(%p %x %x)\n", this, state, reraise);
4959     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4960 }
4961
4962 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4963 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4964 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear, 8)
4965 void __thiscall basic_ios_char_clear(basic_ios_char *this, unsigned int state)
4966 {
4967     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
4968 }
4969
4970 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
4971 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4972 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
4973 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
4974 {
4975     TRACE("(%p %p)\n", this, copy);
4976     if(this == copy)
4977         return this;
4978
4979     this->stream = copy->stream;
4980     this->fillch = copy->fillch;
4981     ios_base_copyfmt(&this->base, &copy->base);
4982     return this;
4983 }
4984
4985 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
4986 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
4987 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
4988 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
4989 {
4990     char ret = this->fillch;
4991
4992     TRACE("(%p %c)\n", this, fill);
4993
4994     this->fillch = fill;
4995     return ret;
4996 }
4997
4998 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
4999 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
5000 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
5001 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
5002 {
5003     TRACE("(%p)\n", this);
5004     return this->fillch;
5005 }
5006
5007 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5008 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5009 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
5010 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
5011 {
5012     TRACE("(%p %p %p)\n", this, ret, loc);
5013
5014     if(this->strbuf) {
5015         basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
5016         locale_dtor(ret);
5017     }
5018
5019     return ios_base_imbue(&this->base, ret, loc);
5020 }
5021
5022 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
5023 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
5024 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
5025 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
5026 {
5027     TRACE("(%p %c %c)\n", this, ch, def);
5028     return ctype_char_narrow_ch(ctype_char_use_facet(this->strbuf->loc), ch, def);
5029 }
5030
5031 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
5032 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
5033 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
5034 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
5035 {
5036     basic_streambuf_char *ret = this->strbuf;
5037
5038     TRACE("(%p %p)\n", this, streambuf);
5039
5040     this->strbuf = streambuf;
5041     basic_ios_char_clear(this, IOSTATE_goodbit);
5042     return ret;
5043 }
5044
5045 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
5046 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
5047 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
5048 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
5049 {
5050     TRACE("(%p)\n", this);
5051     return this->strbuf;
5052 }
5053
5054 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
5055 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
5056 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
5057 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
5058 {
5059     TRACE("(%p %x %x)\n", this, state, reraise);
5060
5061     if(state != IOSTATE_goodbit)
5062         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
5063 }
5064
5065 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
5066 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
5067 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate, 8)
5068 void __thiscall basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
5069 {
5070     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
5071 }
5072
5073 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
5074 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
5075 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
5076 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
5077 {
5078     basic_ostream_char *ret = this->stream;
5079
5080     TRACE("(%p %p)\n", this, ostream);
5081
5082     this->stream = ostream;
5083     return ret;
5084 }
5085
5086 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
5087 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
5088 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
5089 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
5090 {
5091     TRACE("(%p)\n", this);
5092     return this->stream;
5093 }
5094
5095 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
5096 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
5097 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
5098 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
5099 {
5100     TRACE("(%p %c)\n", this, ch);
5101     return ctype_char_widen_ch(ctype_char_use_facet(this->strbuf->loc), ch);
5102 }
5103
5104
5105 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
5106 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
5107 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor, 4)
5108 basic_ios_wchar* __thiscall basic_ios_wchar_ctor(basic_ios_wchar *this)
5109 {
5110     TRACE("(%p)\n", this);
5111
5112     ios_base_ctor(&this->base);
5113     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
5114     return this;
5115 }
5116
5117 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
5118 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
5119 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
5120 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
5121 {
5122     basic_ios_wchar_ctor(this);
5123     this->base.vtable = &MSVCP_basic_ios_short_vtable;
5124     return this;
5125 }
5126
5127 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
5128 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
5129 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
5130 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
5131 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
5132 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
5133 {
5134     TRACE("(%p %p %x)\n", this, streambuf, isstd);
5135     ios_base_Init(&this->base);
5136     this->strbuf = streambuf;
5137     this->stream = NULL;
5138     this->fillch = ' ';
5139
5140     if(!streambuf)
5141         ios_base_setstate(&this->base, IOSTATE_badbit);
5142
5143     if(isstd)
5144         FIXME("standard streams not handled yet\n");
5145 }
5146
5147 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5148 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5149 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor_streambuf, 8)
5150 basic_ios_wchar* __thiscall basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
5151 {
5152     TRACE("(%p %p)\n", this, strbuf);
5153
5154     basic_ios_wchar_ctor(this);
5155     basic_ios_wchar_init(this, strbuf, FALSE);
5156     return this;
5157 }
5158
5159 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5160 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5161 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
5162 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
5163 {
5164     basic_ios_wchar_ctor_streambuf(this, strbuf);
5165     this->base.vtable = &MSVCP_basic_ios_short_vtable;
5166     return this;
5167 }
5168
5169 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
5170 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
5171 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
5172 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
5173 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
5174 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
5175 {
5176     TRACE("(%p)\n", this);
5177     ios_base_dtor(&this->base);
5178 }
5179
5180 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_vector_dtor, 8)
5181 basic_ios_wchar* __thiscall basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
5182 {
5183     TRACE("(%p %x)\n", this, flags);
5184     if(flags & 2) {
5185         /* we have an array, with the number of elements stored before the first object */
5186         INT_PTR i, *ptr = (INT_PTR *)this-1;
5187
5188         for(i=*ptr-1; i>=0; i--)
5189             basic_ios_wchar_dtor(this+i);
5190         MSVCRT_operator_delete(ptr);
5191     } else {
5192         basic_ios_wchar_dtor(this);
5193         if(flags & 1)
5194             MSVCRT_operator_delete(this);
5195     }
5196
5197     return this;
5198 }
5199
5200 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5201 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5202 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5203 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5204 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
5205 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5206 {
5207     TRACE("(%p %x %x)\n", this, state, reraise);
5208     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
5209 }
5210
5211 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5212 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5213 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5214 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5215 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear, 8)
5216 void __thiscall basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
5217 {
5218     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
5219 }
5220
5221 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
5222 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5223 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
5224 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5225 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
5226 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
5227 {
5228     TRACE("(%p %p)\n", this, copy);
5229     if(this == copy)
5230         return this;
5231
5232     this->stream = copy->stream;
5233     this->fillch = copy->fillch;
5234     ios_base_copyfmt(&this->base, &copy->base);
5235     return this;
5236 }
5237
5238 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
5239 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
5240 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
5241 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
5242 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
5243 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
5244 {
5245     wchar_t ret = this->fillch;
5246
5247     TRACE("(%p %c)\n", this, fill);
5248
5249     this->fillch = fill;
5250     return ret;
5251 }
5252
5253 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
5254 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
5255 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
5256 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
5257 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
5258 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
5259 {
5260     TRACE("(%p)\n", this);
5261     return this->fillch;
5262 }
5263
5264 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5265 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5266 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5267 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5268 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
5269 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
5270 {
5271     TRACE("(%p %p %p)\n", this, ret, loc);
5272
5273     if(this->strbuf)
5274         return basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
5275
5276     locale_copy_ctor(ret, loc);
5277     return ret;
5278 }
5279
5280 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
5281 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
5282 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
5283 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
5284 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
5285 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
5286 {
5287     TRACE("(%p %c %c)\n", this, ch, def);
5288     return ctype_wchar_narrow_ch(ctype_wchar_use_facet(this->strbuf->loc), ch, def);
5289 }
5290
5291 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5292 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5293 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
5294 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5295 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
5296 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
5297 {
5298     basic_streambuf_wchar *ret = this->strbuf;
5299
5300     TRACE("(%p %p)\n", this, streambuf);
5301
5302     this->strbuf = streambuf;
5303     basic_ios_wchar_clear(this, IOSTATE_goodbit);
5304     return ret;
5305 }
5306
5307 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5308 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5309 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5310 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5311 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
5312 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
5313 {
5314     TRACE("(%p)\n", this);
5315     return this->strbuf;
5316 }
5317
5318 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5319 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5320 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5321 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5322 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
5323 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5324 {
5325     TRACE("(%p %x %x)\n", this, state, reraise);
5326
5327     if(state != IOSTATE_goodbit)
5328         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
5329 }
5330
5331 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5332 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5333 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5334 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5335 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate, 8)
5336 void __thiscall basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
5337 {
5338     basic_ios_wchar_setstate_reraise(this, state, FALSE);
5339 }
5340
5341 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5342 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5343 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
5344 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5345 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
5346 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
5347 {
5348     basic_ostream_wchar *ret = this->stream;
5349
5350     TRACE("(%p %p)\n", this, ostream);
5351
5352     this->stream = ostream;
5353     return ret;
5354 }
5355
5356 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5357 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5358 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5359 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5360 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
5361 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
5362 {
5363     TRACE("(%p)\n", this);
5364     return this->stream;
5365 }
5366
5367 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
5368 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
5369 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
5370 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
5371 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
5372 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
5373 {
5374     TRACE("(%p %c)\n", this, ch);
5375     return ctype_wchar_widen_ch(ctype_wchar_use_facet(this->strbuf->loc), ch);
5376 }
5377
5378 /* Caution: basic_ostream uses virtual inheritance.
5379  * All constructors have additional parameter that says if base class should be initialized.
5380  * Base class needs to be accessed using vbtable.
5381  */
5382 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
5383 {
5384     return (basic_ios_char*)((char*)this+this->vbtable[1]);
5385 }
5386
5387 static inline basic_ios_char* basic_ostream_char_to_basic_ios(basic_ostream_char *ptr)
5388 {
5389     return (basic_ios_char*)((char*)ptr+basic_ostream_char_vbtable[1]);
5390 }
5391
5392 static inline basic_ostream_char* basic_ostream_char_from_basic_ios(basic_ios_char *ptr)
5393 {
5394     return (basic_ostream_char*)((char*)ptr-basic_ostream_char_vbtable[1]);
5395 }
5396
5397 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5398 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5399 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor, 16)
5400 basic_ostream_char* __thiscall basic_ostream_char_ctor(basic_ostream_char *this,
5401         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5402 {
5403     basic_ios_char *base;
5404
5405     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5406
5407     if(virt_init) {
5408         this->vbtable = basic_ostream_char_vbtable;
5409         base = basic_ostream_char_get_basic_ios(this);
5410         basic_ios_char_ctor(base);
5411     }else {
5412         base = basic_ostream_char_get_basic_ios(this);
5413     }
5414
5415     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5416     basic_ios_char_init(base, strbuf, isstd);
5417     return this;
5418 }
5419
5420 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5421 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5422 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor_uninitialized, 16)
5423 basic_ostream_char* __thiscall basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
5424         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5425 {
5426     basic_ios_char *base;
5427
5428     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5429
5430     if(virt_init) {
5431         this->vbtable = basic_ostream_char_vbtable;
5432         base = basic_ostream_char_get_basic_ios(this);
5433         basic_ios_char_ctor(base);
5434     }else {
5435         base = basic_ostream_char_get_basic_ios(this);
5436     }
5437
5438     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5439     if(addstd)
5440         ios_base_Addstd(&base->base);
5441     return this;
5442 }
5443
5444 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5445 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5446 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
5447 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
5448 {
5449     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5450
5451     /* don't destroy virtual base here */
5452     TRACE("(%p)\n", this);
5453 }
5454
5455 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5456 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5457 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
5458 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
5459 {
5460     TRACE("(%p)\n", this);
5461     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
5462     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
5463 }
5464
5465 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
5466 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5467 {
5468     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5469
5470     TRACE("(%p %x)\n", this, flags);
5471
5472     if(flags & 2) {
5473         /* we have an array, with the number of elements stored before the first object */
5474         INT_PTR i, *ptr = (INT_PTR *)this-1;
5475
5476         for(i=*ptr-1; i>=0; i--)
5477             basic_ostream_char_vbase_dtor(this+i);
5478         MSVCRT_operator_delete(ptr);
5479     } else {
5480         basic_ostream_char_vbase_dtor(this);
5481         if(flags & 1)
5482             MSVCRT_operator_delete(this);
5483     }
5484
5485     return this;
5486 }
5487
5488 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5489 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5490 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
5491 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
5492 {
5493     /* this function is not matching C++ specification */
5494     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5495
5496     TRACE("(%p)\n", this);
5497
5498     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
5499             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
5500         basic_ios_char_setstate(base, IOSTATE_badbit);
5501     return this;
5502 }
5503
5504 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5505 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5506 DEFINE_THISCALL_WRAPPER(basic_ostream_char__Osfx, 4)
5507 void __thiscall basic_ostream_char__Osfx(basic_ostream_char *this)
5508 {
5509     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5510
5511     TRACE("(%p)\n", this);
5512
5513     if(base->base.fmtfl & FMTFLAG_unitbuf)
5514         basic_ostream_char_flush(this);
5515 }
5516
5517 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5518 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5519 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
5520 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
5521 {
5522     TRACE("(%p)\n", this);
5523     basic_ostream_char__Osfx(this);
5524 }
5525
5526 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
5527 {
5528     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5529
5530     if(basic_ios_char_rdbuf_get(base))
5531         basic_streambuf_char__Lock(base->strbuf);
5532
5533     if(ios_base_good(&base->base) && base->stream)
5534         basic_ostream_char_flush(base->stream);
5535
5536     return ios_base_good(&base->base);
5537 }
5538
5539 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
5540 {
5541     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5542
5543     if(ios_base_good(&base->base) && !__uncaught_exception())
5544         basic_ostream_char_osfx(ostr);
5545
5546     if(basic_ios_char_rdbuf_get(base))
5547         basic_streambuf_char__Unlock(base->strbuf);
5548 }
5549
5550 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
5551 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
5552 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
5553 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
5554 {
5555     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5556
5557     TRACE("(%p)\n", this);
5558
5559     if(ios_base_good(&base->base) && base->stream)
5560         basic_ostream_char_flush(base->stream);
5561     return ios_base_good(&base->base);
5562 }
5563
5564 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5565 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5566 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
5567 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
5568 {
5569     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5570
5571     TRACE("(%p %c)\n", this, ch);
5572
5573     if(!basic_ostream_char_sentry_create(this)
5574             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
5575         basic_ostream_char_sentry_destroy(this);
5576         basic_ios_char_setstate(base, IOSTATE_badbit);
5577         return this;
5578     }
5579
5580     basic_ostream_char_sentry_destroy(this);
5581     return this;
5582 }
5583
5584 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
5585 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
5586 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp, 12)
5587 basic_ostream_char* __thiscall basic_ostream_char_seekp(basic_ostream_char *this, streamoff off, int way)
5588 {
5589     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5590
5591     TRACE("(%p %ld %d)\n", this, off, way);
5592
5593     if(!ios_base_fail(&base->base)) {
5594         fpos_int seek;
5595
5596         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5597                 &seek, off, way, OPENMODE_out);
5598         if(seek.off==0 && seek.pos==-1 && seek.state==0)
5599             basic_ios_char_setstate(base, IOSTATE_failbit);
5600     }
5601     return this;
5602 }
5603
5604 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
5605 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
5606 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
5607 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
5608 {
5609     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5610
5611     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
5612
5613     if(!ios_base_fail(&base->base)) {
5614         fpos_int seek;
5615
5616         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
5617                 &seek, pos, OPENMODE_out);
5618         if(seek.off==0 && seek.pos==-1 && seek.state==0)
5619             basic_ios_char_setstate(base, IOSTATE_failbit);
5620     }
5621     return this;
5622 }
5623
5624 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
5625 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
5626 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
5627 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
5628 {
5629     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5630
5631     TRACE("(%p)\n", this);
5632
5633     if(!ios_base_fail(&base->base)) {
5634         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5635                 ret, 0, SEEKDIR_cur, OPENMODE_out);
5636     }else {
5637         ret->off = 0;
5638         ret->pos = -1;
5639         ret->state = 0;
5640     }
5641     return ret;
5642 }
5643
5644 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
5645 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
5646 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
5647 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
5648 {
5649     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5650
5651     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
5652
5653     if(!basic_ostream_char_sentry_create(this)
5654             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
5655         basic_ostream_char_sentry_destroy(this);
5656         basic_ios_char_setstate(base, IOSTATE_badbit);
5657         return this;
5658     }
5659
5660     basic_ostream_char_sentry_destroy(this);
5661     return this;
5662 }
5663
5664 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
5665 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
5666 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
5667 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
5668 {
5669     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5670     int state = IOSTATE_goodbit;
5671
5672     TRACE("(%p %d)\n", this, val);
5673
5674     if(basic_ostream_char_sentry_create(this)) {
5675         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5676         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5677         ostreambuf_iterator_char dest = {0, strbuf};
5678
5679         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
5680                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
5681                 ? (LONG)((unsigned short)val) : (LONG)val);
5682     }
5683     basic_ostream_char_sentry_destroy(this);
5684
5685     basic_ios_char_setstate(base, state);
5686     return this;
5687 }
5688
5689 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
5690 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
5691 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
5692 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
5693 {
5694     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5695     int state = IOSTATE_goodbit;
5696
5697     TRACE("(%p %u)\n", this, val);
5698
5699     if(basic_ostream_char_sentry_create(this)) {
5700         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5701         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5702         ostreambuf_iterator_char dest = {0, strbuf};
5703
5704         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5705     }
5706     basic_ostream_char_sentry_destroy(this);
5707
5708     basic_ios_char_setstate(base, state);
5709     return this;
5710 }
5711
5712 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
5713 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
5714 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
5715 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
5716 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
5717 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
5718 {
5719     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5720     int state = IOSTATE_goodbit;
5721
5722     TRACE("(%p %d)\n", this, val);
5723
5724     if(basic_ostream_char_sentry_create(this)) {
5725         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5726         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5727         ostreambuf_iterator_char dest = {0, strbuf};
5728
5729         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5730     }
5731     basic_ostream_char_sentry_destroy(this);
5732
5733     basic_ios_char_setstate(base, state);
5734     return this;
5735 }
5736
5737 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
5738 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
5739 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
5740 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
5741 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
5742 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
5743 {
5744     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5745     int state = IOSTATE_goodbit;
5746
5747     TRACE("(%p %u)\n", this, val);
5748
5749     if(basic_ostream_char_sentry_create(this)) {
5750         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5751         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5752         ostreambuf_iterator_char dest = {0, strbuf};
5753
5754         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5755     }
5756     basic_ostream_char_sentry_destroy(this);
5757
5758     basic_ios_char_setstate(base, state);
5759     return this;
5760 }
5761
5762 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
5763 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
5764 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
5765 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
5766 {
5767     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5768     int state = IOSTATE_goodbit;
5769
5770     TRACE("(%p %f)\n", this, val);
5771
5772     if(basic_ostream_char_sentry_create(this)) {
5773         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5774         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5775         ostreambuf_iterator_char dest = {0, strbuf};
5776
5777         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5778     }
5779     basic_ostream_char_sentry_destroy(this);
5780
5781     basic_ios_char_setstate(base, state);
5782     return this;
5783 }
5784
5785 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
5786 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
5787 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
5788 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
5789 {
5790     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5791     int state = IOSTATE_goodbit;
5792
5793     TRACE("(%p %lf)\n", this, val);
5794
5795     if(basic_ostream_char_sentry_create(this)) {
5796         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5797         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5798         ostreambuf_iterator_char dest = {0, strbuf};
5799
5800         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5801     }
5802     basic_ostream_char_sentry_destroy(this);
5803
5804     basic_ios_char_setstate(base, state);
5805     return this;
5806 }
5807
5808 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
5809 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
5810 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
5811 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
5812 {
5813     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5814     int state = IOSTATE_goodbit;
5815
5816     TRACE("(%p %lf)\n", this, val);
5817
5818     if(basic_ostream_char_sentry_create(this)) {
5819         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5820         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5821         ostreambuf_iterator_char dest = {0, strbuf};
5822
5823         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5824     }
5825     basic_ostream_char_sentry_destroy(this);
5826
5827     basic_ios_char_setstate(base, state);
5828     return this;
5829 }
5830
5831 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5832 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5833 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
5834 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
5835 {
5836     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5837     IOSB_iostate state = IOSTATE_badbit;
5838     int c = '\n';
5839
5840     TRACE("(%p %p)\n", this, val);
5841
5842     if(basic_ostream_char_sentry_create(this)) {
5843         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
5844                 c = basic_streambuf_char_snextc(val)) {
5845             state = IOSTATE_goodbit;
5846
5847             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
5848                 state = IOSTATE_badbit;
5849                 break;
5850             }
5851         }
5852     }else {
5853         state = IOSTATE_badbit;
5854     }
5855     basic_ostream_char_sentry_destroy(this);
5856
5857     ios_base_width_set(&base->base, 0);
5858     basic_ios_char_setstate(base, state);
5859     return this;
5860 }
5861
5862 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
5863 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
5864 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
5865 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
5866 {
5867     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5868     int state = IOSTATE_goodbit;
5869
5870     TRACE("(%p %p)\n", this, val);
5871
5872     if(basic_ostream_char_sentry_create(this)) {
5873         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5874         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5875         ostreambuf_iterator_char dest = {0, strbuf};
5876
5877         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5878     }
5879     basic_ostream_char_sentry_destroy(this);
5880
5881     basic_ios_char_setstate(base, state);
5882     return this;
5883 }
5884
5885 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
5886 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
5887 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
5888 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
5889 {
5890     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5891     int state = IOSTATE_goodbit;
5892
5893     TRACE("(%p)\n", this);
5894
5895     if(basic_ostream_char_sentry_create(this)) {
5896         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5897         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5898         ostreambuf_iterator_char dest = {0, strbuf};
5899
5900         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5901     }
5902     basic_ostream_char_sentry_destroy(this);
5903
5904     basic_ios_char_setstate(base, state);
5905     return this;
5906 }
5907
5908 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
5909 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
5910 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
5911 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
5912 {
5913     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5914     int state = IOSTATE_goodbit;
5915
5916     TRACE("(%p)\n", this);
5917
5918     if(basic_ostream_char_sentry_create(this)) {
5919         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5920         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5921         ostreambuf_iterator_char dest = {0, strbuf};
5922
5923         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5924     }
5925     basic_ostream_char_sentry_destroy(this);
5926
5927     basic_ios_char_setstate(base, state);
5928     return this;
5929 }
5930
5931 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
5932 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
5933 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
5934 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
5935 {
5936     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5937     int state = IOSTATE_goodbit;
5938
5939     TRACE("(%p %x)\n", this, val);
5940
5941     if(basic_ostream_char_sentry_create(this)) {
5942         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5943         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5944         ostreambuf_iterator_char dest = {0, strbuf};
5945
5946         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5947     }
5948     basic_ostream_char_sentry_destroy(this);
5949
5950     basic_ios_char_setstate(base, state);
5951     return this;
5952 }
5953
5954 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5955 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5956 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
5957 {
5958     TRACE("(%p)\n", ostr);
5959
5960     basic_ostream_char_put(ostr, '\n');
5961     basic_ostream_char_flush(ostr);
5962     return ostr;
5963 }
5964
5965 /* $?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 */
5966 /* ??$?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 */
5967 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
5968 {
5969     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5970     IOSB_iostate state = IOSTATE_goodbit;
5971
5972     TRACE("(%p %p)\n", ostr, str);
5973
5974     if(basic_ostream_char_sentry_create(ostr)) {
5975         MSVCP_size_t len = MSVCP_basic_string_char_length(str);
5976         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5977
5978         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5979             for(; pad!=0; pad--) {
5980                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5981                     state = IOSTATE_badbit;
5982                     break;
5983                 }
5984             }
5985         }
5986
5987         if(state == IOSTATE_goodbit) {
5988             if(basic_streambuf_char_sputn(base->strbuf, MSVCP_basic_string_char_c_str(str), len) != len)
5989                     state = IOSTATE_badbit;
5990         }
5991
5992         if(state == IOSTATE_goodbit) {
5993             for(; pad!=0; pad--) {
5994                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5995                     state = IOSTATE_badbit;
5996                     break;
5997                 }
5998             }
5999         }
6000
6001         base->base.wide = 0;
6002     }else {
6003         state = IOSTATE_badbit;
6004     }
6005     basic_ostream_char_sentry_destroy(ostr);
6006
6007     basic_ios_char_setstate(base, state);
6008     return ostr;
6009 }
6010
6011 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@C@Z */
6012 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@C@Z */
6013 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z */
6014 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z */
6015 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@E@Z */
6016 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@E@Z */
6017 basic_ostream_char* __cdecl basic_ostream_char_print_ch(basic_ostream_char *ostr, char ch)
6018 {
6019     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
6020     IOSB_iostate state = IOSTATE_goodbit;
6021
6022     TRACE("(%p %d)\n", ostr, ch);
6023
6024     if(basic_ostream_char_sentry_create(ostr)) {
6025         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6026
6027         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6028             for(; pad!=0; pad--) {
6029                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6030                     state = IOSTATE_badbit;
6031                     break;
6032                 }
6033             }
6034         }
6035
6036         if(state == IOSTATE_goodbit) {
6037             if(basic_streambuf_char_sputc(base->strbuf, ch) == EOF)
6038                 state = IOSTATE_badbit;
6039         }
6040
6041         if(state == IOSTATE_goodbit) {
6042             for(; pad!=0; pad--) {
6043                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6044                     state = IOSTATE_badbit;
6045                     break;
6046                 }
6047             }
6048         }
6049
6050         base->base.wide = 0;
6051     }else {
6052         state = IOSTATE_badbit;
6053     }
6054     basic_ostream_char_sentry_destroy(ostr);
6055
6056     basic_ios_char_setstate(base, state);
6057     return ostr;
6058 }
6059
6060 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBC@Z */
6061 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBC@Z */
6062 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z */
6063 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z */
6064 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBE@Z */
6065 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBE@Z */
6066 basic_ostream_char* __cdecl basic_ostream_char_print_str(basic_ostream_char *ostr, const char *str)
6067 {
6068     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
6069     IOSB_iostate state = IOSTATE_goodbit;
6070
6071     TRACE("(%p %s)\n", ostr, str);
6072
6073     if(basic_ostream_char_sentry_create(ostr)) {
6074         MSVCP_size_t len = strlen(str);
6075         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6076
6077         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6078             for(; pad!=0; pad--) {
6079                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6080                     state = IOSTATE_badbit;
6081                     break;
6082                 }
6083             }
6084         }
6085
6086         if(state == IOSTATE_goodbit) {
6087             if(basic_streambuf_char_sputn(base->strbuf, str, len) != len)
6088                 state = IOSTATE_badbit;
6089         }
6090
6091         if(state == IOSTATE_goodbit) {
6092             for(; pad!=0; pad--) {
6093                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6094                     state = IOSTATE_badbit;
6095                     break;
6096                 }
6097             }
6098         }
6099
6100         base->base.wide = 0;
6101     }else {
6102         state = IOSTATE_badbit;
6103     }
6104     basic_ostream_char_sentry_destroy(ostr);
6105
6106     basic_ios_char_setstate(base, state);
6107     return ostr;
6108 }
6109
6110 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6111 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6112 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
6113 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
6114         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
6115 {
6116     TRACE("(%p %p)\n", this, pfunc);
6117     pfunc(this);
6118     return this;
6119 }
6120
6121 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
6122 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
6123 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
6124 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
6125         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
6126 {
6127     TRACE("(%p %p)\n", this, pfunc);
6128     pfunc(basic_ostream_char_get_basic_ios(this));
6129     return this;
6130 }
6131
6132 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6133 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6134 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
6135 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
6136         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
6137 {
6138     TRACE("(%p %p)\n", this, pfunc);
6139     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
6140     return this;
6141 }
6142
6143 /* Caution: basic_ostream uses virtual inheritance. */
6144 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
6145 {
6146     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
6147 }
6148
6149 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
6150 {
6151     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
6152 }
6153
6154 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
6155 {
6156     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
6157 }
6158
6159 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6160 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6161 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_ctor, 16)
6162 basic_ostream_wchar* __thiscall basic_ostream_wchar_ctor(basic_ostream_wchar *this,
6163         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6164 {
6165     basic_ios_wchar *base;
6166
6167     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
6168
6169     if(virt_init) {
6170         this->vbtable = basic_ostream_wchar_vbtable;
6171         base = basic_ostream_wchar_get_basic_ios(this);
6172         basic_ios_wchar_ctor(base);
6173     }else {
6174         base = basic_ostream_wchar_get_basic_ios(this);
6175     }
6176
6177     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6178     basic_ios_wchar_init(base, strbuf, isstd);
6179     return this;
6180 }
6181
6182 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6183 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6184 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor, 16)
6185 basic_ostream_wchar* __thiscall basic_ostream_short_ctor(basic_ostream_wchar *this,
6186         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6187 {
6188     basic_ostream_wchar_ctor(this, strbuf, isstd, virt_init);
6189     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
6190     return this;
6191 }
6192
6193 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
6194 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
6195 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_ctor_uninitialized, 16)
6196 basic_ostream_wchar* __thiscall basic_ostream_wchar_ctor_uninitialized(basic_ostream_wchar *this,
6197         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
6198 {
6199     basic_ios_wchar *base;
6200
6201     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
6202
6203     if(virt_init) {
6204         this->vbtable = basic_ostream_wchar_vbtable;
6205         base = basic_ostream_wchar_get_basic_ios(this);
6206         basic_ios_wchar_ctor(base);
6207     }else {
6208         base = basic_ostream_wchar_get_basic_ios(this);
6209     }
6210
6211     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6212     if(addstd)
6213         ios_base_Addstd(&base->base);
6214     return this;
6215 }
6216
6217 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
6218 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
6219 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor_uninitialized, 16)
6220 basic_ostream_wchar* __thiscall basic_ostream_short_ctor_uninitialized(basic_ostream_wchar *this,
6221         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
6222 {
6223     basic_ostream_wchar_ctor_uninitialized(this, uninitialized, addstd, virt_init);
6224     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
6225     return this;
6226 }
6227
6228 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
6229 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
6230 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
6231 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
6232 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
6233 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
6234 {
6235     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6236
6237     /* don't destroy virtual base here */
6238     TRACE("(%p)\n", this);
6239 }
6240
6241 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6242 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6243 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6244 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6245 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
6246 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
6247 {
6248     TRACE("(%p)\n", this);
6249     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
6250     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
6251 }
6252
6253 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
6254 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
6255 {
6256     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6257
6258     TRACE("(%p %x)\n", this, flags);
6259
6260     if(flags & 2) {
6261         /* we have an array, with the number of elements stored before the first object */
6262         INT_PTR i, *ptr = (INT_PTR *)this-1;
6263
6264         for(i=*ptr-1; i>=0; i--)
6265             basic_ostream_wchar_vbase_dtor(this+i);
6266         MSVCRT_operator_delete(ptr);
6267     } else {
6268         basic_ostream_wchar_vbase_dtor(this);
6269         if(flags & 1)
6270             MSVCRT_operator_delete(this);
6271     }
6272
6273     return this;
6274 }
6275
6276 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
6277 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
6278 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
6279 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
6280 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
6281 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
6282 {
6283     /* this function is not matching C++ specification */
6284     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6285
6286     TRACE("(%p)\n", this);
6287
6288     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
6289             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
6290         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6291     return this;
6292 }
6293
6294 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6295 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6296 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6297 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6298 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar__Osfx, 4)
6299 void __thiscall basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
6300 {
6301     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6302
6303     TRACE("(%p)\n", this);
6304
6305     if(base->base.fmtfl & FMTFLAG_unitbuf)
6306         basic_ostream_wchar_flush(this);
6307 }
6308
6309 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6310 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6311 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6312 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6313 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
6314 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
6315 {
6316     TRACE("(%p)\n", this);
6317     basic_ostream_wchar__Osfx(this);
6318 }
6319
6320 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
6321 {
6322     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6323
6324     if(basic_ios_wchar_rdbuf_get(base))
6325         basic_streambuf_wchar__Lock(base->strbuf);
6326
6327     if(ios_base_good(&base->base) && base->stream)
6328         basic_ostream_wchar_flush(base->stream);
6329
6330     return ios_base_good(&base->base);
6331 }
6332
6333 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
6334 {
6335     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6336
6337     if(ios_base_good(&base->base) && !__uncaught_exception())
6338         basic_ostream_wchar_osfx(ostr);
6339
6340     if(basic_ios_wchar_rdbuf_get(base))
6341         basic_streambuf_wchar__Unlock(base->strbuf);
6342 }
6343
6344 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
6345 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
6346 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
6347 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
6348 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
6349 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
6350 {
6351     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6352
6353     TRACE("(%p)\n", this);
6354
6355     if(ios_base_good(&base->base) && base->stream)
6356         basic_ostream_wchar_flush(base->stream);
6357     return ios_base_good(&base->base);
6358 }
6359
6360 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
6361 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
6362 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
6363 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
6364 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
6365 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
6366 {
6367     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6368
6369     TRACE("(%p %c)\n", this, ch);
6370
6371     if(!basic_ostream_wchar_sentry_create(this)
6372             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
6373         basic_ostream_wchar_sentry_destroy(this);
6374         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6375         return this;
6376     }
6377
6378     basic_ostream_wchar_sentry_destroy(this);
6379     return this;
6380 }
6381
6382 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
6383 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
6384 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
6385 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
6386 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp, 12)
6387 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp(basic_ostream_wchar *this, streamoff off, int way)
6388 {
6389     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6390
6391     TRACE("(%p %ld %d)\n", this, off, way);
6392
6393     if(!ios_base_fail(&base->base)) {
6394         fpos_int seek;
6395
6396         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6397                 &seek, off, way, OPENMODE_out);
6398         if(seek.off==0 && seek.pos==-1 && seek.state==0)
6399             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6400     }
6401     return this;
6402 }
6403
6404 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6405 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6406 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6407 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6408 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
6409 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
6410 {
6411     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6412
6413     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6414
6415     if(!ios_base_fail(&base->base)) {
6416         fpos_int seek;
6417
6418         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
6419                 &seek, pos, OPENMODE_out);
6420         if(seek.off==0 && seek.pos==-1 && seek.state==0)
6421             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6422     }
6423     return this;
6424 }
6425
6426 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6427 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6428 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6429 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6430 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
6431 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
6432 {
6433     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6434
6435     TRACE("(%p)\n", this);
6436
6437     if(!ios_base_fail(&base->base)) {
6438         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6439                 ret, 0, SEEKDIR_cur, OPENMODE_out);
6440     }else {
6441         ret->off = 0;
6442         ret->pos = -1;
6443         ret->state = 0;
6444     }
6445     return ret;
6446 }
6447
6448 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
6449 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
6450 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
6451 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
6452 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 12)
6453 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
6454 {
6455     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6456
6457     TRACE("(%p %s %ld)\n", this, debugstr_w(str), count);
6458
6459     if(!basic_ostream_wchar_sentry_create(this)
6460             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
6461         basic_ostream_wchar_sentry_destroy(this);
6462         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6463         return this;
6464     }
6465
6466     basic_ostream_wchar_sentry_destroy(this);
6467     return this;
6468 }
6469
6470 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
6471 {
6472     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6473     int state = IOSTATE_goodbit;
6474
6475     TRACE("(%p %d)\n", this, val);
6476
6477     if(basic_ostream_wchar_sentry_create(this)) {
6478         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6479         ostreambuf_iterator_wchar dest = {0, strbuf};
6480
6481         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
6482                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
6483                 ? (LONG)((unsigned short)val) : (LONG)val);
6484     }
6485     basic_ostream_wchar_sentry_destroy(this);
6486
6487     basic_ios_wchar_setstate(base, state);
6488     return this;
6489 }
6490
6491 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@F@Z */
6492 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@F@Z */
6493 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_short, 8)
6494 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_short(basic_ostream_wchar *this, short val)
6495 {
6496     return basic_ostream_print_short(this, val, num_put_wchar_use_facet(
6497                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6498 }
6499
6500 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
6501 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
6502 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
6503 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
6504 {
6505     return basic_ostream_print_short(this, val, num_put_short_use_facet(
6506                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6507 }
6508
6509 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@G@Z */
6510 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@G@Z */
6511 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ushort, 8)
6512 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ushort(basic_ostream_wchar *this, unsigned short val)
6513 {
6514     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6515     int state = IOSTATE_goodbit;
6516
6517     TRACE("(%p %u)\n", this, val);
6518
6519     if(basic_ostream_wchar_sentry_create(this)) {
6520         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6521         const num_put *numput = num_put_wchar_use_facet(strbuf->loc);
6522         ostreambuf_iterator_wchar dest = {0, strbuf};
6523
6524         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6525     }
6526     basic_ostream_wchar_sentry_destroy(this);
6527
6528     basic_ios_wchar_setstate(base, state);
6529     return this;
6530 }
6531
6532 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
6533 {
6534     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6535     int state = IOSTATE_goodbit;
6536
6537     TRACE("(%p %d)\n", this, val);
6538
6539     if(basic_ostream_wchar_sentry_create(this)) {
6540         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6541         ostreambuf_iterator_wchar dest = {0, strbuf};
6542
6543         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6544     }
6545     basic_ostream_wchar_sentry_destroy(this);
6546
6547     basic_ios_wchar_setstate(base, state);
6548     return this;
6549 }
6550
6551 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@H@Z */
6552 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@H@Z */
6553 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@J@Z */
6554 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@J@Z */
6555 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int, 8)
6556 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int(basic_ostream_wchar *this, int val)
6557 {
6558     return basic_ostream_print_int(this, val, num_put_wchar_use_facet(
6559                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6560 }
6561
6562 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
6563 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
6564 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
6565 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
6566 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
6567 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
6568 {
6569     return basic_ostream_print_int(this, val, num_put_short_use_facet(
6570                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6571 }
6572
6573 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
6574 {
6575     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6576     int state = IOSTATE_goodbit;
6577
6578     TRACE("(%p %u)\n", this, val);
6579
6580     if(basic_ostream_wchar_sentry_create(this)) {
6581         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6582         ostreambuf_iterator_wchar dest = {0, strbuf};
6583
6584         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6585     }
6586     basic_ostream_wchar_sentry_destroy(this);
6587
6588     basic_ios_wchar_setstate(base, state);
6589     return this;
6590 }
6591
6592 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@I@Z */
6593 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@I@Z */
6594 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@K@Z */
6595 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@K@Z */
6596 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint, 8)
6597 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint(basic_ostream_wchar *this, unsigned int val)
6598 {
6599     return basic_ostream_print_uint(this, val, num_put_wchar_use_facet(
6600                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6601 }
6602
6603 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
6604 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
6605 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
6606 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
6607 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
6608 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
6609 {
6610     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
6611                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6612 }
6613
6614 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
6615 {
6616     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6617     int state = IOSTATE_goodbit;
6618
6619     TRACE("(%p %f)\n", this, val);
6620
6621     if(basic_ostream_wchar_sentry_create(this)) {
6622         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6623         ostreambuf_iterator_wchar dest = {0, strbuf};
6624
6625         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6626     }
6627     basic_ostream_wchar_sentry_destroy(this);
6628
6629     basic_ios_wchar_setstate(base, state);
6630     return this;
6631 }
6632
6633 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@M@Z */
6634 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@M@Z */
6635 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_float, 8)
6636 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_float(basic_ostream_wchar *this, float val)
6637 {
6638     return basic_ostream_print_float(this, val, num_put_wchar_use_facet(
6639                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6640 }
6641
6642 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
6643 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
6644 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
6645 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
6646 {
6647     return basic_ostream_print_float(this, val, num_put_short_use_facet(
6648                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6649 }
6650
6651 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
6652 {
6653     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6654     int state = IOSTATE_goodbit;
6655
6656     TRACE("(%p %lf)\n", this, val);
6657
6658     if(basic_ostream_wchar_sentry_create(this)) {
6659         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6660         ostreambuf_iterator_wchar dest = {0, strbuf};
6661
6662         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6663     }
6664     basic_ostream_wchar_sentry_destroy(this);
6665
6666     basic_ios_wchar_setstate(base, state);
6667     return this;
6668 }
6669
6670 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@N@Z */
6671 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@N@Z */
6672 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_double, 12)
6673 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_double(basic_ostream_wchar *this, double val)
6674 {
6675     return basic_ostream_print_double(this, val, num_put_wchar_use_facet(
6676                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6677 }
6678
6679 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
6680 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
6681 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
6682 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
6683 {
6684     return basic_ostream_print_double(this, val, num_put_short_use_facet(
6685                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6686 }
6687
6688 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
6689 {
6690     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6691     int state = IOSTATE_goodbit;
6692
6693     TRACE("(%p %lf)\n", this, val);
6694
6695     if(basic_ostream_wchar_sentry_create(this)) {
6696         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6697         ostreambuf_iterator_wchar dest = {0, strbuf};
6698
6699         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6700     }
6701     basic_ostream_wchar_sentry_destroy(this);
6702
6703     basic_ios_wchar_setstate(base, state);
6704     return this;
6705 }
6706
6707 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@O@Z */
6708 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@O@Z */
6709 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ldouble, 12)
6710 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ldouble(basic_ostream_wchar *this, double val)
6711 {
6712     return basic_ostream_print_ldouble(this, val, num_put_wchar_use_facet(
6713                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6714 }
6715
6716 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
6717 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
6718 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
6719 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
6720 {
6721     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
6722                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6723 }
6724
6725 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6726 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6727 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6728 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6729 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
6730 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
6731 {
6732     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6733     IOSB_iostate state = IOSTATE_badbit;
6734     unsigned short c = '\n';
6735
6736     TRACE("(%p %p)\n", this, val);
6737
6738     if(basic_ostream_wchar_sentry_create(this)) {
6739         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
6740                 c = basic_streambuf_wchar_snextc(val)) {
6741             state = IOSTATE_goodbit;
6742
6743             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
6744                 state = IOSTATE_badbit;
6745                 break;
6746             }
6747         }
6748     }else {
6749         state = IOSTATE_badbit;
6750     }
6751     basic_ostream_wchar_sentry_destroy(this);
6752
6753     ios_base_width_set(&base->base, 0);
6754     basic_ios_wchar_setstate(base, state);
6755     return this;
6756 }
6757
6758 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
6759 {
6760     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6761     int state = IOSTATE_goodbit;
6762
6763     TRACE("(%p %p)\n", this, val);
6764
6765     if(basic_ostream_wchar_sentry_create(this)) {
6766         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6767         ostreambuf_iterator_wchar dest = {0, strbuf};
6768
6769         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6770     }
6771     basic_ostream_wchar_sentry_destroy(this);
6772
6773     basic_ios_wchar_setstate(base, state);
6774     return this;
6775 }
6776
6777 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PBX@Z */
6778 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEBX@Z */
6779 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ptr, 8)
6780 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ptr(basic_ostream_wchar *this, const void *val)
6781 {
6782     return basic_ostream_print_ptr(this, val, num_put_wchar_use_facet(
6783                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6784 }
6785
6786 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
6787 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
6788 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
6789 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
6790 {
6791     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
6792                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6793 }
6794
6795 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
6796 {
6797     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6798     int state = IOSTATE_goodbit;
6799
6800     TRACE("(%p)\n", this);
6801
6802     if(basic_ostream_wchar_sentry_create(this)) {
6803         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6804         ostreambuf_iterator_wchar dest = {0, strbuf};
6805
6806         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6807     }
6808     basic_ostream_wchar_sentry_destroy(this);
6809
6810     basic_ios_wchar_setstate(base, state);
6811     return this;
6812 }
6813
6814 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_J@Z */
6815 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_J@Z */
6816 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int64, 12)
6817 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int64(basic_ostream_wchar *this, __int64 val)
6818 {
6819     return basic_ostream_print_int64(this, val, num_put_wchar_use_facet(
6820                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6821 }
6822
6823 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
6824 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
6825 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
6826 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
6827 {
6828     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
6829                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6830 }
6831
6832 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
6833 {
6834     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6835     int state = IOSTATE_goodbit;
6836
6837     TRACE("(%p)\n", this);
6838
6839     if(basic_ostream_wchar_sentry_create(this)) {
6840         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6841         ostreambuf_iterator_wchar dest = {0, strbuf};
6842
6843         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6844     }
6845     basic_ostream_wchar_sentry_destroy(this);
6846
6847     basic_ios_wchar_setstate(base, state);
6848     return this;
6849 }
6850
6851 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_K@Z */
6852 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_K@Z */
6853 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint64, 12)
6854 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6855 {
6856     return basic_ostream_print_uint64(this, val, num_put_wchar_use_facet(
6857                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6858 }
6859
6860 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
6861 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
6862 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
6863 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6864 {
6865     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
6866                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6867 }
6868
6869 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
6870 {
6871     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6872     int state = IOSTATE_goodbit;
6873
6874     TRACE("(%p %x)\n", this, val);
6875
6876     if(basic_ostream_wchar_sentry_create(this)) {
6877         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6878         ostreambuf_iterator_wchar dest = {0, strbuf};
6879
6880         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6881     }
6882     basic_ostream_wchar_sentry_destroy(this);
6883
6884     basic_ios_wchar_setstate(base, state);
6885     return this;
6886 }
6887
6888 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_N@Z */
6889 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_N@Z */
6890 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_bool, 8)
6891 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6892 {
6893     return basic_ostream_print_bool(this, val, num_put_wchar_use_facet(
6894                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6895 }
6896
6897 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
6898 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
6899 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
6900 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6901 {
6902     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
6903                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6904 }
6905
6906 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6907 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6908 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6909 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6910 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
6911 {
6912     TRACE("(%p)\n", ostr);
6913
6914     basic_ostream_wchar_put(ostr, '\n');
6915     basic_ostream_wchar_flush(ostr);
6916     return ostr;
6917 }
6918
6919 /* ??$?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 */
6920 /* ??$?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 */
6921 /* ??$?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 */
6922 /* ??$?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 */
6923 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_bstr(basic_ostream_wchar *ostr, const basic_string_wchar *str)
6924 {
6925     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6926     IOSB_iostate state = IOSTATE_goodbit;
6927
6928     TRACE("(%p %p)\n", ostr, str);
6929
6930     if(basic_ostream_wchar_sentry_create(ostr)) {
6931         MSVCP_size_t len = MSVCP_basic_string_wchar_length(str);
6932         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6933
6934         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6935             for(; pad!=0; pad--) {
6936                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6937                     state = IOSTATE_badbit;
6938                     break;
6939                 }
6940             }
6941         }
6942
6943         if(state == IOSTATE_goodbit) {
6944             if(basic_streambuf_wchar_sputn(base->strbuf, MSVCP_basic_string_wchar_c_str(str), len) != len)
6945                 state = IOSTATE_badbit;
6946         }
6947
6948         if(state == IOSTATE_goodbit) {
6949             for(; pad!=0; pad--) {
6950                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6951                     state = IOSTATE_badbit;
6952                     break;
6953                 }
6954             }
6955         }
6956
6957         base->base.wide = 0;
6958     }else {
6959         state = IOSTATE_badbit;
6960     }
6961     basic_ostream_wchar_sentry_destroy(ostr);
6962
6963     basic_ios_wchar_setstate(base, state);
6964     return ostr;
6965 }
6966
6967 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@_W@Z */
6968 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@_W@Z */
6969 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@G@Z */
6970 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@G@Z */
6971 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_ch(basic_ostream_wchar *ostr, wchar_t ch)
6972 {
6973     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6974     IOSB_iostate state = IOSTATE_goodbit;
6975
6976     TRACE("(%p %d)\n", ostr, ch);
6977
6978     if(basic_ostream_wchar_sentry_create(ostr)) {
6979         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6980
6981         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6982             for(; pad!=0; pad--) {
6983                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6984                     state = IOSTATE_badbit;
6985                     break;
6986                 }
6987             }
6988         }
6989
6990         if(state == IOSTATE_goodbit) {
6991             if(basic_streambuf_wchar_sputc(base->strbuf, ch) == WEOF)
6992                 state = IOSTATE_badbit;
6993         }
6994
6995         if(state == IOSTATE_goodbit) {
6996             for(; pad!=0; pad--) {
6997                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6998                     state = IOSTATE_badbit;
6999                     break;
7000                 }
7001             }
7002         }
7003
7004         base->base.wide = 0;
7005     }else {
7006         state = IOSTATE_badbit;
7007     }
7008     basic_ostream_wchar_sentry_destroy(ostr);
7009
7010     basic_ios_wchar_setstate(base, state);
7011     return ostr;
7012 }
7013
7014 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@PB_W@Z */
7015 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@PEB_W@Z */
7016 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@PBG@Z */
7017 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@PEBG@Z */
7018 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_str(basic_ostream_wchar *ostr, const wchar_t *str)
7019 {
7020     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
7021     IOSB_iostate state = IOSTATE_goodbit;
7022
7023     TRACE("(%p %s)\n", ostr, debugstr_w(str));
7024
7025     if(basic_ostream_wchar_sentry_create(ostr)) {
7026         MSVCP_size_t len = wcslen(str);
7027         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
7028
7029         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
7030             for(; pad!=0; pad--) {
7031                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7032                     state = IOSTATE_badbit;
7033                     break;
7034                 }
7035             }
7036         }
7037
7038         if(state == IOSTATE_goodbit) {
7039             if(basic_streambuf_wchar_sputn(base->strbuf, str, len) != len)
7040                                         state = IOSTATE_badbit;
7041         }
7042
7043         if(state == IOSTATE_goodbit) {
7044             for(; pad!=0; pad--) {
7045                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7046                     state = IOSTATE_badbit;
7047                     break;
7048                 }
7049             }
7050         }
7051
7052         base->base.wide = 0;
7053     }else {
7054         state = IOSTATE_badbit;
7055     }
7056     basic_ostream_wchar_sentry_destroy(ostr);
7057
7058     basic_ios_wchar_setstate(base, state);
7059     return ostr;
7060 }
7061
7062 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7063 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7064 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7065 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7066 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
7067 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
7068         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
7069 {
7070     TRACE("(%p %p)\n", this, pfunc);
7071     pfunc(this);
7072     return this;
7073 }
7074
7075 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
7076 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
7077 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
7078 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
7079 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
7080 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
7081         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
7082 {
7083     TRACE("(%p %p)\n", this, pfunc);
7084     pfunc(basic_ostream_wchar_get_basic_ios(this));
7085     return this;
7086 }
7087
7088 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7089 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7090 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7091 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7092 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
7093 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
7094         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
7095 {
7096     TRACE("(%p %p)\n", this, pfunc);
7097     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
7098     return this;
7099 }
7100
7101 /* Caution: basic_istream uses virtual inheritance. */
7102 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
7103 {
7104     return (basic_ios_char*)((char*)this+this->vbtable[1]);
7105 }
7106
7107 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
7108 {
7109     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
7110 }
7111
7112 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
7113 {
7114     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
7115 }
7116
7117 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
7118 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
7119 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_init, 20)
7120 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)
7121 {
7122     basic_ios_char *base;
7123
7124     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
7125
7126     if(virt_init) {
7127         this->vbtable = basic_istream_char_vbtable;
7128         base = basic_istream_char_get_basic_ios(this);
7129         basic_ios_char_ctor(base);
7130     }else {
7131         base = basic_istream_char_get_basic_ios(this);
7132     }
7133
7134     base->base.vtable = &MSVCP_basic_istream_char_vtable;
7135     this->count = 0;
7136     if(!noinit)
7137         basic_ios_char_init(base, strbuf, isstd);
7138     return this;
7139 }
7140
7141 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
7142 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
7143 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
7144 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7145 {
7146     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7147 }
7148
7149 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7150 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7151 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
7152 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
7153 {
7154     basic_ios_char *base;
7155
7156     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
7157
7158     if(virt_init) {
7159         this->vbtable = basic_istream_char_vbtable;
7160         base = basic_istream_char_get_basic_ios(this);
7161         basic_ios_char_ctor(base);
7162     }else {
7163         base = basic_istream_char_get_basic_ios(this);
7164     }
7165
7166     base->base.vtable = &MSVCP_basic_istream_char_vtable;
7167     ios_base_Addstd(&base->base);
7168     return this;
7169 }
7170
7171 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
7172 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
7173 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
7174 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
7175 {
7176     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
7177
7178     /* don't destroy virtual base here */
7179     TRACE("(%p)\n", this);
7180 }
7181
7182 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
7183 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
7184 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
7185 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
7186 {
7187     TRACE("(%p)\n", this);
7188     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
7189     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
7190 }
7191
7192 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
7193 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
7194 {
7195     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
7196
7197     TRACE("(%p %x)\n", this, flags);
7198
7199     if(flags & 2) {
7200         /* we have an array, with the number of elements stored before the first object */
7201         INT_PTR i, *ptr = (INT_PTR *)this-1;
7202
7203         for(i=*ptr-1; i>=0; i--)
7204             basic_istream_char_vbase_dtor(this+i);
7205         MSVCRT_operator_delete(ptr);
7206     } else {
7207         basic_istream_char_vbase_dtor(this);
7208         if(flags & 1)
7209             MSVCRT_operator_delete(this);
7210     }
7211
7212     return this;
7213 }
7214
7215 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
7216 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
7217 DEFINE_THISCALL_WRAPPER(basic_istream_char__Ipfx, 8)
7218 MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
7219 {
7220     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7221
7222     TRACE("(%p %d)\n", this, noskip);
7223
7224     if(!ios_base_good(&base->base)) {
7225         basic_ios_char_setstate(base, IOSTATE_failbit);
7226         return FALSE;
7227     }
7228
7229     if(basic_ios_char_tie_get(base))
7230         basic_ostream_char_flush(basic_ios_char_tie_get(base));
7231
7232     if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
7233         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7234         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
7235         int ch;
7236
7237         for(ch = basic_streambuf_char_sgetc(strbuf); ;
7238                 ch = basic_streambuf_char_snextc(strbuf)) {
7239             if(ch == EOF) {
7240                 basic_ios_char_setstate(base, IOSTATE_eofbit);
7241                 return FALSE;
7242             }
7243
7244             if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
7245                 break;
7246         }
7247     }
7248
7249     return TRUE;
7250 }
7251
7252 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
7253 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
7254 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
7255 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
7256 {
7257     return basic_istream_char__Ipfx(this, noskip);
7258 }
7259
7260 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
7261 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
7262 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
7263 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
7264 {
7265     TRACE("(%p)\n", this);
7266 }
7267
7268 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
7269 {
7270     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
7271
7272     if(basic_ios_char_rdbuf_get(base))
7273         basic_streambuf_char__Lock(base->strbuf);
7274
7275     return basic_istream_char_ipfx(istr, noskip);
7276 }
7277
7278 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
7279 {
7280     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
7281
7282     if(basic_ios_char_rdbuf_get(base))
7283         basic_streambuf_char__Unlock(base->strbuf);
7284 }
7285
7286 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
7287 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
7288 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
7289 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
7290 {
7291     TRACE("(%p)\n", this);
7292     return this->count;
7293 }
7294
7295 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7296 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7297 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
7298 int __thiscall basic_istream_char_get(basic_istream_char *this)
7299 {
7300     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7301     int ret;
7302
7303     TRACE("(%p)\n", this);
7304
7305     this->count = 0;
7306
7307     if(!basic_istream_char_sentry_create(this, TRUE)) {
7308         basic_istream_char_sentry_destroy(this);
7309         return EOF;
7310     }
7311
7312     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
7313     basic_istream_char_sentry_destroy(this);
7314     if(ret == EOF)
7315         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
7316     else
7317         this->count++;
7318
7319     return ret;
7320 }
7321
7322 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
7323 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
7324 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
7325 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
7326 {
7327     int ret;
7328
7329     TRACE("(%p %p)\n", this, ch);
7330
7331     ret = basic_istream_char_get(this);
7332     if(ret != EOF)
7333         *ch = (char)ret;
7334     return this;
7335 }
7336
7337 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7338 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7339 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
7340 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7341 {
7342     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7343     int ch = delim;
7344
7345     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7346
7347     this->count = 0;
7348
7349     if(basic_istream_char_sentry_create(this, TRUE)) {
7350         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7351
7352         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
7353                 ch = basic_streambuf_char_snextc(strbuf)) {
7354             if(ch==EOF || ch==delim)
7355                 break;
7356
7357             *str++ = ch;
7358             this->count++;
7359             count--;
7360         }
7361     }
7362     basic_istream_char_sentry_destroy(this);
7363
7364     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7365             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7366     if(count > 0)
7367         *str = 0;
7368     return this;
7369 }
7370
7371 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7372 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7373 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
7374 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
7375 {
7376     return basic_istream_char_get_str_delim(this, str, count, '\n');
7377 }
7378
7379 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7380 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7381 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
7382 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
7383 {
7384     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7385     int ch = delim;
7386
7387     TRACE("(%p %p %c)\n", this, strbuf, delim);
7388
7389     this->count = 0;
7390
7391     if(basic_istream_char_sentry_create(this, TRUE)) {
7392         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
7393
7394         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
7395                 ch = basic_streambuf_char_snextc(strbuf_read)) {
7396             if(ch==EOF || ch==delim)
7397                 break;
7398
7399             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
7400                 break;
7401             this->count++;
7402         }
7403     }
7404     basic_istream_char_sentry_destroy(this);
7405
7406     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7407             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7408     return this;
7409 }
7410
7411 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7412 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7413 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
7414 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
7415 {
7416     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
7417 }
7418
7419 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7420 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7421 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
7422 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7423 {
7424     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7425     int ch = delim;
7426
7427     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7428
7429     this->count = 0;
7430
7431     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
7432         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7433
7434         while(count > 1) {
7435             ch = basic_streambuf_char_sbumpc(strbuf);
7436
7437             if(ch==EOF || ch==delim)
7438                 break;
7439
7440             *str++ = ch;
7441             this->count++;
7442             count--;
7443         }
7444
7445         if(ch == delim)
7446             this->count++;
7447         else if(ch != EOF) {
7448             ch = basic_streambuf_char_sgetc(strbuf);
7449
7450             if(ch == delim) {
7451                 basic_streambuf_char__Gninc(strbuf);
7452                 this->count++;
7453             }
7454         }
7455     }
7456     basic_istream_char_sentry_destroy(this);
7457
7458     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
7459             (!this->count || (ch!=delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
7460     if(count > 0)
7461         *str = 0;
7462     return this;
7463 }
7464
7465 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7466 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7467 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
7468 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
7469 {
7470     return basic_istream_char_getline_delim(this, str, count, '\n');
7471 }
7472
7473 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
7474 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7475 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
7476 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
7477 {
7478     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7479     int ch = delim;
7480
7481     TRACE("(%p %ld %d)\n", this, count, delim);
7482
7483     this->count = 0;
7484
7485     if(basic_istream_char_sentry_create(this, TRUE)) {
7486         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7487
7488         while(count > 0) {
7489             ch = basic_streambuf_char_sbumpc(strbuf);
7490
7491             if(ch==EOF || ch==delim)
7492                 break;
7493
7494             this->count++;
7495             if(count != INT_MAX)
7496                 count--;
7497         }
7498     }
7499     basic_istream_char_sentry_destroy(this);
7500
7501     if(ch == EOF)
7502         basic_ios_char_setstate(base, IOSTATE_eofbit);
7503     return this;
7504 }
7505
7506 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7507 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7508 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
7509 int __thiscall basic_istream_char_peek(basic_istream_char *this)
7510 {
7511     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7512     int ret = EOF;
7513
7514     TRACE("(%p)\n", this);
7515
7516     this->count = 0;
7517
7518     if(basic_istream_char_sentry_create(this, TRUE))
7519         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7520     basic_istream_char_sentry_destroy(this);
7521     return ret;
7522 }
7523
7524 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
7525 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
7526 DEFINE_THISCALL_WRAPPER(basic_istream_char__Read_s, 16)
7527 basic_istream_char* __thiscall basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7528 {
7529     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7530     IOSB_iostate state = IOSTATE_goodbit;
7531
7532     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7533
7534     if(basic_istream_char_sentry_create(this, TRUE)) {
7535         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7536
7537         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
7538         if(this->count != count)
7539             state |= IOSTATE_failbit | IOSTATE_eofbit;
7540     }else {
7541         this->count = 0;
7542     }
7543     basic_istream_char_sentry_destroy(this);
7544
7545     basic_ios_char_setstate(base, state);
7546     return this;
7547 }
7548
7549 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7550 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7551 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
7552 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
7553 {
7554     return basic_istream_char__Read_s(this, str, count, count);
7555 }
7556
7557 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
7558 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
7559 DEFINE_THISCALL_WRAPPER(basic_istream_char__Readsome_s, 16)
7560 streamsize __thiscall basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7561 {
7562     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7563     IOSB_iostate state = IOSTATE_goodbit;
7564
7565     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7566
7567     this->count = 0;
7568
7569     if(basic_istream_char_sentry_create(this, TRUE)) {
7570         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
7571         if(avail > count)
7572             avail = count;
7573
7574         if(avail == -1)
7575             state |= IOSTATE_eofbit;
7576         else if(avail > 0)
7577             basic_istream_char__Read_s(this, str, size, avail);
7578     }else {
7579         state |= IOSTATE_failbit;
7580     }
7581     basic_istream_char_sentry_destroy(this);
7582
7583     basic_ios_char_setstate(base, state);
7584     return this->count;
7585 }
7586
7587 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
7588 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
7589 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
7590 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
7591 {
7592     return basic_istream_char__Readsome_s(this, str, count, count);
7593 }
7594
7595 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
7596 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
7597 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
7598 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
7599 {
7600     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7601     IOSB_iostate state = IOSTATE_goodbit;
7602
7603     TRACE("(%p %c)\n", this, ch);
7604
7605     this->count = 0;
7606
7607     if(basic_istream_char_sentry_create(this, TRUE)) {
7608         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7609
7610         if(!ios_base_good(&base->base))
7611             state |= IOSTATE_failbit;
7612         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
7613             state |= IOSTATE_badbit;
7614     }
7615     basic_istream_char_sentry_destroy(this);
7616
7617     basic_ios_char_setstate(base, state);
7618     return this;
7619 }
7620
7621 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
7622 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
7623 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
7624 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
7625 {
7626     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7627     IOSB_iostate state = IOSTATE_goodbit;
7628
7629     TRACE("(%p)\n", this);
7630
7631     this->count = 0;
7632
7633     if(basic_istream_char_sentry_create(this, TRUE)) {
7634         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7635
7636         if(!ios_base_good(&base->base))
7637             state |= IOSTATE_failbit;
7638         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
7639             state |= IOSTATE_badbit;
7640     }
7641     basic_istream_char_sentry_destroy(this);
7642
7643     basic_ios_char_setstate(base, state);
7644     return this;
7645 }
7646
7647 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7648 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7649 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
7650 int __thiscall basic_istream_char_sync(basic_istream_char *this)
7651 {
7652     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7653     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7654
7655     TRACE("(%p)\n", this);
7656
7657     if(!strbuf)
7658         return -1;
7659
7660     if(basic_istream_char_sentry_create(this, TRUE)) {
7661         if(basic_streambuf_char_pubsync(strbuf) != -1) {
7662             basic_istream_char_sentry_destroy(this);
7663             return 0;
7664         }
7665     }
7666     basic_istream_char_sentry_destroy(this);
7667
7668     basic_ios_char_setstate(base, IOSTATE_badbit);
7669     return -1;
7670 }
7671
7672 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7673 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7674 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
7675 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
7676 {
7677     TRACE("(%p %p)\n", this, ret);
7678
7679     if(basic_istream_char_sentry_create(this, TRUE)) {
7680         basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7681         if(!ios_base_fail(&base->base)) {
7682             basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
7683                     ret, 0, SEEKDIR_cur, OPENMODE_in);
7684             basic_istream_char_sentry_destroy(this);
7685
7686             if(ret->off==0 && ret->pos==-1 && ret->state==0)
7687                 basic_ios_char_setstate(base, IOSTATE_failbit);
7688             return ret;
7689         }
7690     }
7691     basic_istream_char_sentry_destroy(this);
7692
7693     ret->off = 0;
7694     ret->pos = -1;
7695     ret->state = 0;
7696     return ret;
7697 }
7698
7699 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
7700 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7701 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
7702 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
7703 {
7704     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7705
7706     TRACE("(%p %ld %d)\n", this, off, dir);
7707
7708     if(basic_istream_char_sentry_create(this, TRUE)) {
7709         if(!ios_base_fail(&base->base)) {
7710             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7711             fpos_int ret;
7712
7713             basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
7714             basic_istream_char_sentry_destroy(this);
7715
7716             if(ret.off==0 && ret.pos==-1 && ret.state==0)
7717                 basic_ios_char_setstate(base, IOSTATE_failbit);
7718             else
7719                 basic_ios_char_clear(base, IOSTATE_goodbit);
7720             return this;
7721         }
7722     }
7723     basic_istream_char_sentry_destroy(this);
7724
7725     basic_ios_char_setstate(base, IOSTATE_failbit);
7726     return this;
7727 }
7728
7729 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7730 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7731 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
7732 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
7733 {
7734     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7735
7736     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7737
7738     if(basic_istream_char_sentry_create(this, TRUE)) {
7739         if(!ios_base_fail(&base->base)) {
7740             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7741             fpos_int ret;
7742
7743             basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7744             basic_istream_char_sentry_destroy(this);
7745
7746             if(ret.off==0 && ret.pos==-1 && ret.state==0)
7747                 basic_ios_char_setstate(base, IOSTATE_failbit);
7748             else
7749                 basic_ios_char_clear(base, IOSTATE_goodbit);
7750             return this;
7751         }
7752     }
7753     basic_istream_char_sentry_destroy(this);
7754
7755     basic_ios_char_setstate(base, IOSTATE_failbit);
7756     return this;
7757 }
7758
7759 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
7760 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
7761 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
7762 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
7763 {
7764     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7765     int state = IOSTATE_goodbit;
7766
7767     TRACE("(%p %p)\n", this, v);
7768
7769     if(basic_istream_char_sentry_create(this, FALSE)) {
7770         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7771         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7772         istreambuf_iterator_char first={0}, last={0};
7773         LONG tmp;
7774
7775         first.strbuf = strbuf;
7776         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7777
7778         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7779             *v = tmp;
7780         else
7781             state |= IOSTATE_failbit;
7782     }
7783     basic_istream_char_sentry_destroy(this);
7784
7785     basic_ios_char_setstate(base, state);
7786     return this;
7787 }
7788
7789 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
7790 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
7791 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
7792 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
7793 {
7794     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7795     int state = IOSTATE_goodbit;
7796
7797     TRACE("(%p %p)\n", this, v);
7798
7799     if(basic_istream_char_sentry_create(this, FALSE)) {
7800         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7801         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7802         istreambuf_iterator_char first={0}, last={0};
7803
7804         first.strbuf = strbuf;
7805         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
7806     }
7807     basic_istream_char_sentry_destroy(this);
7808
7809     basic_ios_char_setstate(base, state);
7810     return this;
7811 }
7812
7813 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
7814 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
7815 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
7816 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
7817 {
7818     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7819     int state = IOSTATE_goodbit;
7820
7821     TRACE("(%p %p)\n", this, v);
7822
7823     if(basic_istream_char_sentry_create(this, FALSE)) {
7824         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7825         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7826         istreambuf_iterator_char first={0}, last={0};
7827
7828         first.strbuf = strbuf;
7829         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7830     }
7831     basic_istream_char_sentry_destroy(this);
7832
7833     basic_ios_char_setstate(base, state);
7834     return this;
7835 }
7836
7837 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
7838 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
7839 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
7840 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *v)
7841 {
7842     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7843     int state = IOSTATE_goodbit;
7844
7845     TRACE("(%p %p)\n", this, v);
7846
7847     if(basic_istream_char_sentry_create(this, FALSE)) {
7848         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7849         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7850         istreambuf_iterator_char first={0}, last={0};
7851
7852         first.strbuf = strbuf;
7853         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
7854     }
7855     basic_istream_char_sentry_destroy(this);
7856
7857     basic_ios_char_setstate(base, state);
7858     return this;
7859 }
7860
7861 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
7862 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
7863 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
7864 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
7865 {
7866     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7867     int state = IOSTATE_goodbit;
7868
7869     TRACE("(%p %p)\n", this, v);
7870
7871     if(basic_istream_char_sentry_create(this, FALSE)) {
7872         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7873         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7874         istreambuf_iterator_char first={0}, last={0};
7875
7876         first.strbuf = strbuf;
7877         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7878     }
7879     basic_istream_char_sentry_destroy(this);
7880
7881     basic_ios_char_setstate(base, state);
7882     return this;
7883 }
7884
7885 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
7886 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
7887 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
7888 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
7889 {
7890     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7891     int state = IOSTATE_goodbit;
7892
7893     TRACE("(%p %p)\n", this, v);
7894
7895     if(basic_istream_char_sentry_create(this, FALSE)) {
7896         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7897         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7898         istreambuf_iterator_char first={0}, last={0};
7899
7900         first.strbuf = strbuf;
7901         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
7902     }
7903     basic_istream_char_sentry_destroy(this);
7904
7905     basic_ios_char_setstate(base, state);
7906     return this;
7907 }
7908
7909 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
7910 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
7911 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
7912 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
7913 {
7914     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7915     int state = IOSTATE_goodbit;
7916
7917     TRACE("(%p %p)\n", this, v);
7918
7919     if(basic_istream_char_sentry_create(this, FALSE)) {
7920         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7921         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7922         istreambuf_iterator_char first={0}, last={0};
7923
7924         first.strbuf = strbuf;
7925         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
7926     }
7927     basic_istream_char_sentry_destroy(this);
7928
7929     basic_ios_char_setstate(base, state);
7930     return this;
7931 }
7932
7933 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
7934 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
7935 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
7936 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
7937 {
7938     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7939     int state = IOSTATE_goodbit;
7940
7941     TRACE("(%p %p)\n", this, v);
7942
7943     if(basic_istream_char_sentry_create(this, FALSE)) {
7944         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7945         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7946         istreambuf_iterator_char first={0}, last={0};
7947
7948         first.strbuf = strbuf;
7949         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
7950     }
7951     basic_istream_char_sentry_destroy(this);
7952
7953     basic_ios_char_setstate(base, state);
7954     return this;
7955 }
7956
7957 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
7958 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
7959 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
7960 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
7961 {
7962     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7963     int state = IOSTATE_goodbit;
7964
7965     TRACE("(%p %p)\n", this, v);
7966
7967     if(basic_istream_char_sentry_create(this, FALSE)) {
7968         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7969         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7970         istreambuf_iterator_char first={0}, last={0};
7971
7972         first.strbuf = strbuf;
7973         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
7974     }
7975     basic_istream_char_sentry_destroy(this);
7976
7977     basic_ios_char_setstate(base, state);
7978     return this;
7979 }
7980
7981 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
7982 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
7983 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
7984 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
7985 {
7986     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7987     int state = IOSTATE_goodbit;
7988
7989     TRACE("(%p %p)\n", this, v);
7990
7991     if(basic_istream_char_sentry_create(this, FALSE)) {
7992         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7993         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7994         istreambuf_iterator_char first={0}, last={0};
7995
7996         first.strbuf = strbuf;
7997         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
7998     }
7999     basic_istream_char_sentry_destroy(this);
8000
8001     basic_ios_char_setstate(base, state);
8002     return this;
8003 }
8004
8005 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
8006 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
8007 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
8008 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
8009 {
8010     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8011     int state = IOSTATE_goodbit;
8012
8013     TRACE("(%p %p)\n", this, v);
8014
8015     if(basic_istream_char_sentry_create(this, FALSE)) {
8016         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8017         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8018         istreambuf_iterator_char first={0}, last={0};
8019
8020         first.strbuf = strbuf;
8021         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
8022     }
8023     basic_istream_char_sentry_destroy(this);
8024
8025     basic_ios_char_setstate(base, state);
8026     return this;
8027 }
8028
8029 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
8030 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
8031 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
8032 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
8033 {
8034     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8035     int state = IOSTATE_goodbit;
8036
8037     TRACE("(%p %p)\n", this, v);
8038
8039     if(basic_istream_char_sentry_create(this, FALSE)) {
8040         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8041         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8042         istreambuf_iterator_char first={0}, last={0};
8043
8044         first.strbuf = strbuf;
8045         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
8046     }
8047     basic_istream_char_sentry_destroy(this);
8048
8049     basic_ios_char_setstate(base, state);
8050     return this;
8051 }
8052
8053 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
8054 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
8055 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
8056 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
8057 {
8058     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8059     int state = IOSTATE_goodbit;
8060
8061     TRACE("(%p %p)\n", this, v);
8062
8063     if(basic_istream_char_sentry_create(this, FALSE)) {
8064         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8065         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8066         istreambuf_iterator_char first={0}, last={0};
8067
8068         first.strbuf = strbuf;
8069         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
8070     }
8071     basic_istream_char_sentry_destroy(this);
8072
8073     basic_ios_char_setstate(base, state);
8074     return this;
8075 }
8076
8077 /* ??$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 */
8078 /* ??$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 */
8079 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
8080         basic_istream_char *istream, basic_string_char *str, char delim)
8081 {
8082     IOSB_iostate state = IOSTATE_failbit;
8083     int c = delim;
8084
8085     TRACE("(%p %p %c)\n", istream, str, delim);
8086
8087     if(basic_istream_char_sentry_create(istream, TRUE)) {
8088         MSVCP_basic_string_char_clear(str);
8089
8090         for(c = basic_istream_char_get(istream); c!=delim && c!=EOF;
8091                 c = basic_istream_char_get(istream)) {
8092             state = IOSTATE_goodbit;
8093             MSVCP_basic_string_char_append_ch(str, c);
8094         }
8095     }
8096     basic_istream_char_sentry_destroy(istream);
8097
8098     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
8099         state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8100     return istream;
8101 }
8102
8103 /* ??$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 */
8104 /* ??$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 */
8105 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
8106         basic_istream_char *istream, basic_string_char *str)
8107 {
8108     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
8109 }
8110
8111 /* ??$?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 */
8112 /* ??$?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 */
8113 basic_istream_char* __cdecl basic_istream_char_read_bstr(
8114         basic_istream_char *istream, basic_string_char *str)
8115 {
8116     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
8117     IOSB_iostate state = IOSTATE_failbit;
8118     int c = '\n';
8119
8120     TRACE("(%p %p)\n", istream, str);
8121
8122     if(basic_istream_char_sentry_create(istream, FALSE)) {
8123         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
8124         MSVCP_size_t count = ios_base_width_get(&base->base);
8125
8126         if(!count)
8127             count = -1;
8128
8129         MSVCP_basic_string_char_clear(str);
8130
8131         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
8132                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8133                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
8134             state = IOSTATE_goodbit;
8135             MSVCP_basic_string_char_append_ch(str, c);
8136         }
8137     }
8138     basic_istream_char_sentry_destroy(istream);
8139
8140     ios_base_width_set(&base->base, 0);
8141     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8142     return istream;
8143 }
8144
8145 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z */
8146 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z */
8147 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAC@Z */
8148 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAC@Z */
8149 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAE@Z */
8150 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAE@Z */
8151 basic_istream_char* __cdecl basic_istream_char_read_str(basic_istream_char *istream, char *str)
8152 {
8153     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
8154     IOSB_iostate state = IOSTATE_failbit;
8155     int c = '\n';
8156
8157     TRACE("(%p %p)\n", istream, str);
8158
8159     if(basic_istream_char_sentry_create(istream, FALSE)) {
8160         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
8161         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
8162
8163         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
8164                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8165                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
8166             state = IOSTATE_goodbit;
8167             *str++ = c;
8168         }
8169     }
8170     basic_istream_char_sentry_destroy(istream);
8171
8172     *str = 0;
8173     ios_base_width_set(&base->base, 0);
8174     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8175     return istream;
8176 }
8177
8178 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z */
8179 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAD@Z */
8180 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z */
8181 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAC@Z */
8182 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z */
8183 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAE@Z */
8184 basic_istream_char* __cdecl basic_istream_char_read_ch(basic_istream_char *istream, char *ch)
8185 {
8186     IOSB_iostate state = IOSTATE_failbit;
8187     int c = 0;
8188
8189     TRACE("(%p %p)\n", istream, ch);
8190
8191     if(basic_istream_char_sentry_create(istream, FALSE)) {
8192         c = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(
8193                     basic_istream_char_get_basic_ios(istream)));
8194         if(c != EOF) {
8195             state = IOSTATE_goodbit;
8196             *ch = c;
8197         }
8198     }
8199     basic_istream_char_sentry_destroy(istream);
8200
8201     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
8202             state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8203     return istream;
8204 }
8205
8206 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
8207 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
8208 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
8209 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
8210         basic_istream_char *this, basic_streambuf_char *streambuf)
8211 {
8212     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8213     IOSB_iostate state = IOSTATE_failbit;
8214     int c = '\n';
8215
8216     TRACE("(%p %p)\n", this, streambuf);
8217
8218     if(basic_istream_char_sentry_create(this, FALSE)) {
8219         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
8220                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
8221             state = IOSTATE_goodbit;
8222             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
8223                 break;
8224         }
8225     }
8226     basic_istream_char_sentry_destroy(this);
8227
8228     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8229     return this;
8230 }
8231
8232 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
8233 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
8234 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
8235 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
8236         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
8237 {
8238     TRACE("(%p %p)\n", this, pfunc);
8239     pfunc(this);
8240     return this;
8241 }
8242
8243 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
8244 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
8245 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
8246 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
8247         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
8248 {
8249     TRACE("(%p %p)\n", this, pfunc);
8250     pfunc(basic_istream_char_get_basic_ios(this));
8251     return this;
8252 }
8253
8254 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
8255 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
8256 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
8257 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
8258         ios_base* (__cdecl *pfunc)(ios_base*))
8259 {
8260     TRACE("(%p %p)\n", this, pfunc);
8261     pfunc(&basic_istream_char_get_basic_ios(this)->base);
8262     return this;
8263 }
8264
8265 /* Caution: basic_istream uses virtual inheritance. */
8266 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
8267 {
8268     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
8269 }
8270
8271 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
8272 {
8273     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
8274 }
8275
8276 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
8277 {
8278     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
8279 }
8280
8281 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
8282 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
8283 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_init, 20)
8284 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_init(basic_istream_wchar *this,
8285         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
8286 {
8287     basic_ios_wchar *base;
8288
8289     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
8290
8291     if(virt_init) {
8292         this->vbtable = basic_istream_wchar_vbtable;
8293         base = basic_istream_wchar_get_basic_ios(this);
8294         basic_ios_wchar_ctor(base);
8295     }else {
8296         base = basic_istream_wchar_get_basic_ios(this);
8297     }
8298
8299     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8300     this->count = 0;
8301     if(!noinit)
8302         basic_ios_wchar_init(base, strbuf, isstd);
8303     return this;
8304 }
8305
8306 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
8307 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
8308 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_init, 20)
8309 basic_istream_wchar* __thiscall basic_istream_short_ctor_init(basic_istream_wchar *this,
8310         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
8311 {
8312     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
8313     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8314     return this;
8315 }
8316
8317 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8318 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8319 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor, 16)
8320 basic_istream_wchar* __thiscall basic_istream_wchar_ctor(basic_istream_wchar *this,
8321         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8322 {
8323     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8324 }
8325
8326 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8327 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8328 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor, 16)
8329 basic_istream_wchar* __thiscall basic_istream_short_ctor(basic_istream_wchar *this,
8330         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8331 {
8332     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8333 }
8334
8335 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8336 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8337 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_uninitialized, 12)
8338 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_uninitialized(
8339         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8340 {
8341     basic_ios_wchar *base;
8342
8343     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
8344
8345     if(virt_init) {
8346         this->vbtable = basic_istream_wchar_vbtable;
8347         base = basic_istream_wchar_get_basic_ios(this);
8348         basic_ios_wchar_ctor(base);
8349     }else {
8350         base = basic_istream_wchar_get_basic_ios(this);
8351     }
8352
8353     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8354     ios_base_Addstd(&base->base);
8355     return this;
8356 }
8357
8358 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8359 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8360 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
8361 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
8362         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8363 {
8364     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
8365     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8366     return this;
8367 }
8368
8369 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
8370 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
8371 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
8372 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
8373 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
8374 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
8375 {
8376     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8377
8378     /* don't destroy virtual base here */
8379     TRACE("(%p)\n", this);
8380 }
8381
8382 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8383 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8384 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8385 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8386 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
8387 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
8388 {
8389     TRACE("(%p)\n", this);
8390     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
8391     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
8392 }
8393
8394 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
8395 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
8396 {
8397     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8398
8399     TRACE("(%p %x)\n", this, flags);
8400
8401     if(flags & 2) {
8402         /* we have an array, with the number of elements stored before the first object */
8403         INT_PTR i, *ptr = (INT_PTR *)this-1;
8404
8405         for(i=*ptr-1; i>=0; i--)
8406             basic_istream_wchar_vbase_dtor(this+i);
8407         MSVCRT_operator_delete(ptr);
8408     } else {
8409         basic_istream_wchar_vbase_dtor(this);
8410         if(flags & 1)
8411             MSVCRT_operator_delete(this);
8412     }
8413
8414     return this;
8415 }
8416
8417 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8418 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8419 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8420 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8421 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Ipfx, 8)
8422 MSVCP_bool __thiscall basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8423 {
8424     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8425
8426     TRACE("(%p %d)\n", this, noskip);
8427
8428     if(!ios_base_good(&base->base)) {
8429         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8430         return FALSE;
8431     }
8432
8433     if(basic_ios_wchar_tie_get(base))
8434         basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
8435
8436     if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
8437         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8438         const ctype_wchar *ctype = ctype_wchar_use_facet(base->strbuf->loc);
8439         int ch;
8440
8441         for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
8442                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8443             if(ch == WEOF) {
8444                 basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8445                 return FALSE;
8446             }
8447
8448             if(!ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
8449                 break;
8450         }
8451     }
8452
8453     return TRUE;
8454 }
8455
8456 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8457 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8458 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8459 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8460 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
8461 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8462 {
8463     return basic_istream_wchar__Ipfx(this, noskip);
8464 }
8465
8466 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8467 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8468 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8469 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8470 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
8471 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
8472 {
8473     TRACE("(%p)\n", this);
8474 }
8475
8476 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
8477 {
8478     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8479
8480     if(basic_ios_wchar_rdbuf_get(base))
8481         basic_streambuf_wchar__Lock(base->strbuf);
8482
8483     return basic_istream_wchar_ipfx(istr, noskip);
8484 }
8485
8486 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
8487 {
8488     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8489
8490     if(basic_ios_wchar_rdbuf_get(base))
8491         basic_streambuf_wchar__Unlock(base->strbuf);
8492 }
8493
8494 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
8495 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
8496 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
8497 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
8498 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
8499 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
8500 {
8501     TRACE("(%p)\n", this);
8502     return this->count;
8503 }
8504
8505 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8506 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8507 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8508 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8509 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
8510 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
8511 {
8512     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8513     int ret;
8514
8515     TRACE("(%p)\n", this);
8516
8517     this->count = 0;
8518
8519     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
8520         basic_istream_wchar_sentry_destroy(this);
8521         return WEOF;
8522     }
8523
8524     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
8525     basic_istream_wchar_sentry_destroy(this);
8526     if(ret == WEOF)
8527         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
8528     else
8529         this->count++;
8530
8531     return ret;
8532 }
8533
8534 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
8535 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
8536 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
8537 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
8538 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
8539 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
8540 {
8541     unsigned short ret;
8542
8543     TRACE("(%p %p)\n", this, ch);
8544
8545     ret = basic_istream_wchar_get(this);
8546     if(ret != WEOF)
8547         *ch = (wchar_t)ret;
8548     return this;
8549 }
8550
8551 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8552 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8553 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8554 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8555 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 16)
8556 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8557 {
8558     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8559     unsigned short ch = delim;
8560
8561     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8562
8563     this->count = 0;
8564
8565     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8566         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8567
8568         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
8569                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8570             if(ch==WEOF || ch==delim)
8571                 break;
8572
8573             *str++ = ch;
8574             this->count++;
8575             count--;
8576         }
8577     }
8578     basic_istream_wchar_sentry_destroy(this);
8579
8580     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8581             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8582     if(count > 0)
8583         *str = 0;
8584     return this;
8585 }
8586
8587 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8588 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8589 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8590 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8591 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 12)
8592 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
8593 {
8594     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
8595 }
8596
8597 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8598 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8599 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8600 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8601 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
8602 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
8603 {
8604     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8605     unsigned short ch = delim;
8606
8607     TRACE("(%p %p %c)\n", this, strbuf, delim);
8608
8609     this->count = 0;
8610
8611     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8612         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
8613
8614         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
8615                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
8616             if(ch==WEOF || ch==delim)
8617                 break;
8618
8619             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
8620                 break;
8621             this->count++;
8622         }
8623     }
8624     basic_istream_wchar_sentry_destroy(this);
8625
8626     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8627             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8628     return this;
8629 }
8630
8631 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8632 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8633 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8634 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8635 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
8636 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
8637 {
8638     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
8639 }
8640
8641 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8642 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8643 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8644 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8645 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 16)
8646 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8647 {
8648     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8649     unsigned short ch = delim;
8650
8651     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8652
8653     this->count = 0;
8654
8655     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
8656         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8657
8658         while(count > 1) {
8659             ch = basic_streambuf_wchar_sbumpc(strbuf);
8660
8661             if(ch==WEOF || ch==delim)
8662                 break;
8663
8664             *str++ = ch;
8665             this->count++;
8666             count--;
8667         }
8668
8669         if(ch == delim)
8670             this->count++;
8671         else if(ch != WEOF) {
8672             ch = basic_streambuf_wchar_sgetc(strbuf);
8673
8674             if(ch == delim) {
8675                 basic_streambuf_wchar__Gninc(strbuf);
8676                 this->count++;
8677             }
8678         }
8679     }
8680     basic_istream_wchar_sentry_destroy(this);
8681
8682     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
8683             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
8684     if(count > 0)
8685         *str = 0;
8686     return this;
8687 }
8688
8689 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8690 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8691 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8692 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8693 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 12)
8694 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
8695 {
8696     return basic_istream_wchar_getline_delim(this, str, count, '\n');
8697 }
8698
8699 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
8700 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
8701 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
8702 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
8703 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 12)
8704 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
8705 {
8706     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8707     unsigned short ch = delim;
8708
8709     TRACE("(%p %ld %d)\n", this, count, delim);
8710
8711     this->count = 0;
8712
8713     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8714         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8715
8716         while(count > 0) {
8717             ch = basic_streambuf_wchar_sbumpc(strbuf);
8718
8719             if(ch==WEOF || ch==delim)
8720                 break;
8721
8722             this->count++;
8723             if(count != INT_MAX)
8724                 count--;
8725         }
8726     }
8727     basic_istream_wchar_sentry_destroy(this);
8728
8729     if(ch == WEOF)
8730         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8731     return this;
8732 }
8733
8734 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8735 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8736 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8737 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8738 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
8739 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
8740 {
8741     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8742     unsigned short ret = WEOF;
8743
8744     TRACE("(%p)\n", this);
8745
8746     this->count = 0;
8747
8748     if(basic_istream_wchar_sentry_create(this, TRUE))
8749         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8750     basic_istream_wchar_sentry_destroy(this);
8751     return ret;
8752 }
8753
8754 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
8755 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
8756 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
8757 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
8758 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Read_s, 16)
8759 basic_istream_wchar* __thiscall basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8760 {
8761     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8762     IOSB_iostate state = IOSTATE_goodbit;
8763
8764     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8765
8766     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8767         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8768
8769         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
8770         if(this->count != count)
8771             state |= IOSTATE_failbit | IOSTATE_eofbit;
8772     }else {
8773         this->count = 0;
8774     }
8775     basic_istream_wchar_sentry_destroy(this);
8776
8777     basic_ios_wchar_setstate(base, state);
8778     return this;
8779 }
8780
8781 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8782 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8783 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8784 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8785 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 12)
8786 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
8787 {
8788     return basic_istream_wchar__Read_s(this, str, count, count);
8789 }
8790
8791 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
8792 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
8793 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
8794 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
8795 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Readsome_s, 16)
8796 streamsize __thiscall basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8797 {
8798     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8799     IOSB_iostate state = IOSTATE_goodbit;
8800
8801     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8802
8803     this->count = 0;
8804
8805     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8806         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
8807         if(avail > count)
8808             avail = count;
8809
8810         if(avail == -1)
8811             state |= IOSTATE_eofbit;
8812         else if(avail > 0)
8813             basic_istream_wchar__Read_s(this, str, size, avail);
8814     }else {
8815         state |= IOSTATE_failbit;
8816     }
8817     basic_istream_wchar_sentry_destroy(this);
8818
8819     basic_ios_wchar_setstate(base, state);
8820     return this->count;
8821 }
8822
8823 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
8824 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
8825 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
8826 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
8827 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 12)
8828 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
8829 {
8830     return basic_istream_wchar__Readsome_s(this, str, count, count);
8831 }
8832
8833 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
8834 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
8835 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
8836 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
8837 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
8838 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
8839 {
8840     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8841     IOSB_iostate state = IOSTATE_goodbit;
8842
8843     TRACE("(%p %c)\n", this, ch);
8844
8845     this->count = 0;
8846
8847     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8848         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8849
8850         if(!ios_base_good(&base->base))
8851             state |= IOSTATE_failbit;
8852         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
8853             state |= IOSTATE_badbit;
8854     }
8855     basic_istream_wchar_sentry_destroy(this);
8856
8857     basic_ios_wchar_setstate(base, state);
8858     return this;
8859 }
8860
8861 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
8862 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
8863 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
8864 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
8865 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
8866 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
8867 {
8868     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8869     IOSB_iostate state = IOSTATE_goodbit;
8870
8871     TRACE("(%p)\n", this);
8872
8873     this->count = 0;
8874
8875     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8876         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8877
8878         if(!ios_base_good(&base->base))
8879             state |= IOSTATE_failbit;
8880         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
8881             state |= IOSTATE_badbit;
8882     }
8883     basic_istream_wchar_sentry_destroy(this);
8884
8885     basic_ios_wchar_setstate(base, state);
8886     return this;
8887 }
8888
8889 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
8890 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
8891 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
8892 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
8893 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
8894 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
8895 {
8896     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8897     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8898
8899     TRACE("(%p)\n", this);
8900
8901     if(!strbuf)
8902         return -1;
8903
8904     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8905         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
8906             basic_istream_wchar_sentry_destroy(this);
8907             return 0;
8908         }
8909     }
8910     basic_istream_wchar_sentry_destroy(this);
8911
8912     basic_ios_wchar_setstate(base, IOSTATE_badbit);
8913     return -1;
8914 }
8915
8916 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8917 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8918 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8919 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8920 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
8921 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
8922 {
8923     TRACE("(%p %p)\n", this, ret);
8924
8925     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8926         basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8927         if(!ios_base_fail(&base->base)) {
8928             basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
8929                     ret, 0, SEEKDIR_cur, OPENMODE_in);
8930             basic_istream_wchar_sentry_destroy(this);
8931
8932             if(ret->off==0 && ret->pos==-1 && ret->state==0)
8933                 basic_ios_wchar_setstate(base, IOSTATE_failbit);
8934             return ret;
8935         }
8936     }
8937     basic_istream_wchar_sentry_destroy(this);
8938
8939     ret->off = 0;
8940     ret->pos = -1;
8941     ret->state = 0;
8942     return ret;
8943 }
8944
8945 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
8946 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
8947 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
8948 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
8949 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 12)
8950 basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir)
8951 {
8952     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8953
8954     TRACE("(%p %ld %d)\n", this, off, dir);
8955
8956     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8957         if(!ios_base_fail(&base->base)) {
8958             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8959             fpos_int ret;
8960
8961             basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
8962             basic_istream_wchar_sentry_destroy(this);
8963
8964             if(ret.off==0 && ret.pos==-1 && ret.state==0)
8965                 basic_ios_wchar_setstate(base, IOSTATE_failbit);
8966             else
8967                 basic_ios_wchar_clear(base, IOSTATE_goodbit);
8968             return this;
8969         }
8970     }
8971     basic_istream_wchar_sentry_destroy(this);
8972
8973     basic_ios_wchar_setstate(base, IOSTATE_failbit);
8974     return this;
8975 }
8976
8977 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8978 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8979 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8980 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8981 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
8982 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
8983 {
8984     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8985
8986     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
8987
8988     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8989         if(!ios_base_fail(&base->base)) {
8990             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8991             fpos_int ret;
8992
8993             basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
8994             basic_istream_wchar_sentry_destroy(this);
8995
8996             if(ret.off==0 && ret.pos==-1 && ret.state==0)
8997                 basic_ios_wchar_setstate(base, IOSTATE_failbit);
8998             else
8999                 basic_ios_wchar_clear(base, IOSTATE_goodbit);
9000             return this;
9001         }
9002     }
9003     basic_istream_wchar_sentry_destroy(this);
9004
9005     basic_ios_wchar_setstate(base, IOSTATE_failbit);
9006     return this;
9007 }
9008
9009 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
9010 {
9011     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9012     int state = IOSTATE_goodbit;
9013
9014     TRACE("(%p %p)\n", this, v);
9015
9016     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9017         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9018         istreambuf_iterator_wchar first={0}, last={0};
9019         LONG tmp;
9020
9021         first.strbuf = strbuf;
9022         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
9023
9024         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
9025             *v = tmp;
9026         else
9027             state |= IOSTATE_failbit;
9028     }
9029     basic_istream_wchar_sentry_destroy(this);
9030
9031     basic_ios_wchar_setstate(base, state);
9032     return this;
9033 }
9034
9035 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAF@Z */
9036 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAF@Z */
9037 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_short, 8)
9038 basic_istream_wchar* __thiscall basic_istream_wchar_read_short(basic_istream_wchar *this, short *v)
9039 {
9040     return basic_istream_read_short(this, v, num_get_wchar_use_facet(
9041                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9042 }
9043
9044 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
9045 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
9046 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
9047 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
9048 {
9049     return basic_istream_read_short(this, v, num_get_short_use_facet(
9050                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9051 }
9052
9053 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAG@Z */
9054 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAG@Z */
9055 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ushort, 8)
9056 basic_istream_wchar* __thiscall basic_istream_wchar_read_ushort(basic_istream_wchar *this, unsigned short *v)
9057 {
9058     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9059     int state = IOSTATE_goodbit;
9060
9061     TRACE("(%p %p)\n", this, v);
9062
9063     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9064         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9065         const num_get *numget = num_get_wchar_use_facet(strbuf->loc);
9066         istreambuf_iterator_wchar first={0}, last={0};
9067
9068         first.strbuf = strbuf;
9069         num_get_wchar_get_ushort(numget, &last, first, last, &base->base, &state, v);
9070     }
9071     basic_istream_wchar_sentry_destroy(this);
9072
9073     basic_ios_wchar_setstate(base, state);
9074     return this;
9075 }
9076
9077 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
9078 {
9079     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9080     int state = IOSTATE_goodbit;
9081
9082     TRACE("(%p %p)\n", this, v);
9083
9084     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9085         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9086         istreambuf_iterator_wchar first={0}, last={0};
9087
9088         first.strbuf = strbuf;
9089         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
9090     }
9091     basic_istream_wchar_sentry_destroy(this);
9092
9093     basic_ios_wchar_setstate(base, state);
9094     return this;
9095 }
9096
9097 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAH@Z */
9098 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAH@Z */
9099 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int, 8)
9100 basic_istream_wchar* __thiscall basic_istream_wchar_read_int(basic_istream_wchar *this, int *v)
9101 {
9102     return basic_istream_read_int(this, v, num_get_wchar_use_facet(
9103                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9104 }
9105
9106 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
9107 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
9108 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
9109 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
9110 {
9111     return basic_istream_read_int(this, v, num_get_short_use_facet(
9112                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9113 }
9114
9115 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
9116 {
9117     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9118     int state = IOSTATE_goodbit;
9119
9120     TRACE("(%p %p)\n", this, v);
9121
9122     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9123         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9124         istreambuf_iterator_wchar first={0}, last={0};
9125
9126         first.strbuf = strbuf;
9127         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
9128     }
9129     basic_istream_wchar_sentry_destroy(this);
9130
9131     basic_ios_wchar_setstate(base, state);
9132     return this;
9133 }
9134
9135 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAI@Z */
9136 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAI@Z */
9137 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint, 8)
9138 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint(basic_istream_wchar *this, unsigned int *v)
9139 {
9140     return basic_istream_read_uint(this, v, num_get_wchar_use_facet(
9141                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9142 }
9143
9144 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
9145 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
9146 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
9147 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
9148 {
9149     return basic_istream_read_uint(this, v, num_get_short_use_facet(
9150                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9151 }
9152
9153 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
9154 {
9155     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9156     int state = IOSTATE_goodbit;
9157
9158     TRACE("(%p %p)\n", this, v);
9159
9160     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9161         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9162         istreambuf_iterator_wchar first={0}, last={0};
9163
9164         first.strbuf = strbuf;
9165         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
9166     }
9167     basic_istream_wchar_sentry_destroy(this);
9168
9169     basic_ios_wchar_setstate(base, state);
9170     return this;
9171 }
9172
9173 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
9174 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
9175 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_long, 8)
9176 basic_istream_wchar* __thiscall basic_istream_wchar_read_long(basic_istream_wchar *this, LONG *v)
9177 {
9178     return basic_istream_read_long(this, v, num_get_wchar_use_facet(
9179                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9180 }
9181
9182 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
9183 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
9184 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
9185 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
9186 {
9187     return basic_istream_read_long(this, v, num_get_short_use_facet(
9188                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9189 }
9190
9191 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
9192 {
9193     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9194     int state = IOSTATE_goodbit;
9195
9196     TRACE("(%p %p)\n", this, v);
9197
9198     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9199         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9200         istreambuf_iterator_wchar first={0}, last={0};
9201
9202         first.strbuf = strbuf;
9203         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
9204     }
9205     basic_istream_wchar_sentry_destroy(this);
9206
9207     basic_ios_wchar_setstate(base, state);
9208     return this;
9209 }
9210
9211 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAK@Z */
9212 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAK@Z */
9213 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ulong, 8)
9214 basic_istream_wchar* __thiscall basic_istream_wchar_read_ulong(basic_istream_wchar *this, ULONG *v)
9215 {
9216     return basic_istream_read_ulong(this, v, num_get_wchar_use_facet(
9217                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9218 }
9219
9220 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
9221 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
9222 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
9223 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
9224 {
9225     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
9226                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9227 }
9228
9229 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
9230 {
9231     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9232     int state = IOSTATE_goodbit;
9233
9234     TRACE("(%p %p)\n", this, v);
9235
9236     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9237         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9238         istreambuf_iterator_wchar first={0}, last={0};
9239
9240         first.strbuf = strbuf;
9241         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
9242     }
9243     basic_istream_wchar_sentry_destroy(this);
9244
9245     basic_ios_wchar_setstate(base, state);
9246     return this;
9247 }
9248
9249 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAM@Z */
9250 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAM@Z */
9251 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_float, 8)
9252 basic_istream_wchar* __thiscall basic_istream_wchar_read_float(basic_istream_wchar *this, float *v)
9253 {
9254     return basic_istream_read_float(this, v, num_get_wchar_use_facet(
9255                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9256 }
9257
9258 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
9259 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
9260 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
9261 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
9262 {
9263     return basic_istream_read_float(this, v, num_get_short_use_facet(
9264                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9265 }
9266
9267 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
9268 {
9269     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9270     int state = IOSTATE_goodbit;
9271
9272     TRACE("(%p %p)\n", this, v);
9273
9274     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9275         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9276         istreambuf_iterator_wchar first={0}, last={0};
9277
9278         first.strbuf = strbuf;
9279         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
9280     }
9281     basic_istream_wchar_sentry_destroy(this);
9282
9283     basic_ios_wchar_setstate(base, state);
9284     return this;
9285 }
9286
9287 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAN@Z */
9288 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAN@Z */
9289 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_double, 8)
9290 basic_istream_wchar* __thiscall basic_istream_wchar_read_double(basic_istream_wchar *this, double *v)
9291 {
9292     return basic_istream_read_double(this, v, num_get_wchar_use_facet(
9293                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9294 }
9295
9296 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
9297 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
9298 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
9299 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
9300 {
9301     return basic_istream_read_double(this, v, num_get_short_use_facet(
9302                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9303 }
9304
9305 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
9306 {
9307     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9308     int state = IOSTATE_goodbit;
9309
9310     TRACE("(%p %p)\n", this, v);
9311
9312     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9313         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9314         istreambuf_iterator_wchar first={0}, last={0};
9315
9316         first.strbuf = strbuf;
9317         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
9318     }
9319     basic_istream_wchar_sentry_destroy(this);
9320
9321     basic_ios_wchar_setstate(base, state);
9322     return this;
9323 }
9324
9325 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAO@Z */
9326 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAO@Z */
9327 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ldouble, 8)
9328 basic_istream_wchar* __thiscall basic_istream_wchar_read_ldouble(basic_istream_wchar *this, double *v)
9329 {
9330     return basic_istream_read_ldouble(this, v, num_get_wchar_use_facet(
9331                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9332 }
9333
9334 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
9335 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
9336 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
9337 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
9338 {
9339     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
9340                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9341 }
9342
9343 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
9344 {
9345     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9346     int state = IOSTATE_goodbit;
9347
9348     TRACE("(%p %p)\n", this, v);
9349
9350     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9351         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9352         istreambuf_iterator_wchar first={0}, last={0};
9353
9354         first.strbuf = strbuf;
9355         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
9356     }
9357     basic_istream_wchar_sentry_destroy(this);
9358
9359     basic_ios_wchar_setstate(base, state);
9360     return this;
9361 }
9362
9363 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAPAX@Z */
9364 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
9365 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ptr, 8)
9366 basic_istream_wchar* __thiscall basic_istream_wchar_read_ptr(basic_istream_wchar *this, void **v)
9367 {
9368     return basic_istream_read_ptr(this, v, num_get_wchar_use_facet(
9369                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9370 }
9371
9372 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
9373 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
9374 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
9375 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
9376 {
9377     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
9378                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9379 }
9380
9381 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
9382 {
9383     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9384     int state = IOSTATE_goodbit;
9385
9386     TRACE("(%p %p)\n", this, v);
9387
9388     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9389         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9390         istreambuf_iterator_wchar first={0}, last={0};
9391
9392         first.strbuf = strbuf;
9393         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
9394     }
9395     basic_istream_wchar_sentry_destroy(this);
9396
9397     basic_ios_wchar_setstate(base, state);
9398     return this;
9399 }
9400
9401 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_J@Z */
9402 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_J@Z */
9403 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int64, 8)
9404 basic_istream_wchar* __thiscall basic_istream_wchar_read_int64(basic_istream_wchar *this, __int64 *v)
9405 {
9406     return basic_istream_read_int64(this, v, num_get_wchar_use_facet(
9407                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9408 }
9409
9410 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
9411 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
9412 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
9413 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
9414 {
9415     return basic_istream_read_int64(this, v, num_get_short_use_facet(
9416                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9417 }
9418
9419 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
9420 {
9421     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9422     int state = IOSTATE_goodbit;
9423
9424     TRACE("(%p %p)\n", this, v);
9425
9426     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9427         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9428         istreambuf_iterator_wchar first={0}, last={0};
9429
9430         first.strbuf = strbuf;
9431         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
9432     }
9433     basic_istream_wchar_sentry_destroy(this);
9434
9435     basic_ios_wchar_setstate(base, state);
9436     return this;
9437 }
9438
9439 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_K@Z */
9440 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_K@Z */
9441 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint64, 8)
9442 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9443 {
9444     return basic_istream_read_uint64(this, v, num_get_wchar_use_facet(
9445                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9446 }
9447
9448 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
9449 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
9450 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
9451 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9452 {
9453     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
9454                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9455 }
9456
9457 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
9458 {
9459     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9460     int state = IOSTATE_goodbit;
9461
9462     TRACE("(%p %p)\n", this, v);
9463
9464     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9465         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9466         istreambuf_iterator_wchar first={0}, last={0};
9467
9468         first.strbuf = strbuf;
9469         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
9470     }
9471     basic_istream_wchar_sentry_destroy(this);
9472
9473     basic_ios_wchar_setstate(base, state);
9474     return this;
9475 }
9476
9477 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_N@Z */
9478 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_N@Z */
9479 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_bool, 8)
9480 basic_istream_wchar* __thiscall basic_istream_wchar_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9481 {
9482     return basic_istream_read_bool(this, v, num_get_wchar_use_facet(
9483                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9484 }
9485
9486 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
9487 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
9488 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
9489 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9490 {
9491     return basic_istream_read_bool(this, v, num_get_short_use_facet(
9492                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9493 }
9494
9495 /* ??$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 */
9496 /* ??$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 */
9497 /* ??$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 */
9498 /* ??$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 */
9499 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr_delim(
9500         basic_istream_wchar *istream, basic_string_wchar *str, wchar_t delim)
9501 {
9502     IOSB_iostate state = IOSTATE_failbit;
9503     int c = delim;
9504
9505     TRACE("(%p %p %c)\n", istream, str, delim);
9506
9507     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
9508         MSVCP_basic_string_wchar_clear(str);
9509
9510         for(c = basic_istream_wchar_get(istream); c!=delim && c!=WEOF;
9511                 c = basic_istream_wchar_get(istream)) {
9512             state = IOSTATE_goodbit;
9513             MSVCP_basic_string_wchar_append_ch(str, c);
9514         }
9515     }
9516     basic_istream_wchar_sentry_destroy(istream);
9517
9518     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9519             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9520     return istream;
9521 }
9522
9523 /* ??$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 */
9524 /* ??$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 */
9525 /* ??$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 */
9526 /* ??$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 */
9527 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr(
9528         basic_istream_wchar *istream, basic_string_wchar *str)
9529 {
9530     return basic_istream_wchar_getline_bstr_delim(istream, str, '\n');
9531 }
9532
9533 static basic_istream_wchar* basic_istream_read_bstr(basic_istream_wchar *istream,
9534         basic_string_wchar *str, const ctype_wchar *ctype)
9535 {
9536     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9537     IOSB_iostate state = IOSTATE_failbit;
9538     int c = '\n';
9539
9540     TRACE("(%p %p)\n", istream, str);
9541
9542     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9543         MSVCP_size_t count = ios_base_width_get(&base->base);
9544
9545         if(!count)
9546             count = -1;
9547
9548         MSVCP_basic_string_wchar_clear(str);
9549
9550         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9551                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9552                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9553             state = IOSTATE_goodbit;
9554             MSVCP_basic_string_wchar_append_ch(str, c);
9555         }
9556     }
9557     basic_istream_wchar_sentry_destroy(istream);
9558
9559     ios_base_width_set(&base->base, 0);
9560     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9561     return istream;
9562 }
9563
9564 /* ??$?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 */
9565 /* ??$?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 */
9566 basic_istream_wchar* __cdecl basic_istream_wchar_read_bstr(
9567         basic_istream_wchar *istream, basic_string_wchar *str)
9568 {
9569     return basic_istream_read_bstr(istream, str, ctype_wchar_use_facet(
9570                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9571 }
9572
9573 /* ??$?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 */
9574 /* ??$?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 */
9575 basic_istream_wchar* __cdecl basic_istream_short_read_bstr(
9576         basic_istream_wchar *istream, basic_string_wchar *str)
9577 {
9578     return basic_istream_read_bstr(istream, str, ctype_short_use_facet(
9579                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9580 }
9581
9582 static basic_istream_wchar* basic_istream_read_str(basic_istream_wchar *istream, wchar_t *str, const ctype_wchar *ctype)
9583 {
9584     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9585     IOSB_iostate state = IOSTATE_failbit;
9586     unsigned short c = '\n';
9587
9588     TRACE("(%p %p)\n", istream, str);
9589
9590     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9591         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
9592
9593         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9594                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9595                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9596             state = IOSTATE_goodbit;
9597             *str++ = c;
9598         }
9599     }
9600     basic_istream_wchar_sentry_destroy(istream);
9601
9602     *str = 0;
9603     ios_base_width_set(&base->base, 0);
9604     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9605     return istream;
9606 }
9607
9608 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@PA_W@Z */
9609 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@PEA_W@Z */
9610 basic_istream_wchar* __cdecl basic_istream_wchar_read_str(basic_istream_wchar *istream, wchar_t *str)
9611 {
9612     return basic_istream_read_str(istream, str, ctype_wchar_use_facet(
9613                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9614 }
9615
9616 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@PAG@Z */
9617 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@PEAG@Z */
9618 basic_istream_wchar* __cdecl basic_istream_short_read_str(basic_istream_wchar *istream, wchar_t *str)
9619 {
9620     return basic_istream_read_str(istream, str, ctype_short_use_facet(
9621                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9622 }
9623
9624 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AA_W@Z */
9625 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEA_W@Z */
9626 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAG@Z */
9627 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAG@Z */
9628 basic_istream_wchar* __cdecl basic_istream_wchar_read_ch(basic_istream_wchar *istream, wchar_t *ch)
9629 {
9630     IOSB_iostate state = IOSTATE_failbit;
9631     unsigned short c = 0;
9632
9633     TRACE("(%p %p)\n", istream, ch);
9634
9635     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9636         c = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(
9637                     basic_istream_wchar_get_basic_ios(istream)));
9638         if(c != WEOF) {
9639             state = IOSTATE_goodbit;
9640             *ch = c;
9641         }
9642     }
9643     basic_istream_wchar_sentry_destroy(istream);
9644
9645     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9646             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9647     return istream;
9648 }
9649
9650 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9651 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9652 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9653 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9654 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
9655 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
9656         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
9657 {
9658     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9659     IOSB_iostate state = IOSTATE_failbit;
9660     unsigned short c = '\n';
9661
9662     TRACE("(%p %p)\n", this, streambuf);
9663
9664     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9665         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
9666                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
9667             state = IOSTATE_goodbit;
9668             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
9669                 break;
9670         }
9671     }
9672     basic_istream_wchar_sentry_destroy(this);
9673
9674     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9675     return this;
9676 }
9677
9678 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9679 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9680 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9681 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9682 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
9683 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
9684         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
9685 {
9686     TRACE("(%p %p)\n", this, pfunc);
9687     pfunc(this);
9688     return this;
9689 }
9690
9691 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
9692 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
9693 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
9694 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
9695 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
9696 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
9697         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
9698 {
9699     TRACE("(%p %p)\n", this, pfunc);
9700     pfunc(basic_istream_wchar_get_basic_ios(this));
9701     return this;
9702 }
9703
9704 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9705 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9706 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9707 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9708 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
9709 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
9710         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
9711 {
9712     TRACE("(%p %p)\n", this, pfunc);
9713     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
9714     return this;
9715 }
9716
9717 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
9718 {
9719     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
9720 }
9721
9722 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
9723 {
9724     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
9725 }
9726
9727 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9728 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9729 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
9730 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
9731 {
9732     basic_ios_char *basic_ios;
9733
9734     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9735
9736     if(virt_init) {
9737         this->base1.vbtable = basic_iostream_char_vbtable1;
9738         this->base2.vbtable = basic_iostream_char_vbtable2;
9739         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9740         basic_ios_char_ctor(basic_ios);
9741     }else {
9742         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9743     }
9744
9745     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
9746
9747     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
9748     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9749     return this;
9750 }
9751
9752 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9753 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9754 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
9755 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
9756 {
9757     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9758
9759     TRACE("(%p)\n", this);
9760     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
9761     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
9762 }
9763
9764 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9765 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9766 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
9767 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
9768 {
9769     TRACE("(%p)\n", this);
9770     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
9771     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
9772 }
9773
9774 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
9775 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9776 {
9777     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9778
9779     TRACE("(%p %x)\n", this, flags);
9780
9781     if(flags & 2) {
9782         /* we have an array, with the number of elements stored before the first object */
9783         INT_PTR i, *ptr = (INT_PTR *)this-1;
9784
9785         for(i=*ptr-1; i>=0; i--)
9786             basic_iostream_char_vbase_dtor(this+i);
9787         MSVCRT_operator_delete(ptr);
9788     } else {
9789         basic_iostream_char_vbase_dtor(this);
9790         if(flags & 1)
9791             MSVCRT_operator_delete(this);
9792     }
9793
9794     return this;
9795 }
9796
9797 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
9798 {
9799     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
9800 }
9801
9802 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9803 {
9804     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
9805 }
9806
9807 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9808 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9809 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_ctor, 12)
9810 basic_iostream_wchar* __thiscall basic_iostream_wchar_ctor(basic_iostream_wchar *this,
9811         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9812 {
9813     basic_ios_wchar *basic_ios;
9814
9815     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9816
9817     if(virt_init) {
9818         this->base1.vbtable = basic_iostream_wchar_vbtable1;
9819         this->base2.vbtable = basic_iostream_wchar_vbtable2;
9820         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9821         basic_ios_wchar_ctor(basic_ios);
9822     }else {
9823         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9824     }
9825
9826     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
9827     basic_ostream_wchar_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9828
9829     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
9830     return this;
9831 }
9832
9833 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9834 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9835 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
9836 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
9837         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9838 {
9839     basic_iostream_wchar_ctor(this, strbuf, virt_init);
9840     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
9841     return this;
9842 }
9843
9844 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9845 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9846 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9847 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9848 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
9849 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
9850 {
9851     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9852
9853     TRACE("(%p)\n", this);
9854     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
9855     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
9856 }
9857
9858 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9859 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9860 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9861 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9862 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
9863 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
9864 {
9865     TRACE("(%p)\n", this);
9866     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
9867     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
9868 }
9869
9870 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
9871 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9872 {
9873     basic_iostream_wchar *this = basic_iostream_wchar_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_wchar_vbase_dtor(this+i);
9883         MSVCRT_operator_delete(ptr);
9884     } else {
9885         basic_iostream_wchar_vbase_dtor(this);
9886         if(flags & 1)
9887             MSVCRT_operator_delete(this);
9888     }
9889
9890     return this;
9891 }
9892
9893 static inline basic_ios_char* basic_ofstream_char_to_basic_ios(basic_ofstream_char *ptr)
9894 {
9895     return (basic_ios_char*)((char*)ptr+basic_ofstream_char_vbtable[1]);
9896 }
9897
9898 static inline basic_ofstream_char* basic_ofstream_char_from_basic_ios(basic_ios_char *ptr)
9899 {
9900     return (basic_ofstream_char*)((char*)ptr-basic_ofstream_char_vbtable[1]);
9901 }
9902
9903 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9904 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9905 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
9906 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
9907 {
9908     basic_ios_char *basic_ios;
9909
9910     TRACE("(%p %d)\n", this, virt_init);
9911
9912     if(virt_init) {
9913         this->base.vbtable = basic_ofstream_char_vbtable;
9914         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9915         basic_ios_char_ctor(basic_ios);
9916     }else {
9917         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9918     }
9919
9920     basic_filebuf_char_ctor(&this->filebuf);
9921     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9922     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9923     return this;
9924 }
9925
9926 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
9927 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9928 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_file, 12)
9929 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_file(
9930         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
9931 {
9932     basic_ios_char *basic_ios;
9933
9934     TRACE("(%p %p %d)\n", this, file, virt_init);
9935
9936     if(virt_init) {
9937         this->base.vbtable = basic_ofstream_char_vbtable;
9938         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9939         basic_ios_char_ctor(basic_ios);
9940     }else {
9941         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9942     }
9943
9944     basic_filebuf_char_ctor_file(&this->filebuf, file);
9945     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9946     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9947     return this;
9948 }
9949
9950 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
9951 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
9952 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 20)
9953 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
9954         const char *name, int mode, int prot, MSVCP_bool virt_init)
9955 {
9956     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
9957
9958     basic_ofstream_char_ctor(this, virt_init);
9959
9960     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
9961         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9962         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9963     }
9964     return this;
9965 }
9966
9967 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
9968 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
9969 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
9970 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
9971 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name_wchar, 20)
9972 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name_wchar(basic_ofstream_char *this,
9973         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
9974 {
9975     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
9976
9977     basic_ofstream_char_ctor(this, virt_init);
9978
9979     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
9980         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9981         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9982     }
9983     return this;
9984 }
9985
9986 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9987 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9988 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
9989 void __thiscall basic_ofstream_char_dtor(basic_ios_char *base)
9990 {
9991     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9992
9993     TRACE("(%p)\n", this);
9994
9995     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
9996     basic_filebuf_char_dtor(&this->filebuf);
9997 }
9998
9999 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10000 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10001 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
10002 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
10003 {
10004     TRACE("(%p)\n", this);
10005
10006     basic_ofstream_char_dtor(basic_ofstream_char_to_basic_ios(this));
10007     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
10008 }
10009
10010 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vector_dtor, 8)
10011 basic_ofstream_char* __thiscall basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10012 {
10013     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
10014
10015     TRACE("(%p %x)\n", this, flags);
10016
10017     if(flags & 2) {
10018         /* we have an array, with the number of elements stored before the first object */
10019         INT_PTR i, *ptr = (INT_PTR *)this-1;
10020
10021         for(i=*ptr-1; i>=0; i--)
10022             basic_ofstream_char_vbase_dtor(this+i);
10023         MSVCRT_operator_delete(ptr);
10024     } else {
10025         basic_ofstream_char_vbase_dtor(this);
10026         if(flags & 1)
10027             MSVCRT_operator_delete(this);
10028     }
10029
10030     return this;
10031 }
10032
10033 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10034 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10035 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
10036 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
10037 {
10038     TRACE("(%p)\n", this);
10039
10040     if(!basic_filebuf_char_close(&this->filebuf)) {
10041         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10042         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10043     }
10044 }
10045
10046 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10047 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10048 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
10049 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
10050 {
10051     TRACE("(%p)\n", this);
10052     return basic_filebuf_char_is_open(&this->filebuf);
10053 }
10054
10055 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
10056 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
10057 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 16)
10058 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
10059         const char *name, int mode, int prot)
10060 {
10061     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10062
10063     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10064         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10065         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10066     }
10067 }
10068
10069 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
10070 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
10071 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
10072 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
10073         const char *name, unsigned int mode)
10074 {
10075     basic_ofstream_char_open(this, name, mode, _SH_DENYNO);
10076 }
10077
10078 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
10079 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
10080 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
10081 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
10082 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar, 16)
10083 void __thiscall basic_ofstream_char_open_wchar(basic_ofstream_char *this,
10084         const wchar_t *name, int mode, int prot)
10085 {
10086     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10087
10088     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10089         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10090         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10091     }
10092 }
10093
10094 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
10095 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
10096 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
10097 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
10098 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar_old, 12)
10099 void __thiscall basic_ofstream_char_open_wchar_old(basic_ofstream_char *this,
10100         const wchar_t *name, unsigned int mode)
10101 {
10102     basic_ofstream_char_open_wchar(this, name, mode, _SH_DENYNO);
10103 }
10104
10105 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10106 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10107 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
10108 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
10109 {
10110     TRACE("(%p)\n", this);
10111     return (basic_filebuf_char*)&this->filebuf;
10112 }
10113
10114 static inline basic_ios_wchar* basic_ofstream_wchar_to_basic_ios(basic_ofstream_wchar *ptr)
10115 {
10116     return (basic_ios_wchar*)((char*)ptr+basic_ofstream_wchar_vbtable[1]);
10117 }
10118
10119 static inline basic_ofstream_wchar* basic_ofstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10120 {
10121     return (basic_ofstream_wchar*)((char*)ptr-basic_ofstream_wchar_vbtable[1]);
10122 }
10123
10124 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10125 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10126 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor, 8)
10127 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
10128 {
10129     basic_ios_wchar *basic_ios;
10130
10131     TRACE("(%p %d)\n", this, virt_init);
10132
10133     if(virt_init) {
10134         this->base.vbtable = basic_ofstream_wchar_vbtable;
10135         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10136         basic_ios_wchar_ctor(basic_ios);
10137     }else {
10138         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10139     }
10140
10141     basic_filebuf_wchar_ctor(&this->filebuf);
10142     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10143     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
10144     return this;
10145 }
10146
10147 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10148 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10149 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor, 8)
10150 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
10151 {
10152     basic_ofstream_wchar_ctor(this, virt_init);
10153     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10154     return this;
10155 }
10156
10157 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10158 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10159 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_file, 12)
10160 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_file(
10161         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10162 {
10163     basic_ios_wchar *basic_ios;
10164
10165     TRACE("(%p %p %d)\n", this, file, virt_init);
10166
10167     if(virt_init) {
10168         this->base.vbtable = basic_ofstream_wchar_vbtable;
10169         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10170         basic_ios_wchar_ctor(basic_ios);
10171     }else {
10172         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10173     }
10174
10175     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10176     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10177     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
10178     return this;
10179 }
10180
10181 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10182 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10183 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_file, 12)
10184 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_file(
10185         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10186 {
10187     basic_ofstream_wchar_ctor_file(this, file, virt_init);
10188     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10189     return this;
10190 }
10191
10192 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z */
10193 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z */
10194 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_name, 20)
10195 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_name(basic_ofstream_wchar *this,
10196         const char *name, int mode, int prot, MSVCP_bool virt_init)
10197 {
10198     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10199
10200     basic_ofstream_wchar_ctor(this, virt_init);
10201
10202     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10203         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10204         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10205     }
10206     return this;
10207 }
10208
10209 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBDHH@Z */
10210 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDHH@Z */
10211 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name, 20)
10212 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name(basic_ofstream_wchar *this,
10213         const char *name, int mode, int prot, MSVCP_bool virt_init)
10214 {
10215     basic_ofstream_wchar_ctor_name(this, name, mode, prot, virt_init);
10216     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10217     return this;
10218 }
10219
10220 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PBGHH@Z */
10221 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBGHH@Z */
10222 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10223 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10224 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_name_wchar, 20)
10225 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_name_wchar(basic_ofstream_wchar *this,
10226         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10227 {
10228     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10229
10230     basic_ofstream_wchar_ctor(this, virt_init);
10231
10232     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10233         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10234         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10235     }
10236     return this;
10237 }
10238
10239 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
10240 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
10241 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PB_WHH@Z */
10242 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEB_WHH@Z */
10243 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name_wchar, 20)
10244 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name_wchar(basic_ofstream_wchar *this,
10245         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10246 {
10247     basic_ofstream_wchar_ctor_name_wchar(this, name, mode, prot, virt_init);
10248     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10249     return this;
10250 }
10251
10252 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10253 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10254 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10255 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10256 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_dtor, 4)
10257 void __thiscall basic_ofstream_wchar_dtor(basic_ios_wchar *base)
10258 {
10259     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
10260
10261     TRACE("(%p)\n", this);
10262
10263     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
10264     basic_filebuf_wchar_dtor(&this->filebuf);
10265 }
10266
10267 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10268 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10269 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10270 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10271 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vbase_dtor, 4)
10272 void __thiscall basic_ofstream_wchar_vbase_dtor(basic_ofstream_wchar *this)
10273 {
10274     TRACE("(%p)\n", this);
10275
10276     basic_ofstream_wchar_dtor(basic_ofstream_wchar_to_basic_ios(this));
10277     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
10278 }
10279
10280 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vector_dtor, 8)
10281 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10282 {
10283     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
10284
10285     TRACE("(%p %x)\n", this, flags);
10286
10287     if(flags & 2) {
10288         /* we have an array, with the number of elements stored before the first object */
10289         INT_PTR i, *ptr = (INT_PTR *)this-1;
10290
10291         for(i=*ptr-1; i>=0; i--)
10292             basic_ofstream_wchar_vbase_dtor(this+i);
10293         MSVCRT_operator_delete(ptr);
10294     } else {
10295         basic_ofstream_wchar_vbase_dtor(this);
10296         if(flags & 1)
10297             MSVCRT_operator_delete(this);
10298     }
10299
10300     return this;
10301 }
10302
10303 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10304 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10305 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10306 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10307 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_close, 4)
10308 void __thiscall basic_ofstream_wchar_close(basic_ofstream_wchar *this)
10309 {
10310     TRACE("(%p)\n", this);
10311
10312     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10313         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10314         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10315     }
10316 }
10317
10318 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10319 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10320 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10321 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10322 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_is_open, 4)
10323 MSVCP_bool __thiscall basic_ofstream_wchar_is_open(const basic_ofstream_wchar *this)
10324 {
10325     TRACE("(%p)\n", this);
10326     return basic_filebuf_wchar_is_open(&this->filebuf);
10327 }
10328
10329 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
10330 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
10331 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
10332 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
10333 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open, 16)
10334 void __thiscall basic_ofstream_wchar_open(basic_ofstream_wchar *this,
10335         const char *name, int mode, int prot)
10336 {
10337     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10338
10339     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10340         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10341         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10342     }
10343 }
10344
10345 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
10346 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
10347 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
10348 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
10349 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_old, 12)
10350 void __thiscall basic_ofstream_wchar_open_old(basic_ofstream_wchar *this,
10351         const char *name, unsigned int mode)
10352 {
10353     basic_ofstream_wchar_open(this, name, mode, _SH_DENYNO);
10354 }
10355
10356 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGHH@Z */
10357 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGHH@Z */
10358 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WHH@Z */
10359 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WHH@Z */
10360 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBGHH@Z */
10361 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGHH@Z */
10362 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPB_WHH@Z */
10363 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WHH@Z */
10364 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_wchar, 16)
10365 void __thiscall basic_ofstream_wchar_open_wchar(basic_ofstream_wchar *this,
10366         const wchar_t *name, int mode, int prot)
10367 {
10368     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10369
10370     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10371         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10372         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10373     }
10374 }
10375
10376 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGI@Z */
10377 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGI@Z */
10378 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WI@Z */
10379 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WI@Z */
10380 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBGI@Z */
10381 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGI@Z */
10382 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPB_WI@Z */
10383 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WI@Z */
10384 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_wchar_old, 12)
10385 void __thiscall basic_ofstream_wchar_open_wchar_old(basic_ofstream_wchar *this,
10386         const wchar_t *name, unsigned int mode)
10387 {
10388     basic_ofstream_wchar_open_wchar(this, name, mode, _SH_DENYNO);
10389 }
10390
10391 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10392 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10393 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10394 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10395 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_rdbuf, 4)
10396 basic_filebuf_wchar* __thiscall basic_ofstream_wchar_rdbuf(const basic_ofstream_wchar *this)
10397 {
10398     TRACE("(%p)\n", this);
10399     return (basic_filebuf_wchar*)&this->filebuf;
10400 }
10401
10402 static inline basic_ios_char* basic_ifstream_char_to_basic_ios(basic_ifstream_char *ptr)
10403 {
10404     return (basic_ios_char*)((char*)ptr+basic_ifstream_char_vbtable[1]);
10405 }
10406
10407 static inline basic_ifstream_char* basic_ifstream_char_from_basic_ios(basic_ios_char *ptr)
10408 {
10409     return (basic_ifstream_char*)((char*)ptr-basic_ifstream_char_vbtable[1]);
10410 }
10411
10412 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10413 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10414 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
10415 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
10416 {
10417     basic_ios_char *basic_ios;
10418
10419     TRACE("(%p %d)\n", this, virt_init);
10420
10421     if(virt_init) {
10422         this->base.vbtable = basic_ifstream_char_vbtable;
10423         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10424         basic_ios_char_ctor(basic_ios);
10425     }else {
10426         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10427     }
10428
10429     basic_filebuf_char_ctor(&this->filebuf);
10430     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10431     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
10432     return this;
10433 }
10434
10435 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10436 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10437 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_file, 12)
10438 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_file(
10439         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
10440 {
10441     basic_ios_char *basic_ios;
10442
10443     TRACE("(%p %p %d)\n", this, file, virt_init);
10444
10445     if(virt_init) {
10446         this->base.vbtable = basic_ifstream_char_vbtable;
10447         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10448         basic_ios_char_ctor(basic_ios);
10449     }else {
10450         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10451     }
10452
10453     basic_filebuf_char_ctor_file(&this->filebuf, file);
10454     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10455     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
10456     return this;
10457 }
10458
10459 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
10460 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
10461 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 20)
10462 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
10463         const char *name, int mode, int prot, MSVCP_bool virt_init)
10464 {
10465     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10466
10467     basic_ifstream_char_ctor(this, virt_init);
10468
10469     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10470         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10471         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10472     }
10473     return this;
10474 }
10475
10476 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
10477 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
10478 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
10479 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
10480 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name_wchar, 20)
10481 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name_wchar(basic_ifstream_char *this,
10482         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10483 {
10484     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10485
10486     basic_ifstream_char_ctor(this, virt_init);
10487
10488     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10489         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10490         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10491     }
10492     return this;
10493 }
10494
10495 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10496 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10497 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
10498 void __thiscall basic_ifstream_char_dtor(basic_ios_char *base)
10499 {
10500     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
10501
10502     TRACE("(%p)\n", this);
10503
10504     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
10505     basic_filebuf_char_dtor(&this->filebuf);
10506 }
10507
10508 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10509 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10510 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
10511 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
10512 {
10513     TRACE("(%p)\n", this);
10514
10515     basic_ifstream_char_dtor(basic_ifstream_char_to_basic_ios(this));
10516     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
10517 }
10518
10519 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vector_dtor, 8)
10520 basic_ifstream_char* __thiscall basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10521 {
10522     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
10523
10524     TRACE("(%p %x)\n", this, flags);
10525
10526     if(flags & 2) {
10527         /* we have an array, with the number of elements stored before the first object */
10528         INT_PTR i, *ptr = (INT_PTR *)this-1;
10529
10530         for(i=*ptr-1; i>=0; i--)
10531             basic_ifstream_char_vbase_dtor(this+i);
10532         MSVCRT_operator_delete(ptr);
10533     } else {
10534         basic_ifstream_char_vbase_dtor(this);
10535         if(flags & 1)
10536             MSVCRT_operator_delete(this);
10537     }
10538
10539     return this;
10540 }
10541
10542 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10543 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10544 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
10545 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
10546 {
10547     TRACE("(%p)\n", this);
10548
10549     if(!basic_filebuf_char_close(&this->filebuf)) {
10550         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10551         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10552     }
10553 }
10554
10555 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10556 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10557 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
10558 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
10559 {
10560     TRACE("(%p)\n", this);
10561     return basic_filebuf_char_is_open(&this->filebuf);
10562 }
10563
10564 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
10565 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
10566 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 16)
10567 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
10568         const char *name, int mode, int prot)
10569 {
10570     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10571
10572     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10573         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10574         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10575     }
10576 }
10577
10578 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
10579 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
10580 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
10581 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
10582         const char *name, unsigned int mode)
10583 {
10584     basic_ifstream_char_open(this, name, mode, _SH_DENYNO);
10585 }
10586
10587 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
10588 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
10589 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
10590 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
10591 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar, 16)
10592 void __thiscall basic_ifstream_char_open_wchar(basic_ifstream_char *this,
10593         const wchar_t *name, int mode, int prot)
10594 {
10595     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10596
10597     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10598         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10599         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10600     }
10601 }
10602
10603 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
10604 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
10605 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
10606 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
10607 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar_old, 12)
10608 void __thiscall basic_ifstream_char_open_wchar_old(basic_ifstream_char *this,
10609         const wchar_t *name, unsigned int mode)
10610 {
10611     basic_ifstream_char_open_wchar(this, name, mode, _SH_DENYNO);
10612 }
10613
10614 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10615 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10616 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
10617 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
10618 {
10619     TRACE("(%p)\n", this);
10620     return (basic_filebuf_char*)&this->filebuf;
10621 }
10622
10623 static inline basic_ios_wchar* basic_ifstream_wchar_to_basic_ios(basic_ifstream_wchar *ptr)
10624 {
10625     return (basic_ios_wchar*)((char*)ptr+basic_ifstream_wchar_vbtable[1]);
10626 }
10627
10628 static inline basic_ifstream_wchar* basic_ifstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10629 {
10630     return (basic_ifstream_wchar*)((char*)ptr-basic_ifstream_wchar_vbtable[1]);
10631 }
10632
10633 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10634 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10635 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor, 8)
10636 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10637 {
10638     basic_ios_wchar *basic_ios;
10639
10640     TRACE("(%p %d)\n", this, virt_init);
10641
10642     if(virt_init) {
10643         this->base.vbtable = basic_ifstream_wchar_vbtable;
10644         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10645         basic_ios_wchar_ctor(basic_ios);
10646     }else {
10647         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10648     }
10649
10650     basic_filebuf_wchar_ctor(&this->filebuf);
10651     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10652     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10653     return this;
10654 }
10655
10656 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10657 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10658 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor, 8)
10659 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10660 {
10661     basic_ifstream_wchar_ctor(this, virt_init);
10662     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10663     return this;
10664 }
10665
10666 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10667 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10668 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_file, 12)
10669 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_file(
10670         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10671 {
10672     basic_ios_wchar *basic_ios;
10673
10674     TRACE("(%p %p %d)\n", this, file, virt_init);
10675
10676     if(virt_init) {
10677         this->base.vbtable = basic_ifstream_wchar_vbtable;
10678         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10679         basic_ios_wchar_ctor(basic_ios);
10680     }else {
10681         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10682     }
10683
10684     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10685     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10686     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10687     return this;
10688 }
10689
10690 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10691 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10692 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_file, 12)
10693 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_file(
10694         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10695 {
10696     basic_ifstream_wchar_ctor_file(this, file, virt_init);
10697     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10698     return this;
10699 }
10700
10701 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z */
10702 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z */
10703 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_name, 20)
10704 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_name(basic_ifstream_wchar *this,
10705         const char *name, int mode, int prot, MSVCP_bool virt_init)
10706 {
10707     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10708
10709     basic_ifstream_wchar_ctor(this, virt_init);
10710
10711     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10712         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10713         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10714     }
10715     return this;
10716 }
10717
10718 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBDHH@Z */
10719 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDHH@Z */
10720 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name, 20)
10721 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name(basic_ifstream_wchar *this,
10722         const char *name, int mode, int prot, MSVCP_bool virt_init)
10723 {
10724     basic_ifstream_wchar_ctor_name(this, name, mode, prot, virt_init);
10725     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10726     return this;
10727 }
10728
10729 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PBGHH@Z */
10730 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBGHH@Z */
10731 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10732 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10733 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_name_wchar, 20)
10734 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_name_wchar(basic_ifstream_wchar *this,
10735         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10736 {
10737     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10738
10739     basic_ifstream_wchar_ctor(this, virt_init);
10740
10741     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10742         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10743         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10744     }
10745     return this;
10746 }
10747
10748 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
10749 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
10750 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PB_WHH@Z */
10751 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEB_WHH@Z */
10752 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name_wchar, 20)
10753 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name_wchar(basic_ifstream_wchar *this,
10754         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10755 {
10756     basic_ifstream_wchar_ctor_name_wchar(this, name, mode, prot, virt_init);
10757     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10758     return this;
10759 }
10760
10761 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10762 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10763 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10764 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10765 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_dtor, 4)
10766 void __thiscall basic_ifstream_wchar_dtor(basic_ios_wchar *base)
10767 {
10768     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10769
10770     TRACE("(%p)\n", this);
10771
10772     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
10773     basic_filebuf_wchar_dtor(&this->filebuf);
10774 }
10775
10776 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10777 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10778 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10779 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10780 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vbase_dtor, 4)
10781 void __thiscall basic_ifstream_wchar_vbase_dtor(basic_ifstream_wchar *this)
10782 {
10783     TRACE("(%p)\n", this);
10784
10785     basic_ifstream_wchar_dtor(basic_ifstream_wchar_to_basic_ios(this));
10786     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
10787 }
10788
10789 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vector_dtor, 8)
10790 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10791 {
10792     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10793
10794     TRACE("(%p %x)\n", this, flags);
10795
10796     if(flags & 2) {
10797         /* we have an array, with the number of elements stored before the first object */
10798         INT_PTR i, *ptr = (INT_PTR *)this-1;
10799
10800         for(i=*ptr-1; i>=0; i--)
10801             basic_ifstream_wchar_vbase_dtor(this+i);
10802         MSVCRT_operator_delete(ptr);
10803     } else {
10804         basic_ifstream_wchar_vbase_dtor(this);
10805         if(flags & 1)
10806             MSVCRT_operator_delete(this);
10807     }
10808
10809     return this;
10810 }
10811
10812 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10813 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10814 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10815 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10816 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_close, 4)
10817 void __thiscall basic_ifstream_wchar_close(basic_ifstream_wchar *this)
10818 {
10819     TRACE("(%p)\n", this);
10820
10821     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10822         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10823         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10824     }
10825 }
10826
10827 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10828 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10829 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10830 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10831 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_is_open, 4)
10832 MSVCP_bool __thiscall basic_ifstream_wchar_is_open(const basic_ifstream_wchar *this)
10833 {
10834     TRACE("(%p)\n", this);
10835     return basic_filebuf_wchar_is_open(&this->filebuf);
10836 }
10837
10838 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
10839 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
10840 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
10841 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
10842 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open, 16)
10843 void __thiscall basic_ifstream_wchar_open(basic_ifstream_wchar *this,
10844         const char *name, int mode, int prot)
10845 {
10846     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10847
10848     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10849         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10850         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10851     }
10852 }
10853
10854 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
10855 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
10856 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
10857 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
10858 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_old, 12)
10859 void __thiscall basic_ifstream_wchar_open_old(basic_ifstream_wchar *this,
10860         const char *name, unsigned int mode)
10861 {
10862     basic_ifstream_wchar_open(this, name, mode, _SH_DENYNO);
10863 }
10864
10865 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGHH@Z */
10866 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGHH@Z */
10867 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WHH@Z */
10868 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WHH@Z */
10869 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBGHH@Z */
10870 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGHH@Z */
10871 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPB_WHH@Z */
10872 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WHH@Z */
10873 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_wchar, 16)
10874 void __thiscall basic_ifstream_wchar_open_wchar(basic_ifstream_wchar *this,
10875         const wchar_t *name, int mode, int prot)
10876 {
10877     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10878
10879     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10880         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10881         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10882     }
10883 }
10884
10885 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGI@Z */
10886 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGI@Z */
10887 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WI@Z */
10888 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WI@Z */
10889 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBGI@Z */
10890 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGI@Z */
10891 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPB_WI@Z */
10892 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WI@Z */
10893 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_wchar_old, 12)
10894 void __thiscall basic_ifstream_wchar_open_wchar_old(basic_ifstream_wchar *this,
10895         const wchar_t *name, unsigned int mode)
10896 {
10897     basic_ifstream_wchar_open_wchar(this, name, mode, _SH_DENYNO);
10898 }
10899
10900 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10901 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10902 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10903 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10904 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_rdbuf, 4)
10905 basic_filebuf_wchar* __thiscall basic_ifstream_wchar_rdbuf(const basic_ifstream_wchar *this)
10906 {
10907     TRACE("(%p)\n", this);
10908     return (basic_filebuf_wchar*)&this->filebuf;
10909 }
10910
10911 static inline basic_ios_char* basic_fstream_char_to_basic_ios(basic_fstream_char *ptr)
10912 {
10913     return (basic_ios_char*)((char*)ptr+basic_fstream_char_vbtable1[1]);
10914 }
10915
10916 static inline basic_fstream_char* basic_fstream_char_from_basic_ios(basic_ios_char *ptr)
10917 {
10918     return (basic_fstream_char*)((char*)ptr-basic_fstream_char_vbtable1[1]);
10919 }
10920
10921 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10922 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10923 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
10924 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
10925 {
10926     basic_ios_char *basic_ios;
10927
10928     TRACE("(%p %d)\n", this, virt_init);
10929
10930     if(virt_init) {
10931         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10932         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10933         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10934         basic_ios_char_ctor(basic_ios);
10935     }else {
10936         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10937     }
10938
10939     basic_filebuf_char_ctor(&this->filebuf);
10940     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10941     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10942     return this;
10943 }
10944
10945 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10946 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10947 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_file, 12)
10948 basic_fstream_char* __thiscall basic_fstream_char_ctor_file(basic_fstream_char *this,
10949         FILE *file, MSVCP_bool virt_init)
10950 {
10951     basic_ios_char *basic_ios;
10952
10953     TRACE("(%p %p %d)\n", this, file, virt_init);
10954
10955     if(virt_init) {
10956         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10957         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10958         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10959         basic_ios_char_ctor(basic_ios);
10960     }else {
10961         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10962     }
10963
10964     basic_filebuf_char_ctor_file(&this->filebuf, file);
10965     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10966     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10967     return this;
10968 }
10969
10970 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
10971 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
10972 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 20)
10973 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
10974         const char *name, int mode, int prot, MSVCP_bool virt_init)
10975 {
10976     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10977
10978     basic_fstream_char_ctor(this, virt_init);
10979
10980     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
10981         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10982         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10983     }
10984     return this;
10985 }
10986
10987 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
10988 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
10989 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
10990 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
10991 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name_wchar, 20)
10992 basic_fstream_char* __thiscall basic_fstream_char_ctor_name_wchar(basic_fstream_char *this,
10993         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10994 {
10995     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10996
10997     basic_fstream_char_ctor(this, virt_init);
10998
10999     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
11000         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11001         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11002     }
11003     return this;
11004 }
11005
11006 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
11007 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
11008 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
11009 void __thiscall basic_fstream_char_dtor(basic_ios_char *base)
11010 {
11011     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
11012
11013     TRACE("(%p)\n", this);
11014
11015     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11016     basic_filebuf_char_dtor(&this->filebuf);
11017 }
11018
11019 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
11020 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
11021 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
11022 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
11023 {
11024     TRACE("(%p)\n", this);
11025
11026     basic_fstream_char_dtor(basic_fstream_char_to_basic_ios(this));
11027     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11028 }
11029
11030 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vector_dtor, 8)
11031 basic_fstream_char* __thiscall basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11032 {
11033     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
11034
11035     TRACE("(%p %x)\n", this, flags);
11036
11037     if(flags & 2) {
11038         /* we have an array, with the number of elements stored before the first object */
11039         INT_PTR i, *ptr = (INT_PTR *)this-1;
11040
11041         for(i=*ptr-1; i>=0; i--)
11042             basic_fstream_char_vbase_dtor(this+i);
11043         MSVCRT_operator_delete(ptr);
11044     } else {
11045         basic_fstream_char_vbase_dtor(this);
11046         if(flags & 1)
11047             MSVCRT_operator_delete(this);
11048     }
11049
11050     return this;
11051 }
11052
11053 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
11054 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
11055 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
11056 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
11057 {
11058     TRACE("(%p)\n", this);
11059
11060     if(!basic_filebuf_char_close(&this->filebuf)) {
11061         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11062         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11063     }
11064 }
11065
11066 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
11067 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
11068 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
11069 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
11070 {
11071     TRACE("(%p)\n", this);
11072     return basic_filebuf_char_is_open(&this->filebuf);
11073 }
11074
11075 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
11076 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
11077 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 16)
11078 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
11079         const char *name, int mode, int prot)
11080 {
11081     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
11082
11083     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
11084         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11085         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11086     }
11087 }
11088
11089 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
11090 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
11091 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
11092 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
11093         const char *name, unsigned int mode)
11094 {
11095     basic_fstream_char_open(this, name, mode, _SH_DENYNO);
11096 }
11097
11098 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
11099 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
11100 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
11101 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
11102 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar, 16)
11103 void __thiscall basic_fstream_char_open_wchar(basic_fstream_char *this,
11104         const wchar_t *name, int mode, int prot)
11105 {
11106     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
11107
11108     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
11109         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11110         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11111     }
11112 }
11113
11114 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
11115 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
11116 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
11117 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
11118 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar_old, 12)
11119 void __thiscall basic_fstream_char_open_wchar_old(basic_fstream_char *this,
11120         const wchar_t *name, unsigned int mode)
11121 {
11122     basic_fstream_char_open_wchar(this, name, mode, _SH_DENYNO);
11123 }
11124
11125 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
11126 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
11127 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
11128 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
11129 {
11130     TRACE("(%p)\n", this);
11131     return (basic_filebuf_char*)&this->filebuf;
11132 }
11133
11134 static inline basic_ios_wchar* basic_fstream_wchar_to_basic_ios(basic_fstream_wchar *ptr)
11135 {
11136     return (basic_ios_wchar*)((char*)ptr+basic_fstream_wchar_vbtable1[1]);
11137 }
11138
11139 static inline basic_fstream_wchar* basic_fstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11140 {
11141     return (basic_fstream_wchar*)((char*)ptr-basic_fstream_wchar_vbtable1[1]);
11142 }
11143
11144 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
11145 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
11146 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor, 8)
11147 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
11148 {
11149     basic_ios_wchar *basic_ios;
11150
11151     TRACE("(%p %d)\n", this, virt_init);
11152
11153     if(virt_init) {
11154         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
11155         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
11156         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11157         basic_ios_wchar_ctor(basic_ios);
11158     }else {
11159         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11160     }
11161
11162     basic_filebuf_wchar_ctor(&this->filebuf);
11163     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
11164     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
11165     return this;
11166 }
11167
11168 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
11169 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
11170 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor, 8)
11171 basic_fstream_wchar* __thiscall basic_fstream_short_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
11172 {
11173     basic_fstream_wchar_ctor(this, virt_init);
11174     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11175     return this;
11176 }
11177
11178 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
11179 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11180 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_file, 12)
11181 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_file(basic_fstream_wchar *this,
11182         FILE *file, MSVCP_bool virt_init)
11183 {
11184     basic_ios_wchar *basic_ios;
11185
11186     TRACE("(%p %p %d)\n", this, file, virt_init);
11187
11188     if(virt_init) {
11189         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
11190         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
11191         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11192         basic_ios_wchar_ctor(basic_ios);
11193     }else {
11194         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11195     }
11196
11197     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
11198     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
11199     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
11200     return this;
11201 }
11202
11203 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
11204 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11205 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_file, 12)
11206 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_file(basic_fstream_wchar *this,
11207         FILE *file, MSVCP_bool virt_init)
11208 {
11209     basic_fstream_wchar_ctor_file(this, file, virt_init);
11210     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11211     return this;
11212 }
11213
11214 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
11215 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
11216 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_name, 20)
11217 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_name(basic_fstream_wchar *this,
11218         const char *name, int mode, int prot, MSVCP_bool virt_init)
11219 {
11220     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
11221
11222     basic_fstream_wchar_ctor(this, virt_init);
11223
11224     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, prot)) {
11225         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11226         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11227     }
11228     return this;
11229 }
11230
11231 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
11232 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
11233 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name, 20)
11234 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name(basic_fstream_wchar *this,
11235         const char *name, int mode, int prot, MSVCP_bool virt_init)
11236 {
11237     basic_fstream_wchar_ctor_name(this, name, mode, prot, virt_init);
11238     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11239     return this;
11240 }
11241
11242 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PBGHH@Z */
11243 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBGHH@Z */
11244 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
11245 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
11246 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_name_wchar, 20)
11247 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_name_wchar(basic_fstream_wchar *this,
11248         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
11249 {
11250     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
11251
11252     basic_fstream_wchar_ctor(this, virt_init);
11253
11254     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode, prot)) {
11255         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11256         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11257     }
11258     return this;
11259 }
11260
11261 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
11262 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
11263 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PB_WHH@Z */
11264 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEB_WHH@Z */
11265 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name_wchar, 20)
11266 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name_wchar(basic_fstream_wchar *this,
11267         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
11268 {
11269     basic_fstream_wchar_ctor_name_wchar(this, name, mode, prot, 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 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
11275 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
11276 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
11277 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
11278 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_dtor, 4)
11279 void __thiscall basic_fstream_wchar_dtor(basic_ios_wchar *base)
11280 {
11281     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
11282
11283     TRACE("(%p)\n", this);
11284
11285     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
11286     basic_filebuf_wchar_dtor(&this->filebuf);
11287 }
11288
11289 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
11290 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
11291 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
11292 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
11293 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vbase_dtor, 4)
11294 void __thiscall basic_fstream_wchar_vbase_dtor(basic_fstream_wchar *this)
11295 {
11296     TRACE("(%p)\n", this);
11297
11298     basic_fstream_wchar_dtor(basic_fstream_wchar_to_basic_ios(this));
11299     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
11300 }
11301
11302 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vector_dtor, 8)
11303 basic_fstream_wchar* __thiscall basic_fstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11304 {
11305     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
11306
11307     TRACE("(%p %x)\n", this, flags);
11308
11309     if(flags & 2) {
11310         /* we have an array, with the number of elements stored before the first object */
11311         INT_PTR i, *ptr = (INT_PTR *)this-1;
11312
11313         for(i=*ptr-1; i>=0; i--)
11314             basic_fstream_wchar_vbase_dtor(this+i);
11315         MSVCRT_operator_delete(ptr);
11316     } else {
11317         basic_fstream_wchar_vbase_dtor(this);
11318         if(flags & 1)
11319             MSVCRT_operator_delete(this);
11320     }
11321
11322     return this;
11323 }
11324
11325 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
11326 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
11327 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
11328 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
11329 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_close, 4)
11330 void __thiscall basic_fstream_wchar_close(basic_fstream_wchar *this)
11331 {
11332     TRACE("(%p)\n", this);
11333
11334     if(!basic_filebuf_wchar_close(&this->filebuf)) {
11335         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11336         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11337     }
11338 }
11339
11340 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
11341 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
11342 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
11343 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
11344 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_is_open, 4)
11345 MSVCP_bool __thiscall basic_fstream_wchar_is_open(const basic_fstream_wchar *this)
11346 {
11347     TRACE("(%p)\n", this);
11348     return basic_filebuf_wchar_is_open(&this->filebuf);
11349 }
11350
11351 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
11352 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
11353 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
11354 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
11355 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open, 16)
11356 void __thiscall basic_fstream_wchar_open(basic_fstream_wchar *this,
11357         const char *name, int mode, int prot)
11358 {
11359     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
11360
11361     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, prot)) {
11362         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11363         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11364     }
11365 }
11366
11367 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
11368 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
11369 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
11370 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
11371 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_old, 12)
11372 void __thiscall basic_fstream_wchar_open_old(basic_fstream_wchar *this,
11373         const char *name, unsigned int mode)
11374 {
11375     basic_fstream_wchar_open(this, name, mode, _SH_DENYNO);
11376 }
11377
11378 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGHH@Z */
11379 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGHH@Z */
11380 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WHH@Z */
11381 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WHH@Z */
11382 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBGHH@Z */
11383 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGHH@Z */
11384 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPB_WHH@Z */
11385 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WHH@Z */
11386 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_wchar, 16)
11387 void __thiscall basic_fstream_wchar_open_wchar(basic_fstream_wchar *this,
11388         const wchar_t *name, int mode, int prot)
11389 {
11390     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
11391
11392     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode, prot)) {
11393         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11394         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11395     }
11396 }
11397
11398 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGI@Z */
11399 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGI@Z */
11400 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WI@Z */
11401 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WI@Z */
11402 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBGI@Z */
11403 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGI@Z */
11404 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPB_WI@Z */
11405 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WI@Z */
11406 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_wchar_old, 12)
11407 void __thiscall basic_fstream_wchar_open_wchar_old(basic_fstream_wchar *this,
11408         const wchar_t *name, unsigned int mode)
11409 {
11410     basic_fstream_wchar_open_wchar(this, name, mode, _SH_DENYNO);
11411 }
11412
11413 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
11414 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
11415 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
11416 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
11417 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_rdbuf, 4)
11418 basic_filebuf_wchar* __thiscall basic_fstream_wchar_rdbuf(const basic_fstream_wchar *this)
11419 {
11420     TRACE("(%p)\n", this);
11421     return (basic_filebuf_wchar*)&this->filebuf;
11422 }
11423
11424 static inline basic_ios_char* basic_ostringstream_char_to_basic_ios(basic_ostringstream_char *ptr)
11425 {
11426     return (basic_ios_char*)((char*)ptr+basic_ostringstream_char_vbtable[1]);
11427 }
11428
11429 static inline basic_ostringstream_char* basic_ostringstream_char_from_basic_ios(basic_ios_char *ptr)
11430 {
11431     return (basic_ostringstream_char*)((char*)ptr-basic_ostringstream_char_vbtable[1]);
11432 }
11433
11434 /* ??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 */
11435 /* ??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 */
11436 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_str, 16)
11437 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_str(basic_ostringstream_char *this,
11438         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11439 {
11440     basic_ios_char *basic_ios;
11441
11442     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11443
11444     if(virt_init) {
11445         this->base.vbtable = basic_ostringstream_char_vbtable;
11446         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11447         basic_ios_char_ctor(basic_ios);
11448     }else {
11449         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11450     }
11451
11452     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
11453     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11454     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
11455     return this;
11456 }
11457
11458 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11459 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11460 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_mode, 12)
11461 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_mode(
11462         basic_ostringstream_char *this, int mode, MSVCP_bool virt_init)
11463 {
11464     basic_ios_char *basic_ios;
11465
11466     TRACE("(%p %d %d)\n", this, mode, virt_init);
11467
11468     if(virt_init) {
11469         this->base.vbtable = basic_ostringstream_char_vbtable;
11470         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11471         basic_ios_char_ctor(basic_ios);
11472     }else {
11473         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11474     }
11475
11476     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_out);
11477     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11478     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
11479     return this;
11480 }
11481
11482 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11483 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11484 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor, 8)
11485 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor(
11486         basic_ostringstream_char *this, MSVCP_bool virt_init)
11487 {
11488     return basic_ostringstream_char_ctor_mode(this, 0, virt_init);
11489 }
11490
11491 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11492 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11493 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_dtor, 4)
11494 void __thiscall basic_ostringstream_char_dtor(basic_ios_char *base)
11495 {
11496     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
11497
11498     TRACE("(%p)\n", this);
11499
11500     basic_stringbuf_char_dtor(&this->strbuf);
11501     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
11502 }
11503
11504 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11505 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11506 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vbase_dtor, 4)
11507 void __thiscall basic_ostringstream_char_vbase_dtor(basic_ostringstream_char *this)
11508 {
11509     TRACE("(%p)\n", this);
11510
11511     basic_ostringstream_char_dtor(basic_ostringstream_char_to_basic_ios(this));
11512     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
11513 }
11514
11515 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vector_dtor, 8)
11516 basic_ostringstream_char* __thiscall basic_ostringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11517 {
11518     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
11519
11520     TRACE("(%p %x)\n", this, flags);
11521
11522     if(flags & 2) {
11523         /* we have an array, with the number of elements stored before the first object */
11524         INT_PTR i, *ptr = (INT_PTR *)this-1;
11525
11526         for(i=*ptr-1; i>=0; i--)
11527             basic_ostringstream_char_vbase_dtor(this+i);
11528         MSVCRT_operator_delete(ptr);
11529     } else {
11530         basic_ostringstream_char_vbase_dtor(this);
11531         if(flags & 1)
11532             MSVCRT_operator_delete(this);
11533     }
11534
11535     return this;
11536 }
11537
11538 /* ?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 */
11539 /* ?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 */
11540 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_rdbuf, 4)
11541 basic_stringbuf_char* __thiscall basic_ostringstream_char_rdbuf(const basic_ostringstream_char *this)
11542 {
11543     TRACE("(%p)\n", this);
11544     return (basic_stringbuf_char*)&this->strbuf;
11545 }
11546
11547 /* ?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 */
11548 /* ?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 */
11549 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_set, 8)
11550 void __thiscall basic_ostringstream_char_str_set(basic_ostringstream_char *this, const basic_string_char *str)
11551 {
11552     TRACE("(%p %p)\n", this, str);
11553     basic_stringbuf_char_str_set(&this->strbuf, str);
11554 }
11555
11556 /* ?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 */
11557 /* ?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 */
11558 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_get, 8)
11559 basic_string_char* __thiscall basic_ostringstream_char_str_get(const basic_ostringstream_char *this, basic_string_char *ret)
11560 {
11561     TRACE("(%p %p)\n", this, ret);
11562     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11563 }
11564
11565 static inline basic_ios_wchar* basic_ostringstream_wchar_to_basic_ios(basic_ostringstream_wchar *ptr)
11566 {
11567     return (basic_ios_wchar*)((char*)ptr+basic_ostringstream_wchar_vbtable[1]);
11568 }
11569
11570 static inline basic_ostringstream_wchar* basic_ostringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11571 {
11572     return (basic_ostringstream_wchar*)((char*)ptr-basic_ostringstream_wchar_vbtable[1]);
11573 }
11574
11575 /* ??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 */
11576 /* ??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 */
11577 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor_str, 16)
11578 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor_str(basic_ostringstream_wchar *this,
11579         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11580 {
11581     basic_ios_wchar *basic_ios;
11582
11583     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11584
11585     if(virt_init) {
11586         this->base.vbtable = basic_ostringstream_wchar_vbtable;
11587         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11588         basic_ios_wchar_ctor(basic_ios);
11589     }else {
11590         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11591     }
11592
11593     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
11594     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11595     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
11596     return this;
11597 }
11598
11599 /* ??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 */
11600 /* ??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 */
11601 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_str, 16)
11602 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_str(basic_ostringstream_wchar *this,
11603         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11604 {
11605     basic_ostringstream_wchar_ctor_str(this, str, mode, virt_init);
11606     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
11607     return this;
11608 }
11609
11610 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11611 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11612 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor_mode, 12)
11613 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor_mode(
11614         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
11615 {
11616     basic_ios_wchar *basic_ios;
11617
11618     TRACE("(%p %d %d)\n", this, mode, virt_init);
11619
11620     if(virt_init) {
11621         this->base.vbtable = basic_ostringstream_wchar_vbtable;
11622         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11623         basic_ios_wchar_ctor(basic_ios);
11624     }else {
11625         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11626     }
11627
11628     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_out);
11629     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11630     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
11631     return this;
11632 }
11633
11634 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11635 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11636 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_mode, 12)
11637 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_mode(
11638         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
11639 {
11640     basic_ostringstream_wchar_ctor_mode(this, mode, virt_init);
11641     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
11642     return this;
11643 }
11644
11645 /* ??_F?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11646 /* ??_F?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11647 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor, 8)
11648 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor(
11649         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
11650 {
11651     return basic_ostringstream_wchar_ctor_mode(this, 0, virt_init);
11652 }
11653
11654 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11655 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11656 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor, 8)
11657 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor(
11658         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
11659 {
11660     return basic_ostringstream_short_ctor_mode(this, 0, virt_init);
11661 }
11662
11663 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11664 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11665 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11666 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11667 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_dtor, 4)
11668 void __thiscall basic_ostringstream_wchar_dtor(basic_ios_wchar *base)
11669 {
11670     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
11671
11672     TRACE("(%p)\n", this);
11673
11674     basic_stringbuf_wchar_dtor(&this->strbuf);
11675     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
11676 }
11677
11678 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11679 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11680 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11681 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11682 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vbase_dtor, 4)
11683 void __thiscall basic_ostringstream_wchar_vbase_dtor(basic_ostringstream_wchar *this)
11684 {
11685     TRACE("(%p)\n", this);
11686
11687     basic_ostringstream_wchar_dtor(basic_ostringstream_wchar_to_basic_ios(this));
11688     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
11689 }
11690
11691 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vector_dtor, 8)
11692 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11693 {
11694     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
11695
11696     TRACE("(%p %x)\n", this, flags);
11697
11698     if(flags & 2) {
11699         /* we have an array, with the number of elements stored before the first object */
11700         INT_PTR i, *ptr = (INT_PTR *)this-1;
11701
11702         for(i=*ptr-1; i>=0; i--)
11703             basic_ostringstream_wchar_vbase_dtor(this+i);
11704         MSVCRT_operator_delete(ptr);
11705     } else {
11706         basic_ostringstream_wchar_vbase_dtor(this);
11707         if(flags & 1)
11708             MSVCRT_operator_delete(this);
11709     }
11710
11711     return this;
11712 }
11713
11714 /* ?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 */
11715 /* ?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 */
11716 /* ?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 */
11717 /* ?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 */
11718 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_rdbuf, 4)
11719 basic_stringbuf_wchar* __thiscall basic_ostringstream_wchar_rdbuf(const basic_ostringstream_wchar *this)
11720 {
11721     TRACE("(%p)\n", this);
11722     return (basic_stringbuf_wchar*)&this->strbuf;
11723 }
11724
11725 /* ?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 */
11726 /* ?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 */
11727 /* ?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 */
11728 /* ?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 */
11729 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_set, 8)
11730 void __thiscall basic_ostringstream_wchar_str_set(basic_ostringstream_wchar *this, const basic_string_wchar *str)
11731 {
11732     TRACE("(%p %p)\n", this, str);
11733     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11734 }
11735
11736 /* ?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 */
11737 /* ?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 */
11738 /* ?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 */
11739 /* ?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 */
11740 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_get, 8)
11741 basic_string_wchar* __thiscall basic_ostringstream_wchar_str_get(const basic_ostringstream_wchar *this, basic_string_wchar *ret)
11742 {
11743     TRACE("(%p %p)\n", this, ret);
11744     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11745 }
11746
11747 static inline basic_ios_char* basic_istringstream_char_to_basic_ios(basic_istringstream_char *ptr)
11748 {
11749     return (basic_ios_char*)((char*)ptr+basic_istringstream_char_vbtable[1]);
11750 }
11751
11752 static inline basic_istringstream_char* basic_istringstream_char_from_basic_ios(basic_ios_char *ptr)
11753 {
11754     return (basic_istringstream_char*)((char*)ptr-basic_istringstream_char_vbtable[1]);
11755 }
11756
11757 /* ??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 */
11758 /* ??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 */
11759 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_str, 16)
11760 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_str(basic_istringstream_char *this,
11761         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11762 {
11763     basic_ios_char *basic_ios;
11764
11765     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11766
11767     if(virt_init) {
11768         this->base.vbtable = basic_istringstream_char_vbtable;
11769         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11770         basic_ios_char_ctor(basic_ios);
11771     }else {
11772         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11773     }
11774
11775     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
11776     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11777     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11778     return this;
11779 }
11780
11781 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11782 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11783 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_mode, 12)
11784 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_mode(
11785         basic_istringstream_char *this, int mode, MSVCP_bool virt_init)
11786 {
11787     basic_ios_char *basic_ios;
11788
11789     TRACE("(%p %d %d)\n", this, mode, virt_init);
11790
11791     if(virt_init) {
11792         this->base.vbtable = basic_istringstream_char_vbtable;
11793         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11794         basic_ios_char_ctor(basic_ios);
11795     }else {
11796         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11797     }
11798
11799     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11800     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11801     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11802     return this;
11803 }
11804
11805 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11806 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11807 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor, 8)
11808 basic_istringstream_char* __thiscall basic_istringstream_char_ctor(
11809         basic_istringstream_char *this, MSVCP_bool virt_init)
11810 {
11811     return basic_istringstream_char_ctor_mode(this, 0, virt_init);
11812 }
11813
11814 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11815 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11816 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_dtor, 4)
11817 void __thiscall basic_istringstream_char_dtor(basic_ios_char *base)
11818 {
11819     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11820
11821     TRACE("(%p)\n", this);
11822
11823     basic_stringbuf_char_dtor(&this->strbuf);
11824     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11825 }
11826
11827 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11828 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11829 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vbase_dtor, 4)
11830 void __thiscall basic_istringstream_char_vbase_dtor(basic_istringstream_char *this)
11831 {
11832     TRACE("(%p)\n", this);
11833
11834     basic_istringstream_char_dtor(basic_istringstream_char_to_basic_ios(this));
11835     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
11836 }
11837
11838 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vector_dtor, 8)
11839 basic_istringstream_char* __thiscall basic_istringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11840 {
11841     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11842
11843     TRACE("(%p %x)\n", this, flags);
11844
11845     if(flags & 2) {
11846         /* we have an array, with the number of elements stored before the first object */
11847         INT_PTR i, *ptr = (INT_PTR *)this-1;
11848
11849         for(i=*ptr-1; i>=0; i--)
11850             basic_istringstream_char_vbase_dtor(this+i);
11851         MSVCRT_operator_delete(ptr);
11852     } else {
11853         basic_istringstream_char_vbase_dtor(this);
11854         if(flags & 1)
11855             MSVCRT_operator_delete(this);
11856     }
11857
11858     return this;
11859 }
11860
11861 /* ?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 */
11862 /* ?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 */
11863 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_rdbuf, 4)
11864 basic_stringbuf_char* __thiscall basic_istringstream_char_rdbuf(const basic_istringstream_char *this)
11865 {
11866     TRACE("(%p)\n", this);
11867     return (basic_stringbuf_char*)&this->strbuf;
11868 }
11869
11870 /* ?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 */
11871 /* ?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 */
11872 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_set, 8)
11873 void __thiscall basic_istringstream_char_str_set(basic_istringstream_char *this, const basic_string_char *str)
11874 {
11875     TRACE("(%p %p)\n", this, str);
11876     basic_stringbuf_char_str_set(&this->strbuf, str);
11877 }
11878
11879 /* ?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 */
11880 /* ?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 */
11881 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_get, 8)
11882 basic_string_char* __thiscall basic_istringstream_char_str_get(const basic_istringstream_char *this, basic_string_char *ret)
11883 {
11884     TRACE("(%p %p)\n", this, ret);
11885     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11886 }
11887
11888 static inline basic_ios_wchar* basic_istringstream_wchar_to_basic_ios(basic_istringstream_wchar *ptr)
11889 {
11890     return (basic_ios_wchar*)((char*)ptr+basic_istringstream_wchar_vbtable[1]);
11891 }
11892
11893 static inline basic_istringstream_wchar* basic_istringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11894 {
11895     return (basic_istringstream_wchar*)((char*)ptr-basic_istringstream_wchar_vbtable[1]);
11896 }
11897
11898 /* ??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 */
11899 /* ??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 */
11900 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor_str, 16)
11901 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor_str(basic_istringstream_wchar *this,
11902         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11903 {
11904     basic_ios_wchar *basic_ios;
11905
11906     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11907
11908     if(virt_init) {
11909         this->base.vbtable = basic_istringstream_wchar_vbtable;
11910         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11911         basic_ios_wchar_ctor(basic_ios);
11912     }else {
11913         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11914     }
11915
11916     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
11917     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11918     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11919     return this;
11920 }
11921
11922 /* ??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 */
11923 /* ??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 */
11924 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_str, 16)
11925 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_str(basic_istringstream_wchar *this,
11926         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11927 {
11928     basic_istringstream_wchar_ctor_str(this, str, mode, virt_init);
11929     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11930     return this;
11931 }
11932
11933 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11934 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11935 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor_mode, 12)
11936 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor_mode(
11937         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11938 {
11939     basic_ios_wchar *basic_ios;
11940
11941     TRACE("(%p %d %d)\n", this, mode, virt_init);
11942
11943     if(virt_init) {
11944         this->base.vbtable = basic_istringstream_wchar_vbtable;
11945         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11946         basic_ios_wchar_ctor(basic_ios);
11947     }else {
11948         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11949     }
11950
11951     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11952     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11953     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11954     return this;
11955 }
11956
11957 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11958 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11959 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_mode, 12)
11960 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_mode(
11961         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11962 {
11963     basic_istringstream_wchar_ctor_mode(this, mode, virt_init);
11964     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11965     return this;
11966 }
11967
11968 /* ??_F?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11969 /* ??_F?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11970 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor, 8)
11971 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor(
11972         basic_istringstream_wchar *this, MSVCP_bool virt_init)
11973 {
11974     return basic_istringstream_wchar_ctor_mode(this, 0, virt_init);
11975 }
11976
11977 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11978 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11979 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor, 8)
11980 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor(
11981         basic_istringstream_wchar *this, MSVCP_bool virt_init)
11982 {
11983     return basic_istringstream_short_ctor_mode(this, 0, virt_init);
11984 }
11985
11986 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11987 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11988 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11989 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11990 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_dtor, 4)
11991 void __thiscall basic_istringstream_wchar_dtor(basic_ios_wchar *base)
11992 {
11993     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11994
11995     TRACE("(%p)\n", this);
11996
11997     basic_stringbuf_wchar_dtor(&this->strbuf);
11998     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
11999 }
12000
12001 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12002 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12003 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12004 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12005 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vbase_dtor, 4)
12006 void __thiscall basic_istringstream_wchar_vbase_dtor(basic_istringstream_wchar *this)
12007 {
12008     TRACE("(%p)\n", this);
12009
12010     basic_istringstream_wchar_dtor(basic_istringstream_wchar_to_basic_ios(this));
12011     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
12012 }
12013
12014 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vector_dtor, 8)
12015 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
12016 {
12017     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
12018
12019     TRACE("(%p %x)\n", this, flags);
12020
12021     if(flags & 2) {
12022         /* we have an array, with the number of elements stored before the first object */
12023         INT_PTR i, *ptr = (INT_PTR *)this-1;
12024
12025         for(i=*ptr-1; i>=0; i--)
12026             basic_istringstream_wchar_vbase_dtor(this+i);
12027         MSVCRT_operator_delete(ptr);
12028     } else {
12029         basic_istringstream_wchar_vbase_dtor(this);
12030         if(flags & 1)
12031             MSVCRT_operator_delete(this);
12032     }
12033
12034     return this;
12035 }
12036
12037 /* ?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 */
12038 /* ?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 */
12039 /* ?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 */
12040 /* ?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 */
12041 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_rdbuf, 4)
12042 basic_stringbuf_wchar* __thiscall basic_istringstream_wchar_rdbuf(const basic_istringstream_wchar *this)
12043 {
12044     TRACE("(%p)\n", this);
12045     return (basic_stringbuf_wchar*)&this->strbuf;
12046 }
12047
12048 /* ?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 */
12049 /* ?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 */
12050 /* ?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 */
12051 /* ?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 */
12052 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_set, 8)
12053 void __thiscall basic_istringstream_wchar_str_set(basic_istringstream_wchar *this, const basic_string_wchar *str)
12054 {
12055     TRACE("(%p %p)\n", this, str);
12056     basic_stringbuf_wchar_str_set(&this->strbuf, str);
12057 }
12058
12059 /* ?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 */
12060 /* ?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 */
12061 /* ?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 */
12062 /* ?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 */
12063 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_get, 8)
12064 basic_string_wchar* __thiscall basic_istringstream_wchar_str_get(const basic_istringstream_wchar *this, basic_string_wchar *ret)
12065 {
12066     TRACE("(%p %p)\n", this, ret);
12067     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
12068 }
12069
12070 static inline basic_ios_char* basic_stringstream_char_to_basic_ios(basic_stringstream_char *ptr)
12071 {
12072     return (basic_ios_char*)((char*)ptr+basic_stringstream_char_vbtable1[1]);
12073 }
12074
12075 static inline basic_stringstream_char* basic_stringstream_char_from_basic_ios(basic_ios_char *ptr)
12076 {
12077     return (basic_stringstream_char*)((char*)ptr-basic_stringstream_char_vbtable1[1]);
12078 }
12079
12080 /* ??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 */
12081 /* ??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 */
12082 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_str, 16)
12083 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_str(basic_stringstream_char *this,
12084         const basic_string_char *str, int mode, MSVCP_bool virt_init)
12085 {
12086     basic_ios_char *basic_ios;
12087
12088     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
12089
12090     if(virt_init) {
12091         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
12092         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
12093         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12094         basic_ios_char_ctor(basic_ios);
12095     }else {
12096         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12097     }
12098
12099     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode);
12100     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
12101     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
12102     return this;
12103 }
12104
12105 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
12106 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
12107 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_mode, 12)
12108 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_mode(
12109         basic_stringstream_char *this, int mode, MSVCP_bool virt_init)
12110 {
12111     basic_ios_char *basic_ios;
12112
12113     TRACE("(%p %d %d)\n", this, mode, virt_init);
12114
12115     if(virt_init) {
12116         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
12117         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
12118         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12119         basic_ios_char_ctor(basic_ios);
12120     }else {
12121         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12122     }
12123
12124     basic_stringbuf_char_ctor_mode(&this->strbuf, mode);
12125     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
12126     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
12127     return this;
12128 }
12129
12130 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
12131 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
12132 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor, 8)
12133 basic_stringstream_char* __thiscall basic_stringstream_char_ctor(
12134         basic_stringstream_char *this, MSVCP_bool virt_init)
12135 {
12136     return basic_stringstream_char_ctor_mode(
12137             this, OPENMODE_out|OPENMODE_in, virt_init);
12138 }
12139
12140 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
12141 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
12142 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_dtor, 4)
12143 void __thiscall basic_stringstream_char_dtor(basic_ios_char *base)
12144 {
12145     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
12146
12147     TRACE("(%p)\n", this);
12148
12149     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
12150     basic_stringbuf_char_dtor(&this->strbuf);
12151 }
12152
12153 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
12154 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
12155 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vbase_dtor, 4)
12156 void __thiscall basic_stringstream_char_vbase_dtor(basic_stringstream_char *this)
12157 {
12158     TRACE("(%p)\n", this);
12159
12160     basic_stringstream_char_dtor(basic_stringstream_char_to_basic_ios(this));
12161     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
12162 }
12163
12164 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vector_dtor, 8)
12165 basic_stringstream_char* __thiscall basic_stringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
12166 {
12167     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
12168
12169     TRACE("(%p %x)\n", this, flags);
12170
12171     if(flags & 2) {
12172         /* we have an array, with the number of elements stored before the first object */
12173         INT_PTR i, *ptr = (INT_PTR *)this-1;
12174
12175         for(i=*ptr-1; i>=0; i--)
12176             basic_stringstream_char_vbase_dtor(this+i);
12177         MSVCRT_operator_delete(ptr);
12178     } else {
12179         basic_stringstream_char_vbase_dtor(this);
12180         if(flags & 1)
12181             MSVCRT_operator_delete(this);
12182     }
12183
12184     return this;
12185 }
12186
12187 /* ?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 */
12188 /* ?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 */
12189 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_rdbuf, 4)
12190 basic_stringbuf_char* __thiscall basic_stringstream_char_rdbuf(const basic_stringstream_char *this)
12191 {
12192     TRACE("(%p)\n", this);
12193     return (basic_stringbuf_char*)&this->strbuf;
12194 }
12195
12196 /* ?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 */
12197 /* ?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 */
12198 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_set, 8)
12199 void __thiscall basic_stringstream_char_str_set(basic_stringstream_char *this, const basic_string_char *str)
12200 {
12201     TRACE("(%p %p)\n", this, str);
12202     basic_stringbuf_char_str_set(&this->strbuf, str);
12203 }
12204
12205 /* ?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 */
12206 /* ?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 */
12207 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_get, 8)
12208 basic_string_char* __thiscall basic_stringstream_char_str_get(const basic_stringstream_char *this, basic_string_char *ret)
12209 {
12210     TRACE("(%p %p)\n", this, ret);
12211     return basic_stringbuf_char_str_get(&this->strbuf, ret);
12212 }
12213
12214 static inline basic_ios_wchar* basic_stringstream_wchar_to_basic_ios(basic_stringstream_wchar *ptr)
12215 {
12216     return (basic_ios_wchar*)((char*)ptr+basic_stringstream_wchar_vbtable1[1]);
12217 }
12218
12219 static inline basic_stringstream_wchar* basic_stringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
12220 {
12221     return (basic_stringstream_wchar*)((char*)ptr-basic_stringstream_wchar_vbtable1[1]);
12222 }
12223
12224 /* ??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 */
12225 /* ??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 */
12226 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor_str, 16)
12227 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor_str(basic_stringstream_wchar *this,
12228         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
12229 {
12230     basic_ios_wchar *basic_ios;
12231
12232     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
12233
12234     if(virt_init) {
12235         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
12236         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
12237         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12238         basic_ios_wchar_ctor(basic_ios);
12239     }else {
12240         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12241     }
12242
12243     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode);
12244     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
12245     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
12246     return this;
12247 }
12248
12249 /* ??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 */
12250 /* ??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 */
12251 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_str, 16)
12252 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_str(basic_stringstream_wchar *this,
12253         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
12254 {
12255     basic_stringstream_wchar_ctor_str(this, str, mode, virt_init);
12256     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
12257     return this;
12258 }
12259
12260 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
12261 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
12262 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor_mode, 12)
12263 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor_mode(
12264         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
12265 {
12266     basic_ios_wchar *basic_ios;
12267
12268     TRACE("(%p %d %d)\n", this, mode, virt_init);
12269
12270     if(virt_init) {
12271         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
12272         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
12273         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12274         basic_ios_wchar_ctor(basic_ios);
12275     }else {
12276         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12277     }
12278
12279     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode);
12280     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
12281     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
12282     return this;
12283 }
12284
12285 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
12286 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
12287 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_mode, 12)
12288 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_mode(
12289         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
12290 {
12291     basic_stringstream_wchar_ctor_mode(this, mode, virt_init);
12292     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
12293     return this;
12294 }
12295
12296 /* ??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12297 /* ??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12298 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor, 8)
12299 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor(
12300         basic_stringstream_wchar *this, MSVCP_bool virt_init)
12301 {
12302     return basic_stringstream_wchar_ctor_mode(
12303             this, OPENMODE_out|OPENMODE_in, virt_init);
12304 }
12305
12306 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12307 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12308 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor, 8)
12309 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor(
12310         basic_stringstream_wchar *this, MSVCP_bool virt_init)
12311 {
12312     return basic_stringstream_short_ctor_mode(
12313             this, OPENMODE_out|OPENMODE_in, virt_init);
12314 }
12315
12316 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
12317 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
12318 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
12319 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
12320 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_dtor, 4)
12321 void __thiscall basic_stringstream_wchar_dtor(basic_ios_wchar *base)
12322 {
12323     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
12324
12325     TRACE("(%p)\n", this);
12326
12327     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
12328     basic_stringbuf_wchar_dtor(&this->strbuf);
12329 }
12330
12331 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12332 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12333 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12334 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12335 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vbase_dtor, 4)
12336 void __thiscall basic_stringstream_wchar_vbase_dtor(basic_stringstream_wchar *this)
12337 {
12338     TRACE("(%p)\n", this);
12339
12340     basic_stringstream_wchar_dtor(basic_stringstream_wchar_to_basic_ios(this));
12341     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
12342 }
12343
12344 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vector_dtor, 8)
12345 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
12346 {
12347     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
12348
12349     TRACE("(%p %x)\n", this, flags);
12350
12351     if(flags & 2) {
12352         /* we have an array, with the number of elements stored before the first object */
12353         INT_PTR i, *ptr = (INT_PTR *)this-1;
12354
12355         for(i=*ptr-1; i>=0; i--)
12356             basic_stringstream_wchar_vbase_dtor(this+i);
12357         MSVCRT_operator_delete(ptr);
12358     } else {
12359         basic_stringstream_wchar_vbase_dtor(this);
12360         if(flags & 1)
12361             MSVCRT_operator_delete(this);
12362     }
12363
12364     return this;
12365 }
12366
12367 /* ?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 */
12368 /* ?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 */
12369 /* ?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 */
12370 /* ?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 */
12371 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_rdbuf, 4)
12372 basic_stringbuf_wchar* __thiscall basic_stringstream_wchar_rdbuf(const basic_stringstream_wchar *this)
12373 {
12374     TRACE("(%p)\n", this);
12375     return (basic_stringbuf_wchar*)&this->strbuf;
12376 }
12377
12378 /* ?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 */
12379 /* ?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 */
12380 /* ?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 */
12381 /* ?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 */
12382 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_set, 8)
12383 void __thiscall basic_stringstream_wchar_str_set(basic_stringstream_wchar *this, const basic_string_wchar *str)
12384 {
12385     TRACE("(%p %p)\n", this, str);
12386     basic_stringbuf_wchar_str_set(&this->strbuf, str);
12387 }
12388
12389 /* ?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 */
12390 /* ?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 */
12391 /* ?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 */
12392 /* ?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 */
12393 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_get, 8)
12394 basic_string_wchar* __thiscall basic_stringstream_wchar_str_get(const basic_stringstream_wchar *this, basic_string_wchar *ret)
12395 {
12396     TRACE("(%p %p)\n", this, ret);
12397     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
12398 }
12399
12400 /* ?_Init@strstreambuf@std@@IAEXHPAD0H@Z */
12401 /* ?_Init@strstreambuf@std@@IEAAX_JPEAD1H@Z */
12402 DEFINE_THISCALL_WRAPPER(strstreambuf__Init, 20)
12403 void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g, char *p, int mode)
12404 {
12405     TRACE("(%p %ld %p %p %d)\n", this, len, g, p, mode);
12406
12407     this->minsize = 32;
12408     this->endsave = NULL;
12409     this->strmode = mode;
12410     this->palloc = NULL;
12411     this->pfree = NULL;
12412
12413     if(!g) {
12414         this->strmode |= STRSTATE_Dynamic;
12415         if(len > this->minsize)
12416             this->minsize = len;
12417         this->seekhigh = NULL;
12418         return;
12419     }
12420
12421     if(len < 0)
12422         len = INT_MAX;
12423     else if(!len)
12424         len = strlen(g);
12425
12426     this->seekhigh = g+len;
12427     basic_streambuf_char_setg(&this->base, g, g, p ? p : this->seekhigh);
12428     if(p)
12429         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
12430 }
12431
12432 /* ??0strstreambuf@std@@QAE@PACH0@Z */
12433 /* ??0strstreambuf@std@@QEAA@PEAC_J0@Z */
12434 /* ??0strstreambuf@std@@QAE@PADH0@Z */
12435 /* ??0strstreambuf@std@@QEAA@PEAD_J0@Z */
12436 /* ??0strstreambuf@std@@QAE@PAEH0@Z */
12437 /* ??0strstreambuf@std@@QEAA@PEAE_J0@Z */
12438 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_get_put, 16)
12439 strstreambuf* __thiscall strstreambuf_ctor_get_put(strstreambuf *this, char *g, streamsize len, char *p)
12440 {
12441     TRACE("(%p %p %ld %p)\n", this, g, len, p);
12442
12443     basic_streambuf_char_ctor(&this->base);
12444     this->base.vtable = &MSVCP_strstreambuf_vtable;
12445
12446     strstreambuf__Init(this, len, g, p, 0);
12447     return this;
12448 }
12449
12450 /* ??0strstreambuf@std@@QAE@H@Z */
12451 /* ??0strstreambuf@std@@QEAA@_J@Z */
12452 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_len, 8)
12453 strstreambuf* __thiscall strstreambuf_ctor_len(strstreambuf *this, streamsize len)
12454 {
12455     return strstreambuf_ctor_get_put(this, NULL, len, NULL);
12456 }
12457
12458 /* ??0strstreambuf@std@@QAE@P6APAXI@ZP6AXPAX@Z@Z */
12459 /* ??0strstreambuf@std@@QEAA@P6APEAX_K@ZP6AXPEAX@Z@Z */
12460 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_alloc, 12)
12461 strstreambuf* __thiscall strstreambuf_ctor_alloc(strstreambuf *this, void* (__cdecl *palloc)(MSVCP_size_t), void (__cdecl *pfree)(void*))
12462 {
12463     TRACE("(%p %p %p)\n", this, palloc, pfree);
12464
12465     strstreambuf_ctor_get_put(this, NULL, 0, NULL);
12466     this->palloc = palloc;
12467     this->pfree = pfree;
12468     return this;
12469 }
12470
12471 /* ??0strstreambuf@std@@QAE@PBCH@Z */
12472 /* ??0strstreambuf@std@@QEAA@PEBC_J@Z */
12473 /* ??0strstreambuf@std@@QAE@PBDH@Z */
12474 /* ??0strstreambuf@std@@QEAA@PEBD_J@Z */
12475 /* ??0strstreambuf@std@@QAE@PBEH@Z */
12476 /* ??0strstreambuf@std@@QEAA@PEBE_J@Z */
12477 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_get, 12)
12478 strstreambuf* __thiscall strstreambuf_ctor_get(strstreambuf *this, const char *g, streamsize len)
12479 {
12480     TRACE("(%p %p %ld)\n", this, g, len);
12481
12482     strstreambuf_ctor_get_put(this, NULL, 0, NULL);
12483     this->strmode |= STRSTATE_Constant;
12484     return this;
12485 }
12486
12487 /* ??_Fstrstreambuf@std@@QAEXXZ */
12488 /* ??_Fstrstreambuf@std@@QEAAXXZ */
12489 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor, 4)
12490 strstreambuf* __thiscall strstreambuf_ctor(strstreambuf *this)
12491 {
12492     return strstreambuf_ctor_get_put(this, NULL, 0, NULL);
12493 }
12494
12495 /* ?_Tidy@strstreambuf@std@@IAEXXZ */
12496 /* ?_Tidy@strstreambuf@std@@IEAAXXZ */
12497 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
12498 void __thiscall strstreambuf__Tidy(strstreambuf *this)
12499 {
12500     TRACE("(%p)\n", this);
12501
12502     if((this->strmode & STRSTATE_Allocated) && !(this->strmode & STRSTATE_Frozen)) {
12503         if(this->pfree)
12504             this->pfree(basic_streambuf_char_eback(&this->base));
12505         else
12506             MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
12507     }
12508
12509     this->endsave = NULL;
12510     this->seekhigh = NULL;
12511     this->strmode &= ~(STRSTATE_Allocated | STRSTATE_Frozen);
12512     basic_streambuf_char_setg(&this->base, NULL, NULL, NULL);
12513     basic_streambuf_char_setp(&this->base, NULL, NULL);
12514 }
12515
12516 /* ??1strstreambuf@std@@UAE@XZ */
12517 /* ??1strstreambuf@std@@UEAA@XZ */
12518 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor, 4)
12519 void __thiscall strstreambuf_dtor(strstreambuf *this)
12520 {
12521     TRACE("(%p)\n", this);
12522
12523     strstreambuf__Tidy(this);
12524     basic_streambuf_char_dtor(&this->base);
12525 }
12526
12527 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor, 8)
12528 strstreambuf* __thiscall strstreambuf_vector_dtor(strstreambuf *this, unsigned int flags)
12529 {
12530     TRACE("(%p %x)\n", this, flags);
12531     if(flags & 2) {
12532         /* we have an array, with the number of elements stored before the first object */
12533         INT_PTR i, *ptr = (INT_PTR *)this-1;
12534
12535         for(i=*ptr-1; i>=0; i--)
12536             strstreambuf_dtor(this+i);
12537         MSVCRT_operator_delete(ptr);
12538     } else {
12539         strstreambuf_dtor(this);
12540         if(flags & 1)
12541             MSVCRT_operator_delete(this);
12542     }
12543
12544     return this;
12545 }
12546
12547 /* ?freeze@strstreambuf@std@@QAEX_N@Z */
12548 /* ?freeze@strstreambuf@std@@QEAAX_N@Z */
12549 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze, 8)
12550 void __thiscall strstreambuf_freeze(strstreambuf *this, MSVCP_bool freeze)
12551 {
12552     TRACE("(%p %d)\n", this, freeze);
12553
12554     if(!freeze == !(this->strmode *STRSTATE_Frozen))
12555         return;
12556
12557     if(freeze) {
12558         this->strmode |= STRSTATE_Frozen;
12559         this->endsave = basic_streambuf_char_epptr(&this->base);
12560         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
12561                 basic_streambuf_char_pptr(&this->base), basic_streambuf_char_eback(&this->base));
12562     }else {
12563         this->strmode &= ~STRSTATE_Frozen;
12564         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
12565                 basic_streambuf_char_pptr(&this->base), this->endsave);
12566     }
12567 }
12568
12569 /* ?str@strstreambuf@std@@QAEPADXZ */
12570 /* ?str@strstreambuf@std@@QEAAPEADXZ */
12571 DEFINE_THISCALL_WRAPPER(strstreambuf_str, 4)
12572 char* __thiscall strstreambuf_str(strstreambuf *this)
12573 {
12574     TRACE("(%p)\n", this);
12575
12576     strstreambuf_freeze(this, TRUE);
12577     return basic_streambuf_char_gptr(&this->base);
12578 }
12579
12580 /* ?pcount@strstreambuf@std@@QBEHXZ */
12581 /* ?pcount@strstreambuf@std@@QEBA_JXZ */
12582 DEFINE_THISCALL_WRAPPER(strstreambuf_pcount, 4)
12583 streamsize __thiscall strstreambuf_pcount(const strstreambuf *this)
12584 {
12585     char *ppos = basic_streambuf_char_pptr(&this->base);
12586
12587     TRACE("(%p)\n", this);
12588
12589     return ppos ? ppos-basic_streambuf_char_pbase(&this->base) : 0;
12590 }
12591
12592 /* ?overflow@strstreambuf@std@@MAEHH@Z */
12593 /* ?overflow@strstreambuf@std@@MEAAHH@Z */
12594 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow, 8)
12595 int __thiscall strstreambuf_overflow(strstreambuf *this, int c)
12596 {
12597     MSVCP_size_t old_size, size;
12598     char *ptr, *buf;
12599
12600     TRACE("(%p %d)\n", this, c);
12601
12602     if(c == EOF)
12603         return !EOF;
12604
12605     if(this->strmode & STRSTATE_Frozen)
12606         return EOF;
12607
12608     ptr = basic_streambuf_char_pptr(&this->base);
12609     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
12610         return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
12611
12612     if(!(this->strmode & STRSTATE_Dynamic) || (this->strmode & STRSTATE_Constant))
12613         return EOF;
12614
12615     ptr = basic_streambuf_char_eback(&this->base);
12616     old_size = ptr ? basic_streambuf_char_epptr(&this->base) - ptr : 0;
12617
12618     size = old_size + old_size/2;
12619     if(size < this->minsize)
12620         size = this->minsize;
12621
12622     if(this->palloc)
12623         buf = this->palloc(size);
12624     else
12625         buf = MSVCRT_operator_new(size);
12626     if(!buf)
12627         return EOF;
12628
12629     memcpy(buf, ptr, old_size);
12630     if(this->strmode & STRSTATE_Allocated) {
12631         if(this->pfree)
12632             this->pfree(ptr);
12633         else
12634             MSVCRT_operator_delete(ptr);
12635     }
12636
12637     this->strmode |= STRSTATE_Allocated;
12638     if(!old_size) {
12639         this->seekhigh = buf;
12640         basic_streambuf_char_setp(&this->base, buf, buf+size);
12641         basic_streambuf_char_setg(&this->base, buf, buf, buf);
12642     }else {
12643         this->seekhigh = this->seekhigh-ptr+buf;
12644         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base)-ptr+buf,
12645                 basic_streambuf_char_pptr(&this->base)-ptr+buf, buf+size);
12646         basic_streambuf_char_setg(&this->base, buf, basic_streambuf_char_gptr(&this->base)-ptr+buf,
12647                 basic_streambuf_char_pptr(&this->base));
12648     }
12649
12650     return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
12651 }
12652
12653 /* ?pbackfail@strstreambuf@std@@MAEHH@Z */
12654 /* ?pbackfail@strstreambuf@std@@MEAAHH@Z */
12655 DEFINE_THISCALL_WRAPPER(strstreambuf_pbackfail, 8)
12656 int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c)
12657 {
12658     char *ptr = basic_streambuf_char_gptr(&this->base);
12659
12660     TRACE("(%p %d)\n", this, c);
12661
12662     if(ptr<=basic_streambuf_char_eback(&this->base)
12663             || ((this->strmode & STRSTATE_Constant) && c!=ptr[-1]))
12664         return EOF;
12665
12666     basic_streambuf_char_gbump(&this->base, -1);
12667     if(c == EOF)
12668         return !EOF;
12669     if(this->strmode & STRSTATE_Constant)
12670         return (unsigned char)c;
12671
12672     return (unsigned char)(ptr[0] = c);
12673 }
12674
12675 /* ?seekoff@strstreambuf@std@@MAE?AV?$fpos@H@2@JHH@Z */
12676 /* ?seekoff@strstreambuf@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
12677 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20)
12678 fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode)
12679 {
12680     char *eback = basic_streambuf_char_eback(&this->base);
12681     char *pptr = basic_streambuf_char_pptr(&this->base);
12682     char *gptr = basic_streambuf_char_gptr(&this->base);
12683
12684     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
12685
12686     ret->off = 0;
12687     ret->state = 0;
12688
12689     if(pptr > this->seekhigh)
12690         this->seekhigh = pptr;
12691
12692     if((mode & OPENMODE_in) && gptr) {
12693         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
12694             off += gptr-eback;
12695         else if(way == SEEKDIR_end)
12696             off += this->seekhigh-eback;
12697         else if(way != SEEKDIR_beg)
12698             off = -1;
12699
12700         if(off<0 || off>this->seekhigh-eback) {
12701             off = -1;
12702         }else {
12703             basic_streambuf_char_gbump(&this->base, eback-gptr+off);
12704             if((mode & OPENMODE_out) && pptr) {
12705                 basic_streambuf_char_setp_next(&this->base, eback,
12706                         gptr, basic_streambuf_char_epptr(&this->base));
12707             }
12708         }
12709     }else if((mode & OPENMODE_out) && pptr) {
12710         if(way == SEEKDIR_cur)
12711             off += pptr-eback;
12712         else if(way == SEEKDIR_end)
12713             off += this->seekhigh-eback;
12714         else if(way != SEEKDIR_beg)
12715             off = -1;
12716
12717          if(off<0 || off>this->seekhigh-eback)
12718              off = -1;
12719          else
12720              basic_streambuf_char_pbump(&this->base, eback-pptr+off);
12721     }else {
12722         off = -1;
12723     }
12724
12725     ret->pos = off;
12726     return ret;
12727 }
12728
12729 /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */
12730 /* ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
12731 DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36)
12732 fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode)
12733 {
12734     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
12735
12736     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
12737         *ret = pos;
12738         return ret;
12739     }
12740
12741     return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
12742 }
12743
12744 /* ?underflow@strstreambuf@std@@MAEHXZ */
12745 /* ?underflow@strstreambuf@std@@MEAAHXZ */
12746 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow, 4)
12747 int __thiscall strstreambuf_underflow(strstreambuf *this)
12748 {
12749     char *gptr = basic_streambuf_char_gptr(&this->base);
12750     char *pptr;
12751
12752     TRACE("(%p)\n", this);
12753
12754     if(!gptr)
12755         return EOF;
12756
12757     if(gptr < basic_streambuf_char_egptr(&this->base))
12758         return (unsigned char)(*gptr);
12759
12760     pptr = basic_streambuf_char_gptr(&this->base);
12761     if(pptr > this->seekhigh)
12762         this->seekhigh = pptr;
12763
12764     if(this->seekhigh <= gptr)
12765         return EOF;
12766
12767     basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base),
12768             gptr, this->seekhigh);
12769     return (unsigned char)(*gptr);
12770 }
12771
12772 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
12773 {
12774     ios_base_precision_set(base, prec);
12775 }
12776
12777 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
12778 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12779 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
12780 {
12781     TRACE("(%p %ld)\n", ret, prec);
12782
12783     ret->pfunc = setprecision_func;
12784     ret->arg = prec;
12785     return ret;
12786 }
12787
12788 static void __cdecl setw_func(ios_base *base, streamsize width)
12789 {
12790     ios_base_width_set(base, width);
12791 }
12792
12793 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
12794 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12795 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
12796 {
12797     TRACE("(%p %ld)\n", ret, width);
12798
12799     ret->pfunc = setw_func;
12800     ret->arg = width;
12801     return ret;
12802 }
12803
12804 static basic_filebuf_char filebuf_char_stdin;
12805 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
12806 struct {
12807     basic_istream_char obj;
12808     basic_ios_char vbase;
12809 } cin = { { 0 } };
12810 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
12811 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
12812 basic_istream_char *_Ptr_cin = &cin.obj;
12813
12814 static basic_filebuf_wchar filebuf_short_stdin;
12815 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
12816 struct {
12817     basic_istream_wchar obj;
12818     basic_ios_wchar vbase;
12819 } ucin = { { 0 } };
12820 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
12821 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
12822 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
12823
12824 static basic_filebuf_wchar filebuf_wchar_stdin;
12825 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12826 struct {
12827     basic_istream_wchar obj;
12828     basic_ios_wchar vbase;
12829 } wcin = { { 0 } };
12830 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12831 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
12832 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
12833
12834 static basic_filebuf_char filebuf_char_stdout;
12835 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12836 struct {
12837     basic_ostream_char obj;
12838     basic_ios_char vbase;
12839 } cout = { { 0 } };
12840 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12841 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12842 basic_ostream_char *_Ptr_cout = &cout.obj;
12843
12844 static basic_filebuf_wchar filebuf_short_stdout;
12845 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12846 struct {
12847     basic_ostream_wchar obj;
12848     basic_ios_wchar vbase;
12849 } ucout = { { 0 } };
12850 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12851 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12852 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
12853
12854 static basic_filebuf_wchar filebuf_wchar_stdout;
12855 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12856 struct {
12857     basic_ostream_wchar obj;
12858     basic_ios_wchar vbase;
12859 } wcout = { { 0 } };
12860 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12861 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12862 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
12863
12864 static basic_filebuf_char filebuf_char_stderr;
12865 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12866 struct {
12867     basic_ostream_char obj;
12868     basic_ios_char vbase;
12869 } cerr = { { 0 } };
12870 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12871 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12872 basic_ostream_char *_Ptr_cerr = &cerr.obj;
12873
12874 static basic_filebuf_wchar filebuf_short_stderr;
12875 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12876 struct {
12877     basic_ostream_wchar obj;
12878     basic_ios_wchar vbase;
12879 } ucerr = { { 0 } };
12880 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12881 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12882 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
12883
12884 static basic_filebuf_wchar filebuf_wchar_stderr;
12885 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12886 struct {
12887     basic_ostream_wchar obj;
12888     basic_ios_wchar vbase;
12889 } wcerr = { { 0 } };
12890 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12891 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12892 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
12893
12894 static basic_filebuf_char filebuf_char_log;
12895 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12896 struct {
12897     basic_ostream_char obj;
12898     basic_ios_char vbase;
12899 } clog = { { 0 } };
12900 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12901 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12902 basic_ostream_char *_Ptr_clog = &clog.obj;
12903
12904 static basic_filebuf_wchar filebuf_short_log;
12905 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12906 struct {
12907     basic_ostream_wchar obj;
12908     basic_ios_wchar vbase;
12909 } uclog = { { 0 } };
12910 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12911 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12912 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
12913
12914 static basic_filebuf_wchar filebuf_wchar_log;
12915 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12916 struct {
12917     basic_ostream_wchar obj;
12918     basic_ios_wchar vbase;
12919 } wclog = { { 0 } };
12920 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12921 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12922 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
12923
12924 void init_io(void)
12925 {
12926 #ifdef __x86_64__
12927     void *base = GetModuleHandleA("msvcp90.dll");
12928     init_iosb_rtti(base);
12929     init_ios_base_rtti(base);
12930     init_basic_ios_char_rtti(base);
12931     init_basic_ios_wchar_rtti(base);
12932     init_basic_ios_short_rtti(base);
12933     init_basic_streambuf_char_rtti(base);
12934     init_basic_streambuf_wchar_rtti(base);
12935     init_basic_streambuf_short_rtti(base);
12936     init_basic_filebuf_char_rtti(base);
12937     init_basic_filebuf_wchar_rtti(base);
12938     init_basic_filebuf_short_rtti(base);
12939     init_basic_stringbuf_char_rtti(base);
12940     init_basic_stringbuf_wchar_rtti(base);
12941     init_basic_stringbuf_short_rtti(base);
12942     init_basic_ostream_char_rtti(base);
12943     init_basic_ostream_wchar_rtti(base);
12944     init_basic_ostream_short_rtti(base);
12945     init_basic_istream_char_rtti(base);
12946     init_basic_istream_wchar_rtti(base);
12947     init_basic_istream_short_rtti(base);
12948     init_basic_iostream_char_rtti(base);
12949     init_basic_iostream_wchar_rtti(base);
12950     init_basic_iostream_short_rtti(base);
12951     init_basic_ofstream_char_rtti(base);
12952     init_basic_ofstream_wchar_rtti(base);
12953     init_basic_ofstream_short_rtti(base);
12954     init_basic_ifstream_char_rtti(base);
12955     init_basic_ifstream_wchar_rtti(base);
12956     init_basic_ifstream_short_rtti(base);
12957     init_basic_fstream_char_rtti(base);
12958     init_basic_fstream_wchar_rtti(base);
12959     init_basic_fstream_short_rtti(base);
12960     init_basic_ostringstream_char_rtti(base);
12961     init_basic_ostringstream_wchar_rtti(base);
12962     init_basic_ostringstream_short_rtti(base);
12963     init_basic_istringstream_char_rtti(base);
12964     init_basic_istringstream_wchar_rtti(base);
12965     init_basic_istringstream_short_rtti(base);
12966     init_basic_stringstream_char_rtti(base);
12967     init_basic_stringstream_wchar_rtti(base);
12968     init_basic_stringstream_short_rtti(base);
12969     init_strstreambuf_rtti(base);
12970 #endif
12971
12972     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
12973     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
12974
12975     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
12976     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
12977
12978     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
12979     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
12980
12981     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
12982     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE);
12983
12984     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
12985     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE);
12986
12987     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
12988     basic_ostream_wchar_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE);
12989
12990     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
12991     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE);
12992
12993     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
12994     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE);
12995
12996     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
12997     basic_ostream_wchar_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE);
12998
12999     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
13000     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE);
13001
13002     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
13003     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE);
13004
13005     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
13006     basic_ostream_wchar_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE);
13007 }
13008
13009 void free_io(void)
13010 {
13011     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&cin.obj));
13012     basic_filebuf_char_dtor(&filebuf_char_stdin);
13013
13014     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&ucin.obj));
13015     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
13016
13017     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&wcin.obj));
13018     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
13019
13020     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&cout.obj));
13021     basic_filebuf_char_dtor(&filebuf_char_stdout);
13022
13023     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&ucout.obj));
13024     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
13025
13026     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&wcout.obj));
13027     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
13028
13029     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&cerr.obj));
13030     basic_filebuf_char_dtor(&filebuf_char_stderr);
13031
13032     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&ucerr.obj));
13033     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
13034
13035     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&wcerr.obj));
13036     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
13037
13038     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&clog.obj));
13039     basic_filebuf_char_dtor(&filebuf_char_log);
13040
13041     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&uclog.obj));
13042     basic_filebuf_wchar_dtor(&filebuf_short_log);
13043
13044     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&wclog.obj));
13045     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
13046 }