ws2_32: Define IP_UNICAST_IF if not found on linux.
[wine] / dlls / msvcp90 / ios.c
1 /*
2  * Copyright 2011 Piotr Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <limits.h>
24 #include <share.h>
25
26 #include "msvcp90.h"
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
31
32 /* ?_Index@ios_base@std@@0HA */
33 int ios_base_Index = 0;
34 /* ?_Sync@ios_base@std@@0_NA */
35 MSVCP_bool ios_base_Sync = FALSE;
36
37 typedef struct {
38     streamoff off;
39     __int64 DECLSPEC_ALIGN(8) pos;
40     int state;
41 } fpos_int;
42
43 static inline const char* debugstr_fpos_int(fpos_int *fpos)
44 {
45     return wine_dbg_sprintf("fpos(%ld %s %d)", fpos->off, wine_dbgstr_longlong(fpos->pos), fpos->state);
46 }
47
48 typedef struct {
49     void (__cdecl *pfunc)(ios_base*, streamsize);
50     streamsize arg;
51 } manip_streamsize;
52
53 typedef struct {
54     void (__cdecl *pfunc)(ios_base*, int);
55     int arg;
56 } manip_int;
57
58 typedef enum {
59     INITFL_new   = 0,
60     INITFL_open  = 1,
61     INITFL_close = 2
62 } basic_filebuf__Initfl;
63
64 typedef struct {
65     basic_streambuf_char base;
66     codecvt_char *cvt;
67     char putback;
68     MSVCP_bool wrotesome;
69     int state;
70     MSVCP_bool close;
71     FILE *file;
72 } basic_filebuf_char;
73
74 typedef struct {
75     basic_streambuf_wchar base;
76     codecvt_wchar *cvt;
77     wchar_t putback;
78     MSVCP_bool wrotesome;
79     int state;
80     MSVCP_bool close;
81     FILE *file;
82 } basic_filebuf_wchar;
83
84 typedef enum {
85     STRINGBUF_allocated = 1,
86     STRINGBUF_no_write = 2,
87     STRINGBUF_no_read = 4,
88     STRINGBUF_append = 8,
89     STRINGBUF_at_end = 16
90 } basic_stringbuf_state;
91
92 typedef struct {
93     basic_streambuf_char base;
94     char *seekhigh;
95     int state;
96     char allocator; /* empty struct */
97 } basic_stringbuf_char;
98
99 typedef struct {
100     basic_streambuf_wchar base;
101     wchar_t *seekhigh;
102     int state;
103     char allocator; /* empty struct */
104 } basic_stringbuf_wchar;
105
106 typedef struct {
107     ios_base base;
108     basic_streambuf_char *strbuf;
109     struct _basic_ostream_char *stream;
110     char fillch;
111 } basic_ios_char;
112
113 typedef struct {
114     ios_base base;
115     basic_streambuf_wchar *strbuf;
116     struct _basic_ostream_wchar *stream;
117     wchar_t fillch;
118 } basic_ios_wchar;
119
120 typedef struct _basic_ostream_char {
121     const int *vbtable;
122     /* virtual inheritance
123      * basic_ios_char basic_ios;
124      */
125 } basic_ostream_char;
126
127 typedef struct _basic_ostream_wchar {
128     const int *vbtable;
129     /* virtual inheritance
130      * basic_ios_wchar basic_ios;
131      */
132 } basic_ostream_wchar;
133
134 typedef struct {
135     const int *vbtable;
136     streamsize count;
137     /* virtual inheritance
138      * basic_ios_char basic_ios;
139      */
140 } basic_istream_char;
141
142 typedef struct {
143     const int *vbtable;
144     streamsize count;
145     /* virtual inheritance
146      * basic_ios_wchar basic_ios;
147      */
148 } basic_istream_wchar;
149
150 typedef struct {
151     basic_istream_char base1;
152     basic_ostream_char base2;
153     /* virtual inheritance
154      * basic_ios_char basic_ios;
155      */
156 } basic_iostream_char;
157
158 typedef struct {
159     basic_istream_wchar base1;
160     basic_ostream_wchar base2;
161     /* virtual inheritance
162      * basic_ios_wchar basic_ios;
163      */
164 } basic_iostream_wchar;
165
166 typedef struct {
167     basic_ostream_char base;
168     basic_filebuf_char filebuf;
169     /* virtual inheritance
170      * basic_ios_char basic_ios;
171      */
172 } basic_ofstream_char;
173
174 typedef struct {
175     basic_ostream_wchar base;
176     basic_filebuf_wchar filebuf;
177     /* virtual inheritance
178      * basic_ios_wchar basic_ios;
179      */
180 } basic_ofstream_wchar;
181
182 typedef struct {
183     basic_istream_char base;
184     basic_filebuf_char filebuf;
185     /* virtual inheritance
186      * basic_ios_char basic_ios;
187      */
188 } basic_ifstream_char;
189
190 typedef struct {
191     basic_istream_wchar base;
192     basic_filebuf_wchar filebuf;
193     /* virtual inheritance
194      * basic_ios_wchar basic_ios;
195      */
196 } basic_ifstream_wchar;
197
198 typedef struct {
199     basic_iostream_char base;
200     basic_filebuf_char filebuf;
201     /* virtual inheritance
202      * basic_ios_char basic_ios;
203      */
204 } basic_fstream_char;
205
206 typedef struct {
207     basic_iostream_wchar base;
208     basic_filebuf_wchar filebuf;
209     /* virtual inheritance
210      * basic_ios_char basic_ios;
211      */
212 } basic_fstream_wchar;
213
214 typedef struct {
215     basic_ostream_char base;
216     basic_stringbuf_char strbuf;
217     /* virtual inheritance
218      * basic_ios_char basic_ios;
219      */
220 } basic_ostringstream_char;
221
222 typedef struct {
223     basic_ostream_wchar base;
224     basic_stringbuf_wchar strbuf;
225     /* virtual inheritance
226      * basic_ios_wchar basic_ios;
227      */
228 } basic_ostringstream_wchar;
229
230 typedef struct {
231     basic_istream_char base;
232     basic_stringbuf_char strbuf;
233     /* virtual inheritance
234      * basic_ios_char basic_ios;
235      */
236 } basic_istringstream_char;
237
238 typedef struct {
239     basic_istream_wchar base;
240     basic_stringbuf_wchar strbuf;
241     /* virtual inheritance
242      * basic_ios_wchar basic_ios;
243      */
244 } basic_istringstream_wchar;
245
246 typedef struct {
247     basic_iostream_char base;
248     basic_stringbuf_char strbuf;
249     /* virtual inheritance
250      * basic_ios_char basic_ios;
251      */
252 } basic_stringstream_char;
253
254 typedef struct {
255     basic_iostream_wchar base;
256     basic_stringbuf_wchar strbuf;
257     /* virtual inheritance
258      * basic_ios_wchar basic_ios;
259      */
260 } basic_stringstream_wchar;
261
262 typedef enum {
263     STRSTATE_Allocated = 1,
264     STRSTATE_Constant = 2,
265     STRSTATE_Dynamic = 4,
266     STRSTATE_Frozen = 8
267 } strstreambuf__Strstate;
268
269 typedef struct {
270     basic_streambuf_char base;
271     streamsize minsize;
272     char *endsave;
273     char *seekhigh;
274     int strmode;
275     void* (__cdecl *palloc)(MSVCP_size_t);
276     void (__cdecl *pfree)(void*);
277 } strstreambuf;
278
279 extern const vtable_ptr MSVCP_iosb_vtable;
280
281 /* ??_7ios_base@std@@6B@ */
282 extern const vtable_ptr MSVCP_ios_base_vtable;
283
284 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
285 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
286
287 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
288 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
289
290 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
291 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
292
293 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
294 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
295
296 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
297 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
298
299 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
300 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
301
302 /* ??_7?$basic_filebuf@DU?$char_traits@D@std@@@std@@6B@ */
303 extern const vtable_ptr MSVCP_basic_filebuf_char_vtable;
304
305 /* ??_7?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@6B@ */
306 extern const vtable_ptr MSVCP_basic_filebuf_wchar_vtable;
307
308 /* ??_7?$basic_filebuf@GU?$char_traits@G@std@@@std@@6B@ */
309 extern const vtable_ptr MSVCP_basic_filebuf_short_vtable;
310
311 /* ??_7?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
312 extern const vtable_ptr MSVCP_basic_stringbuf_char_vtable;
313
314 /* ??_7?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
315 extern const vtable_ptr MSVCP_basic_stringbuf_wchar_vtable;
316
317 /* ??_7?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
318 extern const vtable_ptr MSVCP_basic_stringbuf_short_vtable;
319
320 /* ??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@ */
321 const int basic_ostream_char_vbtable[] = {0, sizeof(basic_ostream_char)};
322 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
323 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
324
325 /* ??_8?$basic_ostream@_WU?$char_traits@_W@std@@@std@@7B@ */
326 const int basic_ostream_wchar_vbtable[] = {0, sizeof(basic_ostream_wchar)};
327 /* ??_7?$basic_ostream@_WU?$char_traits@_W@std@@@std@@6B@ */
328 extern const vtable_ptr MSVCP_basic_ostream_wchar_vtable;
329
330 /* ??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@ */
331 const int basic_ostream_short_vbtable[] = {0, sizeof(basic_ostream_wchar)};
332 /* ??_7?$basic_ostream@GU?$char_traits@G@std@@@std@@6B@ */
333 extern const vtable_ptr MSVCP_basic_ostream_short_vtable;
334
335 /* ??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@ */
336 const int basic_istream_char_vbtable[] = {0, sizeof(basic_istream_char)};
337 /* ??_7?$basic_istream@DU?$char_traits@D@std@@@std@@6B@ */
338 extern const vtable_ptr MSVCP_basic_istream_char_vtable;
339
340 /* ??_8?$basic_istream@_WU?$char_traits@_W@std@@@std@@7B@ */
341 const int basic_istream_wchar_vbtable[] = {0, sizeof(basic_istream_wchar)};
342 /* ??_7?$basic_istream@_WU?$char_traits@_W@std@@@std@@6B@ */
343 extern const vtable_ptr MSVCP_basic_istream_wchar_vtable;
344
345 /* ??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@ */
346 const int basic_istream_short_vbtable[] = {0, sizeof(basic_istream_wchar)};
347 /* ??_7?$basic_istream@GU?$char_traits@G@std@@@std@@6B@ */
348 extern const vtable_ptr MSVCP_basic_istream_short_vtable;
349
350 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
351 const int basic_iostream_char_vbtable1[] = {0, sizeof(basic_iostream_char)};
352 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
353 const int basic_iostream_char_vbtable2[] = {0, sizeof(basic_iostream_char)-FIELD_OFFSET(basic_iostream_char, base2)};
354 /* ??_7?$basic_iostream@DU?$char_traits@D@std@@@std@@6B@ */
355 extern const vtable_ptr MSVCP_basic_iostream_char_vtable;
356
357 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
358 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
359 const int basic_iostream_wchar_vbtable1[] = {0, sizeof(basic_iostream_wchar)};
360 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
361 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
362 const int basic_iostream_wchar_vbtable2[] = {0, sizeof(basic_iostream_wchar)-FIELD_OFFSET(basic_iostream_wchar, base2)};
363 /* ??_7?$basic_iostream@_WU?$char_traits@_W@std@@@std@@6B@ */
364 extern const vtable_ptr MSVCP_basic_iostream_wchar_vtable;
365 /* ??_7?$basic_iostream@GU?$char_traits@G@std@@@std@@6B@ */
366 extern const vtable_ptr MSVCP_basic_iostream_short_vtable;
367
368 /* ??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@ */
369 const int basic_ofstream_char_vbtable[] = {0, sizeof(basic_ofstream_char)};
370 /* ??_7?$basic_ofstream@DU?$char_traits@D@std@@@std@@6B@ */
371 extern const vtable_ptr MSVCP_basic_ofstream_char_vtable;
372
373 /* ??_8?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@7B@ */
374 const int basic_ofstream_wchar_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
375 /* ??_7?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@6B@ */
376 extern const vtable_ptr MSVCP_basic_ofstream_wchar_vtable;
377
378 /* ??_8?$basic_ofstream@GU?$char_traits@G@std@@@std@@7B@ */
379 const int basic_ofstream_short_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
380 /* ??_7?$basic_ofstream@GU?$char_traits@G@std@@@std@@6B@ */
381 extern const vtable_ptr MSVCP_basic_ofstream_short_vtable;
382
383 /* ??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@ */
384 const int basic_ifstream_char_vbtable[] = {0, sizeof(basic_ifstream_char)};
385 /* ??_7?$basic_ifstream@DU?$char_traits@D@std@@@std@@6B@ */
386 extern const vtable_ptr MSVCP_basic_ifstream_char_vtable;
387
388 /* ??_8?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@7B@ */
389 const int basic_ifstream_wchar_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
390 /* ??_7?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@6B@ */
391 extern const vtable_ptr MSVCP_basic_ifstream_wchar_vtable;
392
393 /* ??_8?$basic_ifstream@GU?$char_traits@G@std@@@std@@7B@ */
394 const int basic_ifstream_short_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
395 /* ??_7?$basic_ifstream@GU?$char_traits@G@std@@@std@@6B@ */
396 extern const vtable_ptr MSVCP_basic_ifstream_short_vtable;
397
398 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
399 const int basic_fstream_char_vbtable1[] = {0, sizeof(basic_fstream_char)};
400 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
401 const int basic_fstream_char_vbtable2[] = {0, sizeof(basic_fstream_char)-FIELD_OFFSET(basic_fstream_char, base.base2)};
402 /* ??_7?$basic_fstream@DU?$char_traits@D@std@@@std@@6B@ */
403 extern const vtable_ptr MSVCP_basic_fstream_char_vtable;
404
405 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
406 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
407 const int basic_fstream_wchar_vbtable1[] = {0, sizeof(basic_fstream_wchar)};
408 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
409 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
410 const int basic_fstream_wchar_vbtable2[] = {0, sizeof(basic_fstream_wchar)-FIELD_OFFSET(basic_fstream_wchar, base.base2)};
411 /* ??_7?$basic_fstream@_WU?$char_traits@_W@std@@@std@@6B@ */
412 extern const vtable_ptr MSVCP_basic_fstream_wchar_vtable;
413 /* ??_7?$basic_fstream@GU?$char_traits@G@std@@@std@@6B@ */
414 extern const vtable_ptr MSVCP_basic_fstream_short_vtable;
415
416 /* ??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
417 const int basic_ostringstream_char_vbtable[] = {0, sizeof(basic_ostringstream_char)};
418 /* ??_7?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
419 extern const vtable_ptr MSVCP_basic_ostringstream_char_vtable;
420
421 /* ??_8?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
422 const int basic_ostringstream_wchar_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
423 /* ??_7?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
424 extern const vtable_ptr MSVCP_basic_ostringstream_wchar_vtable;
425
426 /* ??_8?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
427 const int basic_ostringstream_short_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
428 /* ??_7?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
429 extern const vtable_ptr MSVCP_basic_ostringstream_short_vtable;
430
431 /* ??_8?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
432 const int basic_istringstream_char_vbtable[] = {0, sizeof(basic_istringstream_char)};
433 /* ??_7?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
434 extern const vtable_ptr MSVCP_basic_istringstream_char_vtable;
435
436 /* ??_8?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
437 const int basic_istringstream_wchar_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
438 /* ??_7?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
439 extern const vtable_ptr MSVCP_basic_istringstream_wchar_vtable;
440
441 /* ??_8?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
442 const int basic_istringstream_short_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
443 /* ??_7?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
444 extern const vtable_ptr MSVCP_basic_istringstream_short_vtable;
445
446 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
447 const int basic_stringstream_char_vbtable1[] = {0, sizeof(basic_stringstream_char)};
448 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
449 const int basic_stringstream_char_vbtable2[] = {0, sizeof(basic_stringstream_char)-FIELD_OFFSET(basic_stringstream_char, base.base2)};
450 /* ??_7?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
451 extern const vtable_ptr MSVCP_basic_stringstream_char_vtable;
452
453 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
454 const int basic_stringstream_wchar_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
455 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
456 const int basic_stringstream_wchar_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
457 /* ??_7?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
458 extern const vtable_ptr MSVCP_basic_stringstream_wchar_vtable;
459
460 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
461 const int basic_stringstream_short_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
462 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
463 const int basic_stringstream_short_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
464 /* ??_7?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
465 extern const vtable_ptr MSVCP_basic_stringstream_short_vtable;
466
467 /* ??_7strstreambuf@std@@6B */
468 extern const vtable_ptr MSVCP_strstreambuf_vtable;
469
470 DEFINE_RTTI_DATA0(iosb, 0, ".?AV?$_Iosb@H@std@@");
471 DEFINE_RTTI_DATA1(ios_base, 0, &iosb_rtti_base_descriptor, ".?AV?$_Iosb@H@std@@");
472 DEFINE_RTTI_DATA2(basic_ios_char, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
473         ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@");
474 DEFINE_RTTI_DATA2(basic_ios_wchar, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
475         ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@");
476 DEFINE_RTTI_DATA2(basic_ios_short, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
477         ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@");
478 DEFINE_RTTI_DATA0(basic_streambuf_char, 0,
479         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@");
480 DEFINE_RTTI_DATA0(basic_streambuf_wchar, 0,
481         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@");
482 DEFINE_RTTI_DATA0(basic_streambuf_short, 0,
483         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@");
484 DEFINE_RTTI_DATA1(basic_filebuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
485         ".?AV?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@");
486 DEFINE_RTTI_DATA1(basic_filebuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
487         ".?AV?$basic_filebuf@GU?$char_traits@G@std@@@std@@");
488 DEFINE_RTTI_DATA1(basic_filebuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
489         ".?AV?$basic_filebuf@DU?$char_traits@D@std@@@std@@");
490 DEFINE_RTTI_DATA1(basic_stringbuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
491         ".?AV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
492 DEFINE_RTTI_DATA1(basic_stringbuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
493         ".?AV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
494 DEFINE_RTTI_DATA1(basic_stringbuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
495         ".?AV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
496 DEFINE_RTTI_DATA3(basic_ostream_char, sizeof(basic_ostream_char), &basic_ios_char_rtti_base_descriptor,
497         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
498         ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@");
499 DEFINE_RTTI_DATA3(basic_ostream_wchar, sizeof(basic_ostream_wchar), &basic_ios_wchar_rtti_base_descriptor,
500         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
501         ".?AV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@");
502 DEFINE_RTTI_DATA3(basic_ostream_short, sizeof(basic_ostream_wchar), &basic_ios_short_rtti_base_descriptor,
503         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
504         ".?AV?$basic_ostream@GU?$char_traits@G@std@@@std@@");
505 DEFINE_RTTI_DATA3(basic_istream_char, sizeof(basic_istream_char), &basic_ios_char_rtti_base_descriptor,
506         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
507         ".?AV?$basic_istream@DU?$char_traits@D@std@@@std@@");
508 DEFINE_RTTI_DATA3(basic_istream_wchar, sizeof(basic_istream_wchar), &basic_ios_wchar_rtti_base_descriptor,
509         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
510         ".?AV?$basic_istream@_WU?$char_traits@_W@std@@@std@@");
511 DEFINE_RTTI_DATA3(basic_istream_short, sizeof(basic_istream_wchar), &basic_ios_short_rtti_base_descriptor,
512         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
513         ".?AV?$basic_istream@GU?$char_traits@G@std@@@std@@");
514 DEFINE_RTTI_DATA8(basic_iostream_char, sizeof(basic_iostream_char),
515         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
516         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
517         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
518         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
519         ".?AV?$basic_iostream@DU?$char_traits@D@std@@@std@@");
520 DEFINE_RTTI_DATA8(basic_iostream_wchar, sizeof(basic_iostream_wchar),
521         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
522         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
523         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
524         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
525         ".?AV?$basic_iostream@_WU?$char_traits@_W@std@@@std@@");
526 DEFINE_RTTI_DATA8(basic_iostream_short, sizeof(basic_iostream_wchar),
527         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
528         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
529         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
530         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
531         ".?AV?$basic_iostream@GU?$char_traits@G@std@@@std@@");
532 DEFINE_RTTI_DATA4(basic_ofstream_char, sizeof(basic_ofstream_char),
533         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
534         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
535         ".?AV?$basic_ofstream@DU?$char_traits@D@std@@@std@@");
536 DEFINE_RTTI_DATA4(basic_ofstream_wchar, sizeof(basic_ofstream_wchar),
537         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
538         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
539         ".?AV?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@");
540 DEFINE_RTTI_DATA4(basic_ofstream_short, sizeof(basic_ofstream_wchar),
541         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
542         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
543         ".?AV?$basic_ofstream@GU?$char_traits@G@std@@@std@@");
544 DEFINE_RTTI_DATA4(basic_ifstream_char, sizeof(basic_ifstream_char),
545         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
546         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
547         ".?AV?$basic_ifstream@DU?$char_traits@D@std@@@std@@");
548 DEFINE_RTTI_DATA4(basic_ifstream_wchar, sizeof(basic_ifstream_wchar),
549         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
550         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
551         ".?AV?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@");
552 DEFINE_RTTI_DATA4(basic_ifstream_short, sizeof(basic_ifstream_wchar),
553         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
554         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
555         ".?AV?$basic_ifstream@GU?$char_traits@G@std@@@std@@");
556 DEFINE_RTTI_DATA8(basic_fstream_char, sizeof(basic_fstream_char),
557         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
558         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
559         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
560         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
561         ".?AV?$basic_fstream@DU?$char_traits@D@std@@@std@@");
562 DEFINE_RTTI_DATA8(basic_fstream_wchar, sizeof(basic_fstream_wchar),
563         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
564         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
565         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
566         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
567         ".?AV?$basic_fstream@_WU?$char_traits@_W@std@@@std@@");
568 DEFINE_RTTI_DATA8(basic_fstream_short, sizeof(basic_fstream_wchar),
569         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
570         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
571         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
572         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
573         ".?AV?$basic_fstream@GU?$char_traits@G@std@@@std@@");
574 DEFINE_RTTI_DATA4(basic_ostringstream_char, sizeof(basic_ostringstream_char),
575         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
576         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
577         ".?AV?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
578 DEFINE_RTTI_DATA4(basic_ostringstream_wchar, sizeof(basic_ostringstream_wchar),
579         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
580         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
581         ".?AV?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
582 DEFINE_RTTI_DATA4(basic_ostringstream_short, sizeof(basic_ostringstream_wchar),
583         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
584         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
585         ".?AV?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
586 DEFINE_RTTI_DATA4(basic_istringstream_char, sizeof(basic_istringstream_char),
587         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
588         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
589         ".?AV?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
590 DEFINE_RTTI_DATA4(basic_istringstream_wchar, sizeof(basic_istringstream_wchar),
591         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
592         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
593         ".?AV?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
594 DEFINE_RTTI_DATA4(basic_istringstream_short, sizeof(basic_istringstream_wchar),
595         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
596         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
597         ".?AV?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
598 DEFINE_RTTI_DATA8(basic_stringstream_char, sizeof(basic_stringstream_char),
599         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
600         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
601         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
602         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
603         ".?AV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
604 DEFINE_RTTI_DATA8(basic_stringstream_wchar, sizeof(basic_stringstream_wchar),
605         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
606         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
607         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
608         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
609         ".?AV?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
610 DEFINE_RTTI_DATA8(basic_stringstream_short, sizeof(basic_stringstream_wchar),
611         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
612         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
613         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
614         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
615         ".?AV?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
616 DEFINE_RTTI_DATA1(strstreambuf, sizeof(strstreambuf),
617         &basic_streambuf_char_rtti_base_descriptor, ".?AVstrstreambuf@std@@");
618
619 #ifndef __GNUC__
620 void __asm_dummy_vtables(void) {
621 #endif
622     __ASM_VTABLE(iosb,
623             VTABLE_ADD_FUNC(iosb_vector_dtor));
624     __ASM_VTABLE(ios_base,
625             VTABLE_ADD_FUNC(ios_base_vector_dtor));
626     __ASM_VTABLE(basic_ios_char,
627             VTABLE_ADD_FUNC(basic_ios_char_vector_dtor));
628     __ASM_VTABLE(basic_ios_wchar,
629             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
630     __ASM_VTABLE(basic_ios_short,
631             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
632     __ASM_VTABLE(basic_streambuf_char,
633             VTABLE_ADD_FUNC(basic_streambuf_char_vector_dtor)
634             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
635             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
636             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
637             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
638             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
639             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
640             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
641             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
642             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
643             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
644             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
645             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
646             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
647     __ASM_VTABLE(basic_streambuf_wchar,
648             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
649             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
650             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
651             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
652             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
653             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
654             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
655             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
656             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
657             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
658             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
659             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
660             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
661             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
662     __ASM_VTABLE(basic_streambuf_short,
663             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
664             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
665             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
666             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
667             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
668             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
669             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
670             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
671             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
672             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
673             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
674             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
675             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
676             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
677     __ASM_VTABLE(basic_filebuf_char,
678             VTABLE_ADD_FUNC(basic_filebuf_char_vector_dtor)
679             VTABLE_ADD_FUNC(basic_filebuf_char_overflow)
680             VTABLE_ADD_FUNC(basic_filebuf_char_pbackfail)
681             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
682             VTABLE_ADD_FUNC(basic_filebuf_char_underflow)
683             VTABLE_ADD_FUNC(basic_filebuf_char_uflow)
684             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
685             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
686             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
687             VTABLE_ADD_FUNC(basic_filebuf_char_seekoff)
688             VTABLE_ADD_FUNC(basic_filebuf_char_seekpos)
689             VTABLE_ADD_FUNC(basic_filebuf_char_setbuf)
690             VTABLE_ADD_FUNC(basic_filebuf_char_sync)
691             VTABLE_ADD_FUNC(basic_filebuf_char_imbue));
692     __ASM_VTABLE(basic_filebuf_wchar,
693             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
694             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
695             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
696             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
697             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
698             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
699             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
700             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
701             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
702             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
703             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
704             VTABLE_ADD_FUNC(basic_filebuf_wchar_setbuf)
705             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
706             VTABLE_ADD_FUNC(basic_filebuf_wchar_imbue));
707     __ASM_VTABLE(basic_filebuf_short,
708             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
709             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
710             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
711             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
712             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
713             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
714             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
715             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
716             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
717             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
718             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
719             VTABLE_ADD_FUNC(basic_filebuf_short_setbuf)
720             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
721             VTABLE_ADD_FUNC(basic_filebuf_short_imbue));
722     __ASM_VTABLE(basic_stringbuf_char,
723             VTABLE_ADD_FUNC(basic_stringbuf_char_vector_dtor)
724             VTABLE_ADD_FUNC(basic_stringbuf_char_overflow)
725             VTABLE_ADD_FUNC(basic_stringbuf_char_pbackfail)
726             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
727             VTABLE_ADD_FUNC(basic_stringbuf_char_underflow)
728             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
729             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
730             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
731             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
732             VTABLE_ADD_FUNC(basic_stringbuf_char_seekoff)
733             VTABLE_ADD_FUNC(basic_stringbuf_char_seekpos)
734             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
735             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
736             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
737     __ASM_VTABLE(basic_stringbuf_wchar,
738             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
739             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
740             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
741             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
742             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
743             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
744             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
745             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
746             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
747             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
748             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
749             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
750             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
751             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
752     __ASM_VTABLE(basic_stringbuf_short,
753             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
754             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
755             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
756             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
757             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
758             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
759             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
760             VTABLE_ADD_FUNC(basic_streambuf_wchar__Xsgetn_s)
761             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
762             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
763             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
764             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
765             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
766             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
767     __ASM_VTABLE(basic_ostream_char,
768             VTABLE_ADD_FUNC(basic_ostream_char_vector_dtor));
769     __ASM_VTABLE(basic_ostream_wchar,
770             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
771     __ASM_VTABLE(basic_ostream_short,
772             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
773     __ASM_VTABLE(basic_istream_char,
774             VTABLE_ADD_FUNC(basic_istream_char_vector_dtor));
775     __ASM_VTABLE(basic_istream_wchar,
776             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
777     __ASM_VTABLE(basic_istream_short,
778             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
779     __ASM_VTABLE(basic_iostream_char,
780             VTABLE_ADD_FUNC(basic_iostream_char_vector_dtor));
781     __ASM_VTABLE(basic_iostream_wchar,
782             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
783     __ASM_VTABLE(basic_iostream_short,
784             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
785     __ASM_VTABLE(basic_ofstream_char,
786             VTABLE_ADD_FUNC(basic_ofstream_char_vector_dtor));
787     __ASM_VTABLE(basic_ofstream_wchar,
788             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
789     __ASM_VTABLE(basic_ofstream_short,
790             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
791     __ASM_VTABLE(basic_ifstream_char,
792             VTABLE_ADD_FUNC(basic_ifstream_char_vector_dtor));
793     __ASM_VTABLE(basic_ifstream_wchar,
794             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
795     __ASM_VTABLE(basic_ifstream_short,
796             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
797     __ASM_VTABLE(basic_fstream_char,
798             VTABLE_ADD_FUNC(basic_fstream_char_vector_dtor));
799     __ASM_VTABLE(basic_fstream_wchar,
800             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
801     __ASM_VTABLE(basic_fstream_short,
802             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
803     __ASM_VTABLE(basic_ostringstream_char,
804             VTABLE_ADD_FUNC(basic_ostringstream_char_vector_dtor));
805     __ASM_VTABLE(basic_ostringstream_wchar,
806             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
807     __ASM_VTABLE(basic_ostringstream_short,
808             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
809     __ASM_VTABLE(basic_istringstream_char,
810             VTABLE_ADD_FUNC(basic_istringstream_char_vector_dtor));
811     __ASM_VTABLE(basic_istringstream_wchar,
812             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
813     __ASM_VTABLE(basic_istringstream_short,
814             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
815     __ASM_VTABLE(basic_stringstream_char,
816             VTABLE_ADD_FUNC(basic_stringstream_char_vector_dtor));
817     __ASM_VTABLE(basic_stringstream_wchar,
818             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
819     __ASM_VTABLE(basic_stringstream_short,
820             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
821     __ASM_VTABLE(strstreambuf,
822             VTABLE_ADD_FUNC(strstreambuf_vector_dtor)
823             VTABLE_ADD_FUNC(strstreambuf_overflow)
824             VTABLE_ADD_FUNC(strstreambuf_pbackfail)
825             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
826             VTABLE_ADD_FUNC(strstreambuf_underflow)
827             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
828             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
829             VTABLE_ADD_FUNC(basic_streambuf_char__Xsgetn_s)
830             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
831             VTABLE_ADD_FUNC(strstreambuf_seekoff)
832             VTABLE_ADD_FUNC(strstreambuf_seekpos)
833             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
834             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
835             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
836 #ifndef __GNUC__
837 }
838 #endif
839
840 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
841 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
842 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
843 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
844 {
845     TRACE("(%p %p %p %p)\n", this, first, next, last);
846
847     this->wbuf = first;
848     this->wpos = next;
849     this->wsize = last-next;
850 }
851
852 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
853 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
854 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
855 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
856 {
857     basic_streambuf_char_setp_next(this, first, first, last);
858 }
859
860 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
861 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
862 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
863 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
864 {
865     TRACE("(%p %p %p %p)\n", this, first, next, last);
866
867     this->rbuf = first;
868     this->rpos = next;
869     this->rsize = last-next;
870 }
871
872 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
873 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
874 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
875 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
876 {
877     TRACE("(%p)\n", this);
878
879     this->prbuf = &this->rbuf;
880     this->pwbuf = &this->wbuf;
881     this->prpos = &this->rpos;
882     this->pwpos = &this->wpos;
883     this->prsize = &this->rsize;
884     this->pwsize = &this->wsize;
885
886     basic_streambuf_char_setp(this, NULL, NULL);
887     basic_streambuf_char_setg(this, NULL, NULL, NULL);
888 }
889
890 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
891 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
892 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
893 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
894 {
895     TRACE("(%p %d)\n", this, uninitialized);
896     this->vtable = &MSVCP_basic_streambuf_char_vtable;
897     mutex_ctor(&this->lock);
898     return this;
899 }
900
901 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
902 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
903 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
904 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
905 {
906     TRACE("(%p)\n", this);
907
908     this->vtable = &MSVCP_basic_streambuf_char_vtable;
909     mutex_ctor(&this->lock);
910     this->loc = MSVCRT_operator_new(sizeof(locale));
911     locale_ctor(this->loc);
912     basic_streambuf_char__Init_empty(this);
913
914     return this;
915 }
916
917 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
918 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
919 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
920 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
921 {
922     TRACE("(%p)\n", this);
923
924     mutex_dtor(&this->lock);
925     locale_dtor(this->loc);
926     MSVCRT_operator_delete(this->loc);
927 }
928
929 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_vector_dtor, 8)
930 basic_streambuf_char* __thiscall basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
931 {
932     TRACE("(%p %x)\n", this, flags);
933     if(flags & 2) {
934         /* we have an array, with the number of elements stored before the first object */
935         INT_PTR i, *ptr = (INT_PTR *)this-1;
936
937         for(i=*ptr-1; i>=0; i--)
938             basic_streambuf_char_dtor(this+i);
939         MSVCRT_operator_delete(ptr);
940     } else {
941         basic_streambuf_char_dtor(this);
942         if(flags & 1)
943             MSVCRT_operator_delete(this);
944     }
945
946     return this;
947 }
948
949 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
950 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
951 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnavail, 4)
952 streamsize __thiscall basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
953 {
954     TRACE("(%p)\n", this);
955     return *this->prpos ? *this->prsize : 0;
956 }
957
958 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
959 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
960 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
961 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
962 {
963     TRACE("(%p)\n", this);
964     (*this->prsize)++;
965     (*this->prpos)--;
966     return *this->prpos;
967 }
968
969 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
970 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
971 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
972 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
973 {
974     TRACE("(%p)\n", this);
975     (*this->prsize)--;
976     return (*this->prpos)++;
977 }
978
979 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
980 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
981 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnpreinc, 4)
982 char* __thiscall basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
983 {
984     TRACE("(%p)\n", this);
985     (*this->prsize)--;
986     (*this->prpos)++;
987     return *this->prpos;
988 }
989
990 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
991 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
992 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
993 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
994 {
995     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
996
997     this->prbuf = gf;
998     this->pwbuf = pf;
999     this->prpos = gn;
1000     this->pwpos = pn;
1001     this->prsize = gc;
1002     this->pwsize = pc;
1003 }
1004
1005 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1006 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1007 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Lock, 4)
1008 void __thiscall basic_streambuf_char__Lock(basic_streambuf_char *this)
1009 {
1010     TRACE("(%p)\n", this);
1011     mutex_lock(&this->lock);
1012 }
1013
1014 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
1015 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
1016 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pnavail, 4)
1017 streamsize __thiscall basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
1018 {
1019     TRACE("(%p)\n", this);
1020     return *this->pwpos ? *this->pwsize : 0;
1021 }
1022
1023 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1024 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1025 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
1026 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
1027 {
1028     TRACE("(%p)\n", this);
1029     (*this->pwsize)--;
1030     return (*this->pwpos)++;
1031 }
1032
1033 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1034 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1035 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
1036 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
1037         int, (basic_streambuf_char*), (this))
1038 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
1039 {
1040     TRACE("(%p)\n", this);
1041     return EOF;
1042 }
1043
1044 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1045 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1046 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
1047 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
1048         int, (basic_streambuf_char*), (this))
1049 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
1050 {
1051     int ret;
1052
1053     TRACE("(%p)\n", this);
1054
1055     if(call_basic_streambuf_char_underflow(this)==EOF)
1056         return EOF;
1057
1058     ret = (unsigned char)**this->prpos;
1059     (*this->prsize)--;
1060     (*this->prpos)++;
1061     return ret;
1062 }
1063
1064 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
1065 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
1066 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Xsgetn_s, 16)
1067 #define call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
1068         streamsize, (basic_streambuf_char*, char*, MSVCP_size_t, streamsize), (this, ptr, size, count))
1069 streamsize __thiscall basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1070 {
1071     streamsize copied, chunk;
1072     int c;
1073
1074     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1075
1076     for(copied=0; copied<count && size;) {
1077         chunk = basic_streambuf_char__Gnavail(this);
1078         if(chunk > count-copied)
1079             chunk = count-copied;
1080
1081         if(chunk > 0) {
1082             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1083             *this->prpos += chunk;
1084             *this->prsize -= chunk;
1085             copied += chunk;
1086             size -= chunk;
1087         }else if((c = call_basic_streambuf_char_uflow(this)) != EOF) {
1088             ptr[copied] = c;
1089             copied++;
1090             size--;
1091         }else {
1092             break;
1093         }
1094     }
1095
1096     return copied;
1097 }
1098
1099 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
1100 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
1101 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Sgetn_s, 16)
1102 streamsize __thiscall basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1103 {
1104     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1105     return call_basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
1106 }
1107
1108 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1109 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1110 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Unlock, 4)
1111 void __thiscall basic_streambuf_char__Unlock(basic_streambuf_char *this)
1112 {
1113     TRACE("(%p)\n", this);
1114     mutex_unlock(&this->lock);
1115 }
1116
1117 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1118 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1119 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
1120 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
1121 {
1122     TRACE("(%p)\n", this);
1123     return *this->prbuf;
1124 }
1125
1126 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1127 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1128 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
1129 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
1130 {
1131     TRACE("(%p)\n", this);
1132     return *this->prpos;
1133 }
1134
1135 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1136 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1137 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
1138 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
1139 {
1140     TRACE("(%p)\n", this);
1141     return *this->prpos+*this->prsize;
1142 }
1143
1144 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1145 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1146 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
1147 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
1148 {
1149     TRACE("(%p)\n", this);
1150     return *this->pwpos+*this->pwsize;
1151 }
1152
1153 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1154 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1155 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
1156 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
1157 {
1158     TRACE("(%p %d)\n", this, off);
1159     *this->prpos += off;
1160     *this->prsize -= off;
1161 }
1162
1163 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QBE?AVlocale@2@XZ */
1164 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ */
1165 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_getloc, 8)
1166 locale* __thiscall basic_streambuf_char_getloc(const basic_streambuf_char *this, locale *ret)
1167 {
1168     TRACE("(%p)\n", this);
1169     return locale_copy_ctor(ret, this->loc);
1170 }
1171
1172 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
1173 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
1174 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
1175 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
1176         void, (basic_streambuf_char*, const locale*), (this, loc))
1177 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
1178 {
1179     TRACE("(%p %p)\n", this, loc);
1180 }
1181
1182 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1183 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1184 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
1185 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1186         int, (basic_streambuf_char*, int), (this, ch))
1187 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
1188 {
1189     TRACE("(%p %d)\n", this, ch);
1190     return EOF;
1191 }
1192
1193 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1194 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1195 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
1196 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1197         int, (basic_streambuf_char*, int), (this, ch))
1198 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
1199 {
1200     TRACE("(%p %d)\n", this, ch);
1201     return EOF;
1202 }
1203
1204 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1205 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1206 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
1207 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
1208 {
1209     TRACE("(%p)\n", this);
1210     return *this->pwbuf;
1211 }
1212
1213 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1214 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1215 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
1216 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
1217 {
1218     TRACE("(%p %d)\n", this, off);
1219     *this->pwpos += off;
1220     *this->pwsize -= off;
1221 }
1222
1223 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1224 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1225 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
1226 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
1227 {
1228     TRACE("(%p)\n", this);
1229     return *this->pwpos;
1230 }
1231
1232 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1233 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1234 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
1235 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
1236 {
1237     TRACE("(%p %p)\n", this, loc);
1238     memcpy(ret, this->loc, sizeof(locale));
1239     call_basic_streambuf_char_imbue(this, loc);
1240     locale_copy_ctor(this->loc, loc);
1241     return ret;
1242 }
1243
1244 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1245 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1246 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
1247 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
1248         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1249 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
1250         fpos_int *ret, streamoff off, int way, int mode)
1251 {
1252     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1253     ret->off = 0;
1254     ret->pos = -1;
1255     ret->state = 0;
1256     return ret;
1257 }
1258
1259 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1260 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1261 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff, 20)
1262 fpos_int* __thiscall basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
1263         fpos_int *ret, streamoff off, int way, int mode)
1264 {
1265     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1266     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
1267 }
1268
1269 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1270 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1271 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff_old, 20)
1272 fpos_int* __thiscall basic_streambuf_char_pubseekoff_old(basic_streambuf_char *this,
1273         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
1274 {
1275     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1276     return basic_streambuf_char_pubseekoff(this, ret, off, way, mode);
1277 }
1278
1279 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1280 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1281 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
1282 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
1283         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1284 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
1285         fpos_int *ret, fpos_int pos, int mode)
1286 {
1287     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1288     ret->off = 0;
1289     ret->pos = -1;
1290     ret->state = 0;
1291     return ret;
1292 }
1293
1294 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1295 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1296 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
1297 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
1298         fpos_int *ret, fpos_int pos, int mode)
1299 {
1300     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1301     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
1302 }
1303
1304 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1305 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1306 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos_old, 36)
1307 fpos_int* __thiscall basic_streambuf_char_pubseekpos_old(basic_streambuf_char *this,
1308         fpos_int *ret, fpos_int pos, unsigned int mode)
1309 {
1310     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1311     return basic_streambuf_char_pubseekpos(this, ret, pos, mode);
1312 }
1313
1314 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
1315 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
1316 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
1317 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
1318         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
1319 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
1320 {
1321     TRACE("(%p %p %ld)\n", this, buf, count);
1322     return this;
1323 }
1324
1325 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
1326 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
1327 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
1328 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
1329 {
1330     TRACE("(%p %p %ld)\n", this, buf, count);
1331     return call_basic_streambuf_char_setbuf(this, buf, count);
1332 }
1333
1334 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1335 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1336 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
1337 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 48, \
1338         int, (basic_streambuf_char*), (this))
1339 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
1340 {
1341     TRACE("(%p)\n", this);
1342     return 0;
1343 }
1344
1345 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1346 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1347 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
1348 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
1349 {
1350     TRACE("(%p)\n", this);
1351     return call_basic_streambuf_char_sync(this);
1352 }
1353
1354 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
1355 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
1356 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
1357 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1358 {
1359     TRACE("(%p %p %ld)\n", this, ptr, count);
1360     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1361 }
1362
1363 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1364 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
1365 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
1366 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1367         streamsize, (basic_streambuf_char*), (this))
1368 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
1369 {
1370     TRACE("(%p)\n", this);
1371     return 0;
1372 }
1373
1374 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1375 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
1376 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
1377 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
1378 {
1379     streamsize ret;
1380
1381     TRACE("(%p)\n", this);
1382
1383     ret = basic_streambuf_char__Gnavail(this);
1384     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
1385 }
1386
1387 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1388 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1389 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
1390 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
1391 {
1392     TRACE("(%p %d)\n", this, ch);
1393     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1394         (*this->prsize)++;
1395         (*this->prpos)--;
1396         return (unsigned char)ch;
1397     }
1398
1399     return call_basic_streambuf_char_pbackfail(this, (unsigned char)ch);
1400 }
1401
1402 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1403 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1404 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
1405 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
1406 {
1407     TRACE("(%p %d)\n", this, ch);
1408     return basic_streambuf_char__Pnavail(this) ?
1409         (*basic_streambuf_char__Pninc(this) = ch) :
1410         call_basic_streambuf_char_overflow(this, (unsigned char)ch);
1411 }
1412
1413 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1414 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1415 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
1416 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
1417 {
1418     TRACE("(%p)\n", this);
1419     if(*this->prpos && *this->prpos>*this->prbuf) {
1420         (*this->prsize)++;
1421         (*this->prpos)--;
1422         return (unsigned char)**this->prpos;
1423     }
1424
1425     return call_basic_streambuf_char_pbackfail(this, EOF);
1426 }
1427
1428 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1429 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1430 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1431 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1432 {
1433     TRACE("(%p)\n", this);
1434     if(basic_streambuf_char__Gnavail(this))
1435         basic_streambuf_char__Gninc(this);
1436     else
1437         call_basic_streambuf_char_uflow(this);
1438 }
1439
1440 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1441 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1442 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1443 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1444 {
1445     TRACE("(%p)\n", this);
1446     return basic_streambuf_char__Gnavail(this) ?
1447         (int)(unsigned char)*basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1448 }
1449
1450 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1451 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1452 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1453 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1454 {
1455     TRACE("(%p)\n", this);
1456     return basic_streambuf_char__Gnavail(this) ?
1457         (int)(unsigned char)*basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1458 }
1459
1460 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1461 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1462 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1463 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1464 {
1465     TRACE("(%p)\n", this);
1466
1467     if(basic_streambuf_char__Gnavail(this) > 1)
1468         return (unsigned char)*basic_streambuf_char__Gnpreinc(this);
1469     return basic_streambuf_char_sbumpc(this)==EOF ?
1470         EOF : basic_streambuf_char_sgetc(this);
1471 }
1472
1473 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1474 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1475 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
1476 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1477         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1478 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1479 {
1480     TRACE("(%p %p %ld)\n", this, ptr, count);
1481     return call_basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1482 }
1483
1484 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1485 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1486 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
1487 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
1488         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1489 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1490 {
1491     streamsize copied, chunk;
1492
1493     TRACE("(%p %p %ld)\n", this, ptr, count);
1494
1495     for(copied=0; copied<count;) {
1496         chunk = basic_streambuf_char__Pnavail(this);
1497         if(chunk > count-copied)
1498             chunk = count-copied;
1499
1500         if(chunk > 0) {
1501             memcpy(*this->pwpos, ptr+copied, chunk);
1502             *this->pwpos += chunk;
1503             *this->pwsize -= chunk;
1504             copied += chunk;
1505         }else if(call_basic_streambuf_char_overflow(this, (unsigned char)ptr[copied]) != EOF) {
1506             copied++;
1507         }else {
1508             break;
1509         }
1510     }
1511
1512     return copied;
1513 }
1514
1515 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1516 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1517 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
1518 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1519 {
1520     TRACE("(%p %p %ld)\n", this, ptr, count);
1521     return call_basic_streambuf_char_xsputn(this, ptr, count);
1522 }
1523
1524 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1525 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1526 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1527 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1528 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1529 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1530 {
1531     TRACE("(%p %p %p %p)\n", this, first, next, last);
1532
1533     this->wbuf = first;
1534     this->wpos = next;
1535     this->wsize = last-next;
1536 }
1537
1538 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1539 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1540 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1541 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1542 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1543 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1544 {
1545     basic_streambuf_wchar_setp_next(this, first, first, last);
1546 }
1547
1548 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1549 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1550 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1551 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1552 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1553 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1554 {
1555     TRACE("(%p %p %p %p)\n", this, first, next, last);
1556
1557     this->rbuf = first;
1558     this->rpos = next;
1559     this->rsize = last-next;
1560 }
1561
1562 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1563 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1564 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1565 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1566 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1567 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1568 {
1569     TRACE("(%p)\n", this);
1570
1571     this->prbuf = &this->rbuf;
1572     this->pwbuf = &this->wbuf;
1573     this->prpos = &this->rpos;
1574     this->pwpos = &this->wpos;
1575     this->prsize = &this->rsize;
1576     this->pwsize = &this->wsize;
1577
1578     basic_streambuf_wchar_setp(this, NULL, NULL);
1579     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1580 }
1581
1582 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1583 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1584 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor_uninitialized, 8)
1585 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1586 {
1587     TRACE("(%p %d)\n", this, uninitialized);
1588     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1589     mutex_ctor(&this->lock);
1590     return this;
1591 }
1592
1593 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1594 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1595 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1596 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1597 {
1598     TRACE("(%p %d)\n", this, uninitialized);
1599     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1600     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1601     return this;
1602 }
1603
1604 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1605 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1606 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor, 4)
1607 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1608 {
1609     TRACE("(%p)\n", this);
1610
1611     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1612     mutex_ctor(&this->lock);
1613     this->loc = MSVCRT_operator_new(sizeof(locale));
1614     locale_ctor(this->loc);
1615     basic_streambuf_wchar__Init_empty(this);
1616
1617     return this;
1618 }
1619
1620 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1621 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1622 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1623 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1624 {
1625     TRACE("(%p)\n", this);
1626     basic_streambuf_wchar_ctor(this);
1627     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1628     return this;
1629 }
1630
1631 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1632 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1633 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1634 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1635 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1636 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1637 {
1638     TRACE("(%p)\n", this);
1639
1640     mutex_dtor(&this->lock);
1641     locale_dtor(this->loc);
1642     MSVCRT_operator_delete(this->loc);
1643 }
1644
1645 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_vector_dtor, 8)
1646 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1647 {
1648     TRACE("(%p %x)\n", this, flags);
1649     if(flags & 2) {
1650         /* we have an array, with the number of elements stored before the first object */
1651         INT_PTR i, *ptr = (INT_PTR *)this-1;
1652
1653         for(i=*ptr-1; i>=0; i--)
1654             basic_streambuf_wchar_dtor(this+i);
1655         MSVCRT_operator_delete(ptr);
1656     } else {
1657         basic_streambuf_wchar_dtor(this);
1658         if(flags & 1)
1659             MSVCRT_operator_delete(this);
1660     }
1661
1662     return this;
1663 }
1664
1665 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1666 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1667 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1668 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1669 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnavail, 4)
1670 streamsize __thiscall basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1671 {
1672     TRACE("(%p)\n", this);
1673     return *this->prpos ? *this->prsize : 0;
1674 }
1675
1676 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1677 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1678 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1679 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1680 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1681 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1682 {
1683     TRACE("(%p)\n", this);
1684     (*this->prsize)++;
1685     (*this->prpos)--;
1686     return *this->prpos;
1687 }
1688
1689 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1690 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1691 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1692 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1693 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1694 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1695 {
1696     TRACE("(%p)\n", this);
1697     (*this->prsize)--;
1698     return (*this->prpos)++;
1699 }
1700
1701 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1702 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1703 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1704 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1705 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnpreinc, 4)
1706 wchar_t* __thiscall basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1707 {
1708     TRACE("(%p)\n", this);
1709     (*this->prsize)--;
1710     (*this->prpos)++;
1711     return *this->prpos;
1712 }
1713
1714 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1715 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1716 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1717 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1718 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1719 void __thiscall basic_streambuf_wchar__Init(basic_streambuf_wchar *this, wchar_t **gf, wchar_t **gn, int *gc, wchar_t **pf, wchar_t **pn, int *pc)
1720 {
1721     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1722
1723     this->prbuf = gf;
1724     this->pwbuf = pf;
1725     this->prpos = gn;
1726     this->pwpos = pn;
1727     this->prsize = gc;
1728     this->pwsize = pc;
1729 }
1730
1731 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1732 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1733 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1734 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1735 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Lock, 4)
1736 void __thiscall basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1737 {
1738     TRACE("(%p)\n", this);
1739     mutex_lock(&this->lock);
1740 }
1741
1742 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1743 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1744 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1745 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1746 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pnavail, 4)
1747 streamsize __thiscall basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1748 {
1749     TRACE("(%p)\n", this);
1750     return *this->pwpos ? *this->pwsize : 0;
1751 }
1752
1753 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1754 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1755 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1756 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1757 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1758 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1759 {
1760     TRACE("(%p)\n", this);
1761     (*this->pwsize)--;
1762     return (*this->pwpos)++;
1763 }
1764
1765 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1766 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1767 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1768 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1769 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1770 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1771         unsigned short, (basic_streambuf_wchar*), (this))
1772 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1773 {
1774     TRACE("(%p)\n", this);
1775     return WEOF;
1776 }
1777
1778 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1779 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1780 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1781 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1782 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1783 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1784         unsigned short, (basic_streambuf_wchar*), (this))
1785 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1786 {
1787     int ret;
1788
1789     TRACE("(%p)\n", this);
1790
1791     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1792         return WEOF;
1793
1794     ret = **this->prpos;
1795     (*this->prsize)--;
1796     (*this->prpos)++;
1797     return ret;
1798 }
1799
1800 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1801 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1802 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1803 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1804 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Xsgetn_s, 16)
1805 #define call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count) CALL_VTBL_FUNC(this, 28, \
1806         streamsize, (basic_streambuf_wchar*, wchar_t*, MSVCP_size_t, streamsize), (this, ptr, size, count))
1807 streamsize __thiscall basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1808 {
1809     streamsize copied, chunk;
1810     unsigned short c;
1811
1812     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1813
1814     for(copied=0; copied<count && size;) {
1815         chunk = basic_streambuf_wchar__Gnavail(this);
1816         if(chunk > count-copied)
1817             chunk = count-copied;
1818
1819         if(chunk > 0) {
1820             memcpy_s(ptr+copied, size, *this->prpos, chunk*sizeof(wchar_t));
1821             *this->prpos += chunk;
1822             *this->prsize -= chunk;
1823             copied += chunk;
1824             size -= chunk*sizeof(wchar_t);
1825         }else if((c = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1826             ptr[copied] = c;
1827             copied++;
1828             size--;
1829         }else {
1830             break;
1831         }
1832     }
1833
1834     return copied;
1835 }
1836
1837 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1838 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1839 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1840 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1841 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Sgetn_s, 16)
1842 streamsize __thiscall basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1843 {
1844     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1845     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1846 }
1847
1848 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1849 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1850 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1851 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1852 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Unlock, 4)
1853 void __thiscall basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1854 {
1855     TRACE("(%p)\n", this);
1856     mutex_unlock(&this->lock);
1857 }
1858
1859 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1860 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1861 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1862 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1863 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1864 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1865 {
1866     TRACE("(%p)\n", this);
1867     return *this->prbuf;
1868 }
1869
1870 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1871 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1872 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1873 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1874 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1875 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1876 {
1877     TRACE("(%p)\n", this);
1878     return *this->prpos;
1879 }
1880
1881 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1882 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1883 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1884 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1885 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1886 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1887 {
1888     TRACE("(%p)\n", this);
1889     return *this->prpos+*this->prsize;
1890 }
1891
1892 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1893 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1894 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1895 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1896 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1897 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1898 {
1899     TRACE("(%p)\n", this);
1900     return *this->pwpos+*this->pwsize;
1901 }
1902
1903 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1904 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1905 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1906 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1907 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1908 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1909 {
1910     TRACE("(%p %d)\n", this, off);
1911     *this->prpos += off;
1912     *this->prsize -= off;
1913 }
1914
1915 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QBE?AVlocale@2@XZ */
1916 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEBA?AVlocale@2@XZ */
1917 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QBE?AVlocale@2@XZ */
1918 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEBA?AVlocale@2@XZ */
1919 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
1920 locale* __thiscall basic_streambuf_wchar_getloc(const basic_streambuf_wchar *this, locale *ret)
1921 {
1922     TRACE("(%p)\n", this);
1923     return locale_copy_ctor(ret, this->loc);
1924 }
1925
1926 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1927 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1928 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1929 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1930 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1931 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 52, \
1932         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1933 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1934 {
1935     TRACE("(%p %p)\n", this, loc);
1936 }
1937
1938 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1939 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1940 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1941 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1942 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1943 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1944         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1945 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1946 {
1947     TRACE("(%p %d)\n", this, ch);
1948     return WEOF;
1949 }
1950
1951 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1952 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1953 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1954 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1955 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1956 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1957         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1958 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1959 {
1960     TRACE("(%p %d)\n", this, ch);
1961     return WEOF;
1962 }
1963
1964 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1965 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1966 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1967 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1968 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1969 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1970 {
1971     TRACE("(%p)\n", this);
1972     return *this->pwbuf;
1973 }
1974
1975 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1976 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1977 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1978 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1979 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1980 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1981 {
1982     TRACE("(%p %d)\n", this, off);
1983     *this->pwpos += off;
1984     *this->pwsize -= off;
1985 }
1986
1987 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1988 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1989 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1990 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1991 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1992 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1993 {
1994     TRACE("(%p)\n", this);
1995     return *this->pwpos;
1996 }
1997
1998 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1999 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2000 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2001 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2002 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
2003 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
2004 {
2005     TRACE("(%p %p)\n", this, loc);
2006     memcpy(ret, this->loc, sizeof(locale));
2007     call_basic_streambuf_wchar_imbue(this, loc);
2008     locale_copy_ctor(this->loc, loc);
2009     return ret;
2010 }
2011
2012 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2013 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2014 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2015 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2016 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
2017 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 36, \
2018         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
2019 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
2020         fpos_int *ret, streamoff off, int way, int mode)
2021 {
2022     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2023     ret->off = 0;
2024     ret->pos = -1;
2025     ret->state = 0;
2026     return ret;
2027 }
2028
2029 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2030 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2031 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2032 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2033 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff, 20)
2034 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
2035         fpos_int *ret, streamoff off, int way, int mode)
2036 {
2037     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2038     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
2039 }
2040
2041 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
2042 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
2043 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
2044 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
2045 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff_old, 20)
2046 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff_old(basic_streambuf_wchar *this,
2047         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
2048 {
2049     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2050     return basic_streambuf_wchar_pubseekoff(this, ret, off, way, mode);
2051 }
2052
2053 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2054 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2055 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2056 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2057 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
2058 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 40, \
2059         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
2060 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
2061         fpos_int *ret, fpos_int pos, int mode)
2062 {
2063     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2064     ret->off = 0;
2065     ret->pos = -1;
2066     ret->state = 0;
2067     return ret;
2068 }
2069
2070 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2071 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2072 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2073 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2074 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
2075 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
2076         fpos_int *ret, fpos_int pos, int mode)
2077 {
2078     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2079     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
2080 }
2081
2082 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
2083 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
2084 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
2085 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
2086 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos_old, 36)
2087 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos_old(basic_streambuf_wchar *this,
2088         fpos_int *ret, fpos_int pos, unsigned int mode)
2089 {
2090     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2091     return basic_streambuf_wchar_pubseekpos(this, ret, pos, mode);
2092 }
2093
2094 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
2095 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
2096 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
2097 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
2098 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
2099 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 44, \
2100         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
2101 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2102 {
2103     TRACE("(%p %p %ld)\n", this, buf, count);
2104     return this;
2105 }
2106
2107 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
2108 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
2109 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
2110 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
2111 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
2112 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2113 {
2114     TRACE("(%p %p %ld)\n", this, buf, count);
2115     return call_basic_streambuf_wchar_setbuf(this, buf, count);
2116 }
2117
2118 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2119 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2120 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2121 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2122 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
2123 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 48, \
2124         int, (basic_streambuf_wchar*), (this))
2125 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
2126 {
2127     TRACE("(%p)\n", this);
2128     return 0;
2129 }
2130
2131 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2132 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
2133 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2134 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
2135 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
2136 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
2137 {
2138     TRACE("(%p)\n", this);
2139     return call_basic_streambuf_wchar_sync(this);
2140 }
2141
2142 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
2143 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
2144 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
2145 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
2146 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
2147 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2148 {
2149     TRACE("(%p %p %ld)\n", this, ptr, count);
2150     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2151 }
2152
2153 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2154 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
2155 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2156 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
2157 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
2158 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
2159         streamsize, (basic_streambuf_wchar*), (this))
2160 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
2161 {
2162     TRACE("(%p)\n", this);
2163     return 0;
2164 }
2165
2166 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2167 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
2168 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2169 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
2170 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
2171 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
2172 {
2173     streamsize ret;
2174
2175     TRACE("(%p)\n", this);
2176
2177     ret = basic_streambuf_wchar__Gnavail(this);
2178     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
2179 }
2180
2181 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2182 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2183 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2184 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2185 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
2186 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
2187 {
2188     TRACE("(%p %d)\n", this, ch);
2189     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
2190         (*this->prsize)++;
2191         (*this->prpos)--;
2192         return ch;
2193     }
2194
2195     return call_basic_streambuf_wchar_pbackfail(this, ch);
2196 }
2197
2198 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2199 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2200 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2201 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
2202 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
2203 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
2204 {
2205     TRACE("(%p %d)\n", this, ch);
2206     return basic_streambuf_wchar__Pnavail(this) ?
2207         (*basic_streambuf_wchar__Pninc(this) = ch) :
2208         call_basic_streambuf_wchar_overflow(this, ch);
2209 }
2210
2211 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2212 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2213 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2214 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2215 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
2216 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
2217 {
2218     TRACE("(%p)\n", this);
2219     if(*this->prpos && *this->prpos>*this->prbuf) {
2220         (*this->prsize)++;
2221         (*this->prpos)--;
2222         return **this->prpos;
2223     }
2224
2225     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
2226 }
2227
2228 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2229 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2230 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2231 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2232 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
2233 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
2234 {
2235     TRACE("(%p)\n", this);
2236     if(basic_streambuf_wchar__Gnavail(this))
2237         basic_streambuf_wchar__Gninc(this);
2238     else
2239         call_basic_streambuf_wchar_uflow(this);
2240 }
2241
2242 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2243 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2244 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2245 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2246 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
2247 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
2248 {
2249     TRACE("(%p)\n", this);
2250     return basic_streambuf_wchar__Gnavail(this) ?
2251         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
2252 }
2253
2254 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2255 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2256 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2257 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2258 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
2259 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
2260 {
2261     TRACE("(%p)\n", this);
2262     return basic_streambuf_wchar__Gnavail(this) ?
2263         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
2264 }
2265
2266 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2267 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2268 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2269 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2270 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
2271 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
2272 {
2273     TRACE("(%p)\n", this);
2274
2275     if(basic_streambuf_wchar__Gnavail(this) > 1)
2276         return *basic_streambuf_wchar__Gnpreinc(this);
2277     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
2278         WEOF : basic_streambuf_wchar_sgetc(this);
2279 }
2280
2281 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
2282 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
2283 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
2284 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
2285 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
2286 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
2287         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
2288 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2289 {
2290     TRACE("(%p %p %ld)\n", this, ptr, count);
2291     return call_basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2292 }
2293
2294 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
2295 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
2296 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
2297 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
2298 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
2299 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
2300         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
2301 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2302 {
2303     streamsize copied, chunk;
2304
2305     TRACE("(%p %p %ld)\n", this, ptr, count);
2306
2307     for(copied=0; copied<count;) {
2308         chunk = basic_streambuf_wchar__Pnavail(this);
2309         if(chunk > count-copied)
2310             chunk = count-copied;
2311
2312         if(chunk > 0) {
2313             memcpy(*this->pwpos, ptr+copied, chunk*sizeof(wchar_t));
2314             *this->pwpos += chunk;
2315             *this->pwsize -= chunk;
2316             copied += chunk;
2317         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
2318             copied++;
2319         }else {
2320             break;
2321         }
2322     }
2323
2324     return copied;
2325 }
2326
2327 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
2328 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
2329 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
2330 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
2331 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
2332 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2333 {
2334     TRACE("(%p %p %ld)\n", this, ptr, count);
2335     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
2336 }
2337
2338 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2339 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2340 int basic_filebuf_char__Init__Stinit = 0;
2341
2342 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2343 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2344 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
2345 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
2346 {
2347     TRACE("(%p %p %d)\n", this, file, which);
2348
2349     this->cvt = NULL;
2350     this->wrotesome = FALSE;
2351     this->state = basic_filebuf_char__Init__Stinit;
2352     this->close = (which == INITFL_open);
2353     this->file = file;
2354
2355     basic_streambuf_char__Init_empty(&this->base);
2356     if(file)
2357         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
2358                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
2359 }
2360
2361 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAV?$codecvt@DDH@2@@Z */
2362 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$codecvt@DDH@2@@Z */
2363 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Initcvt, 8)
2364 void __thiscall basic_filebuf_char__Initcvt(basic_filebuf_char *this, codecvt_char *cvt)
2365 {
2366     TRACE("(%p %p)\n", this, cvt);
2367
2368     if(codecvt_base_always_noconv(&cvt->base)) {
2369         this->cvt = NULL;
2370     }else {
2371         basic_streambuf_char__Init_empty(&this->base);
2372         this->cvt = cvt;
2373     }
2374 }
2375
2376 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAE_NXZ */
2377 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAA_NXZ */
2378 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Endwrite, 4)
2379 MSVCP_bool __thiscall basic_filebuf_char__Endwrite(basic_filebuf_char *this)
2380 {
2381     TRACE("(%p)\n", this);
2382
2383     if(!this->wrotesome || !this->cvt)
2384         return TRUE;
2385
2386
2387     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2388         return FALSE;
2389
2390     while(1) {
2391         /* TODO: check if we need a dynamic buffer here */
2392         char buf[128];
2393         char *next;
2394         int ret;
2395
2396         ret = codecvt_char_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2397         switch(ret) {
2398         case CODECVT_ok:
2399             this->wrotesome = FALSE;
2400             /* fall through */
2401         case CODECVT_partial:
2402             if(!fwrite(buf, next-buf, 1, this->file))
2403                 return FALSE;
2404             if(this->wrotesome)
2405                 break;
2406             /* fall through */
2407         case CODECVT_noconv:
2408             if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2409                 return FALSE;
2410             return TRUE;
2411         default:
2412             return FALSE;
2413         }
2414     }
2415 }
2416
2417 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2418 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2419 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2420 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2421 {
2422     basic_filebuf_char *ret = this;
2423
2424     TRACE("(%p)\n", this);
2425
2426     if(!this->file)
2427         return NULL;
2428
2429     /* TODO: handle exceptions */
2430     if(!basic_filebuf_char__Endwrite(this))
2431         ret = NULL;
2432     if(fclose(this->file))
2433         ret  = NULL;
2434
2435     basic_filebuf_char__Init(this, NULL, INITFL_close);
2436     return ret;
2437 }
2438
2439 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2440 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2441 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2442 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2443 {
2444     TRACE("(%p %p)\n", this, file);
2445
2446     basic_streambuf_char_ctor(&this->base);
2447     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2448
2449     basic_filebuf_char__Init(this, file, INITFL_new);
2450     return this;
2451 }
2452
2453 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2454 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2455 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2456 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2457 {
2458     return basic_filebuf_char_ctor_file(this, NULL);
2459 }
2460
2461 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2462 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2463 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2464 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2465 {
2466     TRACE("(%p %d)\n", this, uninitialized);
2467
2468     basic_streambuf_char_ctor(&this->base);
2469     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2470     return this;
2471 }
2472
2473 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2474 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2475 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2476 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2477 {
2478     TRACE("(%p)\n", this);
2479
2480     if(this->close)
2481         basic_filebuf_char_close(this);
2482     basic_streambuf_char_dtor(&this->base);
2483 }
2484
2485 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2486 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2487 {
2488     TRACE("(%p %x)\n", this, flags);
2489     if(flags & 2) {
2490         /* we have an array, with the number of elements stored before the first object */
2491         INT_PTR i, *ptr = (INT_PTR *)this-1;
2492
2493         for(i=*ptr-1; i>=0; i--)
2494             basic_filebuf_char_dtor(this+i);
2495         MSVCRT_operator_delete(ptr);
2496     } else {
2497         basic_filebuf_char_dtor(this);
2498         if(flags & 1)
2499             MSVCRT_operator_delete(this);
2500     }
2501
2502     return this;
2503 }
2504
2505 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2506 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2507 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2508 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2509 {
2510     TRACE("(%p)\n", this);
2511     return this->file != NULL;
2512 }
2513
2514 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2515 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2516 FILE* __cdecl _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2517 {
2518     static const wchar_t rW[] = {'r',0};
2519     static const struct {
2520         int mode;
2521         const wchar_t str[4];
2522         const wchar_t str_bin[4];
2523     } str_mode[] = {
2524         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2525         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2526         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2527         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2528         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2529         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2530         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2531         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2532         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2533     };
2534
2535     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2536     int mode_idx;
2537     FILE *f = NULL;
2538
2539     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2540
2541     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2542         if(str_mode[mode_idx].mode == real_mode)
2543             break;
2544     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2545         return NULL;
2546
2547     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2548         return NULL;
2549     else if(f)
2550         fclose(f);
2551
2552     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2553             && (f = _wfopen(name, rW))) {
2554         fclose(f);
2555         return NULL;
2556     }
2557
2558     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2559             : str_mode[mode_idx].str, prot);
2560     if(!f)
2561         return NULL;
2562
2563     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2564         fclose(f);
2565         return NULL;
2566     }
2567
2568     return f;
2569 }
2570
2571 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2572 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2573 FILE* __cdecl _Fiopen(const char *name, int mode, int prot)
2574 {
2575     wchar_t nameW[FILENAME_MAX];
2576
2577     TRACE("(%s %d %d)\n", name, mode, prot);
2578
2579     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2580         return NULL;
2581     return _Fiopen_wchar(nameW, mode, prot);
2582 }
2583
2584 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2585 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2586 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2587 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2588 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_wchar, 16)
2589 basic_filebuf_char* __thiscall basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2590 {
2591     FILE *f = NULL;
2592
2593     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2594
2595     if(basic_filebuf_char_is_open(this))
2596         return NULL;
2597
2598     if(!(f = _Fiopen_wchar(name, mode, prot)))
2599         return NULL;
2600
2601     basic_filebuf_char__Init(this, f, INITFL_open);
2602     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(this->base.loc));
2603     return this;
2604 }
2605
2606 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WI@Z */
2607 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WI@Z */
2608 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGI@Z */
2609 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGI@Z */
2610 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_wchar_mode, 12)
2611 basic_filebuf_char* __thiscall basic_filebuf_char_open_wchar_mode(basic_filebuf_char *this, const wchar_t *name, unsigned int mode)
2612 {
2613     return basic_filebuf_char_open_wchar(this, name, mode, SH_DENYNO);
2614 }
2615
2616 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2617 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2618 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open, 16)
2619 basic_filebuf_char* __thiscall basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2620 {
2621     wchar_t nameW[FILENAME_MAX];
2622
2623     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2624
2625     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2626         return NULL;
2627     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2628 }
2629
2630 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDI@Z */
2631 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDI@Z */
2632 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2633 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, unsigned int mode)
2634 {
2635     return basic_filebuf_char_open(this, name, mode, SH_DENYNO);
2636 }
2637
2638 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2639 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2640 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2641 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2642 {
2643     char buf[8], *dyn_buf;
2644     char ch = c, *to_next;
2645     const char *from_next;
2646     int ret, max_size;
2647
2648
2649     TRACE("(%p %d)\n", this, c);
2650
2651     if(!basic_filebuf_char_is_open(this))
2652         return EOF;
2653     if(c == EOF)
2654         return !c;
2655
2656     if(!this->cvt)
2657         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2658
2659     from_next = &ch;
2660     do {
2661         ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2662                 &from_next, buf, buf+sizeof(buf), &to_next);
2663
2664         switch(ret) {
2665         case CODECVT_partial:
2666             if(to_next == buf)
2667                 break;
2668             /* fall through */
2669         case CODECVT_ok:
2670             if(!fwrite(buf, to_next-buf, 1, this->file))
2671                 return EOF;
2672             if(ret == CODECVT_partial)
2673                 continue;
2674             return c;
2675         case CODECVT_noconv:
2676             return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2677         default:
2678             return EOF;
2679         }
2680
2681         break;
2682     } while(1);
2683
2684     max_size = codecvt_base_max_length(&this->cvt->base);
2685     dyn_buf = malloc(max_size);
2686     if(!dyn_buf)
2687         return EOF;
2688
2689     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2690             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2691
2692     switch(ret) {
2693     case CODECVT_ok:
2694         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2695         free(dyn_buf);
2696         return ret ? c : EOF;
2697     case CODECVT_partial:
2698         ERR("buffer should be big enough to store all output\n");
2699         /* fall through */
2700     default:
2701         free(dyn_buf);
2702         return EOF;
2703     }
2704 }
2705
2706 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2707 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2708 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2709 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2710 {
2711     TRACE("(%p %d)\n", this, c);
2712
2713     if(!basic_filebuf_char_is_open(this))
2714         return EOF;
2715
2716     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2717             && (c==EOF || (int)(unsigned char)basic_streambuf_char_gptr(&this->base)[-1]==c)) {
2718         basic_streambuf_char__Gndec(&this->base);
2719         return c==EOF ? !c : c;
2720     }else if(c!=EOF && !this->cvt) {
2721         return ungetc(c, this->file);
2722     }
2723
2724     return EOF;
2725 }
2726
2727 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2728 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2729 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2730 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2731 {
2732     char ch, buf[128], *to_next;
2733     const char *buf_next;
2734     int c, i;
2735
2736     TRACE("(%p)\n", this);
2737
2738     if(!basic_filebuf_char_is_open(this))
2739         return EOF;
2740
2741     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2742         return (unsigned char)*basic_streambuf_char__Gninc(&this->base);
2743
2744     c = fgetc(this->file);
2745     if(!this->cvt || c==EOF)
2746         return c;
2747
2748     buf_next = buf;
2749     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
2750         buf[i] = c;
2751
2752         switch(codecvt_char_in(this->cvt, &this->state, buf_next,
2753                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2754         case CODECVT_partial:
2755         case CODECVT_ok:
2756             if(to_next == &ch) {
2757                 c = fgetc(this->file);
2758                 if(c == EOF)
2759                     return EOF;
2760                 continue;
2761             }
2762
2763             for(i--; i>=buf_next-buf; i--)
2764                 ungetc(buf[i], this->file);
2765             return ch;
2766         case CODECVT_noconv:
2767             return (unsigned char)buf[0];
2768         default:
2769             return EOF;
2770         }
2771     }
2772
2773     FIXME("buffer is too small\n");
2774     return EOF;
2775 }
2776
2777 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2778 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2779 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2780 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2781 {
2782     int ret;
2783
2784     TRACE("(%p)\n", this);
2785
2786     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2787         return (unsigned char)*basic_streambuf_char_gptr(&this->base);
2788
2789     ret = call_basic_streambuf_char_uflow(&this->base);
2790     if(ret != EOF)
2791         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2792     return ret;
2793 }
2794
2795 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2796 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2797 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2798 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2799         fpos_int *ret, streamoff off, int way, int mode)
2800 {
2801     fpos_t pos;
2802
2803     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2804
2805     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2806             || fseek(this->file, off, way)) {
2807         ret->off = 0;
2808         ret->pos = -1;
2809         ret->state = 0;
2810         return ret;
2811     }
2812
2813     fgetpos(this->file, &pos);
2814     ret->off = 0;
2815     ret->pos = pos;
2816     ret->state = this->state;
2817     return ret;
2818 }
2819
2820 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2821 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2822 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2823 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2824         fpos_int *ret, fpos_int pos, int mode)
2825 {
2826     fpos_t fpos;
2827
2828     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2829
2830     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2831             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2832             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2833         ret->off = 0;
2834         ret->pos = -1;
2835         ret->state = 0;
2836         return ret;
2837     }
2838
2839     fgetpos(this->file, &fpos);
2840     ret->off = 0;
2841     ret->pos = fpos;
2842     ret->state = this->state;
2843     return ret;
2844 }
2845
2846 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2847 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2848 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2849 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2850 {
2851     TRACE("(%p %p %ld)\n", this, buf, count);
2852
2853     if(!basic_filebuf_char_is_open(this))
2854         return NULL;
2855
2856     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2857         return NULL;
2858
2859     basic_filebuf_char__Init(this, this->file, INITFL_open);
2860     return &this->base;
2861 }
2862
2863 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2864 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2865 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2866 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2867 {
2868     TRACE("(%p)\n", this);
2869
2870     if(!basic_filebuf_char_is_open(this))
2871         return 0;
2872
2873     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2874         return 0;
2875     return fflush(this->file);
2876 }
2877
2878 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
2879 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
2880 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_imbue, 8)
2881 void __thiscall basic_filebuf_char_imbue(basic_filebuf_char *this, const locale *loc)
2882 {
2883     TRACE("(%p %p)\n", this, loc);
2884     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(loc));
2885 }
2886
2887 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2888 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2889 int basic_filebuf_wchar__Init__Stinit = 0;
2890
2891 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2892 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2893 int basic_filebuf_short__Init__Stinit = 0;
2894
2895 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2896 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2897 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Init, 12)
2898 void __thiscall basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2899 {
2900     TRACE("(%p %p %d)\n", this, file, which);
2901
2902     this->cvt = NULL;
2903     this->wrotesome = FALSE;
2904     this->state = basic_filebuf_wchar__Init__Stinit;
2905     this->close = (which == INITFL_open);
2906     this->file = file;
2907
2908     basic_streambuf_wchar__Init_empty(&this->base);
2909 }
2910
2911 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2912 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2913 DEFINE_THISCALL_WRAPPER(basic_filebuf_short__Init, 12)
2914 void __thiscall basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2915 {
2916     TRACE("(%p %p %d)\n", this, file, which);
2917
2918     this->cvt = NULL;
2919     this->wrotesome = FALSE;
2920     this->state = basic_filebuf_short__Init__Stinit;
2921     this->close = (which == INITFL_open);
2922     this->file = file;
2923
2924     basic_streambuf_wchar__Init_empty(&this->base);
2925 }
2926
2927 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$codecvt@_WDH@2@@Z */
2928 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$codecvt@_WDH@2@@Z */
2929 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAV?$codecvt@GDH@2@@Z */
2930 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$codecvt@GDH@2@@Z */
2931 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Initcvt, 8)
2932 void __thiscall basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this, codecvt_wchar *cvt)
2933 {
2934     TRACE("(%p %p)\n", this, cvt);
2935
2936     if(codecvt_base_always_noconv(&cvt->base)) {
2937         this->cvt = NULL;
2938     }else {
2939         basic_streambuf_wchar__Init_empty(&this->base);
2940         this->cvt = cvt;
2941     }
2942 }
2943
2944 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAE_NXZ */
2945 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAA_NXZ */
2946 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAE_NXZ */
2947 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAA_NXZ */
2948 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Endwrite, 4)
2949 MSVCP_bool __thiscall basic_filebuf_wchar__Endwrite(basic_filebuf_wchar *this)
2950 {
2951     TRACE("(%p)\n", this);
2952
2953     if(!this->wrotesome || !this->cvt)
2954         return TRUE;
2955
2956     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2957         return FALSE;
2958
2959     while(1) {
2960         /* TODO: check if we need a dynamic buffer here */
2961         char buf[128];
2962         char *next;
2963         int ret;
2964
2965         ret = codecvt_wchar_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2966         switch(ret) {
2967         case CODECVT_ok:
2968             this->wrotesome = FALSE;
2969             /* fall through */
2970         case CODECVT_partial:
2971             if(!fwrite(buf, next-buf, 1, this->file))
2972                 return FALSE;
2973             if(this->wrotesome)
2974                 break;
2975             /* fall through */
2976         case CODECVT_noconv:
2977             if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2978                 return FALSE;
2979             return TRUE;
2980         default:
2981             return FALSE;
2982         }
2983     }
2984 }
2985
2986 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
2987 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
2988 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
2989 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
2990 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_close, 4)
2991 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_close(basic_filebuf_wchar *this)
2992 {
2993     basic_filebuf_wchar *ret = this;
2994
2995     TRACE("(%p)\n", this);
2996
2997     if(!this->file)
2998         return NULL;
2999
3000     /* TODO: handle exceptions */
3001     if(!basic_filebuf_wchar__Endwrite(this))
3002         ret = NULL;
3003     if(fclose(this->file))
3004         ret  = NULL;
3005
3006     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
3007     return ret;
3008 }
3009
3010 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
3011 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
3012 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor_file, 8)
3013 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
3014 {
3015     TRACE("(%p %p)\n", this, file);
3016
3017     basic_streambuf_wchar_ctor(&this->base);
3018     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
3019
3020     basic_filebuf_wchar__Init(this, file, INITFL_new);
3021     return this;
3022 }
3023
3024 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
3025 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
3026 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_file, 8)
3027 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
3028 {
3029     TRACE("(%p %p)\n", this, file);
3030
3031     basic_streambuf_short_ctor(&this->base);
3032     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3033
3034     basic_filebuf_short__Init(this, file, INITFL_new);
3035     return this;
3036 }
3037
3038 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
3039 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
3040 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor, 4)
3041 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor(basic_filebuf_wchar *this)
3042 {
3043     return basic_filebuf_wchar_ctor_file(this, NULL);
3044 }
3045
3046 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
3047 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
3048 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor, 4)
3049 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor(basic_filebuf_wchar *this)
3050 {
3051     return basic_filebuf_short_ctor_file(this, NULL);
3052 }
3053
3054 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3055 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3056 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor_uninitialized, 8)
3057 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
3058 {
3059     TRACE("(%p %d)\n", this, uninitialized);
3060
3061     basic_streambuf_wchar_ctor(&this->base);
3062     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
3063     return this;
3064 }
3065
3066 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3067 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3068 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_uninitialized, 8)
3069 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
3070 {
3071     TRACE("(%p %d)\n", this, uninitialized);
3072
3073     basic_streambuf_short_ctor(&this->base);
3074     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3075     return this;
3076 }
3077
3078 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
3079 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
3080 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
3081 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
3082 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_dtor, 4)
3083 void __thiscall basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
3084 {
3085     TRACE("(%p)\n", this);
3086
3087     if(this->close)
3088         basic_filebuf_wchar_close(this);
3089     basic_streambuf_wchar_dtor(&this->base);
3090 }
3091
3092 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
3093 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
3094 {
3095     TRACE("(%p %x)\n", this, flags);
3096     if(flags & 2) {
3097         /* we have an array, with the number of elements stored before the first object */
3098         INT_PTR i, *ptr = (INT_PTR *)this-1;
3099
3100         for(i=*ptr-1; i>=0; i--)
3101             basic_filebuf_wchar_dtor(this+i);
3102         MSVCRT_operator_delete(ptr);
3103     } else {
3104         basic_filebuf_wchar_dtor(this);
3105         if(flags & 1)
3106             MSVCRT_operator_delete(this);
3107     }
3108
3109     return this;
3110 }
3111
3112 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
3113 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
3114 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
3115 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
3116 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_is_open, 4)
3117 MSVCP_bool __thiscall basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
3118 {
3119     TRACE("(%p)\n", this);
3120     return this->file != NULL;
3121 }
3122
3123 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WHH@Z */
3124 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3125 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGHH@Z */
3126 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3127 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_wchar, 16)
3128 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3129 {
3130     FILE *f = NULL;
3131
3132     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3133
3134     if(basic_filebuf_wchar_is_open(this))
3135         return NULL;
3136
3137     if(!(f = _Fiopen_wchar(name, mode, prot)))
3138         return NULL;
3139
3140     basic_filebuf_wchar__Init(this, f, INITFL_open);
3141     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(this->base.loc));
3142     return this;
3143 }
3144
3145 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PB_WHH@Z */
3146 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3147 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBGHH@Z */
3148 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3149 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_wchar, 16)
3150 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3151 {
3152     FILE *f = NULL;
3153
3154     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3155
3156     if(basic_filebuf_wchar_is_open(this))
3157         return NULL;
3158
3159     if(!(f = _Fiopen_wchar(name, mode, prot)))
3160         return NULL;
3161
3162     basic_filebuf_short__Init(this, f, INITFL_open);
3163     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(this->base.loc));
3164     return this;
3165 }
3166
3167 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WI@Z */
3168 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WI@Z */
3169 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGI@Z */
3170 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGI@Z */
3171 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_wchar_mode, 12)
3172 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_wchar_mode(basic_filebuf_wchar *this, const wchar_t *name, unsigned int mode)
3173 {
3174     return basic_filebuf_wchar_open_wchar(this, name, mode, SH_DENYNO);
3175 }
3176
3177 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PB_WI@Z */
3178 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEB_WI@Z */
3179 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBGI@Z */
3180 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBGI@Z */
3181 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_wchar_mode, 12)
3182 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_wchar_mode(basic_filebuf_wchar *this, const wchar_t *name, unsigned int mode)
3183 {
3184     return basic_filebuf_short_open_wchar(this, name, mode, SH_DENYNO);
3185 }
3186
3187 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDHH@Z */
3188 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3189 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open, 16)
3190 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3191 {
3192     wchar_t nameW[FILENAME_MAX];
3193
3194     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3195
3196     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3197         return NULL;
3198     return basic_filebuf_wchar_open_wchar(this, nameW, mode, prot);
3199 }
3200
3201 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDHH@Z */
3202 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3203 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open, 16)
3204 basic_filebuf_wchar* __thiscall basic_filebuf_short_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3205 {
3206     wchar_t nameW[FILENAME_MAX];
3207
3208     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3209
3210     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3211         return NULL;
3212     return basic_filebuf_short_open_wchar(this, nameW, mode, prot);
3213 }
3214
3215 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDI@Z */
3216 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDI@Z */
3217 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode, 12)
3218 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode(basic_filebuf_wchar *this, const char *name, unsigned int mode)
3219 {
3220     return basic_filebuf_wchar_open(this, name, mode, SH_DENYNO);
3221 }
3222
3223 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDI@Z */
3224 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDI@Z */
3225 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_mode, 12)
3226 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_mode(basic_filebuf_wchar *this, const char *name, unsigned int mode)
3227 {
3228     return basic_filebuf_short_open(this, name, mode, SH_DENYNO);
3229 }
3230
3231 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3232 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3233 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3234 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3235 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
3236 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
3237 {
3238     char buf[8], *dyn_buf, *to_next;
3239     wchar_t ch = c;
3240     const wchar_t *from_next;
3241     int max_size;
3242     unsigned short ret;
3243
3244
3245     TRACE("(%p %d)\n", this, c);
3246
3247     if(!basic_filebuf_wchar_is_open(this))
3248         return WEOF;
3249     if(c == WEOF)
3250         return !c;
3251
3252     if(!this->cvt)
3253         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3254
3255     from_next = &ch;
3256     do {
3257         ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3258                 &from_next, buf, buf+sizeof(buf), &to_next);
3259
3260         switch(ret) {
3261         case CODECVT_partial:
3262             if(to_next == buf)
3263                 break;
3264             /* fall through */
3265         case CODECVT_ok:
3266             if(!fwrite(buf, to_next-buf, 1, this->file))
3267                 return WEOF;
3268             if(ret == CODECVT_partial)
3269                 continue;
3270             return c;
3271         case CODECVT_noconv:
3272             return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3273         default:
3274             return WEOF;
3275         }
3276
3277         break;
3278     } while(1);
3279
3280     max_size = codecvt_base_max_length(&this->cvt->base);
3281     dyn_buf = malloc(max_size);
3282     if(!dyn_buf)
3283         return WEOF;
3284
3285     ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3286             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
3287
3288     switch(ret) {
3289     case CODECVT_ok:
3290         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
3291         free(dyn_buf);
3292         return ret ? c : WEOF;
3293     case CODECVT_partial:
3294         ERR("buffer should be big enough to store all output\n");
3295         /* fall through */
3296     default:
3297         free(dyn_buf);
3298         return WEOF;
3299     }
3300 }
3301
3302 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3303 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3304 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3305 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3306 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
3307 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
3308 {
3309     TRACE("(%p %d)\n", this, c);
3310
3311     if(!basic_filebuf_wchar_is_open(this))
3312         return WEOF;
3313
3314     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
3315             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==c)) {
3316         basic_streambuf_wchar__Gndec(&this->base);
3317         return c==WEOF ? !c : c;
3318     }else if(c!=WEOF && !this->cvt) {
3319         return ungetwc(c, this->file);
3320     }else if(c!=WEOF && basic_streambuf_wchar_gptr(&this->base)!=&this->putback) {
3321         this->putback = c;
3322         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback, &this->putback+1);
3323         return c;
3324     }
3325
3326     return WEOF;
3327 }
3328
3329 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3330 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3331 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3332 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3333 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
3334 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
3335 {
3336     wchar_t ch, *to_next;
3337     char buf[128];
3338     const char *buf_next;
3339     int c, i;
3340
3341     TRACE("(%p)\n", this);
3342
3343     if(!basic_filebuf_wchar_is_open(this))
3344         return WEOF;
3345
3346     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3347         return *basic_streambuf_wchar__Gninc(&this->base);
3348
3349     if(!this->cvt)
3350         return fgetwc(this->file);
3351
3352     buf_next = buf;
3353     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
3354         if((c = fgetc(this->file)) == EOF)
3355             return WEOF;
3356         buf[i] = c;
3357
3358         switch(codecvt_wchar_in(this->cvt, &this->state, buf_next,
3359                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
3360         case CODECVT_partial:
3361         case CODECVT_ok:
3362             if(to_next == &ch)
3363                 continue;
3364
3365             for(i--; i>=buf_next-buf; i--)
3366                 ungetc(buf[i], this->file);
3367             return ch;
3368         case CODECVT_noconv:
3369             if(i+1 < sizeof(wchar_t))
3370                 continue;
3371
3372             memcpy(&ch, buf, sizeof(wchar_t));
3373             return ch;
3374         default:
3375             return WEOF;
3376         }
3377     }
3378
3379     FIXME("buffer is too small\n");
3380     return WEOF;
3381 }
3382
3383 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3384 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3385 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3386 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3387 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
3388 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
3389 {
3390     unsigned short ret;
3391
3392     TRACE("(%p)\n", this);
3393
3394     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3395         return *basic_streambuf_wchar_gptr(&this->base);
3396
3397     ret = call_basic_streambuf_wchar_uflow(&this->base);
3398     if(ret != WEOF)
3399         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
3400     return ret;
3401 }
3402
3403 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3404 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3405 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3406 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3407 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 20)
3408 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
3409         fpos_int *ret, streamoff off, int way, int mode)
3410 {
3411     fpos_t pos;
3412
3413     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3414
3415     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback) {
3416         if(way == SEEKDIR_cur)
3417             off -= sizeof(wchar_t);
3418
3419         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3420     }
3421
3422     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3423             || fseek(this->file, off, way)) {
3424         ret->off = 0;
3425         ret->pos = -1;
3426         ret->state = 0;
3427         return ret;
3428     }
3429
3430     fgetpos(this->file, &pos);
3431     ret->off = 0;
3432     ret->pos = pos;
3433     ret->state = this->state;
3434     return ret;
3435 }
3436
3437 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3438 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3439 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3440 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3441 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
3442 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
3443         fpos_int *ret, fpos_int pos, int mode)
3444 {
3445     fpos_t fpos;
3446
3447     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3448
3449     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3450             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
3451             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
3452         ret->off = 0;
3453         ret->pos = -1;
3454         ret->state = 0;
3455         return ret;
3456     }
3457
3458     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback)
3459         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3460
3461     fgetpos(this->file, &fpos);
3462     ret->off = 0;
3463     ret->pos = fpos;
3464     ret->state = this->state;
3465     return ret;
3466 }
3467
3468 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
3469 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
3470 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 12)
3471 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3472 {
3473     TRACE("(%p %p %ld)\n", this, buf, count);
3474
3475     if(!basic_filebuf_wchar_is_open(this))
3476         return NULL;
3477
3478     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3479         return NULL;
3480
3481     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
3482     return &this->base;
3483 }
3484
3485 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
3486 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
3487 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 12)
3488 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3489 {
3490     TRACE("(%p %p %ld)\n", this, buf, count);
3491
3492     if(!basic_filebuf_wchar_is_open(this))
3493         return NULL;
3494
3495     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3496         return NULL;
3497
3498     basic_filebuf_short__Init(this, this->file, INITFL_open);
3499     return &this->base;
3500 }
3501
3502 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
3503 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
3504 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
3505 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
3506 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
3507 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
3508 {
3509     TRACE("(%p)\n", this);
3510
3511     if(!basic_filebuf_wchar_is_open(this))
3512         return 0;
3513
3514     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
3515         return 0;
3516     return fflush(this->file);
3517 }
3518
3519 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
3520 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
3521 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_imbue, 8)
3522 void __thiscall basic_filebuf_wchar_imbue(basic_filebuf_wchar *this, const locale *loc)
3523 {
3524     TRACE("(%p %p)\n", this, loc);
3525     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(loc));
3526 }
3527
3528 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
3529 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
3530 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_imbue, 8)
3531 void __thiscall basic_filebuf_short_imbue(basic_filebuf_wchar *this, const locale *loc)
3532 {
3533     TRACE("(%p %p)\n", this, loc);
3534     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(loc));
3535 }
3536
3537 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3538 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3539 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Getstate, 8)
3540 int __thiscall basic_stringbuf_char__Getstate(basic_stringbuf_char *this, IOSB_openmode mode)
3541 {
3542     int state = 0;
3543
3544     if(!(mode & OPENMODE_in))
3545         state |= STRINGBUF_no_read;
3546
3547     if(!(mode & OPENMODE_out))
3548         state |= STRINGBUF_no_write;
3549
3550     if(mode & OPENMODE_ate)
3551         state |= STRINGBUF_at_end;
3552
3553     if(mode & OPENMODE_app)
3554         state |= STRINGBUF_append;
3555
3556     return state;
3557 }
3558
3559 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXPBDIH@Z */
3560 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXPEBD_KH@Z */
3561 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Init, 16)
3562 void __thiscall basic_stringbuf_char__Init(basic_stringbuf_char *this, const char *str, MSVCP_size_t count, int state)
3563 {
3564     TRACE("(%p, %p, %ld, %d)\n", this, str, count, state);
3565
3566     basic_streambuf_char__Init_empty(&this->base);
3567
3568     this->state = state;
3569     this->seekhigh = NULL;
3570
3571     if(count && str) {
3572         char *buf = MSVCRT_operator_new(count);
3573         if(!buf) {
3574             ERR("Out of memory\n");
3575             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3576         }
3577
3578         memcpy(buf, str, count);
3579         this->seekhigh = buf + count;
3580
3581         this->state |= STRINGBUF_allocated;
3582
3583         if(!(state & STRINGBUF_no_read))
3584             basic_streambuf_char_setg(&this->base, buf, buf, buf + count);
3585
3586         if(!(state & STRINGBUF_no_write)) {
3587             basic_streambuf_char_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3588
3589             if(!basic_streambuf_char_gptr(&this->base))
3590                 basic_streambuf_char_setg(&this->base, buf, 0, buf);
3591         }
3592     }
3593 }
3594
3595 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
3596 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@H@Z */
3597 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_str, 12)
3598 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_str(basic_stringbuf_char *this,
3599         const basic_string_char *str, IOSB_openmode mode)
3600 {
3601     TRACE("(%p %p %d)\n", this, str, mode);
3602
3603     basic_streambuf_char_ctor(&this->base);
3604     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3605
3606     basic_stringbuf_char__Init(this, MSVCP_basic_string_char_c_str(str),
3607             str->size, basic_stringbuf_char__Getstate(this, mode));
3608     return this;
3609 }
3610
3611 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
3612 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
3613 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_mode, 8)
3614 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_mode(
3615         basic_stringbuf_char *this, IOSB_openmode mode)
3616 {
3617     TRACE("(%p %d)\n", this, mode);
3618
3619     basic_streambuf_char_ctor(&this->base);
3620     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3621
3622     basic_stringbuf_char__Init(this, NULL, 0, basic_stringbuf_char__Getstate(this, mode));
3623     return this;
3624 }
3625
3626 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
3627 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
3628 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor, 4)
3629 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor(basic_stringbuf_char *this)
3630 {
3631     return basic_stringbuf_char_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3632 }
3633
3634 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXXZ */
3635 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXXZ */
3636 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Tidy, 4)
3637 void __thiscall basic_stringbuf_char__Tidy(basic_stringbuf_char *this)
3638 {
3639     TRACE("(%p)\n", this);
3640
3641     if(this->state & STRINGBUF_allocated) {
3642         MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
3643         this->seekhigh = NULL;
3644         this->state &= ~STRINGBUF_allocated;
3645     }
3646
3647     basic_streambuf_char__Init_empty(&this->base);
3648 }
3649
3650 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
3651 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
3652 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_dtor, 4)
3653 void __thiscall basic_stringbuf_char_dtor(basic_stringbuf_char *this)
3654 {
3655     TRACE("(%p)\n", this);
3656
3657     basic_stringbuf_char__Tidy(this);
3658     basic_streambuf_char_dtor(&this->base);
3659 }
3660
3661 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_vector_dtor, 8)
3662 basic_stringbuf_char* __thiscall basic_stringbuf_char_vector_dtor(basic_stringbuf_char *this, unsigned int flags)
3663 {
3664     TRACE("(%p %x)\n", this, flags);
3665
3666     if(flags & 2) {
3667         /* we have an array, with the number of elements stored before the first object */
3668         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3669
3670         for (i = *ptr - 1; i >= 0; i--)
3671             basic_stringbuf_char_dtor(this+i);
3672
3673         MSVCRT_operator_delete(ptr);
3674     }else {
3675         basic_stringbuf_char_dtor(this);
3676
3677         if(flags & 1)
3678             MSVCRT_operator_delete(this);
3679     }
3680
3681     return this;
3682 }
3683
3684 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3685 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3686 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_overflow, 8)
3687 int __thiscall basic_stringbuf_char_overflow(basic_stringbuf_char *this, int meta)
3688 {
3689     MSVCP_size_t oldsize, size;
3690     char *ptr, *buf;
3691
3692     TRACE("(%p %x)\n", this, meta);
3693
3694     if(meta == EOF)
3695         return !EOF;
3696     if(this->state & STRINGBUF_no_write)
3697         return EOF;
3698
3699     ptr = basic_streambuf_char_pptr(&this->base);
3700     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3701         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
3702                 this->seekhigh, basic_streambuf_char_epptr(&this->base));
3703
3704     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
3705         return (*basic_streambuf_char__Pninc(&this->base) = meta);
3706
3707     oldsize = (ptr ? basic_streambuf_char_epptr(&this->base)-basic_streambuf_char_eback(&this->base): 0);
3708     size = oldsize|0xf;
3709     size += size/2;
3710     buf = MSVCRT_operator_new(size);
3711     if(!buf) {
3712         ERR("Out of memory\n");
3713         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3714     }
3715
3716     if(!oldsize) {
3717         this->seekhigh = buf;
3718         basic_streambuf_char_setp(&this->base, buf, buf+size);
3719         if(this->state & STRINGBUF_no_read)
3720             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3721         else
3722             basic_streambuf_char_setg(&this->base, buf, buf, buf+1);
3723
3724         this->state |= STRINGBUF_allocated;
3725     }else {
3726         ptr = basic_streambuf_char_eback(&this->base);
3727         memcpy(buf, ptr, oldsize);
3728
3729         this->seekhigh = buf+(this->seekhigh-ptr);
3730         basic_streambuf_char_setp_next(&this->base, buf,
3731                 buf+(basic_streambuf_char_pptr(&this->base)-ptr), buf+size);
3732         if(this->state & STRINGBUF_no_read)
3733             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3734         else
3735             basic_streambuf_char_setg(&this->base, buf,
3736                     buf+(basic_streambuf_char_gptr(&this->base)-ptr),
3737                     basic_streambuf_char_pptr(&this->base)+1);
3738
3739         MSVCRT_operator_delete(ptr);
3740     }
3741
3742     return (*basic_streambuf_char__Pninc(&this->base) = meta);
3743 }
3744
3745 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3746 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3747 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_pbackfail, 8)
3748 int __thiscall basic_stringbuf_char_pbackfail(basic_stringbuf_char *this, int c)
3749 {
3750     char *cur;
3751
3752     TRACE("(%p %x)\n", this, c);
3753
3754     cur = basic_streambuf_char_gptr(&this->base);
3755     if(!cur || cur==basic_streambuf_char_eback(&this->base)
3756             || (c!=EOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3757         return EOF;
3758
3759     if(c != EOF)
3760         cur[-1] = c;
3761     basic_streambuf_char_gbump(&this->base, -1);
3762     return c==EOF ? !EOF : c;
3763 }
3764
3765 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHXZ */
3766 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHXZ */
3767 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_underflow, 4)
3768 int __thiscall basic_stringbuf_char_underflow(basic_stringbuf_char *this)
3769 {
3770     char *ptr, *cur;
3771
3772     TRACE("(%p)\n", this);
3773
3774     cur = basic_streambuf_char_gptr(&this->base);
3775     if(!cur || this->state&STRINGBUF_no_read)
3776         return EOF;
3777
3778     ptr  = basic_streambuf_char_pptr(&this->base);
3779     if(this->seekhigh < ptr)
3780         this->seekhigh = ptr;
3781
3782     ptr = basic_streambuf_char_egptr(&this->base);
3783     if(this->seekhigh > ptr)
3784         basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base), cur, this->seekhigh);
3785
3786     if(cur < this->seekhigh)
3787         return (unsigned char)*cur;
3788     return EOF;
3789 }
3790
3791 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3792 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3793 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekoff, 20)
3794 fpos_int* __thiscall basic_stringbuf_char_seekoff(basic_stringbuf_char *this,
3795         fpos_int *ret, streamoff off, int way, int mode)
3796 {
3797     char *beg, *cur_r, *cur_w;
3798
3799     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3800
3801     cur_w = basic_streambuf_char_pptr(&this->base);
3802     if(cur_w > this->seekhigh)
3803         this->seekhigh = cur_w;
3804
3805     ret->off = 0;
3806     ret->state = 0;
3807
3808     beg = basic_streambuf_char_eback(&this->base);
3809     cur_r = basic_streambuf_char_gptr(&this->base);
3810     if((mode & OPENMODE_in) && cur_r) {
3811         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3812             off += cur_r-beg;
3813         else if(way == SEEKDIR_end)
3814             off += this->seekhigh-beg;
3815         else if(way != SEEKDIR_beg)
3816             off = -1;
3817
3818         if(off<0 || off>this->seekhigh-beg) {
3819             off = -1;
3820         }else {
3821             basic_streambuf_char_gbump(&this->base, beg-cur_r+off);
3822             if((mode & OPENMODE_out) && cur_w) {
3823                 basic_streambuf_char_setp_next(&this->base, beg,
3824                         basic_streambuf_char_gptr(&this->base),
3825                         basic_streambuf_char_epptr(&this->base));
3826             }
3827         }
3828     }else if((mode & OPENMODE_out) && cur_w) {
3829         if(way == SEEKDIR_cur)
3830             off += cur_w-beg;
3831         else if(way == SEEKDIR_end)
3832             off += this->seekhigh-beg;
3833         else if(way != SEEKDIR_beg)
3834             off = -1;
3835
3836         if(off<0 || off>this->seekhigh-beg)
3837             off = -1;
3838         else
3839             basic_streambuf_char_pbump(&this->base, beg-cur_w+off);
3840     }else {
3841         off = -1;
3842     }
3843
3844     ret->pos = off;
3845     return ret;
3846 }
3847
3848 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3849 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3850 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekpos, 36)
3851 fpos_int* __thiscall basic_stringbuf_char_seekpos(basic_stringbuf_char *this,
3852         fpos_int *ret, fpos_int pos, int mode)
3853 {
3854     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3855
3856     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
3857         *ret = pos;
3858         return ret;
3859     }
3860
3861     return basic_stringbuf_char_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
3862 }
3863
3864 /* ?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 */
3865 /* ?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 */
3866 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_set, 8)
3867 void __thiscall basic_stringbuf_char_str_set(basic_stringbuf_char *this, const basic_string_char *str)
3868 {
3869     TRACE("(%p %p)\n", this, str);
3870
3871     basic_stringbuf_char__Tidy(this);
3872     basic_stringbuf_char__Init(this, MSVCP_basic_string_char_c_str(str), str->size, this->state);
3873 }
3874
3875 /* ?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 */
3876 /* ?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 */
3877 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_get, 8)
3878 basic_string_char* __thiscall basic_stringbuf_char_str_get(const basic_stringbuf_char *this, basic_string_char *ret)
3879 {
3880     char *ptr;
3881
3882     TRACE("(%p)\n", this);
3883
3884     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_char_pptr(&this->base)) {
3885         char *pptr;
3886
3887         ptr = basic_streambuf_char_pbase(&this->base);
3888         pptr = basic_streambuf_char_pptr(&this->base);
3889
3890         return MSVCP_basic_string_char_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
3891     }
3892
3893     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_char_gptr(&this->base)) {
3894         ptr = basic_streambuf_char_eback(&this->base);
3895         return MSVCP_basic_string_char_ctor_cstr_len(ret, ptr, basic_streambuf_char_egptr(&this->base) - ptr);
3896     }
3897
3898     return MSVCP_basic_string_char_ctor(ret);
3899 }
3900
3901 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAEHH@Z */
3902 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAAHH@Z */
3903 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3904 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3905 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Getstate, 8)
3906 int __thiscall basic_stringbuf_wchar__Getstate(basic_stringbuf_wchar *this, IOSB_openmode mode)
3907 {
3908     int state = 0;
3909
3910     if(!(mode & OPENMODE_in))
3911         state |= STRINGBUF_no_read;
3912
3913     if(!(mode & OPENMODE_out))
3914         state |= STRINGBUF_no_write;
3915
3916     if(mode & OPENMODE_ate)
3917         state |= STRINGBUF_at_end;
3918
3919     if(mode & OPENMODE_app)
3920         state |= STRINGBUF_append;
3921
3922     return state;
3923 }
3924
3925 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXPB_WIH@Z */
3926 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXPEB_W_KH@Z */
3927 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXPBGIH@Z */
3928 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXPEBG_KH@Z */
3929 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Init, 16)
3930 void __thiscall basic_stringbuf_wchar__Init(basic_stringbuf_wchar *this, const wchar_t *str, MSVCP_size_t count, int state)
3931 {
3932     TRACE("(%p, %p, %lu, %d)\n", this, str, count, state);
3933
3934     basic_streambuf_wchar__Init_empty(&this->base);
3935
3936     this->state = state;
3937     this->seekhigh = NULL;
3938
3939     if(count && str) {
3940         wchar_t *buf = MSVCRT_operator_new(count*sizeof(wchar_t));
3941         if(!buf) {
3942             ERR("Out of memory\n");
3943             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3944         }
3945
3946         memcpy(buf, str, count*sizeof(wchar_t));
3947         this->seekhigh = buf + count;
3948
3949         this->state |= STRINGBUF_allocated;
3950
3951         if(!(state & STRINGBUF_no_read))
3952             basic_streambuf_wchar_setg(&this->base, buf, buf, buf + count);
3953
3954         if(!(state & STRINGBUF_no_write)) {
3955             basic_streambuf_wchar_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3956
3957             if(!basic_streambuf_wchar_gptr(&this->base))
3958                 basic_streambuf_wchar_setg(&this->base, buf, 0, buf);
3959         }
3960     }
3961 }
3962
3963 /* ??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 */
3964 /* ??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 */
3965 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor_str, 12)
3966 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor_str(basic_stringbuf_wchar *this,
3967         const basic_string_wchar *str, IOSB_openmode mode)
3968 {
3969     TRACE("(%p %p %d)\n", this, str, mode);
3970
3971     basic_streambuf_wchar_ctor(&this->base);
3972     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3973
3974     basic_stringbuf_wchar__Init(this, MSVCP_basic_string_wchar_c_str(str),
3975             str->size, basic_stringbuf_wchar__Getstate(this, mode));
3976     return this;
3977 }
3978
3979 /* ??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 */
3980 /* ??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 */
3981 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_str, 12)
3982 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_str(basic_stringbuf_wchar *this,
3983         const basic_string_wchar *str, IOSB_openmode mode)
3984 {
3985     basic_stringbuf_wchar_ctor_str(this, str, mode);
3986     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3987     return this;
3988 }
3989
3990 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
3991 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
3992 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor_mode, 8)
3993 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor_mode(
3994         basic_stringbuf_wchar *this, IOSB_openmode mode)
3995 {
3996     TRACE("(%p %d)\n", this, mode);
3997
3998     basic_streambuf_wchar_ctor(&this->base);
3999     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
4000
4001     basic_stringbuf_wchar__Init(this, NULL, 0, basic_stringbuf_wchar__Getstate(this, mode));
4002     return this;
4003 }
4004
4005 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
4006 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
4007 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_mode, 8)
4008 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_mode(
4009         basic_stringbuf_wchar *this, IOSB_openmode mode)
4010 {
4011     basic_stringbuf_wchar_ctor_mode(this, mode);
4012     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
4013     return this;
4014 }
4015
4016 /* ??_F?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
4017 /* ??_F?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
4018 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor, 4)
4019 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor(basic_stringbuf_wchar *this)
4020 {
4021     return basic_stringbuf_wchar_ctor_mode(this, OPENMODE_in|OPENMODE_out);
4022 }
4023
4024 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
4025 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
4026 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor, 4)
4027 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor(basic_stringbuf_wchar *this)
4028 {
4029     return basic_stringbuf_short_ctor_mode(this, OPENMODE_in|OPENMODE_out);
4030 }
4031
4032 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXXZ */
4033 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXXZ */
4034 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXXZ */
4035 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXXZ */
4036 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Tidy, 4)
4037 void __thiscall basic_stringbuf_wchar__Tidy(basic_stringbuf_wchar *this)
4038 {
4039     TRACE("(%p)\n", this);
4040
4041     if(this->state & STRINGBUF_allocated) {
4042         MSVCRT_operator_delete(basic_streambuf_wchar_eback(&this->base));
4043         this->seekhigh = NULL;
4044         this->state &= ~STRINGBUF_allocated;
4045     }
4046
4047     basic_streambuf_wchar__Init_empty(&this->base);
4048 }
4049
4050 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
4051 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
4052 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
4053 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
4054 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_dtor, 4)
4055 void __thiscall basic_stringbuf_wchar_dtor(basic_stringbuf_wchar *this)
4056 {
4057     TRACE("(%p)\n", this);
4058
4059     basic_stringbuf_wchar__Tidy(this);
4060     basic_streambuf_wchar_dtor(&this->base);
4061 }
4062
4063 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_vector_dtor, 8)
4064 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_vector_dtor(basic_stringbuf_wchar *this, unsigned int flags)
4065 {
4066     TRACE("(%p %x)\n", this, flags);
4067
4068     if(flags & 2) {
4069         /* we have an array, with the number of elements stored before the first object */
4070         INT_PTR i, *ptr = (INT_PTR *) this - 1;
4071
4072         for (i = *ptr - 1; i >= 0; i--)
4073             basic_stringbuf_wchar_dtor(this+i);
4074
4075         MSVCRT_operator_delete(ptr);
4076     }else {
4077         basic_stringbuf_wchar_dtor(this);
4078
4079         if(flags & 1)
4080             MSVCRT_operator_delete(this);
4081     }
4082
4083     return this;
4084 }
4085
4086 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4087 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4088 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4089 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4090 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_overflow, 8)
4091 unsigned short __thiscall basic_stringbuf_wchar_overflow(basic_stringbuf_wchar *this, unsigned short meta)
4092 {
4093     MSVCP_size_t oldsize, size;
4094     wchar_t *ptr, *buf;
4095
4096     TRACE("(%p %x)\n", this, meta);
4097
4098     if(meta == WEOF)
4099         return !WEOF;
4100     if(this->state & STRINGBUF_no_write)
4101         return WEOF;
4102
4103     ptr = basic_streambuf_wchar_pptr(&this->base);
4104     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
4105         basic_streambuf_wchar_setp_next(&this->base, basic_streambuf_wchar_pbase(&this->base),
4106                 this->seekhigh, basic_streambuf_wchar_epptr(&this->base));
4107
4108     if(ptr && ptr<basic_streambuf_wchar_epptr(&this->base))
4109         return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4110
4111     oldsize = (ptr ? basic_streambuf_wchar_epptr(&this->base)-basic_streambuf_wchar_eback(&this->base): 0);
4112     size = oldsize|0xf;
4113     size += size/2;
4114     buf = MSVCRT_operator_new(size*sizeof(wchar_t));
4115     if(!buf) {
4116         ERR("Out of memory\n");
4117         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
4118     }
4119
4120     if(!oldsize) {
4121         this->seekhigh = buf;
4122         basic_streambuf_wchar_setp(&this->base, buf, buf+size);
4123         if(this->state & STRINGBUF_no_read)
4124             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4125         else
4126             basic_streambuf_wchar_setg(&this->base, buf, buf, buf+1);
4127
4128         this->state |= STRINGBUF_allocated;
4129     }else {
4130         ptr = basic_streambuf_wchar_eback(&this->base);
4131         memcpy(buf, ptr, oldsize*sizeof(wchar_t));
4132
4133         this->seekhigh = buf+(this->seekhigh-ptr);
4134         basic_streambuf_wchar_setp_next(&this->base, buf,
4135                 buf+(basic_streambuf_wchar_pptr(&this->base)-ptr), buf+size);
4136         if(this->state & STRINGBUF_no_read)
4137             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4138         else
4139             basic_streambuf_wchar_setg(&this->base, buf,
4140                     buf+(basic_streambuf_wchar_gptr(&this->base)-ptr),
4141                     basic_streambuf_wchar_pptr(&this->base)+1);
4142
4143         MSVCRT_operator_delete(ptr);
4144     }
4145
4146     return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4147 }
4148
4149 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4150 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4151 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4152 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4153 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_pbackfail, 8)
4154 unsigned short __thiscall basic_stringbuf_wchar_pbackfail(basic_stringbuf_wchar *this, unsigned short c)
4155 {
4156     wchar_t *cur;
4157
4158     TRACE("(%p %x)\n", this, c);
4159
4160     cur = basic_streambuf_wchar_gptr(&this->base);
4161     if(!cur || cur==basic_streambuf_wchar_eback(&this->base)
4162             || (c!=WEOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
4163         return WEOF;
4164
4165     if(c != WEOF)
4166         cur[-1] = c;
4167     basic_streambuf_wchar_gbump(&this->base, -1);
4168     return c==WEOF ? !WEOF : c;
4169 }
4170
4171 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGXZ */
4172 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGXZ */
4173 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGXZ */
4174 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGXZ */
4175 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_underflow, 4)
4176 unsigned short __thiscall basic_stringbuf_wchar_underflow(basic_stringbuf_wchar *this)
4177 {
4178     wchar_t *ptr, *cur;
4179
4180     TRACE("(%p)\n", this);
4181
4182     cur = basic_streambuf_wchar_gptr(&this->base);
4183     if(!cur || this->state&STRINGBUF_no_read)
4184         return WEOF;
4185
4186     ptr  = basic_streambuf_wchar_pptr(&this->base);
4187     if(this->seekhigh < ptr)
4188         this->seekhigh = ptr;
4189
4190     ptr = basic_streambuf_wchar_egptr(&this->base);
4191     if(this->seekhigh > ptr)
4192         basic_streambuf_wchar_setg(&this->base, basic_streambuf_wchar_eback(&this->base), cur, this->seekhigh);
4193
4194     if(cur < this->seekhigh)
4195         return *cur;
4196     return WEOF;
4197 }
4198
4199 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4200 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4201 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4202 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4203 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekoff, 20)
4204 fpos_int* __thiscall basic_stringbuf_wchar_seekoff(basic_stringbuf_wchar *this,
4205         fpos_int *ret, streamoff off, int way, int mode)
4206 {
4207     wchar_t *beg, *cur_r, *cur_w;
4208
4209     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
4210
4211     cur_w = basic_streambuf_wchar_pptr(&this->base);
4212     if(cur_w > this->seekhigh)
4213         this->seekhigh = cur_w;
4214
4215     ret->off = 0;
4216     ret->state = 0;
4217
4218     beg = basic_streambuf_wchar_eback(&this->base);
4219     cur_r = basic_streambuf_wchar_gptr(&this->base);
4220     if((mode & OPENMODE_in) && cur_r) {
4221         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
4222             off += cur_r-beg;
4223         else if(way == SEEKDIR_end)
4224             off += this->seekhigh-beg;
4225         else if(way != SEEKDIR_beg)
4226             off = -1;
4227
4228         if(off<0 || off>this->seekhigh-beg) {
4229             off = -1;
4230         }else {
4231             basic_streambuf_wchar_gbump(&this->base, beg-cur_r+off);
4232             if((mode & OPENMODE_out) && cur_w) {
4233                 basic_streambuf_wchar_setp_next(&this->base, beg,
4234                         basic_streambuf_wchar_gptr(&this->base),
4235                         basic_streambuf_wchar_epptr(&this->base));
4236             }
4237         }
4238     }else if((mode & OPENMODE_out) && cur_w) {
4239         if(way == SEEKDIR_cur)
4240             off += cur_w-beg;
4241         else if(way == SEEKDIR_end)
4242             off += this->seekhigh-beg;
4243         else if(way != SEEKDIR_beg)
4244             off = -1;
4245
4246         if(off<0 || off>this->seekhigh-beg)
4247             off = -1;
4248         else
4249             basic_streambuf_wchar_pbump(&this->base, beg-cur_w+off);
4250     }else {
4251         off = -1;
4252     }
4253
4254     ret->pos = off;
4255     return ret;
4256 }
4257
4258 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4259 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4260 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4261 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4262 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekpos, 36)
4263 fpos_int* __thiscall basic_stringbuf_wchar_seekpos(basic_stringbuf_wchar *this,
4264         fpos_int *ret, fpos_int pos, int mode)
4265 {
4266     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
4267
4268     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
4269         *ret = pos;
4270         return ret;
4271     }
4272
4273     return basic_stringbuf_wchar_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
4274 }
4275
4276 /* ?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 */
4277 /* ?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 */
4278 /* ?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 */
4279 /* ?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 */
4280 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_set, 8)
4281 void __thiscall basic_stringbuf_wchar_str_set(basic_stringbuf_wchar *this, const basic_string_wchar *str)
4282 {
4283     TRACE("(%p %p)\n", this, str);
4284
4285     basic_stringbuf_wchar__Tidy(this);
4286     basic_stringbuf_wchar__Init(this, MSVCP_basic_string_wchar_c_str(str), str->size, this->state);
4287 }
4288
4289 /* ?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 */
4290 /* ?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 */
4291 /* ?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 */
4292 /* ?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 */
4293 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_get, 8)
4294 basic_string_wchar* __thiscall basic_stringbuf_wchar_str_get(const basic_stringbuf_wchar *this, basic_string_wchar *ret)
4295 {
4296     wchar_t *ptr;
4297
4298     TRACE("(%p)\n", this);
4299
4300     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_wchar_pptr(&this->base)) {
4301         wchar_t *pptr;
4302
4303         ptr = basic_streambuf_wchar_pbase(&this->base);
4304         pptr = basic_streambuf_wchar_pptr(&this->base);
4305
4306         return MSVCP_basic_string_wchar_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
4307     }
4308
4309     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_wchar_gptr(&this->base)) {
4310         ptr = basic_streambuf_wchar_eback(&this->base);
4311         return MSVCP_basic_string_wchar_ctor_cstr_len(ret, ptr, basic_streambuf_wchar_egptr(&this->base) - ptr);
4312     }
4313
4314     return MSVCP_basic_string_wchar_ctor(ret);
4315 }
4316
4317 /* ??0ios_base@std@@IAE@XZ */
4318 /* ??0ios_base@std@@IEAA@XZ */
4319 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
4320 ios_base* __thiscall ios_base_ctor(ios_base *this)
4321 {
4322     TRACE("(%p)\n", this);
4323     this->vtable = &MSVCP_ios_base_vtable;
4324     return this;
4325 }
4326
4327 /* ??0ios_base@std@@QAE@ABV01@@Z */
4328 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
4329 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
4330 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
4331 {
4332     TRACE("(%p %p)\n", this, copy);
4333     *this = *copy;
4334     this->vtable = &MSVCP_ios_base_vtable;
4335     return this;
4336 }
4337
4338 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
4339 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
4340 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
4341 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
4342 {
4343     IOS_BASE_fnarray *cur;
4344
4345     TRACE("(%p %x)\n", this, event);
4346
4347     for(cur=this->calls; cur; cur=cur->next)
4348         cur->event_handler(event, this, cur->index);
4349 }
4350
4351 /* ?_Tidy@ios_base@std@@AAAXXZ */
4352 /* ?_Tidy@ios_base@std@@AEAAXXZ */
4353 void CDECL ios_base_Tidy(ios_base *this)
4354 {
4355     IOS_BASE_iosarray *arr_cur, *arr_next;
4356     IOS_BASE_fnarray *event_cur, *event_next;
4357
4358     TRACE("(%p)\n", this);
4359
4360     ios_base_Callfns(this, EVENT_erase_event);
4361
4362     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
4363         arr_next = arr_cur->next;
4364         MSVCRT_operator_delete(arr_cur);
4365     }
4366     this->arr = NULL;
4367
4368     for(event_cur=this->calls; event_cur; event_cur=event_next) {
4369         event_next = event_cur->next;
4370         MSVCRT_operator_delete(event_cur);
4371     }
4372     this->calls = NULL;
4373 }
4374
4375 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
4376 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
4377 void CDECL ios_base_Ios_base_dtor(ios_base *obj)
4378 {
4379     TRACE("(%p)\n", obj);
4380     if(obj->loc) {
4381         locale_dtor(obj->loc);
4382         MSVCRT_operator_delete(obj->loc);
4383     }
4384     ios_base_Tidy(obj);
4385 }
4386
4387 /* ??1ios_base@std@@UAE@XZ */
4388 /* ??1ios_base@std@@UEAA@XZ */
4389 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
4390 void __thiscall ios_base_dtor(ios_base *this)
4391 {
4392     ios_base_Ios_base_dtor(this);
4393 }
4394
4395 DEFINE_THISCALL_WRAPPER(ios_base_vector_dtor, 8)
4396 ios_base* __thiscall ios_base_vector_dtor(ios_base *this, unsigned int flags)
4397 {
4398     TRACE("(%p %x)\n", this, flags);
4399     if(flags & 2) {
4400         /* we have an array, with the number of elements stored before the first object */
4401         INT_PTR i, *ptr = (INT_PTR *)this-1;
4402
4403         for(i=*ptr-1; i>=0; i--)
4404             ios_base_dtor(this+i);
4405         MSVCRT_operator_delete(ptr);
4406     } else {
4407         ios_base_dtor(this);
4408         if(flags & 1)
4409             MSVCRT_operator_delete(this);
4410     }
4411
4412     return this;
4413 }
4414
4415 DEFINE_THISCALL_WRAPPER(iosb_vector_dtor, 8)
4416 void* __thiscall iosb_vector_dtor(void *this, unsigned int flags)
4417 {
4418     TRACE("(%p %x)\n", this, flags);
4419     if(flags & 2) {
4420         INT_PTR *ptr = (INT_PTR *)this-1;
4421         MSVCRT_operator_delete(ptr);
4422     } else {
4423         if(flags & 1)
4424             MSVCRT_operator_delete(this);
4425     }
4426
4427     return this;
4428 }
4429
4430 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
4431 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
4432 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
4433 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
4434 {
4435     IOS_BASE_iosarray *p;
4436
4437     TRACE("(%p %d)\n", this, index);
4438
4439     for(p=this->arr; p; p=p->next) {
4440         if(p->index == index)
4441             return p;
4442     }
4443
4444     for(p=this->arr; p; p=p->next) {
4445         if(!p->long_val && !p->ptr_val) {
4446             p->index = index;
4447             return p;
4448         }
4449     }
4450
4451     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
4452     p->next = this->arr;
4453     p->index = index;
4454     p->long_val = 0;
4455     p->ptr_val = NULL;
4456     this->arr = p;
4457     return p;
4458 }
4459
4460 /* ?iword@ios_base@std@@QAEAAJH@Z */
4461 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
4462 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
4463 LONG* __thiscall ios_base_iword(ios_base *this, int index)
4464 {
4465     TRACE("(%p %d)\n", this, index);
4466     return &ios_base_Findarr(this, index)->long_val;
4467 }
4468
4469 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
4470 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
4471 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
4472 void** __thiscall ios_base_pword(ios_base *this, int index)
4473 {
4474     TRACE("(%p %d)\n", this, index);
4475     return &ios_base_Findarr(this, index)->ptr_val;
4476 }
4477
4478 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
4479 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
4480 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
4481 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
4482 {
4483     IOS_BASE_fnarray *event;
4484
4485     TRACE("(%p %p %d)\n", this, callback, index);
4486
4487     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
4488     event->next = this->calls;
4489     event->index = index;
4490     event->event_handler = callback;
4491     this->calls = event;
4492 }
4493
4494 /* ?clear@ios_base@std@@QAEXH_N@Z */
4495 /* ?clear@ios_base@std@@QEAAXH_N@Z */
4496 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
4497 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4498 {
4499     TRACE("(%p %x %x)\n", this, state, reraise);
4500
4501     this->state = state & IOSTATE_mask;
4502     if(!(this->state & this->except))
4503         return;
4504
4505     if(reraise)
4506         throw_exception(EXCEPTION_RERAISE, NULL);
4507     else if(this->state & this->except & IOSTATE_eofbit)
4508         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
4509     else if(this->state & this->except & IOSTATE_failbit)
4510         throw_exception(EXCEPTION_FAILURE, "failbit is set");
4511     else if(this->state & this->except & IOSTATE_badbit)
4512         throw_exception(EXCEPTION_FAILURE, "badbit is set");
4513     else if(this->state & this->except & IOSTATE__Hardfail)
4514         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
4515 }
4516
4517 /* ?clear@ios_base@std@@QAEXH@Z */
4518 /* ?clear@ios_base@std@@QEAAXH@Z */
4519 DEFINE_THISCALL_WRAPPER(ios_base_clear, 8)
4520 void __thiscall ios_base_clear(ios_base *this, IOSB_iostate state)
4521 {
4522     ios_base_clear_reraise(this, state, FALSE);
4523 }
4524
4525 /* ?clear@ios_base@std@@QAEXI@Z */
4526 /* ?clear@ios_base@std@@QEAAXI@Z */
4527 DEFINE_THISCALL_WRAPPER(ios_base_clear_unsigned, 8)
4528 void __thiscall ios_base_clear_unsigned(ios_base *this, unsigned int state)
4529 {
4530     ios_base_clear_reraise(this, (IOSB_iostate)state, FALSE);
4531 }
4532
4533 /* ?exceptions@ios_base@std@@QAEXH@Z */
4534 /* ?exceptions@ios_base@std@@QEAAXH@Z */
4535 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
4536 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
4537 {
4538     TRACE("(%p %x)\n", this, state);
4539     this->except = state & IOSTATE_mask;
4540     ios_base_clear(this, this->state);
4541 }
4542
4543 /* ?exceptions@ios_base@std@@QAEXI@Z */
4544 /* ?exceptions@ios_base@std@@QEAAXI@Z */
4545 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set_unsigned, 8)
4546 void __thiscall ios_base_exceptions_set_unsigned(ios_base *this, unsigned int state)
4547 {
4548     TRACE("(%p %x)\n", this, state);
4549     ios_base_exceptions_set(this, state);
4550 }
4551
4552 /* ?exceptions@ios_base@std@@QBEHXZ */
4553 /* ?exceptions@ios_base@std@@QEBAHXZ */
4554 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
4555 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
4556 {
4557     TRACE("(%p)\n", this);
4558     return this->except;
4559 }
4560
4561 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
4562 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
4563 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
4564 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
4565 {
4566     TRACE("(%p %p)\n", this, rhs);
4567
4568     if(this != rhs) {
4569         IOS_BASE_iosarray *arr_cur;
4570         IOS_BASE_fnarray *event_cur;
4571
4572         ios_base_Tidy(this);
4573
4574         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
4575             if(arr_cur->long_val)
4576                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
4577             if(arr_cur->ptr_val)
4578                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
4579         }
4580         this->stdstr = rhs->stdstr;
4581         this->fmtfl = rhs->fmtfl;
4582         this->prec = rhs->prec;
4583         this->wide = rhs->wide;
4584         locale_operator_assign(this->loc, rhs->loc);
4585
4586         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
4587             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
4588
4589         ios_base_Callfns(this, EVENT_copyfmt_event);
4590         ios_base_exceptions_set(this, rhs->except);
4591     }
4592
4593     return this;
4594 }
4595
4596 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
4597 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
4598 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
4599 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
4600 {
4601     TRACE("(%p %p)\n", this, right);
4602
4603     if(this != right) {
4604         this->state = right->state;
4605         ios_base_copyfmt(this, right);
4606     }
4607
4608     return this;
4609 }
4610
4611 /* ?fail@ios_base@std@@QBE_NXZ */
4612 /* ?fail@ios_base@std@@QEBA_NXZ */
4613 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
4614 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
4615 {
4616     TRACE("(%p)\n", this);
4617     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
4618 }
4619
4620 /* ??7ios_base@std@@QBE_NXZ */
4621 /* ??7ios_base@std@@QEBA_NXZ */
4622 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
4623 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
4624 {
4625     TRACE("(%p)\n", this);
4626     return ios_base_fail(this);
4627 }
4628
4629 /* ??Bios_base@std@@QBEPAXXZ */
4630 /* ??Bios_base@std@@QEBAPEAXXZ */
4631 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
4632 void* __thiscall ios_base_op_fail(const ios_base *this)
4633 {
4634     TRACE("(%p)\n", this);
4635     return ios_base_fail(this) ? NULL : (void*)this;
4636 }
4637
4638 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
4639 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
4640 void CDECL ios_base_Addstd(ios_base *add)
4641 {
4642     FIXME("(%p) stub\n", add);
4643 }
4644
4645 /* ?_Index_func@ios_base@std@@CAAAHXZ */
4646 /* ?_Index_func@ios_base@std@@CAAEAHXZ */
4647 int* CDECL ios_base_Index_func(void)
4648 {
4649     TRACE("\n");
4650     return &ios_base_Index;
4651 }
4652
4653 /* ?_Init@ios_base@std@@IAEXXZ */
4654 /* ?_Init@ios_base@std@@IEAAXXZ */
4655 DEFINE_THISCALL_WRAPPER(ios_base__Init, 4)
4656 void __thiscall ios_base__Init(ios_base *this)
4657 {
4658     TRACE("(%p)\n", this);
4659
4660     this->stdstr = 0;
4661     this->state = this->except = IOSTATE_goodbit;
4662     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
4663     this->prec = 6;
4664     this->wide = 0;
4665     this->arr = NULL;
4666     this->calls = NULL;
4667     this->loc = MSVCRT_operator_new(sizeof(locale));
4668     locale_ctor(this->loc);
4669 }
4670
4671 /* ?_Sync_func@ios_base@std@@CAAA_NXZ */
4672 /* ?_Sync_func@ios_base@std@@CAAEA_NXZ */
4673 MSVCP_bool* CDECL ios_base_Sync_func(void)
4674 {
4675     TRACE("\n");
4676     return &ios_base_Sync;
4677 }
4678
4679 /* ?bad@ios_base@std@@QBE_NXZ */
4680 /* ?bad@ios_base@std@@QEBA_NXZ */
4681 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
4682 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
4683 {
4684     TRACE("(%p)\n", this);
4685     return (this->state & IOSTATE_badbit) != 0;
4686 }
4687
4688 /* ?eof@ios_base@std@@QBE_NXZ */
4689 /* ?eof@ios_base@std@@QEBA_NXZ */
4690 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
4691 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
4692 {
4693     TRACE("(%p)\n", this);
4694     return (this->state & IOSTATE_eofbit) != 0;
4695 }
4696
4697 /* ?flags@ios_base@std@@QAEHH@Z */
4698 /* ?flags@ios_base@std@@QEAAHH@Z */
4699 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
4700 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
4701 {
4702     IOSB_fmtflags ret = this->fmtfl;
4703
4704     TRACE("(%p %x)\n", this, flags);
4705
4706     this->fmtfl = flags & FMTFLAG_mask;
4707     return ret;
4708 }
4709
4710 /* ?flags@ios_base@std@@QBEHXZ */
4711 /* ?flags@ios_base@std@@QEBAHXZ */
4712 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
4713 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
4714 {
4715     TRACE("(%p)\n", this);
4716     return this->fmtfl;
4717 }
4718
4719 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
4720 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
4721 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
4722 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
4723 {
4724     TRACE("(%p)\n", this);
4725     return locale_copy_ctor(ret, this->loc);
4726 }
4727
4728 /* ?good@ios_base@std@@QBE_NXZ */
4729 /* ?good@ios_base@std@@QEBA_NXZ */
4730 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
4731 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
4732 {
4733     TRACE("(%p)\n", this);
4734     return this->state == IOSTATE_goodbit;
4735 }
4736
4737 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
4738 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
4739 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
4740 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
4741 {
4742     TRACE("(%p %p)\n", this, loc);
4743     *ret = *this->loc;
4744     locale_copy_ctor(this->loc, loc);
4745     return ret;
4746 }
4747
4748 /* ?precision@ios_base@std@@QAEHH@Z */
4749 /* ?precision@ios_base@std@@QEAA_J_J@Z */
4750 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
4751 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
4752 {
4753     streamsize ret = this->prec;
4754
4755     TRACE("(%p %ld)\n", this, precision);
4756
4757     this->prec = precision;
4758     return ret;
4759 }
4760
4761 /* ?precision@ios_base@std@@QBEHXZ */
4762 /* ?precision@ios_base@std@@QEBA_JXZ */
4763 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
4764 streamsize __thiscall ios_base_precision_get(const ios_base *this)
4765 {
4766     TRACE("(%p)\n", this);
4767     return this->prec;
4768 }
4769
4770 /* ?rdstate@ios_base@std@@QBEHXZ */
4771 /* ?rdstate@ios_base@std@@QEBAHXZ */
4772 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
4773 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
4774 {
4775     TRACE("(%p)\n", this);
4776     return this->state;
4777 }
4778
4779 /* ?setf@ios_base@std@@QAEHHH@Z */
4780 /* ?setf@ios_base@std@@QEAAHHH@Z */
4781 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
4782 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
4783 {
4784     IOSB_fmtflags ret = this->fmtfl;
4785
4786     TRACE("(%p %x %x)\n", this, flags, mask);
4787
4788     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
4789     return ret;
4790 }
4791
4792 /* ?setf@ios_base@std@@QAEHH@Z */
4793 /* ?setf@ios_base@std@@QEAAHH@Z */
4794 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
4795 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
4796 {
4797     return ios_base_setf_mask(this, flags, ~0);
4798 }
4799
4800 /* ?setstate@ios_base@std@@QAEXH_N@Z */
4801 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
4802 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
4803 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4804 {
4805     TRACE("(%p %x %x)\n", this, state, reraise);
4806
4807     if(state != IOSTATE_goodbit)
4808         ios_base_clear_reraise(this, this->state | state, reraise);
4809 }
4810
4811 /* ?setstate@ios_base@std@@QAEXH@Z */
4812 /* ?setstate@ios_base@std@@QEAAXH@Z */
4813 DEFINE_THISCALL_WRAPPER(ios_base_setstate, 8)
4814 void __thiscall ios_base_setstate(ios_base *this, IOSB_iostate state)
4815 {
4816     ios_base_setstate_reraise(this, state, FALSE);
4817 }
4818
4819 /* ?setstate@ios_base@std@@QAEXI@Z */
4820 /* ?setstate@ios_base@std@@QEAAXI@Z */
4821 DEFINE_THISCALL_WRAPPER(ios_base_setstate_unsigned, 8)
4822 void __thiscall ios_base_setstate_unsigned(ios_base *this, unsigned int state)
4823 {
4824     ios_base_setstate_reraise(this, (IOSB_iostate)state, FALSE);
4825 }
4826
4827 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
4828 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
4829 {
4830     _Lockit lock;
4831     MSVCP_bool ret;
4832
4833     TRACE("(%x)\n", sync);
4834
4835     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4836     ret = ios_base_Sync;
4837     ios_base_Sync = sync;
4838     _Lockit_dtor(&lock);
4839     return ret;
4840 }
4841
4842 /* ?unsetf@ios_base@std@@QAEXH@Z */
4843 /* ?unsetf@ios_base@std@@QEAAXH@Z */
4844 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
4845 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
4846 {
4847     TRACE("(%p %x)\n", this, flags);
4848     this->fmtfl &= ~flags;
4849 }
4850
4851 /* ?width@ios_base@std@@QAEHH@Z */
4852 /* ?width@ios_base@std@@QEAA_J_J@Z */
4853 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
4854 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
4855 {
4856     streamsize ret = this->wide;
4857
4858     TRACE("(%p %ld)\n", this, width);
4859
4860     this->wide = width;
4861     return ret;
4862 }
4863
4864 /* ?width@ios_base@std@@QBEHXZ */
4865 /* ?width@ios_base@std@@QEBA_JXZ */
4866 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
4867 streamsize __thiscall ios_base_width_get(ios_base *this)
4868 {
4869     TRACE("(%p)\n", this);
4870     return this->wide;
4871 }
4872
4873 /* ?xalloc@ios_base@std@@SAHXZ */
4874 int CDECL ios_base_xalloc(void)
4875 {
4876     _Lockit lock;
4877     int ret;
4878
4879     TRACE("\n");
4880
4881     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4882     ret = ios_base_Index++;
4883     _Lockit_dtor(&lock);
4884     return ret;
4885 }
4886
4887 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
4888 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
4889 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
4890 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
4891 {
4892     TRACE("(%p)\n", this);
4893
4894     ios_base_ctor(&this->base);
4895     this->base.vtable = &MSVCP_basic_ios_char_vtable;
4896     return this;
4897 }
4898
4899 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4900 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4901 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
4902 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
4903 {
4904     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4905     ios_base__Init(&this->base);
4906     this->strbuf = streambuf;
4907     this->stream = NULL;
4908     this->fillch = ' ';
4909
4910     if(!streambuf)
4911         ios_base_setstate(&this->base, IOSTATE_badbit);
4912
4913     if(isstd)
4914         FIXME("standard streams not handled yet\n");
4915 }
4916
4917 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4918 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4919 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
4920 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
4921 {
4922     TRACE("(%p %p)\n", this, strbuf);
4923
4924     basic_ios_char_ctor(this);
4925     basic_ios_char_init(this, strbuf, FALSE);
4926     return this;
4927 }
4928
4929 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
4930 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4931 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
4932 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
4933 {
4934     TRACE("(%p)\n", this);
4935     ios_base_dtor(&this->base);
4936 }
4937
4938 DEFINE_THISCALL_WRAPPER(basic_ios_char_vector_dtor, 8)
4939 basic_ios_char* __thiscall basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
4940 {
4941     TRACE("(%p %x)\n", this, flags);
4942     if(flags & 2) {
4943         /* we have an array, with the number of elements stored before the first object */
4944         INT_PTR i, *ptr = (INT_PTR *)this-1;
4945
4946         for(i=*ptr-1; i>=0; i--)
4947             basic_ios_char_dtor(this+i);
4948         MSVCRT_operator_delete(ptr);
4949     } else {
4950         basic_ios_char_dtor(this);
4951         if(flags & 1)
4952             MSVCRT_operator_delete(this);
4953     }
4954
4955     return this;
4956 }
4957
4958 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4959 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4960 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
4961 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4962 {
4963     TRACE("(%p %x %x)\n", this, state, reraise);
4964     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4965 }
4966
4967 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4968 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4969 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear, 8)
4970 void __thiscall basic_ios_char_clear(basic_ios_char *this, unsigned int state)
4971 {
4972     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
4973 }
4974
4975 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
4976 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4977 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
4978 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
4979 {
4980     TRACE("(%p %p)\n", this, copy);
4981     if(this == copy)
4982         return this;
4983
4984     this->stream = copy->stream;
4985     this->fillch = copy->fillch;
4986     ios_base_copyfmt(&this->base, &copy->base);
4987     return this;
4988 }
4989
4990 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
4991 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
4992 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
4993 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
4994 {
4995     char ret = this->fillch;
4996
4997     TRACE("(%p %c)\n", this, fill);
4998
4999     this->fillch = fill;
5000     return ret;
5001 }
5002
5003 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
5004 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
5005 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
5006 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
5007 {
5008     TRACE("(%p)\n", this);
5009     return this->fillch;
5010 }
5011
5012 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5013 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5014 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
5015 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
5016 {
5017     TRACE("(%p %p %p)\n", this, ret, loc);
5018
5019     if(this->strbuf) {
5020         basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
5021         locale_dtor(ret);
5022     }
5023
5024     return ios_base_imbue(&this->base, ret, loc);
5025 }
5026
5027 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
5028 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
5029 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
5030 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
5031 {
5032     TRACE("(%p %c %c)\n", this, ch, def);
5033     return ctype_char_narrow_ch(ctype_char_use_facet(this->strbuf->loc), ch, def);
5034 }
5035
5036 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
5037 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
5038 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
5039 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
5040 {
5041     basic_streambuf_char *ret = this->strbuf;
5042
5043     TRACE("(%p %p)\n", this, streambuf);
5044
5045     this->strbuf = streambuf;
5046     basic_ios_char_clear(this, IOSTATE_goodbit);
5047     return ret;
5048 }
5049
5050 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
5051 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
5052 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
5053 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
5054 {
5055     TRACE("(%p)\n", this);
5056     return this->strbuf;
5057 }
5058
5059 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
5060 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
5061 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
5062 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
5063 {
5064     TRACE("(%p %x %x)\n", this, state, reraise);
5065
5066     if(state != IOSTATE_goodbit)
5067         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
5068 }
5069
5070 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
5071 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
5072 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate, 8)
5073 void __thiscall basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
5074 {
5075     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
5076 }
5077
5078 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
5079 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
5080 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
5081 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
5082 {
5083     basic_ostream_char *ret = this->stream;
5084
5085     TRACE("(%p %p)\n", this, ostream);
5086
5087     this->stream = ostream;
5088     return ret;
5089 }
5090
5091 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
5092 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
5093 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
5094 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
5095 {
5096     TRACE("(%p)\n", this);
5097     return this->stream;
5098 }
5099
5100 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
5101 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
5102 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
5103 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
5104 {
5105     TRACE("(%p %c)\n", this, ch);
5106     return ctype_char_widen_ch(ctype_char_use_facet(this->strbuf->loc), ch);
5107 }
5108
5109
5110 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
5111 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
5112 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor, 4)
5113 basic_ios_wchar* __thiscall basic_ios_wchar_ctor(basic_ios_wchar *this)
5114 {
5115     TRACE("(%p)\n", this);
5116
5117     ios_base_ctor(&this->base);
5118     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
5119     return this;
5120 }
5121
5122 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
5123 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
5124 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
5125 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
5126 {
5127     basic_ios_wchar_ctor(this);
5128     this->base.vtable = &MSVCP_basic_ios_short_vtable;
5129     return this;
5130 }
5131
5132 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
5133 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
5134 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
5135 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
5136 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
5137 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
5138 {
5139     TRACE("(%p %p %x)\n", this, streambuf, isstd);
5140     ios_base__Init(&this->base);
5141     this->strbuf = streambuf;
5142     this->stream = NULL;
5143     this->fillch = ' ';
5144
5145     if(!streambuf)
5146         ios_base_setstate(&this->base, IOSTATE_badbit);
5147
5148     if(isstd)
5149         FIXME("standard streams not handled yet\n");
5150 }
5151
5152 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5153 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5154 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor_streambuf, 8)
5155 basic_ios_wchar* __thiscall basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
5156 {
5157     TRACE("(%p %p)\n", this, strbuf);
5158
5159     basic_ios_wchar_ctor(this);
5160     basic_ios_wchar_init(this, strbuf, FALSE);
5161     return this;
5162 }
5163
5164 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5165 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5166 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
5167 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
5168 {
5169     basic_ios_wchar_ctor_streambuf(this, strbuf);
5170     this->base.vtable = &MSVCP_basic_ios_short_vtable;
5171     return this;
5172 }
5173
5174 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
5175 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
5176 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
5177 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
5178 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
5179 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
5180 {
5181     TRACE("(%p)\n", this);
5182     ios_base_dtor(&this->base);
5183 }
5184
5185 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_vector_dtor, 8)
5186 basic_ios_wchar* __thiscall basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
5187 {
5188     TRACE("(%p %x)\n", this, flags);
5189     if(flags & 2) {
5190         /* we have an array, with the number of elements stored before the first object */
5191         INT_PTR i, *ptr = (INT_PTR *)this-1;
5192
5193         for(i=*ptr-1; i>=0; i--)
5194             basic_ios_wchar_dtor(this+i);
5195         MSVCRT_operator_delete(ptr);
5196     } else {
5197         basic_ios_wchar_dtor(this);
5198         if(flags & 1)
5199             MSVCRT_operator_delete(this);
5200     }
5201
5202     return this;
5203 }
5204
5205 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5206 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5207 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5208 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5209 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
5210 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5211 {
5212     TRACE("(%p %x %x)\n", this, state, reraise);
5213     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
5214 }
5215
5216 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5217 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5218 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5219 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5220 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear, 8)
5221 void __thiscall basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
5222 {
5223     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
5224 }
5225
5226 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
5227 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5228 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
5229 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5230 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
5231 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
5232 {
5233     TRACE("(%p %p)\n", this, copy);
5234     if(this == copy)
5235         return this;
5236
5237     this->stream = copy->stream;
5238     this->fillch = copy->fillch;
5239     ios_base_copyfmt(&this->base, &copy->base);
5240     return this;
5241 }
5242
5243 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
5244 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
5245 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
5246 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
5247 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
5248 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
5249 {
5250     wchar_t ret = this->fillch;
5251
5252     TRACE("(%p %c)\n", this, fill);
5253
5254     this->fillch = fill;
5255     return ret;
5256 }
5257
5258 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
5259 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
5260 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
5261 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
5262 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
5263 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
5264 {
5265     TRACE("(%p)\n", this);
5266     return this->fillch;
5267 }
5268
5269 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5270 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5271 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5272 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5273 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
5274 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
5275 {
5276     TRACE("(%p %p %p)\n", this, ret, loc);
5277
5278     if(this->strbuf) {
5279         basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
5280         locale_dtor(ret);
5281     }
5282
5283     return ios_base_imbue(&this->base, ret, loc);
5284 }
5285
5286 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
5287 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
5288 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
5289 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
5290 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
5291 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
5292 {
5293     TRACE("(%p %c %c)\n", this, ch, def);
5294     return ctype_wchar_narrow_ch(ctype_wchar_use_facet(this->strbuf->loc), ch, def);
5295 }
5296
5297 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5298 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5299 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
5300 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5301 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
5302 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
5303 {
5304     basic_streambuf_wchar *ret = this->strbuf;
5305
5306     TRACE("(%p %p)\n", this, streambuf);
5307
5308     this->strbuf = streambuf;
5309     basic_ios_wchar_clear(this, IOSTATE_goodbit);
5310     return ret;
5311 }
5312
5313 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5314 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5315 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5316 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5317 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
5318 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
5319 {
5320     TRACE("(%p)\n", this);
5321     return this->strbuf;
5322 }
5323
5324 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5325 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5326 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5327 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5328 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
5329 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5330 {
5331     TRACE("(%p %x %x)\n", this, state, reraise);
5332
5333     if(state != IOSTATE_goodbit)
5334         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
5335 }
5336
5337 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5338 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5339 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5340 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5341 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate, 8)
5342 void __thiscall basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
5343 {
5344     basic_ios_wchar_setstate_reraise(this, state, FALSE);
5345 }
5346
5347 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5348 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5349 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
5350 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5351 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
5352 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
5353 {
5354     basic_ostream_wchar *ret = this->stream;
5355
5356     TRACE("(%p %p)\n", this, ostream);
5357
5358     this->stream = ostream;
5359     return ret;
5360 }
5361
5362 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5363 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5364 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5365 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5366 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
5367 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
5368 {
5369     TRACE("(%p)\n", this);
5370     return this->stream;
5371 }
5372
5373 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
5374 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
5375 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
5376 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
5377 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
5378 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
5379 {
5380     TRACE("(%p %c)\n", this, ch);
5381     return ctype_wchar_widen_ch(ctype_wchar_use_facet(this->strbuf->loc), ch);
5382 }
5383
5384 /* Caution: basic_ostream uses virtual inheritance.
5385  * All constructors have additional parameter that says if base class should be initialized.
5386  * Base class needs to be accessed using vbtable.
5387  */
5388 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
5389 {
5390     return (basic_ios_char*)((char*)this+this->vbtable[1]);
5391 }
5392
5393 static inline basic_ios_char* basic_ostream_char_to_basic_ios(basic_ostream_char *ptr)
5394 {
5395     return (basic_ios_char*)((char*)ptr+basic_ostream_char_vbtable[1]);
5396 }
5397
5398 static inline basic_ostream_char* basic_ostream_char_from_basic_ios(basic_ios_char *ptr)
5399 {
5400     return (basic_ostream_char*)((char*)ptr-basic_ostream_char_vbtable[1]);
5401 }
5402
5403 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5404 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5405 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor, 16)
5406 basic_ostream_char* __thiscall basic_ostream_char_ctor(basic_ostream_char *this,
5407         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5408 {
5409     basic_ios_char *base;
5410
5411     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5412
5413     if(virt_init) {
5414         this->vbtable = basic_ostream_char_vbtable;
5415         base = basic_ostream_char_get_basic_ios(this);
5416         basic_ios_char_ctor(base);
5417     }else {
5418         base = basic_ostream_char_get_basic_ios(this);
5419     }
5420
5421     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5422     basic_ios_char_init(base, strbuf, isstd);
5423     return this;
5424 }
5425
5426 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5427 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5428 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor_uninitialized, 16)
5429 basic_ostream_char* __thiscall basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
5430         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5431 {
5432     basic_ios_char *base;
5433
5434     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5435
5436     if(virt_init) {
5437         this->vbtable = basic_ostream_char_vbtable;
5438         base = basic_ostream_char_get_basic_ios(this);
5439         basic_ios_char_ctor(base);
5440     }else {
5441         base = basic_ostream_char_get_basic_ios(this);
5442     }
5443
5444     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5445     if(addstd)
5446         ios_base_Addstd(&base->base);
5447     return this;
5448 }
5449
5450 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5451 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5452 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
5453 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
5454 {
5455     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5456
5457     /* don't destroy virtual base here */
5458     TRACE("(%p)\n", this);
5459 }
5460
5461 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5462 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5463 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
5464 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
5465 {
5466     TRACE("(%p)\n", this);
5467     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
5468     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
5469 }
5470
5471 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
5472 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5473 {
5474     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5475
5476     TRACE("(%p %x)\n", this, flags);
5477
5478     if(flags & 2) {
5479         /* we have an array, with the number of elements stored before the first object */
5480         INT_PTR i, *ptr = (INT_PTR *)this-1;
5481
5482         for(i=*ptr-1; i>=0; i--)
5483             basic_ostream_char_vbase_dtor(this+i);
5484         MSVCRT_operator_delete(ptr);
5485     } else {
5486         basic_ostream_char_vbase_dtor(this);
5487         if(flags & 1)
5488             MSVCRT_operator_delete(this);
5489     }
5490
5491     return this;
5492 }
5493
5494 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5495 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5496 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
5497 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
5498 {
5499     /* this function is not matching C++ specification */
5500     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5501
5502     TRACE("(%p)\n", this);
5503
5504     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
5505             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
5506         basic_ios_char_setstate(base, IOSTATE_badbit);
5507     return this;
5508 }
5509
5510 /* ?flush@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5511 /* ?flush@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5512 basic_ostream_char* __cdecl flush_ostream_char(basic_ostream_char *ostream)
5513 {
5514     return basic_ostream_char_flush(ostream);
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     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5523
5524     TRACE("(%p)\n", this);
5525
5526     if(base->base.fmtfl & FMTFLAG_unitbuf)
5527         basic_ostream_char_flush(this);
5528 }
5529
5530 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5531 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5532 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
5533 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
5534 {
5535     TRACE("(%p)\n", this);
5536     basic_ostream_char__Osfx(this);
5537 }
5538
5539 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
5540 {
5541     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5542
5543     if(basic_ios_char_rdbuf_get(base))
5544         basic_streambuf_char__Lock(base->strbuf);
5545
5546     if(ios_base_good(&base->base) && base->stream)
5547         basic_ostream_char_flush(base->stream);
5548
5549     return ios_base_good(&base->base);
5550 }
5551
5552 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
5553 {
5554     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5555
5556     if(ios_base_good(&base->base) && !__uncaught_exception())
5557         basic_ostream_char_osfx(ostr);
5558
5559     if(basic_ios_char_rdbuf_get(base))
5560         basic_streambuf_char__Unlock(base->strbuf);
5561 }
5562
5563 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
5564 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
5565 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
5566 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
5567 {
5568     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5569
5570     TRACE("(%p)\n", this);
5571
5572     if(ios_base_good(&base->base) && base->stream)
5573         basic_ostream_char_flush(base->stream);
5574     return ios_base_good(&base->base);
5575 }
5576
5577 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5578 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5579 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
5580 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
5581 {
5582     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5583
5584     TRACE("(%p %c)\n", this, ch);
5585
5586     if(!basic_ostream_char_sentry_create(this)
5587             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
5588         basic_ostream_char_sentry_destroy(this);
5589         basic_ios_char_setstate(base, IOSTATE_badbit);
5590         return this;
5591     }
5592
5593     basic_ostream_char_sentry_destroy(this);
5594     return this;
5595 }
5596
5597 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
5598 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
5599 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp, 12)
5600 basic_ostream_char* __thiscall basic_ostream_char_seekp(basic_ostream_char *this, streamoff off, int way)
5601 {
5602     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5603
5604     TRACE("(%p %ld %d)\n", this, off, way);
5605
5606     if(!ios_base_fail(&base->base)) {
5607         fpos_int seek;
5608
5609         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5610                 &seek, off, way, OPENMODE_out);
5611         if(seek.off==0 && seek.pos==-1 && seek.state==0)
5612             basic_ios_char_setstate(base, IOSTATE_failbit);
5613     }
5614     return this;
5615 }
5616
5617 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
5618 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
5619 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
5620 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
5621 {
5622     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5623
5624     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
5625
5626     if(!ios_base_fail(&base->base)) {
5627         fpos_int seek;
5628
5629         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
5630                 &seek, pos, OPENMODE_out);
5631         if(seek.off==0 && seek.pos==-1 && seek.state==0)
5632             basic_ios_char_setstate(base, IOSTATE_failbit);
5633     }
5634     return this;
5635 }
5636
5637 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
5638 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
5639 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
5640 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
5641 {
5642     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5643
5644     TRACE("(%p)\n", this);
5645
5646     if(!ios_base_fail(&base->base)) {
5647         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5648                 ret, 0, SEEKDIR_cur, OPENMODE_out);
5649     }else {
5650         ret->off = 0;
5651         ret->pos = -1;
5652         ret->state = 0;
5653     }
5654     return ret;
5655 }
5656
5657 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
5658 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
5659 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
5660 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
5661 {
5662     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5663
5664     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
5665
5666     if(!basic_ostream_char_sentry_create(this)
5667             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
5668         basic_ostream_char_sentry_destroy(this);
5669         basic_ios_char_setstate(base, IOSTATE_badbit);
5670         return this;
5671     }
5672
5673     basic_ostream_char_sentry_destroy(this);
5674     return this;
5675 }
5676
5677 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
5678 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
5679 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
5680 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
5681 {
5682     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5683     int state = IOSTATE_goodbit;
5684
5685     TRACE("(%p %d)\n", this, val);
5686
5687     if(basic_ostream_char_sentry_create(this)) {
5688         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5689         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5690         ostreambuf_iterator_char dest = {0, strbuf};
5691
5692         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
5693                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
5694                 ? (LONG)((unsigned short)val) : (LONG)val);
5695     }
5696     basic_ostream_char_sentry_destroy(this);
5697
5698     basic_ios_char_setstate(base, state);
5699     return this;
5700 }
5701
5702 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
5703 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
5704 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
5705 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
5706 {
5707     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5708     int state = IOSTATE_goodbit;
5709
5710     TRACE("(%p %u)\n", this, val);
5711
5712     if(basic_ostream_char_sentry_create(this)) {
5713         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5714         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5715         ostreambuf_iterator_char dest = {0, strbuf};
5716
5717         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5718     }
5719     basic_ostream_char_sentry_destroy(this);
5720
5721     basic_ios_char_setstate(base, state);
5722     return this;
5723 }
5724
5725 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
5726 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
5727 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
5728 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
5729 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
5730 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
5731 {
5732     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5733     int state = IOSTATE_goodbit;
5734
5735     TRACE("(%p %d)\n", this, val);
5736
5737     if(basic_ostream_char_sentry_create(this)) {
5738         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5739         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5740         ostreambuf_iterator_char dest = {0, strbuf};
5741
5742         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5743     }
5744     basic_ostream_char_sentry_destroy(this);
5745
5746     basic_ios_char_setstate(base, state);
5747     return this;
5748 }
5749
5750 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
5751 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
5752 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
5753 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
5754 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
5755 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
5756 {
5757     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5758     int state = IOSTATE_goodbit;
5759
5760     TRACE("(%p %u)\n", this, val);
5761
5762     if(basic_ostream_char_sentry_create(this)) {
5763         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5764         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5765         ostreambuf_iterator_char dest = {0, strbuf};
5766
5767         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5768     }
5769     basic_ostream_char_sentry_destroy(this);
5770
5771     basic_ios_char_setstate(base, state);
5772     return this;
5773 }
5774
5775 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
5776 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
5777 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
5778 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
5779 {
5780     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5781     int state = IOSTATE_goodbit;
5782
5783     TRACE("(%p %f)\n", this, val);
5784
5785     if(basic_ostream_char_sentry_create(this)) {
5786         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5787         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5788         ostreambuf_iterator_char dest = {0, strbuf};
5789
5790         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5791     }
5792     basic_ostream_char_sentry_destroy(this);
5793
5794     basic_ios_char_setstate(base, state);
5795     return this;
5796 }
5797
5798 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
5799 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
5800 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
5801 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
5802 {
5803     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5804     int state = IOSTATE_goodbit;
5805
5806     TRACE("(%p %lf)\n", this, val);
5807
5808     if(basic_ostream_char_sentry_create(this)) {
5809         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5810         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5811         ostreambuf_iterator_char dest = {0, strbuf};
5812
5813         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5814     }
5815     basic_ostream_char_sentry_destroy(this);
5816
5817     basic_ios_char_setstate(base, state);
5818     return this;
5819 }
5820
5821 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
5822 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
5823 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
5824 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
5825 {
5826     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5827     int state = IOSTATE_goodbit;
5828
5829     TRACE("(%p %lf)\n", this, val);
5830
5831     if(basic_ostream_char_sentry_create(this)) {
5832         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5833         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5834         ostreambuf_iterator_char dest = {0, strbuf};
5835
5836         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5837     }
5838     basic_ostream_char_sentry_destroy(this);
5839
5840     basic_ios_char_setstate(base, state);
5841     return this;
5842 }
5843
5844 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5845 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5846 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
5847 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
5848 {
5849     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5850     IOSB_iostate state = IOSTATE_badbit;
5851     int c = '\n';
5852
5853     TRACE("(%p %p)\n", this, val);
5854
5855     if(basic_ostream_char_sentry_create(this)) {
5856         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
5857                 c = basic_streambuf_char_snextc(val)) {
5858             state = IOSTATE_goodbit;
5859
5860             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
5861                 state = IOSTATE_badbit;
5862                 break;
5863             }
5864         }
5865     }else {
5866         state = IOSTATE_badbit;
5867     }
5868     basic_ostream_char_sentry_destroy(this);
5869
5870     ios_base_width_set(&base->base, 0);
5871     basic_ios_char_setstate(base, state);
5872     return this;
5873 }
5874
5875 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
5876 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
5877 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
5878 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
5879 {
5880     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5881     int state = IOSTATE_goodbit;
5882
5883     TRACE("(%p %p)\n", this, val);
5884
5885     if(basic_ostream_char_sentry_create(this)) {
5886         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5887         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5888         ostreambuf_iterator_char dest = {0, strbuf};
5889
5890         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5891     }
5892     basic_ostream_char_sentry_destroy(this);
5893
5894     basic_ios_char_setstate(base, state);
5895     return this;
5896 }
5897
5898 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
5899 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
5900 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
5901 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
5902 {
5903     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5904     int state = IOSTATE_goodbit;
5905
5906     TRACE("(%p)\n", this);
5907
5908     if(basic_ostream_char_sentry_create(this)) {
5909         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5910         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5911         ostreambuf_iterator_char dest = {0, strbuf};
5912
5913         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5914     }
5915     basic_ostream_char_sentry_destroy(this);
5916
5917     basic_ios_char_setstate(base, state);
5918     return this;
5919 }
5920
5921 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
5922 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
5923 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
5924 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
5925 {
5926     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5927     int state = IOSTATE_goodbit;
5928
5929     TRACE("(%p)\n", this);
5930
5931     if(basic_ostream_char_sentry_create(this)) {
5932         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5933         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5934         ostreambuf_iterator_char dest = {0, strbuf};
5935
5936         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5937     }
5938     basic_ostream_char_sentry_destroy(this);
5939
5940     basic_ios_char_setstate(base, state);
5941     return this;
5942 }
5943
5944 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
5945 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
5946 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
5947 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
5948 {
5949     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5950     int state = IOSTATE_goodbit;
5951
5952     TRACE("(%p %x)\n", this, val);
5953
5954     if(basic_ostream_char_sentry_create(this)) {
5955         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5956         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5957         ostreambuf_iterator_char dest = {0, strbuf};
5958
5959         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5960     }
5961     basic_ostream_char_sentry_destroy(this);
5962
5963     basic_ios_char_setstate(base, state);
5964     return this;
5965 }
5966
5967 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5968 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5969 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
5970 {
5971     TRACE("(%p)\n", ostr);
5972
5973     basic_ostream_char_put(ostr, '\n');
5974     basic_ostream_char_flush(ostr);
5975     return ostr;
5976 }
5977
5978 /* $?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 */
5979 /* ??$?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 */
5980 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
5981 {
5982     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5983     IOSB_iostate state = IOSTATE_goodbit;
5984
5985     TRACE("(%p %p)\n", ostr, str);
5986
5987     if(basic_ostream_char_sentry_create(ostr)) {
5988         MSVCP_size_t len = MSVCP_basic_string_char_length(str);
5989         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5990
5991         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5992             for(; pad!=0; pad--) {
5993                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5994                     state = IOSTATE_badbit;
5995                     break;
5996                 }
5997             }
5998         }
5999
6000         if(state == IOSTATE_goodbit) {
6001             if(basic_streambuf_char_sputn(base->strbuf, MSVCP_basic_string_char_c_str(str), len) != len)
6002                     state = IOSTATE_badbit;
6003         }
6004
6005         if(state == IOSTATE_goodbit) {
6006             for(; pad!=0; pad--) {
6007                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6008                     state = IOSTATE_badbit;
6009                     break;
6010                 }
6011             }
6012         }
6013
6014         base->base.wide = 0;
6015     }else {
6016         state = IOSTATE_badbit;
6017     }
6018     basic_ostream_char_sentry_destroy(ostr);
6019
6020     basic_ios_char_setstate(base, state);
6021     return ostr;
6022 }
6023
6024 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@C@Z */
6025 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@C@Z */
6026 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z */
6027 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z */
6028 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@E@Z */
6029 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@E@Z */
6030 basic_ostream_char* __cdecl basic_ostream_char_print_ch(basic_ostream_char *ostr, char ch)
6031 {
6032     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
6033     IOSB_iostate state = IOSTATE_goodbit;
6034
6035     TRACE("(%p %d)\n", ostr, ch);
6036
6037     if(basic_ostream_char_sentry_create(ostr)) {
6038         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6039
6040         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6041             for(; pad!=0; pad--) {
6042                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6043                     state = IOSTATE_badbit;
6044                     break;
6045                 }
6046             }
6047         }
6048
6049         if(state == IOSTATE_goodbit) {
6050             if(basic_streambuf_char_sputc(base->strbuf, ch) == EOF)
6051                 state = IOSTATE_badbit;
6052         }
6053
6054         if(state == IOSTATE_goodbit) {
6055             for(; pad!=0; pad--) {
6056                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6057                     state = IOSTATE_badbit;
6058                     break;
6059                 }
6060             }
6061         }
6062
6063         base->base.wide = 0;
6064     }else {
6065         state = IOSTATE_badbit;
6066     }
6067     basic_ostream_char_sentry_destroy(ostr);
6068
6069     basic_ios_char_setstate(base, state);
6070     return ostr;
6071 }
6072
6073 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBC@Z */
6074 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBC@Z */
6075 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z */
6076 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z */
6077 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBE@Z */
6078 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBE@Z */
6079 basic_ostream_char* __cdecl basic_ostream_char_print_str(basic_ostream_char *ostr, const char *str)
6080 {
6081     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
6082     IOSB_iostate state = IOSTATE_goodbit;
6083
6084     TRACE("(%p %s)\n", ostr, str);
6085
6086     if(basic_ostream_char_sentry_create(ostr)) {
6087         MSVCP_size_t len = strlen(str);
6088         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6089
6090         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6091             for(; pad!=0; pad--) {
6092                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6093                     state = IOSTATE_badbit;
6094                     break;
6095                 }
6096             }
6097         }
6098
6099         if(state == IOSTATE_goodbit) {
6100             if(basic_streambuf_char_sputn(base->strbuf, str, len) != len)
6101                 state = IOSTATE_badbit;
6102         }
6103
6104         if(state == IOSTATE_goodbit) {
6105             for(; pad!=0; pad--) {
6106                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6107                     state = IOSTATE_badbit;
6108                     break;
6109                 }
6110             }
6111         }
6112
6113         base->base.wide = 0;
6114     }else {
6115         state = IOSTATE_badbit;
6116     }
6117     basic_ostream_char_sentry_destroy(ostr);
6118
6119     basic_ios_char_setstate(base, state);
6120     return ostr;
6121 }
6122
6123 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6124 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6125 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
6126 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
6127         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
6128 {
6129     TRACE("(%p %p)\n", this, pfunc);
6130     pfunc(this);
6131     return this;
6132 }
6133
6134 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
6135 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
6136 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
6137 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
6138         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
6139 {
6140     TRACE("(%p %p)\n", this, pfunc);
6141     pfunc(basic_ostream_char_get_basic_ios(this));
6142     return this;
6143 }
6144
6145 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6146 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6147 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
6148 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
6149         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
6150 {
6151     TRACE("(%p %p)\n", this, pfunc);
6152     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
6153     return this;
6154 }
6155
6156 /* Caution: basic_ostream uses virtual inheritance. */
6157 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
6158 {
6159     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
6160 }
6161
6162 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
6163 {
6164     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
6165 }
6166
6167 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
6168 {
6169     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
6170 }
6171
6172 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6173 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6174 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_ctor, 16)
6175 basic_ostream_wchar* __thiscall basic_ostream_wchar_ctor(basic_ostream_wchar *this,
6176         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6177 {
6178     basic_ios_wchar *base;
6179
6180     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
6181
6182     if(virt_init) {
6183         this->vbtable = basic_ostream_wchar_vbtable;
6184         base = basic_ostream_wchar_get_basic_ios(this);
6185         basic_ios_wchar_ctor(base);
6186     }else {
6187         base = basic_ostream_wchar_get_basic_ios(this);
6188     }
6189
6190     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6191     basic_ios_wchar_init(base, strbuf, isstd);
6192     return this;
6193 }
6194
6195 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6196 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6197 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor, 16)
6198 basic_ostream_wchar* __thiscall basic_ostream_short_ctor(basic_ostream_wchar *this,
6199         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6200 {
6201     basic_ostream_wchar_ctor(this, strbuf, isstd, virt_init);
6202     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
6203     return this;
6204 }
6205
6206 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
6207 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
6208 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_ctor_uninitialized, 16)
6209 basic_ostream_wchar* __thiscall basic_ostream_wchar_ctor_uninitialized(basic_ostream_wchar *this,
6210         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
6211 {
6212     basic_ios_wchar *base;
6213
6214     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
6215
6216     if(virt_init) {
6217         this->vbtable = basic_ostream_wchar_vbtable;
6218         base = basic_ostream_wchar_get_basic_ios(this);
6219         basic_ios_wchar_ctor(base);
6220     }else {
6221         base = basic_ostream_wchar_get_basic_ios(this);
6222     }
6223
6224     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6225     if(addstd)
6226         ios_base_Addstd(&base->base);
6227     return this;
6228 }
6229
6230 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
6231 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
6232 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor_uninitialized, 16)
6233 basic_ostream_wchar* __thiscall basic_ostream_short_ctor_uninitialized(basic_ostream_wchar *this,
6234         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
6235 {
6236     basic_ostream_wchar_ctor_uninitialized(this, uninitialized, addstd, virt_init);
6237     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
6238     return this;
6239 }
6240
6241 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
6242 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
6243 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
6244 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
6245 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
6246 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
6247 {
6248     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6249
6250     /* don't destroy virtual base here */
6251     TRACE("(%p)\n", this);
6252 }
6253
6254 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6255 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6256 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6257 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6258 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
6259 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
6260 {
6261     TRACE("(%p)\n", this);
6262     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
6263     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
6264 }
6265
6266 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
6267 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
6268 {
6269     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6270
6271     TRACE("(%p %x)\n", this, flags);
6272
6273     if(flags & 2) {
6274         /* we have an array, with the number of elements stored before the first object */
6275         INT_PTR i, *ptr = (INT_PTR *)this-1;
6276
6277         for(i=*ptr-1; i>=0; i--)
6278             basic_ostream_wchar_vbase_dtor(this+i);
6279         MSVCRT_operator_delete(ptr);
6280     } else {
6281         basic_ostream_wchar_vbase_dtor(this);
6282         if(flags & 1)
6283             MSVCRT_operator_delete(this);
6284     }
6285
6286     return this;
6287 }
6288
6289 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
6290 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
6291 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
6292 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
6293 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
6294 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
6295 {
6296     /* this function is not matching C++ specification */
6297     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6298
6299     TRACE("(%p)\n", this);
6300
6301     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
6302             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
6303         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6304     return this;
6305 }
6306
6307 /* ?flush@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6308 /* ?flush@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6309 /* ?flush@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6310 /* ?flush@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6311 basic_ostream_wchar* __cdecl flush_ostream_wchar(basic_ostream_wchar *ostream)
6312 {
6313     return basic_ostream_wchar_flush(ostream);
6314 }
6315
6316 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6317 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6318 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6319 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6320 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar__Osfx, 4)
6321 void __thiscall basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
6322 {
6323     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6324
6325     TRACE("(%p)\n", this);
6326
6327     if(base->base.fmtfl & FMTFLAG_unitbuf)
6328         basic_ostream_wchar_flush(this);
6329 }
6330
6331 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6332 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6333 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6334 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6335 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
6336 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
6337 {
6338     TRACE("(%p)\n", this);
6339     basic_ostream_wchar__Osfx(this);
6340 }
6341
6342 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
6343 {
6344     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6345
6346     if(basic_ios_wchar_rdbuf_get(base))
6347         basic_streambuf_wchar__Lock(base->strbuf);
6348
6349     if(ios_base_good(&base->base) && base->stream)
6350         basic_ostream_wchar_flush(base->stream);
6351
6352     return ios_base_good(&base->base);
6353 }
6354
6355 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
6356 {
6357     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6358
6359     if(ios_base_good(&base->base) && !__uncaught_exception())
6360         basic_ostream_wchar_osfx(ostr);
6361
6362     if(basic_ios_wchar_rdbuf_get(base))
6363         basic_streambuf_wchar__Unlock(base->strbuf);
6364 }
6365
6366 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
6367 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
6368 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
6369 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
6370 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
6371 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
6372 {
6373     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6374
6375     TRACE("(%p)\n", this);
6376
6377     if(ios_base_good(&base->base) && base->stream)
6378         basic_ostream_wchar_flush(base->stream);
6379     return ios_base_good(&base->base);
6380 }
6381
6382 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
6383 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
6384 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
6385 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
6386 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
6387 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
6388 {
6389     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6390
6391     TRACE("(%p %c)\n", this, ch);
6392
6393     if(!basic_ostream_wchar_sentry_create(this)
6394             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
6395         basic_ostream_wchar_sentry_destroy(this);
6396         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6397         return this;
6398     }
6399
6400     basic_ostream_wchar_sentry_destroy(this);
6401     return this;
6402 }
6403
6404 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
6405 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
6406 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
6407 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
6408 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp, 12)
6409 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp(basic_ostream_wchar *this, streamoff off, int way)
6410 {
6411     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6412
6413     TRACE("(%p %ld %d)\n", this, off, way);
6414
6415     if(!ios_base_fail(&base->base)) {
6416         fpos_int seek;
6417
6418         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6419                 &seek, off, way, 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 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6427 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6428 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6429 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6430 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
6431 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
6432 {
6433     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6434
6435     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6436
6437     if(!ios_base_fail(&base->base)) {
6438         fpos_int seek;
6439
6440         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
6441                 &seek, pos, OPENMODE_out);
6442         if(seek.off==0 && seek.pos==-1 && seek.state==0)
6443             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6444     }
6445     return this;
6446 }
6447
6448 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6449 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6450 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6451 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6452 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
6453 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
6454 {
6455     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6456
6457     TRACE("(%p)\n", this);
6458
6459     if(!ios_base_fail(&base->base)) {
6460         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6461                 ret, 0, SEEKDIR_cur, OPENMODE_out);
6462     }else {
6463         ret->off = 0;
6464         ret->pos = -1;
6465         ret->state = 0;
6466     }
6467     return ret;
6468 }
6469
6470 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
6471 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
6472 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
6473 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
6474 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 12)
6475 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
6476 {
6477     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6478
6479     TRACE("(%p %s %ld)\n", this, debugstr_w(str), count);
6480
6481     if(!basic_ostream_wchar_sentry_create(this)
6482             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
6483         basic_ostream_wchar_sentry_destroy(this);
6484         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6485         return this;
6486     }
6487
6488     basic_ostream_wchar_sentry_destroy(this);
6489     return this;
6490 }
6491
6492 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
6493 {
6494     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6495     int state = IOSTATE_goodbit;
6496
6497     TRACE("(%p %d)\n", this, val);
6498
6499     if(basic_ostream_wchar_sentry_create(this)) {
6500         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6501         ostreambuf_iterator_wchar dest = {0, strbuf};
6502
6503         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
6504                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
6505                 ? (LONG)((unsigned short)val) : (LONG)val);
6506     }
6507     basic_ostream_wchar_sentry_destroy(this);
6508
6509     basic_ios_wchar_setstate(base, state);
6510     return this;
6511 }
6512
6513 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@F@Z */
6514 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@F@Z */
6515 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_short, 8)
6516 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_short(basic_ostream_wchar *this, short val)
6517 {
6518     return basic_ostream_print_short(this, val, num_put_wchar_use_facet(
6519                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6520 }
6521
6522 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
6523 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
6524 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
6525 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
6526 {
6527     return basic_ostream_print_short(this, val, num_put_short_use_facet(
6528                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6529 }
6530
6531 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@G@Z */
6532 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@G@Z */
6533 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ushort, 8)
6534 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ushort(basic_ostream_wchar *this, unsigned short val)
6535 {
6536     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6537     int state = IOSTATE_goodbit;
6538
6539     TRACE("(%p %u)\n", this, val);
6540
6541     if(basic_ostream_wchar_sentry_create(this)) {
6542         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6543         const num_put *numput = num_put_wchar_use_facet(strbuf->loc);
6544         ostreambuf_iterator_wchar dest = {0, strbuf};
6545
6546         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6547     }
6548     basic_ostream_wchar_sentry_destroy(this);
6549
6550     basic_ios_wchar_setstate(base, state);
6551     return this;
6552 }
6553
6554 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
6555 {
6556     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6557     int state = IOSTATE_goodbit;
6558
6559     TRACE("(%p %d)\n", this, val);
6560
6561     if(basic_ostream_wchar_sentry_create(this)) {
6562         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6563         ostreambuf_iterator_wchar dest = {0, strbuf};
6564
6565         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6566     }
6567     basic_ostream_wchar_sentry_destroy(this);
6568
6569     basic_ios_wchar_setstate(base, state);
6570     return this;
6571 }
6572
6573 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@H@Z */
6574 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@H@Z */
6575 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@J@Z */
6576 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@J@Z */
6577 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int, 8)
6578 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int(basic_ostream_wchar *this, int val)
6579 {
6580     return basic_ostream_print_int(this, val, num_put_wchar_use_facet(
6581                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6582 }
6583
6584 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
6585 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
6586 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
6587 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
6588 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
6589 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
6590 {
6591     return basic_ostream_print_int(this, val, num_put_short_use_facet(
6592                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6593 }
6594
6595 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
6596 {
6597     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6598     int state = IOSTATE_goodbit;
6599
6600     TRACE("(%p %u)\n", this, val);
6601
6602     if(basic_ostream_wchar_sentry_create(this)) {
6603         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6604         ostreambuf_iterator_wchar dest = {0, strbuf};
6605
6606         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6607     }
6608     basic_ostream_wchar_sentry_destroy(this);
6609
6610     basic_ios_wchar_setstate(base, state);
6611     return this;
6612 }
6613
6614 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@I@Z */
6615 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@I@Z */
6616 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@K@Z */
6617 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@K@Z */
6618 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint, 8)
6619 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint(basic_ostream_wchar *this, unsigned int val)
6620 {
6621     return basic_ostream_print_uint(this, val, num_put_wchar_use_facet(
6622                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6623 }
6624
6625 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
6626 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
6627 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
6628 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
6629 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
6630 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
6631 {
6632     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
6633                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6634 }
6635
6636 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
6637 {
6638     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6639     int state = IOSTATE_goodbit;
6640
6641     TRACE("(%p %f)\n", this, val);
6642
6643     if(basic_ostream_wchar_sentry_create(this)) {
6644         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6645         ostreambuf_iterator_wchar dest = {0, strbuf};
6646
6647         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6648     }
6649     basic_ostream_wchar_sentry_destroy(this);
6650
6651     basic_ios_wchar_setstate(base, state);
6652     return this;
6653 }
6654
6655 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@M@Z */
6656 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@M@Z */
6657 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_float, 8)
6658 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_float(basic_ostream_wchar *this, float val)
6659 {
6660     return basic_ostream_print_float(this, val, num_put_wchar_use_facet(
6661                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6662 }
6663
6664 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
6665 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
6666 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
6667 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
6668 {
6669     return basic_ostream_print_float(this, val, num_put_short_use_facet(
6670                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6671 }
6672
6673 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
6674 {
6675     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6676     int state = IOSTATE_goodbit;
6677
6678     TRACE("(%p %lf)\n", this, val);
6679
6680     if(basic_ostream_wchar_sentry_create(this)) {
6681         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6682         ostreambuf_iterator_wchar dest = {0, strbuf};
6683
6684         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6685     }
6686     basic_ostream_wchar_sentry_destroy(this);
6687
6688     basic_ios_wchar_setstate(base, state);
6689     return this;
6690 }
6691
6692 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@N@Z */
6693 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@N@Z */
6694 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_double, 12)
6695 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_double(basic_ostream_wchar *this, double val)
6696 {
6697     return basic_ostream_print_double(this, val, num_put_wchar_use_facet(
6698                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6699 }
6700
6701 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
6702 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
6703 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
6704 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
6705 {
6706     return basic_ostream_print_double(this, val, num_put_short_use_facet(
6707                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6708 }
6709
6710 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
6711 {
6712     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6713     int state = IOSTATE_goodbit;
6714
6715     TRACE("(%p %lf)\n", this, val);
6716
6717     if(basic_ostream_wchar_sentry_create(this)) {
6718         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6719         ostreambuf_iterator_wchar dest = {0, strbuf};
6720
6721         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6722     }
6723     basic_ostream_wchar_sentry_destroy(this);
6724
6725     basic_ios_wchar_setstate(base, state);
6726     return this;
6727 }
6728
6729 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@O@Z */
6730 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@O@Z */
6731 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ldouble, 12)
6732 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ldouble(basic_ostream_wchar *this, double val)
6733 {
6734     return basic_ostream_print_ldouble(this, val, num_put_wchar_use_facet(
6735                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6736 }
6737
6738 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
6739 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
6740 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
6741 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
6742 {
6743     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
6744                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6745 }
6746
6747 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6748 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6749 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6750 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6751 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
6752 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
6753 {
6754     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6755     IOSB_iostate state = IOSTATE_badbit;
6756     unsigned short c = '\n';
6757
6758     TRACE("(%p %p)\n", this, val);
6759
6760     if(basic_ostream_wchar_sentry_create(this)) {
6761         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
6762                 c = basic_streambuf_wchar_snextc(val)) {
6763             state = IOSTATE_goodbit;
6764
6765             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
6766                 state = IOSTATE_badbit;
6767                 break;
6768             }
6769         }
6770     }else {
6771         state = IOSTATE_badbit;
6772     }
6773     basic_ostream_wchar_sentry_destroy(this);
6774
6775     ios_base_width_set(&base->base, 0);
6776     basic_ios_wchar_setstate(base, state);
6777     return this;
6778 }
6779
6780 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
6781 {
6782     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6783     int state = IOSTATE_goodbit;
6784
6785     TRACE("(%p %p)\n", this, val);
6786
6787     if(basic_ostream_wchar_sentry_create(this)) {
6788         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6789         ostreambuf_iterator_wchar dest = {0, strbuf};
6790
6791         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6792     }
6793     basic_ostream_wchar_sentry_destroy(this);
6794
6795     basic_ios_wchar_setstate(base, state);
6796     return this;
6797 }
6798
6799 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PBX@Z */
6800 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEBX@Z */
6801 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ptr, 8)
6802 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ptr(basic_ostream_wchar *this, const void *val)
6803 {
6804     return basic_ostream_print_ptr(this, val, num_put_wchar_use_facet(
6805                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6806 }
6807
6808 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
6809 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
6810 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
6811 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
6812 {
6813     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
6814                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6815 }
6816
6817 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
6818 {
6819     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6820     int state = IOSTATE_goodbit;
6821
6822     TRACE("(%p)\n", this);
6823
6824     if(basic_ostream_wchar_sentry_create(this)) {
6825         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6826         ostreambuf_iterator_wchar dest = {0, strbuf};
6827
6828         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6829     }
6830     basic_ostream_wchar_sentry_destroy(this);
6831
6832     basic_ios_wchar_setstate(base, state);
6833     return this;
6834 }
6835
6836 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_J@Z */
6837 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_J@Z */
6838 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int64, 12)
6839 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int64(basic_ostream_wchar *this, __int64 val)
6840 {
6841     return basic_ostream_print_int64(this, val, num_put_wchar_use_facet(
6842                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6843 }
6844
6845 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
6846 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
6847 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
6848 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
6849 {
6850     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
6851                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6852 }
6853
6854 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
6855 {
6856     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6857     int state = IOSTATE_goodbit;
6858
6859     TRACE("(%p)\n", this);
6860
6861     if(basic_ostream_wchar_sentry_create(this)) {
6862         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6863         ostreambuf_iterator_wchar dest = {0, strbuf};
6864
6865         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6866     }
6867     basic_ostream_wchar_sentry_destroy(this);
6868
6869     basic_ios_wchar_setstate(base, state);
6870     return this;
6871 }
6872
6873 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_K@Z */
6874 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_K@Z */
6875 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint64, 12)
6876 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6877 {
6878     return basic_ostream_print_uint64(this, val, num_put_wchar_use_facet(
6879                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6880 }
6881
6882 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
6883 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
6884 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
6885 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6886 {
6887     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
6888                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6889 }
6890
6891 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
6892 {
6893     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6894     int state = IOSTATE_goodbit;
6895
6896     TRACE("(%p %x)\n", this, val);
6897
6898     if(basic_ostream_wchar_sentry_create(this)) {
6899         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6900         ostreambuf_iterator_wchar dest = {0, strbuf};
6901
6902         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6903     }
6904     basic_ostream_wchar_sentry_destroy(this);
6905
6906     basic_ios_wchar_setstate(base, state);
6907     return this;
6908 }
6909
6910 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_N@Z */
6911 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_N@Z */
6912 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_bool, 8)
6913 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6914 {
6915     return basic_ostream_print_bool(this, val, num_put_wchar_use_facet(
6916                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6917 }
6918
6919 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
6920 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
6921 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
6922 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6923 {
6924     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
6925                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6926 }
6927
6928 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6929 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6930 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6931 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6932 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
6933 {
6934     TRACE("(%p)\n", ostr);
6935
6936     basic_ostream_wchar_put(ostr, '\n');
6937     basic_ostream_wchar_flush(ostr);
6938     return ostr;
6939 }
6940
6941 /* ??$?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 */
6942 /* ??$?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 */
6943 /* ??$?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 */
6944 /* ??$?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 */
6945 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_bstr(basic_ostream_wchar *ostr, const basic_string_wchar *str)
6946 {
6947     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6948     IOSB_iostate state = IOSTATE_goodbit;
6949
6950     TRACE("(%p %p)\n", ostr, str);
6951
6952     if(basic_ostream_wchar_sentry_create(ostr)) {
6953         MSVCP_size_t len = MSVCP_basic_string_wchar_length(str);
6954         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6955
6956         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6957             for(; pad!=0; pad--) {
6958                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6959                     state = IOSTATE_badbit;
6960                     break;
6961                 }
6962             }
6963         }
6964
6965         if(state == IOSTATE_goodbit) {
6966             if(basic_streambuf_wchar_sputn(base->strbuf, MSVCP_basic_string_wchar_c_str(str), len) != len)
6967                 state = IOSTATE_badbit;
6968         }
6969
6970         if(state == IOSTATE_goodbit) {
6971             for(; pad!=0; pad--) {
6972                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6973                     state = IOSTATE_badbit;
6974                     break;
6975                 }
6976             }
6977         }
6978
6979         base->base.wide = 0;
6980     }else {
6981         state = IOSTATE_badbit;
6982     }
6983     basic_ostream_wchar_sentry_destroy(ostr);
6984
6985     basic_ios_wchar_setstate(base, state);
6986     return ostr;
6987 }
6988
6989 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@_W@Z */
6990 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@_W@Z */
6991 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@G@Z */
6992 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@G@Z */
6993 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_ch(basic_ostream_wchar *ostr, wchar_t ch)
6994 {
6995     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6996     IOSB_iostate state = IOSTATE_goodbit;
6997
6998     TRACE("(%p %d)\n", ostr, ch);
6999
7000     if(basic_ostream_wchar_sentry_create(ostr)) {
7001         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
7002
7003         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
7004             for(; pad!=0; pad--) {
7005                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7006                     state = IOSTATE_badbit;
7007                     break;
7008                 }
7009             }
7010         }
7011
7012         if(state == IOSTATE_goodbit) {
7013             if(basic_streambuf_wchar_sputc(base->strbuf, ch) == WEOF)
7014                 state = IOSTATE_badbit;
7015         }
7016
7017         if(state == IOSTATE_goodbit) {
7018             for(; pad!=0; pad--) {
7019                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7020                     state = IOSTATE_badbit;
7021                     break;
7022                 }
7023             }
7024         }
7025
7026         base->base.wide = 0;
7027     }else {
7028         state = IOSTATE_badbit;
7029     }
7030     basic_ostream_wchar_sentry_destroy(ostr);
7031
7032     basic_ios_wchar_setstate(base, state);
7033     return ostr;
7034 }
7035
7036 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@PB_W@Z */
7037 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@PEB_W@Z */
7038 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@PBG@Z */
7039 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@PEBG@Z */
7040 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_str(basic_ostream_wchar *ostr, const wchar_t *str)
7041 {
7042     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
7043     IOSB_iostate state = IOSTATE_goodbit;
7044
7045     TRACE("(%p %s)\n", ostr, debugstr_w(str));
7046
7047     if(basic_ostream_wchar_sentry_create(ostr)) {
7048         MSVCP_size_t len = wcslen(str);
7049         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
7050
7051         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
7052             for(; pad!=0; pad--) {
7053                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7054                     state = IOSTATE_badbit;
7055                     break;
7056                 }
7057             }
7058         }
7059
7060         if(state == IOSTATE_goodbit) {
7061             if(basic_streambuf_wchar_sputn(base->strbuf, str, len) != len)
7062                                         state = IOSTATE_badbit;
7063         }
7064
7065         if(state == IOSTATE_goodbit) {
7066             for(; pad!=0; pad--) {
7067                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7068                     state = IOSTATE_badbit;
7069                     break;
7070                 }
7071             }
7072         }
7073
7074         base->base.wide = 0;
7075     }else {
7076         state = IOSTATE_badbit;
7077     }
7078     basic_ostream_wchar_sentry_destroy(ostr);
7079
7080     basic_ios_wchar_setstate(base, state);
7081     return ostr;
7082 }
7083
7084 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7085 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7086 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7087 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7088 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
7089 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
7090         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
7091 {
7092     TRACE("(%p %p)\n", this, pfunc);
7093     pfunc(this);
7094     return this;
7095 }
7096
7097 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
7098 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
7099 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
7100 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
7101 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
7102 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
7103         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
7104 {
7105     TRACE("(%p %p)\n", this, pfunc);
7106     pfunc(basic_ostream_wchar_get_basic_ios(this));
7107     return this;
7108 }
7109
7110 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7111 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7112 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7113 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7114 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
7115 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
7116         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
7117 {
7118     TRACE("(%p %p)\n", this, pfunc);
7119     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
7120     return this;
7121 }
7122
7123 /* Caution: basic_istream uses virtual inheritance. */
7124 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
7125 {
7126     return (basic_ios_char*)((char*)this+this->vbtable[1]);
7127 }
7128
7129 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
7130 {
7131     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
7132 }
7133
7134 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
7135 {
7136     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
7137 }
7138
7139 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
7140 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
7141 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_init, 20)
7142 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)
7143 {
7144     basic_ios_char *base;
7145
7146     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
7147
7148     if(virt_init) {
7149         this->vbtable = basic_istream_char_vbtable;
7150         base = basic_istream_char_get_basic_ios(this);
7151         basic_ios_char_ctor(base);
7152     }else {
7153         base = basic_istream_char_get_basic_ios(this);
7154     }
7155
7156     base->base.vtable = &MSVCP_basic_istream_char_vtable;
7157     this->count = 0;
7158     if(!noinit)
7159         basic_ios_char_init(base, strbuf, isstd);
7160     return this;
7161 }
7162
7163 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
7164 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
7165 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
7166 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7167 {
7168     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7169 }
7170
7171 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7172 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7173 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
7174 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
7175 {
7176     basic_ios_char *base;
7177
7178     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
7179
7180     if(virt_init) {
7181         this->vbtable = basic_istream_char_vbtable;
7182         base = basic_istream_char_get_basic_ios(this);
7183         basic_ios_char_ctor(base);
7184     }else {
7185         base = basic_istream_char_get_basic_ios(this);
7186     }
7187
7188     base->base.vtable = &MSVCP_basic_istream_char_vtable;
7189     ios_base_Addstd(&base->base);
7190     return this;
7191 }
7192
7193 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
7194 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
7195 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
7196 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
7197 {
7198     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
7199
7200     /* don't destroy virtual base here */
7201     TRACE("(%p)\n", this);
7202 }
7203
7204 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
7205 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
7206 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
7207 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
7208 {
7209     TRACE("(%p)\n", this);
7210     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
7211     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
7212 }
7213
7214 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
7215 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
7216 {
7217     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
7218
7219     TRACE("(%p %x)\n", this, flags);
7220
7221     if(flags & 2) {
7222         /* we have an array, with the number of elements stored before the first object */
7223         INT_PTR i, *ptr = (INT_PTR *)this-1;
7224
7225         for(i=*ptr-1; i>=0; i--)
7226             basic_istream_char_vbase_dtor(this+i);
7227         MSVCRT_operator_delete(ptr);
7228     } else {
7229         basic_istream_char_vbase_dtor(this);
7230         if(flags & 1)
7231             MSVCRT_operator_delete(this);
7232     }
7233
7234     return this;
7235 }
7236
7237 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
7238 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
7239 DEFINE_THISCALL_WRAPPER(basic_istream_char__Ipfx, 8)
7240 MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
7241 {
7242     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7243
7244     TRACE("(%p %d)\n", this, noskip);
7245
7246     if(ios_base_good(&base->base)) {
7247         if(basic_ios_char_tie_get(base))
7248             basic_ostream_char_flush(basic_ios_char_tie_get(base));
7249
7250         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
7251             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7252             const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
7253             int ch;
7254
7255             for(ch = basic_streambuf_char_sgetc(strbuf); ;
7256                     ch = basic_streambuf_char_snextc(strbuf)) {
7257                 if(ch == EOF) {
7258                     basic_ios_char_setstate(base, IOSTATE_eofbit);
7259                     break;
7260                 }
7261
7262                 if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
7263                     break;
7264             }
7265         }
7266     }
7267
7268     if(!ios_base_good(&base->base)) {
7269         basic_ios_char_setstate(base, IOSTATE_failbit);
7270         return FALSE;
7271     }
7272
7273     return TRUE;
7274 }
7275
7276 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
7277 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
7278 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
7279 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
7280 {
7281     return basic_istream_char__Ipfx(this, noskip);
7282 }
7283
7284 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
7285 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
7286 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
7287 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
7288 {
7289     TRACE("(%p)\n", this);
7290 }
7291
7292 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
7293 {
7294     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
7295
7296     if(basic_ios_char_rdbuf_get(base))
7297         basic_streambuf_char__Lock(base->strbuf);
7298
7299     return basic_istream_char_ipfx(istr, noskip);
7300 }
7301
7302 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
7303 {
7304     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
7305
7306     if(basic_ios_char_rdbuf_get(base))
7307         basic_streambuf_char__Unlock(base->strbuf);
7308 }
7309
7310 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
7311 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
7312 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
7313 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
7314 {
7315     TRACE("(%p)\n", this);
7316     return this->count;
7317 }
7318
7319 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7320 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7321 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
7322 int __thiscall basic_istream_char_get(basic_istream_char *this)
7323 {
7324     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7325     int ret;
7326
7327     TRACE("(%p)\n", this);
7328
7329     this->count = 0;
7330
7331     if(!basic_istream_char_sentry_create(this, TRUE)) {
7332         basic_istream_char_sentry_destroy(this);
7333         return EOF;
7334     }
7335
7336     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
7337     basic_istream_char_sentry_destroy(this);
7338     if(ret == EOF)
7339         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
7340     else
7341         this->count++;
7342
7343     return ret;
7344 }
7345
7346 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
7347 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
7348 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
7349 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
7350 {
7351     int ret;
7352
7353     TRACE("(%p %p)\n", this, ch);
7354
7355     ret = basic_istream_char_get(this);
7356     if(ret != EOF)
7357         *ch = (char)ret;
7358     return this;
7359 }
7360
7361 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7362 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7363 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
7364 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7365 {
7366     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7367     int ch = delim;
7368
7369     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7370
7371     this->count = 0;
7372
7373     if(basic_istream_char_sentry_create(this, TRUE)) {
7374         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7375
7376         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
7377                 ch = basic_streambuf_char_snextc(strbuf)) {
7378             if(ch==EOF || ch==delim)
7379                 break;
7380
7381             *str++ = ch;
7382             this->count++;
7383             count--;
7384         }
7385     }
7386     basic_istream_char_sentry_destroy(this);
7387
7388     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7389             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7390     if(count > 0)
7391         *str = 0;
7392     return this;
7393 }
7394
7395 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7396 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7397 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
7398 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
7399 {
7400     return basic_istream_char_get_str_delim(this, str, count, '\n');
7401 }
7402
7403 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7404 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7405 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
7406 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
7407 {
7408     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7409     int ch = delim;
7410
7411     TRACE("(%p %p %c)\n", this, strbuf, delim);
7412
7413     this->count = 0;
7414
7415     if(basic_istream_char_sentry_create(this, TRUE)) {
7416         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
7417
7418         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
7419                 ch = basic_streambuf_char_snextc(strbuf_read)) {
7420             if(ch==EOF || ch==delim)
7421                 break;
7422
7423             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
7424                 break;
7425             this->count++;
7426         }
7427     }
7428     basic_istream_char_sentry_destroy(this);
7429
7430     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7431             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7432     return this;
7433 }
7434
7435 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7436 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7437 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
7438 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
7439 {
7440     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
7441 }
7442
7443 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7444 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7445 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
7446 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7447 {
7448     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7449     int ch = (unsigned char)delim;
7450
7451     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7452
7453     this->count = 0;
7454
7455     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
7456         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7457
7458         while(count > 1) {
7459             ch = basic_streambuf_char_sbumpc(strbuf);
7460
7461             if(ch==EOF || ch==(unsigned char)delim)
7462                 break;
7463
7464             *str++ = ch;
7465             this->count++;
7466             count--;
7467         }
7468
7469         if(ch == (unsigned char)delim)
7470             this->count++;
7471         else if(ch != EOF) {
7472             ch = basic_streambuf_char_sgetc(strbuf);
7473
7474             if(ch == (unsigned char)delim) {
7475                 basic_streambuf_char__Gninc(strbuf);
7476                 this->count++;
7477             }
7478         }
7479     }
7480     basic_istream_char_sentry_destroy(this);
7481
7482     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
7483             (!this->count || (ch!=(unsigned char)delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
7484     if(count > 0)
7485         *str = 0;
7486     return this;
7487 }
7488
7489 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7490 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7491 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
7492 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
7493 {
7494     return basic_istream_char_getline_delim(this, str, count, '\n');
7495 }
7496
7497 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
7498 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7499 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
7500 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
7501 {
7502     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7503     int ch = (unsigned char)delim;
7504     unsigned int state;
7505
7506     TRACE("(%p %ld %d)\n", this, count, delim);
7507
7508     this->count = 0;
7509
7510     if(basic_istream_char_sentry_create(this, TRUE)) {
7511         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7512         state = IOSTATE_goodbit;
7513
7514         while(count > 0) {
7515             ch = basic_streambuf_char_sbumpc(strbuf);
7516
7517             if(ch==EOF) {
7518                 state = IOSTATE_eofbit;
7519                 break;
7520             }
7521
7522             if(ch==(unsigned char)delim)
7523                 break;
7524
7525             this->count++;
7526             if(count != INT_MAX)
7527                 count--;
7528         }
7529     }else
7530         state = IOSTATE_failbit;
7531     basic_istream_char_sentry_destroy(this);
7532
7533     basic_ios_char_setstate(base, state);
7534     return this;
7535 }
7536
7537 /* ?ws@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@1@AAV21@@Z */
7538 /* ?ws@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
7539 basic_istream_char* __cdecl ws_basic_istream_char(basic_istream_char *istream)
7540 {
7541     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7542     int ch = '\n';
7543
7544     TRACE("(%p)\n", istream);
7545
7546     if(basic_istream_char_sentry_create(istream, TRUE)) {
7547         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7548         const ctype_char *ctype = ctype_char_use_facet(strbuf->loc);
7549
7550         for(ch = basic_streambuf_char_sgetc(strbuf); ctype_char_is_ch(ctype, _SPACE, ch);
7551                 ch = basic_streambuf_char_snextc(strbuf)) {
7552             if(ch == EOF)
7553                 break;
7554         }
7555     }
7556     basic_istream_char_sentry_destroy(istream);
7557
7558     if(ch == EOF)
7559         basic_ios_char_setstate(base, IOSTATE_eofbit);
7560     return istream;
7561 }
7562
7563 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7564 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7565 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
7566 int __thiscall basic_istream_char_peek(basic_istream_char *this)
7567 {
7568     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7569     int ret = EOF;
7570
7571     TRACE("(%p)\n", this);
7572
7573     this->count = 0;
7574
7575     if(basic_istream_char_sentry_create(this, TRUE))
7576         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7577     basic_istream_char_sentry_destroy(this);
7578     return ret;
7579 }
7580
7581 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
7582 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
7583 DEFINE_THISCALL_WRAPPER(basic_istream_char__Read_s, 16)
7584 basic_istream_char* __thiscall basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7585 {
7586     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7587     IOSB_iostate state = IOSTATE_goodbit;
7588
7589     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7590
7591     if(basic_istream_char_sentry_create(this, TRUE)) {
7592         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7593
7594         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
7595         if(this->count != count)
7596             state |= IOSTATE_failbit | IOSTATE_eofbit;
7597     }else {
7598         this->count = 0;
7599     }
7600     basic_istream_char_sentry_destroy(this);
7601
7602     basic_ios_char_setstate(base, state);
7603     return this;
7604 }
7605
7606 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7607 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7608 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
7609 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
7610 {
7611     return basic_istream_char__Read_s(this, str, count, count);
7612 }
7613
7614 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
7615 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
7616 DEFINE_THISCALL_WRAPPER(basic_istream_char__Readsome_s, 16)
7617 streamsize __thiscall basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7618 {
7619     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7620     IOSB_iostate state = IOSTATE_goodbit;
7621
7622     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7623
7624     this->count = 0;
7625
7626     if(basic_istream_char_sentry_create(this, TRUE)) {
7627         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
7628         if(avail > count)
7629             avail = count;
7630
7631         if(avail == -1)
7632             state |= IOSTATE_eofbit;
7633         else if(avail > 0)
7634             basic_istream_char__Read_s(this, str, size, avail);
7635     }else {
7636         state |= IOSTATE_failbit;
7637     }
7638     basic_istream_char_sentry_destroy(this);
7639
7640     basic_ios_char_setstate(base, state);
7641     return this->count;
7642 }
7643
7644 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
7645 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
7646 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
7647 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
7648 {
7649     return basic_istream_char__Readsome_s(this, str, count, count);
7650 }
7651
7652 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
7653 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
7654 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
7655 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
7656 {
7657     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7658     IOSB_iostate state = IOSTATE_goodbit;
7659
7660     TRACE("(%p %c)\n", this, ch);
7661
7662     this->count = 0;
7663
7664     if(basic_istream_char_sentry_create(this, TRUE)) {
7665         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7666
7667         if(!ios_base_good(&base->base))
7668             state |= IOSTATE_failbit;
7669         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
7670             state |= IOSTATE_badbit;
7671     }
7672     basic_istream_char_sentry_destroy(this);
7673
7674     basic_ios_char_setstate(base, state);
7675     return this;
7676 }
7677
7678 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
7679 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
7680 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
7681 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
7682 {
7683     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7684     IOSB_iostate state = IOSTATE_goodbit;
7685
7686     TRACE("(%p)\n", this);
7687
7688     this->count = 0;
7689
7690     if(basic_istream_char_sentry_create(this, TRUE)) {
7691         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7692
7693         if(!ios_base_good(&base->base))
7694             state |= IOSTATE_failbit;
7695         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
7696             state |= IOSTATE_badbit;
7697     }
7698     basic_istream_char_sentry_destroy(this);
7699
7700     basic_ios_char_setstate(base, state);
7701     return this;
7702 }
7703
7704 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7705 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7706 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
7707 int __thiscall basic_istream_char_sync(basic_istream_char *this)
7708 {
7709     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7710     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7711
7712     TRACE("(%p)\n", this);
7713
7714     if(!strbuf)
7715         return -1;
7716
7717     if(basic_istream_char_sentry_create(this, TRUE)) {
7718         if(basic_streambuf_char_pubsync(strbuf) != -1) {
7719             basic_istream_char_sentry_destroy(this);
7720             return 0;
7721         }
7722     }
7723     basic_istream_char_sentry_destroy(this);
7724
7725     basic_ios_char_setstate(base, IOSTATE_badbit);
7726     return -1;
7727 }
7728
7729 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7730 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7731 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
7732 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
7733 {
7734     TRACE("(%p %p)\n", this, ret);
7735
7736     if(basic_istream_char_sentry_create(this, TRUE)) {
7737         basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7738         if(!ios_base_fail(&base->base)) {
7739             basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
7740                     ret, 0, SEEKDIR_cur, OPENMODE_in);
7741             basic_istream_char_sentry_destroy(this);
7742
7743             if(ret->off==0 && ret->pos==-1 && ret->state==0)
7744                 basic_ios_char_setstate(base, IOSTATE_failbit);
7745             return ret;
7746         }
7747     }
7748     basic_istream_char_sentry_destroy(this);
7749
7750     ret->off = 0;
7751     ret->pos = -1;
7752     ret->state = 0;
7753     return ret;
7754 }
7755
7756 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
7757 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7758 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
7759 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
7760 {
7761     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7762
7763     TRACE("(%p %ld %d)\n", this, off, dir);
7764
7765     if(!ios_base_fail(&base->base)) {
7766         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7767         fpos_int ret;
7768
7769         basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
7770
7771         if(ret.off==0 && ret.pos==-1 && ret.state==0)
7772             basic_ios_char_setstate(base, IOSTATE_failbit);
7773         else
7774             basic_ios_char_clear(base, IOSTATE_goodbit);
7775         return this;
7776     }else
7777         basic_ios_char_clear(base, IOSTATE_goodbit);
7778
7779     return this;
7780 }
7781
7782 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7783 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7784 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
7785 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
7786 {
7787     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7788
7789     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7790
7791     if(!ios_base_fail(&base->base)) {
7792         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7793         fpos_int ret;
7794
7795         basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7796         basic_istream_char_sentry_destroy(this);
7797
7798         if(ret.off==0 && ret.pos==-1 && ret.state==0)
7799             basic_ios_char_setstate(base, IOSTATE_failbit);
7800         else
7801             basic_ios_char_clear(base, IOSTATE_goodbit);
7802         return this;
7803     }else
7804         basic_ios_char_clear(base, IOSTATE_goodbit);
7805
7806     return this;
7807 }
7808
7809 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
7810 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
7811 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
7812 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
7813 {
7814     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7815     int state = IOSTATE_goodbit;
7816
7817     TRACE("(%p %p)\n", this, v);
7818
7819     if(basic_istream_char_sentry_create(this, FALSE)) {
7820         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7821         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7822         istreambuf_iterator_char first={0}, last={0};
7823         LONG tmp;
7824
7825         first.strbuf = strbuf;
7826         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7827
7828         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7829             *v = tmp;
7830         else
7831             state |= IOSTATE_failbit;
7832     }
7833     basic_istream_char_sentry_destroy(this);
7834
7835     basic_ios_char_setstate(base, state);
7836     return this;
7837 }
7838
7839 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
7840 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
7841 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
7842 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
7843 {
7844     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7845     int state = IOSTATE_goodbit;
7846
7847     TRACE("(%p %p)\n", this, v);
7848
7849     if(basic_istream_char_sentry_create(this, FALSE)) {
7850         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7851         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7852         istreambuf_iterator_char first={0}, last={0};
7853
7854         first.strbuf = strbuf;
7855         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
7856     }
7857     basic_istream_char_sentry_destroy(this);
7858
7859     basic_ios_char_setstate(base, state);
7860     return this;
7861 }
7862
7863 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
7864 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
7865 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
7866 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
7867 {
7868     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7869     int state = IOSTATE_goodbit;
7870
7871     TRACE("(%p %p)\n", this, v);
7872
7873     if(basic_istream_char_sentry_create(this, FALSE)) {
7874         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7875         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7876         istreambuf_iterator_char first={0}, last={0};
7877
7878         first.strbuf = strbuf;
7879         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7880     }
7881     basic_istream_char_sentry_destroy(this);
7882
7883     basic_ios_char_setstate(base, state);
7884     return this;
7885 }
7886
7887 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
7888 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
7889 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
7890 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *v)
7891 {
7892     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7893     int state = IOSTATE_goodbit;
7894
7895     TRACE("(%p %p)\n", this, v);
7896
7897     if(basic_istream_char_sentry_create(this, FALSE)) {
7898         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7899         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7900         istreambuf_iterator_char first={0}, last={0};
7901
7902         first.strbuf = strbuf;
7903         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
7904     }
7905     basic_istream_char_sentry_destroy(this);
7906
7907     basic_ios_char_setstate(base, state);
7908     return this;
7909 }
7910
7911 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
7912 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
7913 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
7914 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
7915 {
7916     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7917     int state = IOSTATE_goodbit;
7918
7919     TRACE("(%p %p)\n", this, v);
7920
7921     if(basic_istream_char_sentry_create(this, FALSE)) {
7922         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7923         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7924         istreambuf_iterator_char first={0}, last={0};
7925
7926         first.strbuf = strbuf;
7927         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7928     }
7929     basic_istream_char_sentry_destroy(this);
7930
7931     basic_ios_char_setstate(base, state);
7932     return this;
7933 }
7934
7935 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
7936 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
7937 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
7938 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
7939 {
7940     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7941     int state = IOSTATE_goodbit;
7942
7943     TRACE("(%p %p)\n", this, v);
7944
7945     if(basic_istream_char_sentry_create(this, FALSE)) {
7946         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7947         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7948         istreambuf_iterator_char first={0}, last={0};
7949
7950         first.strbuf = strbuf;
7951         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
7952     }
7953     basic_istream_char_sentry_destroy(this);
7954
7955     basic_ios_char_setstate(base, state);
7956     return this;
7957 }
7958
7959 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
7960 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
7961 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
7962 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
7963 {
7964     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7965     int state = IOSTATE_goodbit;
7966
7967     TRACE("(%p %p)\n", this, v);
7968
7969     if(basic_istream_char_sentry_create(this, FALSE)) {
7970         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7971         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7972         istreambuf_iterator_char first={0}, last={0};
7973
7974         first.strbuf = strbuf;
7975         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
7976     }
7977     basic_istream_char_sentry_destroy(this);
7978
7979     basic_ios_char_setstate(base, state);
7980     return this;
7981 }
7982
7983 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
7984 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
7985 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
7986 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
7987 {
7988     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7989     int state = IOSTATE_goodbit;
7990
7991     TRACE("(%p %p)\n", this, v);
7992
7993     if(basic_istream_char_sentry_create(this, FALSE)) {
7994         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7995         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7996         istreambuf_iterator_char first={0}, last={0};
7997
7998         first.strbuf = strbuf;
7999         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
8000     }
8001     basic_istream_char_sentry_destroy(this);
8002
8003     basic_ios_char_setstate(base, state);
8004     return this;
8005 }
8006
8007 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
8008 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
8009 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
8010 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
8011 {
8012     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8013     int state = IOSTATE_goodbit;
8014
8015     TRACE("(%p %p)\n", this, v);
8016
8017     if(basic_istream_char_sentry_create(this, FALSE)) {
8018         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8019         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8020         istreambuf_iterator_char first={0}, last={0};
8021
8022         first.strbuf = strbuf;
8023         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
8024     }
8025     basic_istream_char_sentry_destroy(this);
8026
8027     basic_ios_char_setstate(base, state);
8028     return this;
8029 }
8030
8031 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
8032 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
8033 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
8034 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
8035 {
8036     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8037     int state = IOSTATE_goodbit;
8038
8039     TRACE("(%p %p)\n", this, v);
8040
8041     if(basic_istream_char_sentry_create(this, FALSE)) {
8042         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8043         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8044         istreambuf_iterator_char first={0}, last={0};
8045
8046         first.strbuf = strbuf;
8047         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
8048     }
8049     basic_istream_char_sentry_destroy(this);
8050
8051     basic_ios_char_setstate(base, state);
8052     return this;
8053 }
8054
8055 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
8056 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
8057 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
8058 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
8059 {
8060     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8061     int state = IOSTATE_goodbit;
8062
8063     TRACE("(%p %p)\n", this, v);
8064
8065     if(basic_istream_char_sentry_create(this, FALSE)) {
8066         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8067         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8068         istreambuf_iterator_char first={0}, last={0};
8069
8070         first.strbuf = strbuf;
8071         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
8072     }
8073     basic_istream_char_sentry_destroy(this);
8074
8075     basic_ios_char_setstate(base, state);
8076     return this;
8077 }
8078
8079 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
8080 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
8081 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
8082 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
8083 {
8084     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8085     int state = IOSTATE_goodbit;
8086
8087     TRACE("(%p %p)\n", this, v);
8088
8089     if(basic_istream_char_sentry_create(this, FALSE)) {
8090         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8091         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8092         istreambuf_iterator_char first={0}, last={0};
8093
8094         first.strbuf = strbuf;
8095         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
8096     }
8097     basic_istream_char_sentry_destroy(this);
8098
8099     basic_ios_char_setstate(base, state);
8100     return this;
8101 }
8102
8103 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
8104 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
8105 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
8106 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
8107 {
8108     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8109     int state = IOSTATE_goodbit;
8110
8111     TRACE("(%p %p)\n", this, v);
8112
8113     if(basic_istream_char_sentry_create(this, FALSE)) {
8114         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8115         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8116         istreambuf_iterator_char first={0}, last={0};
8117
8118         first.strbuf = strbuf;
8119         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
8120     }
8121     basic_istream_char_sentry_destroy(this);
8122
8123     basic_ios_char_setstate(base, state);
8124     return this;
8125 }
8126
8127 /* ??$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 */
8128 /* ??$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 */
8129 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
8130         basic_istream_char *istream, basic_string_char *str, char delim)
8131 {
8132     IOSB_iostate state = IOSTATE_failbit;
8133     int c = (unsigned char)delim;
8134
8135     TRACE("(%p %p %c)\n", istream, str, delim);
8136
8137     if(basic_istream_char_sentry_create(istream, TRUE)) {
8138         MSVCP_basic_string_char_clear(str);
8139
8140         c = basic_istream_char_get(istream);
8141         if(c != EOF)
8142             state = IOSTATE_goodbit;
8143
8144         for(; c!=(unsigned char)delim && c!=EOF; c = basic_istream_char_get(istream)) {
8145             state = IOSTATE_goodbit;
8146             MSVCP_basic_string_char_append_ch(str, c);
8147         }
8148     }
8149     basic_istream_char_sentry_destroy(istream);
8150
8151     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
8152         state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8153     return istream;
8154 }
8155
8156 /* ??$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 */
8157 /* ??$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 */
8158 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
8159         basic_istream_char *istream, basic_string_char *str)
8160 {
8161     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
8162 }
8163
8164 /* ??$?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 */
8165 /* ??$?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 */
8166 basic_istream_char* __cdecl basic_istream_char_read_bstr(
8167         basic_istream_char *istream, basic_string_char *str)
8168 {
8169     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
8170     IOSB_iostate state = IOSTATE_failbit;
8171     int c = '\n';
8172
8173     TRACE("(%p %p)\n", istream, str);
8174
8175     if(basic_istream_char_sentry_create(istream, FALSE)) {
8176         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
8177         MSVCP_size_t count = ios_base_width_get(&base->base);
8178
8179         if(!count)
8180             count = -1;
8181
8182         MSVCP_basic_string_char_clear(str);
8183
8184         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
8185                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8186                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
8187             state = IOSTATE_goodbit;
8188             MSVCP_basic_string_char_append_ch(str, c);
8189         }
8190     }
8191     basic_istream_char_sentry_destroy(istream);
8192
8193     ios_base_width_set(&base->base, 0);
8194     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8195     return istream;
8196 }
8197
8198 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z */
8199 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z */
8200 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAC@Z */
8201 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAC@Z */
8202 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAE@Z */
8203 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAE@Z */
8204 basic_istream_char* __cdecl basic_istream_char_read_str(basic_istream_char *istream, char *str)
8205 {
8206     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
8207     IOSB_iostate state = IOSTATE_failbit;
8208     int c = '\n';
8209
8210     TRACE("(%p %p)\n", istream, str);
8211
8212     if(basic_istream_char_sentry_create(istream, FALSE)) {
8213         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
8214         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
8215
8216         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
8217                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8218                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
8219             state = IOSTATE_goodbit;
8220             *str++ = c;
8221         }
8222     }
8223     basic_istream_char_sentry_destroy(istream);
8224
8225     *str = 0;
8226     ios_base_width_set(&base->base, 0);
8227     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8228     return istream;
8229 }
8230
8231 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z */
8232 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAD@Z */
8233 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z */
8234 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAC@Z */
8235 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z */
8236 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAE@Z */
8237 basic_istream_char* __cdecl basic_istream_char_read_ch(basic_istream_char *istream, char *ch)
8238 {
8239     IOSB_iostate state = IOSTATE_failbit;
8240     int c = 0;
8241
8242     TRACE("(%p %p)\n", istream, ch);
8243
8244     if(basic_istream_char_sentry_create(istream, FALSE)) {
8245         c = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(
8246                     basic_istream_char_get_basic_ios(istream)));
8247         if(c != EOF) {
8248             state = IOSTATE_goodbit;
8249             *ch = c;
8250         }
8251     }
8252     basic_istream_char_sentry_destroy(istream);
8253
8254     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
8255             state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8256     return istream;
8257 }
8258
8259 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
8260 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
8261 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
8262 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
8263         basic_istream_char *this, basic_streambuf_char *streambuf)
8264 {
8265     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8266     IOSB_iostate state = IOSTATE_failbit;
8267     int c = '\n';
8268
8269     TRACE("(%p %p)\n", this, streambuf);
8270
8271     if(basic_istream_char_sentry_create(this, FALSE)) {
8272         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
8273                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
8274             state = IOSTATE_goodbit;
8275             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
8276                 break;
8277         }
8278     }
8279     basic_istream_char_sentry_destroy(this);
8280
8281     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8282     return this;
8283 }
8284
8285 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
8286 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
8287 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
8288 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
8289         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
8290 {
8291     TRACE("(%p %p)\n", this, pfunc);
8292     pfunc(this);
8293     return this;
8294 }
8295
8296 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
8297 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
8298 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
8299 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
8300         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
8301 {
8302     TRACE("(%p %p)\n", this, pfunc);
8303     pfunc(basic_istream_char_get_basic_ios(this));
8304     return this;
8305 }
8306
8307 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
8308 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
8309 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
8310 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
8311         ios_base* (__cdecl *pfunc)(ios_base*))
8312 {
8313     TRACE("(%p %p)\n", this, pfunc);
8314     pfunc(&basic_istream_char_get_basic_ios(this)->base);
8315     return this;
8316 }
8317
8318 /* Caution: basic_istream uses virtual inheritance. */
8319 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
8320 {
8321     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
8322 }
8323
8324 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
8325 {
8326     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
8327 }
8328
8329 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
8330 {
8331     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
8332 }
8333
8334 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
8335 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
8336 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_init, 20)
8337 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_init(basic_istream_wchar *this,
8338         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
8339 {
8340     basic_ios_wchar *base;
8341
8342     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
8343
8344     if(virt_init) {
8345         this->vbtable = basic_istream_wchar_vbtable;
8346         base = basic_istream_wchar_get_basic_ios(this);
8347         basic_ios_wchar_ctor(base);
8348     }else {
8349         base = basic_istream_wchar_get_basic_ios(this);
8350     }
8351
8352     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8353     this->count = 0;
8354     if(!noinit)
8355         basic_ios_wchar_init(base, strbuf, isstd);
8356     return this;
8357 }
8358
8359 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
8360 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
8361 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_init, 20)
8362 basic_istream_wchar* __thiscall basic_istream_short_ctor_init(basic_istream_wchar *this,
8363         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
8364 {
8365     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
8366     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8367     return this;
8368 }
8369
8370 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8371 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8372 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor, 16)
8373 basic_istream_wchar* __thiscall basic_istream_wchar_ctor(basic_istream_wchar *this,
8374         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8375 {
8376     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8377 }
8378
8379 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8380 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8381 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor, 16)
8382 basic_istream_wchar* __thiscall basic_istream_short_ctor(basic_istream_wchar *this,
8383         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8384 {
8385     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8386 }
8387
8388 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8389 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8390 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_uninitialized, 12)
8391 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_uninitialized(
8392         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8393 {
8394     basic_ios_wchar *base;
8395
8396     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
8397
8398     if(virt_init) {
8399         this->vbtable = basic_istream_wchar_vbtable;
8400         base = basic_istream_wchar_get_basic_ios(this);
8401         basic_ios_wchar_ctor(base);
8402     }else {
8403         base = basic_istream_wchar_get_basic_ios(this);
8404     }
8405
8406     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8407     ios_base_Addstd(&base->base);
8408     return this;
8409 }
8410
8411 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8412 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8413 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
8414 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
8415         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8416 {
8417     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
8418     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8419     return this;
8420 }
8421
8422 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
8423 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
8424 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
8425 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
8426 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
8427 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
8428 {
8429     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8430
8431     /* don't destroy virtual base here */
8432     TRACE("(%p)\n", this);
8433 }
8434
8435 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8436 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8437 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8438 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8439 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
8440 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
8441 {
8442     TRACE("(%p)\n", this);
8443     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
8444     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
8445 }
8446
8447 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
8448 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
8449 {
8450     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8451
8452     TRACE("(%p %x)\n", this, flags);
8453
8454     if(flags & 2) {
8455         /* we have an array, with the number of elements stored before the first object */
8456         INT_PTR i, *ptr = (INT_PTR *)this-1;
8457
8458         for(i=*ptr-1; i>=0; i--)
8459             basic_istream_wchar_vbase_dtor(this+i);
8460         MSVCRT_operator_delete(ptr);
8461     } else {
8462         basic_istream_wchar_vbase_dtor(this);
8463         if(flags & 1)
8464             MSVCRT_operator_delete(this);
8465     }
8466
8467     return this;
8468 }
8469
8470 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8471 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8472 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8473 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8474 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Ipfx, 8)
8475 MSVCP_bool __thiscall basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8476 {
8477     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8478
8479     TRACE("(%p %d)\n", this, noskip);
8480
8481     if(ios_base_good(&base->base)) {
8482         if(basic_ios_wchar_tie_get(base))
8483             basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
8484
8485         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
8486             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8487             const ctype_wchar *ctype = ctype_wchar_use_facet(base->strbuf->loc);
8488             int ch;
8489
8490             for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
8491                     ch = basic_streambuf_wchar_snextc(strbuf)) {
8492                 if(ch == WEOF) {
8493                     basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8494                     break;
8495                 }
8496
8497                 if(!ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
8498                     break;
8499             }
8500         }
8501     }
8502
8503     if(!ios_base_good(&base->base)) {
8504         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8505         return FALSE;
8506     }
8507     return TRUE;
8508 }
8509
8510 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8511 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8512 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8513 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8514 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
8515 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8516 {
8517     return basic_istream_wchar__Ipfx(this, noskip);
8518 }
8519
8520 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8521 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8522 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8523 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8524 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
8525 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
8526 {
8527     TRACE("(%p)\n", this);
8528 }
8529
8530 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
8531 {
8532     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8533
8534     if(basic_ios_wchar_rdbuf_get(base))
8535         basic_streambuf_wchar__Lock(base->strbuf);
8536
8537     return basic_istream_wchar_ipfx(istr, noskip);
8538 }
8539
8540 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
8541 {
8542     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8543
8544     if(basic_ios_wchar_rdbuf_get(base))
8545         basic_streambuf_wchar__Unlock(base->strbuf);
8546 }
8547
8548 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
8549 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
8550 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
8551 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
8552 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
8553 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
8554 {
8555     TRACE("(%p)\n", this);
8556     return this->count;
8557 }
8558
8559 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8560 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8561 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8562 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8563 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
8564 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
8565 {
8566     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8567     int ret;
8568
8569     TRACE("(%p)\n", this);
8570
8571     this->count = 0;
8572
8573     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
8574         basic_istream_wchar_sentry_destroy(this);
8575         return WEOF;
8576     }
8577
8578     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
8579     basic_istream_wchar_sentry_destroy(this);
8580     if(ret == WEOF)
8581         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
8582     else
8583         this->count++;
8584
8585     return ret;
8586 }
8587
8588 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
8589 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
8590 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
8591 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
8592 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
8593 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
8594 {
8595     unsigned short ret;
8596
8597     TRACE("(%p %p)\n", this, ch);
8598
8599     ret = basic_istream_wchar_get(this);
8600     if(ret != WEOF)
8601         *ch = (wchar_t)ret;
8602     return this;
8603 }
8604
8605 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8606 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8607 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8608 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8609 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 16)
8610 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8611 {
8612     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8613     unsigned short ch = delim;
8614
8615     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8616
8617     this->count = 0;
8618
8619     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8620         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8621
8622         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
8623                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8624             if(ch==WEOF || ch==delim)
8625                 break;
8626
8627             *str++ = ch;
8628             this->count++;
8629             count--;
8630         }
8631     }
8632     basic_istream_wchar_sentry_destroy(this);
8633
8634     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8635             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8636     if(count > 0)
8637         *str = 0;
8638     return this;
8639 }
8640
8641 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8642 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8643 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8644 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8645 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 12)
8646 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
8647 {
8648     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
8649 }
8650
8651 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8652 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8653 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8654 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8655 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
8656 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
8657 {
8658     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8659     unsigned short ch = delim;
8660
8661     TRACE("(%p %p %c)\n", this, strbuf, delim);
8662
8663     this->count = 0;
8664
8665     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8666         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
8667
8668         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
8669                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
8670             if(ch==WEOF || ch==delim)
8671                 break;
8672
8673             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
8674                 break;
8675             this->count++;
8676         }
8677     }
8678     basic_istream_wchar_sentry_destroy(this);
8679
8680     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8681             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8682     return this;
8683 }
8684
8685 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8686 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8687 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8688 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8689 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
8690 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
8691 {
8692     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
8693 }
8694
8695 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8696 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8697 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8698 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8699 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 16)
8700 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8701 {
8702     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8703     unsigned short ch = delim;
8704
8705     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8706
8707     this->count = 0;
8708
8709     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
8710         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8711
8712         while(count > 1) {
8713             ch = basic_streambuf_wchar_sbumpc(strbuf);
8714
8715             if(ch==WEOF || ch==delim)
8716                 break;
8717
8718             *str++ = ch;
8719             this->count++;
8720             count--;
8721         }
8722
8723         if(ch == delim)
8724             this->count++;
8725         else if(ch != WEOF) {
8726             ch = basic_streambuf_wchar_sgetc(strbuf);
8727
8728             if(ch == delim) {
8729                 basic_streambuf_wchar__Gninc(strbuf);
8730                 this->count++;
8731             }
8732         }
8733     }
8734     basic_istream_wchar_sentry_destroy(this);
8735
8736     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
8737             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
8738     if(count > 0)
8739         *str = 0;
8740     return this;
8741 }
8742
8743 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8744 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8745 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8746 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8747 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 12)
8748 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
8749 {
8750     return basic_istream_wchar_getline_delim(this, str, count, '\n');
8751 }
8752
8753 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
8754 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
8755 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
8756 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
8757 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 12)
8758 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
8759 {
8760     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8761     unsigned short ch = delim;
8762     unsigned int state;
8763
8764     TRACE("(%p %ld %d)\n", this, count, delim);
8765
8766     this->count = 0;
8767
8768     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8769         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8770         state = IOSTATE_goodbit;
8771
8772         while(count > 0) {
8773             ch = basic_streambuf_wchar_sbumpc(strbuf);
8774
8775             if(ch==WEOF) {
8776                 state = IOSTATE_eofbit;
8777                 break;
8778             }
8779
8780             if(ch==delim)
8781                 break;
8782
8783             this->count++;
8784             if(count != INT_MAX)
8785                 count--;
8786         }
8787     }else
8788         state = IOSTATE_failbit;
8789     basic_istream_wchar_sentry_destroy(this);
8790
8791     basic_ios_wchar_setstate(base, state);
8792     return this;
8793 }
8794
8795 /* ?ws@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
8796 /* ?ws@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
8797 /* ?ws@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@1@AAV21@@Z */
8798 /* ?ws@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
8799 basic_istream_wchar* __cdecl ws_basic_istream_wchar(basic_istream_wchar *istream)
8800 {
8801     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8802     unsigned short ch = '\n';
8803
8804     TRACE("(%p)\n", istream);
8805
8806     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8807         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8808         const ctype_wchar *ctype = ctype_wchar_use_facet(strbuf->loc);
8809
8810         for(ch = basic_streambuf_wchar_sgetc(strbuf); ctype_wchar_is_ch(ctype, _SPACE, ch);
8811                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8812             if(ch == WEOF)
8813                 break;
8814         }
8815     }
8816     basic_istream_wchar_sentry_destroy(istream);
8817
8818     if(ch == WEOF)
8819         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8820     return istream;
8821 }
8822
8823 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8824 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8825 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8826 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8827 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
8828 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
8829 {
8830     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8831     unsigned short ret = WEOF;
8832
8833     TRACE("(%p)\n", this);
8834
8835     this->count = 0;
8836
8837     if(basic_istream_wchar_sentry_create(this, TRUE))
8838         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8839     basic_istream_wchar_sentry_destroy(this);
8840     return ret;
8841 }
8842
8843 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
8844 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
8845 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
8846 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
8847 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Read_s, 16)
8848 basic_istream_wchar* __thiscall basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8849 {
8850     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8851     IOSB_iostate state = IOSTATE_goodbit;
8852
8853     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8854
8855     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8856         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8857
8858         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
8859         if(this->count != count)
8860             state |= IOSTATE_failbit | IOSTATE_eofbit;
8861     }else {
8862         this->count = 0;
8863     }
8864     basic_istream_wchar_sentry_destroy(this);
8865
8866     basic_ios_wchar_setstate(base, state);
8867     return this;
8868 }
8869
8870 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8871 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8872 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8873 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8874 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 12)
8875 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
8876 {
8877     return basic_istream_wchar__Read_s(this, str, count, count);
8878 }
8879
8880 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
8881 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
8882 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
8883 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
8884 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Readsome_s, 16)
8885 streamsize __thiscall basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8886 {
8887     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8888     IOSB_iostate state = IOSTATE_goodbit;
8889
8890     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8891
8892     this->count = 0;
8893
8894     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8895         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
8896         if(avail > count)
8897             avail = count;
8898
8899         if(avail == -1)
8900             state |= IOSTATE_eofbit;
8901         else if(avail > 0)
8902             basic_istream_wchar__Read_s(this, str, size, avail);
8903     }else {
8904         state |= IOSTATE_failbit;
8905     }
8906     basic_istream_wchar_sentry_destroy(this);
8907
8908     basic_ios_wchar_setstate(base, state);
8909     return this->count;
8910 }
8911
8912 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
8913 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
8914 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
8915 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
8916 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 12)
8917 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
8918 {
8919     return basic_istream_wchar__Readsome_s(this, str, count, count);
8920 }
8921
8922 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
8923 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
8924 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
8925 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
8926 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
8927 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
8928 {
8929     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8930     IOSB_iostate state = IOSTATE_goodbit;
8931
8932     TRACE("(%p %c)\n", this, ch);
8933
8934     this->count = 0;
8935
8936     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8937         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8938
8939         if(!ios_base_good(&base->base))
8940             state |= IOSTATE_failbit;
8941         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
8942             state |= IOSTATE_badbit;
8943     }
8944     basic_istream_wchar_sentry_destroy(this);
8945
8946     basic_ios_wchar_setstate(base, state);
8947     return this;
8948 }
8949
8950 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
8951 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
8952 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
8953 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
8954 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
8955 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
8956 {
8957     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8958     IOSB_iostate state = IOSTATE_goodbit;
8959
8960     TRACE("(%p)\n", this);
8961
8962     this->count = 0;
8963
8964     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8965         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8966
8967         if(!ios_base_good(&base->base))
8968             state |= IOSTATE_failbit;
8969         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
8970             state |= IOSTATE_badbit;
8971     }
8972     basic_istream_wchar_sentry_destroy(this);
8973
8974     basic_ios_wchar_setstate(base, state);
8975     return this;
8976 }
8977
8978 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
8979 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
8980 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
8981 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
8982 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
8983 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
8984 {
8985     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8986     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8987
8988     TRACE("(%p)\n", this);
8989
8990     if(!strbuf)
8991         return -1;
8992
8993     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8994         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
8995             basic_istream_wchar_sentry_destroy(this);
8996             return 0;
8997         }
8998     }
8999     basic_istream_wchar_sentry_destroy(this);
9000
9001     basic_ios_wchar_setstate(base, IOSTATE_badbit);
9002     return -1;
9003 }
9004
9005 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
9006 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
9007 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
9008 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
9009 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
9010 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
9011 {
9012     TRACE("(%p %p)\n", this, ret);
9013
9014     if(basic_istream_wchar_sentry_create(this, TRUE)) {
9015         basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9016         if(!ios_base_fail(&base->base)) {
9017             basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
9018                     ret, 0, SEEKDIR_cur, OPENMODE_in);
9019             basic_istream_wchar_sentry_destroy(this);
9020
9021             if(ret->off==0 && ret->pos==-1 && ret->state==0)
9022                 basic_ios_wchar_setstate(base, IOSTATE_failbit);
9023             return ret;
9024         }
9025     }
9026     basic_istream_wchar_sentry_destroy(this);
9027
9028     ret->off = 0;
9029     ret->pos = -1;
9030     ret->state = 0;
9031     return ret;
9032 }
9033
9034 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
9035 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
9036 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
9037 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
9038 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 12)
9039 basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir)
9040 {
9041     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9042
9043     TRACE("(%p %ld %d)\n", this, off, dir);
9044
9045     if(!ios_base_fail(&base->base)) {
9046         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9047         fpos_int ret;
9048
9049         basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
9050         basic_istream_wchar_sentry_destroy(this);
9051
9052         if(ret.off==0 && ret.pos==-1 && ret.state==0)
9053             basic_ios_wchar_setstate(base, IOSTATE_failbit);
9054         else
9055             basic_ios_wchar_clear(base, IOSTATE_goodbit);
9056         return this;
9057     }else
9058         basic_ios_wchar_clear(base, IOSTATE_goodbit);
9059
9060     return this;
9061 }
9062
9063 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
9064 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
9065 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
9066 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
9067 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
9068 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
9069 {
9070     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9071
9072     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
9073
9074     if(!ios_base_fail(&base->base)) {
9075         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9076         fpos_int ret;
9077
9078         basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
9079         basic_istream_wchar_sentry_destroy(this);
9080
9081         if(ret.off==0 && ret.pos==-1 && ret.state==0)
9082             basic_ios_wchar_setstate(base, IOSTATE_failbit);
9083         else
9084             basic_ios_wchar_clear(base, IOSTATE_goodbit);
9085         return this;
9086     }else
9087         basic_ios_wchar_clear(base, IOSTATE_goodbit);
9088
9089     return this;
9090 }
9091
9092 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
9093 {
9094     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9095     int state = IOSTATE_goodbit;
9096
9097     TRACE("(%p %p)\n", this, v);
9098
9099     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9100         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9101         istreambuf_iterator_wchar first={0}, last={0};
9102         LONG tmp;
9103
9104         first.strbuf = strbuf;
9105         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
9106
9107         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
9108             *v = tmp;
9109         else
9110             state |= IOSTATE_failbit;
9111     }
9112     basic_istream_wchar_sentry_destroy(this);
9113
9114     basic_ios_wchar_setstate(base, state);
9115     return this;
9116 }
9117
9118 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAF@Z */
9119 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAF@Z */
9120 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_short, 8)
9121 basic_istream_wchar* __thiscall basic_istream_wchar_read_short(basic_istream_wchar *this, short *v)
9122 {
9123     return basic_istream_read_short(this, v, num_get_wchar_use_facet(
9124                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9125 }
9126
9127 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
9128 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
9129 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
9130 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
9131 {
9132     return basic_istream_read_short(this, v, num_get_short_use_facet(
9133                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9134 }
9135
9136 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAG@Z */
9137 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAG@Z */
9138 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ushort, 8)
9139 basic_istream_wchar* __thiscall basic_istream_wchar_read_ushort(basic_istream_wchar *this, unsigned short *v)
9140 {
9141     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9142     int state = IOSTATE_goodbit;
9143
9144     TRACE("(%p %p)\n", this, v);
9145
9146     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9147         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9148         const num_get *numget = num_get_wchar_use_facet(strbuf->loc);
9149         istreambuf_iterator_wchar first={0}, last={0};
9150
9151         first.strbuf = strbuf;
9152         num_get_wchar_get_ushort(numget, &last, first, last, &base->base, &state, v);
9153     }
9154     basic_istream_wchar_sentry_destroy(this);
9155
9156     basic_ios_wchar_setstate(base, state);
9157     return this;
9158 }
9159
9160 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
9161 {
9162     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9163     int state = IOSTATE_goodbit;
9164
9165     TRACE("(%p %p)\n", this, v);
9166
9167     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9168         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9169         istreambuf_iterator_wchar first={0}, last={0};
9170
9171         first.strbuf = strbuf;
9172         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
9173     }
9174     basic_istream_wchar_sentry_destroy(this);
9175
9176     basic_ios_wchar_setstate(base, state);
9177     return this;
9178 }
9179
9180 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAH@Z */
9181 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAH@Z */
9182 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int, 8)
9183 basic_istream_wchar* __thiscall basic_istream_wchar_read_int(basic_istream_wchar *this, int *v)
9184 {
9185     return basic_istream_read_int(this, v, num_get_wchar_use_facet(
9186                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9187 }
9188
9189 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
9190 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
9191 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
9192 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
9193 {
9194     return basic_istream_read_int(this, v, num_get_short_use_facet(
9195                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9196 }
9197
9198 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
9199 {
9200     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9201     int state = IOSTATE_goodbit;
9202
9203     TRACE("(%p %p)\n", this, v);
9204
9205     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9206         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9207         istreambuf_iterator_wchar first={0}, last={0};
9208
9209         first.strbuf = strbuf;
9210         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
9211     }
9212     basic_istream_wchar_sentry_destroy(this);
9213
9214     basic_ios_wchar_setstate(base, state);
9215     return this;
9216 }
9217
9218 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAI@Z */
9219 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAI@Z */
9220 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint, 8)
9221 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint(basic_istream_wchar *this, unsigned int *v)
9222 {
9223     return basic_istream_read_uint(this, v, num_get_wchar_use_facet(
9224                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9225 }
9226
9227 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
9228 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
9229 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
9230 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
9231 {
9232     return basic_istream_read_uint(this, v, num_get_short_use_facet(
9233                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9234 }
9235
9236 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
9237 {
9238     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9239     int state = IOSTATE_goodbit;
9240
9241     TRACE("(%p %p)\n", this, v);
9242
9243     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9244         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9245         istreambuf_iterator_wchar first={0}, last={0};
9246
9247         first.strbuf = strbuf;
9248         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
9249     }
9250     basic_istream_wchar_sentry_destroy(this);
9251
9252     basic_ios_wchar_setstate(base, state);
9253     return this;
9254 }
9255
9256 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
9257 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
9258 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_long, 8)
9259 basic_istream_wchar* __thiscall basic_istream_wchar_read_long(basic_istream_wchar *this, LONG *v)
9260 {
9261     return basic_istream_read_long(this, v, num_get_wchar_use_facet(
9262                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9263 }
9264
9265 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
9266 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
9267 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
9268 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
9269 {
9270     return basic_istream_read_long(this, v, num_get_short_use_facet(
9271                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9272 }
9273
9274 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
9275 {
9276     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9277     int state = IOSTATE_goodbit;
9278
9279     TRACE("(%p %p)\n", this, v);
9280
9281     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9282         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9283         istreambuf_iterator_wchar first={0}, last={0};
9284
9285         first.strbuf = strbuf;
9286         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
9287     }
9288     basic_istream_wchar_sentry_destroy(this);
9289
9290     basic_ios_wchar_setstate(base, state);
9291     return this;
9292 }
9293
9294 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAK@Z */
9295 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAK@Z */
9296 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ulong, 8)
9297 basic_istream_wchar* __thiscall basic_istream_wchar_read_ulong(basic_istream_wchar *this, ULONG *v)
9298 {
9299     return basic_istream_read_ulong(this, v, num_get_wchar_use_facet(
9300                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9301 }
9302
9303 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
9304 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
9305 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
9306 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
9307 {
9308     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
9309                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9310 }
9311
9312 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
9313 {
9314     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9315     int state = IOSTATE_goodbit;
9316
9317     TRACE("(%p %p)\n", this, v);
9318
9319     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9320         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9321         istreambuf_iterator_wchar first={0}, last={0};
9322
9323         first.strbuf = strbuf;
9324         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
9325     }
9326     basic_istream_wchar_sentry_destroy(this);
9327
9328     basic_ios_wchar_setstate(base, state);
9329     return this;
9330 }
9331
9332 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAM@Z */
9333 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAM@Z */
9334 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_float, 8)
9335 basic_istream_wchar* __thiscall basic_istream_wchar_read_float(basic_istream_wchar *this, float *v)
9336 {
9337     return basic_istream_read_float(this, v, num_get_wchar_use_facet(
9338                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9339 }
9340
9341 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
9342 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
9343 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
9344 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
9345 {
9346     return basic_istream_read_float(this, v, num_get_short_use_facet(
9347                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9348 }
9349
9350 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
9351 {
9352     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9353     int state = IOSTATE_goodbit;
9354
9355     TRACE("(%p %p)\n", this, v);
9356
9357     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9358         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9359         istreambuf_iterator_wchar first={0}, last={0};
9360
9361         first.strbuf = strbuf;
9362         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
9363     }
9364     basic_istream_wchar_sentry_destroy(this);
9365
9366     basic_ios_wchar_setstate(base, state);
9367     return this;
9368 }
9369
9370 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAN@Z */
9371 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAN@Z */
9372 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_double, 8)
9373 basic_istream_wchar* __thiscall basic_istream_wchar_read_double(basic_istream_wchar *this, double *v)
9374 {
9375     return basic_istream_read_double(this, v, num_get_wchar_use_facet(
9376                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9377 }
9378
9379 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
9380 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
9381 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
9382 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
9383 {
9384     return basic_istream_read_double(this, v, num_get_short_use_facet(
9385                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9386 }
9387
9388 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
9389 {
9390     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9391     int state = IOSTATE_goodbit;
9392
9393     TRACE("(%p %p)\n", this, v);
9394
9395     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9396         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9397         istreambuf_iterator_wchar first={0}, last={0};
9398
9399         first.strbuf = strbuf;
9400         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
9401     }
9402     basic_istream_wchar_sentry_destroy(this);
9403
9404     basic_ios_wchar_setstate(base, state);
9405     return this;
9406 }
9407
9408 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAO@Z */
9409 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAO@Z */
9410 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ldouble, 8)
9411 basic_istream_wchar* __thiscall basic_istream_wchar_read_ldouble(basic_istream_wchar *this, double *v)
9412 {
9413     return basic_istream_read_ldouble(this, v, num_get_wchar_use_facet(
9414                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9415 }
9416
9417 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
9418 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
9419 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
9420 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
9421 {
9422     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
9423                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9424 }
9425
9426 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
9427 {
9428     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9429     int state = IOSTATE_goodbit;
9430
9431     TRACE("(%p %p)\n", this, v);
9432
9433     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9434         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9435         istreambuf_iterator_wchar first={0}, last={0};
9436
9437         first.strbuf = strbuf;
9438         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
9439     }
9440     basic_istream_wchar_sentry_destroy(this);
9441
9442     basic_ios_wchar_setstate(base, state);
9443     return this;
9444 }
9445
9446 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAPAX@Z */
9447 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
9448 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ptr, 8)
9449 basic_istream_wchar* __thiscall basic_istream_wchar_read_ptr(basic_istream_wchar *this, void **v)
9450 {
9451     return basic_istream_read_ptr(this, v, num_get_wchar_use_facet(
9452                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9453 }
9454
9455 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
9456 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
9457 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
9458 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
9459 {
9460     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
9461                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9462 }
9463
9464 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
9465 {
9466     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9467     int state = IOSTATE_goodbit;
9468
9469     TRACE("(%p %p)\n", this, v);
9470
9471     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9472         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9473         istreambuf_iterator_wchar first={0}, last={0};
9474
9475         first.strbuf = strbuf;
9476         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
9477     }
9478     basic_istream_wchar_sentry_destroy(this);
9479
9480     basic_ios_wchar_setstate(base, state);
9481     return this;
9482 }
9483
9484 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_J@Z */
9485 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_J@Z */
9486 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int64, 8)
9487 basic_istream_wchar* __thiscall basic_istream_wchar_read_int64(basic_istream_wchar *this, __int64 *v)
9488 {
9489     return basic_istream_read_int64(this, v, num_get_wchar_use_facet(
9490                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9491 }
9492
9493 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
9494 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
9495 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
9496 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
9497 {
9498     return basic_istream_read_int64(this, v, num_get_short_use_facet(
9499                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9500 }
9501
9502 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
9503 {
9504     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9505     int state = IOSTATE_goodbit;
9506
9507     TRACE("(%p %p)\n", this, v);
9508
9509     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9510         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9511         istreambuf_iterator_wchar first={0}, last={0};
9512
9513         first.strbuf = strbuf;
9514         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
9515     }
9516     basic_istream_wchar_sentry_destroy(this);
9517
9518     basic_ios_wchar_setstate(base, state);
9519     return this;
9520 }
9521
9522 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_K@Z */
9523 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_K@Z */
9524 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint64, 8)
9525 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9526 {
9527     return basic_istream_read_uint64(this, v, num_get_wchar_use_facet(
9528                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9529 }
9530
9531 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
9532 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
9533 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
9534 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9535 {
9536     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
9537                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9538 }
9539
9540 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
9541 {
9542     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9543     int state = IOSTATE_goodbit;
9544
9545     TRACE("(%p %p)\n", this, v);
9546
9547     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9548         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9549         istreambuf_iterator_wchar first={0}, last={0};
9550
9551         first.strbuf = strbuf;
9552         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
9553     }
9554     basic_istream_wchar_sentry_destroy(this);
9555
9556     basic_ios_wchar_setstate(base, state);
9557     return this;
9558 }
9559
9560 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_N@Z */
9561 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_N@Z */
9562 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_bool, 8)
9563 basic_istream_wchar* __thiscall basic_istream_wchar_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9564 {
9565     return basic_istream_read_bool(this, v, num_get_wchar_use_facet(
9566                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9567 }
9568
9569 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
9570 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
9571 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
9572 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9573 {
9574     return basic_istream_read_bool(this, v, num_get_short_use_facet(
9575                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9576 }
9577
9578 /* ??$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 */
9579 /* ??$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 */
9580 /* ??$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 */
9581 /* ??$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 */
9582 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr_delim(
9583         basic_istream_wchar *istream, basic_string_wchar *str, wchar_t delim)
9584 {
9585     IOSB_iostate state = IOSTATE_failbit;
9586     int c = delim;
9587
9588     TRACE("(%p %p %c)\n", istream, str, delim);
9589
9590     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
9591         MSVCP_basic_string_wchar_clear(str);
9592
9593         c = basic_istream_wchar_get(istream);
9594         if(c != WEOF)
9595             state = IOSTATE_goodbit;
9596
9597         for(; c!=delim && c!=WEOF; c = basic_istream_wchar_get(istream)) {
9598             state = IOSTATE_goodbit;
9599             MSVCP_basic_string_wchar_append_ch(str, c);
9600         }
9601     }
9602     basic_istream_wchar_sentry_destroy(istream);
9603
9604     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9605             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9606     return istream;
9607 }
9608
9609 /* ??$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 */
9610 /* ??$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 */
9611 /* ??$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 */
9612 /* ??$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 */
9613 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr(
9614         basic_istream_wchar *istream, basic_string_wchar *str)
9615 {
9616     return basic_istream_wchar_getline_bstr_delim(istream, str, '\n');
9617 }
9618
9619 static basic_istream_wchar* basic_istream_read_bstr(basic_istream_wchar *istream,
9620         basic_string_wchar *str, const ctype_wchar *ctype)
9621 {
9622     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9623     IOSB_iostate state = IOSTATE_failbit;
9624     int c = '\n';
9625
9626     TRACE("(%p %p)\n", istream, str);
9627
9628     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9629         MSVCP_size_t count = ios_base_width_get(&base->base);
9630
9631         if(!count)
9632             count = -1;
9633
9634         MSVCP_basic_string_wchar_clear(str);
9635
9636         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9637                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9638                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9639             state = IOSTATE_goodbit;
9640             MSVCP_basic_string_wchar_append_ch(str, c);
9641         }
9642     }
9643     basic_istream_wchar_sentry_destroy(istream);
9644
9645     ios_base_width_set(&base->base, 0);
9646     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9647     return istream;
9648 }
9649
9650 /* ??$?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 */
9651 /* ??$?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 */
9652 basic_istream_wchar* __cdecl basic_istream_wchar_read_bstr(
9653         basic_istream_wchar *istream, basic_string_wchar *str)
9654 {
9655     return basic_istream_read_bstr(istream, str, ctype_wchar_use_facet(
9656                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9657 }
9658
9659 /* ??$?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 */
9660 /* ??$?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 */
9661 basic_istream_wchar* __cdecl basic_istream_short_read_bstr(
9662         basic_istream_wchar *istream, basic_string_wchar *str)
9663 {
9664     return basic_istream_read_bstr(istream, str, ctype_short_use_facet(
9665                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9666 }
9667
9668 static basic_istream_wchar* basic_istream_read_str(basic_istream_wchar *istream, wchar_t *str, const ctype_wchar *ctype)
9669 {
9670     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9671     IOSB_iostate state = IOSTATE_failbit;
9672     unsigned short c = '\n';
9673
9674     TRACE("(%p %p)\n", istream, str);
9675
9676     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9677         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
9678
9679         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9680                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9681                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9682             state = IOSTATE_goodbit;
9683             *str++ = c;
9684         }
9685     }
9686     basic_istream_wchar_sentry_destroy(istream);
9687
9688     *str = 0;
9689     ios_base_width_set(&base->base, 0);
9690     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9691     return istream;
9692 }
9693
9694 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@PA_W@Z */
9695 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@PEA_W@Z */
9696 basic_istream_wchar* __cdecl basic_istream_wchar_read_str(basic_istream_wchar *istream, wchar_t *str)
9697 {
9698     return basic_istream_read_str(istream, str, ctype_wchar_use_facet(
9699                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9700 }
9701
9702 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@PAG@Z */
9703 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@PEAG@Z */
9704 basic_istream_wchar* __cdecl basic_istream_short_read_str(basic_istream_wchar *istream, wchar_t *str)
9705 {
9706     return basic_istream_read_str(istream, str, ctype_short_use_facet(
9707                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9708 }
9709
9710 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AA_W@Z */
9711 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEA_W@Z */
9712 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAG@Z */
9713 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAG@Z */
9714 basic_istream_wchar* __cdecl basic_istream_wchar_read_ch(basic_istream_wchar *istream, wchar_t *ch)
9715 {
9716     IOSB_iostate state = IOSTATE_failbit;
9717     unsigned short c = 0;
9718
9719     TRACE("(%p %p)\n", istream, ch);
9720
9721     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9722         c = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(
9723                     basic_istream_wchar_get_basic_ios(istream)));
9724         if(c != WEOF) {
9725             state = IOSTATE_goodbit;
9726             *ch = c;
9727         }
9728     }
9729     basic_istream_wchar_sentry_destroy(istream);
9730
9731     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9732             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9733     return istream;
9734 }
9735
9736 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9737 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9738 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9739 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9740 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
9741 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
9742         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
9743 {
9744     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9745     IOSB_iostate state = IOSTATE_failbit;
9746     unsigned short c = '\n';
9747
9748     TRACE("(%p %p)\n", this, streambuf);
9749
9750     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9751         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
9752                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
9753             state = IOSTATE_goodbit;
9754             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
9755                 break;
9756         }
9757     }
9758     basic_istream_wchar_sentry_destroy(this);
9759
9760     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9761     return this;
9762 }
9763
9764 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9765 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9766 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9767 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9768 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
9769 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
9770         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
9771 {
9772     TRACE("(%p %p)\n", this, pfunc);
9773     pfunc(this);
9774     return this;
9775 }
9776
9777 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
9778 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
9779 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
9780 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
9781 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
9782 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
9783         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
9784 {
9785     TRACE("(%p %p)\n", this, pfunc);
9786     pfunc(basic_istream_wchar_get_basic_ios(this));
9787     return this;
9788 }
9789
9790 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9791 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9792 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9793 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9794 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
9795 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
9796         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
9797 {
9798     TRACE("(%p %p)\n", this, pfunc);
9799     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
9800     return this;
9801 }
9802
9803 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
9804 {
9805     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
9806 }
9807
9808 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
9809 {
9810     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
9811 }
9812
9813 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9814 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9815 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
9816 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
9817 {
9818     basic_ios_char *basic_ios;
9819
9820     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9821
9822     if(virt_init) {
9823         this->base1.vbtable = basic_iostream_char_vbtable1;
9824         this->base2.vbtable = basic_iostream_char_vbtable2;
9825         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9826         basic_ios_char_ctor(basic_ios);
9827     }else {
9828         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9829     }
9830
9831     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
9832
9833     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
9834     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9835     return this;
9836 }
9837
9838 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9839 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9840 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
9841 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
9842 {
9843     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9844
9845     TRACE("(%p)\n", this);
9846     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
9847     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
9848 }
9849
9850 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9851 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9852 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
9853 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
9854 {
9855     TRACE("(%p)\n", this);
9856     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
9857     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
9858 }
9859
9860 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
9861 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9862 {
9863     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9864
9865     TRACE("(%p %x)\n", this, flags);
9866
9867     if(flags & 2) {
9868         /* we have an array, with the number of elements stored before the first object */
9869         INT_PTR i, *ptr = (INT_PTR *)this-1;
9870
9871         for(i=*ptr-1; i>=0; i--)
9872             basic_iostream_char_vbase_dtor(this+i);
9873         MSVCRT_operator_delete(ptr);
9874     } else {
9875         basic_iostream_char_vbase_dtor(this);
9876         if(flags & 1)
9877             MSVCRT_operator_delete(this);
9878     }
9879
9880     return this;
9881 }
9882
9883 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
9884 {
9885     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
9886 }
9887
9888 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9889 {
9890     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
9891 }
9892
9893 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9894 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9895 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_ctor, 12)
9896 basic_iostream_wchar* __thiscall basic_iostream_wchar_ctor(basic_iostream_wchar *this,
9897         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9898 {
9899     basic_ios_wchar *basic_ios;
9900
9901     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9902
9903     if(virt_init) {
9904         this->base1.vbtable = basic_iostream_wchar_vbtable1;
9905         this->base2.vbtable = basic_iostream_wchar_vbtable2;
9906         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9907         basic_ios_wchar_ctor(basic_ios);
9908     }else {
9909         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9910     }
9911
9912     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
9913     basic_ostream_wchar_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9914
9915     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
9916     return this;
9917 }
9918
9919 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9920 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9921 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
9922 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
9923         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9924 {
9925     basic_iostream_wchar_ctor(this, strbuf, virt_init);
9926     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
9927     return this;
9928 }
9929
9930 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9931 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9932 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9933 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9934 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
9935 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
9936 {
9937     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9938
9939     TRACE("(%p)\n", this);
9940     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
9941     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
9942 }
9943
9944 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9945 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9946 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9947 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9948 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
9949 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
9950 {
9951     TRACE("(%p)\n", this);
9952     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
9953     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
9954 }
9955
9956 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
9957 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9958 {
9959     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9960
9961     TRACE("(%p %x)\n", this, flags);
9962
9963     if(flags & 2) {
9964         /* we have an array, with the number of elements stored before the first object */
9965         INT_PTR i, *ptr = (INT_PTR *)this-1;
9966
9967         for(i=*ptr-1; i>=0; i--)
9968             basic_iostream_wchar_vbase_dtor(this+i);
9969         MSVCRT_operator_delete(ptr);
9970     } else {
9971         basic_iostream_wchar_vbase_dtor(this);
9972         if(flags & 1)
9973             MSVCRT_operator_delete(this);
9974     }
9975
9976     return this;
9977 }
9978
9979 static inline basic_ios_char* basic_ofstream_char_to_basic_ios(basic_ofstream_char *ptr)
9980 {
9981     return (basic_ios_char*)((char*)ptr+basic_ofstream_char_vbtable[1]);
9982 }
9983
9984 static inline basic_ofstream_char* basic_ofstream_char_from_basic_ios(basic_ios_char *ptr)
9985 {
9986     return (basic_ofstream_char*)((char*)ptr-basic_ofstream_char_vbtable[1]);
9987 }
9988
9989 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9990 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9991 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
9992 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
9993 {
9994     basic_ios_char *basic_ios;
9995
9996     TRACE("(%p %d)\n", this, virt_init);
9997
9998     if(virt_init) {
9999         this->base.vbtable = basic_ofstream_char_vbtable;
10000         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10001         basic_ios_char_ctor(basic_ios);
10002     }else {
10003         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10004     }
10005
10006     basic_filebuf_char_ctor(&this->filebuf);
10007     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10008     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
10009     return this;
10010 }
10011
10012 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10013 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10014 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_file, 12)
10015 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_file(
10016         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
10017 {
10018     basic_ios_char *basic_ios;
10019
10020     TRACE("(%p %p %d)\n", this, file, virt_init);
10021
10022     if(virt_init) {
10023         this->base.vbtable = basic_ofstream_char_vbtable;
10024         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10025         basic_ios_char_ctor(basic_ios);
10026     }else {
10027         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10028     }
10029
10030     basic_filebuf_char_ctor_file(&this->filebuf, file);
10031     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10032     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
10033     return this;
10034 }
10035
10036 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
10037 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
10038 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 20)
10039 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
10040         const char *name, int mode, int prot, MSVCP_bool virt_init)
10041 {
10042     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10043
10044     basic_ofstream_char_ctor(this, virt_init);
10045
10046     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10047         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10048         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10049     }
10050     return this;
10051 }
10052
10053 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
10054 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
10055 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
10056 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
10057 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name_wchar, 20)
10058 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name_wchar(basic_ofstream_char *this,
10059         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10060 {
10061     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10062
10063     basic_ofstream_char_ctor(this, virt_init);
10064
10065     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10066         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10067         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10068     }
10069     return this;
10070 }
10071
10072 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10073 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10074 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
10075 void __thiscall basic_ofstream_char_dtor(basic_ios_char *base)
10076 {
10077     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
10078
10079     TRACE("(%p)\n", this);
10080
10081     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
10082     basic_filebuf_char_dtor(&this->filebuf);
10083 }
10084
10085 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10086 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10087 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
10088 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
10089 {
10090     TRACE("(%p)\n", this);
10091
10092     basic_ofstream_char_dtor(basic_ofstream_char_to_basic_ios(this));
10093     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
10094 }
10095
10096 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vector_dtor, 8)
10097 basic_ofstream_char* __thiscall basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10098 {
10099     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
10100
10101     TRACE("(%p %x)\n", this, flags);
10102
10103     if(flags & 2) {
10104         /* we have an array, with the number of elements stored before the first object */
10105         INT_PTR i, *ptr = (INT_PTR *)this-1;
10106
10107         for(i=*ptr-1; i>=0; i--)
10108             basic_ofstream_char_vbase_dtor(this+i);
10109         MSVCRT_operator_delete(ptr);
10110     } else {
10111         basic_ofstream_char_vbase_dtor(this);
10112         if(flags & 1)
10113             MSVCRT_operator_delete(this);
10114     }
10115
10116     return this;
10117 }
10118
10119 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10120 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10121 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
10122 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
10123 {
10124     TRACE("(%p)\n", this);
10125
10126     if(!basic_filebuf_char_close(&this->filebuf)) {
10127         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10128         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10129     }
10130 }
10131
10132 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10133 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10134 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
10135 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
10136 {
10137     TRACE("(%p)\n", this);
10138     return basic_filebuf_char_is_open(&this->filebuf);
10139 }
10140
10141 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
10142 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
10143 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 16)
10144 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
10145         const char *name, int mode, int prot)
10146 {
10147     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10148
10149     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10150         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10151         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10152     }
10153 }
10154
10155 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
10156 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
10157 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
10158 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
10159         const char *name, unsigned int mode)
10160 {
10161     basic_ofstream_char_open(this, name, mode, _SH_DENYNO);
10162 }
10163
10164 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
10165 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
10166 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
10167 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
10168 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar, 16)
10169 void __thiscall basic_ofstream_char_open_wchar(basic_ofstream_char *this,
10170         const wchar_t *name, int mode, int prot)
10171 {
10172     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10173
10174     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10175         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10176         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10177     }
10178 }
10179
10180 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
10181 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
10182 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
10183 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
10184 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_wchar_old, 12)
10185 void __thiscall basic_ofstream_char_open_wchar_old(basic_ofstream_char *this,
10186         const wchar_t *name, unsigned int mode)
10187 {
10188     basic_ofstream_char_open_wchar(this, name, mode, _SH_DENYNO);
10189 }
10190
10191 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10192 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10193 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
10194 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
10195 {
10196     TRACE("(%p)\n", this);
10197     return (basic_filebuf_char*)&this->filebuf;
10198 }
10199
10200 static inline basic_ios_wchar* basic_ofstream_wchar_to_basic_ios(basic_ofstream_wchar *ptr)
10201 {
10202     return (basic_ios_wchar*)((char*)ptr+basic_ofstream_wchar_vbtable[1]);
10203 }
10204
10205 static inline basic_ofstream_wchar* basic_ofstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10206 {
10207     return (basic_ofstream_wchar*)((char*)ptr-basic_ofstream_wchar_vbtable[1]);
10208 }
10209
10210 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10211 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10212 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor, 8)
10213 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
10214 {
10215     basic_ios_wchar *basic_ios;
10216
10217     TRACE("(%p %d)\n", this, virt_init);
10218
10219     if(virt_init) {
10220         this->base.vbtable = basic_ofstream_wchar_vbtable;
10221         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10222         basic_ios_wchar_ctor(basic_ios);
10223     }else {
10224         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10225     }
10226
10227     basic_filebuf_wchar_ctor(&this->filebuf);
10228     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10229     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
10230     return this;
10231 }
10232
10233 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10234 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10235 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor, 8)
10236 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
10237 {
10238     basic_ofstream_wchar_ctor(this, virt_init);
10239     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10240     return this;
10241 }
10242
10243 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10244 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10245 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_file, 12)
10246 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_file(
10247         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10248 {
10249     basic_ios_wchar *basic_ios;
10250
10251     TRACE("(%p %p %d)\n", this, file, virt_init);
10252
10253     if(virt_init) {
10254         this->base.vbtable = basic_ofstream_wchar_vbtable;
10255         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10256         basic_ios_wchar_ctor(basic_ios);
10257     }else {
10258         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10259     }
10260
10261     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10262     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10263     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
10264     return this;
10265 }
10266
10267 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10268 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10269 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_file, 12)
10270 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_file(
10271         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10272 {
10273     basic_ofstream_wchar_ctor_file(this, file, virt_init);
10274     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10275     return this;
10276 }
10277
10278 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z */
10279 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z */
10280 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_name, 20)
10281 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_name(basic_ofstream_wchar *this,
10282         const char *name, int mode, int prot, MSVCP_bool virt_init)
10283 {
10284     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10285
10286     basic_ofstream_wchar_ctor(this, virt_init);
10287
10288     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10289         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10290         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10291     }
10292     return this;
10293 }
10294
10295 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBDHH@Z */
10296 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDHH@Z */
10297 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name, 20)
10298 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name(basic_ofstream_wchar *this,
10299         const char *name, int mode, int prot, MSVCP_bool virt_init)
10300 {
10301     basic_ofstream_wchar_ctor_name(this, name, mode, prot, virt_init);
10302     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10303     return this;
10304 }
10305
10306 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PBGHH@Z */
10307 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBGHH@Z */
10308 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10309 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10310 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_name_wchar, 20)
10311 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_name_wchar(basic_ofstream_wchar *this,
10312         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10313 {
10314     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10315
10316     basic_ofstream_wchar_ctor(this, virt_init);
10317
10318     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10319         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10320         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10321     }
10322     return this;
10323 }
10324
10325 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
10326 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
10327 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PB_WHH@Z */
10328 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEB_WHH@Z */
10329 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name_wchar, 20)
10330 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name_wchar(basic_ofstream_wchar *this,
10331         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10332 {
10333     basic_ofstream_wchar_ctor_name_wchar(this, name, mode, prot, virt_init);
10334     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10335     return this;
10336 }
10337
10338 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10339 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10340 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10341 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10342 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_dtor, 4)
10343 void __thiscall basic_ofstream_wchar_dtor(basic_ios_wchar *base)
10344 {
10345     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
10346
10347     TRACE("(%p)\n", this);
10348
10349     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
10350     basic_filebuf_wchar_dtor(&this->filebuf);
10351 }
10352
10353 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10354 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10355 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10356 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10357 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vbase_dtor, 4)
10358 void __thiscall basic_ofstream_wchar_vbase_dtor(basic_ofstream_wchar *this)
10359 {
10360     TRACE("(%p)\n", this);
10361
10362     basic_ofstream_wchar_dtor(basic_ofstream_wchar_to_basic_ios(this));
10363     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
10364 }
10365
10366 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vector_dtor, 8)
10367 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10368 {
10369     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
10370
10371     TRACE("(%p %x)\n", this, flags);
10372
10373     if(flags & 2) {
10374         /* we have an array, with the number of elements stored before the first object */
10375         INT_PTR i, *ptr = (INT_PTR *)this-1;
10376
10377         for(i=*ptr-1; i>=0; i--)
10378             basic_ofstream_wchar_vbase_dtor(this+i);
10379         MSVCRT_operator_delete(ptr);
10380     } else {
10381         basic_ofstream_wchar_vbase_dtor(this);
10382         if(flags & 1)
10383             MSVCRT_operator_delete(this);
10384     }
10385
10386     return this;
10387 }
10388
10389 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10390 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10391 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10392 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10393 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_close, 4)
10394 void __thiscall basic_ofstream_wchar_close(basic_ofstream_wchar *this)
10395 {
10396     TRACE("(%p)\n", this);
10397
10398     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10399         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10400         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10401     }
10402 }
10403
10404 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10405 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10406 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10407 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10408 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_is_open, 4)
10409 MSVCP_bool __thiscall basic_ofstream_wchar_is_open(const basic_ofstream_wchar *this)
10410 {
10411     TRACE("(%p)\n", this);
10412     return basic_filebuf_wchar_is_open(&this->filebuf);
10413 }
10414
10415 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
10416 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
10417 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
10418 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
10419 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open, 16)
10420 void __thiscall basic_ofstream_wchar_open(basic_ofstream_wchar *this,
10421         const char *name, int mode, int prot)
10422 {
10423     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10424
10425     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10426         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10427         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10428     }
10429 }
10430
10431 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
10432 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
10433 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
10434 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
10435 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_old, 12)
10436 void __thiscall basic_ofstream_wchar_open_old(basic_ofstream_wchar *this,
10437         const char *name, unsigned int mode)
10438 {
10439     basic_ofstream_wchar_open(this, name, mode, _SH_DENYNO);
10440 }
10441
10442 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGHH@Z */
10443 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGHH@Z */
10444 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WHH@Z */
10445 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WHH@Z */
10446 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBGHH@Z */
10447 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGHH@Z */
10448 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPB_WHH@Z */
10449 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WHH@Z */
10450 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_wchar, 16)
10451 void __thiscall basic_ofstream_wchar_open_wchar(basic_ofstream_wchar *this,
10452         const wchar_t *name, int mode, int prot)
10453 {
10454     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10455
10456     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10457         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10458         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10459     }
10460 }
10461
10462 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGI@Z */
10463 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGI@Z */
10464 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WI@Z */
10465 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WI@Z */
10466 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBGI@Z */
10467 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGI@Z */
10468 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPB_WI@Z */
10469 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WI@Z */
10470 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_wchar_old, 12)
10471 void __thiscall basic_ofstream_wchar_open_wchar_old(basic_ofstream_wchar *this,
10472         const wchar_t *name, unsigned int mode)
10473 {
10474     basic_ofstream_wchar_open_wchar(this, name, mode, _SH_DENYNO);
10475 }
10476
10477 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10478 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10479 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10480 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10481 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_rdbuf, 4)
10482 basic_filebuf_wchar* __thiscall basic_ofstream_wchar_rdbuf(const basic_ofstream_wchar *this)
10483 {
10484     TRACE("(%p)\n", this);
10485     return (basic_filebuf_wchar*)&this->filebuf;
10486 }
10487
10488 static inline basic_ios_char* basic_ifstream_char_to_basic_ios(basic_ifstream_char *ptr)
10489 {
10490     return (basic_ios_char*)((char*)ptr+basic_ifstream_char_vbtable[1]);
10491 }
10492
10493 static inline basic_ifstream_char* basic_ifstream_char_from_basic_ios(basic_ios_char *ptr)
10494 {
10495     return (basic_ifstream_char*)((char*)ptr-basic_ifstream_char_vbtable[1]);
10496 }
10497
10498 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10499 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10500 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
10501 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
10502 {
10503     basic_ios_char *basic_ios;
10504
10505     TRACE("(%p %d)\n", this, virt_init);
10506
10507     if(virt_init) {
10508         this->base.vbtable = basic_ifstream_char_vbtable;
10509         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10510         basic_ios_char_ctor(basic_ios);
10511     }else {
10512         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10513     }
10514
10515     basic_filebuf_char_ctor(&this->filebuf);
10516     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10517     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
10518     return this;
10519 }
10520
10521 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10522 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10523 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_file, 12)
10524 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_file(
10525         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
10526 {
10527     basic_ios_char *basic_ios;
10528
10529     TRACE("(%p %p %d)\n", this, file, virt_init);
10530
10531     if(virt_init) {
10532         this->base.vbtable = basic_ifstream_char_vbtable;
10533         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10534         basic_ios_char_ctor(basic_ios);
10535     }else {
10536         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10537     }
10538
10539     basic_filebuf_char_ctor_file(&this->filebuf, file);
10540     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10541     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
10542     return this;
10543 }
10544
10545 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
10546 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
10547 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 20)
10548 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
10549         const char *name, int mode, int prot, MSVCP_bool virt_init)
10550 {
10551     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10552
10553     basic_ifstream_char_ctor(this, virt_init);
10554
10555     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10556         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10557         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10558     }
10559     return this;
10560 }
10561
10562 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
10563 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
10564 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
10565 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
10566 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name_wchar, 20)
10567 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name_wchar(basic_ifstream_char *this,
10568         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10569 {
10570     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10571
10572     basic_ifstream_char_ctor(this, virt_init);
10573
10574     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10575         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10576         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10577     }
10578     return this;
10579 }
10580
10581 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10582 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10583 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
10584 void __thiscall basic_ifstream_char_dtor(basic_ios_char *base)
10585 {
10586     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
10587
10588     TRACE("(%p)\n", this);
10589
10590     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
10591     basic_filebuf_char_dtor(&this->filebuf);
10592 }
10593
10594 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10595 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10596 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
10597 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
10598 {
10599     TRACE("(%p)\n", this);
10600
10601     basic_ifstream_char_dtor(basic_ifstream_char_to_basic_ios(this));
10602     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
10603 }
10604
10605 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vector_dtor, 8)
10606 basic_ifstream_char* __thiscall basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10607 {
10608     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
10609
10610     TRACE("(%p %x)\n", this, flags);
10611
10612     if(flags & 2) {
10613         /* we have an array, with the number of elements stored before the first object */
10614         INT_PTR i, *ptr = (INT_PTR *)this-1;
10615
10616         for(i=*ptr-1; i>=0; i--)
10617             basic_ifstream_char_vbase_dtor(this+i);
10618         MSVCRT_operator_delete(ptr);
10619     } else {
10620         basic_ifstream_char_vbase_dtor(this);
10621         if(flags & 1)
10622             MSVCRT_operator_delete(this);
10623     }
10624
10625     return this;
10626 }
10627
10628 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10629 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10630 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
10631 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
10632 {
10633     TRACE("(%p)\n", this);
10634
10635     if(!basic_filebuf_char_close(&this->filebuf)) {
10636         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10637         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10638     }
10639 }
10640
10641 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10642 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10643 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
10644 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
10645 {
10646     TRACE("(%p)\n", this);
10647     return basic_filebuf_char_is_open(&this->filebuf);
10648 }
10649
10650 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
10651 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
10652 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 16)
10653 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
10654         const char *name, int mode, int prot)
10655 {
10656     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10657
10658     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10659         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10660         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10661     }
10662 }
10663
10664 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
10665 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
10666 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
10667 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
10668         const char *name, unsigned int mode)
10669 {
10670     basic_ifstream_char_open(this, name, mode, _SH_DENYNO);
10671 }
10672
10673 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
10674 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
10675 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
10676 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
10677 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar, 16)
10678 void __thiscall basic_ifstream_char_open_wchar(basic_ifstream_char *this,
10679         const wchar_t *name, int mode, int prot)
10680 {
10681     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10682
10683     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10684         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10685         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10686     }
10687 }
10688
10689 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
10690 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
10691 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
10692 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
10693 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_wchar_old, 12)
10694 void __thiscall basic_ifstream_char_open_wchar_old(basic_ifstream_char *this,
10695         const wchar_t *name, unsigned int mode)
10696 {
10697     basic_ifstream_char_open_wchar(this, name, mode, _SH_DENYNO);
10698 }
10699
10700 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10701 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10702 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
10703 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
10704 {
10705     TRACE("(%p)\n", this);
10706     return (basic_filebuf_char*)&this->filebuf;
10707 }
10708
10709 static inline basic_ios_wchar* basic_ifstream_wchar_to_basic_ios(basic_ifstream_wchar *ptr)
10710 {
10711     return (basic_ios_wchar*)((char*)ptr+basic_ifstream_wchar_vbtable[1]);
10712 }
10713
10714 static inline basic_ifstream_wchar* basic_ifstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10715 {
10716     return (basic_ifstream_wchar*)((char*)ptr-basic_ifstream_wchar_vbtable[1]);
10717 }
10718
10719 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10720 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10721 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor, 8)
10722 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10723 {
10724     basic_ios_wchar *basic_ios;
10725
10726     TRACE("(%p %d)\n", this, virt_init);
10727
10728     if(virt_init) {
10729         this->base.vbtable = basic_ifstream_wchar_vbtable;
10730         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10731         basic_ios_wchar_ctor(basic_ios);
10732     }else {
10733         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10734     }
10735
10736     basic_filebuf_wchar_ctor(&this->filebuf);
10737     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10738     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10739     return this;
10740 }
10741
10742 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10743 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10744 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor, 8)
10745 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10746 {
10747     basic_ifstream_wchar_ctor(this, virt_init);
10748     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10749     return this;
10750 }
10751
10752 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10753 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10754 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_file, 12)
10755 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_file(
10756         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10757 {
10758     basic_ios_wchar *basic_ios;
10759
10760     TRACE("(%p %p %d)\n", this, file, virt_init);
10761
10762     if(virt_init) {
10763         this->base.vbtable = basic_ifstream_wchar_vbtable;
10764         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10765         basic_ios_wchar_ctor(basic_ios);
10766     }else {
10767         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10768     }
10769
10770     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10771     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10772     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10773     return this;
10774 }
10775
10776 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10777 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10778 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_file, 12)
10779 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_file(
10780         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10781 {
10782     basic_ifstream_wchar_ctor_file(this, file, virt_init);
10783     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10784     return this;
10785 }
10786
10787 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z */
10788 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z */
10789 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_name, 20)
10790 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_name(basic_ifstream_wchar *this,
10791         const char *name, int mode, int prot, MSVCP_bool virt_init)
10792 {
10793     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10794
10795     basic_ifstream_wchar_ctor(this, virt_init);
10796
10797     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10798         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10799         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10800     }
10801     return this;
10802 }
10803
10804 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBDHH@Z */
10805 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDHH@Z */
10806 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name, 20)
10807 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name(basic_ifstream_wchar *this,
10808         const char *name, int mode, int prot, MSVCP_bool virt_init)
10809 {
10810     basic_ifstream_wchar_ctor_name(this, name, mode, prot, virt_init);
10811     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10812     return this;
10813 }
10814
10815 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PBGHH@Z */
10816 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBGHH@Z */
10817 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10818 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10819 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_name_wchar, 20)
10820 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_name_wchar(basic_ifstream_wchar *this,
10821         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10822 {
10823     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
10824
10825     basic_ifstream_wchar_ctor(this, virt_init);
10826
10827     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10828         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10829         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10830     }
10831     return this;
10832 }
10833
10834 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
10835 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
10836 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PB_WHH@Z */
10837 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEB_WHH@Z */
10838 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name_wchar, 20)
10839 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name_wchar(basic_ifstream_wchar *this,
10840         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
10841 {
10842     basic_ifstream_wchar_ctor_name_wchar(this, name, mode, prot, virt_init);
10843     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10844     return this;
10845 }
10846
10847 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10848 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10849 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10850 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10851 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_dtor, 4)
10852 void __thiscall basic_ifstream_wchar_dtor(basic_ios_wchar *base)
10853 {
10854     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10855
10856     TRACE("(%p)\n", this);
10857
10858     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
10859     basic_filebuf_wchar_dtor(&this->filebuf);
10860 }
10861
10862 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10863 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10864 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10865 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10866 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vbase_dtor, 4)
10867 void __thiscall basic_ifstream_wchar_vbase_dtor(basic_ifstream_wchar *this)
10868 {
10869     TRACE("(%p)\n", this);
10870
10871     basic_ifstream_wchar_dtor(basic_ifstream_wchar_to_basic_ios(this));
10872     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
10873 }
10874
10875 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vector_dtor, 8)
10876 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10877 {
10878     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10879
10880     TRACE("(%p %x)\n", this, flags);
10881
10882     if(flags & 2) {
10883         /* we have an array, with the number of elements stored before the first object */
10884         INT_PTR i, *ptr = (INT_PTR *)this-1;
10885
10886         for(i=*ptr-1; i>=0; i--)
10887             basic_ifstream_wchar_vbase_dtor(this+i);
10888         MSVCRT_operator_delete(ptr);
10889     } else {
10890         basic_ifstream_wchar_vbase_dtor(this);
10891         if(flags & 1)
10892             MSVCRT_operator_delete(this);
10893     }
10894
10895     return this;
10896 }
10897
10898 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10899 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10900 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10901 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10902 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_close, 4)
10903 void __thiscall basic_ifstream_wchar_close(basic_ifstream_wchar *this)
10904 {
10905     TRACE("(%p)\n", this);
10906
10907     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10908         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10909         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10910     }
10911 }
10912
10913 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10914 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10915 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10916 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10917 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_is_open, 4)
10918 MSVCP_bool __thiscall basic_ifstream_wchar_is_open(const basic_ifstream_wchar *this)
10919 {
10920     TRACE("(%p)\n", this);
10921     return basic_filebuf_wchar_is_open(&this->filebuf);
10922 }
10923
10924 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
10925 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
10926 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
10927 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
10928 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open, 16)
10929 void __thiscall basic_ifstream_wchar_open(basic_ifstream_wchar *this,
10930         const char *name, int mode, int prot)
10931 {
10932     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10933
10934     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10935         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10936         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10937     }
10938 }
10939
10940 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
10941 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
10942 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
10943 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
10944 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_old, 12)
10945 void __thiscall basic_ifstream_wchar_open_old(basic_ifstream_wchar *this,
10946         const char *name, unsigned int mode)
10947 {
10948     basic_ifstream_wchar_open(this, name, mode, _SH_DENYNO);
10949 }
10950
10951 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGHH@Z */
10952 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGHH@Z */
10953 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WHH@Z */
10954 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WHH@Z */
10955 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBGHH@Z */
10956 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGHH@Z */
10957 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPB_WHH@Z */
10958 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WHH@Z */
10959 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_wchar, 16)
10960 void __thiscall basic_ifstream_wchar_open_wchar(basic_ifstream_wchar *this,
10961         const wchar_t *name, int mode, int prot)
10962 {
10963     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
10964
10965     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10966         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10967         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10968     }
10969 }
10970
10971 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGI@Z */
10972 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGI@Z */
10973 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WI@Z */
10974 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WI@Z */
10975 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBGI@Z */
10976 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGI@Z */
10977 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPB_WI@Z */
10978 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WI@Z */
10979 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_wchar_old, 12)
10980 void __thiscall basic_ifstream_wchar_open_wchar_old(basic_ifstream_wchar *this,
10981         const wchar_t *name, unsigned int mode)
10982 {
10983     basic_ifstream_wchar_open_wchar(this, name, mode, _SH_DENYNO);
10984 }
10985
10986 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10987 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10988 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10989 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10990 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_rdbuf, 4)
10991 basic_filebuf_wchar* __thiscall basic_ifstream_wchar_rdbuf(const basic_ifstream_wchar *this)
10992 {
10993     TRACE("(%p)\n", this);
10994     return (basic_filebuf_wchar*)&this->filebuf;
10995 }
10996
10997 static inline basic_ios_char* basic_fstream_char_to_basic_ios(basic_fstream_char *ptr)
10998 {
10999     return (basic_ios_char*)((char*)ptr+basic_fstream_char_vbtable1[1]);
11000 }
11001
11002 static inline basic_fstream_char* basic_fstream_char_from_basic_ios(basic_ios_char *ptr)
11003 {
11004     return (basic_fstream_char*)((char*)ptr-basic_fstream_char_vbtable1[1]);
11005 }
11006
11007 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
11008 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
11009 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
11010 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
11011 {
11012     basic_ios_char *basic_ios;
11013
11014     TRACE("(%p %d)\n", this, virt_init);
11015
11016     if(virt_init) {
11017         this->base.base1.vbtable = basic_fstream_char_vbtable1;
11018         this->base.base2.vbtable = basic_fstream_char_vbtable2;
11019         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11020         basic_ios_char_ctor(basic_ios);
11021     }else {
11022         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11023     }
11024
11025     basic_filebuf_char_ctor(&this->filebuf);
11026     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
11027     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
11028     return this;
11029 }
11030
11031 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
11032 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11033 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_file, 12)
11034 basic_fstream_char* __thiscall basic_fstream_char_ctor_file(basic_fstream_char *this,
11035         FILE *file, MSVCP_bool virt_init)
11036 {
11037     basic_ios_char *basic_ios;
11038
11039     TRACE("(%p %p %d)\n", this, file, virt_init);
11040
11041     if(virt_init) {
11042         this->base.base1.vbtable = basic_fstream_char_vbtable1;
11043         this->base.base2.vbtable = basic_fstream_char_vbtable2;
11044         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11045         basic_ios_char_ctor(basic_ios);
11046     }else {
11047         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11048     }
11049
11050     basic_filebuf_char_ctor_file(&this->filebuf, file);
11051     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
11052     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
11053     return this;
11054 }
11055
11056 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
11057 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
11058 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 20)
11059 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
11060         const char *name, int mode, int prot, MSVCP_bool virt_init)
11061 {
11062     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
11063
11064     basic_fstream_char_ctor(this, virt_init);
11065
11066     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
11067         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11068         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11069     }
11070     return this;
11071 }
11072
11073 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBGHH@Z */
11074 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBGHH@Z */
11075 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PB_WHH@Z */
11076 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEB_WHH@Z */
11077 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name_wchar, 20)
11078 basic_fstream_char* __thiscall basic_fstream_char_ctor_name_wchar(basic_fstream_char *this,
11079         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
11080 {
11081     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
11082
11083     basic_fstream_char_ctor(this, virt_init);
11084
11085     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
11086         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11087         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11088     }
11089     return this;
11090 }
11091
11092 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
11093 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
11094 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
11095 void __thiscall basic_fstream_char_dtor(basic_ios_char *base)
11096 {
11097     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
11098
11099     TRACE("(%p)\n", this);
11100
11101     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11102     basic_filebuf_char_dtor(&this->filebuf);
11103 }
11104
11105 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
11106 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
11107 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
11108 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
11109 {
11110     TRACE("(%p)\n", this);
11111
11112     basic_fstream_char_dtor(basic_fstream_char_to_basic_ios(this));
11113     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11114 }
11115
11116 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vector_dtor, 8)
11117 basic_fstream_char* __thiscall basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11118 {
11119     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
11120
11121     TRACE("(%p %x)\n", this, flags);
11122
11123     if(flags & 2) {
11124         /* we have an array, with the number of elements stored before the first object */
11125         INT_PTR i, *ptr = (INT_PTR *)this-1;
11126
11127         for(i=*ptr-1; i>=0; i--)
11128             basic_fstream_char_vbase_dtor(this+i);
11129         MSVCRT_operator_delete(ptr);
11130     } else {
11131         basic_fstream_char_vbase_dtor(this);
11132         if(flags & 1)
11133             MSVCRT_operator_delete(this);
11134     }
11135
11136     return this;
11137 }
11138
11139 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
11140 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
11141 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
11142 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
11143 {
11144     TRACE("(%p)\n", this);
11145
11146     if(!basic_filebuf_char_close(&this->filebuf)) {
11147         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11148         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11149     }
11150 }
11151
11152 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
11153 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
11154 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
11155 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
11156 {
11157     TRACE("(%p)\n", this);
11158     return basic_filebuf_char_is_open(&this->filebuf);
11159 }
11160
11161 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
11162 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
11163 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 16)
11164 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
11165         const char *name, int mode, int prot)
11166 {
11167     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
11168
11169     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
11170         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11171         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11172     }
11173 }
11174
11175 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
11176 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
11177 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
11178 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
11179         const char *name, unsigned int mode)
11180 {
11181     basic_fstream_char_open(this, name, mode, _SH_DENYNO);
11182 }
11183
11184 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGHH@Z */
11185 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGHH@Z */
11186 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WHH@Z */
11187 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WHH@Z */
11188 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar, 16)
11189 void __thiscall basic_fstream_char_open_wchar(basic_fstream_char *this,
11190         const wchar_t *name, int mode, int prot)
11191 {
11192     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
11193
11194     if(!basic_filebuf_char_open_wchar(&this->filebuf, name, mode, prot)) {
11195         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11196         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
11197     }
11198 }
11199
11200 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBGI@Z */
11201 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBGI@Z */
11202 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPB_WI@Z */
11203 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEB_WI@Z */
11204 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_wchar_old, 12)
11205 void __thiscall basic_fstream_char_open_wchar_old(basic_fstream_char *this,
11206         const wchar_t *name, unsigned int mode)
11207 {
11208     basic_fstream_char_open_wchar(this, name, mode, _SH_DENYNO);
11209 }
11210
11211 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
11212 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
11213 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
11214 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
11215 {
11216     TRACE("(%p)\n", this);
11217     return (basic_filebuf_char*)&this->filebuf;
11218 }
11219
11220 static inline basic_ios_wchar* basic_fstream_wchar_to_basic_ios(basic_fstream_wchar *ptr)
11221 {
11222     return (basic_ios_wchar*)((char*)ptr+basic_fstream_wchar_vbtable1[1]);
11223 }
11224
11225 static inline basic_fstream_wchar* basic_fstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11226 {
11227     return (basic_fstream_wchar*)((char*)ptr-basic_fstream_wchar_vbtable1[1]);
11228 }
11229
11230 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
11231 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
11232 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor, 8)
11233 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
11234 {
11235     basic_ios_wchar *basic_ios;
11236
11237     TRACE("(%p %d)\n", this, virt_init);
11238
11239     if(virt_init) {
11240         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
11241         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
11242         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11243         basic_ios_wchar_ctor(basic_ios);
11244     }else {
11245         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11246     }
11247
11248     basic_filebuf_wchar_ctor(&this->filebuf);
11249     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
11250     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
11251     return this;
11252 }
11253
11254 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
11255 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
11256 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor, 8)
11257 basic_fstream_wchar* __thiscall basic_fstream_short_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
11258 {
11259     basic_fstream_wchar_ctor(this, virt_init);
11260     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11261     return this;
11262 }
11263
11264 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
11265 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11266 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_file, 12)
11267 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_file(basic_fstream_wchar *this,
11268         FILE *file, MSVCP_bool virt_init)
11269 {
11270     basic_ios_wchar *basic_ios;
11271
11272     TRACE("(%p %p %d)\n", this, file, virt_init);
11273
11274     if(virt_init) {
11275         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
11276         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
11277         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11278         basic_ios_wchar_ctor(basic_ios);
11279     }else {
11280         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11281     }
11282
11283     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
11284     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
11285     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
11286     return this;
11287 }
11288
11289 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
11290 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11291 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_file, 12)
11292 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_file(basic_fstream_wchar *this,
11293         FILE *file, MSVCP_bool virt_init)
11294 {
11295     basic_fstream_wchar_ctor_file(this, file, virt_init);
11296     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11297     return this;
11298 }
11299
11300 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
11301 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
11302 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_name, 20)
11303 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_name(basic_fstream_wchar *this,
11304         const char *name, int mode, int prot, MSVCP_bool virt_init)
11305 {
11306     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
11307
11308     basic_fstream_wchar_ctor(this, virt_init);
11309
11310     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, prot)) {
11311         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11312         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11313     }
11314     return this;
11315 }
11316
11317 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
11318 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
11319 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name, 20)
11320 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name(basic_fstream_wchar *this,
11321         const char *name, int mode, int prot, MSVCP_bool virt_init)
11322 {
11323     basic_fstream_wchar_ctor_name(this, name, mode, prot, virt_init);
11324     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11325     return this;
11326 }
11327
11328 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PBGHH@Z */
11329 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBGHH@Z */
11330 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
11331 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
11332 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_name_wchar, 20)
11333 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_name_wchar(basic_fstream_wchar *this,
11334         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
11335 {
11336     TRACE("(%p %s %d %d %d)\n", this, debugstr_w(name), mode, prot, virt_init);
11337
11338     basic_fstream_wchar_ctor(this, virt_init);
11339
11340     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode, prot)) {
11341         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11342         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11343     }
11344     return this;
11345 }
11346
11347 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
11348 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
11349 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PB_WHH@Z */
11350 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEB_WHH@Z */
11351 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name_wchar, 20)
11352 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name_wchar(basic_fstream_wchar *this,
11353         const wchar_t *name, int mode, int prot, MSVCP_bool virt_init)
11354 {
11355     basic_fstream_wchar_ctor_name_wchar(this, name, mode, prot, virt_init);
11356     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11357     return this;
11358 }
11359
11360 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
11361 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
11362 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
11363 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
11364 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_dtor, 4)
11365 void __thiscall basic_fstream_wchar_dtor(basic_ios_wchar *base)
11366 {
11367     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
11368
11369     TRACE("(%p)\n", this);
11370
11371     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
11372     basic_filebuf_wchar_dtor(&this->filebuf);
11373 }
11374
11375 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
11376 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
11377 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
11378 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
11379 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vbase_dtor, 4)
11380 void __thiscall basic_fstream_wchar_vbase_dtor(basic_fstream_wchar *this)
11381 {
11382     TRACE("(%p)\n", this);
11383
11384     basic_fstream_wchar_dtor(basic_fstream_wchar_to_basic_ios(this));
11385     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
11386 }
11387
11388 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vector_dtor, 8)
11389 basic_fstream_wchar* __thiscall basic_fstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11390 {
11391     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
11392
11393     TRACE("(%p %x)\n", this, flags);
11394
11395     if(flags & 2) {
11396         /* we have an array, with the number of elements stored before the first object */
11397         INT_PTR i, *ptr = (INT_PTR *)this-1;
11398
11399         for(i=*ptr-1; i>=0; i--)
11400             basic_fstream_wchar_vbase_dtor(this+i);
11401         MSVCRT_operator_delete(ptr);
11402     } else {
11403         basic_fstream_wchar_vbase_dtor(this);
11404         if(flags & 1)
11405             MSVCRT_operator_delete(this);
11406     }
11407
11408     return this;
11409 }
11410
11411 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
11412 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
11413 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
11414 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
11415 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_close, 4)
11416 void __thiscall basic_fstream_wchar_close(basic_fstream_wchar *this)
11417 {
11418     TRACE("(%p)\n", this);
11419
11420     if(!basic_filebuf_wchar_close(&this->filebuf)) {
11421         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11422         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11423     }
11424 }
11425
11426 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
11427 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
11428 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
11429 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
11430 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_is_open, 4)
11431 MSVCP_bool __thiscall basic_fstream_wchar_is_open(const basic_fstream_wchar *this)
11432 {
11433     TRACE("(%p)\n", this);
11434     return basic_filebuf_wchar_is_open(&this->filebuf);
11435 }
11436
11437 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
11438 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
11439 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
11440 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
11441 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open, 16)
11442 void __thiscall basic_fstream_wchar_open(basic_fstream_wchar *this,
11443         const char *name, int mode, int prot)
11444 {
11445     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
11446
11447     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, prot)) {
11448         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11449         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11450     }
11451 }
11452
11453 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
11454 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
11455 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
11456 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
11457 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_old, 12)
11458 void __thiscall basic_fstream_wchar_open_old(basic_fstream_wchar *this,
11459         const char *name, unsigned int mode)
11460 {
11461     basic_fstream_wchar_open(this, name, mode, _SH_DENYNO);
11462 }
11463
11464 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGHH@Z */
11465 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGHH@Z */
11466 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WHH@Z */
11467 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WHH@Z */
11468 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBGHH@Z */
11469 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGHH@Z */
11470 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPB_WHH@Z */
11471 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WHH@Z */
11472 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_wchar, 16)
11473 void __thiscall basic_fstream_wchar_open_wchar(basic_fstream_wchar *this,
11474         const wchar_t *name, int mode, int prot)
11475 {
11476     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
11477
11478     if(!basic_filebuf_wchar_open_wchar(&this->filebuf, name, mode, prot)) {
11479         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11480         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11481     }
11482 }
11483
11484 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBGI@Z */
11485 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBGI@Z */
11486 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPB_WI@Z */
11487 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEB_WI@Z */
11488 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBGI@Z */
11489 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBGI@Z */
11490 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPB_WI@Z */
11491 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEB_WI@Z */
11492 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_wchar_old, 12)
11493 void __thiscall basic_fstream_wchar_open_wchar_old(basic_fstream_wchar *this,
11494         const wchar_t *name, unsigned int mode)
11495 {
11496     basic_fstream_wchar_open_wchar(this, name, mode, _SH_DENYNO);
11497 }
11498
11499 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
11500 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
11501 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
11502 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
11503 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_rdbuf, 4)
11504 basic_filebuf_wchar* __thiscall basic_fstream_wchar_rdbuf(const basic_fstream_wchar *this)
11505 {
11506     TRACE("(%p)\n", this);
11507     return (basic_filebuf_wchar*)&this->filebuf;
11508 }
11509
11510 static inline basic_ios_char* basic_ostringstream_char_to_basic_ios(basic_ostringstream_char *ptr)
11511 {
11512     return (basic_ios_char*)((char*)ptr+basic_ostringstream_char_vbtable[1]);
11513 }
11514
11515 static inline basic_ostringstream_char* basic_ostringstream_char_from_basic_ios(basic_ios_char *ptr)
11516 {
11517     return (basic_ostringstream_char*)((char*)ptr-basic_ostringstream_char_vbtable[1]);
11518 }
11519
11520 /* ??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 */
11521 /* ??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 */
11522 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_str, 16)
11523 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_str(basic_ostringstream_char *this,
11524         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11525 {
11526     basic_ios_char *basic_ios;
11527
11528     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11529
11530     if(virt_init) {
11531         this->base.vbtable = basic_ostringstream_char_vbtable;
11532         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11533         basic_ios_char_ctor(basic_ios);
11534     }else {
11535         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11536     }
11537
11538     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
11539     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11540     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
11541     return this;
11542 }
11543
11544 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11545 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11546 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_mode, 12)
11547 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_mode(
11548         basic_ostringstream_char *this, int mode, MSVCP_bool virt_init)
11549 {
11550     basic_ios_char *basic_ios;
11551
11552     TRACE("(%p %d %d)\n", this, mode, virt_init);
11553
11554     if(virt_init) {
11555         this->base.vbtable = basic_ostringstream_char_vbtable;
11556         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11557         basic_ios_char_ctor(basic_ios);
11558     }else {
11559         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11560     }
11561
11562     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_out);
11563     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11564     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
11565     return this;
11566 }
11567
11568 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11569 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11570 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor, 8)
11571 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor(
11572         basic_ostringstream_char *this, MSVCP_bool virt_init)
11573 {
11574     return basic_ostringstream_char_ctor_mode(this, 0, virt_init);
11575 }
11576
11577 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11578 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11579 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_dtor, 4)
11580 void __thiscall basic_ostringstream_char_dtor(basic_ios_char *base)
11581 {
11582     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
11583
11584     TRACE("(%p)\n", this);
11585
11586     basic_stringbuf_char_dtor(&this->strbuf);
11587     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
11588 }
11589
11590 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11591 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11592 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vbase_dtor, 4)
11593 void __thiscall basic_ostringstream_char_vbase_dtor(basic_ostringstream_char *this)
11594 {
11595     TRACE("(%p)\n", this);
11596
11597     basic_ostringstream_char_dtor(basic_ostringstream_char_to_basic_ios(this));
11598     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
11599 }
11600
11601 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vector_dtor, 8)
11602 basic_ostringstream_char* __thiscall basic_ostringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11603 {
11604     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
11605
11606     TRACE("(%p %x)\n", this, flags);
11607
11608     if(flags & 2) {
11609         /* we have an array, with the number of elements stored before the first object */
11610         INT_PTR i, *ptr = (INT_PTR *)this-1;
11611
11612         for(i=*ptr-1; i>=0; i--)
11613             basic_ostringstream_char_vbase_dtor(this+i);
11614         MSVCRT_operator_delete(ptr);
11615     } else {
11616         basic_ostringstream_char_vbase_dtor(this);
11617         if(flags & 1)
11618             MSVCRT_operator_delete(this);
11619     }
11620
11621     return this;
11622 }
11623
11624 /* ?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 */
11625 /* ?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 */
11626 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_rdbuf, 4)
11627 basic_stringbuf_char* __thiscall basic_ostringstream_char_rdbuf(const basic_ostringstream_char *this)
11628 {
11629     TRACE("(%p)\n", this);
11630     return (basic_stringbuf_char*)&this->strbuf;
11631 }
11632
11633 /* ?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 */
11634 /* ?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 */
11635 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_set, 8)
11636 void __thiscall basic_ostringstream_char_str_set(basic_ostringstream_char *this, const basic_string_char *str)
11637 {
11638     TRACE("(%p %p)\n", this, str);
11639     basic_stringbuf_char_str_set(&this->strbuf, str);
11640 }
11641
11642 /* ?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 */
11643 /* ?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 */
11644 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_get, 8)
11645 basic_string_char* __thiscall basic_ostringstream_char_str_get(const basic_ostringstream_char *this, basic_string_char *ret)
11646 {
11647     TRACE("(%p %p)\n", this, ret);
11648     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11649 }
11650
11651 static inline basic_ios_wchar* basic_ostringstream_wchar_to_basic_ios(basic_ostringstream_wchar *ptr)
11652 {
11653     return (basic_ios_wchar*)((char*)ptr+basic_ostringstream_wchar_vbtable[1]);
11654 }
11655
11656 static inline basic_ostringstream_wchar* basic_ostringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11657 {
11658     return (basic_ostringstream_wchar*)((char*)ptr-basic_ostringstream_wchar_vbtable[1]);
11659 }
11660
11661 /* ??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 */
11662 /* ??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 */
11663 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor_str, 16)
11664 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor_str(basic_ostringstream_wchar *this,
11665         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11666 {
11667     basic_ios_wchar *basic_ios;
11668
11669     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11670
11671     if(virt_init) {
11672         this->base.vbtable = basic_ostringstream_wchar_vbtable;
11673         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11674         basic_ios_wchar_ctor(basic_ios);
11675     }else {
11676         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11677     }
11678
11679     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
11680     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11681     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
11682     return this;
11683 }
11684
11685 /* ??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 */
11686 /* ??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 */
11687 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_str, 16)
11688 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_str(basic_ostringstream_wchar *this,
11689         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11690 {
11691     basic_ostringstream_wchar_ctor_str(this, str, mode, virt_init);
11692     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
11693     return this;
11694 }
11695
11696 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11697 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11698 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor_mode, 12)
11699 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor_mode(
11700         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
11701 {
11702     basic_ios_wchar *basic_ios;
11703
11704     TRACE("(%p %d %d)\n", this, mode, virt_init);
11705
11706     if(virt_init) {
11707         this->base.vbtable = basic_ostringstream_wchar_vbtable;
11708         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11709         basic_ios_wchar_ctor(basic_ios);
11710     }else {
11711         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11712     }
11713
11714     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_out);
11715     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11716     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
11717     return this;
11718 }
11719
11720 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11721 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11722 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_mode, 12)
11723 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_mode(
11724         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
11725 {
11726     basic_ostringstream_wchar_ctor_mode(this, mode, virt_init);
11727     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
11728     return this;
11729 }
11730
11731 /* ??_F?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11732 /* ??_F?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11733 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor, 8)
11734 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor(
11735         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
11736 {
11737     return basic_ostringstream_wchar_ctor_mode(this, 0, virt_init);
11738 }
11739
11740 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11741 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11742 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor, 8)
11743 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor(
11744         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
11745 {
11746     return basic_ostringstream_short_ctor_mode(this, 0, virt_init);
11747 }
11748
11749 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11750 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11751 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11752 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11753 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_dtor, 4)
11754 void __thiscall basic_ostringstream_wchar_dtor(basic_ios_wchar *base)
11755 {
11756     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
11757
11758     TRACE("(%p)\n", this);
11759
11760     basic_stringbuf_wchar_dtor(&this->strbuf);
11761     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
11762 }
11763
11764 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11765 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11766 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11767 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11768 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vbase_dtor, 4)
11769 void __thiscall basic_ostringstream_wchar_vbase_dtor(basic_ostringstream_wchar *this)
11770 {
11771     TRACE("(%p)\n", this);
11772
11773     basic_ostringstream_wchar_dtor(basic_ostringstream_wchar_to_basic_ios(this));
11774     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
11775 }
11776
11777 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vector_dtor, 8)
11778 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11779 {
11780     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
11781
11782     TRACE("(%p %x)\n", this, flags);
11783
11784     if(flags & 2) {
11785         /* we have an array, with the number of elements stored before the first object */
11786         INT_PTR i, *ptr = (INT_PTR *)this-1;
11787
11788         for(i=*ptr-1; i>=0; i--)
11789             basic_ostringstream_wchar_vbase_dtor(this+i);
11790         MSVCRT_operator_delete(ptr);
11791     } else {
11792         basic_ostringstream_wchar_vbase_dtor(this);
11793         if(flags & 1)
11794             MSVCRT_operator_delete(this);
11795     }
11796
11797     return this;
11798 }
11799
11800 /* ?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 */
11801 /* ?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 */
11802 /* ?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 */
11803 /* ?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 */
11804 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_rdbuf, 4)
11805 basic_stringbuf_wchar* __thiscall basic_ostringstream_wchar_rdbuf(const basic_ostringstream_wchar *this)
11806 {
11807     TRACE("(%p)\n", this);
11808     return (basic_stringbuf_wchar*)&this->strbuf;
11809 }
11810
11811 /* ?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 */
11812 /* ?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 */
11813 /* ?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 */
11814 /* ?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 */
11815 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_set, 8)
11816 void __thiscall basic_ostringstream_wchar_str_set(basic_ostringstream_wchar *this, const basic_string_wchar *str)
11817 {
11818     TRACE("(%p %p)\n", this, str);
11819     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11820 }
11821
11822 /* ?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 */
11823 /* ?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 */
11824 /* ?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 */
11825 /* ?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 */
11826 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_get, 8)
11827 basic_string_wchar* __thiscall basic_ostringstream_wchar_str_get(const basic_ostringstream_wchar *this, basic_string_wchar *ret)
11828 {
11829     TRACE("(%p %p)\n", this, ret);
11830     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11831 }
11832
11833 static inline basic_ios_char* basic_istringstream_char_to_basic_ios(basic_istringstream_char *ptr)
11834 {
11835     return (basic_ios_char*)((char*)ptr+basic_istringstream_char_vbtable[1]);
11836 }
11837
11838 static inline basic_istringstream_char* basic_istringstream_char_from_basic_ios(basic_ios_char *ptr)
11839 {
11840     return (basic_istringstream_char*)((char*)ptr-basic_istringstream_char_vbtable[1]);
11841 }
11842
11843 /* ??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 */
11844 /* ??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 */
11845 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_str, 16)
11846 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_str(basic_istringstream_char *this,
11847         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11848 {
11849     basic_ios_char *basic_ios;
11850
11851     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11852
11853     if(virt_init) {
11854         this->base.vbtable = basic_istringstream_char_vbtable;
11855         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11856         basic_ios_char_ctor(basic_ios);
11857     }else {
11858         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11859     }
11860
11861     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
11862     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11863     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11864     return this;
11865 }
11866
11867 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11868 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11869 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_mode, 12)
11870 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_mode(
11871         basic_istringstream_char *this, int mode, MSVCP_bool virt_init)
11872 {
11873     basic_ios_char *basic_ios;
11874
11875     TRACE("(%p %d %d)\n", this, mode, virt_init);
11876
11877     if(virt_init) {
11878         this->base.vbtable = basic_istringstream_char_vbtable;
11879         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11880         basic_ios_char_ctor(basic_ios);
11881     }else {
11882         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11883     }
11884
11885     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11886     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11887     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11888     return this;
11889 }
11890
11891 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11892 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11893 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor, 8)
11894 basic_istringstream_char* __thiscall basic_istringstream_char_ctor(
11895         basic_istringstream_char *this, MSVCP_bool virt_init)
11896 {
11897     return basic_istringstream_char_ctor_mode(this, 0, virt_init);
11898 }
11899
11900 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11901 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11902 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_dtor, 4)
11903 void __thiscall basic_istringstream_char_dtor(basic_ios_char *base)
11904 {
11905     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11906
11907     TRACE("(%p)\n", this);
11908
11909     basic_stringbuf_char_dtor(&this->strbuf);
11910     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11911 }
11912
11913 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11914 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11915 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vbase_dtor, 4)
11916 void __thiscall basic_istringstream_char_vbase_dtor(basic_istringstream_char *this)
11917 {
11918     TRACE("(%p)\n", this);
11919
11920     basic_istringstream_char_dtor(basic_istringstream_char_to_basic_ios(this));
11921     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
11922 }
11923
11924 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vector_dtor, 8)
11925 basic_istringstream_char* __thiscall basic_istringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11926 {
11927     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11928
11929     TRACE("(%p %x)\n", this, flags);
11930
11931     if(flags & 2) {
11932         /* we have an array, with the number of elements stored before the first object */
11933         INT_PTR i, *ptr = (INT_PTR *)this-1;
11934
11935         for(i=*ptr-1; i>=0; i--)
11936             basic_istringstream_char_vbase_dtor(this+i);
11937         MSVCRT_operator_delete(ptr);
11938     } else {
11939         basic_istringstream_char_vbase_dtor(this);
11940         if(flags & 1)
11941             MSVCRT_operator_delete(this);
11942     }
11943
11944     return this;
11945 }
11946
11947 /* ?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 */
11948 /* ?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 */
11949 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_rdbuf, 4)
11950 basic_stringbuf_char* __thiscall basic_istringstream_char_rdbuf(const basic_istringstream_char *this)
11951 {
11952     TRACE("(%p)\n", this);
11953     return (basic_stringbuf_char*)&this->strbuf;
11954 }
11955
11956 /* ?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 */
11957 /* ?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 */
11958 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_set, 8)
11959 void __thiscall basic_istringstream_char_str_set(basic_istringstream_char *this, const basic_string_char *str)
11960 {
11961     TRACE("(%p %p)\n", this, str);
11962     basic_stringbuf_char_str_set(&this->strbuf, str);
11963 }
11964
11965 /* ?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 */
11966 /* ?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 */
11967 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_get, 8)
11968 basic_string_char* __thiscall basic_istringstream_char_str_get(const basic_istringstream_char *this, basic_string_char *ret)
11969 {
11970     TRACE("(%p %p)\n", this, ret);
11971     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11972 }
11973
11974 static inline basic_ios_wchar* basic_istringstream_wchar_to_basic_ios(basic_istringstream_wchar *ptr)
11975 {
11976     return (basic_ios_wchar*)((char*)ptr+basic_istringstream_wchar_vbtable[1]);
11977 }
11978
11979 static inline basic_istringstream_wchar* basic_istringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11980 {
11981     return (basic_istringstream_wchar*)((char*)ptr-basic_istringstream_wchar_vbtable[1]);
11982 }
11983
11984 /* ??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 */
11985 /* ??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 */
11986 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor_str, 16)
11987 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor_str(basic_istringstream_wchar *this,
11988         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11989 {
11990     basic_ios_wchar *basic_ios;
11991
11992     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11993
11994     if(virt_init) {
11995         this->base.vbtable = basic_istringstream_wchar_vbtable;
11996         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11997         basic_ios_wchar_ctor(basic_ios);
11998     }else {
11999         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
12000     }
12001
12002     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
12003     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
12004     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
12005     return this;
12006 }
12007
12008 /* ??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 */
12009 /* ??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 */
12010 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_str, 16)
12011 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_str(basic_istringstream_wchar *this,
12012         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
12013 {
12014     basic_istringstream_wchar_ctor_str(this, str, mode, virt_init);
12015     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
12016     return this;
12017 }
12018
12019 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
12020 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
12021 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor_mode, 12)
12022 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor_mode(
12023         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
12024 {
12025     basic_ios_wchar *basic_ios;
12026
12027     TRACE("(%p %d %d)\n", this, mode, virt_init);
12028
12029     if(virt_init) {
12030         this->base.vbtable = basic_istringstream_wchar_vbtable;
12031         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
12032         basic_ios_wchar_ctor(basic_ios);
12033     }else {
12034         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
12035     }
12036
12037     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_in);
12038     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
12039     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
12040     return this;
12041 }
12042
12043 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
12044 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
12045 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_mode, 12)
12046 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_mode(
12047         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
12048 {
12049     basic_istringstream_wchar_ctor_mode(this, mode, virt_init);
12050     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
12051     return this;
12052 }
12053
12054 /* ??_F?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12055 /* ??_F?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12056 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor, 8)
12057 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor(
12058         basic_istringstream_wchar *this, MSVCP_bool virt_init)
12059 {
12060     return basic_istringstream_wchar_ctor_mode(this, 0, virt_init);
12061 }
12062
12063 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12064 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12065 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor, 8)
12066 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor(
12067         basic_istringstream_wchar *this, MSVCP_bool virt_init)
12068 {
12069     return basic_istringstream_short_ctor_mode(this, 0, virt_init);
12070 }
12071
12072 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
12073 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
12074 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
12075 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
12076 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_dtor, 4)
12077 void __thiscall basic_istringstream_wchar_dtor(basic_ios_wchar *base)
12078 {
12079     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
12080
12081     TRACE("(%p)\n", this);
12082
12083     basic_stringbuf_wchar_dtor(&this->strbuf);
12084     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
12085 }
12086
12087 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12088 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12089 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12090 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12091 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vbase_dtor, 4)
12092 void __thiscall basic_istringstream_wchar_vbase_dtor(basic_istringstream_wchar *this)
12093 {
12094     TRACE("(%p)\n", this);
12095
12096     basic_istringstream_wchar_dtor(basic_istringstream_wchar_to_basic_ios(this));
12097     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
12098 }
12099
12100 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vector_dtor, 8)
12101 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
12102 {
12103     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
12104
12105     TRACE("(%p %x)\n", this, flags);
12106
12107     if(flags & 2) {
12108         /* we have an array, with the number of elements stored before the first object */
12109         INT_PTR i, *ptr = (INT_PTR *)this-1;
12110
12111         for(i=*ptr-1; i>=0; i--)
12112             basic_istringstream_wchar_vbase_dtor(this+i);
12113         MSVCRT_operator_delete(ptr);
12114     } else {
12115         basic_istringstream_wchar_vbase_dtor(this);
12116         if(flags & 1)
12117             MSVCRT_operator_delete(this);
12118     }
12119
12120     return this;
12121 }
12122
12123 /* ?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 */
12124 /* ?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 */
12125 /* ?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 */
12126 /* ?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 */
12127 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_rdbuf, 4)
12128 basic_stringbuf_wchar* __thiscall basic_istringstream_wchar_rdbuf(const basic_istringstream_wchar *this)
12129 {
12130     TRACE("(%p)\n", this);
12131     return (basic_stringbuf_wchar*)&this->strbuf;
12132 }
12133
12134 /* ?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 */
12135 /* ?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 */
12136 /* ?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 */
12137 /* ?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 */
12138 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_set, 8)
12139 void __thiscall basic_istringstream_wchar_str_set(basic_istringstream_wchar *this, const basic_string_wchar *str)
12140 {
12141     TRACE("(%p %p)\n", this, str);
12142     basic_stringbuf_wchar_str_set(&this->strbuf, str);
12143 }
12144
12145 /* ?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 */
12146 /* ?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 */
12147 /* ?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 */
12148 /* ?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 */
12149 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_get, 8)
12150 basic_string_wchar* __thiscall basic_istringstream_wchar_str_get(const basic_istringstream_wchar *this, basic_string_wchar *ret)
12151 {
12152     TRACE("(%p %p)\n", this, ret);
12153     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
12154 }
12155
12156 static inline basic_ios_char* basic_stringstream_char_to_basic_ios(basic_stringstream_char *ptr)
12157 {
12158     return (basic_ios_char*)((char*)ptr+basic_stringstream_char_vbtable1[1]);
12159 }
12160
12161 static inline basic_stringstream_char* basic_stringstream_char_from_basic_ios(basic_ios_char *ptr)
12162 {
12163     return (basic_stringstream_char*)((char*)ptr-basic_stringstream_char_vbtable1[1]);
12164 }
12165
12166 /* ??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 */
12167 /* ??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 */
12168 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_str, 16)
12169 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_str(basic_stringstream_char *this,
12170         const basic_string_char *str, int mode, MSVCP_bool virt_init)
12171 {
12172     basic_ios_char *basic_ios;
12173
12174     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
12175
12176     if(virt_init) {
12177         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
12178         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
12179         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12180         basic_ios_char_ctor(basic_ios);
12181     }else {
12182         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12183     }
12184
12185     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode);
12186     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
12187     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
12188     return this;
12189 }
12190
12191 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
12192 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
12193 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_mode, 12)
12194 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_mode(
12195         basic_stringstream_char *this, int mode, MSVCP_bool virt_init)
12196 {
12197     basic_ios_char *basic_ios;
12198
12199     TRACE("(%p %d %d)\n", this, mode, virt_init);
12200
12201     if(virt_init) {
12202         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
12203         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
12204         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12205         basic_ios_char_ctor(basic_ios);
12206     }else {
12207         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12208     }
12209
12210     basic_stringbuf_char_ctor_mode(&this->strbuf, mode);
12211     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
12212     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
12213     return this;
12214 }
12215
12216 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
12217 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
12218 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor, 8)
12219 basic_stringstream_char* __thiscall basic_stringstream_char_ctor(
12220         basic_stringstream_char *this, MSVCP_bool virt_init)
12221 {
12222     return basic_stringstream_char_ctor_mode(
12223             this, OPENMODE_out|OPENMODE_in, virt_init);
12224 }
12225
12226 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
12227 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
12228 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_dtor, 4)
12229 void __thiscall basic_stringstream_char_dtor(basic_ios_char *base)
12230 {
12231     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
12232
12233     TRACE("(%p)\n", this);
12234
12235     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
12236     basic_stringbuf_char_dtor(&this->strbuf);
12237 }
12238
12239 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
12240 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
12241 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vbase_dtor, 4)
12242 void __thiscall basic_stringstream_char_vbase_dtor(basic_stringstream_char *this)
12243 {
12244     TRACE("(%p)\n", this);
12245
12246     basic_stringstream_char_dtor(basic_stringstream_char_to_basic_ios(this));
12247     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
12248 }
12249
12250 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vector_dtor, 8)
12251 basic_stringstream_char* __thiscall basic_stringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
12252 {
12253     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
12254
12255     TRACE("(%p %x)\n", this, flags);
12256
12257     if(flags & 2) {
12258         /* we have an array, with the number of elements stored before the first object */
12259         INT_PTR i, *ptr = (INT_PTR *)this-1;
12260
12261         for(i=*ptr-1; i>=0; i--)
12262             basic_stringstream_char_vbase_dtor(this+i);
12263         MSVCRT_operator_delete(ptr);
12264     } else {
12265         basic_stringstream_char_vbase_dtor(this);
12266         if(flags & 1)
12267             MSVCRT_operator_delete(this);
12268     }
12269
12270     return this;
12271 }
12272
12273 /* ?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 */
12274 /* ?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 */
12275 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_rdbuf, 4)
12276 basic_stringbuf_char* __thiscall basic_stringstream_char_rdbuf(const basic_stringstream_char *this)
12277 {
12278     TRACE("(%p)\n", this);
12279     return (basic_stringbuf_char*)&this->strbuf;
12280 }
12281
12282 /* ?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 */
12283 /* ?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 */
12284 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_set, 8)
12285 void __thiscall basic_stringstream_char_str_set(basic_stringstream_char *this, const basic_string_char *str)
12286 {
12287     TRACE("(%p %p)\n", this, str);
12288     basic_stringbuf_char_str_set(&this->strbuf, str);
12289 }
12290
12291 /* ?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 */
12292 /* ?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 */
12293 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_get, 8)
12294 basic_string_char* __thiscall basic_stringstream_char_str_get(const basic_stringstream_char *this, basic_string_char *ret)
12295 {
12296     TRACE("(%p %p)\n", this, ret);
12297     return basic_stringbuf_char_str_get(&this->strbuf, ret);
12298 }
12299
12300 static inline basic_ios_wchar* basic_stringstream_wchar_to_basic_ios(basic_stringstream_wchar *ptr)
12301 {
12302     return (basic_ios_wchar*)((char*)ptr+basic_stringstream_wchar_vbtable1[1]);
12303 }
12304
12305 static inline basic_stringstream_wchar* basic_stringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
12306 {
12307     return (basic_stringstream_wchar*)((char*)ptr-basic_stringstream_wchar_vbtable1[1]);
12308 }
12309
12310 /* ??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 */
12311 /* ??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 */
12312 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor_str, 16)
12313 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor_str(basic_stringstream_wchar *this,
12314         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
12315 {
12316     basic_ios_wchar *basic_ios;
12317
12318     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
12319
12320     if(virt_init) {
12321         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
12322         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
12323         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12324         basic_ios_wchar_ctor(basic_ios);
12325     }else {
12326         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12327     }
12328
12329     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode);
12330     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
12331     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
12332     return this;
12333 }
12334
12335 /* ??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 */
12336 /* ??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 */
12337 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_str, 16)
12338 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_str(basic_stringstream_wchar *this,
12339         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
12340 {
12341     basic_stringstream_wchar_ctor_str(this, str, mode, virt_init);
12342     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
12343     return this;
12344 }
12345
12346 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
12347 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
12348 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor_mode, 12)
12349 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor_mode(
12350         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
12351 {
12352     basic_ios_wchar *basic_ios;
12353
12354     TRACE("(%p %d %d)\n", this, mode, virt_init);
12355
12356     if(virt_init) {
12357         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
12358         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
12359         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12360         basic_ios_wchar_ctor(basic_ios);
12361     }else {
12362         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12363     }
12364
12365     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode);
12366     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
12367     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
12368     return this;
12369 }
12370
12371 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
12372 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
12373 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_mode, 12)
12374 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_mode(
12375         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
12376 {
12377     basic_stringstream_wchar_ctor_mode(this, mode, virt_init);
12378     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
12379     return this;
12380 }
12381
12382 /* ??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12383 /* ??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12384 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor, 8)
12385 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor(
12386         basic_stringstream_wchar *this, MSVCP_bool virt_init)
12387 {
12388     return basic_stringstream_wchar_ctor_mode(
12389             this, OPENMODE_out|OPENMODE_in, virt_init);
12390 }
12391
12392 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12393 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12394 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor, 8)
12395 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor(
12396         basic_stringstream_wchar *this, MSVCP_bool virt_init)
12397 {
12398     return basic_stringstream_short_ctor_mode(
12399             this, OPENMODE_out|OPENMODE_in, virt_init);
12400 }
12401
12402 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
12403 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
12404 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
12405 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
12406 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_dtor, 4)
12407 void __thiscall basic_stringstream_wchar_dtor(basic_ios_wchar *base)
12408 {
12409     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
12410
12411     TRACE("(%p)\n", this);
12412
12413     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
12414     basic_stringbuf_wchar_dtor(&this->strbuf);
12415 }
12416
12417 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12418 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12419 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12420 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12421 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vbase_dtor, 4)
12422 void __thiscall basic_stringstream_wchar_vbase_dtor(basic_stringstream_wchar *this)
12423 {
12424     TRACE("(%p)\n", this);
12425
12426     basic_stringstream_wchar_dtor(basic_stringstream_wchar_to_basic_ios(this));
12427     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
12428 }
12429
12430 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vector_dtor, 8)
12431 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
12432 {
12433     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
12434
12435     TRACE("(%p %x)\n", this, flags);
12436
12437     if(flags & 2) {
12438         /* we have an array, with the number of elements stored before the first object */
12439         INT_PTR i, *ptr = (INT_PTR *)this-1;
12440
12441         for(i=*ptr-1; i>=0; i--)
12442             basic_stringstream_wchar_vbase_dtor(this+i);
12443         MSVCRT_operator_delete(ptr);
12444     } else {
12445         basic_stringstream_wchar_vbase_dtor(this);
12446         if(flags & 1)
12447             MSVCRT_operator_delete(this);
12448     }
12449
12450     return this;
12451 }
12452
12453 /* ?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 */
12454 /* ?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 */
12455 /* ?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 */
12456 /* ?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 */
12457 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_rdbuf, 4)
12458 basic_stringbuf_wchar* __thiscall basic_stringstream_wchar_rdbuf(const basic_stringstream_wchar *this)
12459 {
12460     TRACE("(%p)\n", this);
12461     return (basic_stringbuf_wchar*)&this->strbuf;
12462 }
12463
12464 /* ?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 */
12465 /* ?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 */
12466 /* ?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 */
12467 /* ?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 */
12468 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_set, 8)
12469 void __thiscall basic_stringstream_wchar_str_set(basic_stringstream_wchar *this, const basic_string_wchar *str)
12470 {
12471     TRACE("(%p %p)\n", this, str);
12472     basic_stringbuf_wchar_str_set(&this->strbuf, str);
12473 }
12474
12475 /* ?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 */
12476 /* ?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 */
12477 /* ?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 */
12478 /* ?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 */
12479 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_get, 8)
12480 basic_string_wchar* __thiscall basic_stringstream_wchar_str_get(const basic_stringstream_wchar *this, basic_string_wchar *ret)
12481 {
12482     TRACE("(%p %p)\n", this, ret);
12483     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
12484 }
12485
12486 /* ?_Init@strstreambuf@std@@IAEXHPAD0H@Z */
12487 /* ?_Init@strstreambuf@std@@IEAAX_JPEAD1H@Z */
12488 DEFINE_THISCALL_WRAPPER(strstreambuf__Init, 20)
12489 void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g, char *p, int mode)
12490 {
12491     TRACE("(%p %ld %p %p %d)\n", this, len, g, p, mode);
12492
12493     this->minsize = 32;
12494     this->endsave = NULL;
12495     this->strmode = mode;
12496     this->palloc = NULL;
12497     this->pfree = NULL;
12498
12499     if(!g) {
12500         this->strmode |= STRSTATE_Dynamic;
12501         if(len > this->minsize)
12502             this->minsize = len;
12503         this->seekhigh = NULL;
12504         return;
12505     }
12506
12507     if(len < 0)
12508         len = INT_MAX;
12509     else if(!len)
12510         len = strlen(g);
12511
12512     this->seekhigh = g+len;
12513     basic_streambuf_char_setg(&this->base, g, g, p ? p : this->seekhigh);
12514     if(p)
12515         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
12516 }
12517
12518 /* ??0strstreambuf@std@@QAE@PACH0@Z */
12519 /* ??0strstreambuf@std@@QEAA@PEAC_J0@Z */
12520 /* ??0strstreambuf@std@@QAE@PADH0@Z */
12521 /* ??0strstreambuf@std@@QEAA@PEAD_J0@Z */
12522 /* ??0strstreambuf@std@@QAE@PAEH0@Z */
12523 /* ??0strstreambuf@std@@QEAA@PEAE_J0@Z */
12524 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_get_put, 16)
12525 strstreambuf* __thiscall strstreambuf_ctor_get_put(strstreambuf *this, char *g, streamsize len, char *p)
12526 {
12527     TRACE("(%p %p %ld %p)\n", this, g, len, p);
12528
12529     basic_streambuf_char_ctor(&this->base);
12530     this->base.vtable = &MSVCP_strstreambuf_vtable;
12531
12532     strstreambuf__Init(this, len, g, p, 0);
12533     return this;
12534 }
12535
12536 /* ??0strstreambuf@std@@QAE@H@Z */
12537 /* ??0strstreambuf@std@@QEAA@_J@Z */
12538 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_len, 8)
12539 strstreambuf* __thiscall strstreambuf_ctor_len(strstreambuf *this, streamsize len)
12540 {
12541     return strstreambuf_ctor_get_put(this, NULL, len, NULL);
12542 }
12543
12544 /* ??0strstreambuf@std@@QAE@P6APAXI@ZP6AXPAX@Z@Z */
12545 /* ??0strstreambuf@std@@QEAA@P6APEAX_K@ZP6AXPEAX@Z@Z */
12546 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_alloc, 12)
12547 strstreambuf* __thiscall strstreambuf_ctor_alloc(strstreambuf *this, void* (__cdecl *palloc)(MSVCP_size_t), void (__cdecl *pfree)(void*))
12548 {
12549     TRACE("(%p %p %p)\n", this, palloc, pfree);
12550
12551     strstreambuf_ctor_get_put(this, NULL, 0, NULL);
12552     this->palloc = palloc;
12553     this->pfree = pfree;
12554     return this;
12555 }
12556
12557 /* ??0strstreambuf@std@@QAE@PBCH@Z */
12558 /* ??0strstreambuf@std@@QEAA@PEBC_J@Z */
12559 /* ??0strstreambuf@std@@QAE@PBDH@Z */
12560 /* ??0strstreambuf@std@@QEAA@PEBD_J@Z */
12561 /* ??0strstreambuf@std@@QAE@PBEH@Z */
12562 /* ??0strstreambuf@std@@QEAA@PEBE_J@Z */
12563 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor_get, 12)
12564 strstreambuf* __thiscall strstreambuf_ctor_get(strstreambuf *this, const char *g, streamsize len)
12565 {
12566     TRACE("(%p %p %ld)\n", this, g, len);
12567
12568     strstreambuf_ctor_get_put(this, (char*)g, len, NULL);
12569     this->strmode |= STRSTATE_Constant;
12570     return this;
12571 }
12572
12573 /* ??_Fstrstreambuf@std@@QAEXXZ */
12574 /* ??_Fstrstreambuf@std@@QEAAXXZ */
12575 DEFINE_THISCALL_WRAPPER(strstreambuf_ctor, 4)
12576 strstreambuf* __thiscall strstreambuf_ctor(strstreambuf *this)
12577 {
12578     return strstreambuf_ctor_get_put(this, NULL, 0, NULL);
12579 }
12580
12581 /* ?_Tidy@strstreambuf@std@@IAEXXZ */
12582 /* ?_Tidy@strstreambuf@std@@IEAAXXZ */
12583 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
12584 void __thiscall strstreambuf__Tidy(strstreambuf *this)
12585 {
12586     TRACE("(%p)\n", this);
12587
12588     if((this->strmode & STRSTATE_Allocated) && !(this->strmode & STRSTATE_Frozen)) {
12589         if(this->pfree)
12590             this->pfree(basic_streambuf_char_eback(&this->base));
12591         else
12592             MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
12593     }
12594
12595     this->endsave = NULL;
12596     this->seekhigh = NULL;
12597     this->strmode &= ~(STRSTATE_Allocated | STRSTATE_Frozen);
12598     basic_streambuf_char_setg(&this->base, NULL, NULL, NULL);
12599     basic_streambuf_char_setp(&this->base, NULL, NULL);
12600 }
12601
12602 /* ??1strstreambuf@std@@UAE@XZ */
12603 /* ??1strstreambuf@std@@UEAA@XZ */
12604 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor, 4)
12605 void __thiscall strstreambuf_dtor(strstreambuf *this)
12606 {
12607     TRACE("(%p)\n", this);
12608
12609     strstreambuf__Tidy(this);
12610     basic_streambuf_char_dtor(&this->base);
12611 }
12612
12613 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor, 8)
12614 strstreambuf* __thiscall strstreambuf_vector_dtor(strstreambuf *this, unsigned int flags)
12615 {
12616     TRACE("(%p %x)\n", this, flags);
12617     if(flags & 2) {
12618         /* we have an array, with the number of elements stored before the first object */
12619         INT_PTR i, *ptr = (INT_PTR *)this-1;
12620
12621         for(i=*ptr-1; i>=0; i--)
12622             strstreambuf_dtor(this+i);
12623         MSVCRT_operator_delete(ptr);
12624     } else {
12625         strstreambuf_dtor(this);
12626         if(flags & 1)
12627             MSVCRT_operator_delete(this);
12628     }
12629
12630     return this;
12631 }
12632
12633 /* ?freeze@strstreambuf@std@@QAEX_N@Z */
12634 /* ?freeze@strstreambuf@std@@QEAAX_N@Z */
12635 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze, 8)
12636 void __thiscall strstreambuf_freeze(strstreambuf *this, MSVCP_bool freeze)
12637 {
12638     TRACE("(%p %d)\n", this, freeze);
12639
12640     if(!freeze == !(this->strmode *STRSTATE_Frozen))
12641         return;
12642
12643     if(freeze) {
12644         this->strmode |= STRSTATE_Frozen;
12645         this->endsave = basic_streambuf_char_epptr(&this->base);
12646         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
12647                 basic_streambuf_char_pptr(&this->base), basic_streambuf_char_eback(&this->base));
12648     }else {
12649         this->strmode &= ~STRSTATE_Frozen;
12650         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
12651                 basic_streambuf_char_pptr(&this->base), this->endsave);
12652     }
12653 }
12654
12655 /* ?str@strstreambuf@std@@QAEPADXZ */
12656 /* ?str@strstreambuf@std@@QEAAPEADXZ */
12657 DEFINE_THISCALL_WRAPPER(strstreambuf_str, 4)
12658 char* __thiscall strstreambuf_str(strstreambuf *this)
12659 {
12660     TRACE("(%p)\n", this);
12661
12662     strstreambuf_freeze(this, TRUE);
12663     return basic_streambuf_char_gptr(&this->base);
12664 }
12665
12666 /* ?pcount@strstreambuf@std@@QBEHXZ */
12667 /* ?pcount@strstreambuf@std@@QEBA_JXZ */
12668 DEFINE_THISCALL_WRAPPER(strstreambuf_pcount, 4)
12669 streamsize __thiscall strstreambuf_pcount(const strstreambuf *this)
12670 {
12671     char *ppos = basic_streambuf_char_pptr(&this->base);
12672
12673     TRACE("(%p)\n", this);
12674
12675     return ppos ? ppos-basic_streambuf_char_pbase(&this->base) : 0;
12676 }
12677
12678 /* ?overflow@strstreambuf@std@@MAEHH@Z */
12679 /* ?overflow@strstreambuf@std@@MEAAHH@Z */
12680 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow, 8)
12681 int __thiscall strstreambuf_overflow(strstreambuf *this, int c)
12682 {
12683     MSVCP_size_t old_size, size;
12684     char *ptr, *buf;
12685
12686     TRACE("(%p %d)\n", this, c);
12687
12688     if(c == EOF)
12689         return !EOF;
12690
12691     if(this->strmode & STRSTATE_Frozen)
12692         return EOF;
12693
12694     ptr = basic_streambuf_char_pptr(&this->base);
12695     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
12696         return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
12697
12698     if(!(this->strmode & STRSTATE_Dynamic) || (this->strmode & STRSTATE_Constant))
12699         return EOF;
12700
12701     ptr = basic_streambuf_char_eback(&this->base);
12702     old_size = ptr ? basic_streambuf_char_epptr(&this->base) - ptr : 0;
12703
12704     size = old_size + old_size/2;
12705     if(size < this->minsize)
12706         size = this->minsize;
12707
12708     if(this->palloc)
12709         buf = this->palloc(size);
12710     else
12711         buf = MSVCRT_operator_new(size);
12712     if(!buf)
12713         return EOF;
12714
12715     memcpy(buf, ptr, old_size);
12716     if(this->strmode & STRSTATE_Allocated) {
12717         if(this->pfree)
12718             this->pfree(ptr);
12719         else
12720             MSVCRT_operator_delete(ptr);
12721     }
12722
12723     this->strmode |= STRSTATE_Allocated;
12724     if(!old_size) {
12725         this->seekhigh = buf;
12726         basic_streambuf_char_setp(&this->base, buf, buf+size);
12727         basic_streambuf_char_setg(&this->base, buf, buf, buf);
12728     }else {
12729         this->seekhigh = this->seekhigh-ptr+buf;
12730         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base)-ptr+buf,
12731                 basic_streambuf_char_pptr(&this->base)-ptr+buf, buf+size);
12732         basic_streambuf_char_setg(&this->base, buf, basic_streambuf_char_gptr(&this->base)-ptr+buf,
12733                 basic_streambuf_char_pptr(&this->base));
12734     }
12735
12736     return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
12737 }
12738
12739 /* ?pbackfail@strstreambuf@std@@MAEHH@Z */
12740 /* ?pbackfail@strstreambuf@std@@MEAAHH@Z */
12741 DEFINE_THISCALL_WRAPPER(strstreambuf_pbackfail, 8)
12742 int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c)
12743 {
12744     char *ptr = basic_streambuf_char_gptr(&this->base);
12745
12746     TRACE("(%p %d)\n", this, c);
12747
12748     if(ptr<=basic_streambuf_char_eback(&this->base)
12749             || ((this->strmode & STRSTATE_Constant) && c!=ptr[-1]))
12750         return EOF;
12751
12752     basic_streambuf_char_gbump(&this->base, -1);
12753     if(c == EOF)
12754         return !EOF;
12755     if(this->strmode & STRSTATE_Constant)
12756         return (unsigned char)c;
12757
12758     return (unsigned char)(ptr[0] = c);
12759 }
12760
12761 /* ?seekoff@strstreambuf@std@@MAE?AV?$fpos@H@2@JHH@Z */
12762 /* ?seekoff@strstreambuf@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
12763 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20)
12764 fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode)
12765 {
12766     char *eback = basic_streambuf_char_eback(&this->base);
12767     char *pptr = basic_streambuf_char_pptr(&this->base);
12768     char *gptr = basic_streambuf_char_gptr(&this->base);
12769
12770     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
12771
12772     ret->off = 0;
12773     ret->state = 0;
12774
12775     if(pptr > this->seekhigh)
12776         this->seekhigh = pptr;
12777
12778     if((mode & OPENMODE_in) && gptr) {
12779         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
12780             off += gptr-eback;
12781         else if(way == SEEKDIR_end)
12782             off += this->seekhigh-eback;
12783         else if(way != SEEKDIR_beg)
12784             off = -1;
12785
12786         if(off<0 || off>this->seekhigh-eback) {
12787             off = -1;
12788         }else {
12789             basic_streambuf_char_gbump(&this->base, eback-gptr+off);
12790             if((mode & OPENMODE_out) && pptr) {
12791                 basic_streambuf_char_setp_next(&this->base, eback,
12792                         gptr, basic_streambuf_char_epptr(&this->base));
12793             }
12794         }
12795     }else if((mode & OPENMODE_out) && pptr) {
12796         if(way == SEEKDIR_cur)
12797             off += pptr-eback;
12798         else if(way == SEEKDIR_end)
12799             off += this->seekhigh-eback;
12800         else if(way != SEEKDIR_beg)
12801             off = -1;
12802
12803          if(off<0 || off>this->seekhigh-eback)
12804              off = -1;
12805          else
12806              basic_streambuf_char_pbump(&this->base, eback-pptr+off);
12807     }else {
12808         off = -1;
12809     }
12810
12811     ret->pos = off;
12812     return ret;
12813 }
12814
12815 /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */
12816 /* ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
12817 DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36)
12818 fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode)
12819 {
12820     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
12821
12822     if(pos.off==0 && pos.pos==-1 && pos.state==0) {
12823         *ret = pos;
12824         return ret;
12825     }
12826
12827     return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
12828 }
12829
12830 /* ?underflow@strstreambuf@std@@MAEHXZ */
12831 /* ?underflow@strstreambuf@std@@MEAAHXZ */
12832 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow, 4)
12833 int __thiscall strstreambuf_underflow(strstreambuf *this)
12834 {
12835     char *gptr = basic_streambuf_char_gptr(&this->base);
12836     char *pptr;
12837
12838     TRACE("(%p)\n", this);
12839
12840     if(!gptr)
12841         return EOF;
12842
12843     if(gptr < basic_streambuf_char_egptr(&this->base))
12844         return (unsigned char)(*gptr);
12845
12846     pptr = basic_streambuf_char_gptr(&this->base);
12847     if(pptr > this->seekhigh)
12848         this->seekhigh = pptr;
12849
12850     if(this->seekhigh <= gptr)
12851         return EOF;
12852
12853     basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base),
12854             gptr, this->seekhigh);
12855     return (unsigned char)(*gptr);
12856 }
12857
12858 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
12859 {
12860     ios_base_precision_set(base, prec);
12861 }
12862
12863 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
12864 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12865 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
12866 {
12867     TRACE("(%p %ld)\n", ret, prec);
12868
12869     ret->pfunc = setprecision_func;
12870     ret->arg = prec;
12871     return ret;
12872 }
12873
12874 static void __cdecl setw_func(ios_base *base, streamsize width)
12875 {
12876     ios_base_width_set(base, width);
12877 }
12878
12879 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
12880 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12881 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
12882 {
12883     TRACE("(%p %ld)\n", ret, width);
12884
12885     ret->pfunc = setw_func;
12886     ret->arg = width;
12887     return ret;
12888 }
12889
12890 static void __cdecl resetioflags_func(ios_base *base, int mask)
12891 {
12892     ios_base_setf_mask(base, 0, mask);
12893 }
12894
12895 /* ?resetiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12896 manip_int* __cdecl resetiosflags(manip_int *ret, int mask)
12897 {
12898     TRACE("(%p %d)\n", ret, mask);
12899
12900     ret->pfunc = resetioflags_func;
12901     ret->arg = mask;
12902     return ret;
12903 }
12904
12905 static void __cdecl setiosflags_func(ios_base *base, int mask)
12906 {
12907     ios_base_setf_mask(base, FMTFLAG_mask, mask);
12908 }
12909
12910 /* ?setiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12911 manip_int* __cdecl setiosflags(manip_int *ret, int mask)
12912 {
12913     TRACE("(%p %d)\n", ret, mask);
12914
12915     ret->pfunc = setiosflags_func;
12916     ret->arg = mask;
12917     return ret;
12918 }
12919
12920 static void __cdecl setbase_func(ios_base *base, int set_base)
12921 {
12922     if(set_base == 10)
12923         set_base = FMTFLAG_dec;
12924     else if(set_base == 8)
12925         set_base = FMTFLAG_oct;
12926     else if(set_base == 16)
12927         set_base = FMTFLAG_hex;
12928     else
12929         set_base = 0;
12930
12931     ios_base_setf_mask(base, set_base, FMTFLAG_basefield);
12932 }
12933
12934 /* ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z */
12935 manip_int* __cdecl setbase(manip_int *ret, int base)
12936 {
12937     TRACE("(%p %d)\n", ret, base);
12938
12939     ret->pfunc = setbase_func;
12940     ret->arg = base;
12941     return ret;
12942 }
12943
12944 static basic_filebuf_char filebuf_char_stdin;
12945 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
12946 struct {
12947     basic_istream_char obj;
12948     basic_ios_char vbase;
12949 } cin = { { 0 } };
12950 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
12951 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
12952 basic_istream_char *_Ptr_cin = &cin.obj;
12953
12954 static basic_filebuf_wchar filebuf_short_stdin;
12955 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
12956 struct {
12957     basic_istream_wchar obj;
12958     basic_ios_wchar vbase;
12959 } ucin = { { 0 } };
12960 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
12961 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
12962 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
12963
12964 static basic_filebuf_wchar filebuf_wchar_stdin;
12965 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12966 struct {
12967     basic_istream_wchar obj;
12968     basic_ios_wchar vbase;
12969 } wcin = { { 0 } };
12970 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12971 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
12972 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
12973
12974 static basic_filebuf_char filebuf_char_stdout;
12975 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12976 struct {
12977     basic_ostream_char obj;
12978     basic_ios_char vbase;
12979 } cout = { { 0 } };
12980 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12981 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12982 basic_ostream_char *_Ptr_cout = &cout.obj;
12983
12984 static basic_filebuf_wchar filebuf_short_stdout;
12985 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12986 struct {
12987     basic_ostream_wchar obj;
12988     basic_ios_wchar vbase;
12989 } ucout = { { 0 } };
12990 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12991 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12992 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
12993
12994 static basic_filebuf_wchar filebuf_wchar_stdout;
12995 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12996 struct {
12997     basic_ostream_wchar obj;
12998     basic_ios_wchar vbase;
12999 } wcout = { { 0 } };
13000 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13001 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
13002 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
13003
13004 static basic_filebuf_char filebuf_char_stderr;
13005 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
13006 struct {
13007     basic_ostream_char obj;
13008     basic_ios_char vbase;
13009 } cerr = { { 0 } };
13010 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
13011 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
13012 basic_ostream_char *_Ptr_cerr = &cerr.obj;
13013
13014 static basic_filebuf_wchar filebuf_short_stderr;
13015 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
13016 struct {
13017     basic_ostream_wchar obj;
13018     basic_ios_wchar vbase;
13019 } ucerr = { { 0 } };
13020 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
13021 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
13022 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
13023
13024 static basic_filebuf_wchar filebuf_wchar_stderr;
13025 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13026 struct {
13027     basic_ostream_wchar obj;
13028     basic_ios_wchar vbase;
13029 } wcerr = { { 0 } };
13030 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13031 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
13032 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
13033
13034 static basic_filebuf_char filebuf_char_log;
13035 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
13036 struct {
13037     basic_ostream_char obj;
13038     basic_ios_char vbase;
13039 } clog = { { 0 } };
13040 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
13041 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
13042 basic_ostream_char *_Ptr_clog = &clog.obj;
13043
13044 static basic_filebuf_wchar filebuf_short_log;
13045 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
13046 struct {
13047     basic_ostream_wchar obj;
13048     basic_ios_wchar vbase;
13049 } uclog = { { 0 } };
13050 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
13051 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
13052 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
13053
13054 static basic_filebuf_wchar filebuf_wchar_log;
13055 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13056 struct {
13057     basic_ostream_wchar obj;
13058     basic_ios_wchar vbase;
13059 } wclog = { { 0 } };
13060 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
13061 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
13062 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
13063
13064 /* ?_Init_cnt@Init@ios_base@std@@0HA */
13065 int ios_base_Init__Init_cnt = -1;
13066
13067 /* ?_Init_cnt_func@Init@ios_base@std@@CAAAHXZ */
13068 /* ?_Init_cnt_func@Init@ios_base@std@@CAAEAHXZ */
13069 int* __cdecl ios_base_Init__Init_cnt_func(void)
13070 {
13071     return &ios_base_Init__Init_cnt;
13072 }
13073
13074 /* ?_Init_ctor@Init@ios_base@std@@CAXPAV123@@Z */
13075 /* ?_Init_ctor@Init@ios_base@std@@CAXPEAV123@@Z */
13076 void __cdecl ios_base_Init__Init_ctor(void *this)
13077 {
13078     TRACE("(%p)\n", this);
13079
13080     if(ios_base_Init__Init_cnt < 0)
13081         ios_base_Init__Init_cnt = 1;
13082     else
13083         ios_base_Init__Init_cnt++;
13084 }
13085
13086 /* ??0Init@ios_base@std@@QAE@XZ */
13087 /* ??0Init@ios_base@std@@QEAA@XZ */
13088 DEFINE_THISCALL_WRAPPER(ios_base_Init_ctor, 4)
13089 void* __thiscall ios_base_Init_ctor(void *this)
13090 {
13091     ios_base_Init__Init_ctor(this);
13092     return this;
13093 }
13094
13095 /* ?_Init_dtor@Init@ios_base@std@@CAXPAV123@@Z */
13096 /* ?_Init_dtor@Init@ios_base@std@@CAXPEAV123@@Z */
13097 void __cdecl ios_base_Init__Init_dtor(void *this)
13098 {
13099     TRACE("(%p)\n", this);
13100
13101     ios_base_Init__Init_cnt--;
13102     if(!ios_base_Init__Init_cnt) {
13103         basic_ostream_char_flush(&cout.obj);
13104         basic_ostream_char_flush(&cerr.obj);
13105         basic_ostream_char_flush(&clog.obj);
13106     }
13107 }
13108
13109 /* ??1Init@ios_base@std@@QAE@XZ */
13110 /* ??1Init@ios_base@std@@QEAA@XZ */
13111 DEFINE_THISCALL_WRAPPER(ios_base_Init_dtor, 4)
13112 void __thiscall ios_base_Init_dtor(void *this)
13113 {
13114     ios_base_Init__Init_dtor(this);
13115 }
13116
13117 /* ??4Init@ios_base@std@@QAEAAV012@ABV012@@Z */
13118 /* ??4Init@ios_base@std@@QEAAAEAV012@AEBV012@@Z */
13119 DEFINE_THISCALL_WRAPPER(ios_base_Init_op_assign, 8)
13120 void* __thiscall ios_base_Init_op_assign(void *this, void *rhs)
13121 {
13122     TRACE("(%p %p)\n", this, rhs);
13123     return this;
13124 }
13125
13126 /* ?_Init_cnt@_Winit@std@@0HA */
13127 int _Winit__Init_cnt = -1;
13128
13129 /* ??0_Winit@std@@QAE@XZ */
13130 /* ??0_Winit@std@@QEAA@XZ */
13131 DEFINE_THISCALL_WRAPPER(_Winit_ctor, 4)
13132 void* __thiscall _Winit_ctor(void *this)
13133 {
13134     TRACE("(%p)\n", this);
13135
13136     if(_Winit__Init_cnt < 0)
13137         _Winit__Init_cnt = 1;
13138     else
13139         _Winit__Init_cnt++;
13140
13141     return this;
13142 }
13143
13144 /* ??1_Winit@std@@QAE@XZ */
13145 /* ??1_Winit@std@@QAE@XZ */
13146 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)
13147 void __thiscall _Winit_dtor(void *this)
13148 {
13149     TRACE("(%p)\n", this);
13150
13151     _Winit__Init_cnt--;
13152     if(!_Winit__Init_cnt) {
13153         basic_ostream_wchar_flush(&wcout.obj);
13154         basic_ostream_wchar_flush(&wcerr.obj);
13155         basic_ostream_wchar_flush(&wclog.obj);
13156     }
13157 }
13158
13159 /* ??4_Winit@std@@QAEAAV01@ABV01@@Z */
13160 /* ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z */
13161 DEFINE_THISCALL_WRAPPER(_Winit_op_assign, 8)
13162 void* __thiscall _Winit_op_assign(void *this, void *rhs)
13163 {
13164     TRACE("(%p %p)\n", this, rhs);
13165     return this;
13166 }
13167
13168 void init_io(void *base)
13169 {
13170 #ifdef __x86_64__
13171     init_iosb_rtti(base);
13172     init_ios_base_rtti(base);
13173     init_basic_ios_char_rtti(base);
13174     init_basic_ios_wchar_rtti(base);
13175     init_basic_ios_short_rtti(base);
13176     init_basic_streambuf_char_rtti(base);
13177     init_basic_streambuf_wchar_rtti(base);
13178     init_basic_streambuf_short_rtti(base);
13179     init_basic_filebuf_char_rtti(base);
13180     init_basic_filebuf_wchar_rtti(base);
13181     init_basic_filebuf_short_rtti(base);
13182     init_basic_stringbuf_char_rtti(base);
13183     init_basic_stringbuf_wchar_rtti(base);
13184     init_basic_stringbuf_short_rtti(base);
13185     init_basic_ostream_char_rtti(base);
13186     init_basic_ostream_wchar_rtti(base);
13187     init_basic_ostream_short_rtti(base);
13188     init_basic_istream_char_rtti(base);
13189     init_basic_istream_wchar_rtti(base);
13190     init_basic_istream_short_rtti(base);
13191     init_basic_iostream_char_rtti(base);
13192     init_basic_iostream_wchar_rtti(base);
13193     init_basic_iostream_short_rtti(base);
13194     init_basic_ofstream_char_rtti(base);
13195     init_basic_ofstream_wchar_rtti(base);
13196     init_basic_ofstream_short_rtti(base);
13197     init_basic_ifstream_char_rtti(base);
13198     init_basic_ifstream_wchar_rtti(base);
13199     init_basic_ifstream_short_rtti(base);
13200     init_basic_fstream_char_rtti(base);
13201     init_basic_fstream_wchar_rtti(base);
13202     init_basic_fstream_short_rtti(base);
13203     init_basic_ostringstream_char_rtti(base);
13204     init_basic_ostringstream_wchar_rtti(base);
13205     init_basic_ostringstream_short_rtti(base);
13206     init_basic_istringstream_char_rtti(base);
13207     init_basic_istringstream_wchar_rtti(base);
13208     init_basic_istringstream_short_rtti(base);
13209     init_basic_stringstream_char_rtti(base);
13210     init_basic_stringstream_wchar_rtti(base);
13211     init_basic_stringstream_short_rtti(base);
13212     init_strstreambuf_rtti(base);
13213 #endif
13214
13215     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
13216     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
13217
13218     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
13219     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
13220
13221     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
13222     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
13223
13224     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
13225     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE);
13226
13227     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
13228     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE);
13229
13230     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
13231     basic_ostream_wchar_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE);
13232
13233     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
13234     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE);
13235
13236     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
13237     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE);
13238
13239     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
13240     basic_ostream_wchar_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE);
13241
13242     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
13243     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE);
13244
13245     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
13246     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE);
13247
13248     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
13249     basic_ostream_wchar_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE);
13250 }
13251
13252 void free_io(void)
13253 {
13254     basic_istream_char_vbase_dtor(&cin.obj);
13255     basic_filebuf_char_dtor(&filebuf_char_stdin);
13256
13257     basic_istream_wchar_vbase_dtor(&ucin.obj);
13258     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
13259
13260     basic_istream_wchar_vbase_dtor(&wcin.obj);
13261     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
13262
13263     basic_ostream_char_vbase_dtor(&cout.obj);
13264     basic_filebuf_char_dtor(&filebuf_char_stdout);
13265
13266     basic_ostream_wchar_vbase_dtor(&ucout.obj);
13267     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
13268
13269     basic_ostream_wchar_vbase_dtor(&wcout.obj);
13270     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
13271
13272     basic_ostream_char_vbase_dtor(&cerr.obj);
13273     basic_filebuf_char_dtor(&filebuf_char_stderr);
13274
13275     basic_ostream_wchar_vbase_dtor(&ucerr.obj);
13276     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
13277
13278     basic_ostream_wchar_vbase_dtor(&wcerr.obj);
13279     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
13280
13281     basic_ostream_char_vbase_dtor(&clog.obj);
13282     basic_filebuf_char_dtor(&filebuf_char_log);
13283
13284     basic_ostream_wchar_vbase_dtor(&uclog.obj);
13285     basic_filebuf_wchar_dtor(&filebuf_short_log);
13286
13287     basic_ostream_wchar_vbase_dtor(&wclog.obj);
13288     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
13289 }