msvcp: Sync implementations.
[wine] / dlls / msvcp60 / ios.c
1 /*
2  * Copyright 2011 Piotr Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <limits.h>
24 #include <share.h>
25 #include <locale.h>
26
27 #include "msvcp.h"
28 #include "windef.h"
29 #include "winbase.h"
30 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
32
33 /* ?_Index@ios_base@std@@0HA */
34 int ios_base_Index = 0;
35 /* ?_Sync@ios_base@std@@0_NA */
36 MSVCP_bool ios_base_Sync = FALSE;
37
38 typedef struct {
39     streamoff off;
40     __int64 DECLSPEC_ALIGN(8) pos;
41     int state;
42 } fpos_int;
43
44 static inline const char* debugstr_fpos_int(fpos_int *fpos)
45 {
46     return wine_dbg_sprintf("fpos(%ld %s %d)", fpos->off, wine_dbgstr_longlong(fpos->pos), fpos->state);
47 }
48
49 typedef struct {
50     void (__cdecl *pfunc)(ios_base*, streamsize);
51     streamsize arg;
52 } manip_streamsize;
53
54 typedef struct {
55     void (__cdecl *pfunc)(ios_base*, int);
56     int arg;
57 } manip_int;
58
59 typedef enum {
60     INITFL_new   = 0,
61     INITFL_open  = 1,
62     INITFL_close = 2
63 } basic_filebuf__Initfl;
64
65 typedef struct {
66     basic_streambuf_char base;
67     codecvt_char *cvt;
68     int state0;
69     int state;
70     basic_string_char *str;
71     MSVCP_bool close;
72     locale loc;
73     FILE *file;
74 } basic_filebuf_char;
75
76 typedef struct {
77     basic_streambuf_wchar base;
78     codecvt_wchar *cvt;
79     int state0;
80     int state;
81     basic_string_char *str;
82     MSVCP_bool close;
83     locale loc;
84     FILE *file;
85 } basic_filebuf_wchar;
86
87 typedef enum {
88     STRINGBUF_allocated = 1,
89     STRINGBUF_no_write = 2,
90     STRINGBUF_no_read = 4,
91     STRINGBUF_append = 8,
92     STRINGBUF_at_end = 16
93 } basic_stringbuf_state;
94
95 typedef struct {
96     basic_streambuf_char base;
97     char *pendsave;
98     char *seekhigh;
99     int alsize;
100     int state;
101     char allocator; /* empty struct */
102 } basic_stringbuf_char;
103
104 typedef struct {
105     basic_streambuf_wchar base;
106     wchar_t *pendsave;
107     wchar_t *seekhigh;
108     int alsize;
109     int state;
110     char allocator; /* empty struct */
111 } basic_stringbuf_wchar;
112
113 typedef struct {
114     ios_base base;
115     basic_streambuf_char *strbuf;
116     struct _basic_ostream_char *stream;
117     char fillch;
118 } basic_ios_char;
119
120 typedef struct {
121     ios_base base;
122     basic_streambuf_wchar *strbuf;
123     struct _basic_ostream_wchar *stream;
124     wchar_t fillch;
125 } basic_ios_wchar;
126
127 typedef struct _basic_ostream_char {
128     const int *vbtable;
129     /* virtual inheritance
130      * basic_ios_char basic_ios;
131      */
132 } basic_ostream_char;
133
134 typedef struct _basic_ostream_wchar {
135     const int *vbtable;
136     /* virtual inheritance
137      * basic_ios_wchar basic_ios;
138      */
139 } basic_ostream_wchar;
140
141 typedef struct {
142     const int *vbtable;
143     streamsize count;
144     /* virtual inheritance
145      * basic_ios_char basic_ios;
146      */
147 } basic_istream_char;
148
149 typedef struct {
150     const int *vbtable;
151     streamsize count;
152     /* virtual inheritance
153      * basic_ios_wchar basic_ios;
154      */
155 } basic_istream_wchar;
156
157 typedef struct {
158     basic_istream_char base1;
159     basic_ostream_char base2;
160     /* virtual inheritance
161      * basic_ios_char basic_ios;
162      */
163 } basic_iostream_char;
164
165 typedef struct {
166     basic_istream_wchar base1;
167     basic_ostream_wchar base2;
168     /* virtual inheritance
169      * basic_ios_wchar basic_ios;
170      */
171 } basic_iostream_wchar;
172
173 typedef struct {
174     basic_ostream_char base;
175     basic_filebuf_char filebuf;
176     /* virtual inheritance
177      * basic_ios_char basic_ios;
178      */
179 } basic_ofstream_char;
180
181 typedef struct {
182     basic_ostream_wchar base;
183     basic_filebuf_wchar filebuf;
184     /* virtual inheritance
185      * basic_ios_wchar basic_ios;
186      */
187 } basic_ofstream_wchar;
188
189 typedef struct {
190     basic_istream_char base;
191     basic_filebuf_char filebuf;
192     /* virtual inheritance
193      * basic_ios_char basic_ios;
194      */
195 } basic_ifstream_char;
196
197 typedef struct {
198     basic_istream_wchar base;
199     basic_filebuf_wchar filebuf;
200     /* virtual inheritance
201      * basic_ios_wchar basic_ios;
202      */
203 } basic_ifstream_wchar;
204
205 typedef struct {
206     basic_iostream_char base;
207     basic_filebuf_char filebuf;
208     /* virtual inheritance
209      * basic_ios_char basic_ios;
210      */
211 } basic_fstream_char;
212
213 typedef struct {
214     basic_iostream_wchar base;
215     basic_filebuf_wchar filebuf;
216     /* virtual inheritance
217      * basic_ios_char basic_ios;
218      */
219 } basic_fstream_wchar;
220
221 typedef struct {
222     basic_ostream_char base;
223     basic_stringbuf_char strbuf;
224     /* virtual inheritance
225      * basic_ios_char basic_ios;
226      */
227 } basic_ostringstream_char;
228
229 typedef struct {
230     basic_ostream_wchar base;
231     basic_stringbuf_wchar strbuf;
232     /* virtual inheritance
233      * basic_ios_wchar basic_ios;
234      */
235 } basic_ostringstream_wchar;
236
237 typedef struct {
238     basic_istream_char base;
239     basic_stringbuf_char strbuf;
240     /* virtual inheritance
241      * basic_ios_char basic_ios;
242      */
243 } basic_istringstream_char;
244
245 typedef struct {
246     basic_istream_wchar base;
247     basic_stringbuf_wchar strbuf;
248     /* virtual inheritance
249      * basic_ios_wchar basic_ios;
250      */
251 } basic_istringstream_wchar;
252
253 typedef struct {
254     basic_iostream_char base;
255     basic_stringbuf_char strbuf;
256     /* virtual inheritance
257      * basic_ios_char basic_ios;
258      */
259 } basic_stringstream_char;
260
261 typedef struct {
262     basic_iostream_wchar base;
263     basic_stringbuf_wchar strbuf;
264     /* virtual inheritance
265      * basic_ios_wchar basic_ios;
266      */
267 } basic_stringstream_wchar;
268
269 typedef enum {
270     STRSTATE_Allocated = 1,
271     STRSTATE_Constant = 2,
272     STRSTATE_Dynamic = 4,
273     STRSTATE_Frozen = 8
274 } strstreambuf__Strstate;
275
276 typedef struct {
277     basic_streambuf_char base;
278     streamsize minsize;
279     char *endsave;
280     char *seekhigh;
281     int strmode;
282     void* (__cdecl *palloc)(MSVCP_size_t);
283     void (__cdecl *pfree)(void*);
284 } strstreambuf;
285
286 typedef struct {
287     basic_ostream_char base;
288     strstreambuf buf;
289     /* virtual inheritance
290      * basic_ios_char basic_ios;
291      */
292 } ostrstream;
293
294 typedef struct {
295     basic_istream_char base;
296     strstreambuf buf;
297     /* virtual inheritance
298      * basic_ios_char basic_ios;
299      */
300 } istrstream;
301
302 typedef struct {
303     basic_iostream_char base;
304     strstreambuf buf;
305     /* virtual inheritance
306      * basic_ios_char basic_ios;
307      */
308 } strstream;
309
310 extern const vtable_ptr MSVCP_iosb_vtable;
311
312 /* ??_7ios_base@std@@6B@ */
313 extern const vtable_ptr MSVCP_ios_base_vtable;
314
315 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
316 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
317
318 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
319 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
320
321 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
322 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
323
324 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
325 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
326
327 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
328 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
329
330 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
331 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
332
333 /* ??_7?$basic_filebuf@DU?$char_traits@D@std@@@std@@6B@ */
334 extern const vtable_ptr MSVCP_basic_filebuf_char_vtable;
335
336 /* ??_7?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@6B@ */
337 extern const vtable_ptr MSVCP_basic_filebuf_wchar_vtable;
338
339 /* ??_7?$basic_filebuf@GU?$char_traits@G@std@@@std@@6B@ */
340 extern const vtable_ptr MSVCP_basic_filebuf_short_vtable;
341
342 /* ??_7?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
343 extern const vtable_ptr MSVCP_basic_stringbuf_char_vtable;
344
345 /* ??_7?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
346 extern const vtable_ptr MSVCP_basic_stringbuf_wchar_vtable;
347
348 /* ??_7?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
349 extern const vtable_ptr MSVCP_basic_stringbuf_short_vtable;
350
351 /* ??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@ */
352 const int basic_ostream_char_vbtable[] = {0, sizeof(basic_ostream_char)};
353 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
354 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
355
356 /* ??_8?$basic_ostream@_WU?$char_traits@_W@std@@@std@@7B@ */
357 const int basic_ostream_wchar_vbtable[] = {0, sizeof(basic_ostream_wchar)};
358 /* ??_7?$basic_ostream@_WU?$char_traits@_W@std@@@std@@6B@ */
359 extern const vtable_ptr MSVCP_basic_ostream_wchar_vtable;
360
361 /* ??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@ */
362 const int basic_ostream_short_vbtable[] = {0, sizeof(basic_ostream_wchar)};
363 /* ??_7?$basic_ostream@GU?$char_traits@G@std@@@std@@6B@ */
364 extern const vtable_ptr MSVCP_basic_ostream_short_vtable;
365
366 /* ??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@ */
367 const int basic_istream_char_vbtable[] = {0, sizeof(basic_istream_char)};
368 /* ??_7?$basic_istream@DU?$char_traits@D@std@@@std@@6B@ */
369 extern const vtable_ptr MSVCP_basic_istream_char_vtable;
370
371 /* ??_8?$basic_istream@_WU?$char_traits@_W@std@@@std@@7B@ */
372 const int basic_istream_wchar_vbtable[] = {0, sizeof(basic_istream_wchar)};
373 /* ??_7?$basic_istream@_WU?$char_traits@_W@std@@@std@@6B@ */
374 extern const vtable_ptr MSVCP_basic_istream_wchar_vtable;
375
376 /* ??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@ */
377 const int basic_istream_short_vbtable[] = {0, sizeof(basic_istream_wchar)};
378 /* ??_7?$basic_istream@GU?$char_traits@G@std@@@std@@6B@ */
379 extern const vtable_ptr MSVCP_basic_istream_short_vtable;
380
381 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
382 const int basic_iostream_char_vbtable1[] = {0, sizeof(basic_iostream_char)};
383 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
384 const int basic_iostream_char_vbtable2[] = {0, sizeof(basic_iostream_char)-FIELD_OFFSET(basic_iostream_char, base2)};
385 /* ??_7?$basic_iostream@DU?$char_traits@D@std@@@std@@6B@ */
386 extern const vtable_ptr MSVCP_basic_iostream_char_vtable;
387
388 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
389 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
390 const int basic_iostream_wchar_vbtable1[] = {0, sizeof(basic_iostream_wchar)};
391 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
392 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
393 const int basic_iostream_wchar_vbtable2[] = {0, sizeof(basic_iostream_wchar)-FIELD_OFFSET(basic_iostream_wchar, base2)};
394 /* ??_7?$basic_iostream@_WU?$char_traits@_W@std@@@std@@6B@ */
395 extern const vtable_ptr MSVCP_basic_iostream_wchar_vtable;
396 /* ??_7?$basic_iostream@GU?$char_traits@G@std@@@std@@6B@ */
397 extern const vtable_ptr MSVCP_basic_iostream_short_vtable;
398
399 /* ??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@ */
400 const int basic_ofstream_char_vbtable[] = {0, sizeof(basic_ofstream_char)};
401 /* ??_7?$basic_ofstream@DU?$char_traits@D@std@@@std@@6B@ */
402 extern const vtable_ptr MSVCP_basic_ofstream_char_vtable;
403
404 /* ??_8?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@7B@ */
405 const int basic_ofstream_wchar_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
406 /* ??_7?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@6B@ */
407 extern const vtable_ptr MSVCP_basic_ofstream_wchar_vtable;
408
409 /* ??_8?$basic_ofstream@GU?$char_traits@G@std@@@std@@7B@ */
410 const int basic_ofstream_short_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
411 /* ??_7?$basic_ofstream@GU?$char_traits@G@std@@@std@@6B@ */
412 extern const vtable_ptr MSVCP_basic_ofstream_short_vtable;
413
414 /* ??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@ */
415 const int basic_ifstream_char_vbtable[] = {0, sizeof(basic_ifstream_char)};
416 /* ??_7?$basic_ifstream@DU?$char_traits@D@std@@@std@@6B@ */
417 extern const vtable_ptr MSVCP_basic_ifstream_char_vtable;
418
419 /* ??_8?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@7B@ */
420 const int basic_ifstream_wchar_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
421 /* ??_7?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@6B@ */
422 extern const vtable_ptr MSVCP_basic_ifstream_wchar_vtable;
423
424 /* ??_8?$basic_ifstream@GU?$char_traits@G@std@@@std@@7B@ */
425 const int basic_ifstream_short_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
426 /* ??_7?$basic_ifstream@GU?$char_traits@G@std@@@std@@6B@ */
427 extern const vtable_ptr MSVCP_basic_ifstream_short_vtable;
428
429 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
430 const int basic_fstream_char_vbtable1[] = {0, sizeof(basic_fstream_char)};
431 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
432 const int basic_fstream_char_vbtable2[] = {0, sizeof(basic_fstream_char)-FIELD_OFFSET(basic_fstream_char, base.base2)};
433 /* ??_7?$basic_fstream@DU?$char_traits@D@std@@@std@@6B@ */
434 extern const vtable_ptr MSVCP_basic_fstream_char_vtable;
435
436 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
437 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
438 const int basic_fstream_wchar_vbtable1[] = {0, sizeof(basic_fstream_wchar)};
439 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
440 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
441 const int basic_fstream_wchar_vbtable2[] = {0, sizeof(basic_fstream_wchar)-FIELD_OFFSET(basic_fstream_wchar, base.base2)};
442 /* ??_7?$basic_fstream@_WU?$char_traits@_W@std@@@std@@6B@ */
443 extern const vtable_ptr MSVCP_basic_fstream_wchar_vtable;
444 /* ??_7?$basic_fstream@GU?$char_traits@G@std@@@std@@6B@ */
445 extern const vtable_ptr MSVCP_basic_fstream_short_vtable;
446
447 /* ??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
448 const int basic_ostringstream_char_vbtable[] = {0, sizeof(basic_ostringstream_char)};
449 /* ??_7?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
450 extern const vtable_ptr MSVCP_basic_ostringstream_char_vtable;
451
452 /* ??_8?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
453 const int basic_ostringstream_wchar_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
454 /* ??_7?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
455 extern const vtable_ptr MSVCP_basic_ostringstream_wchar_vtable;
456
457 /* ??_8?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
458 const int basic_ostringstream_short_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
459 /* ??_7?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
460 extern const vtable_ptr MSVCP_basic_ostringstream_short_vtable;
461
462 /* ??_8?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
463 const int basic_istringstream_char_vbtable[] = {0, sizeof(basic_istringstream_char)};
464 /* ??_7?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
465 extern const vtable_ptr MSVCP_basic_istringstream_char_vtable;
466
467 /* ??_8?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
468 const int basic_istringstream_wchar_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
469 /* ??_7?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
470 extern const vtable_ptr MSVCP_basic_istringstream_wchar_vtable;
471
472 /* ??_8?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
473 const int basic_istringstream_short_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
474 /* ??_7?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
475 extern const vtable_ptr MSVCP_basic_istringstream_short_vtable;
476
477 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
478 const int basic_stringstream_char_vbtable1[] = {0, sizeof(basic_stringstream_char)};
479 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
480 const int basic_stringstream_char_vbtable2[] = {0, sizeof(basic_stringstream_char)-FIELD_OFFSET(basic_stringstream_char, base.base2)};
481 /* ??_7?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
482 extern const vtable_ptr MSVCP_basic_stringstream_char_vtable;
483
484 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
485 const int basic_stringstream_wchar_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
486 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
487 const int basic_stringstream_wchar_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
488 /* ??_7?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
489 extern const vtable_ptr MSVCP_basic_stringstream_wchar_vtable;
490
491 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
492 const int basic_stringstream_short_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
493 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
494 const int basic_stringstream_short_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
495 /* ??_7?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
496 extern const vtable_ptr MSVCP_basic_stringstream_short_vtable;
497
498 /* ??_7strstreambuf@std@@6B */
499 extern const vtable_ptr MSVCP_strstreambuf_vtable;
500
501 static const int ostrstream_vbtable[] = {0, sizeof(ostrstream)};
502 extern const vtable_ptr MSVCP_ostrstream_vtable;
503
504 static const int istrstream_vbtable[] = {0, sizeof(istrstream)};
505
506 static const int strstream_vbtable1[] = {0, sizeof(strstream)};
507 static const int strstream_vbtable2[] = {0, sizeof(strstream)-FIELD_OFFSET(strstream, base.base2)};
508 extern const vtable_ptr MSVCP_strstream_vtable;
509
510 DEFINE_RTTI_DATA0(iosb, 0, ".?AV?$_Iosb@H@std@@");
511 DEFINE_RTTI_DATA1(ios_base, 0, &iosb_rtti_base_descriptor, ".?AV?$_Iosb@H@std@@");
512 DEFINE_RTTI_DATA2(basic_ios_char, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
513         ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@");
514 DEFINE_RTTI_DATA2(basic_ios_wchar, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
515         ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@");
516 DEFINE_RTTI_DATA2(basic_ios_short, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
517         ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@");
518 DEFINE_RTTI_DATA0(basic_streambuf_char, 0,
519         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@");
520 DEFINE_RTTI_DATA0(basic_streambuf_wchar, 0,
521         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@");
522 DEFINE_RTTI_DATA0(basic_streambuf_short, 0,
523         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@");
524 DEFINE_RTTI_DATA1(basic_filebuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
525         ".?AV?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@");
526 DEFINE_RTTI_DATA1(basic_filebuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
527         ".?AV?$basic_filebuf@GU?$char_traits@G@std@@@std@@");
528 DEFINE_RTTI_DATA1(basic_filebuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
529         ".?AV?$basic_filebuf@DU?$char_traits@D@std@@@std@@");
530 DEFINE_RTTI_DATA1(basic_stringbuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
531         ".?AV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
532 DEFINE_RTTI_DATA1(basic_stringbuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
533         ".?AV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
534 DEFINE_RTTI_DATA1(basic_stringbuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
535         ".?AV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
536 DEFINE_RTTI_DATA3(basic_ostream_char, sizeof(basic_ostream_char), &basic_ios_char_rtti_base_descriptor,
537         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
538         ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@");
539 DEFINE_RTTI_DATA3(basic_ostream_wchar, sizeof(basic_ostream_wchar), &basic_ios_wchar_rtti_base_descriptor,
540         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
541         ".?AV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@");
542 DEFINE_RTTI_DATA3(basic_ostream_short, sizeof(basic_ostream_wchar), &basic_ios_short_rtti_base_descriptor,
543         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
544         ".?AV?$basic_ostream@GU?$char_traits@G@std@@@std@@");
545 DEFINE_RTTI_DATA3(basic_istream_char, sizeof(basic_istream_char), &basic_ios_char_rtti_base_descriptor,
546         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
547         ".?AV?$basic_istream@DU?$char_traits@D@std@@@std@@");
548 DEFINE_RTTI_DATA3(basic_istream_wchar, sizeof(basic_istream_wchar), &basic_ios_wchar_rtti_base_descriptor,
549         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
550         ".?AV?$basic_istream@_WU?$char_traits@_W@std@@@std@@");
551 DEFINE_RTTI_DATA3(basic_istream_short, sizeof(basic_istream_wchar), &basic_ios_short_rtti_base_descriptor,
552         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
553         ".?AV?$basic_istream@GU?$char_traits@G@std@@@std@@");
554 DEFINE_RTTI_DATA8(basic_iostream_char, sizeof(basic_iostream_char),
555         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
556         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
557         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
558         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
559         ".?AV?$basic_iostream@DU?$char_traits@D@std@@@std@@");
560 DEFINE_RTTI_DATA8(basic_iostream_wchar, sizeof(basic_iostream_wchar),
561         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
562         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
563         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
564         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
565         ".?AV?$basic_iostream@_WU?$char_traits@_W@std@@@std@@");
566 DEFINE_RTTI_DATA8(basic_iostream_short, sizeof(basic_iostream_wchar),
567         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
568         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
569         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
570         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
571         ".?AV?$basic_iostream@GU?$char_traits@G@std@@@std@@");
572 DEFINE_RTTI_DATA4(basic_ofstream_char, sizeof(basic_ofstream_char),
573         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
574         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
575         ".?AV?$basic_ofstream@DU?$char_traits@D@std@@@std@@");
576 DEFINE_RTTI_DATA4(basic_ofstream_wchar, sizeof(basic_ofstream_wchar),
577         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
578         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
579         ".?AV?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@");
580 DEFINE_RTTI_DATA4(basic_ofstream_short, sizeof(basic_ofstream_wchar),
581         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
582         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
583         ".?AV?$basic_ofstream@GU?$char_traits@G@std@@@std@@");
584 DEFINE_RTTI_DATA4(basic_ifstream_char, sizeof(basic_ifstream_char),
585         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
586         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
587         ".?AV?$basic_ifstream@DU?$char_traits@D@std@@@std@@");
588 DEFINE_RTTI_DATA4(basic_ifstream_wchar, sizeof(basic_ifstream_wchar),
589         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
590         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
591         ".?AV?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@");
592 DEFINE_RTTI_DATA4(basic_ifstream_short, sizeof(basic_ifstream_wchar),
593         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
594         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
595         ".?AV?$basic_ifstream@GU?$char_traits@G@std@@@std@@");
596 DEFINE_RTTI_DATA8(basic_fstream_char, sizeof(basic_fstream_char),
597         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
598         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
599         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
600         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
601         ".?AV?$basic_fstream@DU?$char_traits@D@std@@@std@@");
602 DEFINE_RTTI_DATA8(basic_fstream_wchar, sizeof(basic_fstream_wchar),
603         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
604         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
605         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
606         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
607         ".?AV?$basic_fstream@_WU?$char_traits@_W@std@@@std@@");
608 DEFINE_RTTI_DATA8(basic_fstream_short, sizeof(basic_fstream_wchar),
609         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
610         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
611         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
612         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
613         ".?AV?$basic_fstream@GU?$char_traits@G@std@@@std@@");
614 DEFINE_RTTI_DATA4(basic_ostringstream_char, sizeof(basic_ostringstream_char),
615         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
616         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
617         ".?AV?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
618 DEFINE_RTTI_DATA4(basic_ostringstream_wchar, sizeof(basic_ostringstream_wchar),
619         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
620         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
621         ".?AV?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
622 DEFINE_RTTI_DATA4(basic_ostringstream_short, sizeof(basic_ostringstream_wchar),
623         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
624         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
625         ".?AV?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
626 DEFINE_RTTI_DATA4(basic_istringstream_char, sizeof(basic_istringstream_char),
627         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
628         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
629         ".?AV?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
630 DEFINE_RTTI_DATA4(basic_istringstream_wchar, sizeof(basic_istringstream_wchar),
631         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
632         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
633         ".?AV?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
634 DEFINE_RTTI_DATA4(basic_istringstream_short, sizeof(basic_istringstream_wchar),
635         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
636         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
637         ".?AV?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
638 DEFINE_RTTI_DATA8(basic_stringstream_char, sizeof(basic_stringstream_char),
639         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
640         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
641         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
642         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
643         ".?AV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@");
644 DEFINE_RTTI_DATA8(basic_stringstream_wchar, sizeof(basic_stringstream_wchar),
645         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
646         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
647         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
648         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
649         ".?AV?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@");
650 DEFINE_RTTI_DATA8(basic_stringstream_short, sizeof(basic_stringstream_wchar),
651         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
652         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
653         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
654         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
655         ".?AV?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@");
656 DEFINE_RTTI_DATA1(strstreambuf, sizeof(strstreambuf),
657         &basic_streambuf_char_rtti_base_descriptor, ".?AVstrstreambuf@std@@");
658 DEFINE_RTTI_DATA4(ostrstream, sizeof(ostrstream),
659         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
660         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
661         "?AVostrstream@std@@");
662 DEFINE_RTTI_DATA8(strstream, sizeof(strstream),
663         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
664         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
665         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
666         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
667         "?AVstrstream@std@@");
668
669 #ifndef __GNUC__
670 void __asm_dummy_vtables(void) {
671 #endif
672     __ASM_VTABLE(iosb,
673             VTABLE_ADD_FUNC(iosb_vector_dtor));
674     __ASM_VTABLE(ios_base,
675             VTABLE_ADD_FUNC(ios_base_vector_dtor));
676     __ASM_VTABLE(basic_ios_char,
677             VTABLE_ADD_FUNC(basic_ios_char_vector_dtor));
678     __ASM_VTABLE(basic_ios_wchar,
679             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
680     __ASM_VTABLE(basic_ios_short,
681             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
682     __ASM_VTABLE(basic_streambuf_char,
683             VTABLE_ADD_FUNC(basic_streambuf_char_vector_dtor)
684             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
685             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
686             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
687             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
688             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
689             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
690             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
691             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
692             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
693             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
694             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
695             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
696     __ASM_VTABLE(basic_streambuf_wchar,
697             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
698             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
699             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
700             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
701             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
702             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
703             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
704             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
705             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
706             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
707             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
708             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
709             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
710     __ASM_VTABLE(basic_streambuf_short,
711             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
712             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
713             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
714             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
715             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
716             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
717             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
718             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
719             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
720             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
721             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
722             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
723             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
724     __ASM_VTABLE(basic_filebuf_char,
725             VTABLE_ADD_FUNC(basic_filebuf_char_vector_dtor)
726             VTABLE_ADD_FUNC(basic_filebuf_char_overflow)
727             VTABLE_ADD_FUNC(basic_filebuf_char_pbackfail)
728             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
729             VTABLE_ADD_FUNC(basic_filebuf_char_underflow)
730             VTABLE_ADD_FUNC(basic_filebuf_char_uflow)
731             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
732             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
733             VTABLE_ADD_FUNC(basic_filebuf_char_seekoff)
734             VTABLE_ADD_FUNC(basic_filebuf_char_seekpos)
735             VTABLE_ADD_FUNC(basic_filebuf_char_setbuf)
736             VTABLE_ADD_FUNC(basic_filebuf_char_sync)
737             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
738     __ASM_VTABLE(basic_filebuf_wchar,
739             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
740             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
741             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
742             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
743             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
744             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
745             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
746             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
747             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
748             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
749             VTABLE_ADD_FUNC(basic_filebuf_wchar_setbuf)
750             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
751             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
752     __ASM_VTABLE(basic_filebuf_short,
753             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
754             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
755             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
756             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
757             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
758             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
759             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
760             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
761             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
762             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
763             VTABLE_ADD_FUNC(basic_filebuf_short_setbuf)
764             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
765             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
766     __ASM_VTABLE(basic_stringbuf_char,
767             VTABLE_ADD_FUNC(basic_stringbuf_char_vector_dtor)
768             VTABLE_ADD_FUNC(basic_stringbuf_char_overflow)
769             VTABLE_ADD_FUNC(basic_stringbuf_char_pbackfail)
770             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
771             VTABLE_ADD_FUNC(basic_stringbuf_char_underflow)
772             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
773             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
774             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
775             VTABLE_ADD_FUNC(basic_stringbuf_char_seekoff)
776             VTABLE_ADD_FUNC(basic_stringbuf_char_seekpos)
777             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
778             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
779             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
780     __ASM_VTABLE(basic_stringbuf_wchar,
781             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
782             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
783             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
784             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
785             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
786             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
787             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
788             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
789             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
790             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
791             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
792             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
793             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
794     __ASM_VTABLE(basic_stringbuf_short,
795             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
796             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
797             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
798             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
799             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
800             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
801             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
802             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
803             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
804             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
805             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
806             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
807             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
808     __ASM_VTABLE(basic_ostream_char,
809             VTABLE_ADD_FUNC(basic_ostream_char_vector_dtor));
810     __ASM_VTABLE(basic_ostream_wchar,
811             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
812     __ASM_VTABLE(basic_ostream_short,
813             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
814     __ASM_VTABLE(basic_istream_char,
815             VTABLE_ADD_FUNC(basic_istream_char_vector_dtor));
816     __ASM_VTABLE(basic_istream_wchar,
817             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
818     __ASM_VTABLE(basic_istream_short,
819             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
820     __ASM_VTABLE(basic_iostream_char,
821             VTABLE_ADD_FUNC(basic_iostream_char_vector_dtor));
822     __ASM_VTABLE(basic_iostream_wchar,
823             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
824     __ASM_VTABLE(basic_iostream_short,
825             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
826     __ASM_VTABLE(basic_ofstream_char,
827             VTABLE_ADD_FUNC(basic_ofstream_char_vector_dtor));
828     __ASM_VTABLE(basic_ofstream_wchar,
829             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
830     __ASM_VTABLE(basic_ofstream_short,
831             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
832     __ASM_VTABLE(basic_ifstream_char,
833             VTABLE_ADD_FUNC(basic_ifstream_char_vector_dtor));
834     __ASM_VTABLE(basic_ifstream_wchar,
835             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
836     __ASM_VTABLE(basic_ifstream_short,
837             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
838     __ASM_VTABLE(basic_fstream_char,
839             VTABLE_ADD_FUNC(basic_fstream_char_vector_dtor));
840     __ASM_VTABLE(basic_fstream_wchar,
841             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
842     __ASM_VTABLE(basic_fstream_short,
843             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
844     __ASM_VTABLE(basic_ostringstream_char,
845             VTABLE_ADD_FUNC(basic_ostringstream_char_vector_dtor));
846     __ASM_VTABLE(basic_ostringstream_wchar,
847             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
848     __ASM_VTABLE(basic_ostringstream_short,
849             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
850     __ASM_VTABLE(basic_istringstream_char,
851             VTABLE_ADD_FUNC(basic_istringstream_char_vector_dtor));
852     __ASM_VTABLE(basic_istringstream_wchar,
853             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
854     __ASM_VTABLE(basic_istringstream_short,
855             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
856     __ASM_VTABLE(basic_stringstream_char,
857             VTABLE_ADD_FUNC(basic_stringstream_char_vector_dtor));
858     __ASM_VTABLE(basic_stringstream_wchar,
859             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
860     __ASM_VTABLE(basic_stringstream_short,
861             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
862     __ASM_VTABLE(strstreambuf,
863             VTABLE_ADD_FUNC(strstreambuf_vector_dtor)
864             VTABLE_ADD_FUNC(strstreambuf_overflow)
865             VTABLE_ADD_FUNC(strstreambuf_pbackfail)
866             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
867             VTABLE_ADD_FUNC(strstreambuf_underflow)
868             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
869             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
870             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
871             VTABLE_ADD_FUNC(strstreambuf_seekoff)
872             VTABLE_ADD_FUNC(strstreambuf_seekpos)
873             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
874             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
875             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
876     __ASM_VTABLE(ostrstream,
877             VTABLE_ADD_FUNC(ostrstream_vector_dtor));
878     __ASM_VTABLE(strstream,
879             VTABLE_ADD_FUNC(strstream_vector_dtor));
880 #ifndef __GNUC__
881 }
882 #endif
883
884 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
885 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
886 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
887 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
888 {
889     TRACE("(%p %p %p %p)\n", this, first, next, last);
890
891     this->wbuf = first;
892     this->wpos = next;
893     this->wsize = last-next;
894 }
895
896 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
897 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
898 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
899 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
900 {
901     basic_streambuf_char_setp_next(this, first, first, last);
902 }
903
904 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
905 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
906 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
907 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
908 {
909     TRACE("(%p %p %p %p)\n", this, first, next, last);
910
911     this->rbuf = first;
912     this->rpos = next;
913     this->rsize = last-next;
914 }
915
916 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
917 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
918 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
919 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
920 {
921     TRACE("(%p)\n", this);
922
923     this->prbuf = &this->rbuf;
924     this->pwbuf = &this->wbuf;
925     this->prpos = &this->rpos;
926     this->pwpos = &this->wpos;
927     this->prsize = &this->rsize;
928     this->pwsize = &this->wsize;
929
930     basic_streambuf_char_setp(this, NULL, NULL);
931     basic_streambuf_char_setg(this, NULL, NULL, NULL);
932 }
933
934 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
935 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
936 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
937 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
938 {
939     TRACE("(%p %d)\n", this, uninitialized);
940     this->vtable = &MSVCP_basic_streambuf_char_vtable;
941     return this;
942 }
943
944 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
945 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
946 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
947 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
948 {
949     TRACE("(%p)\n", this);
950
951     this->vtable = &MSVCP_basic_streambuf_char_vtable;
952     locale_ctor(&this->loc);
953     basic_streambuf_char__Init_empty(this);
954
955     return this;
956 }
957
958 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
959 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
960 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
961 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
962 {
963     TRACE("(%p)\n", this);
964
965     locale_dtor(&this->loc);
966 }
967
968 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_vector_dtor, 8)
969 basic_streambuf_char* __thiscall basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
970 {
971     TRACE("(%p %x)\n", this, flags);
972     if(flags & 2) {
973         /* we have an array, with the number of elements stored before the first object */
974         INT_PTR i, *ptr = (INT_PTR *)this-1;
975
976         for(i=*ptr-1; i>=0; i--)
977             basic_streambuf_char_dtor(this+i);
978         MSVCRT_operator_delete(ptr);
979     } else {
980         basic_streambuf_char_dtor(this);
981         if(flags & 1)
982             MSVCRT_operator_delete(this);
983     }
984
985     return this;
986 }
987
988 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
989 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
990 static streamsize basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
991 {
992     TRACE("(%p)\n", this);
993     return *this->prpos ? *this->prsize : 0;
994 }
995
996 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
997 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
998 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
999 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
1000 {
1001     TRACE("(%p)\n", this);
1002     (*this->prsize)++;
1003     (*this->prpos)--;
1004     return *this->prpos;
1005 }
1006
1007 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1008 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1009 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
1010 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
1011 {
1012     TRACE("(%p)\n", this);
1013     (*this->prsize)--;
1014     return (*this->prpos)++;
1015 }
1016
1017 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1018 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1019 static char* basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
1020 {
1021     TRACE("(%p)\n", this);
1022     (*this->prsize)--;
1023     (*this->prpos)++;
1024     return *this->prpos;
1025 }
1026
1027 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
1028 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
1029 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
1030 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
1031 {
1032     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1033
1034     this->prbuf = gf;
1035     this->pwbuf = pf;
1036     this->prpos = gn;
1037     this->pwpos = pn;
1038     this->prsize = gc;
1039     this->pwsize = pc;
1040 }
1041
1042 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1043 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1044 static void basic_streambuf_char__Lock(basic_streambuf_char *this)
1045 {
1046     TRACE("(%p)\n", this);
1047 }
1048
1049 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
1050 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
1051 static streamsize basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
1052 {
1053     TRACE("(%p)\n", this);
1054     return *this->pwpos ? *this->pwsize : 0;
1055 }
1056
1057 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1058 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1059 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
1060 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
1061 {
1062     TRACE("(%p)\n", this);
1063     (*this->pwsize)--;
1064     return (*this->pwpos)++;
1065 }
1066
1067 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1068 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1069 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
1070 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 16, \
1071         int, (basic_streambuf_char*), (this))
1072 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
1073 {
1074     TRACE("(%p)\n", this);
1075     return EOF;
1076 }
1077
1078 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1079 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1080 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
1081 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 20, \
1082         int, (basic_streambuf_char*), (this))
1083 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
1084 {
1085     int ret;
1086
1087     TRACE("(%p)\n", this);
1088
1089     if(call_basic_streambuf_char_underflow(this)==EOF)
1090         return EOF;
1091
1092     ret = (unsigned char)**this->prpos;
1093     (*this->prsize)--;
1094     (*this->prpos)++;
1095     return ret;
1096 }
1097
1098 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
1099 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
1100 static streamsize basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1101 {
1102     streamsize copied, chunk;
1103     int c;
1104
1105     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1106
1107     for(copied=0; copied<count && size;) {
1108         chunk = basic_streambuf_char__Gnavail(this);
1109         if(chunk > count-copied)
1110             chunk = count-copied;
1111
1112         if(chunk > 0) {
1113             memcpy_s(ptr+copied, size, *this->prpos, chunk);
1114             *this->prpos += chunk;
1115             *this->prsize -= chunk;
1116             copied += chunk;
1117             size -= chunk;
1118         }else if((c = call_basic_streambuf_char_uflow(this)) != EOF) {
1119             ptr[copied] = c;
1120             copied++;
1121             size--;
1122         }else {
1123             break;
1124         }
1125     }
1126
1127     return copied;
1128 }
1129
1130 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
1131 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
1132 static streamsize basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
1133 {
1134     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1135     return basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
1136 }
1137
1138 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1139 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1140 static void basic_streambuf_char__Unlock(basic_streambuf_char *this)
1141 {
1142     TRACE("(%p)\n", this);
1143 }
1144
1145 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1146 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1147 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
1148 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
1149 {
1150     TRACE("(%p)\n", this);
1151     return *this->prbuf;
1152 }
1153
1154 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1155 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1156 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
1157 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
1158 {
1159     TRACE("(%p)\n", this);
1160     return *this->prpos;
1161 }
1162
1163 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1164 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1165 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
1166 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
1167 {
1168     TRACE("(%p)\n", this);
1169     return *this->prpos+*this->prsize;
1170 }
1171
1172 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1173 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1174 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
1175 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
1176 {
1177     TRACE("(%p)\n", this);
1178     return *this->pwpos+*this->pwsize;
1179 }
1180
1181 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1182 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1183 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
1184 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
1185 {
1186     TRACE("(%p %d)\n", this, off);
1187     *this->prpos += off;
1188     *this->prsize -= off;
1189 }
1190
1191 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
1192 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
1193 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
1194 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1195         void, (basic_streambuf_char*, const locale*), (this, loc))
1196 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
1197 {
1198     TRACE("(%p %p)\n", this, loc);
1199 }
1200
1201 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1202 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1203 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
1204 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1205         int, (basic_streambuf_char*, int), (this, ch))
1206 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
1207 {
1208     TRACE("(%p %d)\n", this, ch);
1209     return EOF;
1210 }
1211
1212 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1213 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1214 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
1215 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1216         int, (basic_streambuf_char*, int), (this, ch))
1217 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
1218 {
1219     TRACE("(%p %d)\n", this, ch);
1220     return EOF;
1221 }
1222
1223 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1224 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1225 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
1226 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
1227 {
1228     TRACE("(%p)\n", this);
1229     return *this->pwbuf;
1230 }
1231
1232 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1233 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1234 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
1235 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
1236 {
1237     TRACE("(%p %d)\n", this, off);
1238     *this->pwpos += off;
1239     *this->pwsize -= off;
1240 }
1241
1242 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1243 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1244 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
1245 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
1246 {
1247     TRACE("(%p)\n", this);
1248     return *this->pwpos;
1249 }
1250
1251 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1252 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1253 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
1254 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
1255 {
1256     TRACE("(%p %p)\n", this, loc);
1257     memcpy(ret, &this->loc, sizeof(locale));
1258     call_basic_streambuf_char_imbue(this, loc);
1259     locale_copy_ctor(&this->loc, loc);
1260     return ret;
1261 }
1262
1263 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1264 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1265 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
1266 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1267         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1268 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
1269         fpos_int *ret, streamoff off, int way, int mode)
1270 {
1271     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1272     ret->off = -1;
1273     ret->pos = 0;
1274     ret->state = 0;
1275     return ret;
1276 }
1277
1278 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1279 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1280 static fpos_int* basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
1281         fpos_int *ret, streamoff off, int way, int mode)
1282 {
1283     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1284     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
1285 }
1286
1287 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1288 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1289 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
1290 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
1291         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1292 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
1293         fpos_int *ret, fpos_int pos, int mode)
1294 {
1295     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1296     ret->off = -1;
1297     ret->pos = 0;
1298     ret->state = 0;
1299     return ret;
1300 }
1301
1302 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1303 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1304 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
1305 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
1306         fpos_int *ret, fpos_int pos, int mode)
1307 {
1308     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1309     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
1310 }
1311
1312 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
1313 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
1314 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
1315 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
1316         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
1317 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
1318 {
1319     TRACE("(%p %p %ld)\n", this, buf, count);
1320     return this;
1321 }
1322
1323 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
1324 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
1325 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
1326 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
1327 {
1328     TRACE("(%p %p %ld)\n", this, buf, count);
1329     return call_basic_streambuf_char_setbuf(this, buf, count);
1330 }
1331
1332 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1333 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1334 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
1335 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 44, \
1336         int, (basic_streambuf_char*), (this))
1337 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
1338 {
1339     TRACE("(%p)\n", this);
1340     return 0;
1341 }
1342
1343 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1344 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1345 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
1346 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
1347 {
1348     TRACE("(%p)\n", this);
1349     return call_basic_streambuf_char_sync(this);
1350 }
1351
1352 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
1353 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
1354 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
1355 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1356 {
1357     TRACE("(%p %p %ld)\n", this, ptr, count);
1358     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1359 }
1360
1361 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1362 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
1363 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
1364 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1365         streamsize, (basic_streambuf_char*), (this))
1366 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
1367 {
1368     TRACE("(%p)\n", this);
1369     return 0;
1370 }
1371
1372 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1373 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
1374 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
1375 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
1376 {
1377     streamsize ret;
1378
1379     TRACE("(%p)\n", this);
1380
1381     ret = basic_streambuf_char__Gnavail(this);
1382     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
1383 }
1384
1385 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1386 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1387 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
1388 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
1389 {
1390     TRACE("(%p %d)\n", this, ch);
1391     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1392         (*this->prsize)++;
1393         (*this->prpos)--;
1394         return (unsigned char)ch;
1395     }
1396
1397     return call_basic_streambuf_char_pbackfail(this, (unsigned char)ch);
1398 }
1399
1400 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1401 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1402 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
1403 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
1404 {
1405     TRACE("(%p %d)\n", this, ch);
1406     return basic_streambuf_char__Pnavail(this) ?
1407         (*basic_streambuf_char__Pninc(this) = ch) :
1408         call_basic_streambuf_char_overflow(this, (unsigned char)ch);
1409 }
1410
1411 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1412 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1413 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
1414 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
1415 {
1416     TRACE("(%p)\n", this);
1417     if(*this->prpos && *this->prpos>*this->prbuf) {
1418         (*this->prsize)++;
1419         (*this->prpos)--;
1420         return (unsigned char)**this->prpos;
1421     }
1422
1423     return call_basic_streambuf_char_pbackfail(this, EOF);
1424 }
1425
1426 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1427 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1428 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1429 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1430 {
1431     TRACE("(%p)\n", this);
1432     if(basic_streambuf_char__Gnavail(this))
1433         basic_streambuf_char__Gninc(this);
1434     else
1435         call_basic_streambuf_char_uflow(this);
1436 }
1437
1438 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1439 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1440 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1441 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1442 {
1443     TRACE("(%p)\n", this);
1444     return basic_streambuf_char__Gnavail(this) ?
1445         (int)(unsigned char)*basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1446 }
1447
1448 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1449 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1450 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1451 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1452 {
1453     TRACE("(%p)\n", this);
1454     return basic_streambuf_char__Gnavail(this) ?
1455         (int)(unsigned char)*basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1456 }
1457
1458 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1459 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1460 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1461 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1462 {
1463     TRACE("(%p)\n", this);
1464
1465     if(basic_streambuf_char__Gnavail(this) > 1)
1466         return (unsigned char)*basic_streambuf_char__Gnpreinc(this);
1467     return basic_streambuf_char_sbumpc(this)==EOF ?
1468         EOF : basic_streambuf_char_sgetc(this);
1469 }
1470
1471 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1472 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1473 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
1474 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1475         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1476 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1477 {
1478     TRACE("(%p %p %ld)\n", this, ptr, count);
1479     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1480 }
1481
1482 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1483 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1484 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
1485 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
1486         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1487 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1488 {
1489     streamsize copied, chunk;
1490
1491     TRACE("(%p %p %ld)\n", this, ptr, count);
1492
1493     for(copied=0; copied<count;) {
1494         chunk = basic_streambuf_char__Pnavail(this);
1495         if(chunk > count-copied)
1496             chunk = count-copied;
1497
1498         if(chunk > 0) {
1499             memcpy(*this->pwpos, ptr+copied, chunk);
1500             *this->pwpos += chunk;
1501             *this->pwsize -= chunk;
1502             copied += chunk;
1503         }else if(call_basic_streambuf_char_overflow(this, (unsigned char)ptr[copied]) != EOF) {
1504             copied++;
1505         }else {
1506             break;
1507         }
1508     }
1509
1510     return copied;
1511 }
1512
1513 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1514 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1515 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
1516 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1517 {
1518     TRACE("(%p %p %ld)\n", this, ptr, count);
1519     return call_basic_streambuf_char_xsputn(this, ptr, count);
1520 }
1521
1522 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@XZ */
1523 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@XZ */
1524 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_getloc, 8)
1525 locale* __thiscall basic_streambuf_char_getloc(basic_streambuf_char *this, locale *ret)
1526 {
1527     TRACE("(%p %p)\n", this, ret);
1528     return locale_copy_ctor(ret, &this->loc);
1529 }
1530
1531 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1532 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1533 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1534 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1535 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1536 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1537 {
1538     TRACE("(%p %p %p %p)\n", this, first, next, last);
1539
1540     this->wbuf = first;
1541     this->wpos = next;
1542     this->wsize = last-next;
1543 }
1544
1545 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1546 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1547 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1548 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1549 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1550 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1551 {
1552     basic_streambuf_wchar_setp_next(this, first, first, last);
1553 }
1554
1555 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1556 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1557 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1558 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1559 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1560 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1561 {
1562     TRACE("(%p %p %p %p)\n", this, first, next, last);
1563
1564     this->rbuf = first;
1565     this->rpos = next;
1566     this->rsize = last-next;
1567 }
1568
1569 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1570 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1571 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1572 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1573 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1574 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1575 {
1576     TRACE("(%p)\n", this);
1577
1578     this->prbuf = &this->rbuf;
1579     this->pwbuf = &this->wbuf;
1580     this->prpos = &this->rpos;
1581     this->pwpos = &this->wpos;
1582     this->prsize = &this->rsize;
1583     this->pwsize = &this->wsize;
1584
1585     basic_streambuf_wchar_setp(this, NULL, NULL);
1586     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1587 }
1588
1589 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1590 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1591 static basic_streambuf_wchar* basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1592 {
1593     TRACE("(%p %d)\n", this, uninitialized);
1594     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1595     return this;
1596 }
1597
1598 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1599 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1600 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1601 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1602 {
1603     TRACE("(%p %d)\n", this, uninitialized);
1604     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1605     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1606     return this;
1607 }
1608
1609 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1610 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1611 static basic_streambuf_wchar* basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1612 {
1613     TRACE("(%p)\n", this);
1614
1615     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1616     locale_ctor(&this->loc);
1617     basic_streambuf_wchar__Init_empty(this);
1618
1619     return this;
1620 }
1621
1622 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1623 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1624 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1625 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1626 {
1627     TRACE("(%p)\n", this);
1628     basic_streambuf_wchar_ctor(this);
1629     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1630     return this;
1631 }
1632
1633 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1634 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1635 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1636 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1637 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1638 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1639 {
1640     TRACE("(%p)\n", this);
1641
1642     locale_dtor(&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 static streamsize basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1670 {
1671     TRACE("(%p)\n", this);
1672     return *this->prpos ? *this->prsize : 0;
1673 }
1674
1675 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1676 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1677 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1678 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1679 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1680 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1681 {
1682     TRACE("(%p)\n", this);
1683     (*this->prsize)++;
1684     (*this->prpos)--;
1685     return *this->prpos;
1686 }
1687
1688 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1689 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1690 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1691 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1692 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1693 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1694 {
1695     TRACE("(%p)\n", this);
1696     (*this->prsize)--;
1697     return (*this->prpos)++;
1698 }
1699
1700 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1701 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1702 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1703 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1704 static wchar_t* basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1705 {
1706     TRACE("(%p)\n", this);
1707     (*this->prsize)--;
1708     (*this->prpos)++;
1709     return *this->prpos;
1710 }
1711
1712 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1713 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1714 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1715 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1716 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1717 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)
1718 {
1719     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1720
1721     this->prbuf = gf;
1722     this->pwbuf = pf;
1723     this->prpos = gn;
1724     this->pwpos = pn;
1725     this->prsize = gc;
1726     this->pwsize = pc;
1727 }
1728
1729 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1730 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1731 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1732 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1733 static void basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1734 {
1735     TRACE("(%p)\n", this);
1736 }
1737
1738 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1739 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1740 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1741 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1742 static streamsize basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1743 {
1744     TRACE("(%p)\n", this);
1745     return *this->pwpos ? *this->pwsize : 0;
1746 }
1747
1748 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1749 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1750 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1751 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1752 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1753 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1754 {
1755     TRACE("(%p)\n", this);
1756     (*this->pwsize)--;
1757     return (*this->pwpos)++;
1758 }
1759
1760 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1761 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1762 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1763 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1764 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1765 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1766         unsigned short, (basic_streambuf_wchar*), (this))
1767 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1768 {
1769     TRACE("(%p)\n", this);
1770     return WEOF;
1771 }
1772
1773 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1774 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1775 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1776 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1777 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1778 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1779         unsigned short, (basic_streambuf_wchar*), (this))
1780 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1781 {
1782     int ret;
1783
1784     TRACE("(%p)\n", this);
1785
1786     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1787         return WEOF;
1788
1789     ret = **this->prpos;
1790     (*this->prsize)--;
1791     (*this->prpos)++;
1792     return ret;
1793 }
1794
1795 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1796 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1797 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1798 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1799 static streamsize basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1800 {
1801     streamsize copied, chunk;
1802     unsigned short c;
1803
1804     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1805
1806     for(copied=0; copied<count && size;) {
1807         chunk = basic_streambuf_wchar__Gnavail(this);
1808         if(chunk > count-copied)
1809             chunk = count-copied;
1810
1811         if(chunk > 0) {
1812             memcpy_s(ptr+copied, size, *this->prpos, chunk*sizeof(wchar_t));
1813             *this->prpos += chunk;
1814             *this->prsize -= chunk;
1815             copied += chunk;
1816             size -= chunk*sizeof(wchar_t);
1817         }else if((c = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1818             ptr[copied] = c;
1819             copied++;
1820             size--;
1821         }else {
1822             break;
1823         }
1824     }
1825
1826     return copied;
1827 }
1828
1829 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1830 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1831 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1832 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1833 static streamsize basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1834 {
1835     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1836     return basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1837 }
1838
1839 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1840 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1841 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1842 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1843 static void basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1844 {
1845     TRACE("(%p)\n", this);
1846 }
1847
1848 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1849 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1850 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1851 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1852 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1853 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1854 {
1855     TRACE("(%p)\n", this);
1856     return *this->prbuf;
1857 }
1858
1859 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1860 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1861 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1862 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1863 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1864 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1865 {
1866     TRACE("(%p)\n", this);
1867     return *this->prpos;
1868 }
1869
1870 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1871 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1872 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1873 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1874 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1875 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1876 {
1877     TRACE("(%p)\n", this);
1878     return *this->prpos+*this->prsize;
1879 }
1880
1881 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1882 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1883 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1884 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1885 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1886 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1887 {
1888     TRACE("(%p)\n", this);
1889     return *this->pwpos+*this->pwsize;
1890 }
1891
1892 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1893 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1894 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1895 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1896 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1897 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1898 {
1899     TRACE("(%p %d)\n", this, off);
1900     *this->prpos += off;
1901     *this->prsize -= off;
1902 }
1903
1904 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1905 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1906 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1907 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1908 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1909 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1910         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1911 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1912 {
1913     TRACE("(%p %p)\n", this, loc);
1914 }
1915
1916 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1917 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1918 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1919 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1920 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1921 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1922         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1923 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1924 {
1925     TRACE("(%p %d)\n", this, ch);
1926     return WEOF;
1927 }
1928
1929 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1930 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1931 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1932 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1933 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1934 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1935         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1936 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1937 {
1938     TRACE("(%p %d)\n", this, ch);
1939     return WEOF;
1940 }
1941
1942 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1943 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1944 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1945 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1946 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1947 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1948 {
1949     TRACE("(%p)\n", this);
1950     return *this->pwbuf;
1951 }
1952
1953 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1954 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1955 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1956 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1957 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1958 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1959 {
1960     TRACE("(%p %d)\n", this, off);
1961     *this->pwpos += off;
1962     *this->pwsize -= off;
1963 }
1964
1965 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1966 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1967 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1968 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1969 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1970 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1971 {
1972     TRACE("(%p)\n", this);
1973     return *this->pwpos;
1974 }
1975
1976 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1977 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1978 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1979 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1980 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
1981 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
1982 {
1983     TRACE("(%p %p)\n", this, loc);
1984     memcpy(ret, &this->loc, sizeof(locale));
1985     call_basic_streambuf_wchar_imbue(this, loc);
1986     locale_copy_ctor(&this->loc, loc);
1987     return ret;
1988 }
1989
1990 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1991 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1992 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1993 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1994 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
1995 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1996         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1997 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
1998         fpos_int *ret, streamoff off, int way, int mode)
1999 {
2000     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2001     ret->off = -1;
2002     ret->pos = 0;
2003     ret->state = 0;
2004     return ret;
2005 }
2006
2007 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2008 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2009 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2010 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2011 static fpos_int* basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
2012         fpos_int *ret, streamoff off, int way, int mode)
2013 {
2014     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2015     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
2016 }
2017
2018 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2019 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2020 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2021 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2022 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
2023 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
2024         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
2025 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
2026         fpos_int *ret, fpos_int pos, int mode)
2027 {
2028     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2029     ret->off = -1;
2030     ret->pos = 0;
2031     ret->state = 0;
2032     return ret;
2033 }
2034
2035 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2036 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2037 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2038 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2039 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
2040 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
2041         fpos_int *ret, fpos_int pos, int mode)
2042 {
2043     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2044     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
2045 }
2046
2047 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
2048 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
2049 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
2050 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
2051 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
2052 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
2053         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
2054 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2055 {
2056     TRACE("(%p %p %ld)\n", this, buf, count);
2057     return this;
2058 }
2059
2060 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
2061 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
2062 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
2063 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
2064 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
2065 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2066 {
2067     TRACE("(%p %p %ld)\n", this, buf, count);
2068     return call_basic_streambuf_wchar_setbuf(this, buf, count);
2069 }
2070
2071 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2072 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2073 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2074 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2075 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
2076 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 44, \
2077         int, (basic_streambuf_wchar*), (this))
2078 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
2079 {
2080     TRACE("(%p)\n", this);
2081     return 0;
2082 }
2083
2084 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2085 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
2086 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2087 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
2088 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
2089 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
2090 {
2091     TRACE("(%p)\n", this);
2092     return call_basic_streambuf_wchar_sync(this);
2093 }
2094
2095 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
2096 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
2097 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
2098 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
2099 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
2100 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2101 {
2102     TRACE("(%p %p %ld)\n", this, ptr, count);
2103     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2104 }
2105
2106 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2107 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
2108 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2109 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
2110 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
2111 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
2112         streamsize, (basic_streambuf_wchar*), (this))
2113 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
2114 {
2115     TRACE("(%p)\n", this);
2116     return 0;
2117 }
2118
2119 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2120 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
2121 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2122 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
2123 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
2124 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
2125 {
2126     streamsize ret;
2127
2128     TRACE("(%p)\n", this);
2129
2130     ret = basic_streambuf_wchar__Gnavail(this);
2131     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
2132 }
2133
2134 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2135 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2136 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2137 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2138 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
2139 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
2140 {
2141     TRACE("(%p %d)\n", this, ch);
2142     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
2143         (*this->prsize)++;
2144         (*this->prpos)--;
2145         return ch;
2146     }
2147
2148     return call_basic_streambuf_wchar_pbackfail(this, ch);
2149 }
2150
2151 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2152 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2153 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2154 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
2155 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
2156 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
2157 {
2158     TRACE("(%p %d)\n", this, ch);
2159     return basic_streambuf_wchar__Pnavail(this) ?
2160         (*basic_streambuf_wchar__Pninc(this) = ch) :
2161         call_basic_streambuf_wchar_overflow(this, ch);
2162 }
2163
2164 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2165 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2166 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2167 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2168 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
2169 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
2170 {
2171     TRACE("(%p)\n", this);
2172     if(*this->prpos && *this->prpos>*this->prbuf) {
2173         (*this->prsize)++;
2174         (*this->prpos)--;
2175         return **this->prpos;
2176     }
2177
2178     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
2179 }
2180
2181 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2182 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2183 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2184 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2185 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
2186 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
2187 {
2188     TRACE("(%p)\n", this);
2189     if(basic_streambuf_wchar__Gnavail(this))
2190         basic_streambuf_wchar__Gninc(this);
2191     else
2192         call_basic_streambuf_wchar_uflow(this);
2193 }
2194
2195 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2196 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2197 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2198 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2199 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
2200 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
2201 {
2202     TRACE("(%p)\n", this);
2203     return basic_streambuf_wchar__Gnavail(this) ?
2204         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
2205 }
2206
2207 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2208 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2209 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2210 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2211 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
2212 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
2213 {
2214     TRACE("(%p)\n", this);
2215     return basic_streambuf_wchar__Gnavail(this) ?
2216         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
2217 }
2218
2219 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2220 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2221 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2222 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2223 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
2224 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
2225 {
2226     TRACE("(%p)\n", this);
2227
2228     if(basic_streambuf_wchar__Gnavail(this) > 1)
2229         return *basic_streambuf_wchar__Gnpreinc(this);
2230     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
2231         WEOF : basic_streambuf_wchar_sgetc(this);
2232 }
2233
2234 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
2235 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
2236 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
2237 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
2238 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
2239 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
2240         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
2241 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2242 {
2243     TRACE("(%p %p %ld)\n", this, ptr, count);
2244     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2245 }
2246
2247 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
2248 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
2249 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
2250 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
2251 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
2252 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
2253         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
2254 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2255 {
2256     streamsize copied, chunk;
2257
2258     TRACE("(%p %p %ld)\n", this, ptr, count);
2259
2260     for(copied=0; copied<count;) {
2261         chunk = basic_streambuf_wchar__Pnavail(this);
2262         if(chunk > count-copied)
2263             chunk = count-copied;
2264
2265         if(chunk > 0) {
2266             memcpy(*this->pwpos, ptr+copied, chunk*sizeof(wchar_t));
2267             *this->pwpos += chunk;
2268             *this->pwsize -= chunk;
2269             copied += chunk;
2270         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
2271             copied++;
2272         }else {
2273             break;
2274         }
2275     }
2276
2277     return copied;
2278 }
2279
2280 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
2281 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
2282 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
2283 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
2284 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
2285 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2286 {
2287     TRACE("(%p %p %ld)\n", this, ptr, count);
2288     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
2289 }
2290
2291 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@XZ */
2292 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@XZ */
2293 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
2294 locale* __thiscall basic_streambuf_wchar_getloc(basic_streambuf_wchar *this, locale *ret)
2295 {
2296     TRACE("(%p %p)\n", this, ret);
2297     return locale_copy_ctor(ret, &this->loc);
2298 }
2299
2300 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2301 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2302 int basic_filebuf_char__Init__Stinit = 0;
2303
2304 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2305 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2306 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
2307 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
2308 {
2309     TRACE("(%p %p %d)\n", this, file, which);
2310
2311     this->cvt = NULL;
2312     this->state0 = basic_filebuf_char__Init__Stinit;
2313     this->state = basic_filebuf_char__Init__Stinit;
2314     this->str = NULL;
2315     this->close = (which == INITFL_open);
2316     this->file = file;
2317
2318     basic_streambuf_char__Init_empty(&this->base);
2319     if(file)
2320         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
2321                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
2322 }
2323
2324 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
2325 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
2326 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Initcvt, 4)
2327 void __thiscall basic_filebuf_char__Initcvt(basic_filebuf_char *this)
2328 {
2329     TRACE("(%p)\n", this);
2330
2331     this->cvt = codecvt_char_use_facet(&this->base.loc);
2332     locale__Addfac(&this->loc, &this->cvt->base.facet, codecvt_char_id.id, LC_CTYPE);
2333     if(codecvt_base_always_noconv(&this->cvt->base)) {
2334         this->cvt = NULL;
2335     }else {
2336         this->str = MSVCRT_operator_new(sizeof(basic_string_char));
2337         basic_string_char_ctor(this->str);
2338     }
2339 }
2340
2341 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2342 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2343 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2344 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2345 {
2346     basic_filebuf_char *ret = this;
2347
2348     TRACE("(%p)\n", this);
2349
2350     if(!this->file || fclose(this->file))
2351         return NULL;
2352
2353     basic_filebuf_char__Init(this, NULL, INITFL_close);
2354     return ret;
2355 }
2356
2357 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2358 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2359 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2360 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2361 {
2362     TRACE("(%p %p)\n", this, file);
2363
2364     basic_streambuf_char_ctor(&this->base);
2365     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2366
2367     locale_ctor(&this->loc);
2368     basic_filebuf_char__Init(this, file, INITFL_new);
2369     return this;
2370 }
2371
2372 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2373 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2374 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2375 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2376 {
2377     return basic_filebuf_char_ctor_file(this, NULL);
2378 }
2379
2380 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2381 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2382 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2383 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2384 {
2385     TRACE("(%p %d)\n", this, uninitialized);
2386
2387     basic_streambuf_char_ctor_uninitialized(&this->base, 0);
2388     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2389     locale_ctor(&this->loc);
2390     return this;
2391 }
2392
2393 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2394 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2395 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2396 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2397 {
2398     TRACE("(%p)\n", this);
2399
2400     if(this->close)
2401         basic_filebuf_char_close(this);
2402     if(this->str) {
2403         basic_string_char_dtor(this->str);
2404         MSVCRT_operator_delete(this->str);
2405     }
2406     locale_dtor(&this->loc);
2407     basic_streambuf_char_dtor(&this->base);
2408 }
2409
2410 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2411 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2412 {
2413     TRACE("(%p %x)\n", this, flags);
2414     if(flags & 2) {
2415         /* we have an array, with the number of elements stored before the first object */
2416         INT_PTR i, *ptr = (INT_PTR *)this-1;
2417
2418         for(i=*ptr-1; i>=0; i--)
2419             basic_filebuf_char_dtor(this+i);
2420         MSVCRT_operator_delete(ptr);
2421     } else {
2422         basic_filebuf_char_dtor(this);
2423         if(flags & 1)
2424             MSVCRT_operator_delete(this);
2425     }
2426
2427     return this;
2428 }
2429
2430 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2431 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2432 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2433 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2434 {
2435     TRACE("(%p)\n", this);
2436     return this->file != NULL;
2437 }
2438
2439 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2440 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2441 static FILE* _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2442 {
2443     static const wchar_t rW[] = {'r',0};
2444     static const struct {
2445         int mode;
2446         const wchar_t str[4];
2447         const wchar_t str_bin[4];
2448     } str_mode[] = {
2449         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2450         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2451         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2452         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2453         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2454         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2455         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2456         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2457         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2458     };
2459
2460     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2461     int mode_idx;
2462     FILE *f = NULL;
2463
2464     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2465
2466     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2467         if(str_mode[mode_idx].mode == real_mode)
2468             break;
2469     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2470         return NULL;
2471
2472     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2473         return NULL;
2474     else if(f)
2475         fclose(f);
2476
2477     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2478             && (f = _wfopen(name, rW))) {
2479         fclose(f);
2480         return NULL;
2481     }
2482
2483     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2484             : str_mode[mode_idx].str, prot);
2485     if(!f)
2486         return NULL;
2487
2488     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2489         fclose(f);
2490         return NULL;
2491     }
2492
2493     return f;
2494 }
2495
2496 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2497 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2498 static FILE* _Fiopen(const char *name, int mode, int prot)
2499 {
2500     wchar_t nameW[FILENAME_MAX];
2501
2502     TRACE("(%s %d %d)\n", name, mode, prot);
2503
2504     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2505         return NULL;
2506     return _Fiopen_wchar(nameW, mode, prot);
2507 }
2508
2509 /* ?__Fiopen@std@@YAPAU_iobuf@@PBDH@Z */
2510 /* ?__Fiopen@std@@YAPEAU_iobuf@@PEBDH@Z */
2511 FILE* __cdecl ___Fiopen(const char *name, int mode)
2512 {
2513     TRACE("(%p %d)\n", name, mode);
2514     return _Fiopen(name, mode, _SH_DENYNO);
2515 }
2516
2517 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2518 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2519 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2520 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2521 static basic_filebuf_char* basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2522 {
2523     FILE *f = NULL;
2524
2525     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2526
2527     if(basic_filebuf_char_is_open(this))
2528         return NULL;
2529
2530     if(!(f = _Fiopen_wchar(name, mode, prot)))
2531         return NULL;
2532
2533     basic_filebuf_char__Init(this, f, INITFL_open);
2534     basic_filebuf_char__Initcvt(this);
2535     return this;
2536 }
2537
2538 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2539 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2540 static basic_filebuf_char* basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2541 {
2542     wchar_t nameW[FILENAME_MAX];
2543
2544     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2545
2546     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2547         return NULL;
2548     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2549 }
2550
2551 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDF@Z */
2552 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDF@Z */
2553 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode_old, 12)
2554 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode_old(basic_filebuf_char *this, const char *name, short mode)
2555 {
2556     TRACE("(%p %p %d)\n", this, name, mode);
2557     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2558 }
2559
2560 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDH@Z */
2561 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDH@Z */
2562 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2563 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, int mode)
2564 {
2565     TRACE("(%p %p %d)\n", this, name, mode);
2566     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2567 }
2568
2569 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2570 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2571 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2572 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2573 {
2574     char *ptr, ch = c, *to_next;
2575     const char *from_next;
2576     int ret;
2577
2578
2579     TRACE("(%p %d)\n", this, c);
2580
2581     if(!basic_filebuf_char_is_open(this))
2582         return EOF;
2583     if(c == EOF)
2584         return !c;
2585
2586     if(!this->cvt)
2587         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2588
2589     from_next = &ch;
2590     basic_string_char_clear(this->str);
2591     basic_string_char_append_len_ch(this->str, 8, '\0');
2592     ptr = this->str->ptr;
2593     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1, &from_next,
2594             ptr, ptr+basic_string_char_length(this->str), &to_next);
2595
2596     switch(ret) {
2597     case CODECVT_partial:
2598         if(from_next == &ch)
2599             return EOF;
2600     case CODECVT_ok:
2601         if(!fwrite(ptr, to_next-ptr, 1, this->file))
2602             return EOF;
2603         return c;
2604     case CODECVT_noconv:
2605         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2606     default:
2607         return EOF;
2608     }
2609 }
2610
2611 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2612 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2613 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2614 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2615 {
2616     TRACE("(%p %d)\n", this, c);
2617
2618     if(!basic_filebuf_char_is_open(this))
2619         return EOF;
2620
2621     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2622             && (c==EOF || (int)(unsigned char)basic_streambuf_char_gptr(&this->base)[-1]==c)) {
2623         basic_streambuf_char__Gndec(&this->base);
2624         return c==EOF ? !c : c;
2625     }else if(c == EOF) {
2626         return EOF;
2627     }else if(!this->cvt) {
2628         return ungetc(c, this->file);
2629     }else if(basic_string_char_length(this->str)) {
2630         char *b, *e, *cur;
2631
2632         e = this->str->ptr;
2633         b = e+this->str->size-1;
2634         for(cur = b; cur>=e; cur--) {
2635             if(ungetc(*cur, this->file) == EOF) {
2636                 for(; cur<=b; cur++)
2637                     fgetc(this->file);
2638                 return EOF;
2639             }
2640         }
2641         basic_string_char_clear(this->str);
2642         this->state = this->state0;
2643         return c;
2644     }
2645
2646     return EOF;
2647 }
2648
2649 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2650 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2651 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2652 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2653 {
2654     char ch, *to_next;
2655     const char *buf_next;
2656     int c;
2657
2658     TRACE("(%p)\n", this);
2659
2660     if(!basic_filebuf_char_is_open(this))
2661         return EOF;
2662
2663     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2664         return (unsigned char)*basic_streambuf_char__Gninc(&this->base);
2665
2666     c = fgetc(this->file);
2667     if(!this->cvt || c==EOF)
2668         return c;
2669
2670     basic_string_char_clear(this->str);
2671     this->state0 = this->state;
2672     while(1) {
2673         basic_string_char_append_ch(this->str, c);
2674         this->state = this->state0;
2675
2676         switch(codecvt_char_in(this->cvt, &this->state, this->str->ptr,
2677                     this->str->ptr+this->str->size, &buf_next, &ch, &ch+1, &to_next)) {
2678         case CODECVT_partial:
2679             break;
2680         case CODECVT_noconv:
2681             return (unsigned char)this->str->ptr[0];
2682         case CODECVT_ok:
2683             return (unsigned char)ch;
2684         default:
2685             return EOF;
2686         }
2687
2688         c = fgetc(this->file);
2689         if(c == EOF)
2690             return EOF;
2691     }
2692 }
2693
2694 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2695 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2696 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2697 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2698 {
2699     int ret;
2700
2701     TRACE("(%p)\n", this);
2702
2703     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2704         return (unsigned char)*basic_streambuf_char_gptr(&this->base);
2705
2706     ret = call_basic_streambuf_char_uflow(&this->base);
2707     if(ret != EOF)
2708         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2709     return ret;
2710 }
2711
2712 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2713 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2714 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2715 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2716         fpos_int *ret, streamoff off, int way, int mode)
2717 {
2718     fpos_t pos;
2719
2720     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2721
2722     if(!basic_filebuf_char_is_open(this) || fseek(this->file, off, way)) {
2723         ret->off = -1;
2724         ret->pos = 0;
2725         ret->state = 0;
2726         return ret;
2727     }
2728
2729     fgetpos(this->file, &pos);
2730     ret->off = 0;
2731     ret->pos = pos;
2732     ret->state = this->state;
2733     return ret;
2734 }
2735
2736 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2737 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2738 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2739 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2740         fpos_int *ret, fpos_int pos, int mode)
2741 {
2742     fpos_t fpos;
2743
2744     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2745
2746     if(!basic_filebuf_char_is_open(this) || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2747             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2748         ret->off = -1;
2749         ret->pos = 0;
2750         ret->state = 0;
2751         return ret;
2752     }
2753
2754     fgetpos(this->file, &fpos);
2755     ret->off = 0;
2756     ret->pos = fpos;
2757     ret->state = this->state;
2758     return ret;
2759 }
2760
2761 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2762 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2763 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2764 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2765 {
2766     TRACE("(%p %p %ld)\n", this, buf, count);
2767
2768     if(!basic_filebuf_char_is_open(this))
2769         return NULL;
2770
2771     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2772         return NULL;
2773
2774     basic_filebuf_char__Init(this, this->file, INITFL_open);
2775     return &this->base;
2776 }
2777
2778 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2779 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2780 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2781 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2782 {
2783     TRACE("(%p)\n", this);
2784
2785     if(!basic_filebuf_char_is_open(this))
2786         return 0;
2787
2788     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2789         return 0;
2790     return fflush(this->file);
2791 }
2792
2793 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2794 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2795 int basic_filebuf_short__Init__Stinit = 0;
2796
2797 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2798 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2799 static void basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2800 {
2801     TRACE("(%p %p %d)\n", this, file, which);
2802
2803     this->cvt = NULL;
2804     this->state0 = basic_filebuf_short__Init__Stinit;
2805     this->state = basic_filebuf_short__Init__Stinit;
2806     this->str = NULL;
2807     this->close = (which == INITFL_open);
2808     this->file = file;
2809
2810     basic_streambuf_wchar__Init_empty(&this->base);
2811 }
2812
2813 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2814 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2815 DEFINE_THISCALL_WRAPPER(basic_filebuf_short__Init, 12)
2816 void __thiscall basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2817 {
2818     TRACE("(%p %p %d)\n", this, file, which);
2819
2820     this->cvt = NULL;
2821     this->state0 = basic_filebuf_short__Init__Stinit;
2822     this->state = basic_filebuf_short__Init__Stinit;
2823     this->str = NULL;
2824     this->close = (which == INITFL_open);
2825     this->file = file;
2826
2827     basic_streambuf_wchar__Init_empty(&this->base);
2828 }
2829
2830 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
2831 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
2832 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Initcvt, 4)
2833 void __thiscall basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this)
2834 {
2835     TRACE("(%p)\n", this);
2836
2837     this->cvt = codecvt_short_use_facet(&this->base.loc);
2838     locale__Addfac(&this->loc, &this->cvt->base.facet, codecvt_short_id.id, LC_CTYPE);
2839     if(codecvt_base_always_noconv(&this->cvt->base)) {
2840         this->cvt = NULL;
2841     }else {
2842         this->str = MSVCRT_operator_new(sizeof(basic_string_char));
2843         basic_string_char_ctor(this->str);
2844     }
2845 }
2846
2847 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
2848 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
2849 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
2850 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
2851 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_close, 4)
2852 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_close(basic_filebuf_wchar *this)
2853 {
2854     basic_filebuf_wchar *ret = this;
2855
2856     TRACE("(%p)\n", this);
2857
2858     if(!this->file || fclose(this->file))
2859         return NULL;
2860
2861     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
2862     return ret;
2863 }
2864
2865 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
2866 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2867 static basic_filebuf_wchar* basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
2868 {
2869     TRACE("(%p %p)\n", this, file);
2870
2871     basic_streambuf_wchar_ctor(&this->base);
2872     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
2873
2874     locale_ctor(&this->loc);
2875     basic_filebuf_wchar__Init(this, file, INITFL_new);
2876     return this;
2877 }
2878
2879 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
2880 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2881 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_file, 8)
2882 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
2883 {
2884     TRACE("(%p %p)\n", this, file);
2885
2886     basic_streambuf_short_ctor(&this->base);
2887     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
2888
2889     locale_ctor(&this->loc);
2890     basic_filebuf_short__Init(this, file, INITFL_new);
2891     return this;
2892 }
2893
2894 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2895 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2896 static basic_filebuf_wchar* basic_filebuf_wchar_ctor(basic_filebuf_wchar *this)
2897 {
2898     return basic_filebuf_wchar_ctor_file(this, NULL);
2899 }
2900
2901 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2902 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2903 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor, 4)
2904 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor(basic_filebuf_wchar *this)
2905 {
2906     return basic_filebuf_short_ctor_file(this, NULL);
2907 }
2908
2909 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2910 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2911 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_uninitialized, 8)
2912 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
2913 {
2914     TRACE("(%p %d)\n", this, uninitialized);
2915
2916     basic_streambuf_short_ctor_uninitialized(&this->base, 0);
2917     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
2918     locale_ctor(&this->loc);
2919     return this;
2920 }
2921
2922 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
2923 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
2924 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
2925 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
2926 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_dtor, 4)
2927 void __thiscall basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
2928 {
2929     TRACE("(%p)\n", this);
2930
2931     if(this->close)
2932         basic_filebuf_wchar_close(this);
2933     if(this->str) {
2934         basic_string_char_dtor(this->str);
2935         MSVCRT_operator_delete(this->str);
2936     }
2937     locale_dtor(&this->loc);
2938     basic_streambuf_wchar_dtor(&this->base);
2939 }
2940
2941 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
2942 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
2943 {
2944     TRACE("(%p %x)\n", this, flags);
2945     if(flags & 2) {
2946         /* we have an array, with the number of elements stored before the first object */
2947         INT_PTR i, *ptr = (INT_PTR *)this-1;
2948
2949         for(i=*ptr-1; i>=0; i--)
2950             basic_filebuf_wchar_dtor(this+i);
2951         MSVCRT_operator_delete(ptr);
2952     } else {
2953         basic_filebuf_wchar_dtor(this);
2954         if(flags & 1)
2955             MSVCRT_operator_delete(this);
2956     }
2957
2958     return this;
2959 }
2960
2961 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
2962 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
2963 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
2964 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
2965 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_is_open, 4)
2966 MSVCP_bool __thiscall basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
2967 {
2968     TRACE("(%p)\n", this);
2969     return this->file != NULL;
2970 }
2971
2972 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WHH@Z */
2973 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2974 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGHH@Z */
2975 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2976 static basic_filebuf_wchar* basic_filebuf_wchar_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
2977 {
2978     FILE *f = NULL;
2979
2980     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2981
2982     if(basic_filebuf_wchar_is_open(this))
2983         return NULL;
2984
2985     if(!(f = _Fiopen_wchar(name, mode, prot)))
2986         return NULL;
2987
2988     basic_filebuf_wchar__Init(this, f, INITFL_open);
2989     basic_filebuf_wchar__Initcvt(this);
2990     return this;
2991 }
2992
2993 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDHH@Z */
2994 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2995 static basic_filebuf_wchar* basic_filebuf_wchar_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
2996 {
2997     wchar_t nameW[FILENAME_MAX];
2998
2999     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3000
3001     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3002         return NULL;
3003     return basic_filebuf_wchar_open_wchar(this, nameW, mode, prot);
3004 }
3005
3006 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
3007 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
3008 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode_old, 12)
3009 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode_old(basic_filebuf_wchar *this, const char *name, short mode)
3010 {
3011     TRACE("(%p %p %d)\n", this, name, mode);
3012     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3013 }
3014
3015 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
3016 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
3017 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode, 12)
3018 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode(basic_filebuf_wchar *this, const char *name, int mode)
3019 {
3020     TRACE("(%p %p %d)\n", this, name, mode);
3021     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3022 }
3023
3024 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3025 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3026 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3027 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3028 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
3029 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
3030 {
3031     char *ptr, *to_next;
3032     wchar_t ch = c;
3033     const wchar_t *from_next;
3034     unsigned short ret;
3035
3036
3037     TRACE("(%p %d)\n", this, c);
3038
3039     if(!basic_filebuf_wchar_is_open(this))
3040         return WEOF;
3041     if(c == WEOF)
3042         return !c;
3043
3044     if(!this->cvt)
3045         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3046
3047     from_next = &ch;
3048     basic_string_char_clear(this->str);
3049     basic_string_char_append_len_ch(this->str, 8, '\0');
3050     ptr = this->str->ptr;
3051     ret = codecvt_wchar_out(this->cvt, &this->state, &ch, &ch+1, &from_next,
3052             ptr, ptr+basic_string_char_length(this->str), &to_next);
3053
3054     switch(ret) {
3055     case CODECVT_partial:
3056         if(from_next == &ch)
3057             return WEOF;
3058         /* fall through */
3059     case CODECVT_ok:
3060         if(!fwrite(ptr, to_next-ptr, 1, this->file))
3061             return WEOF;
3062         return c;
3063     case CODECVT_noconv:
3064         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3065     default:
3066         return WEOF;
3067     }
3068 }
3069
3070 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3071 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3072 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3073 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3074 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
3075 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
3076 {
3077     TRACE("(%p %d)\n", this, c);
3078
3079     if(!basic_filebuf_wchar_is_open(this))
3080         return WEOF;
3081
3082     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
3083             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==c)) {
3084         basic_streambuf_wchar__Gndec(&this->base);
3085         return c==WEOF ? !c : c;
3086     }else if(c == WEOF) {
3087         return WEOF;
3088     }else if(!this->cvt) {
3089         return ungetwc(c, this->file);
3090     }else if(basic_string_char_length(this->str)) {
3091         char *b, *e, *cur;
3092
3093         e = this->str->ptr;
3094         b = e+this->str->size-1;
3095         for(cur = b; cur>=e; cur--) {
3096             if(ungetc(*cur, this->file) == EOF) {
3097                 for(; cur<=b; cur++)
3098                     fgetc(this->file);
3099                 return WEOF;
3100             }
3101         }
3102         basic_string_char_clear(this->str);
3103         this->state = this->state0;
3104         return c;
3105     }
3106
3107     return WEOF;
3108 }
3109
3110 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3111 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3112 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3113 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3114 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
3115 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
3116 {
3117     wchar_t ch, *to_next;
3118     const char *buf_next;
3119     int c;
3120
3121     TRACE("(%p)\n", this);
3122
3123     if(!basic_filebuf_wchar_is_open(this))
3124         return WEOF;
3125
3126     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3127         return *basic_streambuf_wchar__Gninc(&this->base);
3128
3129     if(!this->cvt)
3130         return fgetwc(this->file);
3131
3132     basic_string_char_clear(this->str);
3133     this->state0 = this->state;
3134     while(1) {
3135         if((c = fgetc(this->file)) == EOF)
3136             return WEOF;
3137         basic_string_char_append_ch(this->str, c);
3138         this->state = this->state0;
3139
3140         switch(codecvt_wchar_in(this->cvt, &this->state, this->str->ptr,
3141                     this->str->ptr+this->str->size, &buf_next, &ch, &ch+1, &to_next)) {
3142         case CODECVT_partial:
3143             break;
3144         case CODECVT_noconv:
3145             if(this->str->size < sizeof(unsigned short)/sizeof(char))
3146                 break;
3147             return *(unsigned short*)this->str->ptr;
3148         case CODECVT_ok:
3149             return (unsigned short)ch;
3150         default:
3151             return WEOF;
3152         }
3153     }
3154 }
3155
3156 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3157 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3158 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3159 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3160 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
3161 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
3162 {
3163     unsigned short ret;
3164
3165     TRACE("(%p)\n", this);
3166
3167     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3168         return *basic_streambuf_wchar_gptr(&this->base);
3169
3170     ret = call_basic_streambuf_wchar_uflow(&this->base);
3171     if(ret != WEOF)
3172         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
3173     return ret;
3174 }
3175
3176 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3177 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3178 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3179 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3180 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 20)
3181 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
3182         fpos_int *ret, streamoff off, int way, int mode)
3183 {
3184     fpos_t pos;
3185
3186     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3187
3188     if(!basic_filebuf_wchar_is_open(this) || fseek(this->file, off, way)) {
3189         ret->off = -1;
3190         ret->pos = 0;
3191         ret->state = 0;
3192         return ret;
3193     }
3194
3195     fgetpos(this->file, &pos);
3196     ret->off = 0;
3197     ret->pos = pos;
3198     ret->state = this->state;
3199     return ret;
3200 }
3201
3202 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3203 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3204 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3205 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3206 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
3207 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
3208         fpos_int *ret, fpos_int pos, int mode)
3209 {
3210     fpos_t fpos;
3211
3212     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3213
3214     if(!basic_filebuf_wchar_is_open(this) || fseek(this->file, (LONG)pos.pos, SEEK_SET)
3215             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
3216         ret->off = -1;
3217         ret->pos = 0;
3218         ret->state = 0;
3219         return ret;
3220     }
3221
3222     fgetpos(this->file, &fpos);
3223     ret->off = 0;
3224     ret->pos = fpos;
3225     ret->state = this->state;
3226     return ret;
3227 }
3228
3229 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
3230 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
3231 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 12)
3232 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3233 {
3234     TRACE("(%p %p %ld)\n", this, buf, count);
3235
3236     if(!basic_filebuf_wchar_is_open(this))
3237         return NULL;
3238
3239     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3240         return NULL;
3241
3242     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
3243     return &this->base;
3244 }
3245
3246 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
3247 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
3248 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 12)
3249 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3250 {
3251     TRACE("(%p %p %ld)\n", this, buf, count);
3252
3253     if(!basic_filebuf_wchar_is_open(this))
3254         return NULL;
3255
3256     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3257         return NULL;
3258
3259     basic_filebuf_short__Init(this, this->file, INITFL_open);
3260     return &this->base;
3261 }
3262
3263 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
3264 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
3265 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
3266 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
3267 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
3268 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
3269 {
3270     TRACE("(%p)\n", this);
3271
3272     if(!basic_filebuf_wchar_is_open(this))
3273         return 0;
3274
3275     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
3276         return 0;
3277     return fflush(this->file);
3278 }
3279
3280 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3281 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3282 static int basic_stringbuf_char__Getstate(basic_stringbuf_char *this, IOSB_openmode mode)
3283 {
3284     int state = 0;
3285
3286     if(!(mode & OPENMODE_in))
3287         state |= STRINGBUF_no_read;
3288
3289     if(!(mode & OPENMODE_out))
3290         state |= STRINGBUF_no_write;
3291
3292     if(mode & OPENMODE_ate)
3293         state |= STRINGBUF_at_end;
3294
3295     if(mode & OPENMODE_app)
3296         state |= STRINGBUF_append;
3297
3298     return state;
3299 }
3300
3301 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXPBDIH@Z */
3302 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXPEBD_KH@Z */
3303 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Init, 16)
3304 void __thiscall basic_stringbuf_char__Init(basic_stringbuf_char *this, const char *str, MSVCP_size_t count, int state)
3305 {
3306     TRACE("(%p, %p, %ld, %d)\n", this, str, count, state);
3307
3308     basic_streambuf_char__Init_empty(&this->base);
3309
3310     this->state = state;
3311     this->seekhigh = NULL;
3312
3313     if(count && str) {
3314         char *buf = MSVCRT_operator_new(count);
3315         if(!buf) {
3316             ERR("Out of memory\n");
3317             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3318         }
3319
3320         memcpy(buf, str, count);
3321         this->seekhigh = buf + count;
3322
3323         this->state |= STRINGBUF_allocated;
3324
3325         if(!(state & STRINGBUF_no_read))
3326             basic_streambuf_char_setg(&this->base, buf, buf, buf + count);
3327
3328         if(!(state & STRINGBUF_no_write)) {
3329             basic_streambuf_char_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3330
3331             if(!basic_streambuf_char_gptr(&this->base))
3332                 basic_streambuf_char_setg(&this->base, buf, 0, buf);
3333         }
3334     }
3335 }
3336
3337 /* ??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 */
3338 /* ??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 */
3339 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_str, 12)
3340 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_str(basic_stringbuf_char *this,
3341         const basic_string_char *str, IOSB_openmode mode)
3342 {
3343     TRACE("(%p %p %d)\n", this, str, mode);
3344
3345     basic_streambuf_char_ctor(&this->base);
3346     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3347
3348     basic_stringbuf_char__Init(this, basic_string_char_c_str(str),
3349             str->size, basic_stringbuf_char__Getstate(this, mode));
3350     return this;
3351 }
3352
3353 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
3354 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
3355 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_mode, 8)
3356 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_mode(
3357         basic_stringbuf_char *this, IOSB_openmode mode)
3358 {
3359     TRACE("(%p %d)\n", this, mode);
3360
3361     basic_streambuf_char_ctor(&this->base);
3362     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3363
3364     basic_stringbuf_char__Init(this, NULL, 0, basic_stringbuf_char__Getstate(this, mode));
3365     return this;
3366 }
3367
3368 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
3369 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
3370 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor, 4)
3371 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor(basic_stringbuf_char *this)
3372 {
3373     return basic_stringbuf_char_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3374 }
3375
3376 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXXZ */
3377 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXXZ */
3378 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Tidy, 4)
3379 void __thiscall basic_stringbuf_char__Tidy(basic_stringbuf_char *this)
3380 {
3381     TRACE("(%p)\n", this);
3382
3383     if(this->state & STRINGBUF_allocated) {
3384         MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
3385         this->seekhigh = NULL;
3386         this->state &= ~STRINGBUF_allocated;
3387     }
3388
3389     basic_streambuf_char__Init_empty(&this->base);
3390 }
3391
3392 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
3393 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
3394 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_dtor, 4)
3395 void __thiscall basic_stringbuf_char_dtor(basic_stringbuf_char *this)
3396 {
3397     TRACE("(%p)\n", this);
3398
3399     basic_stringbuf_char__Tidy(this);
3400     basic_streambuf_char_dtor(&this->base);
3401 }
3402
3403 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_vector_dtor, 8)
3404 basic_stringbuf_char* __thiscall basic_stringbuf_char_vector_dtor(basic_stringbuf_char *this, unsigned int flags)
3405 {
3406     TRACE("(%p %x)\n", this, flags);
3407
3408     if(flags & 2) {
3409         /* we have an array, with the number of elements stored before the first object */
3410         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3411
3412         for (i = *ptr - 1; i >= 0; i--)
3413             basic_stringbuf_char_dtor(this+i);
3414
3415         MSVCRT_operator_delete(ptr);
3416     }else {
3417         basic_stringbuf_char_dtor(this);
3418
3419         if(flags & 1)
3420             MSVCRT_operator_delete(this);
3421     }
3422
3423     return this;
3424 }
3425
3426 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3427 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3428 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_overflow, 8)
3429 int __thiscall basic_stringbuf_char_overflow(basic_stringbuf_char *this, int meta)
3430 {
3431     MSVCP_size_t oldsize, size;
3432     char *ptr, *buf;
3433
3434     TRACE("(%p %x)\n", this, meta);
3435
3436     if(meta == EOF)
3437         return !EOF;
3438     if(this->state & STRINGBUF_no_write)
3439         return EOF;
3440
3441     ptr = basic_streambuf_char_pptr(&this->base);
3442     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3443         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
3444                 this->seekhigh, basic_streambuf_char_epptr(&this->base));
3445
3446     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
3447         return (*basic_streambuf_char__Pninc(&this->base) = meta);
3448
3449     oldsize = (ptr ? basic_streambuf_char_epptr(&this->base)-basic_streambuf_char_eback(&this->base): 0);
3450     size = oldsize|0xf;
3451     size += size/2;
3452     buf = MSVCRT_operator_new(size);
3453     if(!buf) {
3454         ERR("Out of memory\n");
3455         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3456     }
3457
3458     if(!oldsize) {
3459         this->seekhigh = buf;
3460         basic_streambuf_char_setp(&this->base, buf, buf+size);
3461         if(this->state & STRINGBUF_no_read)
3462             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3463         else
3464             basic_streambuf_char_setg(&this->base, buf, buf, buf+1);
3465
3466         this->state |= STRINGBUF_allocated;
3467     }else {
3468         ptr = basic_streambuf_char_eback(&this->base);
3469         memcpy(buf, ptr, oldsize);
3470
3471         this->seekhigh = buf+(this->seekhigh-ptr);
3472         basic_streambuf_char_setp_next(&this->base, buf,
3473                 buf+(basic_streambuf_char_pptr(&this->base)-ptr), buf+size);
3474         if(this->state & STRINGBUF_no_read)
3475             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3476         else
3477             basic_streambuf_char_setg(&this->base, buf,
3478                     buf+(basic_streambuf_char_gptr(&this->base)-ptr),
3479                     basic_streambuf_char_pptr(&this->base)+1);
3480
3481         MSVCRT_operator_delete(ptr);
3482     }
3483
3484     return (*basic_streambuf_char__Pninc(&this->base) = meta);
3485 }
3486
3487 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3488 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3489 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_pbackfail, 8)
3490 int __thiscall basic_stringbuf_char_pbackfail(basic_stringbuf_char *this, int c)
3491 {
3492     char *cur;
3493
3494     TRACE("(%p %x)\n", this, c);
3495
3496     cur = basic_streambuf_char_gptr(&this->base);
3497     if(!cur || cur==basic_streambuf_char_eback(&this->base)
3498             || (c!=EOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3499         return EOF;
3500
3501     if(c != EOF)
3502         cur[-1] = c;
3503     basic_streambuf_char_gbump(&this->base, -1);
3504     return c==EOF ? !EOF : c;
3505 }
3506
3507 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHXZ */
3508 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHXZ */
3509 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_underflow, 4)
3510 int __thiscall basic_stringbuf_char_underflow(basic_stringbuf_char *this)
3511 {
3512     char *ptr, *cur;
3513
3514     TRACE("(%p)\n", this);
3515
3516     cur = basic_streambuf_char_gptr(&this->base);
3517     if(!cur || this->state&STRINGBUF_no_read)
3518         return EOF;
3519
3520     ptr  = basic_streambuf_char_pptr(&this->base);
3521     if(this->seekhigh < ptr)
3522         this->seekhigh = ptr;
3523
3524     ptr = basic_streambuf_char_egptr(&this->base);
3525     if(this->seekhigh > ptr)
3526         basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base), cur, this->seekhigh);
3527
3528     if(cur < this->seekhigh)
3529         return (unsigned char)*cur;
3530     return EOF;
3531 }
3532
3533 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3534 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3535 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekoff, 20)
3536 fpos_int* __thiscall basic_stringbuf_char_seekoff(basic_stringbuf_char *this,
3537         fpos_int *ret, streamoff off, int way, int mode)
3538 {
3539     char *beg, *cur_r, *cur_w;
3540
3541     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3542
3543     cur_w = basic_streambuf_char_pptr(&this->base);
3544     if(cur_w > this->seekhigh)
3545         this->seekhigh = cur_w;
3546
3547     ret->off = 0;
3548     ret->pos = 0;
3549     ret->state = 0;
3550
3551     beg = basic_streambuf_char_eback(&this->base);
3552     cur_r = basic_streambuf_char_gptr(&this->base);
3553     if((mode & OPENMODE_in) && cur_r) {
3554         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3555             off += cur_r-beg;
3556         else if(way == SEEKDIR_end)
3557             off += this->seekhigh-beg;
3558         else if(way != SEEKDIR_beg)
3559             off = -1;
3560
3561         if(off<0 || off>this->seekhigh-beg) {
3562             off = -1;
3563         }else {
3564             basic_streambuf_char_gbump(&this->base, beg-cur_r+off);
3565             if((mode & OPENMODE_out) && cur_w) {
3566                 basic_streambuf_char_setp_next(&this->base, beg,
3567                         basic_streambuf_char_gptr(&this->base),
3568                         basic_streambuf_char_epptr(&this->base));
3569             }
3570         }
3571     }else if((mode & OPENMODE_out) && cur_w) {
3572         if(way == SEEKDIR_cur)
3573             off += cur_w-beg;
3574         else if(way == SEEKDIR_end)
3575             off += this->seekhigh-beg;
3576         else if(way != SEEKDIR_beg)
3577             off = -1;
3578
3579         if(off<0 || off>this->seekhigh-beg)
3580             off = -1;
3581         else
3582             basic_streambuf_char_pbump(&this->base, beg-cur_w+off);
3583     }else {
3584         off = -1;
3585     }
3586
3587     ret->off = off;
3588     return ret;
3589 }
3590
3591 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3592 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3593 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekpos, 36)
3594 fpos_int* __thiscall basic_stringbuf_char_seekpos(basic_stringbuf_char *this,
3595         fpos_int *ret, fpos_int pos, int mode)
3596 {
3597     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3598
3599     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
3600         *ret = pos;
3601         return ret;
3602     }
3603
3604     return basic_stringbuf_char_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
3605 }
3606
3607 /* ?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 */
3608 /* ?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 */
3609 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_set, 8)
3610 void __thiscall basic_stringbuf_char_str_set(basic_stringbuf_char *this, const basic_string_char *str)
3611 {
3612     TRACE("(%p %p)\n", this, str);
3613
3614     basic_stringbuf_char__Tidy(this);
3615     basic_stringbuf_char__Init(this, basic_string_char_c_str(str), str->size, this->state);
3616 }
3617
3618 /* ?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 */
3619 /* ?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 */
3620 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_get, 8)
3621 basic_string_char* __thiscall basic_stringbuf_char_str_get(const basic_stringbuf_char *this, basic_string_char *ret)
3622 {
3623     char *ptr;
3624
3625     TRACE("(%p)\n", this);
3626
3627     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_char_pptr(&this->base)) {
3628         char *pptr;
3629
3630         ptr = basic_streambuf_char_pbase(&this->base);
3631         pptr = basic_streambuf_char_pptr(&this->base);
3632
3633         return basic_string_char_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
3634     }
3635
3636     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_char_gptr(&this->base)) {
3637         ptr = basic_streambuf_char_eback(&this->base);
3638         return basic_string_char_ctor_cstr_len(ret, ptr, basic_streambuf_char_egptr(&this->base) - ptr);
3639     }
3640
3641     return basic_string_char_ctor(ret);
3642 }
3643
3644 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAEHH@Z */
3645 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAAHH@Z */
3646 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3647 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3648 static int basic_stringbuf_wchar__Getstate(basic_stringbuf_wchar *this, IOSB_openmode mode)
3649 {
3650     int state = 0;
3651
3652     if(!(mode & OPENMODE_in))
3653         state |= STRINGBUF_no_read;
3654
3655     if(!(mode & OPENMODE_out))
3656         state |= STRINGBUF_no_write;
3657
3658     if(mode & OPENMODE_ate)
3659         state |= STRINGBUF_at_end;
3660
3661     if(mode & OPENMODE_app)
3662         state |= STRINGBUF_append;
3663
3664     return state;
3665 }
3666
3667 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXPB_WIH@Z */
3668 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXPEB_W_KH@Z */
3669 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXPBGIH@Z */
3670 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXPEBG_KH@Z */
3671 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Init, 16)
3672 void __thiscall basic_stringbuf_wchar__Init(basic_stringbuf_wchar *this, const wchar_t *str, MSVCP_size_t count, int state)
3673 {
3674     TRACE("(%p, %p, %lu, %d)\n", this, str, count, state);
3675
3676     basic_streambuf_wchar__Init_empty(&this->base);
3677
3678     this->state = state;
3679     this->seekhigh = NULL;
3680
3681     if(count && str) {
3682         wchar_t *buf = MSVCRT_operator_new(count*sizeof(wchar_t));
3683         if(!buf) {
3684             ERR("Out of memory\n");
3685             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3686         }
3687
3688         memcpy(buf, str, count*sizeof(wchar_t));
3689         this->seekhigh = buf + count;
3690
3691         this->state |= STRINGBUF_allocated;
3692
3693         if(!(state & STRINGBUF_no_read))
3694             basic_streambuf_wchar_setg(&this->base, buf, buf, buf + count);
3695
3696         if(!(state & STRINGBUF_no_write)) {
3697             basic_streambuf_wchar_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3698
3699             if(!basic_streambuf_wchar_gptr(&this->base))
3700                 basic_streambuf_wchar_setg(&this->base, buf, 0, buf);
3701         }
3702     }
3703 }
3704
3705 /* ??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 */
3706 /* ??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 */
3707 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_str(basic_stringbuf_wchar *this,
3708         const basic_string_wchar *str, IOSB_openmode mode)
3709 {
3710     TRACE("(%p %p %d)\n", this, str, mode);
3711
3712     basic_streambuf_wchar_ctor(&this->base);
3713     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3714
3715     basic_stringbuf_wchar__Init(this, basic_string_wchar_c_str(str),
3716             str->size, basic_stringbuf_wchar__Getstate(this, mode));
3717     return this;
3718 }
3719
3720 /* ??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 */
3721 /* ??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 */
3722 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_str, 12)
3723 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_str(basic_stringbuf_wchar *this,
3724         const basic_string_wchar *str, IOSB_openmode mode)
3725 {
3726     basic_stringbuf_wchar_ctor_str(this, str, mode);
3727     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3728     return this;
3729 }
3730
3731 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
3732 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
3733 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_mode(
3734         basic_stringbuf_wchar *this, IOSB_openmode mode)
3735 {
3736     TRACE("(%p %d)\n", this, mode);
3737
3738     basic_streambuf_wchar_ctor(&this->base);
3739     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3740
3741     basic_stringbuf_wchar__Init(this, NULL, 0, basic_stringbuf_wchar__Getstate(this, mode));
3742     return this;
3743 }
3744
3745 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
3746 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
3747 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_mode, 8)
3748 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_mode(
3749         basic_stringbuf_wchar *this, IOSB_openmode mode)
3750 {
3751     basic_stringbuf_wchar_ctor_mode(this, mode);
3752     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3753     return this;
3754 }
3755
3756 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
3757 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
3758 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor, 4)
3759 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor(basic_stringbuf_wchar *this)
3760 {
3761     return basic_stringbuf_short_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3762 }
3763
3764 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXXZ */
3765 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXXZ */
3766 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXXZ */
3767 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXXZ */
3768 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Tidy, 4)
3769 void __thiscall basic_stringbuf_wchar__Tidy(basic_stringbuf_wchar *this)
3770 {
3771     TRACE("(%p)\n", this);
3772
3773     if(this->state & STRINGBUF_allocated) {
3774         MSVCRT_operator_delete(basic_streambuf_wchar_eback(&this->base));
3775         this->seekhigh = NULL;
3776         this->state &= ~STRINGBUF_allocated;
3777     }
3778
3779     basic_streambuf_wchar__Init_empty(&this->base);
3780 }
3781
3782 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
3783 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
3784 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
3785 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
3786 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_dtor, 4)
3787 void __thiscall basic_stringbuf_wchar_dtor(basic_stringbuf_wchar *this)
3788 {
3789     TRACE("(%p)\n", this);
3790
3791     basic_stringbuf_wchar__Tidy(this);
3792     basic_streambuf_wchar_dtor(&this->base);
3793 }
3794
3795 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_vector_dtor, 8)
3796 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_vector_dtor(basic_stringbuf_wchar *this, unsigned int flags)
3797 {
3798     TRACE("(%p %x)\n", this, flags);
3799
3800     if(flags & 2) {
3801         /* we have an array, with the number of elements stored before the first object */
3802         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3803
3804         for (i = *ptr - 1; i >= 0; i--)
3805             basic_stringbuf_wchar_dtor(this+i);
3806
3807         MSVCRT_operator_delete(ptr);
3808     }else {
3809         basic_stringbuf_wchar_dtor(this);
3810
3811         if(flags & 1)
3812             MSVCRT_operator_delete(this);
3813     }
3814
3815     return this;
3816 }
3817
3818 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
3819 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
3820 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
3821 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
3822 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_overflow, 8)
3823 unsigned short __thiscall basic_stringbuf_wchar_overflow(basic_stringbuf_wchar *this, unsigned short meta)
3824 {
3825     MSVCP_size_t oldsize, size;
3826     wchar_t *ptr, *buf;
3827
3828     TRACE("(%p %x)\n", this, meta);
3829
3830     if(meta == WEOF)
3831         return !WEOF;
3832     if(this->state & STRINGBUF_no_write)
3833         return WEOF;
3834
3835     ptr = basic_streambuf_wchar_pptr(&this->base);
3836     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3837         basic_streambuf_wchar_setp_next(&this->base, basic_streambuf_wchar_pbase(&this->base),
3838                 this->seekhigh, basic_streambuf_wchar_epptr(&this->base));
3839
3840     if(ptr && ptr<basic_streambuf_wchar_epptr(&this->base))
3841         return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
3842
3843     oldsize = (ptr ? basic_streambuf_wchar_epptr(&this->base)-basic_streambuf_wchar_eback(&this->base): 0);
3844     size = oldsize|0xf;
3845     size += size/2;
3846     buf = MSVCRT_operator_new(size*sizeof(wchar_t));
3847     if(!buf) {
3848         ERR("Out of memory\n");
3849         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3850     }
3851
3852     if(!oldsize) {
3853         this->seekhigh = buf;
3854         basic_streambuf_wchar_setp(&this->base, buf, buf+size);
3855         if(this->state & STRINGBUF_no_read)
3856             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
3857         else
3858             basic_streambuf_wchar_setg(&this->base, buf, buf, buf+1);
3859
3860         this->state |= STRINGBUF_allocated;
3861     }else {
3862         ptr = basic_streambuf_wchar_eback(&this->base);
3863         memcpy(buf, ptr, oldsize*sizeof(wchar_t));
3864
3865         this->seekhigh = buf+(this->seekhigh-ptr);
3866         basic_streambuf_wchar_setp_next(&this->base, buf,
3867                 buf+(basic_streambuf_wchar_pptr(&this->base)-ptr), buf+size);
3868         if(this->state & STRINGBUF_no_read)
3869             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
3870         else
3871             basic_streambuf_wchar_setg(&this->base, buf,
3872                     buf+(basic_streambuf_wchar_gptr(&this->base)-ptr),
3873                     basic_streambuf_wchar_pptr(&this->base)+1);
3874
3875         MSVCRT_operator_delete(ptr);
3876     }
3877
3878     return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
3879 }
3880
3881 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
3882 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
3883 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
3884 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
3885 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_pbackfail, 8)
3886 unsigned short __thiscall basic_stringbuf_wchar_pbackfail(basic_stringbuf_wchar *this, unsigned short c)
3887 {
3888     wchar_t *cur;
3889
3890     TRACE("(%p %x)\n", this, c);
3891
3892     cur = basic_streambuf_wchar_gptr(&this->base);
3893     if(!cur || cur==basic_streambuf_wchar_eback(&this->base)
3894             || (c!=WEOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3895         return WEOF;
3896
3897     if(c != WEOF)
3898         cur[-1] = c;
3899     basic_streambuf_wchar_gbump(&this->base, -1);
3900     return c==WEOF ? !WEOF : c;
3901 }
3902
3903 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGXZ */
3904 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGXZ */
3905 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGXZ */
3906 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGXZ */
3907 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_underflow, 4)
3908 unsigned short __thiscall basic_stringbuf_wchar_underflow(basic_stringbuf_wchar *this)
3909 {
3910     wchar_t *ptr, *cur;
3911
3912     TRACE("(%p)\n", this);
3913
3914     cur = basic_streambuf_wchar_gptr(&this->base);
3915     if(!cur || this->state&STRINGBUF_no_read)
3916         return WEOF;
3917
3918     ptr  = basic_streambuf_wchar_pptr(&this->base);
3919     if(this->seekhigh < ptr)
3920         this->seekhigh = ptr;
3921
3922     ptr = basic_streambuf_wchar_egptr(&this->base);
3923     if(this->seekhigh > ptr)
3924         basic_streambuf_wchar_setg(&this->base, basic_streambuf_wchar_eback(&this->base), cur, this->seekhigh);
3925
3926     if(cur < this->seekhigh)
3927         return *cur;
3928     return WEOF;
3929 }
3930
3931 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3932 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3933 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3934 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3935 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekoff, 20)
3936 fpos_int* __thiscall basic_stringbuf_wchar_seekoff(basic_stringbuf_wchar *this,
3937         fpos_int *ret, streamoff off, int way, int mode)
3938 {
3939     wchar_t *beg, *cur_r, *cur_w;
3940
3941     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3942
3943     cur_w = basic_streambuf_wchar_pptr(&this->base);
3944     if(cur_w > this->seekhigh)
3945         this->seekhigh = cur_w;
3946
3947     ret->off = 0;
3948     ret->pos = 0;
3949     ret->state = 0;
3950
3951     beg = basic_streambuf_wchar_eback(&this->base);
3952     cur_r = basic_streambuf_wchar_gptr(&this->base);
3953     if((mode & OPENMODE_in) && cur_r) {
3954         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3955             off += cur_r-beg;
3956         else if(way == SEEKDIR_end)
3957             off += this->seekhigh-beg;
3958         else if(way != SEEKDIR_beg)
3959             off = -1;
3960
3961         if(off<0 || off>this->seekhigh-beg) {
3962             off = -1;
3963         }else {
3964             basic_streambuf_wchar_gbump(&this->base, beg-cur_r+off);
3965             if((mode & OPENMODE_out) && cur_w) {
3966                 basic_streambuf_wchar_setp_next(&this->base, beg,
3967                         basic_streambuf_wchar_gptr(&this->base),
3968                         basic_streambuf_wchar_epptr(&this->base));
3969             }
3970         }
3971     }else if((mode & OPENMODE_out) && cur_w) {
3972         if(way == SEEKDIR_cur)
3973             off += cur_w-beg;
3974         else if(way == SEEKDIR_end)
3975             off += this->seekhigh-beg;
3976         else if(way != SEEKDIR_beg)
3977             off = -1;
3978
3979         if(off<0 || off>this->seekhigh-beg)
3980             off = -1;
3981         else
3982             basic_streambuf_wchar_pbump(&this->base, beg-cur_w+off);
3983     }else {
3984         off = -1;
3985     }
3986
3987     ret->off = off;
3988     return ret;
3989 }
3990
3991 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3992 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3993 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3994 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3995 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekpos, 36)
3996 fpos_int* __thiscall basic_stringbuf_wchar_seekpos(basic_stringbuf_wchar *this,
3997         fpos_int *ret, fpos_int pos, int mode)
3998 {
3999     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
4000
4001     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
4002         *ret = pos;
4003         return ret;
4004     }
4005
4006     return basic_stringbuf_wchar_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
4007 }
4008
4009 /* ?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 */
4010 /* ?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 */
4011 /* ?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 */
4012 /* ?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 */
4013 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_set, 8)
4014 void __thiscall basic_stringbuf_wchar_str_set(basic_stringbuf_wchar *this, const basic_string_wchar *str)
4015 {
4016     TRACE("(%p %p)\n", this, str);
4017
4018     basic_stringbuf_wchar__Tidy(this);
4019     basic_stringbuf_wchar__Init(this, basic_string_wchar_c_str(str), str->size, this->state);
4020 }
4021
4022 /* ?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 */
4023 /* ?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 */
4024 /* ?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 */
4025 /* ?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 */
4026 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_get, 8)
4027 basic_string_wchar* __thiscall basic_stringbuf_wchar_str_get(const basic_stringbuf_wchar *this, basic_string_wchar *ret)
4028 {
4029     wchar_t *ptr;
4030
4031     TRACE("(%p)\n", this);
4032
4033     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_wchar_pptr(&this->base)) {
4034         wchar_t *pptr;
4035
4036         ptr = basic_streambuf_wchar_pbase(&this->base);
4037         pptr = basic_streambuf_wchar_pptr(&this->base);
4038
4039         return basic_string_wchar_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
4040     }
4041
4042     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_wchar_gptr(&this->base)) {
4043         ptr = basic_streambuf_wchar_eback(&this->base);
4044         return basic_string_wchar_ctor_cstr_len(ret, ptr, basic_streambuf_wchar_egptr(&this->base) - ptr);
4045     }
4046
4047     return basic_string_wchar_ctor(ret);
4048 }
4049
4050 /* ??0ios_base@std@@IAE@XZ */
4051 /* ??0ios_base@std@@IEAA@XZ */
4052 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
4053 ios_base* __thiscall ios_base_ctor(ios_base *this)
4054 {
4055     TRACE("(%p)\n", this);
4056     this->vtable = &MSVCP_ios_base_vtable;
4057     locale_ctor_uninitialized(&this->loc, 0);
4058     return this;
4059 }
4060
4061 /* ??0ios_base@std@@QAE@ABV01@@Z */
4062 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
4063 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
4064 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
4065 {
4066     TRACE("(%p %p)\n", this, copy);
4067     *this = *copy;
4068     this->vtable = &MSVCP_ios_base_vtable;
4069     return this;
4070 }
4071
4072 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
4073 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
4074 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
4075 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
4076 {
4077     IOS_BASE_fnarray *cur;
4078
4079     TRACE("(%p %x)\n", this, event);
4080
4081     for(cur=this->calls; cur; cur=cur->next)
4082         cur->event_handler(event, this, cur->index);
4083 }
4084
4085 /* ?_Tidy@ios_base@std@@AAAXXZ */
4086 /* ?_Tidy@ios_base@std@@AEAAXXZ */
4087 void CDECL ios_base_Tidy(ios_base *this)
4088 {
4089     IOS_BASE_iosarray *arr_cur, *arr_next;
4090     IOS_BASE_fnarray *event_cur, *event_next;
4091
4092     TRACE("(%p)\n", this);
4093
4094     ios_base_Callfns(this, EVENT_erase_event);
4095
4096     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
4097         arr_next = arr_cur->next;
4098         MSVCRT_operator_delete(arr_cur);
4099     }
4100     this->arr = NULL;
4101
4102     for(event_cur=this->calls; event_cur; event_cur=event_next) {
4103         event_next = event_cur->next;
4104         MSVCRT_operator_delete(event_cur);
4105     }
4106     this->calls = NULL;
4107 }
4108
4109 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
4110 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
4111 static void ios_base_Ios_base_dtor(ios_base *obj)
4112 {
4113     TRACE("(%p)\n", obj);
4114     locale_dtor(&obj->loc);
4115     ios_base_Tidy(obj);
4116 }
4117
4118 /* ??1ios_base@std@@UAE@XZ */
4119 /* ??1ios_base@std@@UEAA@XZ */
4120 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
4121 void __thiscall ios_base_dtor(ios_base *this)
4122 {
4123     ios_base_Ios_base_dtor(this);
4124 }
4125
4126 DEFINE_THISCALL_WRAPPER(ios_base_vector_dtor, 8)
4127 ios_base* __thiscall ios_base_vector_dtor(ios_base *this, unsigned int flags)
4128 {
4129     TRACE("(%p %x)\n", this, flags);
4130     if(flags & 2) {
4131         /* we have an array, with the number of elements stored before the first object */
4132         INT_PTR i, *ptr = (INT_PTR *)this-1;
4133
4134         for(i=*ptr-1; i>=0; i--)
4135             ios_base_dtor(this+i);
4136         MSVCRT_operator_delete(ptr);
4137     } else {
4138         ios_base_dtor(this);
4139         if(flags & 1)
4140             MSVCRT_operator_delete(this);
4141     }
4142
4143     return this;
4144 }
4145
4146 DEFINE_THISCALL_WRAPPER(iosb_vector_dtor, 8)
4147 void* __thiscall iosb_vector_dtor(void *this, unsigned int flags)
4148 {
4149     TRACE("(%p %x)\n", this, flags);
4150     if(flags & 2) {
4151         INT_PTR *ptr = (INT_PTR *)this-1;
4152         MSVCRT_operator_delete(ptr);
4153     } else {
4154         if(flags & 1)
4155             MSVCRT_operator_delete(this);
4156     }
4157
4158     return this;
4159 }
4160
4161 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
4162 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
4163 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
4164 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
4165 {
4166     IOS_BASE_iosarray *p;
4167
4168     TRACE("(%p %d)\n", this, index);
4169
4170     for(p=this->arr; p; p=p->next) {
4171         if(p->index == index)
4172             return p;
4173     }
4174
4175     for(p=this->arr; p; p=p->next) {
4176         if(!p->long_val && !p->ptr_val) {
4177             p->index = index;
4178             return p;
4179         }
4180     }
4181
4182     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
4183     p->next = this->arr;
4184     p->index = index;
4185     p->long_val = 0;
4186     p->ptr_val = NULL;
4187     this->arr = p;
4188     return p;
4189 }
4190
4191 /* ?iword@ios_base@std@@QAEAAJH@Z */
4192 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
4193 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
4194 LONG* __thiscall ios_base_iword(ios_base *this, int index)
4195 {
4196     TRACE("(%p %d)\n", this, index);
4197     return &ios_base_Findarr(this, index)->long_val;
4198 }
4199
4200 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
4201 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
4202 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
4203 void** __thiscall ios_base_pword(ios_base *this, int index)
4204 {
4205     TRACE("(%p %d)\n", this, index);
4206     return &ios_base_Findarr(this, index)->ptr_val;
4207 }
4208
4209 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
4210 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
4211 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
4212 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
4213 {
4214     IOS_BASE_fnarray *event;
4215
4216     TRACE("(%p %p %d)\n", this, callback, index);
4217
4218     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
4219     event->next = this->calls;
4220     event->index = index;
4221     event->event_handler = callback;
4222     this->calls = event;
4223 }
4224
4225 /* ?clear@ios_base@std@@QAEXH_N@Z */
4226 /* ?clear@ios_base@std@@QEAAXH_N@Z */
4227 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
4228 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4229 {
4230     TRACE("(%p %x %x)\n", this, state, reraise);
4231
4232     this->state = state & IOSTATE_mask;
4233     if(!(this->state & this->except))
4234         return;
4235
4236     if(reraise)
4237         throw_exception(EXCEPTION_RERAISE, NULL);
4238     else if(this->state & this->except & IOSTATE_eofbit)
4239         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
4240     else if(this->state & this->except & IOSTATE_failbit)
4241         throw_exception(EXCEPTION_FAILURE, "failbit is set");
4242     else if(this->state & this->except & IOSTATE_badbit)
4243         throw_exception(EXCEPTION_FAILURE, "badbit is set");
4244     else if(this->state & this->except & IOSTATE__Hardfail)
4245         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
4246 }
4247
4248 /* ?clear@ios_base@std@@QAEXH@Z */
4249 /* ?clear@ios_base@std@@QEAAXH@Z */
4250 static void ios_base_clear(ios_base *this, IOSB_iostate state)
4251 {
4252     ios_base_clear_reraise(this, state, FALSE);
4253 }
4254
4255 /* ?exceptions@ios_base@std@@QAEXH@Z */
4256 /* ?exceptions@ios_base@std@@QEAAXH@Z */
4257 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
4258 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
4259 {
4260     TRACE("(%p %x)\n", this, state);
4261     this->except = state & IOSTATE_mask;
4262     ios_base_clear(this, this->state);
4263 }
4264
4265 /* ?exceptions@ios_base@std@@QBEHXZ */
4266 /* ?exceptions@ios_base@std@@QEBAHXZ */
4267 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
4268 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
4269 {
4270     TRACE("(%p)\n", this);
4271     return this->except;
4272 }
4273
4274 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
4275 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
4276 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
4277 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
4278 {
4279     TRACE("(%p %p)\n", this, rhs);
4280
4281     if(this != rhs) {
4282         IOS_BASE_iosarray *arr_cur;
4283         IOS_BASE_fnarray *event_cur;
4284
4285         ios_base_Tidy(this);
4286
4287         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
4288             if(arr_cur->long_val)
4289                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
4290             if(arr_cur->ptr_val)
4291                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
4292         }
4293         this->stdstr = rhs->stdstr;
4294         this->fmtfl = rhs->fmtfl;
4295         this->prec = rhs->prec;
4296         this->wide = rhs->wide;
4297         locale_operator_assign(&this->loc, &rhs->loc);
4298
4299         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
4300             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
4301
4302         ios_base_Callfns(this, EVENT_copyfmt_event);
4303         ios_base_exceptions_set(this, rhs->except);
4304     }
4305
4306     return this;
4307 }
4308
4309 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
4310 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
4311 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
4312 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
4313 {
4314     TRACE("(%p %p)\n", this, right);
4315
4316     if(this != right) {
4317         this->state = right->state;
4318         ios_base_copyfmt(this, right);
4319     }
4320
4321     return this;
4322 }
4323
4324 /* ?fail@ios_base@std@@QBE_NXZ */
4325 /* ?fail@ios_base@std@@QEBA_NXZ */
4326 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
4327 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
4328 {
4329     TRACE("(%p)\n", this);
4330     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
4331 }
4332
4333 /* ??7ios_base@std@@QBE_NXZ */
4334 /* ??7ios_base@std@@QEBA_NXZ */
4335 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
4336 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
4337 {
4338     TRACE("(%p)\n", this);
4339     return ios_base_fail(this);
4340 }
4341
4342 /* ??Bios_base@std@@QBEPAXXZ */
4343 /* ??Bios_base@std@@QEBAPEAXXZ */
4344 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
4345 void* __thiscall ios_base_op_fail(const ios_base *this)
4346 {
4347     TRACE("(%p)\n", this);
4348     return ios_base_fail(this) ? NULL : (void*)this;
4349 }
4350
4351 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
4352 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
4353 static void ios_base_Addstd(ios_base *add)
4354 {
4355     FIXME("(%p) stub\n", add);
4356 }
4357
4358 /* ?_Init@ios_base@std@@IAEXXZ */
4359 /* ?_Init@ios_base@std@@IEAAXXZ */
4360 DEFINE_THISCALL_WRAPPER(ios_base__Init, 4)
4361 void __thiscall ios_base__Init(ios_base *this)
4362 {
4363     TRACE("(%p)\n", this);
4364
4365     this->stdstr = 0;
4366     this->state = this->except = IOSTATE_goodbit;
4367     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
4368     this->prec = 6;
4369     this->wide = 0;
4370     this->arr = NULL;
4371     this->calls = NULL;
4372     locale_ctor(&this->loc);
4373 }
4374
4375 /* ?bad@ios_base@std@@QBE_NXZ */
4376 /* ?bad@ios_base@std@@QEBA_NXZ */
4377 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
4378 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
4379 {
4380     TRACE("(%p)\n", this);
4381     return (this->state & IOSTATE_badbit) != 0;
4382 }
4383
4384 /* ?eof@ios_base@std@@QBE_NXZ */
4385 /* ?eof@ios_base@std@@QEBA_NXZ */
4386 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
4387 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
4388 {
4389     TRACE("(%p)\n", this);
4390     return (this->state & IOSTATE_eofbit) != 0;
4391 }
4392
4393 /* ?flags@ios_base@std@@QAEHH@Z */
4394 /* ?flags@ios_base@std@@QEAAHH@Z */
4395 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
4396 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
4397 {
4398     IOSB_fmtflags ret = this->fmtfl;
4399
4400     TRACE("(%p %x)\n", this, flags);
4401
4402     this->fmtfl = flags & FMTFLAG_mask;
4403     return ret;
4404 }
4405
4406 /* ?flags@ios_base@std@@QBEHXZ */
4407 /* ?flags@ios_base@std@@QEBAHXZ */
4408 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
4409 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
4410 {
4411     TRACE("(%p)\n", this);
4412     return this->fmtfl;
4413 }
4414
4415 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
4416 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
4417 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
4418 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
4419 {
4420     TRACE("(%p)\n", this);
4421     return locale_copy_ctor(ret, &this->loc);
4422 }
4423
4424 /* ?good@ios_base@std@@QBE_NXZ */
4425 /* ?good@ios_base@std@@QEBA_NXZ */
4426 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
4427 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
4428 {
4429     TRACE("(%p)\n", this);
4430     return this->state == IOSTATE_goodbit;
4431 }
4432
4433 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
4434 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
4435 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
4436 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
4437 {
4438     TRACE("(%p %p)\n", this, loc);
4439     *ret = this->loc;
4440     locale_copy_ctor(&this->loc, loc);
4441     return ret;
4442 }
4443
4444 /* ?precision@ios_base@std@@QAEHH@Z */
4445 /* ?precision@ios_base@std@@QEAA_J_J@Z */
4446 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
4447 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
4448 {
4449     streamsize ret = this->prec;
4450
4451     TRACE("(%p %ld)\n", this, precision);
4452
4453     this->prec = precision;
4454     return ret;
4455 }
4456
4457 /* ?precision@ios_base@std@@QBEHXZ */
4458 /* ?precision@ios_base@std@@QEBA_JXZ */
4459 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
4460 streamsize __thiscall ios_base_precision_get(const ios_base *this)
4461 {
4462     TRACE("(%p)\n", this);
4463     return this->prec;
4464 }
4465
4466 /* ?rdstate@ios_base@std@@QBEHXZ */
4467 /* ?rdstate@ios_base@std@@QEBAHXZ */
4468 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
4469 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
4470 {
4471     TRACE("(%p)\n", this);
4472     return this->state;
4473 }
4474
4475 /* ?setf@ios_base@std@@QAEHHH@Z */
4476 /* ?setf@ios_base@std@@QEAAHHH@Z */
4477 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
4478 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
4479 {
4480     IOSB_fmtflags ret = this->fmtfl;
4481
4482     TRACE("(%p %x %x)\n", this, flags, mask);
4483
4484     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
4485     return ret;
4486 }
4487
4488 /* ?setf@ios_base@std@@QAEHH@Z */
4489 /* ?setf@ios_base@std@@QEAAHH@Z */
4490 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
4491 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
4492 {
4493     return ios_base_setf_mask(this, flags, ~0);
4494 }
4495
4496 /* ?setstate@ios_base@std@@QAEXH_N@Z */
4497 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
4498 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
4499 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4500 {
4501     TRACE("(%p %x %x)\n", this, state, reraise);
4502
4503     if(state != IOSTATE_goodbit)
4504         ios_base_clear_reraise(this, this->state | state, reraise);
4505 }
4506
4507 /* ?setstate@ios_base@std@@QAEXH@Z */
4508 /* ?setstate@ios_base@std@@QEAAXH@Z */
4509 static void ios_base_setstate(ios_base *this, IOSB_iostate state)
4510 {
4511     ios_base_setstate_reraise(this, state, FALSE);
4512 }
4513
4514 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
4515 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
4516 {
4517     _Lockit lock;
4518     MSVCP_bool ret;
4519
4520     TRACE("(%x)\n", sync);
4521
4522     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4523     ret = ios_base_Sync;
4524     ios_base_Sync = sync;
4525     _Lockit_dtor(&lock);
4526     return ret;
4527 }
4528
4529 /* ?unsetf@ios_base@std@@QAEXH@Z */
4530 /* ?unsetf@ios_base@std@@QEAAXH@Z */
4531 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
4532 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
4533 {
4534     TRACE("(%p %x)\n", this, flags);
4535     this->fmtfl &= ~flags;
4536 }
4537
4538 /* ?width@ios_base@std@@QAEHH@Z */
4539 /* ?width@ios_base@std@@QEAA_J_J@Z */
4540 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
4541 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
4542 {
4543     streamsize ret = this->wide;
4544
4545     TRACE("(%p %ld)\n", this, width);
4546
4547     this->wide = width;
4548     return ret;
4549 }
4550
4551 /* ?width@ios_base@std@@QBEHXZ */
4552 /* ?width@ios_base@std@@QEBA_JXZ */
4553 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
4554 streamsize __thiscall ios_base_width_get(ios_base *this)
4555 {
4556     TRACE("(%p)\n", this);
4557     return this->wide;
4558 }
4559
4560 /* ?xalloc@ios_base@std@@SAHXZ */
4561 int CDECL ios_base_xalloc(void)
4562 {
4563     _Lockit lock;
4564     int ret;
4565
4566     TRACE("\n");
4567
4568     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4569     ret = ios_base_Index++;
4570     _Lockit_dtor(&lock);
4571     return ret;
4572 }
4573
4574 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
4575 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
4576 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
4577 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
4578 {
4579     TRACE("(%p)\n", this);
4580
4581     ios_base_ctor(&this->base);
4582     this->base.vtable = &MSVCP_basic_ios_char_vtable;
4583     return this;
4584 }
4585
4586 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4587 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4588 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
4589 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
4590 {
4591     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4592     ios_base__Init(&this->base);
4593     this->strbuf = streambuf;
4594     this->stream = NULL;
4595     this->fillch = ' ';
4596
4597     if(!streambuf)
4598         ios_base_setstate(&this->base, IOSTATE_badbit);
4599
4600     if(isstd)
4601         FIXME("standard streams not handled yet\n");
4602 }
4603
4604 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4605 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4606 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
4607 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
4608 {
4609     TRACE("(%p %p)\n", this, strbuf);
4610
4611     basic_ios_char_ctor(this);
4612     basic_ios_char_init(this, strbuf, FALSE);
4613     return this;
4614 }
4615
4616 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
4617 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4618 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
4619 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
4620 {
4621     TRACE("(%p)\n", this);
4622     ios_base_dtor(&this->base);
4623 }
4624
4625 DEFINE_THISCALL_WRAPPER(basic_ios_char_vector_dtor, 8)
4626 basic_ios_char* __thiscall basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
4627 {
4628     TRACE("(%p %x)\n", this, flags);
4629     if(flags & 2) {
4630         /* we have an array, with the number of elements stored before the first object */
4631         INT_PTR i, *ptr = (INT_PTR *)this-1;
4632
4633         for(i=*ptr-1; i>=0; i--)
4634             basic_ios_char_dtor(this+i);
4635         MSVCRT_operator_delete(ptr);
4636     } else {
4637         basic_ios_char_dtor(this);
4638         if(flags & 1)
4639             MSVCRT_operator_delete(this);
4640     }
4641
4642     return this;
4643 }
4644
4645 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4646 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4647 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
4648 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4649 {
4650     TRACE("(%p %x %x)\n", this, state, reraise);
4651     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4652 }
4653
4654 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4655 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4656 static void basic_ios_char_clear(basic_ios_char *this, unsigned int state)
4657 {
4658     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
4659 }
4660
4661 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
4662 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4663 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
4664 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
4665 {
4666     TRACE("(%p %p)\n", this, copy);
4667     if(this == copy)
4668         return this;
4669
4670     this->stream = copy->stream;
4671     this->fillch = copy->fillch;
4672     ios_base_copyfmt(&this->base, &copy->base);
4673     return this;
4674 }
4675
4676 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
4677 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
4678 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
4679 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
4680 {
4681     char ret = this->fillch;
4682
4683     TRACE("(%p %c)\n", this, fill);
4684
4685     this->fillch = fill;
4686     return ret;
4687 }
4688
4689 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
4690 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
4691 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
4692 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
4693 {
4694     TRACE("(%p)\n", this);
4695     return this->fillch;
4696 }
4697
4698 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
4699 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
4700 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
4701 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
4702 {
4703     TRACE("(%p %p %p)\n", this, ret, loc);
4704
4705     if(this->strbuf) {
4706         basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
4707         locale_dtor(ret);
4708     }
4709
4710     return ios_base_imbue(&this->base, ret, loc);
4711 }
4712
4713 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
4714 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
4715 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
4716 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
4717 {
4718     TRACE("(%p %c %c)\n", this, ch, def);
4719     return ctype_char_narrow_ch(ctype_char_use_facet(&this->strbuf->loc), ch, def);
4720 }
4721
4722 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
4723 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
4724 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
4725 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
4726 {
4727     basic_streambuf_char *ret = this->strbuf;
4728
4729     TRACE("(%p %p)\n", this, streambuf);
4730
4731     this->strbuf = streambuf;
4732     basic_ios_char_clear(this, IOSTATE_goodbit);
4733     return ret;
4734 }
4735
4736 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
4737 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
4738 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
4739 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
4740 {
4741     TRACE("(%p)\n", this);
4742     return this->strbuf;
4743 }
4744
4745 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4746 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4747 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
4748 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4749 {
4750     TRACE("(%p %x %x)\n", this, state, reraise);
4751
4752     if(state != IOSTATE_goodbit)
4753         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
4754 }
4755
4756 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4757 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4758 static void basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
4759 {
4760     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
4761 }
4762
4763 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
4764 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
4765 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
4766 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
4767 {
4768     basic_ostream_char *ret = this->stream;
4769
4770     TRACE("(%p %p)\n", this, ostream);
4771
4772     this->stream = ostream;
4773     return ret;
4774 }
4775
4776 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
4777 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
4778 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
4779 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
4780 {
4781     TRACE("(%p)\n", this);
4782     return this->stream;
4783 }
4784
4785 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
4786 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
4787 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
4788 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
4789 {
4790     TRACE("(%p %c)\n", this, ch);
4791     return ctype_char_widen_ch(ctype_char_use_facet(&this->strbuf->loc), ch);
4792 }
4793
4794
4795 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
4796 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
4797 static basic_ios_wchar* basic_ios_wchar_ctor(basic_ios_wchar *this)
4798 {
4799     TRACE("(%p)\n", this);
4800
4801     ios_base_ctor(&this->base);
4802     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
4803     return this;
4804 }
4805
4806 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
4807 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
4808 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
4809 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
4810 {
4811     basic_ios_wchar_ctor(this);
4812     this->base.vtable = &MSVCP_basic_ios_short_vtable;
4813     return this;
4814 }
4815
4816 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
4817 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
4818 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
4819 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
4820 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
4821 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
4822 {
4823     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4824     ios_base__Init(&this->base);
4825     this->strbuf = streambuf;
4826     this->stream = NULL;
4827     this->fillch = ' ';
4828
4829     if(!streambuf)
4830         ios_base_setstate(&this->base, IOSTATE_badbit);
4831
4832     if(isstd)
4833         FIXME("standard streams not handled yet\n");
4834 }
4835
4836 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
4837 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
4838 static basic_ios_wchar* basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
4839 {
4840     TRACE("(%p %p)\n", this, strbuf);
4841
4842     basic_ios_wchar_ctor(this);
4843     basic_ios_wchar_init(this, strbuf, FALSE);
4844     return this;
4845 }
4846
4847 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
4848 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
4849 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
4850 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
4851 {
4852     basic_ios_wchar_ctor_streambuf(this, strbuf);
4853     this->base.vtable = &MSVCP_basic_ios_short_vtable;
4854     return this;
4855 }
4856
4857 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
4858 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
4859 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
4860 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
4861 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
4862 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
4863 {
4864     TRACE("(%p)\n", this);
4865     ios_base_dtor(&this->base);
4866 }
4867
4868 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_vector_dtor, 8)
4869 basic_ios_wchar* __thiscall basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
4870 {
4871     TRACE("(%p %x)\n", this, flags);
4872     if(flags & 2) {
4873         /* we have an array, with the number of elements stored before the first object */
4874         INT_PTR i, *ptr = (INT_PTR *)this-1;
4875
4876         for(i=*ptr-1; i>=0; i--)
4877             basic_ios_wchar_dtor(this+i);
4878         MSVCRT_operator_delete(ptr);
4879     } else {
4880         basic_ios_wchar_dtor(this);
4881         if(flags & 1)
4882             MSVCRT_operator_delete(this);
4883     }
4884
4885     return this;
4886 }
4887
4888 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
4889 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
4890 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
4891 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
4892 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
4893 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
4894 {
4895     TRACE("(%p %x %x)\n", this, state, reraise);
4896     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4897 }
4898
4899 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
4900 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
4901 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
4902 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
4903 static void basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
4904 {
4905     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
4906 }
4907
4908 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
4909 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4910 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
4911 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4912 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
4913 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
4914 {
4915     TRACE("(%p %p)\n", this, copy);
4916     if(this == copy)
4917         return this;
4918
4919     this->stream = copy->stream;
4920     this->fillch = copy->fillch;
4921     ios_base_copyfmt(&this->base, &copy->base);
4922     return this;
4923 }
4924
4925 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
4926 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
4927 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
4928 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
4929 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
4930 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
4931 {
4932     wchar_t ret = this->fillch;
4933
4934     TRACE("(%p %c)\n", this, fill);
4935
4936     this->fillch = fill;
4937     return ret;
4938 }
4939
4940 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
4941 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
4942 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
4943 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
4944 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
4945 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
4946 {
4947     TRACE("(%p)\n", this);
4948     return this->fillch;
4949 }
4950
4951 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
4952 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
4953 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
4954 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
4955 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
4956 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
4957 {
4958     TRACE("(%p %p %p)\n", this, ret, loc);
4959
4960     if(this->strbuf) {
4961         basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
4962         locale_dtor(ret);
4963     }
4964
4965     return ios_base_imbue(&this->base, ret, loc);
4966 }
4967
4968 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
4969 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
4970 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
4971 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
4972 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
4973 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
4974 {
4975     TRACE("(%p %c %c)\n", this, ch, def);
4976     return ctype_wchar_narrow_ch(ctype_wchar_use_facet(&this->strbuf->loc), ch, def);
4977 }
4978
4979 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
4980 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
4981 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
4982 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
4983 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
4984 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
4985 {
4986     basic_streambuf_wchar *ret = this->strbuf;
4987
4988     TRACE("(%p %p)\n", this, streambuf);
4989
4990     this->strbuf = streambuf;
4991     basic_ios_wchar_clear(this, IOSTATE_goodbit);
4992     return ret;
4993 }
4994
4995 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
4996 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
4997 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
4998 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
4999 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
5000 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
5001 {
5002     TRACE("(%p)\n", this);
5003     return this->strbuf;
5004 }
5005
5006 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5007 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5008 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5009 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5010 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
5011 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5012 {
5013     TRACE("(%p %x %x)\n", this, state, reraise);
5014
5015     if(state != IOSTATE_goodbit)
5016         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
5017 }
5018
5019 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5020 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5021 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5022 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5023 static void basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
5024 {
5025     basic_ios_wchar_setstate_reraise(this, state, FALSE);
5026 }
5027
5028 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5029 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5030 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
5031 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5032 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
5033 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
5034 {
5035     basic_ostream_wchar *ret = this->stream;
5036
5037     TRACE("(%p %p)\n", this, ostream);
5038
5039     this->stream = ostream;
5040     return ret;
5041 }
5042
5043 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5044 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5045 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5046 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5047 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
5048 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
5049 {
5050     TRACE("(%p)\n", this);
5051     return this->stream;
5052 }
5053
5054 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
5055 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
5056 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
5057 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
5058 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
5059 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
5060 {
5061     TRACE("(%p %c)\n", this, ch);
5062     return ctype_wchar_widen_ch(ctype_wchar_use_facet(&this->strbuf->loc), ch);
5063 }
5064
5065 /* Caution: basic_ostream uses virtual inheritance.
5066  * All constructors have additional parameter that says if base class should be initialized.
5067  * Base class needs to be accessed using vbtable.
5068  */
5069 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
5070 {
5071     return (basic_ios_char*)((char*)this+this->vbtable[1]);
5072 }
5073
5074 static inline basic_ios_char* basic_ostream_char_to_basic_ios(basic_ostream_char *ptr)
5075 {
5076     return (basic_ios_char*)((char*)ptr+basic_ostream_char_vbtable[1]);
5077 }
5078
5079 static inline basic_ostream_char* basic_ostream_char_from_basic_ios(basic_ios_char *ptr)
5080 {
5081     return (basic_ostream_char*)((char*)ptr-basic_ostream_char_vbtable[1]);
5082 }
5083
5084 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5085 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5086 static basic_ostream_char* basic_ostream_char_ctor(basic_ostream_char *this,
5087         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5088 {
5089     basic_ios_char *base;
5090
5091     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5092
5093     if(virt_init) {
5094         this->vbtable = basic_ostream_char_vbtable;
5095         base = basic_ostream_char_get_basic_ios(this);
5096         basic_ios_char_ctor(base);
5097     }else {
5098         base = basic_ostream_char_get_basic_ios(this);
5099     }
5100
5101     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5102     basic_ios_char_init(base, strbuf, isstd);
5103     return this;
5104 }
5105
5106 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5107 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5108 static basic_ostream_char* basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
5109         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5110 {
5111     basic_ios_char *base;
5112
5113     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5114
5115     if(virt_init) {
5116         this->vbtable = basic_ostream_char_vbtable;
5117         base = basic_ostream_char_get_basic_ios(this);
5118         basic_ios_char_ctor(base);
5119     }else {
5120         base = basic_ostream_char_get_basic_ios(this);
5121     }
5122
5123     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5124     if(addstd)
5125         ios_base_Addstd(&base->base);
5126     return this;
5127 }
5128
5129 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5130 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5131 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
5132 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
5133 {
5134     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5135
5136     /* don't destroy virtual base here */
5137     TRACE("(%p)\n", this);
5138 }
5139
5140 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5141 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5142 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
5143 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
5144 {
5145     TRACE("(%p)\n", this);
5146     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
5147     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
5148 }
5149
5150 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
5151 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5152 {
5153     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5154
5155     TRACE("(%p %x)\n", this, flags);
5156
5157     if(flags & 2) {
5158         /* we have an array, with the number of elements stored before the first object */
5159         INT_PTR i, *ptr = (INT_PTR *)this-1;
5160
5161         for(i=*ptr-1; i>=0; i--)
5162             basic_ostream_char_vbase_dtor(this+i);
5163         MSVCRT_operator_delete(ptr);
5164     } else {
5165         basic_ostream_char_vbase_dtor(this);
5166         if(flags & 1)
5167             MSVCRT_operator_delete(this);
5168     }
5169
5170     return this;
5171 }
5172
5173 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5174 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5175 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
5176 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
5177 {
5178     /* this function is not matching C++ specification */
5179     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5180
5181     TRACE("(%p)\n", this);
5182
5183     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
5184             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
5185         basic_ios_char_setstate(base, IOSTATE_badbit);
5186     return this;
5187 }
5188
5189 /* ?flush@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5190 /* ?flush@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5191 basic_ostream_char* __cdecl flush_ostream_char(basic_ostream_char *ostream)
5192 {
5193     return basic_ostream_char_flush(ostream);
5194 }
5195
5196 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5197 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5198 static void basic_ostream_char__Osfx(basic_ostream_char *this)
5199 {
5200     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5201
5202     TRACE("(%p)\n", this);
5203
5204     if(base->base.fmtfl & FMTFLAG_unitbuf)
5205         basic_ostream_char_flush(this);
5206 }
5207
5208 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5209 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5210 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
5211 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
5212 {
5213     TRACE("(%p)\n", this);
5214     basic_ostream_char__Osfx(this);
5215 }
5216
5217 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
5218 {
5219     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5220
5221     if(basic_ios_char_rdbuf_get(base))
5222         basic_streambuf_char__Lock(base->strbuf);
5223
5224     if(ios_base_good(&base->base) && base->stream)
5225         basic_ostream_char_flush(base->stream);
5226
5227     return ios_base_good(&base->base);
5228 }
5229
5230 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
5231 {
5232     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5233
5234     if(ios_base_good(&base->base) && !__uncaught_exception())
5235         basic_ostream_char_osfx(ostr);
5236
5237     if(basic_ios_char_rdbuf_get(base))
5238         basic_streambuf_char__Unlock(base->strbuf);
5239 }
5240
5241 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
5242 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
5243 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
5244 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
5245 {
5246     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5247
5248     TRACE("(%p)\n", this);
5249
5250     if(ios_base_good(&base->base) && base->stream)
5251         basic_ostream_char_flush(base->stream);
5252     return ios_base_good(&base->base);
5253 }
5254
5255 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5256 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5257 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
5258 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
5259 {
5260     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5261
5262     TRACE("(%p %c)\n", this, ch);
5263
5264     if(!basic_ostream_char_sentry_create(this)
5265             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
5266         basic_ostream_char_sentry_destroy(this);
5267         basic_ios_char_setstate(base, IOSTATE_badbit);
5268         return this;
5269     }
5270
5271     basic_ostream_char_sentry_destroy(this);
5272     return this;
5273 }
5274
5275 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
5276 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
5277 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
5278 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
5279 {
5280     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5281
5282     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
5283
5284     if(!ios_base_fail(&base->base)) {
5285         fpos_int seek;
5286
5287         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
5288                 &seek, pos, OPENMODE_out);
5289         if(seek.off==-1 && seek.pos==0 && seek.state==0)
5290             basic_ios_char_setstate(base, IOSTATE_failbit);
5291     }
5292     return this;
5293 }
5294
5295 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
5296 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
5297 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
5298 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
5299 {
5300     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5301
5302     TRACE("(%p)\n", this);
5303
5304     if(!ios_base_fail(&base->base)) {
5305         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5306                 ret, 0, SEEKDIR_cur, OPENMODE_out);
5307     }else {
5308         ret->off = -1;
5309         ret->pos = 0;
5310         ret->state = 0;
5311     }
5312     return ret;
5313 }
5314
5315 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
5316 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
5317 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
5318 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
5319 {
5320     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5321
5322     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
5323
5324     if(!basic_ostream_char_sentry_create(this)
5325             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
5326         basic_ostream_char_sentry_destroy(this);
5327         basic_ios_char_setstate(base, IOSTATE_badbit);
5328         return this;
5329     }
5330
5331     basic_ostream_char_sentry_destroy(this);
5332     return this;
5333 }
5334
5335 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
5336 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
5337 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
5338 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
5339 {
5340     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5341     int state = IOSTATE_goodbit;
5342
5343     TRACE("(%p %d)\n", this, val);
5344
5345     if(basic_ostream_char_sentry_create(this)) {
5346         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5347         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5348         ostreambuf_iterator_char dest = {0, strbuf};
5349
5350         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
5351                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
5352                 ? (LONG)((unsigned short)val) : (LONG)val);
5353     }
5354     basic_ostream_char_sentry_destroy(this);
5355
5356     basic_ios_char_setstate(base, state);
5357     return this;
5358 }
5359
5360 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
5361 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
5362 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
5363 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
5364 {
5365     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5366     int state = IOSTATE_goodbit;
5367
5368     TRACE("(%p %u)\n", this, val);
5369
5370     if(basic_ostream_char_sentry_create(this)) {
5371         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5372         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5373         ostreambuf_iterator_char dest = {0, strbuf};
5374
5375         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5376     }
5377     basic_ostream_char_sentry_destroy(this);
5378
5379     basic_ios_char_setstate(base, state);
5380     return this;
5381 }
5382
5383 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
5384 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
5385 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
5386 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
5387 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
5388 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
5389 {
5390     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5391     int state = IOSTATE_goodbit;
5392
5393     TRACE("(%p %d)\n", this, val);
5394
5395     if(basic_ostream_char_sentry_create(this)) {
5396         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5397         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5398         ostreambuf_iterator_char dest = {0, strbuf};
5399
5400         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5401     }
5402     basic_ostream_char_sentry_destroy(this);
5403
5404     basic_ios_char_setstate(base, state);
5405     return this;
5406 }
5407
5408 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
5409 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
5410 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
5411 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
5412 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
5413 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
5414 {
5415     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5416     int state = IOSTATE_goodbit;
5417
5418     TRACE("(%p %u)\n", this, val);
5419
5420     if(basic_ostream_char_sentry_create(this)) {
5421         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5422         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5423         ostreambuf_iterator_char dest = {0, strbuf};
5424
5425         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5426     }
5427     basic_ostream_char_sentry_destroy(this);
5428
5429     basic_ios_char_setstate(base, state);
5430     return this;
5431 }
5432
5433 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
5434 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
5435 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
5436 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
5437 {
5438     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5439     int state = IOSTATE_goodbit;
5440
5441     TRACE("(%p %f)\n", this, val);
5442
5443     if(basic_ostream_char_sentry_create(this)) {
5444         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5445         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5446         ostreambuf_iterator_char dest = {0, strbuf};
5447
5448         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5449     }
5450     basic_ostream_char_sentry_destroy(this);
5451
5452     basic_ios_char_setstate(base, state);
5453     return this;
5454 }
5455
5456 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
5457 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
5458 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
5459 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
5460 {
5461     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5462     int state = IOSTATE_goodbit;
5463
5464     TRACE("(%p %lf)\n", this, val);
5465
5466     if(basic_ostream_char_sentry_create(this)) {
5467         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5468         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5469         ostreambuf_iterator_char dest = {0, strbuf};
5470
5471         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5472     }
5473     basic_ostream_char_sentry_destroy(this);
5474
5475     basic_ios_char_setstate(base, state);
5476     return this;
5477 }
5478
5479 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
5480 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
5481 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
5482 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
5483 {
5484     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5485     int state = IOSTATE_goodbit;
5486
5487     TRACE("(%p %lf)\n", this, val);
5488
5489     if(basic_ostream_char_sentry_create(this)) {
5490         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5491         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5492         ostreambuf_iterator_char dest = {0, strbuf};
5493
5494         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5495     }
5496     basic_ostream_char_sentry_destroy(this);
5497
5498     basic_ios_char_setstate(base, state);
5499     return this;
5500 }
5501
5502 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5503 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5504 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
5505 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
5506 {
5507     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5508     IOSB_iostate state = IOSTATE_badbit;
5509     int c = '\n';
5510
5511     TRACE("(%p %p)\n", this, val);
5512
5513     if(basic_ostream_char_sentry_create(this)) {
5514         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
5515                 c = basic_streambuf_char_snextc(val)) {
5516             state = IOSTATE_goodbit;
5517
5518             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
5519                 state = IOSTATE_badbit;
5520                 break;
5521             }
5522         }
5523     }else {
5524         state = IOSTATE_badbit;
5525     }
5526     basic_ostream_char_sentry_destroy(this);
5527
5528     ios_base_width_set(&base->base, 0);
5529     basic_ios_char_setstate(base, state);
5530     return this;
5531 }
5532
5533 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
5534 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
5535 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
5536 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
5537 {
5538     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5539     int state = IOSTATE_goodbit;
5540
5541     TRACE("(%p %p)\n", this, val);
5542
5543     if(basic_ostream_char_sentry_create(this)) {
5544         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5545         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5546         ostreambuf_iterator_char dest = {0, strbuf};
5547
5548         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5549     }
5550     basic_ostream_char_sentry_destroy(this);
5551
5552     basic_ios_char_setstate(base, state);
5553     return this;
5554 }
5555
5556 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
5557 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
5558 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
5559 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
5560 {
5561     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5562     int state = IOSTATE_goodbit;
5563
5564     TRACE("(%p)\n", this);
5565
5566     if(basic_ostream_char_sentry_create(this)) {
5567         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5568         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5569         ostreambuf_iterator_char dest = {0, strbuf};
5570
5571         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5572     }
5573     basic_ostream_char_sentry_destroy(this);
5574
5575     basic_ios_char_setstate(base, state);
5576     return this;
5577 }
5578
5579 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
5580 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
5581 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
5582 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
5583 {
5584     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5585     int state = IOSTATE_goodbit;
5586
5587     TRACE("(%p)\n", this);
5588
5589     if(basic_ostream_char_sentry_create(this)) {
5590         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5591         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5592         ostreambuf_iterator_char dest = {0, strbuf};
5593
5594         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5595     }
5596     basic_ostream_char_sentry_destroy(this);
5597
5598     basic_ios_char_setstate(base, state);
5599     return this;
5600 }
5601
5602 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
5603 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
5604 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
5605 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
5606 {
5607     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5608     int state = IOSTATE_goodbit;
5609
5610     TRACE("(%p %x)\n", this, val);
5611
5612     if(basic_ostream_char_sentry_create(this)) {
5613         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5614         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5615         ostreambuf_iterator_char dest = {0, strbuf};
5616
5617         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5618     }
5619     basic_ostream_char_sentry_destroy(this);
5620
5621     basic_ios_char_setstate(base, state);
5622     return this;
5623 }
5624
5625 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5626 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5627 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
5628 {
5629     TRACE("(%p)\n", ostr);
5630
5631     basic_ostream_char_put(ostr, '\n');
5632     basic_ostream_char_flush(ostr);
5633     return ostr;
5634 }
5635
5636 /* $?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 */
5637 /* ??$?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 */
5638 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
5639 {
5640     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5641     IOSB_iostate state = IOSTATE_goodbit;
5642
5643     TRACE("(%p %p)\n", ostr, str);
5644
5645     if(basic_ostream_char_sentry_create(ostr)) {
5646         MSVCP_size_t len = basic_string_char_length(str);
5647         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5648
5649         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5650             for(; pad!=0; pad--) {
5651                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5652                     state = IOSTATE_badbit;
5653                     break;
5654                 }
5655             }
5656         }
5657
5658         if(state == IOSTATE_goodbit) {
5659             if(basic_streambuf_char_sputn(base->strbuf, basic_string_char_c_str(str), len) != len)
5660                     state = IOSTATE_badbit;
5661         }
5662
5663         if(state == IOSTATE_goodbit) {
5664             for(; pad!=0; pad--) {
5665                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5666                     state = IOSTATE_badbit;
5667                     break;
5668                 }
5669             }
5670         }
5671
5672         base->base.wide = 0;
5673     }else {
5674         state = IOSTATE_badbit;
5675     }
5676     basic_ostream_char_sentry_destroy(ostr);
5677
5678     basic_ios_char_setstate(base, state);
5679     return ostr;
5680 }
5681
5682 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@C@Z */
5683 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@C@Z */
5684 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z */
5685 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z */
5686 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@E@Z */
5687 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@E@Z */
5688 basic_ostream_char* __cdecl basic_ostream_char_print_ch(basic_ostream_char *ostr, char ch)
5689 {
5690     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5691     IOSB_iostate state = IOSTATE_goodbit;
5692
5693     TRACE("(%p %d)\n", ostr, ch);
5694
5695     if(basic_ostream_char_sentry_create(ostr)) {
5696         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
5697
5698         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5699             for(; pad!=0; pad--) {
5700                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5701                     state = IOSTATE_badbit;
5702                     break;
5703                 }
5704             }
5705         }
5706
5707         if(state == IOSTATE_goodbit) {
5708             if(basic_streambuf_char_sputc(base->strbuf, ch) == EOF)
5709                 state = IOSTATE_badbit;
5710         }
5711
5712         if(state == IOSTATE_goodbit) {
5713             for(; pad!=0; pad--) {
5714                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5715                     state = IOSTATE_badbit;
5716                     break;
5717                 }
5718             }
5719         }
5720
5721         base->base.wide = 0;
5722     }else {
5723         state = IOSTATE_badbit;
5724     }
5725     basic_ostream_char_sentry_destroy(ostr);
5726
5727     basic_ios_char_setstate(base, state);
5728     return ostr;
5729 }
5730
5731 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBC@Z */
5732 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBC@Z */
5733 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z */
5734 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z */
5735 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBE@Z */
5736 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBE@Z */
5737 basic_ostream_char* __cdecl basic_ostream_char_print_str(basic_ostream_char *ostr, const char *str)
5738 {
5739     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5740     IOSB_iostate state = IOSTATE_goodbit;
5741
5742     TRACE("(%p %s)\n", ostr, str);
5743
5744     if(basic_ostream_char_sentry_create(ostr)) {
5745         MSVCP_size_t len = strlen(str);
5746         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5747
5748         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5749             for(; pad!=0; pad--) {
5750                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5751                     state = IOSTATE_badbit;
5752                     break;
5753                 }
5754             }
5755         }
5756
5757         if(state == IOSTATE_goodbit) {
5758             if(basic_streambuf_char_sputn(base->strbuf, str, len) != len)
5759                 state = IOSTATE_badbit;
5760         }
5761
5762         if(state == IOSTATE_goodbit) {
5763             for(; pad!=0; pad--) {
5764                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5765                     state = IOSTATE_badbit;
5766                     break;
5767                 }
5768             }
5769         }
5770
5771         base->base.wide = 0;
5772     }else {
5773         state = IOSTATE_badbit;
5774     }
5775     basic_ostream_char_sentry_destroy(ostr);
5776
5777     basic_ios_char_setstate(base, state);
5778     return ostr;
5779 }
5780
5781 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
5782 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
5783 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
5784 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
5785         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
5786 {
5787     TRACE("(%p %p)\n", this, pfunc);
5788     pfunc(this);
5789     return this;
5790 }
5791
5792 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
5793 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
5794 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
5795 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
5796         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
5797 {
5798     TRACE("(%p %p)\n", this, pfunc);
5799     pfunc(basic_ostream_char_get_basic_ios(this));
5800     return this;
5801 }
5802
5803 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
5804 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
5805 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
5806 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
5807         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
5808 {
5809     TRACE("(%p %p)\n", this, pfunc);
5810     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
5811     return this;
5812 }
5813
5814 /* Caution: basic_ostream uses virtual inheritance. */
5815 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
5816 {
5817     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
5818 }
5819
5820 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
5821 {
5822     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
5823 }
5824
5825 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
5826 {
5827     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
5828 }
5829
5830 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
5831 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
5832 static basic_ostream_wchar* basic_ostream_wchar_ctor(basic_ostream_wchar *this,
5833         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5834 {
5835     basic_ios_wchar *base;
5836
5837     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5838
5839     if(virt_init) {
5840         this->vbtable = basic_ostream_wchar_vbtable;
5841         base = basic_ostream_wchar_get_basic_ios(this);
5842         basic_ios_wchar_ctor(base);
5843     }else {
5844         base = basic_ostream_wchar_get_basic_ios(this);
5845     }
5846
5847     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
5848     basic_ios_wchar_init(base, strbuf, isstd);
5849     return this;
5850 }
5851
5852 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
5853 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
5854 static basic_ostream_wchar* basic_ostream_short_ctor(basic_ostream_wchar *this,
5855         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5856 {
5857     basic_ostream_wchar_ctor(this, strbuf, isstd, virt_init);
5858     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
5859     return this;
5860 }
5861
5862 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5863 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5864 static basic_ostream_wchar* basic_ostream_wchar_ctor_uninitialized(basic_ostream_wchar *this,
5865         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5866 {
5867     basic_ios_wchar *base;
5868
5869     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5870
5871     if(virt_init) {
5872         this->vbtable = basic_ostream_wchar_vbtable;
5873         base = basic_ostream_wchar_get_basic_ios(this);
5874         basic_ios_wchar_ctor(base);
5875     }else {
5876         base = basic_ostream_wchar_get_basic_ios(this);
5877     }
5878
5879     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
5880     if(addstd)
5881         ios_base_Addstd(&base->base);
5882     return this;
5883 }
5884
5885 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
5886 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
5887 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
5888 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
5889 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
5890 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
5891 {
5892     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
5893
5894     /* don't destroy virtual base here */
5895     TRACE("(%p)\n", this);
5896 }
5897
5898 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
5899 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
5900 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
5901 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
5902 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
5903 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
5904 {
5905     TRACE("(%p)\n", this);
5906     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
5907     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
5908 }
5909
5910 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
5911 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
5912 {
5913     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
5914
5915     TRACE("(%p %x)\n", this, flags);
5916
5917     if(flags & 2) {
5918         /* we have an array, with the number of elements stored before the first object */
5919         INT_PTR i, *ptr = (INT_PTR *)this-1;
5920
5921         for(i=*ptr-1; i>=0; i--)
5922             basic_ostream_wchar_vbase_dtor(this+i);
5923         MSVCRT_operator_delete(ptr);
5924     } else {
5925         basic_ostream_wchar_vbase_dtor(this);
5926         if(flags & 1)
5927             MSVCRT_operator_delete(this);
5928     }
5929
5930     return this;
5931 }
5932
5933 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
5934 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
5935 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
5936 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
5937 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
5938 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
5939 {
5940     /* this function is not matching C++ specification */
5941     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5942
5943     TRACE("(%p)\n", this);
5944
5945     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
5946             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
5947         basic_ios_wchar_setstate(base, IOSTATE_badbit);
5948     return this;
5949 }
5950
5951 /* ?flush@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
5952 /* ?flush@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
5953 /* ?flush@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
5954 /* ?flush@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
5955 basic_ostream_wchar* __cdecl flush_ostream_wchar(basic_ostream_wchar *ostream)
5956 {
5957     return basic_ostream_wchar_flush(ostream);
5958 }
5959
5960 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
5961 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
5962 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
5963 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
5964 static void basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
5965 {
5966     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5967
5968     TRACE("(%p)\n", this);
5969
5970     if(base->base.fmtfl & FMTFLAG_unitbuf)
5971         basic_ostream_wchar_flush(this);
5972 }
5973
5974 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
5975 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
5976 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
5977 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
5978 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
5979 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
5980 {
5981     TRACE("(%p)\n", this);
5982     basic_ostream_wchar__Osfx(this);
5983 }
5984
5985 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
5986 {
5987     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
5988
5989     if(basic_ios_wchar_rdbuf_get(base))
5990         basic_streambuf_wchar__Lock(base->strbuf);
5991
5992     if(ios_base_good(&base->base) && base->stream)
5993         basic_ostream_wchar_flush(base->stream);
5994
5995     return ios_base_good(&base->base);
5996 }
5997
5998 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
5999 {
6000     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6001
6002     if(ios_base_good(&base->base) && !__uncaught_exception())
6003         basic_ostream_wchar_osfx(ostr);
6004
6005     if(basic_ios_wchar_rdbuf_get(base))
6006         basic_streambuf_wchar__Unlock(base->strbuf);
6007 }
6008
6009 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
6010 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
6011 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
6012 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
6013 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
6014 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
6015 {
6016     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6017
6018     TRACE("(%p)\n", this);
6019
6020     if(ios_base_good(&base->base) && base->stream)
6021         basic_ostream_wchar_flush(base->stream);
6022     return ios_base_good(&base->base);
6023 }
6024
6025 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
6026 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
6027 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
6028 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
6029 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
6030 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
6031 {
6032     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6033
6034     TRACE("(%p %c)\n", this, ch);
6035
6036     if(!basic_ostream_wchar_sentry_create(this)
6037             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
6038         basic_ostream_wchar_sentry_destroy(this);
6039         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6040         return this;
6041     }
6042
6043     basic_ostream_wchar_sentry_destroy(this);
6044     return this;
6045 }
6046
6047 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6048 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6049 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6050 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6051 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
6052 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
6053 {
6054     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6055
6056     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6057
6058     if(!ios_base_fail(&base->base)) {
6059         fpos_int seek;
6060
6061         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
6062                 &seek, pos, OPENMODE_out);
6063         if(seek.off==-1 && seek.pos==0 && seek.state==0)
6064             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6065     }
6066     return this;
6067 }
6068
6069 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6070 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6071 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6072 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6073 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
6074 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
6075 {
6076     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6077
6078     TRACE("(%p)\n", this);
6079
6080     if(!ios_base_fail(&base->base)) {
6081         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6082                 ret, 0, SEEKDIR_cur, OPENMODE_out);
6083     }else {
6084         ret->off = -1;
6085         ret->pos = 0;
6086         ret->state = 0;
6087     }
6088     return ret;
6089 }
6090
6091 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
6092 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
6093 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
6094 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
6095 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 12)
6096 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
6097 {
6098     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6099
6100     TRACE("(%p %s %ld)\n", this, debugstr_w(str), count);
6101
6102     if(!basic_ostream_wchar_sentry_create(this)
6103             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
6104         basic_ostream_wchar_sentry_destroy(this);
6105         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6106         return this;
6107     }
6108
6109     basic_ostream_wchar_sentry_destroy(this);
6110     return this;
6111 }
6112
6113 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
6114 {
6115     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6116     int state = IOSTATE_goodbit;
6117
6118     TRACE("(%p %d)\n", this, val);
6119
6120     if(basic_ostream_wchar_sentry_create(this)) {
6121         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6122         ostreambuf_iterator_wchar dest = {0, strbuf};
6123
6124         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
6125                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
6126                 ? (LONG)((unsigned short)val) : (LONG)val);
6127     }
6128     basic_ostream_wchar_sentry_destroy(this);
6129
6130     basic_ios_wchar_setstate(base, state);
6131     return this;
6132 }
6133
6134 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
6135 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
6136 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
6137 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
6138 {
6139     return basic_ostream_print_short(this, val, num_put_short_use_facet(
6140                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6141 }
6142
6143 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
6144 {
6145     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6146     int state = IOSTATE_goodbit;
6147
6148     TRACE("(%p %d)\n", this, val);
6149
6150     if(basic_ostream_wchar_sentry_create(this)) {
6151         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6152         ostreambuf_iterator_wchar dest = {0, strbuf};
6153
6154         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6155     }
6156     basic_ostream_wchar_sentry_destroy(this);
6157
6158     basic_ios_wchar_setstate(base, state);
6159     return this;
6160 }
6161
6162 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
6163 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
6164 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
6165 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
6166 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
6167 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
6168 {
6169     return basic_ostream_print_int(this, val, num_put_short_use_facet(
6170                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6171 }
6172
6173 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
6174 {
6175     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6176     int state = IOSTATE_goodbit;
6177
6178     TRACE("(%p %u)\n", this, val);
6179
6180     if(basic_ostream_wchar_sentry_create(this)) {
6181         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6182         ostreambuf_iterator_wchar dest = {0, strbuf};
6183
6184         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6185     }
6186     basic_ostream_wchar_sentry_destroy(this);
6187
6188     basic_ios_wchar_setstate(base, state);
6189     return this;
6190 }
6191
6192 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
6193 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
6194 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
6195 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
6196 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
6197 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
6198 {
6199     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
6200                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6201 }
6202
6203 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
6204 {
6205     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6206     int state = IOSTATE_goodbit;
6207
6208     TRACE("(%p %f)\n", this, val);
6209
6210     if(basic_ostream_wchar_sentry_create(this)) {
6211         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6212         ostreambuf_iterator_wchar dest = {0, strbuf};
6213
6214         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6215     }
6216     basic_ostream_wchar_sentry_destroy(this);
6217
6218     basic_ios_wchar_setstate(base, state);
6219     return this;
6220 }
6221
6222 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
6223 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
6224 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
6225 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
6226 {
6227     return basic_ostream_print_float(this, val, num_put_short_use_facet(
6228                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6229 }
6230
6231 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
6232 {
6233     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6234     int state = IOSTATE_goodbit;
6235
6236     TRACE("(%p %lf)\n", this, val);
6237
6238     if(basic_ostream_wchar_sentry_create(this)) {
6239         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6240         ostreambuf_iterator_wchar dest = {0, strbuf};
6241
6242         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6243     }
6244     basic_ostream_wchar_sentry_destroy(this);
6245
6246     basic_ios_wchar_setstate(base, state);
6247     return this;
6248 }
6249
6250 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
6251 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
6252 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
6253 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
6254 {
6255     return basic_ostream_print_double(this, val, num_put_short_use_facet(
6256                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6257 }
6258
6259 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
6260 {
6261     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6262     int state = IOSTATE_goodbit;
6263
6264     TRACE("(%p %lf)\n", this, val);
6265
6266     if(basic_ostream_wchar_sentry_create(this)) {
6267         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6268         ostreambuf_iterator_wchar dest = {0, strbuf};
6269
6270         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6271     }
6272     basic_ostream_wchar_sentry_destroy(this);
6273
6274     basic_ios_wchar_setstate(base, state);
6275     return this;
6276 }
6277
6278 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
6279 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
6280 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
6281 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
6282 {
6283     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
6284                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6285 }
6286
6287 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6288 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6289 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6290 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6291 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
6292 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
6293 {
6294     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6295     IOSB_iostate state = IOSTATE_badbit;
6296     unsigned short c = '\n';
6297
6298     TRACE("(%p %p)\n", this, val);
6299
6300     if(basic_ostream_wchar_sentry_create(this)) {
6301         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
6302                 c = basic_streambuf_wchar_snextc(val)) {
6303             state = IOSTATE_goodbit;
6304
6305             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
6306                 state = IOSTATE_badbit;
6307                 break;
6308             }
6309         }
6310     }else {
6311         state = IOSTATE_badbit;
6312     }
6313     basic_ostream_wchar_sentry_destroy(this);
6314
6315     ios_base_width_set(&base->base, 0);
6316     basic_ios_wchar_setstate(base, state);
6317     return this;
6318 }
6319
6320 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
6321 {
6322     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6323     int state = IOSTATE_goodbit;
6324
6325     TRACE("(%p %p)\n", this, val);
6326
6327     if(basic_ostream_wchar_sentry_create(this)) {
6328         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6329         ostreambuf_iterator_wchar dest = {0, strbuf};
6330
6331         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6332     }
6333     basic_ostream_wchar_sentry_destroy(this);
6334
6335     basic_ios_wchar_setstate(base, state);
6336     return this;
6337 }
6338
6339 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
6340 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
6341 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
6342 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
6343 {
6344     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
6345                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6346 }
6347
6348 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
6349 {
6350     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6351     int state = IOSTATE_goodbit;
6352
6353     TRACE("(%p)\n", this);
6354
6355     if(basic_ostream_wchar_sentry_create(this)) {
6356         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6357         ostreambuf_iterator_wchar dest = {0, strbuf};
6358
6359         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6360     }
6361     basic_ostream_wchar_sentry_destroy(this);
6362
6363     basic_ios_wchar_setstate(base, state);
6364     return this;
6365 }
6366
6367 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
6368 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
6369 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
6370 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
6371 {
6372     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
6373                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6374 }
6375
6376 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
6377 {
6378     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6379     int state = IOSTATE_goodbit;
6380
6381     TRACE("(%p)\n", this);
6382
6383     if(basic_ostream_wchar_sentry_create(this)) {
6384         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6385         ostreambuf_iterator_wchar dest = {0, strbuf};
6386
6387         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6388     }
6389     basic_ostream_wchar_sentry_destroy(this);
6390
6391     basic_ios_wchar_setstate(base, state);
6392     return this;
6393 }
6394
6395 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
6396 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
6397 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
6398 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6399 {
6400     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
6401                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6402 }
6403
6404 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
6405 {
6406     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6407     int state = IOSTATE_goodbit;
6408
6409     TRACE("(%p %x)\n", this, val);
6410
6411     if(basic_ostream_wchar_sentry_create(this)) {
6412         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6413         ostreambuf_iterator_wchar dest = {0, strbuf};
6414
6415         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6416     }
6417     basic_ostream_wchar_sentry_destroy(this);
6418
6419     basic_ios_wchar_setstate(base, state);
6420     return this;
6421 }
6422
6423 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
6424 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
6425 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
6426 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6427 {
6428     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
6429                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6430 }
6431
6432 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6433 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6434 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6435 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6436 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
6437 {
6438     TRACE("(%p)\n", ostr);
6439
6440     basic_ostream_wchar_put(ostr, '\n');
6441     basic_ostream_wchar_flush(ostr);
6442     return ostr;
6443 }
6444
6445 /* ??$?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 */
6446 /* ??$?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 */
6447 /* ??$?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 */
6448 /* ??$?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 */
6449 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_bstr(basic_ostream_wchar *ostr, const basic_string_wchar *str)
6450 {
6451     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6452     IOSB_iostate state = IOSTATE_goodbit;
6453
6454     TRACE("(%p %p)\n", ostr, str);
6455
6456     if(basic_ostream_wchar_sentry_create(ostr)) {
6457         MSVCP_size_t len = basic_string_wchar_length(str);
6458         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6459
6460         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6461             for(; pad!=0; pad--) {
6462                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6463                     state = IOSTATE_badbit;
6464                     break;
6465                 }
6466             }
6467         }
6468
6469         if(state == IOSTATE_goodbit) {
6470             if(basic_streambuf_wchar_sputn(base->strbuf, basic_string_wchar_c_str(str), len) != len)
6471                 state = IOSTATE_badbit;
6472         }
6473
6474         if(state == IOSTATE_goodbit) {
6475             for(; pad!=0; pad--) {
6476                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6477                     state = IOSTATE_badbit;
6478                     break;
6479                 }
6480             }
6481         }
6482
6483         base->base.wide = 0;
6484     }else {
6485         state = IOSTATE_badbit;
6486     }
6487     basic_ostream_wchar_sentry_destroy(ostr);
6488
6489     basic_ios_wchar_setstate(base, state);
6490     return ostr;
6491 }
6492
6493 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@_W@Z */
6494 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@_W@Z */
6495 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@G@Z */
6496 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@G@Z */
6497 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_ch(basic_ostream_wchar *ostr, wchar_t ch)
6498 {
6499     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6500     IOSB_iostate state = IOSTATE_goodbit;
6501
6502     TRACE("(%p %d)\n", ostr, ch);
6503
6504     if(basic_ostream_wchar_sentry_create(ostr)) {
6505         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6506
6507         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6508             for(; pad!=0; pad--) {
6509                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6510                     state = IOSTATE_badbit;
6511                     break;
6512                 }
6513             }
6514         }
6515
6516         if(state == IOSTATE_goodbit) {
6517             if(basic_streambuf_wchar_sputc(base->strbuf, ch) == WEOF)
6518                 state = IOSTATE_badbit;
6519         }
6520
6521         if(state == IOSTATE_goodbit) {
6522             for(; pad!=0; pad--) {
6523                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6524                     state = IOSTATE_badbit;
6525                     break;
6526                 }
6527             }
6528         }
6529
6530         base->base.wide = 0;
6531     }else {
6532         state = IOSTATE_badbit;
6533     }
6534     basic_ostream_wchar_sentry_destroy(ostr);
6535
6536     basic_ios_wchar_setstate(base, state);
6537     return ostr;
6538 }
6539
6540 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@PB_W@Z */
6541 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@PEB_W@Z */
6542 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@PBG@Z */
6543 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@PEBG@Z */
6544 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_str(basic_ostream_wchar *ostr, const wchar_t *str)
6545 {
6546     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6547     IOSB_iostate state = IOSTATE_goodbit;
6548
6549     TRACE("(%p %s)\n", ostr, debugstr_w(str));
6550
6551     if(basic_ostream_wchar_sentry_create(ostr)) {
6552         MSVCP_size_t len = wcslen(str);
6553         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6554
6555         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6556             for(; pad!=0; pad--) {
6557                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6558                     state = IOSTATE_badbit;
6559                     break;
6560                 }
6561             }
6562         }
6563
6564         if(state == IOSTATE_goodbit) {
6565             if(basic_streambuf_wchar_sputn(base->strbuf, str, len) != len)
6566                                         state = IOSTATE_badbit;
6567         }
6568
6569         if(state == IOSTATE_goodbit) {
6570             for(; pad!=0; pad--) {
6571                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6572                     state = IOSTATE_badbit;
6573                     break;
6574                 }
6575             }
6576         }
6577
6578         base->base.wide = 0;
6579     }else {
6580         state = IOSTATE_badbit;
6581     }
6582     basic_ostream_wchar_sentry_destroy(ostr);
6583
6584     basic_ios_wchar_setstate(base, state);
6585     return ostr;
6586 }
6587
6588 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6589 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6590 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6591 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6592 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
6593 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
6594         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
6595 {
6596     TRACE("(%p %p)\n", this, pfunc);
6597     pfunc(this);
6598     return this;
6599 }
6600
6601 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
6602 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
6603 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
6604 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
6605 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
6606 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
6607         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
6608 {
6609     TRACE("(%p %p)\n", this, pfunc);
6610     pfunc(basic_ostream_wchar_get_basic_ios(this));
6611     return this;
6612 }
6613
6614 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6615 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6616 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6617 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6618 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
6619 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
6620         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
6621 {
6622     TRACE("(%p %p)\n", this, pfunc);
6623     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
6624     return this;
6625 }
6626
6627 /* Caution: basic_istream uses virtual inheritance. */
6628 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
6629 {
6630     return (basic_ios_char*)((char*)this+this->vbtable[1]);
6631 }
6632
6633 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
6634 {
6635     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
6636 }
6637
6638 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
6639 {
6640     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
6641 }
6642
6643 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6644 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6645 static basic_istream_char* basic_istream_char_ctor_init(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
6646 {
6647     basic_ios_char *base;
6648
6649     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
6650
6651     if(virt_init) {
6652         this->vbtable = basic_istream_char_vbtable;
6653         base = basic_istream_char_get_basic_ios(this);
6654         basic_ios_char_ctor(base);
6655     }else {
6656         base = basic_istream_char_get_basic_ios(this);
6657     }
6658
6659     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6660     this->count = 0;
6661     if(!noinit)
6662         basic_ios_char_init(base, strbuf, isstd);
6663     return this;
6664 }
6665
6666 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6667 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6668 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
6669 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6670 {
6671     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
6672 }
6673
6674 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
6675 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
6676 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
6677 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
6678 {
6679     basic_ios_char *base;
6680
6681     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
6682
6683     if(virt_init) {
6684         this->vbtable = basic_istream_char_vbtable;
6685         base = basic_istream_char_get_basic_ios(this);
6686         basic_ios_char_ctor(base);
6687     }else {
6688         base = basic_istream_char_get_basic_ios(this);
6689     }
6690
6691     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6692     ios_base_Addstd(&base->base);
6693     return this;
6694 }
6695
6696 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
6697 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
6698 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
6699 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
6700 {
6701     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6702
6703     /* don't destroy virtual base here */
6704     TRACE("(%p)\n", this);
6705 }
6706
6707 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6708 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6709 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
6710 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
6711 {
6712     TRACE("(%p)\n", this);
6713     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
6714     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
6715 }
6716
6717 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
6718 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
6719 {
6720     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6721
6722     TRACE("(%p %x)\n", this, flags);
6723
6724     if(flags & 2) {
6725         /* we have an array, with the number of elements stored before the first object */
6726         INT_PTR i, *ptr = (INT_PTR *)this-1;
6727
6728         for(i=*ptr-1; i>=0; i--)
6729             basic_istream_char_vbase_dtor(this+i);
6730         MSVCRT_operator_delete(ptr);
6731     } else {
6732         basic_istream_char_vbase_dtor(this);
6733         if(flags & 1)
6734             MSVCRT_operator_delete(this);
6735     }
6736
6737     return this;
6738 }
6739
6740 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6741 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6742 static MSVCP_bool basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
6743 {
6744     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6745
6746     TRACE("(%p %d)\n", this, noskip);
6747
6748     if(ios_base_good(&base->base)) {
6749         if(basic_ios_char_tie_get(base))
6750             basic_ostream_char_flush(basic_ios_char_tie_get(base));
6751
6752         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
6753             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6754             const ctype_char *ctype = ctype_char_use_facet(&base->strbuf->loc);
6755             int ch;
6756
6757             for(ch = basic_streambuf_char_sgetc(strbuf); ;
6758                     ch = basic_streambuf_char_snextc(strbuf)) {
6759                 if(ch==EOF || !ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
6760                     break;
6761             }
6762         }
6763     }
6764
6765     if(!ios_base_good(&base->base)) {
6766         basic_ios_char_setstate(base, IOSTATE_failbit);
6767         return FALSE;
6768     }
6769
6770     return TRUE;
6771 }
6772
6773 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6774 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6775 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
6776 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
6777 {
6778     return basic_istream_char__Ipfx(this, noskip);
6779 }
6780
6781 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6782 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6783 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
6784 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
6785 {
6786     TRACE("(%p)\n", this);
6787 }
6788
6789 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
6790 {
6791     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6792
6793     if(basic_ios_char_rdbuf_get(base))
6794         basic_streambuf_char__Lock(base->strbuf);
6795
6796     return basic_istream_char_ipfx(istr, noskip);
6797 }
6798
6799 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
6800 {
6801     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6802
6803     if(basic_ios_char_rdbuf_get(base))
6804         basic_streambuf_char__Unlock(base->strbuf);
6805 }
6806
6807 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
6808 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
6809 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
6810 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
6811 {
6812     TRACE("(%p)\n", this);
6813     return this->count;
6814 }
6815
6816 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
6817 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
6818 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
6819 int __thiscall basic_istream_char_get(basic_istream_char *this)
6820 {
6821     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6822     int ret;
6823
6824     TRACE("(%p)\n", this);
6825
6826     this->count = 0;
6827
6828     if(!basic_istream_char_sentry_create(this, TRUE)) {
6829         basic_istream_char_sentry_destroy(this);
6830         return EOF;
6831     }
6832
6833     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
6834     basic_istream_char_sentry_destroy(this);
6835     if(ret == EOF)
6836         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
6837     else
6838         this->count++;
6839
6840     return ret;
6841 }
6842
6843 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
6844 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
6845 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
6846 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
6847 {
6848     int ret;
6849
6850     TRACE("(%p %p)\n", this, ch);
6851
6852     ret = basic_istream_char_get(this);
6853     if(ret != EOF)
6854         *ch = (char)ret;
6855     return this;
6856 }
6857
6858 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
6859 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
6860 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
6861 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
6862 {
6863     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6864     int ch = delim;
6865
6866     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
6867
6868     this->count = 0;
6869
6870     if(basic_istream_char_sentry_create(this, TRUE)) {
6871         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6872
6873         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
6874                 ch = basic_streambuf_char_snextc(strbuf)) {
6875             if(ch==EOF || ch==delim)
6876                 break;
6877
6878             *str++ = ch;
6879             this->count++;
6880             count--;
6881         }
6882     }
6883     basic_istream_char_sentry_destroy(this);
6884
6885     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
6886             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
6887     if(count > 0)
6888         *str = 0;
6889     return this;
6890 }
6891
6892 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
6893 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
6894 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
6895 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
6896 {
6897     return basic_istream_char_get_str_delim(this, str, count, '\n');
6898 }
6899
6900 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
6901 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
6902 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
6903 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
6904 {
6905     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6906     int ch = delim;
6907
6908     TRACE("(%p %p %c)\n", this, strbuf, delim);
6909
6910     this->count = 0;
6911
6912     if(basic_istream_char_sentry_create(this, TRUE)) {
6913         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
6914
6915         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
6916                 ch = basic_streambuf_char_snextc(strbuf_read)) {
6917             if(ch==EOF || ch==delim)
6918                 break;
6919
6920             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
6921                 break;
6922             this->count++;
6923         }
6924     }
6925     basic_istream_char_sentry_destroy(this);
6926
6927     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
6928             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
6929     return this;
6930 }
6931
6932 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
6933 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
6934 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
6935 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
6936 {
6937     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
6938 }
6939
6940 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
6941 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
6942 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
6943 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
6944 {
6945     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6946     int ch = (unsigned char)delim;
6947
6948     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
6949
6950     this->count = 0;
6951
6952     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
6953         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6954
6955         while(count > 1) {
6956             ch = basic_streambuf_char_sbumpc(strbuf);
6957
6958             if(ch==EOF || ch==(unsigned char)delim)
6959                 break;
6960
6961             *str++ = ch;
6962             this->count++;
6963             count--;
6964         }
6965
6966         if(ch == (unsigned char)delim)
6967             this->count++;
6968         else if(ch != EOF) {
6969             ch = basic_streambuf_char_sgetc(strbuf);
6970
6971             if(ch == (unsigned char)delim) {
6972                 basic_streambuf_char__Gninc(strbuf);
6973                 this->count++;
6974             }
6975         }
6976     }
6977     basic_istream_char_sentry_destroy(this);
6978
6979     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
6980             (!this->count || (ch!=(unsigned char)delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
6981     if(count > 0)
6982         *str = 0;
6983     return this;
6984 }
6985
6986 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
6987 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
6988 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
6989 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
6990 {
6991     return basic_istream_char_getline_delim(this, str, count, '\n');
6992 }
6993
6994 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
6995 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
6996 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
6997 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
6998 {
6999     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7000     int ch = (unsigned char)delim;
7001     unsigned int state;
7002
7003     TRACE("(%p %ld %d)\n", this, count, delim);
7004
7005     this->count = 0;
7006
7007     if(basic_istream_char_sentry_create(this, TRUE)) {
7008         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7009         state = IOSTATE_goodbit;
7010
7011         while(count > 0) {
7012             ch = basic_streambuf_char_sbumpc(strbuf);
7013
7014             if(ch==EOF) {
7015                 state = IOSTATE_eofbit;
7016                 break;
7017             }
7018
7019             if(ch==(unsigned char)delim)
7020                 break;
7021
7022             this->count++;
7023             if(count != INT_MAX)
7024                 count--;
7025         }
7026     }else
7027         state = IOSTATE_failbit;
7028     basic_istream_char_sentry_destroy(this);
7029
7030     basic_ios_char_setstate(base, state);
7031     return this;
7032 }
7033
7034 /* ?ws@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@1@AAV21@@Z */
7035 /* ?ws@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
7036 basic_istream_char* __cdecl ws_basic_istream_char(basic_istream_char *istream)
7037 {
7038     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7039     int ch = '\n';
7040
7041     TRACE("(%p)\n", istream);
7042
7043     if(basic_istream_char_sentry_create(istream, TRUE)) {
7044         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7045         const ctype_char *ctype = ctype_char_use_facet(&strbuf->loc);
7046
7047         for(ch = basic_streambuf_char_sgetc(strbuf); ctype_char_is_ch(ctype, _SPACE, ch);
7048                 ch = basic_streambuf_char_snextc(strbuf)) {
7049             if(ch == EOF)
7050                 break;
7051         }
7052     }
7053     basic_istream_char_sentry_destroy(istream);
7054
7055     if(ch == EOF)
7056         basic_ios_char_setstate(base, IOSTATE_eofbit);
7057     return istream;
7058 }
7059
7060 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7061 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7062 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
7063 int __thiscall basic_istream_char_peek(basic_istream_char *this)
7064 {
7065     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7066     int ret = EOF;
7067
7068     TRACE("(%p)\n", this);
7069
7070     this->count = 0;
7071
7072     if(basic_istream_char_sentry_create(this, TRUE))
7073         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7074     basic_istream_char_sentry_destroy(this);
7075
7076     if (ret == EOF)
7077         basic_ios_char_setstate(base, IOSTATE_eofbit);
7078
7079     return ret;
7080 }
7081
7082 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
7083 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
7084 static basic_istream_char* basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7085 {
7086     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7087     IOSB_iostate state = IOSTATE_goodbit;
7088
7089     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7090
7091     if(basic_istream_char_sentry_create(this, TRUE)) {
7092         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7093
7094         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
7095         if(this->count != count)
7096             state |= IOSTATE_failbit | IOSTATE_eofbit;
7097     }else {
7098         this->count = 0;
7099     }
7100     basic_istream_char_sentry_destroy(this);
7101
7102     basic_ios_char_setstate(base, state);
7103     return this;
7104 }
7105
7106 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7107 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7108 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
7109 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
7110 {
7111     return basic_istream_char__Read_s(this, str, count, count);
7112 }
7113
7114 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
7115 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
7116 static streamsize basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7117 {
7118     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7119     IOSB_iostate state = IOSTATE_goodbit;
7120
7121     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7122
7123     this->count = 0;
7124
7125     if(basic_istream_char_sentry_create(this, TRUE)) {
7126         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
7127         if(avail > count)
7128             avail = count;
7129
7130         if(avail == -1)
7131             state |= IOSTATE_eofbit;
7132         else if(avail > 0)
7133             basic_istream_char__Read_s(this, str, size, avail);
7134     }else {
7135         state |= IOSTATE_failbit;
7136     }
7137     basic_istream_char_sentry_destroy(this);
7138
7139     basic_ios_char_setstate(base, state);
7140     return this->count;
7141 }
7142
7143 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
7144 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
7145 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
7146 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
7147 {
7148     return basic_istream_char__Readsome_s(this, str, count, count);
7149 }
7150
7151 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
7152 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
7153 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
7154 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
7155 {
7156     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7157     IOSB_iostate state = IOSTATE_goodbit;
7158
7159     TRACE("(%p %c)\n", this, ch);
7160
7161     this->count = 0;
7162
7163     if(basic_istream_char_sentry_create(this, TRUE)) {
7164         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7165
7166         if(!ios_base_good(&base->base))
7167             state |= IOSTATE_failbit;
7168         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
7169             state |= IOSTATE_badbit;
7170     }
7171     basic_istream_char_sentry_destroy(this);
7172
7173     basic_ios_char_setstate(base, state);
7174     return this;
7175 }
7176
7177 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
7178 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
7179 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
7180 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
7181 {
7182     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7183     IOSB_iostate state = IOSTATE_goodbit;
7184
7185     TRACE("(%p)\n", this);
7186
7187     this->count = 0;
7188
7189     if(basic_istream_char_sentry_create(this, TRUE)) {
7190         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7191
7192         if(!ios_base_good(&base->base))
7193             state |= IOSTATE_failbit;
7194         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
7195             state |= IOSTATE_badbit;
7196     }
7197     basic_istream_char_sentry_destroy(this);
7198
7199     basic_ios_char_setstate(base, state);
7200     return this;
7201 }
7202
7203 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7204 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7205 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
7206 int __thiscall basic_istream_char_sync(basic_istream_char *this)
7207 {
7208     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7209     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7210
7211     TRACE("(%p)\n", this);
7212
7213     if(!strbuf)
7214         return -1;
7215
7216     if(basic_istream_char_sentry_create(this, TRUE)) {
7217         if(basic_streambuf_char_pubsync(strbuf) != -1) {
7218             basic_istream_char_sentry_destroy(this);
7219             return 0;
7220         }
7221     }
7222     basic_istream_char_sentry_destroy(this);
7223
7224     basic_ios_char_setstate(base, IOSTATE_badbit);
7225     return -1;
7226 }
7227
7228 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7229 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7230 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
7231 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
7232 {
7233     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7234
7235     TRACE("(%p %p)\n", this, ret);
7236
7237     if(ios_base_fail(&base->base)) {
7238         ret->off = -1;
7239         ret->pos = 0;
7240         ret->state = 0;
7241         return ret;
7242     }
7243
7244     basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
7245             ret, 0, SEEKDIR_cur, OPENMODE_in);
7246
7247     if(ret->off==-1 && ret->pos==0 && ret->state==0)
7248         basic_ios_char_setstate(base, IOSTATE_failbit);
7249
7250     return ret;
7251 }
7252
7253 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z */
7254 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z */
7255 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
7256 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
7257 {
7258     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7259
7260     TRACE("(%p %ld %d)\n", this, off, dir);
7261
7262     if(!ios_base_fail(&base->base)) {
7263         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7264         fpos_int ret;
7265
7266         basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
7267     }
7268
7269     return this;
7270 }
7271
7272 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7273 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7274 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
7275 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
7276 {
7277     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7278
7279     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7280
7281     if(!ios_base_fail(&base->base)) {
7282         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7283         fpos_int ret;
7284
7285         basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7286     }
7287
7288     return this;
7289 }
7290
7291 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
7292 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
7293 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
7294 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
7295 {
7296     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7297     int state = IOSTATE_goodbit;
7298
7299     TRACE("(%p %p)\n", this, v);
7300
7301     if(basic_istream_char_sentry_create(this, FALSE)) {
7302         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7303         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7304         istreambuf_iterator_char first={0}, last={0};
7305         LONG tmp;
7306
7307         first.strbuf = strbuf;
7308         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7309
7310         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7311             *v = tmp;
7312         else
7313             state |= IOSTATE_failbit;
7314     }
7315     basic_istream_char_sentry_destroy(this);
7316
7317     basic_ios_char_setstate(base, state);
7318     return this;
7319 }
7320
7321 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
7322 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
7323 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
7324 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
7325 {
7326     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7327     int state = IOSTATE_goodbit;
7328
7329     TRACE("(%p %p)\n", this, v);
7330
7331     if(basic_istream_char_sentry_create(this, FALSE)) {
7332         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7333         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7334         istreambuf_iterator_char first={0}, last={0};
7335
7336         first.strbuf = strbuf;
7337         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
7338     }
7339     basic_istream_char_sentry_destroy(this);
7340
7341     basic_ios_char_setstate(base, state);
7342     return this;
7343 }
7344
7345 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
7346 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
7347 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
7348 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
7349 {
7350     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7351     int state = IOSTATE_goodbit;
7352
7353     TRACE("(%p %p)\n", this, v);
7354
7355     if(basic_istream_char_sentry_create(this, FALSE)) {
7356         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7357         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7358         istreambuf_iterator_char first={0}, last={0};
7359
7360         first.strbuf = strbuf;
7361         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7362     }
7363     basic_istream_char_sentry_destroy(this);
7364
7365     basic_ios_char_setstate(base, state);
7366     return this;
7367 }
7368
7369 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
7370 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
7371 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
7372 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *v)
7373 {
7374     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7375     int state = IOSTATE_goodbit;
7376
7377     TRACE("(%p %p)\n", this, v);
7378
7379     if(basic_istream_char_sentry_create(this, FALSE)) {
7380         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7381         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7382         istreambuf_iterator_char first={0}, last={0};
7383
7384         first.strbuf = strbuf;
7385         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
7386     }
7387     basic_istream_char_sentry_destroy(this);
7388
7389     basic_ios_char_setstate(base, state);
7390     return this;
7391 }
7392
7393 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
7394 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
7395 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
7396 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
7397 {
7398     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7399     int state = IOSTATE_goodbit;
7400
7401     TRACE("(%p %p)\n", this, v);
7402
7403     if(basic_istream_char_sentry_create(this, FALSE)) {
7404         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7405         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7406         istreambuf_iterator_char first={0}, last={0};
7407
7408         first.strbuf = strbuf;
7409         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7410     }
7411     basic_istream_char_sentry_destroy(this);
7412
7413     basic_ios_char_setstate(base, state);
7414     return this;
7415 }
7416
7417 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
7418 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
7419 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
7420 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
7421 {
7422     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7423     int state = IOSTATE_goodbit;
7424
7425     TRACE("(%p %p)\n", this, v);
7426
7427     if(basic_istream_char_sentry_create(this, FALSE)) {
7428         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7429         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7430         istreambuf_iterator_char first={0}, last={0};
7431
7432         first.strbuf = strbuf;
7433         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
7434     }
7435     basic_istream_char_sentry_destroy(this);
7436
7437     basic_ios_char_setstate(base, state);
7438     return this;
7439 }
7440
7441 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
7442 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
7443 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
7444 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
7445 {
7446     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7447     int state = IOSTATE_goodbit;
7448
7449     TRACE("(%p %p)\n", this, v);
7450
7451     if(basic_istream_char_sentry_create(this, FALSE)) {
7452         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7453         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7454         istreambuf_iterator_char first={0}, last={0};
7455
7456         first.strbuf = strbuf;
7457         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
7458     }
7459     basic_istream_char_sentry_destroy(this);
7460
7461     basic_ios_char_setstate(base, state);
7462     return this;
7463 }
7464
7465 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
7466 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
7467 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
7468 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
7469 {
7470     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7471     int state = IOSTATE_goodbit;
7472
7473     TRACE("(%p %p)\n", this, v);
7474
7475     if(basic_istream_char_sentry_create(this, FALSE)) {
7476         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7477         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7478         istreambuf_iterator_char first={0}, last={0};
7479
7480         first.strbuf = strbuf;
7481         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
7482     }
7483     basic_istream_char_sentry_destroy(this);
7484
7485     basic_ios_char_setstate(base, state);
7486     return this;
7487 }
7488
7489 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
7490 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
7491 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
7492 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
7493 {
7494     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7495     int state = IOSTATE_goodbit;
7496
7497     TRACE("(%p %p)\n", this, v);
7498
7499     if(basic_istream_char_sentry_create(this, FALSE)) {
7500         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7501         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7502         istreambuf_iterator_char first={0}, last={0};
7503
7504         first.strbuf = strbuf;
7505         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
7506     }
7507     basic_istream_char_sentry_destroy(this);
7508
7509     basic_ios_char_setstate(base, state);
7510     return this;
7511 }
7512
7513 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
7514 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
7515 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
7516 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
7517 {
7518     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7519     int state = IOSTATE_goodbit;
7520
7521     TRACE("(%p %p)\n", this, v);
7522
7523     if(basic_istream_char_sentry_create(this, FALSE)) {
7524         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7525         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7526         istreambuf_iterator_char first={0}, last={0};
7527
7528         first.strbuf = strbuf;
7529         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
7530     }
7531     basic_istream_char_sentry_destroy(this);
7532
7533     basic_ios_char_setstate(base, state);
7534     return this;
7535 }
7536
7537 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
7538 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
7539 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
7540 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
7541 {
7542     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7543     int state = IOSTATE_goodbit;
7544
7545     TRACE("(%p %p)\n", this, v);
7546
7547     if(basic_istream_char_sentry_create(this, FALSE)) {
7548         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7549         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7550         istreambuf_iterator_char first={0}, last={0};
7551
7552         first.strbuf = strbuf;
7553         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
7554     }
7555     basic_istream_char_sentry_destroy(this);
7556
7557     basic_ios_char_setstate(base, state);
7558     return this;
7559 }
7560
7561 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
7562 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
7563 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
7564 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
7565 {
7566     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7567     int state = IOSTATE_goodbit;
7568
7569     TRACE("(%p %p)\n", this, v);
7570
7571     if(basic_istream_char_sentry_create(this, FALSE)) {
7572         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7573         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7574         istreambuf_iterator_char first={0}, last={0};
7575
7576         first.strbuf = strbuf;
7577         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
7578     }
7579     basic_istream_char_sentry_destroy(this);
7580
7581     basic_ios_char_setstate(base, state);
7582     return this;
7583 }
7584
7585 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
7586 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
7587 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
7588 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
7589 {
7590     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7591     int state = IOSTATE_goodbit;
7592
7593     TRACE("(%p %p)\n", this, v);
7594
7595     if(basic_istream_char_sentry_create(this, FALSE)) {
7596         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7597         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7598         istreambuf_iterator_char first={0}, last={0};
7599
7600         first.strbuf = strbuf;
7601         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
7602     }
7603     basic_istream_char_sentry_destroy(this);
7604
7605     basic_ios_char_setstate(base, state);
7606     return this;
7607 }
7608
7609 /* ??$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 */
7610 /* ??$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 */
7611 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
7612         basic_istream_char *istream, basic_string_char *str, char delim)
7613 {
7614     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7615     IOSB_iostate state = IOSTATE_goodbit;
7616     int c = (unsigned char)delim;
7617
7618     TRACE("(%p %p %c)\n", istream, str, delim);
7619
7620     basic_string_char_clear(str);
7621     if(basic_istream_char_sentry_create(istream, TRUE)) {
7622         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7623
7624         c = basic_streambuf_char_sgetc(strbuf);
7625         for(; c!=(unsigned char)delim && c!=EOF; c = basic_streambuf_char_snextc(strbuf))
7626             basic_string_char_append_ch(str, c);
7627         if(c==EOF) state |= IOSTATE_eofbit;
7628         else if(c==(unsigned char)delim) basic_streambuf_char_sbumpc(strbuf);
7629
7630         if(!basic_string_char_length(str) && c!=(unsigned char)delim) state |= IOSTATE_failbit;
7631     }
7632     basic_istream_char_sentry_destroy(istream);
7633
7634     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream), state);
7635     return istream;
7636 }
7637
7638 /* ??$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 */
7639 /* ??$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 */
7640 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
7641         basic_istream_char *istream, basic_string_char *str)
7642 {
7643     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
7644 }
7645
7646 /* ??$?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 */
7647 /* ??$?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 */
7648 basic_istream_char* __cdecl basic_istream_char_read_bstr(
7649         basic_istream_char *istream, basic_string_char *str)
7650 {
7651     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7652     IOSB_iostate state = IOSTATE_failbit;
7653     int c = '\n';
7654
7655     TRACE("(%p %p)\n", istream, str);
7656
7657     if(basic_istream_char_sentry_create(istream, FALSE)) {
7658         const ctype_char *ctype = ctype_char_use_facet(&base->strbuf->loc);
7659         MSVCP_size_t count = ios_base_width_get(&base->base);
7660
7661         if(!count)
7662             count = -1;
7663
7664         basic_string_char_clear(str);
7665
7666         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7667                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7668                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7669             state = IOSTATE_goodbit;
7670             basic_string_char_append_ch(str, c);
7671         }
7672     }
7673     basic_istream_char_sentry_destroy(istream);
7674
7675     ios_base_width_set(&base->base, 0);
7676     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7677     return istream;
7678 }
7679
7680 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z */
7681 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z */
7682 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAC@Z */
7683 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAC@Z */
7684 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAE@Z */
7685 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAE@Z */
7686 basic_istream_char* __cdecl basic_istream_char_read_str(basic_istream_char *istream, char *str)
7687 {
7688     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7689     IOSB_iostate state = IOSTATE_failbit;
7690     int c = '\n';
7691
7692     TRACE("(%p %p)\n", istream, str);
7693
7694     if(basic_istream_char_sentry_create(istream, FALSE)) {
7695         const ctype_char *ctype = ctype_char_use_facet(&base->strbuf->loc);
7696         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
7697
7698         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7699                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7700                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7701             state = IOSTATE_goodbit;
7702             *str++ = c;
7703         }
7704     }
7705     basic_istream_char_sentry_destroy(istream);
7706
7707     *str = 0;
7708     ios_base_width_set(&base->base, 0);
7709     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7710     return istream;
7711 }
7712
7713 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z */
7714 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAD@Z */
7715 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z */
7716 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAC@Z */
7717 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z */
7718 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAE@Z */
7719 basic_istream_char* __cdecl basic_istream_char_read_ch(basic_istream_char *istream, char *ch)
7720 {
7721     IOSB_iostate state = IOSTATE_failbit;
7722     int c = 0;
7723
7724     TRACE("(%p %p)\n", istream, ch);
7725
7726     if(basic_istream_char_sentry_create(istream, FALSE)) {
7727         c = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(
7728                     basic_istream_char_get_basic_ios(istream)));
7729         if(c != EOF) {
7730             state = IOSTATE_goodbit;
7731             *ch = c;
7732         }
7733     }
7734     basic_istream_char_sentry_destroy(istream);
7735
7736     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
7737             state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7738     return istream;
7739 }
7740
7741 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7742 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7743 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
7744 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
7745         basic_istream_char *this, basic_streambuf_char *streambuf)
7746 {
7747     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7748     IOSB_iostate state = IOSTATE_failbit;
7749     int c = '\n';
7750
7751     TRACE("(%p %p)\n", this, streambuf);
7752
7753     if(basic_istream_char_sentry_create(this, FALSE)) {
7754         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
7755                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
7756             state = IOSTATE_goodbit;
7757             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
7758                 break;
7759         }
7760     }
7761     basic_istream_char_sentry_destroy(this);
7762
7763     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7764     return this;
7765 }
7766
7767 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7768 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7769 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
7770 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
7771         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
7772 {
7773     TRACE("(%p %p)\n", this, pfunc);
7774     pfunc(this);
7775     return this;
7776 }
7777
7778 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
7779 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
7780 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
7781 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
7782         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
7783 {
7784     TRACE("(%p %p)\n", this, pfunc);
7785     pfunc(basic_istream_char_get_basic_ios(this));
7786     return this;
7787 }
7788
7789 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7790 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7791 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
7792 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
7793         ios_base* (__cdecl *pfunc)(ios_base*))
7794 {
7795     TRACE("(%p %p)\n", this, pfunc);
7796     pfunc(&basic_istream_char_get_basic_ios(this)->base);
7797     return this;
7798 }
7799
7800 /* Caution: basic_istream uses virtual inheritance. */
7801 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
7802 {
7803     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
7804 }
7805
7806 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
7807 {
7808     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
7809 }
7810
7811 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
7812 {
7813     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
7814 }
7815
7816 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7817 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7818 static basic_istream_wchar* basic_istream_wchar_ctor_init(basic_istream_wchar *this,
7819         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7820 {
7821     basic_ios_wchar *base;
7822
7823     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
7824
7825     if(virt_init) {
7826         this->vbtable = basic_istream_wchar_vbtable;
7827         base = basic_istream_wchar_get_basic_ios(this);
7828         basic_ios_wchar_ctor(base);
7829     }else {
7830         base = basic_istream_wchar_get_basic_ios(this);
7831     }
7832
7833     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
7834     this->count = 0;
7835     if(!noinit)
7836         basic_ios_wchar_init(base, strbuf, isstd);
7837     return this;
7838 }
7839
7840 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7841 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7842 static basic_istream_wchar* basic_istream_short_ctor_init(basic_istream_wchar *this,
7843         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7844 {
7845     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
7846     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
7847     return this;
7848 }
7849
7850 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
7851 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
7852 static basic_istream_wchar* basic_istream_wchar_ctor(basic_istream_wchar *this,
7853         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7854 {
7855     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7856 }
7857
7858 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
7859 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
7860 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor, 16)
7861 basic_istream_wchar* __thiscall basic_istream_short_ctor(basic_istream_wchar *this,
7862         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7863 {
7864     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7865 }
7866
7867 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7868 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7869 static basic_istream_wchar* basic_istream_wchar_ctor_uninitialized(
7870         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
7871 {
7872     basic_ios_wchar *base;
7873
7874     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
7875
7876     if(virt_init) {
7877         this->vbtable = basic_istream_wchar_vbtable;
7878         base = basic_istream_wchar_get_basic_ios(this);
7879         basic_ios_wchar_ctor(base);
7880     }else {
7881         base = basic_istream_wchar_get_basic_ios(this);
7882     }
7883
7884     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
7885     ios_base_Addstd(&base->base);
7886     return this;
7887 }
7888
7889 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7890 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7891 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
7892 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
7893         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
7894 {
7895     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
7896     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
7897     return this;
7898 }
7899
7900 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
7901 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
7902 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
7903 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
7904 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
7905 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
7906 {
7907     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
7908
7909     /* don't destroy virtual base here */
7910     TRACE("(%p)\n", this);
7911 }
7912
7913 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
7914 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
7915 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
7916 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
7917 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
7918 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
7919 {
7920     TRACE("(%p)\n", this);
7921     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
7922     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
7923 }
7924
7925 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
7926 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
7927 {
7928     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
7929
7930     TRACE("(%p %x)\n", this, flags);
7931
7932     if(flags & 2) {
7933         /* we have an array, with the number of elements stored before the first object */
7934         INT_PTR i, *ptr = (INT_PTR *)this-1;
7935
7936         for(i=*ptr-1; i>=0; i--)
7937             basic_istream_wchar_vbase_dtor(this+i);
7938         MSVCRT_operator_delete(ptr);
7939     } else {
7940         basic_istream_wchar_vbase_dtor(this);
7941         if(flags & 1)
7942             MSVCRT_operator_delete(this);
7943     }
7944
7945     return this;
7946 }
7947
7948 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
7949 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
7950 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
7951 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
7952 static MSVCP_bool basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
7953 {
7954     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7955
7956     TRACE("(%p %d)\n", this, noskip);
7957
7958     if(ios_base_good(&base->base)) {
7959         if(basic_ios_wchar_tie_get(base))
7960             basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
7961
7962         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
7963             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7964             const ctype_wchar *ctype = ctype_wchar_use_facet(&base->strbuf->loc);
7965             int ch;
7966
7967             for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
7968                     ch = basic_streambuf_wchar_snextc(strbuf)) {
7969                 if(ch==WEOF || !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
7970                     break;
7971             }
7972         }
7973     }
7974
7975     if(!ios_base_good(&base->base)) {
7976         basic_ios_wchar_setstate(base, IOSTATE_failbit);
7977         return FALSE;
7978     }
7979     return TRUE;
7980 }
7981
7982 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
7983 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
7984 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
7985 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
7986 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
7987 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
7988 {
7989     return basic_istream_wchar__Ipfx(this, noskip);
7990 }
7991
7992 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
7993 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
7994 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
7995 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
7996 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
7997 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
7998 {
7999     TRACE("(%p)\n", this);
8000 }
8001
8002 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
8003 {
8004     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8005
8006     if(basic_ios_wchar_rdbuf_get(base))
8007         basic_streambuf_wchar__Lock(base->strbuf);
8008
8009     return basic_istream_wchar_ipfx(istr, noskip);
8010 }
8011
8012 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
8013 {
8014     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8015
8016     if(basic_ios_wchar_rdbuf_get(base))
8017         basic_streambuf_wchar__Unlock(base->strbuf);
8018 }
8019
8020 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
8021 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
8022 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
8023 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
8024 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
8025 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
8026 {
8027     TRACE("(%p)\n", this);
8028     return this->count;
8029 }
8030
8031 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8032 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8033 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8034 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8035 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
8036 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
8037 {
8038     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8039     int ret;
8040
8041     TRACE("(%p)\n", this);
8042
8043     this->count = 0;
8044
8045     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
8046         basic_istream_wchar_sentry_destroy(this);
8047         return WEOF;
8048     }
8049
8050     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
8051     basic_istream_wchar_sentry_destroy(this);
8052     if(ret == WEOF)
8053         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
8054     else
8055         this->count++;
8056
8057     return ret;
8058 }
8059
8060 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
8061 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
8062 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
8063 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
8064 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
8065 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
8066 {
8067     unsigned short ret;
8068
8069     TRACE("(%p %p)\n", this, ch);
8070
8071     ret = basic_istream_wchar_get(this);
8072     if(ret != WEOF)
8073         *ch = (wchar_t)ret;
8074     return this;
8075 }
8076
8077 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8078 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8079 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8080 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8081 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 16)
8082 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8083 {
8084     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8085     unsigned short ch = delim;
8086
8087     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8088
8089     this->count = 0;
8090
8091     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8092         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8093
8094         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
8095                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8096             if(ch==WEOF || ch==delim)
8097                 break;
8098
8099             *str++ = ch;
8100             this->count++;
8101             count--;
8102         }
8103     }
8104     basic_istream_wchar_sentry_destroy(this);
8105
8106     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8107             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8108     if(count > 0)
8109         *str = 0;
8110     return this;
8111 }
8112
8113 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8114 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8115 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8116 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8117 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 12)
8118 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
8119 {
8120     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
8121 }
8122
8123 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8124 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8125 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8126 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8127 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
8128 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
8129 {
8130     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8131     unsigned short ch = delim;
8132
8133     TRACE("(%p %p %c)\n", this, strbuf, delim);
8134
8135     this->count = 0;
8136
8137     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8138         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
8139
8140         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
8141                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
8142             if(ch==WEOF || ch==delim)
8143                 break;
8144
8145             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
8146                 break;
8147             this->count++;
8148         }
8149     }
8150     basic_istream_wchar_sentry_destroy(this);
8151
8152     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8153             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8154     return this;
8155 }
8156
8157 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8158 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8159 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8160 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8161 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
8162 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
8163 {
8164     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
8165 }
8166
8167 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8168 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8169 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8170 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8171 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 16)
8172 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8173 {
8174     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8175     unsigned short ch = delim;
8176
8177     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8178
8179     this->count = 0;
8180
8181     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
8182         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8183
8184         while(count > 1) {
8185             ch = basic_streambuf_wchar_sbumpc(strbuf);
8186
8187             if(ch==WEOF || ch==delim)
8188                 break;
8189
8190             *str++ = ch;
8191             this->count++;
8192             count--;
8193         }
8194
8195         if(ch == delim)
8196             this->count++;
8197         else if(ch != WEOF) {
8198             ch = basic_streambuf_wchar_sgetc(strbuf);
8199
8200             if(ch == delim) {
8201                 basic_streambuf_wchar__Gninc(strbuf);
8202                 this->count++;
8203             }
8204         }
8205     }
8206     basic_istream_wchar_sentry_destroy(this);
8207
8208     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
8209             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
8210     if(count > 0)
8211         *str = 0;
8212     return this;
8213 }
8214
8215 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8216 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8217 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8218 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8219 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 12)
8220 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
8221 {
8222     return basic_istream_wchar_getline_delim(this, str, count, '\n');
8223 }
8224
8225 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
8226 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
8227 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
8228 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
8229 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 12)
8230 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
8231 {
8232     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8233     unsigned short ch = delim;
8234     unsigned int state;
8235
8236     TRACE("(%p %ld %d)\n", this, count, delim);
8237
8238     this->count = 0;
8239
8240     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8241         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8242         state = IOSTATE_goodbit;
8243
8244         while(count > 0) {
8245             ch = basic_streambuf_wchar_sbumpc(strbuf);
8246
8247             if(ch==WEOF) {
8248                 state = IOSTATE_eofbit;
8249                 break;
8250             }
8251
8252             if(ch==delim)
8253                 break;
8254
8255             this->count++;
8256             if(count != INT_MAX)
8257                 count--;
8258         }
8259     }else
8260         state = IOSTATE_failbit;
8261     basic_istream_wchar_sentry_destroy(this);
8262
8263     basic_ios_wchar_setstate(base, state);
8264     return this;
8265 }
8266
8267 /* ?ws@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
8268 /* ?ws@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
8269 /* ?ws@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@1@AAV21@@Z */
8270 /* ?ws@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
8271 basic_istream_wchar* __cdecl ws_basic_istream_wchar(basic_istream_wchar *istream)
8272 {
8273     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8274     unsigned short ch = '\n';
8275
8276     TRACE("(%p)\n", istream);
8277
8278     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8279         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8280         const ctype_wchar *ctype = ctype_wchar_use_facet(&strbuf->loc);
8281
8282         for(ch = basic_streambuf_wchar_sgetc(strbuf); ctype_wchar_is_ch(ctype, _SPACE, ch);
8283                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8284             if(ch == WEOF)
8285                 break;
8286         }
8287     }
8288     basic_istream_wchar_sentry_destroy(istream);
8289
8290     if(ch == WEOF)
8291         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8292     return istream;
8293 }
8294
8295 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8296 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8297 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8298 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8299 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
8300 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
8301 {
8302     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8303     unsigned short ret = WEOF;
8304
8305     TRACE("(%p)\n", this);
8306
8307     this->count = 0;
8308
8309     if(basic_istream_wchar_sentry_create(this, TRUE))
8310         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8311     basic_istream_wchar_sentry_destroy(this);
8312
8313     if (ret == WEOF)
8314         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8315
8316     return ret;
8317 }
8318
8319 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
8320 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
8321 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
8322 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
8323 static basic_istream_wchar* basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8324 {
8325     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8326     IOSB_iostate state = IOSTATE_goodbit;
8327
8328     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8329
8330     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8331         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8332
8333         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
8334         if(this->count != count)
8335             state |= IOSTATE_failbit | IOSTATE_eofbit;
8336     }else {
8337         this->count = 0;
8338     }
8339     basic_istream_wchar_sentry_destroy(this);
8340
8341     basic_ios_wchar_setstate(base, state);
8342     return this;
8343 }
8344
8345 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8346 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8347 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8348 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8349 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 12)
8350 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
8351 {
8352     return basic_istream_wchar__Read_s(this, str, count, count);
8353 }
8354
8355 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
8356 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
8357 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
8358 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
8359 static streamsize basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8360 {
8361     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8362     IOSB_iostate state = IOSTATE_goodbit;
8363
8364     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8365
8366     this->count = 0;
8367
8368     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8369         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
8370         if(avail > count)
8371             avail = count;
8372
8373         if(avail == -1)
8374             state |= IOSTATE_eofbit;
8375         else if(avail > 0)
8376             basic_istream_wchar__Read_s(this, str, size, avail);
8377     }else {
8378         state |= IOSTATE_failbit;
8379     }
8380     basic_istream_wchar_sentry_destroy(this);
8381
8382     basic_ios_wchar_setstate(base, state);
8383     return this->count;
8384 }
8385
8386 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
8387 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
8388 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
8389 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
8390 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 12)
8391 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
8392 {
8393     return basic_istream_wchar__Readsome_s(this, str, count, count);
8394 }
8395
8396 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
8397 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
8398 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
8399 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
8400 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
8401 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
8402 {
8403     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8404     IOSB_iostate state = IOSTATE_goodbit;
8405
8406     TRACE("(%p %c)\n", this, ch);
8407
8408     this->count = 0;
8409
8410     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8411         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8412
8413         if(!ios_base_good(&base->base))
8414             state |= IOSTATE_failbit;
8415         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
8416             state |= IOSTATE_badbit;
8417     }
8418     basic_istream_wchar_sentry_destroy(this);
8419
8420     basic_ios_wchar_setstate(base, state);
8421     return this;
8422 }
8423
8424 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
8425 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
8426 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
8427 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
8428 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
8429 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
8430 {
8431     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8432     IOSB_iostate state = IOSTATE_goodbit;
8433
8434     TRACE("(%p)\n", this);
8435
8436     this->count = 0;
8437
8438     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8439         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8440
8441         if(!ios_base_good(&base->base))
8442             state |= IOSTATE_failbit;
8443         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
8444             state |= IOSTATE_badbit;
8445     }
8446     basic_istream_wchar_sentry_destroy(this);
8447
8448     basic_ios_wchar_setstate(base, state);
8449     return this;
8450 }
8451
8452 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
8453 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
8454 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
8455 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
8456 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
8457 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
8458 {
8459     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8460     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8461
8462     TRACE("(%p)\n", this);
8463
8464     if(!strbuf)
8465         return -1;
8466
8467     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8468         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
8469             basic_istream_wchar_sentry_destroy(this);
8470             return 0;
8471         }
8472     }
8473     basic_istream_wchar_sentry_destroy(this);
8474
8475     basic_ios_wchar_setstate(base, IOSTATE_badbit);
8476     return -1;
8477 }
8478
8479 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8480 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8481 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8482 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8483 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
8484 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
8485 {
8486     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8487
8488     TRACE("(%p %p)\n", this, ret);
8489
8490     if(ios_base_fail(&base->base)) {
8491         ret->off = -1;
8492         ret->pos = 0;
8493         ret->state = 0;
8494         return ret;
8495     }
8496
8497     basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
8498             ret, 0, SEEKDIR_cur, OPENMODE_in);
8499     if(ret->off==-1 && ret->pos==0 && ret->state==0)
8500         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8501
8502     return ret;
8503 }
8504
8505 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z */
8506 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z */
8507 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 12)
8508 basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir)
8509 {
8510     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8511
8512     TRACE("(%p %ld %d)\n", this, off, dir);
8513
8514     if(!ios_base_fail(&base->base)) {
8515         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8516         fpos_int ret;
8517
8518         basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
8519     }
8520
8521     return this;
8522 }
8523
8524 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8525 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8526 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8527 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8528 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
8529 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
8530 {
8531     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8532
8533     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
8534
8535     if(!ios_base_fail(&base->base)) {
8536         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8537         fpos_int ret;
8538
8539         basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
8540     }
8541
8542     return this;
8543 }
8544
8545 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
8546 {
8547     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8548     int state = IOSTATE_goodbit;
8549
8550     TRACE("(%p %p)\n", this, v);
8551
8552     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8553         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8554         istreambuf_iterator_wchar first={0}, last={0};
8555         LONG tmp;
8556
8557         first.strbuf = strbuf;
8558         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
8559
8560         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
8561             *v = tmp;
8562         else
8563             state |= IOSTATE_failbit;
8564     }
8565     basic_istream_wchar_sentry_destroy(this);
8566
8567     basic_ios_wchar_setstate(base, state);
8568     return this;
8569 }
8570
8571 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
8572 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
8573 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
8574 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
8575 {
8576     return basic_istream_read_short(this, v, num_get_short_use_facet(
8577                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8578 }
8579
8580 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
8581 {
8582     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8583     int state = IOSTATE_goodbit;
8584
8585     TRACE("(%p %p)\n", this, v);
8586
8587     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8588         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8589         istreambuf_iterator_wchar first={0}, last={0};
8590
8591         first.strbuf = strbuf;
8592         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8593     }
8594     basic_istream_wchar_sentry_destroy(this);
8595
8596     basic_ios_wchar_setstate(base, state);
8597     return this;
8598 }
8599
8600 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
8601 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
8602 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
8603 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
8604 {
8605     return basic_istream_read_int(this, v, num_get_short_use_facet(
8606                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8607 }
8608
8609 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
8610 {
8611     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8612     int state = IOSTATE_goodbit;
8613
8614     TRACE("(%p %p)\n", this, v);
8615
8616     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8617         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8618         istreambuf_iterator_wchar first={0}, last={0};
8619
8620         first.strbuf = strbuf;
8621         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
8622     }
8623     basic_istream_wchar_sentry_destroy(this);
8624
8625     basic_ios_wchar_setstate(base, state);
8626     return this;
8627 }
8628
8629 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
8630 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
8631 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
8632 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
8633 {
8634     return basic_istream_read_uint(this, v, num_get_short_use_facet(
8635                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8636 }
8637
8638 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
8639 {
8640     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8641     int state = IOSTATE_goodbit;
8642
8643     TRACE("(%p %p)\n", this, v);
8644
8645     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8646         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8647         istreambuf_iterator_wchar first={0}, last={0};
8648
8649         first.strbuf = strbuf;
8650         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8651     }
8652     basic_istream_wchar_sentry_destroy(this);
8653
8654     basic_ios_wchar_setstate(base, state);
8655     return this;
8656 }
8657
8658 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
8659 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
8660 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
8661 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
8662 {
8663     return basic_istream_read_long(this, v, num_get_short_use_facet(
8664                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8665 }
8666
8667 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
8668 {
8669     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8670     int state = IOSTATE_goodbit;
8671
8672     TRACE("(%p %p)\n", this, v);
8673
8674     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8675         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8676         istreambuf_iterator_wchar first={0}, last={0};
8677
8678         first.strbuf = strbuf;
8679         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
8680     }
8681     basic_istream_wchar_sentry_destroy(this);
8682
8683     basic_ios_wchar_setstate(base, state);
8684     return this;
8685 }
8686
8687 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
8688 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
8689 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
8690 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
8691 {
8692     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
8693                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8694 }
8695
8696 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
8697 {
8698     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8699     int state = IOSTATE_goodbit;
8700
8701     TRACE("(%p %p)\n", this, v);
8702
8703     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8704         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8705         istreambuf_iterator_wchar first={0}, last={0};
8706
8707         first.strbuf = strbuf;
8708         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
8709     }
8710     basic_istream_wchar_sentry_destroy(this);
8711
8712     basic_ios_wchar_setstate(base, state);
8713     return this;
8714 }
8715
8716 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
8717 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
8718 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
8719 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
8720 {
8721     return basic_istream_read_float(this, v, num_get_short_use_facet(
8722                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8723 }
8724
8725 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
8726 {
8727     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8728     int state = IOSTATE_goodbit;
8729
8730     TRACE("(%p %p)\n", this, v);
8731
8732     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8733         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8734         istreambuf_iterator_wchar first={0}, last={0};
8735
8736         first.strbuf = strbuf;
8737         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
8738     }
8739     basic_istream_wchar_sentry_destroy(this);
8740
8741     basic_ios_wchar_setstate(base, state);
8742     return this;
8743 }
8744
8745 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
8746 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
8747 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
8748 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
8749 {
8750     return basic_istream_read_double(this, v, num_get_short_use_facet(
8751                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8752 }
8753
8754 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
8755 {
8756     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8757     int state = IOSTATE_goodbit;
8758
8759     TRACE("(%p %p)\n", this, v);
8760
8761     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8762         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8763         istreambuf_iterator_wchar first={0}, last={0};
8764
8765         first.strbuf = strbuf;
8766         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
8767     }
8768     basic_istream_wchar_sentry_destroy(this);
8769
8770     basic_ios_wchar_setstate(base, state);
8771     return this;
8772 }
8773
8774 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
8775 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
8776 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
8777 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
8778 {
8779     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
8780                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8781 }
8782
8783 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
8784 {
8785     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8786     int state = IOSTATE_goodbit;
8787
8788     TRACE("(%p %p)\n", this, v);
8789
8790     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8791         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8792         istreambuf_iterator_wchar first={0}, last={0};
8793
8794         first.strbuf = strbuf;
8795         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
8796     }
8797     basic_istream_wchar_sentry_destroy(this);
8798
8799     basic_ios_wchar_setstate(base, state);
8800     return this;
8801 }
8802
8803 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
8804 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
8805 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
8806 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
8807 {
8808     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
8809                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8810 }
8811
8812 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
8813 {
8814     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8815     int state = IOSTATE_goodbit;
8816
8817     TRACE("(%p %p)\n", this, v);
8818
8819     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8820         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8821         istreambuf_iterator_wchar first={0}, last={0};
8822
8823         first.strbuf = strbuf;
8824         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
8825     }
8826     basic_istream_wchar_sentry_destroy(this);
8827
8828     basic_ios_wchar_setstate(base, state);
8829     return this;
8830 }
8831
8832 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
8833 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
8834 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
8835 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
8836 {
8837     return basic_istream_read_int64(this, v, num_get_short_use_facet(
8838                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8839 }
8840
8841 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
8842 {
8843     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8844     int state = IOSTATE_goodbit;
8845
8846     TRACE("(%p %p)\n", this, v);
8847
8848     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8849         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8850         istreambuf_iterator_wchar first={0}, last={0};
8851
8852         first.strbuf = strbuf;
8853         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
8854     }
8855     basic_istream_wchar_sentry_destroy(this);
8856
8857     basic_ios_wchar_setstate(base, state);
8858     return this;
8859 }
8860
8861 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
8862 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
8863 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
8864 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
8865 {
8866     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
8867                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8868 }
8869
8870 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
8871 {
8872     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8873     int state = IOSTATE_goodbit;
8874
8875     TRACE("(%p %p)\n", this, v);
8876
8877     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8878         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8879         istreambuf_iterator_wchar first={0}, last={0};
8880
8881         first.strbuf = strbuf;
8882         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
8883     }
8884     basic_istream_wchar_sentry_destroy(this);
8885
8886     basic_ios_wchar_setstate(base, state);
8887     return this;
8888 }
8889
8890 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
8891 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
8892 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
8893 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
8894 {
8895     return basic_istream_read_bool(this, v, num_get_short_use_facet(
8896                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8897 }
8898
8899 /* ??$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 */
8900 /* ??$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 */
8901 /* ??$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 */
8902 /* ??$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 */
8903 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr_delim(
8904         basic_istream_wchar *istream, basic_string_wchar *str, wchar_t delim)
8905 {
8906     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8907     IOSB_iostate state = IOSTATE_goodbit;
8908     int c = delim;
8909
8910     TRACE("(%p %p %c)\n", istream, str, delim);
8911
8912     basic_string_wchar_clear(str);
8913     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8914         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8915
8916         c = basic_streambuf_wchar_sgetc(strbuf);
8917         for(; c!=delim && c!=WEOF; c = basic_streambuf_wchar_snextc(strbuf))
8918             basic_string_wchar_append_ch(str, c);
8919         if(c==delim) basic_streambuf_wchar_sbumpc(strbuf);
8920         else if(c==WEOF) state |= IOSTATE_eofbit;
8921
8922         if(!basic_string_wchar_length(str) && c!=delim) state |= IOSTATE_failbit;
8923     }
8924     basic_istream_wchar_sentry_destroy(istream);
8925
8926     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream), state);
8927     return istream;
8928 }
8929
8930 /* ??$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 */
8931 /* ??$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 */
8932 /* ??$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 */
8933 /* ??$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 */
8934 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr(
8935         basic_istream_wchar *istream, basic_string_wchar *str)
8936 {
8937     return basic_istream_wchar_getline_bstr_delim(istream, str, '\n');
8938 }
8939
8940 static basic_istream_wchar* basic_istream_read_bstr(basic_istream_wchar *istream,
8941         basic_string_wchar *str, const ctype_wchar *ctype)
8942 {
8943     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8944     IOSB_iostate state = IOSTATE_failbit;
8945     int c = '\n';
8946
8947     TRACE("(%p %p)\n", istream, str);
8948
8949     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
8950         MSVCP_size_t count = ios_base_width_get(&base->base);
8951
8952         if(!count)
8953             count = -1;
8954
8955         basic_string_wchar_clear(str);
8956
8957         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8958                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8959                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
8960             state = IOSTATE_goodbit;
8961             basic_string_wchar_append_ch(str, c);
8962         }
8963     }
8964     basic_istream_wchar_sentry_destroy(istream);
8965
8966     ios_base_width_set(&base->base, 0);
8967     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8968     return istream;
8969 }
8970
8971 /* ??$?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 */
8972 /* ??$?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 */
8973 basic_istream_wchar* __cdecl basic_istream_wchar_read_bstr(
8974         basic_istream_wchar *istream, basic_string_wchar *str)
8975 {
8976     return basic_istream_read_bstr(istream, str, ctype_wchar_use_facet(
8977                 &basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
8978 }
8979
8980 /* ??$?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 */
8981 /* ??$?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 */
8982 basic_istream_wchar* __cdecl basic_istream_short_read_bstr(
8983         basic_istream_wchar *istream, basic_string_wchar *str)
8984 {
8985     return basic_istream_read_bstr(istream, str, ctype_short_use_facet(
8986                 &basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
8987 }
8988
8989 static basic_istream_wchar* basic_istream_read_str(basic_istream_wchar *istream, wchar_t *str, const ctype_wchar *ctype)
8990 {
8991     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8992     IOSB_iostate state = IOSTATE_failbit;
8993     unsigned short c = '\n';
8994
8995     TRACE("(%p %p)\n", istream, str);
8996
8997     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
8998         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
8999
9000         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9001                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9002                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9003             state = IOSTATE_goodbit;
9004             *str++ = c;
9005         }
9006     }
9007     basic_istream_wchar_sentry_destroy(istream);
9008
9009     *str = 0;
9010     ios_base_width_set(&base->base, 0);
9011     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9012     return istream;
9013 }
9014
9015 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@PAG@Z */
9016 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@PEAG@Z */
9017 basic_istream_wchar* __cdecl basic_istream_short_read_str(basic_istream_wchar *istream, wchar_t *str)
9018 {
9019     return basic_istream_read_str(istream, str, ctype_short_use_facet(
9020                 &basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9021 }
9022
9023 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AA_W@Z */
9024 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEA_W@Z */
9025 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAG@Z */
9026 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAG@Z */
9027 basic_istream_wchar* __cdecl basic_istream_wchar_read_ch(basic_istream_wchar *istream, wchar_t *ch)
9028 {
9029     IOSB_iostate state = IOSTATE_failbit;
9030     unsigned short c = 0;
9031
9032     TRACE("(%p %p)\n", istream, ch);
9033
9034     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9035         c = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(
9036                     basic_istream_wchar_get_basic_ios(istream)));
9037         if(c != WEOF) {
9038             state = IOSTATE_goodbit;
9039             *ch = c;
9040         }
9041     }
9042     basic_istream_wchar_sentry_destroy(istream);
9043
9044     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9045             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9046     return istream;
9047 }
9048
9049 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9050 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9051 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9052 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9053 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
9054 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
9055         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
9056 {
9057     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9058     IOSB_iostate state = IOSTATE_failbit;
9059     unsigned short c = '\n';
9060
9061     TRACE("(%p %p)\n", this, streambuf);
9062
9063     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9064         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
9065                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
9066             state = IOSTATE_goodbit;
9067             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
9068                 break;
9069         }
9070     }
9071     basic_istream_wchar_sentry_destroy(this);
9072
9073     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9074     return this;
9075 }
9076
9077 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9078 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9079 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9080 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9081 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
9082 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
9083         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
9084 {
9085     TRACE("(%p %p)\n", this, pfunc);
9086     pfunc(this);
9087     return this;
9088 }
9089
9090 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
9091 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
9092 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
9093 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
9094 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
9095 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
9096         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
9097 {
9098     TRACE("(%p %p)\n", this, pfunc);
9099     pfunc(basic_istream_wchar_get_basic_ios(this));
9100     return this;
9101 }
9102
9103 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9104 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9105 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9106 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9107 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
9108 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
9109         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
9110 {
9111     TRACE("(%p %p)\n", this, pfunc);
9112     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
9113     return this;
9114 }
9115
9116 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
9117 {
9118     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
9119 }
9120
9121 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
9122 {
9123     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
9124 }
9125
9126 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9127 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9128 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
9129 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
9130 {
9131     basic_ios_char *basic_ios;
9132
9133     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9134
9135     if(virt_init) {
9136         this->base1.vbtable = basic_iostream_char_vbtable1;
9137         this->base2.vbtable = basic_iostream_char_vbtable2;
9138         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9139         basic_ios_char_ctor(basic_ios);
9140     }else {
9141         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9142     }
9143
9144     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
9145
9146     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
9147     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9148     return this;
9149 }
9150
9151 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9152 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9153 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
9154 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
9155 {
9156     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9157
9158     TRACE("(%p)\n", this);
9159     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
9160     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
9161 }
9162
9163 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9164 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9165 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
9166 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
9167 {
9168     TRACE("(%p)\n", this);
9169     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
9170     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
9171 }
9172
9173 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
9174 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9175 {
9176     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9177
9178     TRACE("(%p %x)\n", this, flags);
9179
9180     if(flags & 2) {
9181         /* we have an array, with the number of elements stored before the first object */
9182         INT_PTR i, *ptr = (INT_PTR *)this-1;
9183
9184         for(i=*ptr-1; i>=0; i--)
9185             basic_iostream_char_vbase_dtor(this+i);
9186         MSVCRT_operator_delete(ptr);
9187     } else {
9188         basic_iostream_char_vbase_dtor(this);
9189         if(flags & 1)
9190             MSVCRT_operator_delete(this);
9191     }
9192
9193     return this;
9194 }
9195
9196 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
9197 {
9198     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
9199 }
9200
9201 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9202 {
9203     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
9204 }
9205
9206 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9207 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9208 static basic_iostream_wchar* basic_iostream_wchar_ctor(basic_iostream_wchar *this,
9209         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9210 {
9211     basic_ios_wchar *basic_ios;
9212
9213     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9214
9215     if(virt_init) {
9216         this->base1.vbtable = basic_iostream_wchar_vbtable1;
9217         this->base2.vbtable = basic_iostream_wchar_vbtable2;
9218         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9219         basic_ios_wchar_ctor(basic_ios);
9220     }else {
9221         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9222     }
9223
9224     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
9225     basic_ostream_wchar_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9226
9227     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
9228     return this;
9229 }
9230
9231 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9232 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9233 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
9234 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
9235         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9236 {
9237     basic_iostream_wchar_ctor(this, strbuf, virt_init);
9238     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
9239     return this;
9240 }
9241
9242 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9243 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9244 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9245 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9246 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
9247 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
9248 {
9249     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9250
9251     TRACE("(%p)\n", this);
9252     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
9253     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
9254 }
9255
9256 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9257 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9258 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9259 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9260 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
9261 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
9262 {
9263     TRACE("(%p)\n", this);
9264     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
9265     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
9266 }
9267
9268 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
9269 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9270 {
9271     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9272
9273     TRACE("(%p %x)\n", this, flags);
9274
9275     if(flags & 2) {
9276         /* we have an array, with the number of elements stored before the first object */
9277         INT_PTR i, *ptr = (INT_PTR *)this-1;
9278
9279         for(i=*ptr-1; i>=0; i--)
9280             basic_iostream_wchar_vbase_dtor(this+i);
9281         MSVCRT_operator_delete(ptr);
9282     } else {
9283         basic_iostream_wchar_vbase_dtor(this);
9284         if(flags & 1)
9285             MSVCRT_operator_delete(this);
9286     }
9287
9288     return this;
9289 }
9290
9291 static inline basic_ios_char* basic_ofstream_char_to_basic_ios(basic_ofstream_char *ptr)
9292 {
9293     return (basic_ios_char*)((char*)ptr+basic_ofstream_char_vbtable[1]);
9294 }
9295
9296 static inline basic_ofstream_char* basic_ofstream_char_from_basic_ios(basic_ios_char *ptr)
9297 {
9298     return (basic_ofstream_char*)((char*)ptr-basic_ofstream_char_vbtable[1]);
9299 }
9300
9301 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9302 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9303 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
9304 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
9305 {
9306     basic_ios_char *basic_ios;
9307
9308     TRACE("(%p %d)\n", this, virt_init);
9309
9310     if(virt_init) {
9311         this->base.vbtable = basic_ofstream_char_vbtable;
9312         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9313         basic_ios_char_ctor(basic_ios);
9314     }else {
9315         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9316     }
9317
9318     basic_filebuf_char_ctor(&this->filebuf);
9319     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9320     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9321     return this;
9322 }
9323
9324 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
9325 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9326 static basic_ofstream_char* basic_ofstream_char_ctor_file(
9327         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
9328 {
9329     basic_ios_char *basic_ios;
9330
9331     TRACE("(%p %p %d)\n", this, file, virt_init);
9332
9333     if(virt_init) {
9334         this->base.vbtable = basic_ofstream_char_vbtable;
9335         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9336         basic_ios_char_ctor(basic_ios);
9337     }else {
9338         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9339     }
9340
9341     basic_filebuf_char_ctor_file(&this->filebuf, file);
9342     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9343     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9344     return this;
9345 }
9346
9347 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
9348 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
9349 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_copy_ctor, 12)
9350 basic_ofstream_char* __thiscall basic_ofstream_char_copy_ctor(basic_ofstream_char *this,
9351         basic_ofstream_char *copy, MSVCP_bool virt_init)
9352 {
9353     TRACE("(%p %p %d)\n", this, copy, virt_init);
9354     return basic_ofstream_char_ctor_file(this, copy->filebuf.file, virt_init);
9355 }
9356
9357 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
9358 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
9359 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 16)
9360 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
9361         const char *name, int mode, MSVCP_bool virt_init)
9362 {
9363     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9364
9365     basic_ofstream_char_ctor(this, virt_init);
9366
9367     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9368         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9369         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9370     }
9371     return this;
9372 }
9373
9374 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9375 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9376 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
9377 void __thiscall basic_ofstream_char_dtor(basic_ios_char *base)
9378 {
9379     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9380
9381     TRACE("(%p)\n", this);
9382
9383     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
9384     basic_filebuf_char_dtor(&this->filebuf);
9385 }
9386
9387 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9388 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9389 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
9390 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
9391 {
9392     TRACE("(%p)\n", this);
9393
9394     basic_ofstream_char_dtor(basic_ofstream_char_to_basic_ios(this));
9395     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
9396 }
9397
9398 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vector_dtor, 8)
9399 basic_ofstream_char* __thiscall basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9400 {
9401     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9402
9403     TRACE("(%p %x)\n", this, flags);
9404
9405     if(flags & 2) {
9406         /* we have an array, with the number of elements stored before the first object */
9407         INT_PTR i, *ptr = (INT_PTR *)this-1;
9408
9409         for(i=*ptr-1; i>=0; i--)
9410             basic_ofstream_char_vbase_dtor(this+i);
9411         MSVCRT_operator_delete(ptr);
9412     } else {
9413         basic_ofstream_char_vbase_dtor(this);
9414         if(flags & 1)
9415             MSVCRT_operator_delete(this);
9416     }
9417
9418     return this;
9419 }
9420
9421 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9422 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9423 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
9424 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
9425 {
9426     TRACE("(%p)\n", this);
9427
9428     if(!basic_filebuf_char_close(&this->filebuf)) {
9429         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9430         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9431     }
9432 }
9433
9434 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
9435 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
9436 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
9437 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
9438 {
9439     TRACE("(%p)\n", this);
9440     return basic_filebuf_char_is_open(&this->filebuf);
9441 }
9442
9443 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
9444 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
9445 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 12)
9446 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
9447         const char *name, int mode)
9448 {
9449     TRACE("(%p %s %d)\n", this, name, mode);
9450
9451     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9452         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9453         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9454     }
9455 }
9456
9457 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
9458 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
9459 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
9460 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
9461         const char *name, short mode)
9462 {
9463     basic_ofstream_char_open(this, name, mode);
9464 }
9465
9466 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9467 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9468 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
9469 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
9470 {
9471     TRACE("(%p)\n", this);
9472     return (basic_filebuf_char*)&this->filebuf;
9473 }
9474
9475 static inline basic_ios_wchar* basic_ofstream_wchar_to_basic_ios(basic_ofstream_wchar *ptr)
9476 {
9477     return (basic_ios_wchar*)((char*)ptr+basic_ofstream_wchar_vbtable[1]);
9478 }
9479
9480 static inline basic_ofstream_wchar* basic_ofstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9481 {
9482     return (basic_ofstream_wchar*)((char*)ptr-basic_ofstream_wchar_vbtable[1]);
9483 }
9484
9485 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
9486 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
9487 static basic_ofstream_wchar* basic_ofstream_wchar_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9488 {
9489     basic_ios_wchar *basic_ios;
9490
9491     TRACE("(%p %d)\n", this, virt_init);
9492
9493     if(virt_init) {
9494         this->base.vbtable = basic_ofstream_wchar_vbtable;
9495         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9496         basic_ios_wchar_ctor(basic_ios);
9497     }else {
9498         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9499     }
9500
9501     basic_filebuf_wchar_ctor(&this->filebuf);
9502     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9503     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
9504     return this;
9505 }
9506
9507 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
9508 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
9509 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor, 8)
9510 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9511 {
9512     basic_ofstream_wchar_ctor(this, virt_init);
9513     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
9514     return this;
9515 }
9516
9517 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
9518 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9519 static basic_ofstream_wchar* basic_ofstream_wchar_ctor_file(
9520         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9521 {
9522     basic_ios_wchar *basic_ios;
9523
9524     TRACE("(%p %p %d)\n", this, file, virt_init);
9525
9526     if(virt_init) {
9527         this->base.vbtable = basic_ofstream_wchar_vbtable;
9528         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9529         basic_ios_wchar_ctor(basic_ios);
9530     }else {
9531         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9532     }
9533
9534     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
9535     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9536     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
9537     return this;
9538 }
9539
9540 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
9541 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9542 static basic_ofstream_wchar* basic_ofstream_short_ctor_file(
9543         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9544 {
9545     basic_ofstream_wchar_ctor_file(this, file, virt_init);
9546     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
9547     return this;
9548 }
9549
9550 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
9551 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
9552 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_copy_ctor, 12)
9553 basic_ofstream_wchar* __thiscall basic_ofstream_short_copy_ctor(basic_ofstream_wchar *this,
9554         basic_ofstream_wchar *copy, MSVCP_bool virt_init)
9555 {
9556     TRACE("(%p %p %d)\n", this, copy, virt_init);
9557     return basic_ofstream_short_ctor_file(this, copy->filebuf.file, virt_init);
9558 }
9559
9560 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBDH@Z */
9561 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDH@Z */
9562 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name, 16)
9563 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name(basic_ofstream_wchar *this,
9564         const char *name, int mode, MSVCP_bool virt_init)
9565 {
9566     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9567
9568     basic_ofstream_short_ctor(this, virt_init);
9569
9570     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9571         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9572         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9573     }
9574     return this;
9575 }
9576
9577 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9578 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9579 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9580 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9581 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_dtor, 4)
9582 void __thiscall basic_ofstream_wchar_dtor(basic_ios_wchar *base)
9583 {
9584     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9585
9586     TRACE("(%p)\n", this);
9587
9588     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
9589     basic_filebuf_wchar_dtor(&this->filebuf);
9590 }
9591
9592 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9593 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9594 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9595 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9596 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vbase_dtor, 4)
9597 void __thiscall basic_ofstream_wchar_vbase_dtor(basic_ofstream_wchar *this)
9598 {
9599     TRACE("(%p)\n", this);
9600
9601     basic_ofstream_wchar_dtor(basic_ofstream_wchar_to_basic_ios(this));
9602     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
9603 }
9604
9605 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vector_dtor, 8)
9606 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9607 {
9608     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9609
9610     TRACE("(%p %x)\n", this, flags);
9611
9612     if(flags & 2) {
9613         /* we have an array, with the number of elements stored before the first object */
9614         INT_PTR i, *ptr = (INT_PTR *)this-1;
9615
9616         for(i=*ptr-1; i>=0; i--)
9617             basic_ofstream_wchar_vbase_dtor(this+i);
9618         MSVCRT_operator_delete(ptr);
9619     } else {
9620         basic_ofstream_wchar_vbase_dtor(this);
9621         if(flags & 1)
9622             MSVCRT_operator_delete(this);
9623     }
9624
9625     return this;
9626 }
9627
9628 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9629 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9630 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9631 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9632 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_close, 4)
9633 void __thiscall basic_ofstream_wchar_close(basic_ofstream_wchar *this)
9634 {
9635     TRACE("(%p)\n", this);
9636
9637     if(!basic_filebuf_wchar_close(&this->filebuf)) {
9638         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9639         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9640     }
9641 }
9642
9643 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
9644 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
9645 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
9646 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
9647 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_is_open, 4)
9648 MSVCP_bool __thiscall basic_ofstream_wchar_is_open(const basic_ofstream_wchar *this)
9649 {
9650     TRACE("(%p)\n", this);
9651     return basic_filebuf_wchar_is_open(&this->filebuf);
9652 }
9653
9654 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
9655 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
9656 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open, 12)
9657 void __thiscall basic_ofstream_wchar_open(basic_ofstream_wchar *this,
9658         const char *name, int mode)
9659 {
9660     TRACE("(%p %s %d)\n", this, name, mode);
9661
9662     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9663         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9664         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9665     }
9666 }
9667
9668 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
9669 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
9670 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_old, 12)
9671 void __thiscall basic_ofstream_wchar_open_old(basic_ofstream_wchar *this,
9672         const char *name, int mode)
9673 {
9674     basic_ofstream_wchar_open(this, name, mode);
9675 }
9676
9677 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9678 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9679 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9680 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9681 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_rdbuf, 4)
9682 basic_filebuf_wchar* __thiscall basic_ofstream_wchar_rdbuf(const basic_ofstream_wchar *this)
9683 {
9684     TRACE("(%p)\n", this);
9685     return (basic_filebuf_wchar*)&this->filebuf;
9686 }
9687
9688 static inline basic_ios_char* basic_ifstream_char_to_basic_ios(basic_ifstream_char *ptr)
9689 {
9690     return (basic_ios_char*)((char*)ptr+basic_ifstream_char_vbtable[1]);
9691 }
9692
9693 static inline basic_ifstream_char* basic_ifstream_char_from_basic_ios(basic_ios_char *ptr)
9694 {
9695     return (basic_ifstream_char*)((char*)ptr-basic_ifstream_char_vbtable[1]);
9696 }
9697
9698 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9699 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9700 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
9701 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
9702 {
9703     basic_ios_char *basic_ios;
9704
9705     TRACE("(%p %d)\n", this, virt_init);
9706
9707     if(virt_init) {
9708         this->base.vbtable = basic_ifstream_char_vbtable;
9709         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9710         basic_ios_char_ctor(basic_ios);
9711     }else {
9712         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9713     }
9714
9715     basic_filebuf_char_ctor(&this->filebuf);
9716     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9717     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
9718     return this;
9719 }
9720
9721 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
9722 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9723 static basic_ifstream_char* basic_ifstream_char_ctor_file(
9724         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
9725 {
9726     basic_ios_char *basic_ios;
9727
9728     TRACE("(%p %p %d)\n", this, file, virt_init);
9729
9730     if(virt_init) {
9731         this->base.vbtable = basic_ifstream_char_vbtable;
9732         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9733         basic_ios_char_ctor(basic_ios);
9734     }else {
9735         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9736     }
9737
9738     basic_filebuf_char_ctor_file(&this->filebuf, file);
9739     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9740     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
9741     return this;
9742 }
9743
9744 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
9745 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
9746 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_copy_ctor, 12)
9747 basic_ifstream_char* __thiscall basic_ifstream_char_copy_ctor(basic_ifstream_char *this,
9748         const basic_ifstream_char *copy, MSVCP_bool virt_init)
9749 {
9750     TRACE("(%p %p %d)\n", this, copy, virt_init);
9751     return basic_ifstream_char_ctor_file(this, copy->filebuf.file, virt_init);
9752 }
9753
9754 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
9755 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
9756 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 16)
9757 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
9758         const char *name, int mode, MSVCP_bool virt_init)
9759 {
9760     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9761
9762     basic_ifstream_char_ctor(this, virt_init);
9763
9764     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9765         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9766         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9767     }
9768     return this;
9769 }
9770
9771 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9772 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9773 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
9774 void __thiscall basic_ifstream_char_dtor(basic_ios_char *base)
9775 {
9776     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9777
9778     TRACE("(%p)\n", this);
9779
9780     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
9781     basic_filebuf_char_dtor(&this->filebuf);
9782 }
9783
9784 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9785 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9786 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
9787 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
9788 {
9789     TRACE("(%p)\n", this);
9790
9791     basic_ifstream_char_dtor(basic_ifstream_char_to_basic_ios(this));
9792     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
9793 }
9794
9795 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vector_dtor, 8)
9796 basic_ifstream_char* __thiscall basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9797 {
9798     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9799
9800     TRACE("(%p %x)\n", this, flags);
9801
9802     if(flags & 2) {
9803         /* we have an array, with the number of elements stored before the first object */
9804         INT_PTR i, *ptr = (INT_PTR *)this-1;
9805
9806         for(i=*ptr-1; i>=0; i--)
9807             basic_ifstream_char_vbase_dtor(this+i);
9808         MSVCRT_operator_delete(ptr);
9809     } else {
9810         basic_ifstream_char_vbase_dtor(this);
9811         if(flags & 1)
9812             MSVCRT_operator_delete(this);
9813     }
9814
9815     return this;
9816 }
9817
9818 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9819 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9820 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
9821 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
9822 {
9823     TRACE("(%p)\n", this);
9824
9825     if(!basic_filebuf_char_close(&this->filebuf)) {
9826         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9827         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9828     }
9829 }
9830
9831 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
9832 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
9833 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
9834 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
9835 {
9836     TRACE("(%p)\n", this);
9837     return basic_filebuf_char_is_open(&this->filebuf);
9838 }
9839
9840 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
9841 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
9842 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 12)
9843 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
9844         const char *name, int mode)
9845 {
9846     TRACE("(%p %s %d)\n", this, name, mode);
9847
9848     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9849         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9850         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9851     }
9852 }
9853
9854 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
9855 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
9856 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
9857 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
9858         const char *name, short mode)
9859 {
9860     basic_ifstream_char_open(this, name, mode);
9861 }
9862
9863 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9864 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9865 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
9866 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
9867 {
9868     TRACE("(%p)\n", this);
9869     return (basic_filebuf_char*)&this->filebuf;
9870 }
9871
9872 static inline basic_ios_wchar* basic_ifstream_wchar_to_basic_ios(basic_ifstream_wchar *ptr)
9873 {
9874     return (basic_ios_wchar*)((char*)ptr+basic_ifstream_wchar_vbtable[1]);
9875 }
9876
9877 static inline basic_ifstream_wchar* basic_ifstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9878 {
9879     return (basic_ifstream_wchar*)((char*)ptr-basic_ifstream_wchar_vbtable[1]);
9880 }
9881
9882 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
9883 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
9884 static basic_ifstream_wchar* basic_ifstream_wchar_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
9885 {
9886     basic_ios_wchar *basic_ios;
9887
9888     TRACE("(%p %d)\n", this, virt_init);
9889
9890     if(virt_init) {
9891         this->base.vbtable = basic_ifstream_wchar_vbtable;
9892         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9893         basic_ios_wchar_ctor(basic_ios);
9894     }else {
9895         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9896     }
9897
9898     basic_filebuf_wchar_ctor(&this->filebuf);
9899     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9900     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
9901     return this;
9902 }
9903
9904 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
9905 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
9906 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor, 8)
9907 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
9908 {
9909     basic_ifstream_wchar_ctor(this, virt_init);
9910     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
9911     return this;
9912 }
9913
9914 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
9915 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9916 static basic_ifstream_wchar* basic_ifstream_wchar_ctor_file(
9917         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9918 {
9919     basic_ios_wchar *basic_ios;
9920
9921     TRACE("(%p %p %d)\n", this, file, virt_init);
9922
9923     if(virt_init) {
9924         this->base.vbtable = basic_ifstream_wchar_vbtable;
9925         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9926         basic_ios_wchar_ctor(basic_ios);
9927     }else {
9928         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9929     }
9930
9931     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
9932     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9933     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
9934     return this;
9935 }
9936
9937 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
9938 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9939 static basic_ifstream_wchar* basic_ifstream_short_ctor_file(
9940         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9941 {
9942     basic_ifstream_wchar_ctor_file(this, file, virt_init);
9943     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
9944     return this;
9945 }
9946
9947 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
9948 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
9949 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_copy_ctor, 12)
9950 basic_ifstream_wchar* __thiscall basic_ifstream_short_copy_ctor(basic_ifstream_wchar *this,
9951         basic_ifstream_wchar *copy, MSVCP_bool virt_init)
9952 {
9953     TRACE("(%p %p %d)\n", this, copy, virt_init);
9954     return basic_ifstream_short_ctor_file(this, copy->filebuf.file, virt_init);
9955 }
9956
9957 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBDH@Z */
9958 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDH@Z */
9959 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name, 16)
9960 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name(basic_ifstream_wchar *this,
9961         const char *name, int mode, MSVCP_bool virt_init)
9962 {
9963     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9964
9965     basic_ifstream_short_ctor(this, virt_init);
9966
9967     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9968         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9969         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9970     }
9971     return this;
9972 }
9973
9974 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9975 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9976 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9977 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9978 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_dtor, 4)
9979 void __thiscall basic_ifstream_wchar_dtor(basic_ios_wchar *base)
9980 {
9981     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
9982
9983     TRACE("(%p)\n", this);
9984
9985     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
9986     basic_filebuf_wchar_dtor(&this->filebuf);
9987 }
9988
9989 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9990 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9991 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9992 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9993 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vbase_dtor, 4)
9994 void __thiscall basic_ifstream_wchar_vbase_dtor(basic_ifstream_wchar *this)
9995 {
9996     TRACE("(%p)\n", this);
9997
9998     basic_ifstream_wchar_dtor(basic_ifstream_wchar_to_basic_ios(this));
9999     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
10000 }
10001
10002 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vector_dtor, 8)
10003 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10004 {
10005     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10006
10007     TRACE("(%p %x)\n", this, flags);
10008
10009     if(flags & 2) {
10010         /* we have an array, with the number of elements stored before the first object */
10011         INT_PTR i, *ptr = (INT_PTR *)this-1;
10012
10013         for(i=*ptr-1; i>=0; i--)
10014             basic_ifstream_wchar_vbase_dtor(this+i);
10015         MSVCRT_operator_delete(ptr);
10016     } else {
10017         basic_ifstream_wchar_vbase_dtor(this);
10018         if(flags & 1)
10019             MSVCRT_operator_delete(this);
10020     }
10021
10022     return this;
10023 }
10024
10025 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10026 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10027 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10028 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10029 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_close, 4)
10030 void __thiscall basic_ifstream_wchar_close(basic_ifstream_wchar *this)
10031 {
10032     TRACE("(%p)\n", this);
10033
10034     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10035         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10036         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10037     }
10038 }
10039
10040 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10041 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10042 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10043 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10044 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_is_open, 4)
10045 MSVCP_bool __thiscall basic_ifstream_wchar_is_open(const basic_ifstream_wchar *this)
10046 {
10047     TRACE("(%p)\n", this);
10048     return basic_filebuf_wchar_is_open(&this->filebuf);
10049 }
10050
10051 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
10052 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
10053 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open, 12)
10054 void __thiscall basic_ifstream_wchar_open(basic_ifstream_wchar *this,
10055         const char *name, int mode)
10056 {
10057     TRACE("(%p %s %d)\n", this, name, mode);
10058
10059     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
10060         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10061         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10062     }
10063 }
10064
10065 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
10066 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
10067 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_old, 12)
10068 void __thiscall basic_ifstream_wchar_open_old(basic_ifstream_wchar *this,
10069         const char *name, short mode)
10070 {
10071     basic_ifstream_wchar_open(this, name, mode);
10072 }
10073
10074 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10075 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10076 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10077 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10078 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_rdbuf, 4)
10079 basic_filebuf_wchar* __thiscall basic_ifstream_wchar_rdbuf(const basic_ifstream_wchar *this)
10080 {
10081     TRACE("(%p)\n", this);
10082     return (basic_filebuf_wchar*)&this->filebuf;
10083 }
10084
10085 static inline basic_ios_char* basic_fstream_char_to_basic_ios(basic_fstream_char *ptr)
10086 {
10087     return (basic_ios_char*)((char*)ptr+basic_fstream_char_vbtable1[1]);
10088 }
10089
10090 static inline basic_fstream_char* basic_fstream_char_from_basic_ios(basic_ios_char *ptr)
10091 {
10092     return (basic_fstream_char*)((char*)ptr-basic_fstream_char_vbtable1[1]);
10093 }
10094
10095 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10096 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10097 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
10098 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
10099 {
10100     basic_ios_char *basic_ios;
10101
10102     TRACE("(%p %d)\n", this, virt_init);
10103
10104     if(virt_init) {
10105         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10106         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10107         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10108         basic_ios_char_ctor(basic_ios);
10109     }else {
10110         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10111     }
10112
10113     basic_filebuf_char_ctor(&this->filebuf);
10114     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10115     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10116     return this;
10117 }
10118
10119 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10120 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10121 static basic_fstream_char* basic_fstream_char_ctor_file(basic_fstream_char *this,
10122         FILE *file, MSVCP_bool virt_init)
10123 {
10124     basic_ios_char *basic_ios;
10125
10126     TRACE("(%p %p %d)\n", this, file, virt_init);
10127
10128     if(virt_init) {
10129         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10130         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10131         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10132         basic_ios_char_ctor(basic_ios);
10133     }else {
10134         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10135     }
10136
10137     basic_filebuf_char_ctor_file(&this->filebuf, file);
10138     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10139     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10140     return this;
10141 }
10142
10143 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
10144 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
10145 DEFINE_THISCALL_WRAPPER(basic_fstream_char_copy_ctor, 12)
10146 basic_fstream_char* __thiscall basic_fstream_char_copy_ctor(basic_fstream_char *this,
10147         basic_fstream_char *copy, MSVCP_bool virt_init)
10148 {
10149     TRACE("(%p %p %d)\n", this, copy, virt_init);
10150     return basic_fstream_char_ctor_file(this, copy->filebuf.file, virt_init);
10151 }
10152
10153 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
10154 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
10155 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 16)
10156 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
10157         const char *name, int mode, MSVCP_bool virt_init)
10158 {
10159     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10160
10161     basic_fstream_char_ctor(this, virt_init);
10162
10163     if(!basic_filebuf_char_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10164         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10165         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10166     }
10167     return this;
10168 }
10169
10170 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10171 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10172 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
10173 void __thiscall basic_fstream_char_dtor(basic_ios_char *base)
10174 {
10175     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10176
10177     TRACE("(%p)\n", this);
10178
10179     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
10180     basic_filebuf_char_dtor(&this->filebuf);
10181 }
10182
10183 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10184 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10185 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
10186 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
10187 {
10188     TRACE("(%p)\n", this);
10189
10190     basic_fstream_char_dtor(basic_fstream_char_to_basic_ios(this));
10191     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
10192 }
10193
10194 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vector_dtor, 8)
10195 basic_fstream_char* __thiscall basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10196 {
10197     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10198
10199     TRACE("(%p %x)\n", this, flags);
10200
10201     if(flags & 2) {
10202         /* we have an array, with the number of elements stored before the first object */
10203         INT_PTR i, *ptr = (INT_PTR *)this-1;
10204
10205         for(i=*ptr-1; i>=0; i--)
10206             basic_fstream_char_vbase_dtor(this+i);
10207         MSVCRT_operator_delete(ptr);
10208     } else {
10209         basic_fstream_char_vbase_dtor(this);
10210         if(flags & 1)
10211             MSVCRT_operator_delete(this);
10212     }
10213
10214     return this;
10215 }
10216
10217 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10218 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10219 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
10220 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
10221 {
10222     TRACE("(%p)\n", this);
10223
10224     if(!basic_filebuf_char_close(&this->filebuf)) {
10225         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10226         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10227     }
10228 }
10229
10230 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10231 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10232 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
10233 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
10234 {
10235     TRACE("(%p)\n", this);
10236     return basic_filebuf_char_is_open(&this->filebuf);
10237 }
10238
10239 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
10240 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
10241 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 12)
10242 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
10243         const char *name, int mode)
10244 {
10245     TRACE("(%p %s %d)\n", this, name, mode);
10246
10247     if(!basic_filebuf_char_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10248         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10249         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10250     }
10251 }
10252
10253 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
10254 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
10255 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
10256 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
10257         const char *name, int mode)
10258 {
10259     basic_fstream_char_open(this, name, mode);
10260 }
10261
10262 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10263 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10264 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
10265 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
10266 {
10267     TRACE("(%p)\n", this);
10268     return (basic_filebuf_char*)&this->filebuf;
10269 }
10270
10271 static inline basic_ios_wchar* basic_fstream_wchar_to_basic_ios(basic_fstream_wchar *ptr)
10272 {
10273     return (basic_ios_wchar*)((char*)ptr+basic_fstream_wchar_vbtable1[1]);
10274 }
10275
10276 static inline basic_fstream_wchar* basic_fstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10277 {
10278     return (basic_fstream_wchar*)((char*)ptr-basic_fstream_wchar_vbtable1[1]);
10279 }
10280
10281 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10282 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10283 static basic_fstream_wchar* basic_fstream_wchar_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10284 {
10285     basic_ios_wchar *basic_ios;
10286
10287     TRACE("(%p %d)\n", this, virt_init);
10288
10289     if(virt_init) {
10290         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10291         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10292         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10293         basic_ios_wchar_ctor(basic_ios);
10294     }else {
10295         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10296     }
10297
10298     basic_filebuf_wchar_ctor(&this->filebuf);
10299     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10300     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10301     return this;
10302 }
10303
10304 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10305 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10306 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor, 8)
10307 basic_fstream_wchar* __thiscall basic_fstream_short_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10308 {
10309     basic_fstream_wchar_ctor(this, virt_init);
10310     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
10311     return this;
10312 }
10313
10314 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10315 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10316 static basic_fstream_wchar* basic_fstream_wchar_ctor_file(basic_fstream_wchar *this,
10317         FILE *file, MSVCP_bool virt_init)
10318 {
10319     basic_ios_wchar *basic_ios;
10320
10321     TRACE("(%p %p %d)\n", this, file, virt_init);
10322
10323     if(virt_init) {
10324         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10325         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10326         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10327         basic_ios_wchar_ctor(basic_ios);
10328     }else {
10329         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10330     }
10331
10332     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10333     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10334     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10335     return this;
10336 }
10337
10338 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10339 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10340 static basic_fstream_wchar* basic_fstream_short_ctor_file(basic_fstream_wchar *this,
10341         FILE *file, MSVCP_bool virt_init)
10342 {
10343     basic_fstream_wchar_ctor_file(this, file, virt_init);
10344     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
10345     return this;
10346 }
10347
10348 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
10349 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
10350 DEFINE_THISCALL_WRAPPER(basic_fstream_short_copy_ctor, 12)
10351 basic_fstream_wchar* __thiscall basic_fstream_short_copy_ctor(basic_fstream_wchar *this,
10352         basic_fstream_wchar *copy, MSVCP_bool virt_init)
10353 {
10354     TRACE("(%p %p %d)\n", this, copy, virt_init);
10355     return basic_fstream_short_ctor_file(this, copy->filebuf.file, virt_init);
10356 }
10357
10358 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10359 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10360 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name, 16)
10361 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name(basic_fstream_wchar *this,
10362         const char *name, int mode, MSVCP_bool virt_init)
10363 {
10364     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10365
10366     basic_fstream_short_ctor(this, virt_init);
10367
10368     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10369         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10370         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10371     }
10372     return this;
10373 }
10374
10375 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10376 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10377 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10378 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10379 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_dtor, 4)
10380 void __thiscall basic_fstream_wchar_dtor(basic_ios_wchar *base)
10381 {
10382     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10383
10384     TRACE("(%p)\n", this);
10385
10386     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
10387     basic_filebuf_wchar_dtor(&this->filebuf);
10388 }
10389
10390 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10391 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10392 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10393 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10394 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vbase_dtor, 4)
10395 void __thiscall basic_fstream_wchar_vbase_dtor(basic_fstream_wchar *this)
10396 {
10397     TRACE("(%p)\n", this);
10398
10399     basic_fstream_wchar_dtor(basic_fstream_wchar_to_basic_ios(this));
10400     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
10401 }
10402
10403 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vector_dtor, 8)
10404 basic_fstream_wchar* __thiscall basic_fstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10405 {
10406     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10407
10408     TRACE("(%p %x)\n", this, flags);
10409
10410     if(flags & 2) {
10411         /* we have an array, with the number of elements stored before the first object */
10412         INT_PTR i, *ptr = (INT_PTR *)this-1;
10413
10414         for(i=*ptr-1; i>=0; i--)
10415             basic_fstream_wchar_vbase_dtor(this+i);
10416         MSVCRT_operator_delete(ptr);
10417     } else {
10418         basic_fstream_wchar_vbase_dtor(this);
10419         if(flags & 1)
10420             MSVCRT_operator_delete(this);
10421     }
10422
10423     return this;
10424 }
10425
10426 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10427 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10428 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10429 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10430 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_close, 4)
10431 void __thiscall basic_fstream_wchar_close(basic_fstream_wchar *this)
10432 {
10433     TRACE("(%p)\n", this);
10434
10435     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10436         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10437         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10438     }
10439 }
10440
10441 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10442 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10443 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10444 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10445 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_is_open, 4)
10446 MSVCP_bool __thiscall basic_fstream_wchar_is_open(const basic_fstream_wchar *this)
10447 {
10448     TRACE("(%p)\n", this);
10449     return basic_filebuf_wchar_is_open(&this->filebuf);
10450 }
10451
10452 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
10453 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
10454 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open, 12)
10455 void __thiscall basic_fstream_wchar_open(basic_fstream_wchar *this,
10456         const char *name, int mode)
10457 {
10458     TRACE("(%p %s %d)\n", this, name, mode);
10459
10460     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10461         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10462         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10463     }
10464 }
10465
10466 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
10467 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
10468 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_old, 12)
10469 void __thiscall basic_fstream_wchar_open_old(basic_fstream_wchar *this,
10470         const char *name, int mode)
10471 {
10472     basic_fstream_wchar_open(this, name, mode);
10473 }
10474
10475 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10476 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10477 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10478 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10479 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_rdbuf, 4)
10480 basic_filebuf_wchar* __thiscall basic_fstream_wchar_rdbuf(const basic_fstream_wchar *this)
10481 {
10482     TRACE("(%p)\n", this);
10483     return (basic_filebuf_wchar*)&this->filebuf;
10484 }
10485
10486 static inline basic_ios_char* basic_ostringstream_char_to_basic_ios(basic_ostringstream_char *ptr)
10487 {
10488     return (basic_ios_char*)((char*)ptr+basic_ostringstream_char_vbtable[1]);
10489 }
10490
10491 static inline basic_ostringstream_char* basic_ostringstream_char_from_basic_ios(basic_ios_char *ptr)
10492 {
10493     return (basic_ostringstream_char*)((char*)ptr-basic_ostringstream_char_vbtable[1]);
10494 }
10495
10496 /* ??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 */
10497 /* ??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 */
10498 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_str, 16)
10499 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_str(basic_ostringstream_char *this,
10500         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10501 {
10502     basic_ios_char *basic_ios;
10503
10504     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10505
10506     if(virt_init) {
10507         this->base.vbtable = basic_ostringstream_char_vbtable;
10508         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10509         basic_ios_char_ctor(basic_ios);
10510     }else {
10511         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10512     }
10513
10514     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10515     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10516     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10517     return this;
10518 }
10519
10520 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
10521 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
10522 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_mode, 12)
10523 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_mode(
10524         basic_ostringstream_char *this, int mode, MSVCP_bool virt_init)
10525 {
10526     basic_ios_char *basic_ios;
10527
10528     TRACE("(%p %d %d)\n", this, mode, virt_init);
10529
10530     if(virt_init) {
10531         this->base.vbtable = basic_ostringstream_char_vbtable;
10532         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10533         basic_ios_char_ctor(basic_ios);
10534     }else {
10535         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10536     }
10537
10538     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10539     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10540     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10541     return this;
10542 }
10543
10544 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10545 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10546 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor, 8)
10547 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor(
10548         basic_ostringstream_char *this, MSVCP_bool virt_init)
10549 {
10550     return basic_ostringstream_char_ctor_mode(this, 0, virt_init);
10551 }
10552
10553 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
10554 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
10555 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_dtor, 4)
10556 void __thiscall basic_ostringstream_char_dtor(basic_ios_char *base)
10557 {
10558     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10559
10560     TRACE("(%p)\n", this);
10561
10562     basic_stringbuf_char_dtor(&this->strbuf);
10563     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
10564 }
10565
10566 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10567 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10568 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vbase_dtor, 4)
10569 void __thiscall basic_ostringstream_char_vbase_dtor(basic_ostringstream_char *this)
10570 {
10571     TRACE("(%p)\n", this);
10572
10573     basic_ostringstream_char_dtor(basic_ostringstream_char_to_basic_ios(this));
10574     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
10575 }
10576
10577 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vector_dtor, 8)
10578 basic_ostringstream_char* __thiscall basic_ostringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10579 {
10580     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10581
10582     TRACE("(%p %x)\n", this, flags);
10583
10584     if(flags & 2) {
10585         /* we have an array, with the number of elements stored before the first object */
10586         INT_PTR i, *ptr = (INT_PTR *)this-1;
10587
10588         for(i=*ptr-1; i>=0; i--)
10589             basic_ostringstream_char_vbase_dtor(this+i);
10590         MSVCRT_operator_delete(ptr);
10591     } else {
10592         basic_ostringstream_char_vbase_dtor(this);
10593         if(flags & 1)
10594             MSVCRT_operator_delete(this);
10595     }
10596
10597     return this;
10598 }
10599
10600 /* ?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 */
10601 /* ?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 */
10602 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_rdbuf, 4)
10603 basic_stringbuf_char* __thiscall basic_ostringstream_char_rdbuf(const basic_ostringstream_char *this)
10604 {
10605     TRACE("(%p)\n", this);
10606     return (basic_stringbuf_char*)&this->strbuf;
10607 }
10608
10609 /* ?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 */
10610 /* ?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 */
10611 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_set, 8)
10612 void __thiscall basic_ostringstream_char_str_set(basic_ostringstream_char *this, const basic_string_char *str)
10613 {
10614     TRACE("(%p %p)\n", this, str);
10615     basic_stringbuf_char_str_set(&this->strbuf, str);
10616 }
10617
10618 /* ?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 */
10619 /* ?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 */
10620 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_get, 8)
10621 basic_string_char* __thiscall basic_ostringstream_char_str_get(const basic_ostringstream_char *this, basic_string_char *ret)
10622 {
10623     TRACE("(%p %p)\n", this, ret);
10624     return basic_stringbuf_char_str_get(&this->strbuf, ret);
10625 }
10626
10627 static inline basic_ios_wchar* basic_ostringstream_wchar_to_basic_ios(basic_ostringstream_wchar *ptr)
10628 {
10629     return (basic_ios_wchar*)((char*)ptr+basic_ostringstream_wchar_vbtable[1]);
10630 }
10631
10632 static inline basic_ostringstream_wchar* basic_ostringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10633 {
10634     return (basic_ostringstream_wchar*)((char*)ptr-basic_ostringstream_wchar_vbtable[1]);
10635 }
10636
10637 /* ??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 */
10638 /* ??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 */
10639 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_str(basic_ostringstream_wchar *this,
10640         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10641 {
10642     basic_ios_wchar *basic_ios;
10643
10644     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10645
10646     if(virt_init) {
10647         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10648         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10649         basic_ios_wchar_ctor(basic_ios);
10650     }else {
10651         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10652     }
10653
10654     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10655     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10656     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10657     return this;
10658 }
10659
10660 /* ??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 */
10661 /* ??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 */
10662 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_str, 16)
10663 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_str(basic_ostringstream_wchar *this,
10664         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10665 {
10666     basic_ostringstream_wchar_ctor_str(this, str, mode, virt_init);
10667     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10668     return this;
10669 }
10670
10671 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
10672 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
10673 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_mode(
10674         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10675 {
10676     basic_ios_wchar *basic_ios;
10677
10678     TRACE("(%p %d %d)\n", this, mode, virt_init);
10679
10680     if(virt_init) {
10681         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10682         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10683         basic_ios_wchar_ctor(basic_ios);
10684     }else {
10685         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10686     }
10687
10688     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10689     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10690     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10691     return this;
10692 }
10693
10694 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
10695 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
10696 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_mode, 12)
10697 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_mode(
10698         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10699 {
10700     basic_ostringstream_wchar_ctor_mode(this, mode, virt_init);
10701     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10702     return this;
10703 }
10704
10705 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10706 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10707 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor, 8)
10708 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor(
10709         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
10710 {
10711     return basic_ostringstream_short_ctor_mode(this, 0, virt_init);
10712 }
10713
10714 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
10715 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
10716 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
10717 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
10718 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_dtor, 4)
10719 void __thiscall basic_ostringstream_wchar_dtor(basic_ios_wchar *base)
10720 {
10721     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10722
10723     TRACE("(%p)\n", this);
10724
10725     basic_stringbuf_wchar_dtor(&this->strbuf);
10726     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
10727 }
10728
10729 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
10730 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
10731 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10732 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10733 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vbase_dtor, 4)
10734 void __thiscall basic_ostringstream_wchar_vbase_dtor(basic_ostringstream_wchar *this)
10735 {
10736     TRACE("(%p)\n", this);
10737
10738     basic_ostringstream_wchar_dtor(basic_ostringstream_wchar_to_basic_ios(this));
10739     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
10740 }
10741
10742 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vector_dtor, 8)
10743 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10744 {
10745     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10746
10747     TRACE("(%p %x)\n", this, flags);
10748
10749     if(flags & 2) {
10750         /* we have an array, with the number of elements stored before the first object */
10751         INT_PTR i, *ptr = (INT_PTR *)this-1;
10752
10753         for(i=*ptr-1; i>=0; i--)
10754             basic_ostringstream_wchar_vbase_dtor(this+i);
10755         MSVCRT_operator_delete(ptr);
10756     } else {
10757         basic_ostringstream_wchar_vbase_dtor(this);
10758         if(flags & 1)
10759             MSVCRT_operator_delete(this);
10760     }
10761
10762     return this;
10763 }
10764
10765 /* ?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 */
10766 /* ?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 */
10767 /* ?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 */
10768 /* ?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 */
10769 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_rdbuf, 4)
10770 basic_stringbuf_wchar* __thiscall basic_ostringstream_wchar_rdbuf(const basic_ostringstream_wchar *this)
10771 {
10772     TRACE("(%p)\n", this);
10773     return (basic_stringbuf_wchar*)&this->strbuf;
10774 }
10775
10776 /* ?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 */
10777 /* ?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 */
10778 /* ?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 */
10779 /* ?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 */
10780 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_set, 8)
10781 void __thiscall basic_ostringstream_wchar_str_set(basic_ostringstream_wchar *this, const basic_string_wchar *str)
10782 {
10783     TRACE("(%p %p)\n", this, str);
10784     basic_stringbuf_wchar_str_set(&this->strbuf, str);
10785 }
10786
10787 /* ?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 */
10788 /* ?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 */
10789 /* ?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 */
10790 /* ?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 */
10791 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_get, 8)
10792 basic_string_wchar* __thiscall basic_ostringstream_wchar_str_get(const basic_ostringstream_wchar *this, basic_string_wchar *ret)
10793 {
10794     TRACE("(%p %p)\n", this, ret);
10795     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
10796 }
10797
10798 static inline basic_ios_char* basic_istringstream_char_to_basic_ios(basic_istringstream_char *ptr)
10799 {
10800     return (basic_ios_char*)((char*)ptr+basic_istringstream_char_vbtable[1]);
10801 }
10802
10803 static inline basic_istringstream_char* basic_istringstream_char_from_basic_ios(basic_ios_char *ptr)
10804 {
10805     return (basic_istringstream_char*)((char*)ptr-basic_istringstream_char_vbtable[1]);
10806 }
10807
10808 /* ??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 */
10809 /* ??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 */
10810 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_str, 16)
10811 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_str(basic_istringstream_char *this,
10812         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10813 {
10814     basic_ios_char *basic_ios;
10815
10816     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10817
10818     if(virt_init) {
10819         this->base.vbtable = basic_istringstream_char_vbtable;
10820         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10821         basic_ios_char_ctor(basic_ios);
10822     }else {
10823         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10824     }
10825
10826     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
10827     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10828     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
10829     return this;
10830 }
10831
10832 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
10833 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
10834 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_mode, 12)
10835 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_mode(
10836         basic_istringstream_char *this, int mode, MSVCP_bool virt_init)
10837 {
10838     basic_ios_char *basic_ios;
10839
10840     TRACE("(%p %d %d)\n", this, mode, virt_init);
10841
10842     if(virt_init) {
10843         this->base.vbtable = basic_istringstream_char_vbtable;
10844         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10845         basic_ios_char_ctor(basic_ios);
10846     }else {
10847         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10848     }
10849
10850     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_in);
10851     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10852     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
10853     return this;
10854 }
10855
10856 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10857 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10858 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor, 8)
10859 basic_istringstream_char* __thiscall basic_istringstream_char_ctor(
10860         basic_istringstream_char *this, MSVCP_bool virt_init)
10861 {
10862     return basic_istringstream_char_ctor_mode(this, 0, virt_init);
10863 }
10864
10865 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
10866 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
10867 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_dtor, 4)
10868 void __thiscall basic_istringstream_char_dtor(basic_ios_char *base)
10869 {
10870     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
10871
10872     TRACE("(%p)\n", this);
10873
10874     basic_stringbuf_char_dtor(&this->strbuf);
10875     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
10876 }
10877
10878 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10879 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10880 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vbase_dtor, 4)
10881 void __thiscall basic_istringstream_char_vbase_dtor(basic_istringstream_char *this)
10882 {
10883     TRACE("(%p)\n", this);
10884
10885     basic_istringstream_char_dtor(basic_istringstream_char_to_basic_ios(this));
10886     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
10887 }
10888
10889 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vector_dtor, 8)
10890 basic_istringstream_char* __thiscall basic_istringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10891 {
10892     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
10893
10894     TRACE("(%p %x)\n", this, flags);
10895
10896     if(flags & 2) {
10897         /* we have an array, with the number of elements stored before the first object */
10898         INT_PTR i, *ptr = (INT_PTR *)this-1;
10899
10900         for(i=*ptr-1; i>=0; i--)
10901             basic_istringstream_char_vbase_dtor(this+i);
10902         MSVCRT_operator_delete(ptr);
10903     } else {
10904         basic_istringstream_char_vbase_dtor(this);
10905         if(flags & 1)
10906             MSVCRT_operator_delete(this);
10907     }
10908
10909     return this;
10910 }
10911
10912 /* ?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 */
10913 /* ?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 */
10914 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_rdbuf, 4)
10915 basic_stringbuf_char* __thiscall basic_istringstream_char_rdbuf(const basic_istringstream_char *this)
10916 {
10917     TRACE("(%p)\n", this);
10918     return (basic_stringbuf_char*)&this->strbuf;
10919 }
10920
10921 /* ?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 */
10922 /* ?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 */
10923 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_set, 8)
10924 void __thiscall basic_istringstream_char_str_set(basic_istringstream_char *this, const basic_string_char *str)
10925 {
10926     TRACE("(%p %p)\n", this, str);
10927     basic_stringbuf_char_str_set(&this->strbuf, str);
10928 }
10929
10930 /* ?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 */
10931 /* ?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 */
10932 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_get, 8)
10933 basic_string_char* __thiscall basic_istringstream_char_str_get(const basic_istringstream_char *this, basic_string_char *ret)
10934 {
10935     TRACE("(%p %p)\n", this, ret);
10936     return basic_stringbuf_char_str_get(&this->strbuf, ret);
10937 }
10938
10939 static inline basic_ios_wchar* basic_istringstream_wchar_to_basic_ios(basic_istringstream_wchar *ptr)
10940 {
10941     return (basic_ios_wchar*)((char*)ptr+basic_istringstream_wchar_vbtable[1]);
10942 }
10943
10944 static inline basic_istringstream_wchar* basic_istringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10945 {
10946     return (basic_istringstream_wchar*)((char*)ptr-basic_istringstream_wchar_vbtable[1]);
10947 }
10948
10949 /* ??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 */
10950 /* ??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 */
10951 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_str(basic_istringstream_wchar *this,
10952         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10953 {
10954     basic_ios_wchar *basic_ios;
10955
10956     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10957
10958     if(virt_init) {
10959         this->base.vbtable = basic_istringstream_wchar_vbtable;
10960         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10961         basic_ios_wchar_ctor(basic_ios);
10962     }else {
10963         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10964     }
10965
10966     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
10967     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10968     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
10969     return this;
10970 }
10971
10972 /* ??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 */
10973 /* ??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 */
10974 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_str, 16)
10975 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_str(basic_istringstream_wchar *this,
10976         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10977 {
10978     basic_istringstream_wchar_ctor_str(this, str, mode, virt_init);
10979     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
10980     return this;
10981 }
10982
10983 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
10984 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
10985 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_mode(
10986         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
10987 {
10988     basic_ios_wchar *basic_ios;
10989
10990     TRACE("(%p %d %d)\n", this, mode, virt_init);
10991
10992     if(virt_init) {
10993         this->base.vbtable = basic_istringstream_wchar_vbtable;
10994         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10995         basic_ios_wchar_ctor(basic_ios);
10996     }else {
10997         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10998     }
10999
11000     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11001     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11002     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11003     return this;
11004 }
11005
11006 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11007 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11008 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_mode, 12)
11009 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_mode(
11010         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11011 {
11012     basic_istringstream_wchar_ctor_mode(this, mode, virt_init);
11013     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11014     return this;
11015 }
11016
11017 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11018 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11019 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor, 8)
11020 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor(
11021         basic_istringstream_wchar *this, MSVCP_bool virt_init)
11022 {
11023     return basic_istringstream_short_ctor_mode(this, 0, virt_init);
11024 }
11025
11026 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11027 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11028 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11029 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11030 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_dtor, 4)
11031 void __thiscall basic_istringstream_wchar_dtor(basic_ios_wchar *base)
11032 {
11033     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11034
11035     TRACE("(%p)\n", this);
11036
11037     basic_stringbuf_wchar_dtor(&this->strbuf);
11038     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
11039 }
11040
11041 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11042 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11043 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11044 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11045 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vbase_dtor, 4)
11046 void __thiscall basic_istringstream_wchar_vbase_dtor(basic_istringstream_wchar *this)
11047 {
11048     TRACE("(%p)\n", this);
11049
11050     basic_istringstream_wchar_dtor(basic_istringstream_wchar_to_basic_ios(this));
11051     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
11052 }
11053
11054 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vector_dtor, 8)
11055 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11056 {
11057     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11058
11059     TRACE("(%p %x)\n", this, flags);
11060
11061     if(flags & 2) {
11062         /* we have an array, with the number of elements stored before the first object */
11063         INT_PTR i, *ptr = (INT_PTR *)this-1;
11064
11065         for(i=*ptr-1; i>=0; i--)
11066             basic_istringstream_wchar_vbase_dtor(this+i);
11067         MSVCRT_operator_delete(ptr);
11068     } else {
11069         basic_istringstream_wchar_vbase_dtor(this);
11070         if(flags & 1)
11071             MSVCRT_operator_delete(this);
11072     }
11073
11074     return this;
11075 }
11076
11077 /* ?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 */
11078 /* ?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 */
11079 /* ?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 */
11080 /* ?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 */
11081 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_rdbuf, 4)
11082 basic_stringbuf_wchar* __thiscall basic_istringstream_wchar_rdbuf(const basic_istringstream_wchar *this)
11083 {
11084     TRACE("(%p)\n", this);
11085     return (basic_stringbuf_wchar*)&this->strbuf;
11086 }
11087
11088 /* ?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 */
11089 /* ?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 */
11090 /* ?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 */
11091 /* ?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 */
11092 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_set, 8)
11093 void __thiscall basic_istringstream_wchar_str_set(basic_istringstream_wchar *this, const basic_string_wchar *str)
11094 {
11095     TRACE("(%p %p)\n", this, str);
11096     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11097 }
11098
11099 /* ?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 */
11100 /* ?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 */
11101 /* ?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 */
11102 /* ?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 */
11103 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_get, 8)
11104 basic_string_wchar* __thiscall basic_istringstream_wchar_str_get(const basic_istringstream_wchar *this, basic_string_wchar *ret)
11105 {
11106     TRACE("(%p %p)\n", this, ret);
11107     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11108 }
11109
11110 static inline basic_ios_char* basic_stringstream_char_to_basic_ios(basic_stringstream_char *ptr)
11111 {
11112     return (basic_ios_char*)((char*)ptr+basic_stringstream_char_vbtable1[1]);
11113 }
11114
11115 static inline basic_stringstream_char* basic_stringstream_char_from_basic_ios(basic_ios_char *ptr)
11116 {
11117     return (basic_stringstream_char*)((char*)ptr-basic_stringstream_char_vbtable1[1]);
11118 }
11119
11120 /* ??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 */
11121 /* ??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 */
11122 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_str, 16)
11123 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_str(basic_stringstream_char *this,
11124         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11125 {
11126     basic_ios_char *basic_ios;
11127
11128     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11129
11130     if(virt_init) {
11131         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11132         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11133         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11134         basic_ios_char_ctor(basic_ios);
11135     }else {
11136         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11137     }
11138
11139     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode);
11140     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11141     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11142     return this;
11143 }
11144
11145 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11146 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11147 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_mode, 12)
11148 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_mode(
11149         basic_stringstream_char *this, int mode, MSVCP_bool virt_init)
11150 {
11151     basic_ios_char *basic_ios;
11152
11153     TRACE("(%p %d %d)\n", this, mode, virt_init);
11154
11155     if(virt_init) {
11156         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11157         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11158         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11159         basic_ios_char_ctor(basic_ios);
11160     }else {
11161         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11162     }
11163
11164     basic_stringbuf_char_ctor_mode(&this->strbuf, mode);
11165     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11166     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11167     return this;
11168 }
11169
11170 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11171 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11172 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor, 8)
11173 basic_stringstream_char* __thiscall basic_stringstream_char_ctor(
11174         basic_stringstream_char *this, MSVCP_bool virt_init)
11175 {
11176     return basic_stringstream_char_ctor_mode(
11177             this, OPENMODE_out|OPENMODE_in, virt_init);
11178 }
11179
11180 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11181 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11182 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_dtor, 4)
11183 void __thiscall basic_stringstream_char_dtor(basic_ios_char *base)
11184 {
11185     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11186
11187     TRACE("(%p)\n", this);
11188
11189     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11190     basic_stringbuf_char_dtor(&this->strbuf);
11191 }
11192
11193 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11194 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11195 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vbase_dtor, 4)
11196 void __thiscall basic_stringstream_char_vbase_dtor(basic_stringstream_char *this)
11197 {
11198     TRACE("(%p)\n", this);
11199
11200     basic_stringstream_char_dtor(basic_stringstream_char_to_basic_ios(this));
11201     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11202 }
11203
11204 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vector_dtor, 8)
11205 basic_stringstream_char* __thiscall basic_stringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11206 {
11207     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11208
11209     TRACE("(%p %x)\n", this, flags);
11210
11211     if(flags & 2) {
11212         /* we have an array, with the number of elements stored before the first object */
11213         INT_PTR i, *ptr = (INT_PTR *)this-1;
11214
11215         for(i=*ptr-1; i>=0; i--)
11216             basic_stringstream_char_vbase_dtor(this+i);
11217         MSVCRT_operator_delete(ptr);
11218     } else {
11219         basic_stringstream_char_vbase_dtor(this);
11220         if(flags & 1)
11221             MSVCRT_operator_delete(this);
11222     }
11223
11224     return this;
11225 }
11226
11227 /* ?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 */
11228 /* ?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 */
11229 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_rdbuf, 4)
11230 basic_stringbuf_char* __thiscall basic_stringstream_char_rdbuf(const basic_stringstream_char *this)
11231 {
11232     TRACE("(%p)\n", this);
11233     return (basic_stringbuf_char*)&this->strbuf;
11234 }
11235
11236 /* ?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 */
11237 /* ?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 */
11238 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_set, 8)
11239 void __thiscall basic_stringstream_char_str_set(basic_stringstream_char *this, const basic_string_char *str)
11240 {
11241     TRACE("(%p %p)\n", this, str);
11242     basic_stringbuf_char_str_set(&this->strbuf, str);
11243 }
11244
11245 /* ?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 */
11246 /* ?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 */
11247 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_get, 8)
11248 basic_string_char* __thiscall basic_stringstream_char_str_get(const basic_stringstream_char *this, basic_string_char *ret)
11249 {
11250     TRACE("(%p %p)\n", this, ret);
11251     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11252 }
11253
11254 static inline basic_ios_wchar* basic_stringstream_wchar_to_basic_ios(basic_stringstream_wchar *ptr)
11255 {
11256     return (basic_ios_wchar*)((char*)ptr+basic_stringstream_wchar_vbtable1[1]);
11257 }
11258
11259 static inline basic_stringstream_wchar* basic_stringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11260 {
11261     return (basic_stringstream_wchar*)((char*)ptr-basic_stringstream_wchar_vbtable1[1]);
11262 }
11263
11264 /* ??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 */
11265 /* ??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 */
11266 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_str(basic_stringstream_wchar *this,
11267         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11268 {
11269     basic_ios_wchar *basic_ios;
11270
11271     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11272
11273     if(virt_init) {
11274         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11275         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11276         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11277         basic_ios_wchar_ctor(basic_ios);
11278     }else {
11279         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11280     }
11281
11282     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode);
11283     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11284     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11285     return this;
11286 }
11287
11288 /* ??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 */
11289 /* ??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 */
11290 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_str, 16)
11291 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_str(basic_stringstream_wchar *this,
11292         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11293 {
11294     basic_stringstream_wchar_ctor_str(this, str, mode, virt_init);
11295     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11296     return this;
11297 }
11298
11299 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11300 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11301 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_mode(
11302         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11303 {
11304     basic_ios_wchar *basic_ios;
11305
11306     TRACE("(%p %d %d)\n", this, mode, virt_init);
11307
11308     if(virt_init) {
11309         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11310         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11311         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11312         basic_ios_wchar_ctor(basic_ios);
11313     }else {
11314         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11315     }
11316
11317     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode);
11318     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11319     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11320     return this;
11321 }
11322
11323 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11324 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11325 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_mode, 12)
11326 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_mode(
11327         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11328 {
11329     basic_stringstream_wchar_ctor_mode(this, mode, virt_init);
11330     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11331     return this;
11332 }
11333
11334 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11335 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11336 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor, 8)
11337 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor(
11338         basic_stringstream_wchar *this, MSVCP_bool virt_init)
11339 {
11340     return basic_stringstream_short_ctor_mode(
11341             this, OPENMODE_out|OPENMODE_in, virt_init);
11342 }
11343
11344 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11345 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11346 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11347 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11348 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_dtor, 4)
11349 void __thiscall basic_stringstream_wchar_dtor(basic_ios_wchar *base)
11350 {
11351     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11352
11353     TRACE("(%p)\n", this);
11354
11355     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
11356     basic_stringbuf_wchar_dtor(&this->strbuf);
11357 }
11358
11359 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11360 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11361 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11362 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11363 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vbase_dtor, 4)
11364 void __thiscall basic_stringstream_wchar_vbase_dtor(basic_stringstream_wchar *this)
11365 {
11366     TRACE("(%p)\n", this);
11367
11368     basic_stringstream_wchar_dtor(basic_stringstream_wchar_to_basic_ios(this));
11369     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
11370 }
11371
11372 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vector_dtor, 8)
11373 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11374 {
11375     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11376
11377     TRACE("(%p %x)\n", this, flags);
11378
11379     if(flags & 2) {
11380         /* we have an array, with the number of elements stored before the first object */
11381         INT_PTR i, *ptr = (INT_PTR *)this-1;
11382
11383         for(i=*ptr-1; i>=0; i--)
11384             basic_stringstream_wchar_vbase_dtor(this+i);
11385         MSVCRT_operator_delete(ptr);
11386     } else {
11387         basic_stringstream_wchar_vbase_dtor(this);
11388         if(flags & 1)
11389             MSVCRT_operator_delete(this);
11390     }
11391
11392     return this;
11393 }
11394
11395 /* ?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 */
11396 /* ?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 */
11397 /* ?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 */
11398 /* ?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 */
11399 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_rdbuf, 4)
11400 basic_stringbuf_wchar* __thiscall basic_stringstream_wchar_rdbuf(const basic_stringstream_wchar *this)
11401 {
11402     TRACE("(%p)\n", this);
11403     return (basic_stringbuf_wchar*)&this->strbuf;
11404 }
11405
11406 /* ?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 */
11407 /* ?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 */
11408 /* ?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 */
11409 /* ?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 */
11410 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_set, 8)
11411 void __thiscall basic_stringstream_wchar_str_set(basic_stringstream_wchar *this, const basic_string_wchar *str)
11412 {
11413     TRACE("(%p %p)\n", this, str);
11414     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11415 }
11416
11417 /* ?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 */
11418 /* ?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 */
11419 /* ?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 */
11420 /* ?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 */
11421 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_get, 8)
11422 basic_string_wchar* __thiscall basic_stringstream_wchar_str_get(const basic_stringstream_wchar *this, basic_string_wchar *ret)
11423 {
11424     TRACE("(%p %p)\n", this, ret);
11425     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11426 }
11427
11428 /* ?_Init@strstreambuf@std@@IAEXHPAD0H@Z */
11429 /* ?_Init@strstreambuf@std@@IEAAX_JPEAD1H@Z */
11430 DEFINE_THISCALL_WRAPPER(strstreambuf__Init, 20)
11431 void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g, char *p, int mode)
11432 {
11433     TRACE("(%p %ld %p %p %d)\n", this, len, g, p, mode);
11434
11435     this->minsize = 32;
11436     this->endsave = NULL;
11437     this->strmode = mode;
11438     this->palloc = NULL;
11439     this->pfree = NULL;
11440
11441     if(!g) {
11442         this->strmode |= STRSTATE_Dynamic;
11443         if(len > this->minsize)
11444             this->minsize = len;
11445         this->seekhigh = NULL;
11446         return;
11447     }
11448
11449     if(len < 0)
11450         len = INT_MAX;
11451     else if(!len)
11452         len = strlen(g);
11453
11454     this->seekhigh = g+len;
11455     basic_streambuf_char_setg(&this->base, g, g, p ? p : this->seekhigh);
11456     if(p)
11457         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
11458 }
11459
11460 /* ??0strstreambuf@std@@QAE@PACH0@Z */
11461 /* ??0strstreambuf@std@@QEAA@PEAC_J0@Z */
11462 /* ??0strstreambuf@std@@QAE@PADH0@Z */
11463 /* ??0strstreambuf@std@@QEAA@PEAD_J0@Z */
11464 /* ??0strstreambuf@std@@QAE@PAEH0@Z */
11465 /* ??0strstreambuf@std@@QEAA@PEAE_J0@Z */
11466 static strstreambuf* strstreambuf_ctor_get_put(strstreambuf *this, char *g, streamsize len, char *p)
11467 {
11468     TRACE("(%p %p %ld %p)\n", this, g, len, p);
11469
11470     basic_streambuf_char_ctor(&this->base);
11471     this->base.vtable = &MSVCP_strstreambuf_vtable;
11472
11473     strstreambuf__Init(this, len, g, p, 0);
11474     return this;
11475 }
11476
11477 /* ?_Tidy@strstreambuf@std@@IAEXXZ */
11478 /* ?_Tidy@strstreambuf@std@@IEAAXXZ */
11479 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
11480 void __thiscall strstreambuf__Tidy(strstreambuf *this)
11481 {
11482     TRACE("(%p)\n", this);
11483
11484     if((this->strmode & STRSTATE_Allocated) && !(this->strmode & STRSTATE_Frozen)) {
11485         if(this->pfree)
11486             this->pfree(basic_streambuf_char_eback(&this->base));
11487         else
11488             MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
11489     }
11490
11491     this->endsave = NULL;
11492     this->seekhigh = NULL;
11493     this->strmode &= ~(STRSTATE_Allocated | STRSTATE_Frozen);
11494     basic_streambuf_char_setg(&this->base, NULL, NULL, NULL);
11495     basic_streambuf_char_setp(&this->base, NULL, NULL);
11496 }
11497
11498 /* ??1strstreambuf@std@@UAE@XZ */
11499 /* ??1strstreambuf@std@@UEAA@XZ */
11500 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor, 4)
11501 void __thiscall strstreambuf_dtor(strstreambuf *this)
11502 {
11503     TRACE("(%p)\n", this);
11504
11505     strstreambuf__Tidy(this);
11506     basic_streambuf_char_dtor(&this->base);
11507 }
11508
11509 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor, 8)
11510 strstreambuf* __thiscall strstreambuf_vector_dtor(strstreambuf *this, unsigned int flags)
11511 {
11512     TRACE("(%p %x)\n", this, flags);
11513     if(flags & 2) {
11514         /* we have an array, with the number of elements stored before the first object */
11515         INT_PTR i, *ptr = (INT_PTR *)this-1;
11516
11517         for(i=*ptr-1; i>=0; i--)
11518             strstreambuf_dtor(this+i);
11519         MSVCRT_operator_delete(ptr);
11520     } else {
11521         strstreambuf_dtor(this);
11522         if(flags & 1)
11523             MSVCRT_operator_delete(this);
11524     }
11525
11526     return this;
11527 }
11528
11529 /* ?freeze@strstreambuf@std@@QAEX_N@Z */
11530 /* ?freeze@strstreambuf@std@@QEAAX_N@Z */
11531 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze, 8)
11532 void __thiscall strstreambuf_freeze(strstreambuf *this, MSVCP_bool freeze)
11533 {
11534     TRACE("(%p %d)\n", this, freeze);
11535
11536     if(!freeze == !(this->strmode *STRSTATE_Frozen))
11537         return;
11538
11539     if(freeze) {
11540         this->strmode |= STRSTATE_Frozen;
11541         this->endsave = basic_streambuf_char_epptr(&this->base);
11542         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11543                 basic_streambuf_char_pptr(&this->base), basic_streambuf_char_eback(&this->base));
11544     }else {
11545         this->strmode &= ~STRSTATE_Frozen;
11546         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11547                 basic_streambuf_char_pptr(&this->base), this->endsave);
11548     }
11549 }
11550
11551 /* ?overflow@strstreambuf@std@@MAEHH@Z */
11552 /* ?overflow@strstreambuf@std@@MEAAHH@Z */
11553 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow, 8)
11554 int __thiscall strstreambuf_overflow(strstreambuf *this, int c)
11555 {
11556     MSVCP_size_t old_size, size;
11557     char *ptr, *buf;
11558
11559     TRACE("(%p %d)\n", this, c);
11560
11561     if(c == EOF)
11562         return !EOF;
11563
11564     if(this->strmode & STRSTATE_Frozen)
11565         return EOF;
11566
11567     ptr = basic_streambuf_char_pptr(&this->base);
11568     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
11569         return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11570
11571     if(!(this->strmode & STRSTATE_Dynamic) || (this->strmode & STRSTATE_Constant))
11572         return EOF;
11573
11574     ptr = basic_streambuf_char_eback(&this->base);
11575     old_size = ptr ? basic_streambuf_char_epptr(&this->base) - ptr : 0;
11576
11577     size = old_size + old_size/2;
11578     if(size < this->minsize)
11579         size = this->minsize;
11580
11581     if(this->palloc)
11582         buf = this->palloc(size);
11583     else
11584         buf = MSVCRT_operator_new(size);
11585     if(!buf)
11586         return EOF;
11587
11588     memcpy(buf, ptr, old_size);
11589     if(this->strmode & STRSTATE_Allocated) {
11590         if(this->pfree)
11591             this->pfree(ptr);
11592         else
11593             MSVCRT_operator_delete(ptr);
11594     }
11595
11596     this->strmode |= STRSTATE_Allocated;
11597     if(!old_size) {
11598         this->seekhigh = buf;
11599         basic_streambuf_char_setp(&this->base, buf, buf+size);
11600         basic_streambuf_char_setg(&this->base, buf, buf, buf);
11601     }else {
11602         this->seekhigh = this->seekhigh-ptr+buf;
11603         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base)-ptr+buf,
11604                 basic_streambuf_char_pptr(&this->base)-ptr+buf, buf+size);
11605         basic_streambuf_char_setg(&this->base, buf, basic_streambuf_char_gptr(&this->base)-ptr+buf,
11606                 basic_streambuf_char_pptr(&this->base));
11607     }
11608
11609     return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11610 }
11611
11612 /* ?pbackfail@strstreambuf@std@@MAEHH@Z */
11613 /* ?pbackfail@strstreambuf@std@@MEAAHH@Z */
11614 DEFINE_THISCALL_WRAPPER(strstreambuf_pbackfail, 8)
11615 int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c)
11616 {
11617     char *ptr = basic_streambuf_char_gptr(&this->base);
11618
11619     TRACE("(%p %d)\n", this, c);
11620
11621     if(ptr<=basic_streambuf_char_eback(&this->base)
11622             || ((this->strmode & STRSTATE_Constant) && c!=ptr[-1]))
11623         return EOF;
11624
11625     basic_streambuf_char_gbump(&this->base, -1);
11626     if(c == EOF)
11627         return !EOF;
11628     if(this->strmode & STRSTATE_Constant)
11629         return (unsigned char)c;
11630
11631     return (unsigned char)(ptr[0] = c);
11632 }
11633
11634 /* ?seekoff@strstreambuf@std@@MAE?AV?$fpos@H@2@JHH@Z */
11635 /* ?seekoff@strstreambuf@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
11636 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20)
11637 fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode)
11638 {
11639     char *eback = basic_streambuf_char_eback(&this->base);
11640     char *pptr = basic_streambuf_char_pptr(&this->base);
11641     char *gptr = basic_streambuf_char_gptr(&this->base);
11642
11643     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
11644
11645     ret->off = 0;
11646     ret->state = 0;
11647
11648     if(pptr > this->seekhigh)
11649         this->seekhigh = pptr;
11650
11651     if((mode & OPENMODE_in) && gptr) {
11652         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
11653             off += gptr-eback;
11654         else if(way == SEEKDIR_end)
11655             off += this->seekhigh-eback;
11656         else if(way != SEEKDIR_beg)
11657             off = -1;
11658
11659         if(off<0 || off>this->seekhigh-eback) {
11660             off = -1;
11661         }else {
11662             basic_streambuf_char_gbump(&this->base, eback-gptr+off);
11663             if((mode & OPENMODE_out) && pptr) {
11664                 basic_streambuf_char_setp_next(&this->base, eback,
11665                         gptr, basic_streambuf_char_epptr(&this->base));
11666             }
11667         }
11668     }else if((mode & OPENMODE_out) && pptr) {
11669         if(way == SEEKDIR_cur)
11670             off += pptr-eback;
11671         else if(way == SEEKDIR_end)
11672             off += this->seekhigh-eback;
11673         else if(way != SEEKDIR_beg)
11674             off = -1;
11675
11676          if(off<0 || off>this->seekhigh-eback)
11677              off = -1;
11678          else
11679              basic_streambuf_char_pbump(&this->base, eback-pptr+off);
11680     }else {
11681         off = -1;
11682     }
11683
11684     ret->pos = off;
11685     return ret;
11686 }
11687
11688 /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */
11689 /* ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
11690 DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36)
11691 fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode)
11692 {
11693     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
11694
11695     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
11696         *ret = pos;
11697         return ret;
11698     }
11699
11700     return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
11701 }
11702
11703 /* ?underflow@strstreambuf@std@@MAEHXZ */
11704 /* ?underflow@strstreambuf@std@@MEAAHXZ */
11705 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow, 4)
11706 int __thiscall strstreambuf_underflow(strstreambuf *this)
11707 {
11708     char *gptr = basic_streambuf_char_gptr(&this->base);
11709     char *pptr;
11710
11711     TRACE("(%p)\n", this);
11712
11713     if(!gptr)
11714         return EOF;
11715
11716     if(gptr < basic_streambuf_char_egptr(&this->base))
11717         return (unsigned char)(*gptr);
11718
11719     pptr = basic_streambuf_char_gptr(&this->base);
11720     if(pptr > this->seekhigh)
11721         this->seekhigh = pptr;
11722
11723     if(this->seekhigh <= gptr)
11724         return EOF;
11725
11726     basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base),
11727             gptr, this->seekhigh);
11728     return (unsigned char)(*gptr);
11729 }
11730
11731 static inline basic_ios_char* ostrstream_to_basic_ios(ostrstream *ptr)
11732 {
11733     return (basic_ios_char*)((char*)ptr+ostrstream_vbtable[1]);
11734 }
11735
11736 static inline ostrstream* ostrstream_from_basic_ios(basic_ios_char *ptr)
11737 {
11738     return (ostrstream*)((char*)ptr-ostrstream_vbtable[1]);
11739 }
11740
11741 /* ??0ostrstream@std@@QAE@PADHH@Z */
11742 DEFINE_THISCALL_WRAPPER(ostrstream_ctor, 20)
11743 ostrstream* __thiscall ostrstream_ctor(ostrstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
11744 {
11745     basic_ios_char *basic_ios;
11746
11747     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
11748
11749     if(virt_init) {
11750         this->base.vbtable = ostrstream_vbtable;
11751         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11752         basic_ios_char_ctor(basic_ios);
11753     }else {
11754         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11755     }
11756
11757     strstreambuf_ctor_get_put(&this->buf, buf, size,
11758             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
11759     basic_ostream_char_ctor(&this->base, &this->buf.base, FALSE, FALSE);
11760     basic_ios->base.vtable = &MSVCP_ostrstream_vtable;
11761     return this;
11762 }
11763
11764 /* ??1ostrstream@std@@UAE@XZ */
11765 /* ??1ostrstream@std@@UEAA@XZ */
11766 DEFINE_THISCALL_WRAPPER(ostrstream_dtor, 4)
11767 void __thiscall ostrstream_dtor(basic_ios_char *base)
11768 {
11769     ostrstream *this = ostrstream_from_basic_ios(base);
11770
11771     TRACE("(%p)\n", this);
11772
11773     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
11774     strstreambuf_dtor(&this->buf);
11775 }
11776
11777 static void ostrstream_vbase_dtor(ostrstream *this)
11778 {
11779     TRACE("(%p)\n", this);
11780
11781     ostrstream_dtor(ostrstream_to_basic_ios(this));
11782     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
11783 }
11784
11785 DEFINE_THISCALL_WRAPPER(ostrstream_vector_dtor, 8)
11786 ostrstream* __thiscall ostrstream_vector_dtor(basic_ios_char *base, unsigned int flags)
11787 {
11788     ostrstream *this = ostrstream_from_basic_ios(base);
11789
11790     TRACE("(%p %x)\n", this, flags);
11791
11792     if(flags & 2) {
11793         /* we have an array, with the number of elements stored before the first object */
11794         INT_PTR i, *ptr = (INT_PTR *)this-1;
11795
11796         for(i=*ptr-1; i>=0; i--)
11797             ostrstream_vbase_dtor(this+i);
11798         MSVCRT_operator_delete(ptr);
11799     } else {
11800         ostrstream_vbase_dtor(this);
11801         if(flags & 1)
11802             MSVCRT_operator_delete(this);
11803     }
11804
11805     return this;
11806 }
11807
11808 static inline istrstream* istrstream_from_basic_ios(basic_ios_char *ptr)
11809 {
11810     return (istrstream*)((char*)ptr-istrstream_vbtable[1]);
11811 }
11812
11813 /* ??1istrstream@std@@UAE@XZ */
11814 /* ??1istrstream@std@@UEAA@XZ */
11815 DEFINE_THISCALL_WRAPPER(istrstream_dtor, 4)
11816 void __thiscall istrstream_dtor(basic_ios_char *base)
11817 {
11818     istrstream *this = istrstream_from_basic_ios(base);
11819
11820     TRACE("(%p)\n", this);
11821
11822     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11823     strstreambuf_dtor(&this->buf);
11824 }
11825
11826 static inline basic_ios_char* strstream_to_basic_ios(strstream *ptr)
11827 {
11828     return (basic_ios_char*)((char*)ptr+strstream_vbtable1[1]);
11829 }
11830
11831 static inline strstream* strstream_from_basic_ios(basic_ios_char *ptr)
11832 {
11833     return (strstream*)((char*)ptr-strstream_vbtable1[1]);
11834 }
11835
11836 /* ??0strstream@std@@QAE@PADHH@Z */
11837 /* ??0strstream@std@@QEAA@PEAD_JH@Z */
11838 DEFINE_THISCALL_WRAPPER(strstream_ctor, 20)
11839 strstream* __thiscall strstream_ctor(strstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
11840 {
11841     basic_ios_char *basic_ios;
11842
11843     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
11844
11845     if(virt_init) {
11846         this->base.base1.vbtable = strstream_vbtable1;
11847         this->base.base2.vbtable = strstream_vbtable2;
11848         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11849         basic_ios_char_ctor(basic_ios);
11850     }else {
11851         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11852     }
11853
11854     strstreambuf_ctor_get_put(&this->buf, buf, size,
11855             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
11856     basic_iostream_char_ctor(&this->base, &this->buf.base, FALSE);
11857     basic_ios->base.vtable = &MSVCP_strstream_vtable;
11858     return this;
11859 }
11860
11861 /* ??1strstream@std@@UAE@XZ */
11862 /* ??1strstream@std@@UEAA@XZ */
11863 DEFINE_THISCALL_WRAPPER(strstream_dtor, 4)
11864 void __thiscall strstream_dtor(basic_ios_char *base)
11865 {
11866     strstream *this = strstream_from_basic_ios(base);
11867
11868     TRACE("(%p)\n", this);
11869
11870     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11871     strstreambuf_dtor(&this->buf);
11872 }
11873
11874 static void strstream_vbase_dtor(strstream *this)
11875 {
11876     TRACE("(%p)\n", this);
11877
11878     strstream_dtor(strstream_to_basic_ios(this));
11879     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11880 }
11881
11882 DEFINE_THISCALL_WRAPPER(strstream_vector_dtor, 8)
11883 strstream* __thiscall strstream_vector_dtor(basic_ios_char *base, unsigned int flags)
11884 {
11885     strstream *this = strstream_from_basic_ios(base);
11886
11887     TRACE("(%p %x)\n", this, flags);
11888
11889     if(flags & 2) {
11890         /* we have an array, with the number of elements stored before the first object */
11891         INT_PTR i, *ptr = (INT_PTR *)this-1;
11892
11893         for(i=*ptr-1; i>=0; i--)
11894             strstream_vbase_dtor(this+i);
11895         MSVCRT_operator_delete(ptr);
11896     } else {
11897         strstream_vbase_dtor(this);
11898         if(flags & 1)
11899             MSVCRT_operator_delete(this);
11900     }
11901
11902     return this;
11903 }
11904
11905 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
11906 {
11907     ios_base_precision_set(base, prec);
11908 }
11909
11910 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
11911 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
11912 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
11913 {
11914     TRACE("(%p %ld)\n", ret, prec);
11915
11916     ret->pfunc = setprecision_func;
11917     ret->arg = prec;
11918     return ret;
11919 }
11920
11921 static void __cdecl setw_func(ios_base *base, streamsize width)
11922 {
11923     ios_base_width_set(base, width);
11924 }
11925
11926 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
11927 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
11928 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
11929 {
11930     TRACE("(%p %ld)\n", ret, width);
11931
11932     ret->pfunc = setw_func;
11933     ret->arg = width;
11934     return ret;
11935 }
11936
11937 static void __cdecl resetioflags_func(ios_base *base, int mask)
11938 {
11939     ios_base_setf_mask(base, 0, mask);
11940 }
11941
11942 /* ?resetiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
11943 manip_int* __cdecl resetiosflags(manip_int *ret, int mask)
11944 {
11945     TRACE("(%p %d)\n", ret, mask);
11946
11947     ret->pfunc = resetioflags_func;
11948     ret->arg = mask;
11949     return ret;
11950 }
11951
11952 static void __cdecl setiosflags_func(ios_base *base, int mask)
11953 {
11954     ios_base_setf_mask(base, FMTFLAG_mask, mask);
11955 }
11956
11957 /* ?setiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
11958 manip_int* __cdecl setiosflags(manip_int *ret, int mask)
11959 {
11960     TRACE("(%p %d)\n", ret, mask);
11961
11962     ret->pfunc = setiosflags_func;
11963     ret->arg = mask;
11964     return ret;
11965 }
11966
11967 static void __cdecl setbase_func(ios_base *base, int set_base)
11968 {
11969     if(set_base == 10)
11970         set_base = FMTFLAG_dec;
11971     else if(set_base == 8)
11972         set_base = FMTFLAG_oct;
11973     else if(set_base == 16)
11974         set_base = FMTFLAG_hex;
11975     else
11976         set_base = 0;
11977
11978     ios_base_setf_mask(base, set_base, FMTFLAG_basefield);
11979 }
11980
11981 /* ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z */
11982 manip_int* __cdecl setbase(manip_int *ret, int base)
11983 {
11984     TRACE("(%p %d)\n", ret, base);
11985
11986     ret->pfunc = setbase_func;
11987     ret->arg = base;
11988     return ret;
11989 }
11990
11991 static basic_filebuf_char filebuf_char_stdin;
11992 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
11993 struct {
11994     basic_istream_char obj;
11995     basic_ios_char vbase;
11996 } cin = { { 0 } };
11997 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
11998 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
11999 basic_istream_char *_Ptr_cin = &cin.obj;
12000
12001 static basic_filebuf_wchar filebuf_short_stdin;
12002 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
12003 struct {
12004     basic_istream_wchar obj;
12005     basic_ios_wchar vbase;
12006 } ucin = { { 0 } };
12007 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
12008 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
12009 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
12010
12011 static basic_filebuf_wchar filebuf_wchar_stdin;
12012 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12013 struct {
12014     basic_istream_wchar obj;
12015     basic_ios_wchar vbase;
12016 } wcin = { { 0 } };
12017 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12018 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
12019 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
12020
12021 static basic_filebuf_char filebuf_char_stdout;
12022 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12023 struct {
12024     basic_ostream_char obj;
12025     basic_ios_char vbase;
12026 } cout = { { 0 } };
12027 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12028 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12029 basic_ostream_char *_Ptr_cout = &cout.obj;
12030
12031 static basic_filebuf_wchar filebuf_short_stdout;
12032 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12033 struct {
12034     basic_ostream_wchar obj;
12035     basic_ios_wchar vbase;
12036 } ucout = { { 0 } };
12037 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12038 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12039 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
12040
12041 static basic_filebuf_wchar filebuf_wchar_stdout;
12042 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12043 struct {
12044     basic_ostream_wchar obj;
12045     basic_ios_wchar vbase;
12046 } wcout = { { 0 } };
12047 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12048 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12049 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
12050
12051 static basic_filebuf_char filebuf_char_stderr;
12052 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12053 struct {
12054     basic_ostream_char obj;
12055     basic_ios_char vbase;
12056 } cerr = { { 0 } };
12057 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12058 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12059 basic_ostream_char *_Ptr_cerr = &cerr.obj;
12060
12061 static basic_filebuf_wchar filebuf_short_stderr;
12062 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12063 struct {
12064     basic_ostream_wchar obj;
12065     basic_ios_wchar vbase;
12066 } ucerr = { { 0 } };
12067 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12068 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12069 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
12070
12071 static basic_filebuf_wchar filebuf_wchar_stderr;
12072 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12073 struct {
12074     basic_ostream_wchar obj;
12075     basic_ios_wchar vbase;
12076 } wcerr = { { 0 } };
12077 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12078 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12079 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
12080
12081 static basic_filebuf_char filebuf_char_log;
12082 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12083 struct {
12084     basic_ostream_char obj;
12085     basic_ios_char vbase;
12086 } clog = { { 0 } };
12087 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12088 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12089 basic_ostream_char *_Ptr_clog = &clog.obj;
12090
12091 static basic_filebuf_wchar filebuf_short_log;
12092 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12093 struct {
12094     basic_ostream_wchar obj;
12095     basic_ios_wchar vbase;
12096 } uclog = { { 0 } };
12097 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12098 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12099 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
12100
12101 static basic_filebuf_wchar filebuf_wchar_log;
12102 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12103 struct {
12104     basic_ostream_wchar obj;
12105     basic_ios_wchar vbase;
12106 } wclog = { { 0 } };
12107 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12108 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12109 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
12110
12111 /* ?_Init_cnt@Init@ios_base@std@@0HA */
12112 int ios_base_Init__Init_cnt = -1;
12113
12114 /* ?_Init_ctor@Init@ios_base@std@@CAXPAV123@@Z */
12115 /* ?_Init_ctor@Init@ios_base@std@@CAXPEAV123@@Z */
12116 static void ios_base_Init__Init_ctor(void *this)
12117 {
12118     TRACE("(%p)\n", this);
12119
12120     if(ios_base_Init__Init_cnt < 0)
12121         ios_base_Init__Init_cnt = 1;
12122     else
12123         ios_base_Init__Init_cnt++;
12124 }
12125
12126 /* ??0Init@ios_base@std@@QAE@XZ */
12127 /* ??0Init@ios_base@std@@QEAA@XZ */
12128 DEFINE_THISCALL_WRAPPER(ios_base_Init_ctor, 4)
12129 void* __thiscall ios_base_Init_ctor(void *this)
12130 {
12131     ios_base_Init__Init_ctor(this);
12132     return this;
12133 }
12134
12135 /* ?_Init_dtor@Init@ios_base@std@@CAXPAV123@@Z */
12136 /* ?_Init_dtor@Init@ios_base@std@@CAXPEAV123@@Z */
12137 static void ios_base_Init__Init_dtor(void *this)
12138 {
12139     TRACE("(%p)\n", this);
12140
12141     ios_base_Init__Init_cnt--;
12142     if(!ios_base_Init__Init_cnt) {
12143         basic_ostream_char_flush(&cout.obj);
12144         basic_ostream_char_flush(&cerr.obj);
12145         basic_ostream_char_flush(&clog.obj);
12146     }
12147 }
12148
12149 /* ??1Init@ios_base@std@@QAE@XZ */
12150 /* ??1Init@ios_base@std@@QEAA@XZ */
12151 DEFINE_THISCALL_WRAPPER(ios_base_Init_dtor, 4)
12152 void __thiscall ios_base_Init_dtor(void *this)
12153 {
12154     ios_base_Init__Init_dtor(this);
12155 }
12156
12157 /* ??4Init@ios_base@std@@QAEAAV012@ABV012@@Z */
12158 /* ??4Init@ios_base@std@@QEAAAEAV012@AEBV012@@Z */
12159 DEFINE_THISCALL_WRAPPER(ios_base_Init_op_assign, 8)
12160 void* __thiscall ios_base_Init_op_assign(void *this, void *rhs)
12161 {
12162     TRACE("(%p %p)\n", this, rhs);
12163     return this;
12164 }
12165
12166 /* ?_Init_cnt@_Winit@std@@0HA */
12167 int _Winit__Init_cnt = -1;
12168
12169 /* ??0_Winit@std@@QAE@XZ */
12170 /* ??0_Winit@std@@QEAA@XZ */
12171 DEFINE_THISCALL_WRAPPER(_Winit_ctor, 4)
12172 void* __thiscall _Winit_ctor(void *this)
12173 {
12174     TRACE("(%p)\n", this);
12175
12176     if(_Winit__Init_cnt < 0)
12177         _Winit__Init_cnt = 1;
12178     else
12179         _Winit__Init_cnt++;
12180
12181     return this;
12182 }
12183
12184 /* ??1_Winit@std@@QAE@XZ */
12185 /* ??1_Winit@std@@QAE@XZ */
12186 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)
12187 void __thiscall _Winit_dtor(void *this)
12188 {
12189     TRACE("(%p)\n", this);
12190
12191     _Winit__Init_cnt--;
12192     if(!_Winit__Init_cnt) {
12193         basic_ostream_wchar_flush(&wcout.obj);
12194         basic_ostream_wchar_flush(&wcerr.obj);
12195         basic_ostream_wchar_flush(&wclog.obj);
12196     }
12197 }
12198
12199 /* ??4_Winit@std@@QAEAAV01@ABV01@@Z */
12200 /* ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z */
12201 DEFINE_THISCALL_WRAPPER(_Winit_op_assign, 8)
12202 void* __thiscall _Winit_op_assign(void *this, void *rhs)
12203 {
12204     TRACE("(%p %p)\n", this, rhs);
12205     return this;
12206 }
12207
12208 void init_io(void *base)
12209 {
12210 #ifdef __x86_64__
12211     init_iosb_rtti(base);
12212     init_ios_base_rtti(base);
12213     init_basic_ios_char_rtti(base);
12214     init_basic_ios_wchar_rtti(base);
12215     init_basic_ios_short_rtti(base);
12216     init_basic_streambuf_char_rtti(base);
12217     init_basic_streambuf_wchar_rtti(base);
12218     init_basic_streambuf_short_rtti(base);
12219     init_basic_filebuf_char_rtti(base);
12220     init_basic_filebuf_wchar_rtti(base);
12221     init_basic_filebuf_short_rtti(base);
12222     init_basic_stringbuf_char_rtti(base);
12223     init_basic_stringbuf_wchar_rtti(base);
12224     init_basic_stringbuf_short_rtti(base);
12225     init_basic_ostream_char_rtti(base);
12226     init_basic_ostream_wchar_rtti(base);
12227     init_basic_ostream_short_rtti(base);
12228     init_basic_istream_char_rtti(base);
12229     init_basic_istream_wchar_rtti(base);
12230     init_basic_istream_short_rtti(base);
12231     init_basic_iostream_char_rtti(base);
12232     init_basic_iostream_wchar_rtti(base);
12233     init_basic_iostream_short_rtti(base);
12234     init_basic_ofstream_char_rtti(base);
12235     init_basic_ofstream_wchar_rtti(base);
12236     init_basic_ofstream_short_rtti(base);
12237     init_basic_ifstream_char_rtti(base);
12238     init_basic_ifstream_wchar_rtti(base);
12239     init_basic_ifstream_short_rtti(base);
12240     init_basic_fstream_char_rtti(base);
12241     init_basic_fstream_wchar_rtti(base);
12242     init_basic_fstream_short_rtti(base);
12243     init_basic_ostringstream_char_rtti(base);
12244     init_basic_ostringstream_wchar_rtti(base);
12245     init_basic_ostringstream_short_rtti(base);
12246     init_basic_istringstream_char_rtti(base);
12247     init_basic_istringstream_wchar_rtti(base);
12248     init_basic_istringstream_short_rtti(base);
12249     init_basic_stringstream_char_rtti(base);
12250     init_basic_stringstream_wchar_rtti(base);
12251     init_basic_stringstream_short_rtti(base);
12252     init_strstreambuf_rtti(base);
12253     init_strstream_rtti(base);
12254     init_ostrstream_rtti(base);
12255 #endif
12256
12257     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
12258     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
12259
12260     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
12261     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
12262
12263     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
12264     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
12265
12266     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
12267     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE);
12268
12269     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
12270     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE);
12271
12272     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
12273     basic_ostream_wchar_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE);
12274
12275     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
12276     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE);
12277
12278     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
12279     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE);
12280
12281     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
12282     basic_ostream_wchar_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE);
12283
12284     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
12285     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE);
12286
12287     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
12288     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE);
12289
12290     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
12291     basic_ostream_wchar_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE);
12292 }
12293
12294 void free_io(void)
12295 {
12296     basic_istream_char_vbase_dtor(&cin.obj);
12297     basic_filebuf_char_dtor(&filebuf_char_stdin);
12298
12299     basic_istream_wchar_vbase_dtor(&ucin.obj);
12300     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
12301
12302     basic_istream_wchar_vbase_dtor(&wcin.obj);
12303     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
12304
12305     basic_ostream_char_vbase_dtor(&cout.obj);
12306     basic_filebuf_char_dtor(&filebuf_char_stdout);
12307
12308     basic_ostream_wchar_vbase_dtor(&ucout.obj);
12309     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
12310
12311     basic_ostream_wchar_vbase_dtor(&wcout.obj);
12312     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
12313
12314     basic_ostream_char_vbase_dtor(&cerr.obj);
12315     basic_filebuf_char_dtor(&filebuf_char_stderr);
12316
12317     basic_ostream_wchar_vbase_dtor(&ucerr.obj);
12318     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
12319
12320     basic_ostream_wchar_vbase_dtor(&wcerr.obj);
12321     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
12322
12323     basic_ostream_char_vbase_dtor(&clog.obj);
12324     basic_filebuf_char_dtor(&filebuf_char_log);
12325
12326     basic_ostream_wchar_vbase_dtor(&uclog.obj);
12327     basic_filebuf_wchar_dtor(&filebuf_short_log);
12328
12329     basic_ostream_wchar_vbase_dtor(&wclog.obj);
12330     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
12331 }