winemac: Translate presence in Windows task bar to participation in Exposé and window...
[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     char *endsave;
279     char *seekhigh;
280     streamsize minsize;
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@JW4seekdir@ios_base@2@H@Z */
1264 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JW4seekdir@ios_base@2@H@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@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z */
1991 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JW4seekdir@ios_base@2@H@Z */
1992 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
1993 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1994         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1995 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
1996         fpos_int *ret, streamoff off, int way, int mode)
1997 {
1998     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1999     ret->off = -1;
2000     ret->pos = 0;
2001     ret->state = 0;
2002     return ret;
2003 }
2004
2005 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2006 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2007 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2008 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2009 static fpos_int* basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
2010         fpos_int *ret, streamoff off, int way, int mode)
2011 {
2012     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2013     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
2014 }
2015
2016 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2017 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2018 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2019 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2020 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
2021 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
2022         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
2023 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
2024         fpos_int *ret, fpos_int pos, int mode)
2025 {
2026     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2027     ret->off = -1;
2028     ret->pos = 0;
2029     ret->state = 0;
2030     return ret;
2031 }
2032
2033 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2034 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2035 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2036 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2037 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
2038 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
2039         fpos_int *ret, fpos_int pos, int mode)
2040 {
2041     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2042     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
2043 }
2044
2045 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
2046 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
2047 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
2048 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
2049 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
2050 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
2051         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
2052 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2053 {
2054     TRACE("(%p %p %ld)\n", this, buf, count);
2055     return this;
2056 }
2057
2058 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
2059 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
2060 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
2061 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
2062 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
2063 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2064 {
2065     TRACE("(%p %p %ld)\n", this, buf, count);
2066     return call_basic_streambuf_wchar_setbuf(this, buf, count);
2067 }
2068
2069 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2070 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2071 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2072 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2073 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
2074 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 44, \
2075         int, (basic_streambuf_wchar*), (this))
2076 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
2077 {
2078     TRACE("(%p)\n", this);
2079     return 0;
2080 }
2081
2082 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2083 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
2084 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2085 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
2086 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
2087 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
2088 {
2089     TRACE("(%p)\n", this);
2090     return call_basic_streambuf_wchar_sync(this);
2091 }
2092
2093 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
2094 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
2095 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
2096 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
2097 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
2098 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2099 {
2100     TRACE("(%p %p %ld)\n", this, ptr, count);
2101     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2102 }
2103
2104 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2105 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
2106 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2107 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
2108 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
2109 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
2110         streamsize, (basic_streambuf_wchar*), (this))
2111 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
2112 {
2113     TRACE("(%p)\n", this);
2114     return 0;
2115 }
2116
2117 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2118 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
2119 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2120 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
2121 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
2122 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
2123 {
2124     streamsize ret;
2125
2126     TRACE("(%p)\n", this);
2127
2128     ret = basic_streambuf_wchar__Gnavail(this);
2129     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
2130 }
2131
2132 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2133 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2134 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2135 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2136 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
2137 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
2138 {
2139     TRACE("(%p %d)\n", this, ch);
2140     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
2141         (*this->prsize)++;
2142         (*this->prpos)--;
2143         return ch;
2144     }
2145
2146     return call_basic_streambuf_wchar_pbackfail(this, ch);
2147 }
2148
2149 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2150 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2151 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2152 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
2153 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
2154 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
2155 {
2156     TRACE("(%p %d)\n", this, ch);
2157     return basic_streambuf_wchar__Pnavail(this) ?
2158         (*basic_streambuf_wchar__Pninc(this) = ch) :
2159         call_basic_streambuf_wchar_overflow(this, ch);
2160 }
2161
2162 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2163 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2164 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2165 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2166 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
2167 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
2168 {
2169     TRACE("(%p)\n", this);
2170     if(*this->prpos && *this->prpos>*this->prbuf) {
2171         (*this->prsize)++;
2172         (*this->prpos)--;
2173         return **this->prpos;
2174     }
2175
2176     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
2177 }
2178
2179 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2180 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2181 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2182 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2183 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
2184 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
2185 {
2186     TRACE("(%p)\n", this);
2187     if(basic_streambuf_wchar__Gnavail(this))
2188         basic_streambuf_wchar__Gninc(this);
2189     else
2190         call_basic_streambuf_wchar_uflow(this);
2191 }
2192
2193 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2194 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2195 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2196 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2197 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
2198 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
2199 {
2200     TRACE("(%p)\n", this);
2201     return basic_streambuf_wchar__Gnavail(this) ?
2202         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
2203 }
2204
2205 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2206 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2207 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2208 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2209 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
2210 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
2211 {
2212     TRACE("(%p)\n", this);
2213     return basic_streambuf_wchar__Gnavail(this) ?
2214         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
2215 }
2216
2217 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2218 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2219 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2220 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2221 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
2222 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
2223 {
2224     TRACE("(%p)\n", this);
2225
2226     if(basic_streambuf_wchar__Gnavail(this) > 1)
2227         return *basic_streambuf_wchar__Gnpreinc(this);
2228     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
2229         WEOF : basic_streambuf_wchar_sgetc(this);
2230 }
2231
2232 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
2233 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
2234 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
2235 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
2236 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
2237 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
2238         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
2239 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2240 {
2241     TRACE("(%p %p %ld)\n", this, ptr, count);
2242     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
2243 }
2244
2245 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
2246 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
2247 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
2248 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
2249 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
2250 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
2251         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
2252 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2253 {
2254     streamsize copied, chunk;
2255
2256     TRACE("(%p %p %ld)\n", this, ptr, count);
2257
2258     for(copied=0; copied<count;) {
2259         chunk = basic_streambuf_wchar__Pnavail(this);
2260         if(chunk > count-copied)
2261             chunk = count-copied;
2262
2263         if(chunk > 0) {
2264             memcpy(*this->pwpos, ptr+copied, chunk*sizeof(wchar_t));
2265             *this->pwpos += chunk;
2266             *this->pwsize -= chunk;
2267             copied += chunk;
2268         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
2269             copied++;
2270         }else {
2271             break;
2272         }
2273     }
2274
2275     return copied;
2276 }
2277
2278 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
2279 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
2280 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
2281 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
2282 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
2283 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2284 {
2285     TRACE("(%p %p %ld)\n", this, ptr, count);
2286     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
2287 }
2288
2289 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@XZ */
2290 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@XZ */
2291 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
2292 locale* __thiscall basic_streambuf_wchar_getloc(basic_streambuf_wchar *this, locale *ret)
2293 {
2294     TRACE("(%p %p)\n", this, ret);
2295     return locale_copy_ctor(ret, &this->loc);
2296 }
2297
2298 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2299 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2300 int basic_filebuf_char__Init__Stinit = 0;
2301
2302 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2303 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2304 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
2305 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
2306 {
2307     TRACE("(%p %p %d)\n", this, file, which);
2308
2309     this->cvt = NULL;
2310     this->state0 = basic_filebuf_char__Init__Stinit;
2311     this->state = basic_filebuf_char__Init__Stinit;
2312     this->str = NULL;
2313     this->close = (which == INITFL_open);
2314     this->file = file;
2315
2316     basic_streambuf_char__Init_empty(&this->base);
2317     if(file)
2318         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
2319                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
2320 }
2321
2322 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
2323 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
2324 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Initcvt, 4)
2325 void __thiscall basic_filebuf_char__Initcvt(basic_filebuf_char *this)
2326 {
2327     TRACE("(%p)\n", this);
2328
2329     this->cvt = codecvt_char_use_facet(&this->base.loc);
2330     locale__Addfac(&this->loc, &this->cvt->base.facet, codecvt_char_id.id, LC_CTYPE);
2331     if(codecvt_base_always_noconv(&this->cvt->base)) {
2332         this->cvt = NULL;
2333     }else {
2334         this->str = MSVCRT_operator_new(sizeof(basic_string_char));
2335         basic_string_char_ctor(this->str);
2336     }
2337 }
2338
2339 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2340 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2341 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2342 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2343 {
2344     basic_filebuf_char *ret = this;
2345
2346     TRACE("(%p)\n", this);
2347
2348     if(!this->file || fclose(this->file))
2349         return NULL;
2350
2351     basic_filebuf_char__Init(this, NULL, INITFL_close);
2352     return ret;
2353 }
2354
2355 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2356 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2357 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2358 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2359 {
2360     TRACE("(%p %p)\n", this, file);
2361
2362     basic_streambuf_char_ctor(&this->base);
2363     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2364
2365     locale_ctor(&this->loc);
2366     basic_filebuf_char__Init(this, file, INITFL_new);
2367     return this;
2368 }
2369
2370 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2371 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2372 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2373 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2374 {
2375     return basic_filebuf_char_ctor_file(this, NULL);
2376 }
2377
2378 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2379 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2380 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2381 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2382 {
2383     TRACE("(%p %d)\n", this, uninitialized);
2384
2385     basic_streambuf_char_ctor_uninitialized(&this->base, 0);
2386     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2387     locale_ctor(&this->loc);
2388     return this;
2389 }
2390
2391 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2392 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2393 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2394 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2395 {
2396     TRACE("(%p)\n", this);
2397
2398     if(this->close)
2399         basic_filebuf_char_close(this);
2400     if(this->str) {
2401         basic_string_char_dtor(this->str);
2402         MSVCRT_operator_delete(this->str);
2403     }
2404     locale_dtor(&this->loc);
2405     basic_streambuf_char_dtor(&this->base);
2406 }
2407
2408 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2409 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2410 {
2411     TRACE("(%p %x)\n", this, flags);
2412     if(flags & 2) {
2413         /* we have an array, with the number of elements stored before the first object */
2414         INT_PTR i, *ptr = (INT_PTR *)this-1;
2415
2416         for(i=*ptr-1; i>=0; i--)
2417             basic_filebuf_char_dtor(this+i);
2418         MSVCRT_operator_delete(ptr);
2419     } else {
2420         basic_filebuf_char_dtor(this);
2421         if(flags & 1)
2422             MSVCRT_operator_delete(this);
2423     }
2424
2425     return this;
2426 }
2427
2428 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2429 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2430 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2431 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2432 {
2433     TRACE("(%p)\n", this);
2434     return this->file != NULL;
2435 }
2436
2437 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2438 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2439 static FILE* _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2440 {
2441     static const wchar_t rW[] = {'r',0};
2442     static const struct {
2443         int mode;
2444         const wchar_t str[4];
2445         const wchar_t str_bin[4];
2446     } str_mode[] = {
2447         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2448         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2449         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2450         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2451         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2452         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2453         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2454         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2455         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2456     };
2457
2458     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2459     int mode_idx;
2460     FILE *f = NULL;
2461
2462     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2463
2464     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2465         if(str_mode[mode_idx].mode == real_mode)
2466             break;
2467     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2468         return NULL;
2469
2470     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2471         return NULL;
2472     else if(f)
2473         fclose(f);
2474
2475     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2476             && (f = _wfopen(name, rW))) {
2477         fclose(f);
2478         return NULL;
2479     }
2480
2481     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2482             : str_mode[mode_idx].str, prot);
2483     if(!f)
2484         return NULL;
2485
2486     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2487         fclose(f);
2488         return NULL;
2489     }
2490
2491     return f;
2492 }
2493
2494 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2495 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2496 static FILE* _Fiopen(const char *name, int mode, int prot)
2497 {
2498     wchar_t nameW[FILENAME_MAX];
2499
2500     TRACE("(%s %d %d)\n", name, mode, prot);
2501
2502     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2503         return NULL;
2504     return _Fiopen_wchar(nameW, mode, prot);
2505 }
2506
2507 /* ?__Fiopen@std@@YAPAU_iobuf@@PBDH@Z */
2508 /* ?__Fiopen@std@@YAPEAU_iobuf@@PEBDH@Z */
2509 FILE* __cdecl ___Fiopen(const char *name, int mode)
2510 {
2511     TRACE("(%p %d)\n", name, mode);
2512     return _Fiopen(name, mode, _SH_DENYNO);
2513 }
2514
2515 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2516 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2517 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2518 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2519 static basic_filebuf_char* basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2520 {
2521     FILE *f = NULL;
2522
2523     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2524
2525     if(basic_filebuf_char_is_open(this))
2526         return NULL;
2527
2528     if(!(f = _Fiopen_wchar(name, mode, prot)))
2529         return NULL;
2530
2531     basic_filebuf_char__Init(this, f, INITFL_open);
2532     basic_filebuf_char__Initcvt(this);
2533     return this;
2534 }
2535
2536 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2537 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2538 static basic_filebuf_char* basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2539 {
2540     wchar_t nameW[FILENAME_MAX];
2541
2542     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2543
2544     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2545         return NULL;
2546     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2547 }
2548
2549 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDF@Z */
2550 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDF@Z */
2551 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode_old, 12)
2552 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode_old(basic_filebuf_char *this, const char *name, short mode)
2553 {
2554     TRACE("(%p %p %d)\n", this, name, mode);
2555     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2556 }
2557
2558 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDH@Z */
2559 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDH@Z */
2560 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2561 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, int mode)
2562 {
2563     TRACE("(%p %p %d)\n", this, name, mode);
2564     return basic_filebuf_char_open(this, name, mode, _SH_DENYNO);
2565 }
2566
2567 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2568 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2569 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2570 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2571 {
2572     char *ptr, ch = c, *to_next;
2573     const char *from_next;
2574     int ret;
2575
2576
2577     TRACE("(%p %d)\n", this, c);
2578
2579     if(!basic_filebuf_char_is_open(this))
2580         return EOF;
2581     if(c == EOF)
2582         return !c;
2583
2584     if(!this->cvt)
2585         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2586
2587     from_next = &ch;
2588     basic_string_char_clear(this->str);
2589     basic_string_char_append_len_ch(this->str, 8, '\0');
2590     ptr = this->str->ptr;
2591     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1, &from_next,
2592             ptr, ptr+basic_string_char_length(this->str), &to_next);
2593
2594     switch(ret) {
2595     case CODECVT_partial:
2596         if(from_next == &ch)
2597             return EOF;
2598     case CODECVT_ok:
2599         if(!fwrite(ptr, to_next-ptr, 1, this->file))
2600             return EOF;
2601         return c;
2602     case CODECVT_noconv:
2603         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2604     default:
2605         return EOF;
2606     }
2607 }
2608
2609 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2610 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2611 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2612 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2613 {
2614     TRACE("(%p %d)\n", this, c);
2615
2616     if(!basic_filebuf_char_is_open(this))
2617         return EOF;
2618
2619     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2620             && (c==EOF || (int)(unsigned char)basic_streambuf_char_gptr(&this->base)[-1]==c)) {
2621         basic_streambuf_char__Gndec(&this->base);
2622         return c==EOF ? !c : c;
2623     }else if(c == EOF) {
2624         return EOF;
2625     }else if(!this->cvt) {
2626         return ungetc(c, this->file);
2627     }else if(basic_string_char_length(this->str)) {
2628         char *b, *e, *cur;
2629
2630         e = this->str->ptr;
2631         b = e+this->str->size-1;
2632         for(cur = b; cur>=e; cur--) {
2633             if(ungetc(*cur, this->file) == EOF) {
2634                 for(; cur<=b; cur++)
2635                     fgetc(this->file);
2636                 return EOF;
2637             }
2638         }
2639         basic_string_char_clear(this->str);
2640         this->state = this->state0;
2641         return c;
2642     }
2643
2644     return EOF;
2645 }
2646
2647 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2648 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2649 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2650 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2651 {
2652     char ch, *to_next;
2653     const char *buf_next;
2654     int c;
2655
2656     TRACE("(%p)\n", this);
2657
2658     if(!basic_filebuf_char_is_open(this))
2659         return EOF;
2660
2661     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2662         return (unsigned char)*basic_streambuf_char__Gninc(&this->base);
2663
2664     c = fgetc(this->file);
2665     if(!this->cvt || c==EOF)
2666         return c;
2667
2668     basic_string_char_clear(this->str);
2669     this->state0 = this->state;
2670     while(1) {
2671         basic_string_char_append_ch(this->str, c);
2672         this->state = this->state0;
2673
2674         switch(codecvt_char_in(this->cvt, &this->state, this->str->ptr,
2675                     this->str->ptr+this->str->size, &buf_next, &ch, &ch+1, &to_next)) {
2676         case CODECVT_partial:
2677             break;
2678         case CODECVT_noconv:
2679             return (unsigned char)this->str->ptr[0];
2680         case CODECVT_ok:
2681             return (unsigned char)ch;
2682         default:
2683             return EOF;
2684         }
2685
2686         c = fgetc(this->file);
2687         if(c == EOF)
2688             return EOF;
2689     }
2690 }
2691
2692 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2693 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2694 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2695 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2696 {
2697     int ret;
2698
2699     TRACE("(%p)\n", this);
2700
2701     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2702         return (unsigned char)*basic_streambuf_char_gptr(&this->base);
2703
2704     ret = call_basic_streambuf_char_uflow(&this->base);
2705     if(ret != EOF)
2706         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2707     return ret;
2708 }
2709
2710 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z */
2711 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JW4seekdir@ios_base@2@H@Z */
2712 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2713 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2714         fpos_int *ret, streamoff off, int way, int mode)
2715 {
2716     fpos_t pos;
2717
2718     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2719
2720     if(!basic_filebuf_char_is_open(this) || fseek(this->file, off, way)) {
2721         ret->off = -1;
2722         ret->pos = 0;
2723         ret->state = 0;
2724         return ret;
2725     }
2726
2727     fgetpos(this->file, &pos);
2728     ret->off = 0;
2729     ret->pos = pos;
2730     ret->state = this->state;
2731     return ret;
2732 }
2733
2734 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2735 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2736 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2737 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2738         fpos_int *ret, fpos_int pos, int mode)
2739 {
2740     fpos_t fpos;
2741
2742     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2743
2744     if(!basic_filebuf_char_is_open(this) || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2745             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2746         ret->off = -1;
2747         ret->pos = 0;
2748         ret->state = 0;
2749         return ret;
2750     }
2751
2752     fgetpos(this->file, &fpos);
2753     ret->off = 0;
2754     ret->pos = fpos;
2755     ret->state = this->state;
2756     return ret;
2757 }
2758
2759 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2760 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2761 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2762 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2763 {
2764     TRACE("(%p %p %ld)\n", this, buf, count);
2765
2766     if(!basic_filebuf_char_is_open(this))
2767         return NULL;
2768
2769     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2770         return NULL;
2771
2772     basic_filebuf_char__Init(this, this->file, INITFL_open);
2773     return &this->base;
2774 }
2775
2776 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2777 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2778 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2779 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2780 {
2781     TRACE("(%p)\n", this);
2782
2783     if(!basic_filebuf_char_is_open(this))
2784         return 0;
2785
2786     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2787         return 0;
2788     return fflush(this->file);
2789 }
2790
2791 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2792 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2793 int basic_filebuf_short__Init__Stinit = 0;
2794
2795 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2796 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2797 static void basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2798 {
2799     TRACE("(%p %p %d)\n", this, file, which);
2800
2801     this->cvt = NULL;
2802     this->state0 = basic_filebuf_short__Init__Stinit;
2803     this->state = basic_filebuf_short__Init__Stinit;
2804     this->str = NULL;
2805     this->close = (which == INITFL_open);
2806     this->file = file;
2807
2808     basic_streambuf_wchar__Init_empty(&this->base);
2809 }
2810
2811 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2812 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2813 DEFINE_THISCALL_WRAPPER(basic_filebuf_short__Init, 12)
2814 void __thiscall basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2815 {
2816     TRACE("(%p %p %d)\n", this, file, which);
2817
2818     this->cvt = NULL;
2819     this->state0 = basic_filebuf_short__Init__Stinit;
2820     this->state = basic_filebuf_short__Init__Stinit;
2821     this->str = NULL;
2822     this->close = (which == INITFL_open);
2823     this->file = file;
2824
2825     basic_streambuf_wchar__Init_empty(&this->base);
2826 }
2827
2828 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
2829 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
2830 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Initcvt, 4)
2831 void __thiscall basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this)
2832 {
2833     TRACE("(%p)\n", this);
2834
2835     this->cvt = codecvt_short_use_facet(&this->base.loc);
2836     locale__Addfac(&this->loc, &this->cvt->base.facet, codecvt_short_id.id, LC_CTYPE);
2837     if(codecvt_base_always_noconv(&this->cvt->base)) {
2838         this->cvt = NULL;
2839     }else {
2840         this->str = MSVCRT_operator_new(sizeof(basic_string_char));
2841         basic_string_char_ctor(this->str);
2842     }
2843 }
2844
2845 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
2846 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
2847 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
2848 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
2849 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_close, 4)
2850 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_close(basic_filebuf_wchar *this)
2851 {
2852     basic_filebuf_wchar *ret = this;
2853
2854     TRACE("(%p)\n", this);
2855
2856     if(!this->file || fclose(this->file))
2857         return NULL;
2858
2859     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
2860     return ret;
2861 }
2862
2863 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
2864 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2865 static basic_filebuf_wchar* basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
2866 {
2867     TRACE("(%p %p)\n", this, file);
2868
2869     basic_streambuf_wchar_ctor(&this->base);
2870     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
2871
2872     locale_ctor(&this->loc);
2873     basic_filebuf_wchar__Init(this, file, INITFL_new);
2874     return this;
2875 }
2876
2877 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
2878 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2879 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_file, 8)
2880 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
2881 {
2882     TRACE("(%p %p)\n", this, file);
2883
2884     basic_streambuf_short_ctor(&this->base);
2885     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
2886
2887     locale_ctor(&this->loc);
2888     basic_filebuf_short__Init(this, file, INITFL_new);
2889     return this;
2890 }
2891
2892 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2893 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2894 static basic_filebuf_wchar* basic_filebuf_wchar_ctor(basic_filebuf_wchar *this)
2895 {
2896     return basic_filebuf_wchar_ctor_file(this, NULL);
2897 }
2898
2899 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2900 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2901 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor, 4)
2902 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor(basic_filebuf_wchar *this)
2903 {
2904     return basic_filebuf_short_ctor_file(this, NULL);
2905 }
2906
2907 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2908 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2909 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_uninitialized, 8)
2910 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
2911 {
2912     TRACE("(%p %d)\n", this, uninitialized);
2913
2914     basic_streambuf_short_ctor_uninitialized(&this->base, 0);
2915     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
2916     locale_ctor(&this->loc);
2917     return this;
2918 }
2919
2920 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
2921 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
2922 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
2923 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
2924 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_dtor, 4)
2925 void __thiscall basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
2926 {
2927     TRACE("(%p)\n", this);
2928
2929     if(this->close)
2930         basic_filebuf_wchar_close(this);
2931     if(this->str) {
2932         basic_string_char_dtor(this->str);
2933         MSVCRT_operator_delete(this->str);
2934     }
2935     locale_dtor(&this->loc);
2936     basic_streambuf_wchar_dtor(&this->base);
2937 }
2938
2939 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
2940 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
2941 {
2942     TRACE("(%p %x)\n", this, flags);
2943     if(flags & 2) {
2944         /* we have an array, with the number of elements stored before the first object */
2945         INT_PTR i, *ptr = (INT_PTR *)this-1;
2946
2947         for(i=*ptr-1; i>=0; i--)
2948             basic_filebuf_wchar_dtor(this+i);
2949         MSVCRT_operator_delete(ptr);
2950     } else {
2951         basic_filebuf_wchar_dtor(this);
2952         if(flags & 1)
2953             MSVCRT_operator_delete(this);
2954     }
2955
2956     return this;
2957 }
2958
2959 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
2960 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
2961 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
2962 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
2963 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_is_open, 4)
2964 MSVCP_bool __thiscall basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
2965 {
2966     TRACE("(%p)\n", this);
2967     return this->file != NULL;
2968 }
2969
2970 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WHH@Z */
2971 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2972 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGHH@Z */
2973 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2974 static basic_filebuf_wchar* basic_filebuf_wchar_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
2975 {
2976     FILE *f = NULL;
2977
2978     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2979
2980     if(basic_filebuf_wchar_is_open(this))
2981         return NULL;
2982
2983     if(!(f = _Fiopen_wchar(name, mode, prot)))
2984         return NULL;
2985
2986     basic_filebuf_wchar__Init(this, f, INITFL_open);
2987     basic_filebuf_wchar__Initcvt(this);
2988     return this;
2989 }
2990
2991 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDHH@Z */
2992 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2993 static basic_filebuf_wchar* basic_filebuf_wchar_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
2994 {
2995     wchar_t nameW[FILENAME_MAX];
2996
2997     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2998
2999     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3000         return NULL;
3001     return basic_filebuf_wchar_open_wchar(this, nameW, mode, prot);
3002 }
3003
3004 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
3005 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
3006 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode_old, 12)
3007 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode_old(basic_filebuf_wchar *this, const char *name, short mode)
3008 {
3009     TRACE("(%p %p %d)\n", this, name, mode);
3010     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3011 }
3012
3013 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
3014 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
3015 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode, 12)
3016 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode(basic_filebuf_wchar *this, const char *name, int mode)
3017 {
3018     TRACE("(%p %p %d)\n", this, name, mode);
3019     return basic_filebuf_wchar_open(this, name, mode, _SH_DENYNO);
3020 }
3021
3022 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3023 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3024 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3025 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3026 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
3027 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
3028 {
3029     char *ptr, *to_next;
3030     wchar_t ch = c;
3031     const wchar_t *from_next;
3032     unsigned short ret;
3033
3034
3035     TRACE("(%p %d)\n", this, c);
3036
3037     if(!basic_filebuf_wchar_is_open(this))
3038         return WEOF;
3039     if(c == WEOF)
3040         return !c;
3041
3042     if(!this->cvt)
3043         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3044
3045     from_next = &ch;
3046     basic_string_char_clear(this->str);
3047     basic_string_char_append_len_ch(this->str, 8, '\0');
3048     ptr = this->str->ptr;
3049     ret = codecvt_wchar_out(this->cvt, &this->state, &ch, &ch+1, &from_next,
3050             ptr, ptr+basic_string_char_length(this->str), &to_next);
3051
3052     switch(ret) {
3053     case CODECVT_partial:
3054         if(from_next == &ch)
3055             return WEOF;
3056         /* fall through */
3057     case CODECVT_ok:
3058         if(!fwrite(ptr, to_next-ptr, 1, this->file))
3059             return WEOF;
3060         return c;
3061     case CODECVT_noconv:
3062         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3063     default:
3064         return WEOF;
3065     }
3066 }
3067
3068 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3069 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3070 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3071 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3072 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
3073 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
3074 {
3075     TRACE("(%p %d)\n", this, c);
3076
3077     if(!basic_filebuf_wchar_is_open(this))
3078         return WEOF;
3079
3080     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
3081             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==c)) {
3082         basic_streambuf_wchar__Gndec(&this->base);
3083         return c==WEOF ? !c : c;
3084     }else if(c == WEOF) {
3085         return WEOF;
3086     }else if(!this->cvt) {
3087         return ungetwc(c, this->file);
3088     }else if(basic_string_char_length(this->str)) {
3089         char *b, *e, *cur;
3090
3091         e = this->str->ptr;
3092         b = e+this->str->size-1;
3093         for(cur = b; cur>=e; cur--) {
3094             if(ungetc(*cur, this->file) == EOF) {
3095                 for(; cur<=b; cur++)
3096                     fgetc(this->file);
3097                 return WEOF;
3098             }
3099         }
3100         basic_string_char_clear(this->str);
3101         this->state = this->state0;
3102         return c;
3103     }
3104
3105     return WEOF;
3106 }
3107
3108 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3109 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3110 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3111 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3112 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
3113 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
3114 {
3115     wchar_t ch, *to_next;
3116     const char *buf_next;
3117     int c;
3118
3119     TRACE("(%p)\n", this);
3120
3121     if(!basic_filebuf_wchar_is_open(this))
3122         return WEOF;
3123
3124     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3125         return *basic_streambuf_wchar__Gninc(&this->base);
3126
3127     if(!this->cvt)
3128         return fgetwc(this->file);
3129
3130     basic_string_char_clear(this->str);
3131     this->state0 = this->state;
3132     while(1) {
3133         if((c = fgetc(this->file)) == EOF)
3134             return WEOF;
3135         basic_string_char_append_ch(this->str, c);
3136         this->state = this->state0;
3137
3138         switch(codecvt_wchar_in(this->cvt, &this->state, this->str->ptr,
3139                     this->str->ptr+this->str->size, &buf_next, &ch, &ch+1, &to_next)) {
3140         case CODECVT_partial:
3141             break;
3142         case CODECVT_noconv:
3143             if(this->str->size < sizeof(unsigned short)/sizeof(char))
3144                 break;
3145             return *(unsigned short*)this->str->ptr;
3146         case CODECVT_ok:
3147             return (unsigned short)ch;
3148         default:
3149             return WEOF;
3150         }
3151     }
3152 }
3153
3154 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3155 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3156 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3157 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3158 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
3159 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
3160 {
3161     unsigned short ret;
3162
3163     TRACE("(%p)\n", this);
3164
3165     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3166         return *basic_streambuf_wchar_gptr(&this->base);
3167
3168     ret = call_basic_streambuf_wchar_uflow(&this->base);
3169     if(ret != WEOF)
3170         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
3171     return ret;
3172 }
3173
3174 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z */
3175 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JW4seekdir@ios_base@2@H@Z */
3176 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 20)
3177 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
3178         fpos_int *ret, streamoff off, int way, int mode)
3179 {
3180     fpos_t pos;
3181
3182     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3183
3184     if(!basic_filebuf_wchar_is_open(this) || fseek(this->file, off, way)) {
3185         ret->off = -1;
3186         ret->pos = 0;
3187         ret->state = 0;
3188         return ret;
3189     }
3190
3191     fgetpos(this->file, &pos);
3192     ret->off = 0;
3193     ret->pos = pos;
3194     ret->state = this->state;
3195     return ret;
3196 }
3197
3198 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3199 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3200 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3201 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3202 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
3203 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
3204         fpos_int *ret, fpos_int pos, int mode)
3205 {
3206     fpos_t fpos;
3207
3208     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3209
3210     if(!basic_filebuf_wchar_is_open(this) || fseek(this->file, (LONG)pos.pos, SEEK_SET)
3211             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
3212         ret->off = -1;
3213         ret->pos = 0;
3214         ret->state = 0;
3215         return ret;
3216     }
3217
3218     fgetpos(this->file, &fpos);
3219     ret->off = 0;
3220     ret->pos = fpos;
3221     ret->state = this->state;
3222     return ret;
3223 }
3224
3225 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
3226 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
3227 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 12)
3228 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3229 {
3230     TRACE("(%p %p %ld)\n", this, buf, count);
3231
3232     if(!basic_filebuf_wchar_is_open(this))
3233         return NULL;
3234
3235     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3236         return NULL;
3237
3238     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
3239     return &this->base;
3240 }
3241
3242 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
3243 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
3244 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 12)
3245 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3246 {
3247     TRACE("(%p %p %ld)\n", this, buf, count);
3248
3249     if(!basic_filebuf_wchar_is_open(this))
3250         return NULL;
3251
3252     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3253         return NULL;
3254
3255     basic_filebuf_short__Init(this, this->file, INITFL_open);
3256     return &this->base;
3257 }
3258
3259 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
3260 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
3261 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
3262 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
3263 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
3264 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
3265 {
3266     TRACE("(%p)\n", this);
3267
3268     if(!basic_filebuf_wchar_is_open(this))
3269         return 0;
3270
3271     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
3272         return 0;
3273     return fflush(this->file);
3274 }
3275
3276 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3277 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3278 /* ?_Mode@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3279 /* ?_Mode@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3280 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Getstate, 8)
3281 int __thiscall basic_stringbuf_char__Getstate(basic_stringbuf_char *this, IOSB_openmode mode)
3282 {
3283     int state = 0;
3284
3285     if(!(mode & OPENMODE_in))
3286         state |= STRINGBUF_no_read;
3287
3288     if(!(mode & OPENMODE_out))
3289         state |= STRINGBUF_no_write;
3290
3291     if(mode & OPENMODE_ate)
3292         state |= STRINGBUF_at_end;
3293
3294     if(mode & OPENMODE_app)
3295         state |= STRINGBUF_append;
3296
3297     return state;
3298 }
3299
3300 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXPBDIH@Z */
3301 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXPEBD_KH@Z */
3302 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Init, 16)
3303 void __thiscall basic_stringbuf_char__Init(basic_stringbuf_char *this, const char *str, MSVCP_size_t count, int state)
3304 {
3305     TRACE("(%p, %p, %ld, %d)\n", this, str, count, state);
3306
3307     basic_streambuf_char__Init_empty(&this->base);
3308
3309     this->state = state;
3310     this->seekhigh = NULL;
3311
3312     if(count && str) {
3313         char *buf = MSVCRT_operator_new(count);
3314         if(!buf) {
3315             ERR("Out of memory\n");
3316             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3317         }
3318
3319         memcpy(buf, str, count);
3320         this->seekhigh = buf + count;
3321
3322         this->state |= STRINGBUF_allocated;
3323
3324         if(!(state & STRINGBUF_no_read))
3325             basic_streambuf_char_setg(&this->base, buf, buf, buf + count);
3326
3327         if(!(state & STRINGBUF_no_write)) {
3328             basic_streambuf_char_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3329
3330             if(!basic_streambuf_char_gptr(&this->base))
3331                 basic_streambuf_char_setg(&this->base, buf, 0, buf);
3332         }
3333     }
3334 }
3335
3336 /* ??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 */
3337 /* ??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 */
3338 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_str, 12)
3339 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_str(basic_stringbuf_char *this,
3340         const basic_string_char *str, IOSB_openmode mode)
3341 {
3342     TRACE("(%p %p %d)\n", this, str, mode);
3343
3344     basic_streambuf_char_ctor(&this->base);
3345     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3346
3347     basic_stringbuf_char__Init(this, basic_string_char_c_str(str),
3348             str->size, basic_stringbuf_char__Getstate(this, mode));
3349     return this;
3350 }
3351
3352 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
3353 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
3354 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_mode, 8)
3355 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_mode(
3356         basic_stringbuf_char *this, IOSB_openmode mode)
3357 {
3358     TRACE("(%p %d)\n", this, mode);
3359
3360     basic_streambuf_char_ctor(&this->base);
3361     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3362
3363     basic_stringbuf_char__Init(this, NULL, 0, basic_stringbuf_char__Getstate(this, mode));
3364     return this;
3365 }
3366
3367 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
3368 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
3369 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor, 4)
3370 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor(basic_stringbuf_char *this)
3371 {
3372     return basic_stringbuf_char_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3373 }
3374
3375 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXXZ */
3376 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXXZ */
3377 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Tidy, 4)
3378 void __thiscall basic_stringbuf_char__Tidy(basic_stringbuf_char *this)
3379 {
3380     TRACE("(%p)\n", this);
3381
3382     if(this->state & STRINGBUF_allocated) {
3383         MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
3384         this->seekhigh = NULL;
3385         this->state &= ~STRINGBUF_allocated;
3386     }
3387
3388     basic_streambuf_char__Init_empty(&this->base);
3389 }
3390
3391 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
3392 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
3393 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_dtor, 4)
3394 void __thiscall basic_stringbuf_char_dtor(basic_stringbuf_char *this)
3395 {
3396     TRACE("(%p)\n", this);
3397
3398     basic_stringbuf_char__Tidy(this);
3399     basic_streambuf_char_dtor(&this->base);
3400 }
3401
3402 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_vector_dtor, 8)
3403 basic_stringbuf_char* __thiscall basic_stringbuf_char_vector_dtor(basic_stringbuf_char *this, unsigned int flags)
3404 {
3405     TRACE("(%p %x)\n", this, flags);
3406
3407     if(flags & 2) {
3408         /* we have an array, with the number of elements stored before the first object */
3409         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3410
3411         for (i = *ptr - 1; i >= 0; i--)
3412             basic_stringbuf_char_dtor(this+i);
3413
3414         MSVCRT_operator_delete(ptr);
3415     }else {
3416         basic_stringbuf_char_dtor(this);
3417
3418         if(flags & 1)
3419             MSVCRT_operator_delete(this);
3420     }
3421
3422     return this;
3423 }
3424
3425 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3426 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3427 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_overflow, 8)
3428 int __thiscall basic_stringbuf_char_overflow(basic_stringbuf_char *this, int meta)
3429 {
3430     MSVCP_size_t oldsize, size;
3431     char *ptr, *buf;
3432
3433     TRACE("(%p %x)\n", this, meta);
3434
3435     if(meta == EOF)
3436         return !EOF;
3437     if(this->state & STRINGBUF_no_write)
3438         return EOF;
3439
3440     ptr = basic_streambuf_char_pptr(&this->base);
3441     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3442         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
3443                 this->seekhigh, basic_streambuf_char_epptr(&this->base));
3444
3445     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
3446         return (*basic_streambuf_char__Pninc(&this->base) = meta);
3447
3448     oldsize = (ptr ? basic_streambuf_char_epptr(&this->base)-basic_streambuf_char_eback(&this->base): 0);
3449     size = oldsize|0xf;
3450     size += size/2;
3451     buf = MSVCRT_operator_new(size);
3452     if(!buf) {
3453         ERR("Out of memory\n");
3454         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3455     }
3456
3457     if(!oldsize) {
3458         this->seekhigh = buf;
3459         basic_streambuf_char_setp(&this->base, buf, buf+size);
3460         if(this->state & STRINGBUF_no_read)
3461             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3462         else
3463             basic_streambuf_char_setg(&this->base, buf, buf, buf+1);
3464
3465         this->state |= STRINGBUF_allocated;
3466     }else {
3467         ptr = basic_streambuf_char_eback(&this->base);
3468         memcpy(buf, ptr, oldsize);
3469
3470         this->seekhigh = buf+(this->seekhigh-ptr);
3471         basic_streambuf_char_setp_next(&this->base, buf,
3472                 buf+(basic_streambuf_char_pptr(&this->base)-ptr), buf+size);
3473         if(this->state & STRINGBUF_no_read)
3474             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3475         else
3476             basic_streambuf_char_setg(&this->base, buf,
3477                     buf+(basic_streambuf_char_gptr(&this->base)-ptr),
3478                     basic_streambuf_char_pptr(&this->base)+1);
3479
3480         MSVCRT_operator_delete(ptr);
3481     }
3482
3483     return (*basic_streambuf_char__Pninc(&this->base) = meta);
3484 }
3485
3486 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3487 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3488 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_pbackfail, 8)
3489 int __thiscall basic_stringbuf_char_pbackfail(basic_stringbuf_char *this, int c)
3490 {
3491     char *cur;
3492
3493     TRACE("(%p %x)\n", this, c);
3494
3495     cur = basic_streambuf_char_gptr(&this->base);
3496     if(!cur || cur==basic_streambuf_char_eback(&this->base)
3497             || (c!=EOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3498         return EOF;
3499
3500     if(c != EOF)
3501         cur[-1] = c;
3502     basic_streambuf_char_gbump(&this->base, -1);
3503     return c==EOF ? !EOF : c;
3504 }
3505
3506 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHXZ */
3507 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHXZ */
3508 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_underflow, 4)
3509 int __thiscall basic_stringbuf_char_underflow(basic_stringbuf_char *this)
3510 {
3511     char *ptr, *cur;
3512
3513     TRACE("(%p)\n", this);
3514
3515     cur = basic_streambuf_char_gptr(&this->base);
3516     if(!cur || this->state&STRINGBUF_no_read)
3517         return EOF;
3518
3519     ptr  = basic_streambuf_char_pptr(&this->base);
3520     if(this->seekhigh < ptr)
3521         this->seekhigh = ptr;
3522
3523     ptr = basic_streambuf_char_egptr(&this->base);
3524     if(this->seekhigh > ptr)
3525         basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base), cur, this->seekhigh);
3526
3527     if(cur < this->seekhigh)
3528         return (unsigned char)*cur;
3529     return EOF;
3530 }
3531
3532 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z */
3533 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@_JW4seekdir@ios_base@2@H@Z */
3534 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekoff, 20)
3535 fpos_int* __thiscall basic_stringbuf_char_seekoff(basic_stringbuf_char *this,
3536         fpos_int *ret, streamoff off, int way, int mode)
3537 {
3538     char *beg, *cur_r, *cur_w;
3539
3540     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3541
3542     cur_w = basic_streambuf_char_pptr(&this->base);
3543     if(cur_w > this->seekhigh)
3544         this->seekhigh = cur_w;
3545
3546     ret->off = 0;
3547     ret->pos = 0;
3548     ret->state = 0;
3549
3550     beg = basic_streambuf_char_eback(&this->base);
3551     cur_r = basic_streambuf_char_gptr(&this->base);
3552     if((mode & OPENMODE_in) && cur_r) {
3553         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3554             off += cur_r-beg;
3555         else if(way == SEEKDIR_end)
3556             off += this->seekhigh-beg;
3557         else if(way != SEEKDIR_beg)
3558             off = -1;
3559
3560         if(off<0 || off>this->seekhigh-beg) {
3561             off = -1;
3562         }else {
3563             basic_streambuf_char_gbump(&this->base, beg-cur_r+off);
3564             if((mode & OPENMODE_out) && cur_w) {
3565                 basic_streambuf_char_setp_next(&this->base, beg,
3566                         basic_streambuf_char_gptr(&this->base),
3567                         basic_streambuf_char_epptr(&this->base));
3568             }
3569         }
3570     }else if((mode & OPENMODE_out) && cur_w) {
3571         if(way == SEEKDIR_cur)
3572             off += cur_w-beg;
3573         else if(way == SEEKDIR_end)
3574             off += this->seekhigh-beg;
3575         else if(way != SEEKDIR_beg)
3576             off = -1;
3577
3578         if(off<0 || off>this->seekhigh-beg)
3579             off = -1;
3580         else
3581             basic_streambuf_char_pbump(&this->base, beg-cur_w+off);
3582     }else {
3583         off = -1;
3584     }
3585
3586     ret->off = off;
3587     return ret;
3588 }
3589
3590 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3591 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3592 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekpos, 36)
3593 fpos_int* __thiscall basic_stringbuf_char_seekpos(basic_stringbuf_char *this,
3594         fpos_int *ret, fpos_int pos, int mode)
3595 {
3596     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3597
3598     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
3599         *ret = pos;
3600         return ret;
3601     }
3602
3603     return basic_stringbuf_char_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
3604 }
3605
3606 /* ?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 */
3607 /* ?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 */
3608 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_set, 8)
3609 void __thiscall basic_stringbuf_char_str_set(basic_stringbuf_char *this, const basic_string_char *str)
3610 {
3611     TRACE("(%p %p)\n", this, str);
3612
3613     basic_stringbuf_char__Tidy(this);
3614     basic_stringbuf_char__Init(this, basic_string_char_c_str(str), str->size, this->state);
3615 }
3616
3617 /* ?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 */
3618 /* ?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 */
3619 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_get, 8)
3620 basic_string_char* __thiscall basic_stringbuf_char_str_get(const basic_stringbuf_char *this, basic_string_char *ret)
3621 {
3622     char *ptr;
3623
3624     TRACE("(%p)\n", this);
3625
3626     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_char_pptr(&this->base)) {
3627         char *pptr;
3628
3629         ptr = basic_streambuf_char_pbase(&this->base);
3630         pptr = basic_streambuf_char_pptr(&this->base);
3631
3632         return basic_string_char_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
3633     }
3634
3635     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_char_gptr(&this->base)) {
3636         ptr = basic_streambuf_char_eback(&this->base);
3637         return basic_string_char_ctor_cstr_len(ret, ptr, basic_streambuf_char_egptr(&this->base) - ptr);
3638     }
3639
3640     return basic_string_char_ctor(ret);
3641 }
3642
3643 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAEHH@Z */
3644 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAAHH@Z */
3645 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3646 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3647 /* ?_Mode@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3648 /* ?_Mode@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3649 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Getstate, 8)
3650 int __thiscall basic_stringbuf_wchar__Getstate(basic_stringbuf_wchar *this, IOSB_openmode mode)
3651 {
3652     int state = 0;
3653
3654     if(!(mode & OPENMODE_in))
3655         state |= STRINGBUF_no_read;
3656
3657     if(!(mode & OPENMODE_out))
3658         state |= STRINGBUF_no_write;
3659
3660     if(mode & OPENMODE_ate)
3661         state |= STRINGBUF_at_end;
3662
3663     if(mode & OPENMODE_app)
3664         state |= STRINGBUF_append;
3665
3666     return state;
3667 }
3668
3669 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXPB_WIH@Z */
3670 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXPEB_W_KH@Z */
3671 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXPBGIH@Z */
3672 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXPEBG_KH@Z */
3673 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Init, 16)
3674 void __thiscall basic_stringbuf_wchar__Init(basic_stringbuf_wchar *this, const wchar_t *str, MSVCP_size_t count, int state)
3675 {
3676     TRACE("(%p, %p, %lu, %d)\n", this, str, count, state);
3677
3678     basic_streambuf_wchar__Init_empty(&this->base);
3679
3680     this->state = state;
3681     this->seekhigh = NULL;
3682
3683     if(count && str) {
3684         wchar_t *buf = MSVCRT_operator_new(count*sizeof(wchar_t));
3685         if(!buf) {
3686             ERR("Out of memory\n");
3687             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3688         }
3689
3690         memcpy(buf, str, count*sizeof(wchar_t));
3691         this->seekhigh = buf + count;
3692
3693         this->state |= STRINGBUF_allocated;
3694
3695         if(!(state & STRINGBUF_no_read))
3696             basic_streambuf_wchar_setg(&this->base, buf, buf, buf + count);
3697
3698         if(!(state & STRINGBUF_no_write)) {
3699             basic_streambuf_wchar_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3700
3701             if(!basic_streambuf_wchar_gptr(&this->base))
3702                 basic_streambuf_wchar_setg(&this->base, buf, 0, buf);
3703         }
3704     }
3705 }
3706
3707 /* ??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 */
3708 /* ??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 */
3709 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_str(basic_stringbuf_wchar *this,
3710         const basic_string_wchar *str, IOSB_openmode mode)
3711 {
3712     TRACE("(%p %p %d)\n", this, str, mode);
3713
3714     basic_streambuf_wchar_ctor(&this->base);
3715     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3716
3717     basic_stringbuf_wchar__Init(this, basic_string_wchar_c_str(str),
3718             str->size, basic_stringbuf_wchar__Getstate(this, mode));
3719     return this;
3720 }
3721
3722 /* ??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 */
3723 /* ??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 */
3724 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_str, 12)
3725 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_str(basic_stringbuf_wchar *this,
3726         const basic_string_wchar *str, IOSB_openmode mode)
3727 {
3728     basic_stringbuf_wchar_ctor_str(this, str, mode);
3729     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3730     return this;
3731 }
3732
3733 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
3734 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
3735 static basic_stringbuf_wchar* basic_stringbuf_wchar_ctor_mode(
3736         basic_stringbuf_wchar *this, IOSB_openmode mode)
3737 {
3738     TRACE("(%p %d)\n", this, mode);
3739
3740     basic_streambuf_wchar_ctor(&this->base);
3741     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3742
3743     basic_stringbuf_wchar__Init(this, NULL, 0, basic_stringbuf_wchar__Getstate(this, mode));
3744     return this;
3745 }
3746
3747 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
3748 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
3749 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_mode, 8)
3750 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_mode(
3751         basic_stringbuf_wchar *this, IOSB_openmode mode)
3752 {
3753     basic_stringbuf_wchar_ctor_mode(this, mode);
3754     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3755     return this;
3756 }
3757
3758 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
3759 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
3760 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor, 4)
3761 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor(basic_stringbuf_wchar *this)
3762 {
3763     return basic_stringbuf_short_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3764 }
3765
3766 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXXZ */
3767 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXXZ */
3768 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXXZ */
3769 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXXZ */
3770 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Tidy, 4)
3771 void __thiscall basic_stringbuf_wchar__Tidy(basic_stringbuf_wchar *this)
3772 {
3773     TRACE("(%p)\n", this);
3774
3775     if(this->state & STRINGBUF_allocated) {
3776         MSVCRT_operator_delete(basic_streambuf_wchar_eback(&this->base));
3777         this->seekhigh = NULL;
3778         this->state &= ~STRINGBUF_allocated;
3779     }
3780
3781     basic_streambuf_wchar__Init_empty(&this->base);
3782 }
3783
3784 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
3785 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
3786 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
3787 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
3788 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_dtor, 4)
3789 void __thiscall basic_stringbuf_wchar_dtor(basic_stringbuf_wchar *this)
3790 {
3791     TRACE("(%p)\n", this);
3792
3793     basic_stringbuf_wchar__Tidy(this);
3794     basic_streambuf_wchar_dtor(&this->base);
3795 }
3796
3797 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_vector_dtor, 8)
3798 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_vector_dtor(basic_stringbuf_wchar *this, unsigned int flags)
3799 {
3800     TRACE("(%p %x)\n", this, flags);
3801
3802     if(flags & 2) {
3803         /* we have an array, with the number of elements stored before the first object */
3804         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3805
3806         for (i = *ptr - 1; i >= 0; i--)
3807             basic_stringbuf_wchar_dtor(this+i);
3808
3809         MSVCRT_operator_delete(ptr);
3810     }else {
3811         basic_stringbuf_wchar_dtor(this);
3812
3813         if(flags & 1)
3814             MSVCRT_operator_delete(this);
3815     }
3816
3817     return this;
3818 }
3819
3820 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
3821 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
3822 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
3823 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
3824 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_overflow, 8)
3825 unsigned short __thiscall basic_stringbuf_wchar_overflow(basic_stringbuf_wchar *this, unsigned short meta)
3826 {
3827     MSVCP_size_t oldsize, size;
3828     wchar_t *ptr, *buf;
3829
3830     TRACE("(%p %x)\n", this, meta);
3831
3832     if(meta == WEOF)
3833         return !WEOF;
3834     if(this->state & STRINGBUF_no_write)
3835         return WEOF;
3836
3837     ptr = basic_streambuf_wchar_pptr(&this->base);
3838     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3839         basic_streambuf_wchar_setp_next(&this->base, basic_streambuf_wchar_pbase(&this->base),
3840                 this->seekhigh, basic_streambuf_wchar_epptr(&this->base));
3841
3842     if(ptr && ptr<basic_streambuf_wchar_epptr(&this->base))
3843         return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
3844
3845     oldsize = (ptr ? basic_streambuf_wchar_epptr(&this->base)-basic_streambuf_wchar_eback(&this->base): 0);
3846     size = oldsize|0xf;
3847     size += size/2;
3848     buf = MSVCRT_operator_new(size*sizeof(wchar_t));
3849     if(!buf) {
3850         ERR("Out of memory\n");
3851         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3852     }
3853
3854     if(!oldsize) {
3855         this->seekhigh = buf;
3856         basic_streambuf_wchar_setp(&this->base, buf, buf+size);
3857         if(this->state & STRINGBUF_no_read)
3858             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
3859         else
3860             basic_streambuf_wchar_setg(&this->base, buf, buf, buf+1);
3861
3862         this->state |= STRINGBUF_allocated;
3863     }else {
3864         ptr = basic_streambuf_wchar_eback(&this->base);
3865         memcpy(buf, ptr, oldsize*sizeof(wchar_t));
3866
3867         this->seekhigh = buf+(this->seekhigh-ptr);
3868         basic_streambuf_wchar_setp_next(&this->base, buf,
3869                 buf+(basic_streambuf_wchar_pptr(&this->base)-ptr), buf+size);
3870         if(this->state & STRINGBUF_no_read)
3871             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
3872         else
3873             basic_streambuf_wchar_setg(&this->base, buf,
3874                     buf+(basic_streambuf_wchar_gptr(&this->base)-ptr),
3875                     basic_streambuf_wchar_pptr(&this->base)+1);
3876
3877         MSVCRT_operator_delete(ptr);
3878     }
3879
3880     return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
3881 }
3882
3883 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
3884 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
3885 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
3886 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
3887 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_pbackfail, 8)
3888 unsigned short __thiscall basic_stringbuf_wchar_pbackfail(basic_stringbuf_wchar *this, unsigned short c)
3889 {
3890     wchar_t *cur;
3891
3892     TRACE("(%p %x)\n", this, c);
3893
3894     cur = basic_streambuf_wchar_gptr(&this->base);
3895     if(!cur || cur==basic_streambuf_wchar_eback(&this->base)
3896             || (c!=WEOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3897         return WEOF;
3898
3899     if(c != WEOF)
3900         cur[-1] = c;
3901     basic_streambuf_wchar_gbump(&this->base, -1);
3902     return c==WEOF ? !WEOF : c;
3903 }
3904
3905 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGXZ */
3906 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGXZ */
3907 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGXZ */
3908 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGXZ */
3909 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_underflow, 4)
3910 unsigned short __thiscall basic_stringbuf_wchar_underflow(basic_stringbuf_wchar *this)
3911 {
3912     wchar_t *ptr, *cur;
3913
3914     TRACE("(%p)\n", this);
3915
3916     cur = basic_streambuf_wchar_gptr(&this->base);
3917     if(!cur || this->state&STRINGBUF_no_read)
3918         return WEOF;
3919
3920     ptr  = basic_streambuf_wchar_pptr(&this->base);
3921     if(this->seekhigh < ptr)
3922         this->seekhigh = ptr;
3923
3924     ptr = basic_streambuf_wchar_egptr(&this->base);
3925     if(this->seekhigh > ptr)
3926         basic_streambuf_wchar_setg(&this->base, basic_streambuf_wchar_eback(&this->base), cur, this->seekhigh);
3927
3928     if(cur < this->seekhigh)
3929         return *cur;
3930     return WEOF;
3931 }
3932
3933 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z */
3934 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@_JW4seekdir@ios_base@2@H@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@_N1@Z */
5085 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
5086 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor, 20)
5087 basic_ostream_char* __thiscall basic_ostream_char_ctor(basic_ostream_char *this,
5088         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool init, MSVCP_bool virt_init)
5089 {
5090     basic_ios_char *base;
5091
5092     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, init, virt_init);
5093
5094     if(virt_init) {
5095         this->vbtable = basic_ostream_char_vbtable;
5096         base = basic_ostream_char_get_basic_ios(this);
5097         basic_ios_char_ctor(base);
5098     }else {
5099         base = basic_ostream_char_get_basic_ios(this);
5100     }
5101
5102     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5103     if(init)
5104         basic_ios_char_init(base, strbuf, isstd);
5105     return this;
5106 }
5107
5108 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
5109 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
5110 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor_uninitialized, 12)
5111 basic_ostream_char* __thiscall basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
5112         int uninitialized, MSVCP_bool virt_init)
5113 {
5114     basic_ios_char *base;
5115
5116     TRACE("(%p %d)\n", this, uninitialized);
5117
5118     if(virt_init) {
5119         this->vbtable = basic_ostream_char_vbtable;
5120         base = basic_ostream_char_get_basic_ios(this);
5121         basic_ios_char_ctor(base);
5122     }else {
5123         base = basic_ostream_char_get_basic_ios(this);
5124     }
5125
5126     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5127     ios_base_Addstd(&base->base);
5128     return this;
5129 }
5130
5131 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5132 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5133 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
5134 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
5135 {
5136     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5137
5138     /* don't destroy virtual base here */
5139     TRACE("(%p)\n", this);
5140 }
5141
5142 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5143 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5144 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
5145 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
5146 {
5147     TRACE("(%p)\n", this);
5148     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
5149     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
5150 }
5151
5152 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
5153 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5154 {
5155     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5156
5157     TRACE("(%p %x)\n", this, flags);
5158
5159     if(flags & 2) {
5160         /* we have an array, with the number of elements stored before the first object */
5161         INT_PTR i, *ptr = (INT_PTR *)this-1;
5162
5163         for(i=*ptr-1; i>=0; i--)
5164             basic_ostream_char_vbase_dtor(this+i);
5165         MSVCRT_operator_delete(ptr);
5166     } else {
5167         basic_ostream_char_vbase_dtor(this);
5168         if(flags & 1)
5169             MSVCRT_operator_delete(this);
5170     }
5171
5172     return this;
5173 }
5174
5175 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5176 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5177 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
5178 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
5179 {
5180     /* this function is not matching C++ specification */
5181     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5182
5183     TRACE("(%p)\n", this);
5184
5185     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
5186             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
5187         basic_ios_char_setstate(base, IOSTATE_badbit);
5188     return this;
5189 }
5190
5191 /* ?flush@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5192 /* ?flush@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5193 basic_ostream_char* __cdecl flush_ostream_char(basic_ostream_char *ostream)
5194 {
5195     return basic_ostream_char_flush(ostream);
5196 }
5197
5198 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5199 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5200 static void basic_ostream_char__Osfx(basic_ostream_char *this)
5201 {
5202     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5203
5204     TRACE("(%p)\n", this);
5205
5206     if(base->base.fmtfl & FMTFLAG_unitbuf)
5207         basic_ostream_char_flush(this);
5208 }
5209
5210 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5211 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5212 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
5213 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
5214 {
5215     TRACE("(%p)\n", this);
5216     basic_ostream_char__Osfx(this);
5217 }
5218
5219 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
5220 {
5221     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5222
5223     if(basic_ios_char_rdbuf_get(base))
5224         basic_streambuf_char__Lock(base->strbuf);
5225
5226     if(ios_base_good(&base->base) && base->stream)
5227         basic_ostream_char_flush(base->stream);
5228
5229     return ios_base_good(&base->base);
5230 }
5231
5232 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
5233 {
5234     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5235
5236     if(ios_base_good(&base->base) && !__uncaught_exception())
5237         basic_ostream_char_osfx(ostr);
5238
5239     if(basic_ios_char_rdbuf_get(base))
5240         basic_streambuf_char__Unlock(base->strbuf);
5241 }
5242
5243 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
5244 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
5245 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
5246 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
5247 {
5248     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5249
5250     TRACE("(%p)\n", this);
5251
5252     if(ios_base_good(&base->base) && base->stream)
5253         basic_ostream_char_flush(base->stream);
5254     return ios_base_good(&base->base);
5255 }
5256
5257 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5258 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5259 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
5260 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
5261 {
5262     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5263
5264     TRACE("(%p %c)\n", this, ch);
5265
5266     if(!basic_ostream_char_sentry_create(this)
5267             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
5268         basic_ostream_char_sentry_destroy(this);
5269         basic_ios_char_setstate(base, IOSTATE_badbit);
5270         return this;
5271     }
5272
5273     basic_ostream_char_sentry_destroy(this);
5274     return this;
5275 }
5276
5277 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
5278 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
5279 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
5280 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
5281 {
5282     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5283
5284     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
5285
5286     if(!ios_base_fail(&base->base)) {
5287         fpos_int seek;
5288
5289         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
5290                 &seek, pos, OPENMODE_out);
5291         if(seek.off==-1 && seek.pos==0 && seek.state==0)
5292             basic_ios_char_setstate(base, IOSTATE_failbit);
5293     }
5294     return this;
5295 }
5296
5297 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
5298 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
5299 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
5300 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
5301 {
5302     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5303
5304     TRACE("(%p)\n", this);
5305
5306     if(!ios_base_fail(&base->base)) {
5307         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5308                 ret, 0, SEEKDIR_cur, OPENMODE_out);
5309     }else {
5310         ret->off = -1;
5311         ret->pos = 0;
5312         ret->state = 0;
5313     }
5314     return ret;
5315 }
5316
5317 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
5318 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
5319 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
5320 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
5321 {
5322     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5323
5324     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
5325
5326     if(!basic_ostream_char_sentry_create(this)
5327             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
5328         basic_ostream_char_sentry_destroy(this);
5329         basic_ios_char_setstate(base, IOSTATE_badbit);
5330         return this;
5331     }
5332
5333     basic_ostream_char_sentry_destroy(this);
5334     return this;
5335 }
5336
5337 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
5338 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
5339 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
5340 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
5341 {
5342     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5343     int state = IOSTATE_goodbit;
5344
5345     TRACE("(%p %d)\n", this, val);
5346
5347     if(basic_ostream_char_sentry_create(this)) {
5348         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5349         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5350         ostreambuf_iterator_char dest = {0, strbuf};
5351
5352         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
5353                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
5354                 ? (LONG)((unsigned short)val) : (LONG)val);
5355     }
5356     basic_ostream_char_sentry_destroy(this);
5357
5358     basic_ios_char_setstate(base, state);
5359     return this;
5360 }
5361
5362 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
5363 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
5364 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
5365 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
5366 {
5367     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5368     int state = IOSTATE_goodbit;
5369
5370     TRACE("(%p %u)\n", this, val);
5371
5372     if(basic_ostream_char_sentry_create(this)) {
5373         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5374         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5375         ostreambuf_iterator_char dest = {0, strbuf};
5376
5377         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5378     }
5379     basic_ostream_char_sentry_destroy(this);
5380
5381     basic_ios_char_setstate(base, state);
5382     return this;
5383 }
5384
5385 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
5386 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
5387 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
5388 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
5389 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
5390 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
5391 {
5392     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5393     int state = IOSTATE_goodbit;
5394
5395     TRACE("(%p %d)\n", this, val);
5396
5397     if(basic_ostream_char_sentry_create(this)) {
5398         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5399         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5400         ostreambuf_iterator_char dest = {0, strbuf};
5401
5402         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5403     }
5404     basic_ostream_char_sentry_destroy(this);
5405
5406     basic_ios_char_setstate(base, state);
5407     return this;
5408 }
5409
5410 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
5411 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
5412 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
5413 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
5414 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
5415 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
5416 {
5417     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5418     int state = IOSTATE_goodbit;
5419
5420     TRACE("(%p %u)\n", this, val);
5421
5422     if(basic_ostream_char_sentry_create(this)) {
5423         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5424         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5425         ostreambuf_iterator_char dest = {0, strbuf};
5426
5427         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5428     }
5429     basic_ostream_char_sentry_destroy(this);
5430
5431     basic_ios_char_setstate(base, state);
5432     return this;
5433 }
5434
5435 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
5436 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
5437 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
5438 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
5439 {
5440     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5441     int state = IOSTATE_goodbit;
5442
5443     TRACE("(%p %f)\n", this, val);
5444
5445     if(basic_ostream_char_sentry_create(this)) {
5446         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5447         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5448         ostreambuf_iterator_char dest = {0, strbuf};
5449
5450         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5451     }
5452     basic_ostream_char_sentry_destroy(this);
5453
5454     basic_ios_char_setstate(base, state);
5455     return this;
5456 }
5457
5458 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
5459 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
5460 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
5461 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
5462 {
5463     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5464     int state = IOSTATE_goodbit;
5465
5466     TRACE("(%p %lf)\n", this, val);
5467
5468     if(basic_ostream_char_sentry_create(this)) {
5469         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5470         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5471         ostreambuf_iterator_char dest = {0, strbuf};
5472
5473         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5474     }
5475     basic_ostream_char_sentry_destroy(this);
5476
5477     basic_ios_char_setstate(base, state);
5478     return this;
5479 }
5480
5481 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
5482 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
5483 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
5484 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
5485 {
5486     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5487     int state = IOSTATE_goodbit;
5488
5489     TRACE("(%p %lf)\n", this, val);
5490
5491     if(basic_ostream_char_sentry_create(this)) {
5492         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5493         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5494         ostreambuf_iterator_char dest = {0, strbuf};
5495
5496         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5497     }
5498     basic_ostream_char_sentry_destroy(this);
5499
5500     basic_ios_char_setstate(base, state);
5501     return this;
5502 }
5503
5504 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5505 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5506 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
5507 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
5508 {
5509     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5510     IOSB_iostate state = IOSTATE_badbit;
5511     int c = '\n';
5512
5513     TRACE("(%p %p)\n", this, val);
5514
5515     if(basic_ostream_char_sentry_create(this)) {
5516         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
5517                 c = basic_streambuf_char_snextc(val)) {
5518             state = IOSTATE_goodbit;
5519
5520             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
5521                 state = IOSTATE_badbit;
5522                 break;
5523             }
5524         }
5525     }else {
5526         state = IOSTATE_badbit;
5527     }
5528     basic_ostream_char_sentry_destroy(this);
5529
5530     ios_base_width_set(&base->base, 0);
5531     basic_ios_char_setstate(base, state);
5532     return this;
5533 }
5534
5535 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
5536 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
5537 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
5538 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
5539 {
5540     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5541     int state = IOSTATE_goodbit;
5542
5543     TRACE("(%p %p)\n", this, val);
5544
5545     if(basic_ostream_char_sentry_create(this)) {
5546         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5547         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5548         ostreambuf_iterator_char dest = {0, strbuf};
5549
5550         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5551     }
5552     basic_ostream_char_sentry_destroy(this);
5553
5554     basic_ios_char_setstate(base, state);
5555     return this;
5556 }
5557
5558 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
5559 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
5560 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
5561 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
5562 {
5563     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5564     int state = IOSTATE_goodbit;
5565
5566     TRACE("(%p)\n", this);
5567
5568     if(basic_ostream_char_sentry_create(this)) {
5569         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5570         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5571         ostreambuf_iterator_char dest = {0, strbuf};
5572
5573         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5574     }
5575     basic_ostream_char_sentry_destroy(this);
5576
5577     basic_ios_char_setstate(base, state);
5578     return this;
5579 }
5580
5581 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
5582 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
5583 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
5584 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
5585 {
5586     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5587     int state = IOSTATE_goodbit;
5588
5589     TRACE("(%p)\n", this);
5590
5591     if(basic_ostream_char_sentry_create(this)) {
5592         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5593         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5594         ostreambuf_iterator_char dest = {0, strbuf};
5595
5596         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5597     }
5598     basic_ostream_char_sentry_destroy(this);
5599
5600     basic_ios_char_setstate(base, state);
5601     return this;
5602 }
5603
5604 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
5605 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
5606 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
5607 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
5608 {
5609     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5610     int state = IOSTATE_goodbit;
5611
5612     TRACE("(%p %x)\n", this, val);
5613
5614     if(basic_ostream_char_sentry_create(this)) {
5615         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5616         const num_put *numput = num_put_char_use_facet(&strbuf->loc);
5617         ostreambuf_iterator_char dest = {0, strbuf};
5618
5619         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5620     }
5621     basic_ostream_char_sentry_destroy(this);
5622
5623     basic_ios_char_setstate(base, state);
5624     return this;
5625 }
5626
5627 /* ?ends@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5628 /* ?ends@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5629 basic_ostream_char* __cdecl basic_ostream_char_ends(basic_ostream_char *ostr)
5630 {
5631     TRACE("(%p)\n", ostr);
5632
5633     basic_ostream_char_put(ostr, 0);
5634     return ostr;
5635 }
5636
5637 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5638 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5639 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
5640 {
5641     TRACE("(%p)\n", ostr);
5642
5643     basic_ostream_char_put(ostr, '\n');
5644     basic_ostream_char_flush(ostr);
5645     return ostr;
5646 }
5647
5648 /* $?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 */
5649 /* ??$?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 */
5650 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
5651 {
5652     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5653     IOSB_iostate state = IOSTATE_goodbit;
5654
5655     TRACE("(%p %p)\n", ostr, str);
5656
5657     if(basic_ostream_char_sentry_create(ostr)) {
5658         MSVCP_size_t len = basic_string_char_length(str);
5659         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5660
5661         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5662             for(; pad!=0; pad--) {
5663                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5664                     state = IOSTATE_badbit;
5665                     break;
5666                 }
5667             }
5668         }
5669
5670         if(state == IOSTATE_goodbit) {
5671             if(basic_streambuf_char_sputn(base->strbuf, basic_string_char_c_str(str), len) != len)
5672                     state = IOSTATE_badbit;
5673         }
5674
5675         if(state == IOSTATE_goodbit) {
5676             for(; pad!=0; pad--) {
5677                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5678                     state = IOSTATE_badbit;
5679                     break;
5680                 }
5681             }
5682         }
5683
5684         base->base.wide = 0;
5685     }else {
5686         state = IOSTATE_badbit;
5687     }
5688     basic_ostream_char_sentry_destroy(ostr);
5689
5690     basic_ios_char_setstate(base, state);
5691     return ostr;
5692 }
5693
5694 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@C@Z */
5695 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@C@Z */
5696 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z */
5697 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z */
5698 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@E@Z */
5699 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@E@Z */
5700 basic_ostream_char* __cdecl basic_ostream_char_print_ch(basic_ostream_char *ostr, char ch)
5701 {
5702     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5703     IOSB_iostate state = IOSTATE_goodbit;
5704
5705     TRACE("(%p %d)\n", ostr, ch);
5706
5707     if(basic_ostream_char_sentry_create(ostr)) {
5708         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
5709
5710         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5711             for(; pad!=0; pad--) {
5712                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5713                     state = IOSTATE_badbit;
5714                     break;
5715                 }
5716             }
5717         }
5718
5719         if(state == IOSTATE_goodbit) {
5720             if(basic_streambuf_char_sputc(base->strbuf, ch) == EOF)
5721                 state = IOSTATE_badbit;
5722         }
5723
5724         if(state == IOSTATE_goodbit) {
5725             for(; pad!=0; pad--) {
5726                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5727                     state = IOSTATE_badbit;
5728                     break;
5729                 }
5730             }
5731         }
5732
5733         base->base.wide = 0;
5734     }else {
5735         state = IOSTATE_badbit;
5736     }
5737     basic_ostream_char_sentry_destroy(ostr);
5738
5739     basic_ios_char_setstate(base, state);
5740     return ostr;
5741 }
5742
5743 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBC@Z */
5744 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBC@Z */
5745 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z */
5746 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z */
5747 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBE@Z */
5748 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBE@Z */
5749 basic_ostream_char* __cdecl basic_ostream_char_print_str(basic_ostream_char *ostr, const char *str)
5750 {
5751     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5752     IOSB_iostate state = IOSTATE_goodbit;
5753
5754     TRACE("(%p %s)\n", ostr, str);
5755
5756     if(basic_ostream_char_sentry_create(ostr)) {
5757         MSVCP_size_t len = strlen(str);
5758         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5759
5760         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5761             for(; pad!=0; pad--) {
5762                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5763                     state = IOSTATE_badbit;
5764                     break;
5765                 }
5766             }
5767         }
5768
5769         if(state == IOSTATE_goodbit) {
5770             if(basic_streambuf_char_sputn(base->strbuf, str, len) != len)
5771                 state = IOSTATE_badbit;
5772         }
5773
5774         if(state == IOSTATE_goodbit) {
5775             for(; pad!=0; pad--) {
5776                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5777                     state = IOSTATE_badbit;
5778                     break;
5779                 }
5780             }
5781         }
5782
5783         base->base.wide = 0;
5784     }else {
5785         state = IOSTATE_badbit;
5786     }
5787     basic_ostream_char_sentry_destroy(ostr);
5788
5789     basic_ios_char_setstate(base, state);
5790     return ostr;
5791 }
5792
5793 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
5794 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
5795 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
5796 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
5797         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
5798 {
5799     TRACE("(%p %p)\n", this, pfunc);
5800     pfunc(this);
5801     return this;
5802 }
5803
5804 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
5805 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
5806 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
5807 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
5808         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
5809 {
5810     TRACE("(%p %p)\n", this, pfunc);
5811     pfunc(basic_ostream_char_get_basic_ios(this));
5812     return this;
5813 }
5814
5815 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
5816 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
5817 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
5818 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
5819         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
5820 {
5821     TRACE("(%p %p)\n", this, pfunc);
5822     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
5823     return this;
5824 }
5825
5826 /* Caution: basic_ostream uses virtual inheritance. */
5827 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
5828 {
5829     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
5830 }
5831
5832 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
5833 {
5834     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
5835 }
5836
5837 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
5838 {
5839     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
5840 }
5841
5842 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
5843 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
5844 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor, 20)
5845 basic_ostream_wchar* __thiscall basic_ostream_short_ctor(basic_ostream_wchar *this,
5846         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool init, MSVCP_bool virt_init)
5847 {
5848     basic_ios_wchar *base;
5849
5850     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, init, virt_init);
5851
5852     if(virt_init) {
5853         this->vbtable = basic_ostream_wchar_vbtable;
5854         base = basic_ostream_wchar_get_basic_ios(this);
5855         basic_ios_wchar_ctor(base);
5856     }else {
5857         base = basic_ostream_wchar_get_basic_ios(this);
5858     }
5859
5860     base->base.vtable = &MSVCP_basic_ostream_short_vtable;
5861     if(init)
5862         basic_ios_wchar_init(base, strbuf, isstd);
5863     return this;
5864 }
5865
5866 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
5867 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
5868 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor_uninitialized, 12)
5869 basic_ostream_wchar* __thiscall basic_ostream_short_ctor_uninitialized(basic_ostream_wchar *this,
5870         int uninitialized, MSVCP_bool virt_init)
5871 {
5872     basic_ios_wchar *base;
5873
5874     TRACE("(%p %d)\n", this, uninitialized);
5875
5876     if(virt_init) {
5877         this->vbtable = basic_ostream_wchar_vbtable;
5878         base = basic_ostream_wchar_get_basic_ios(this);
5879         basic_ios_wchar_ctor(base);
5880     }else {
5881         base = basic_ostream_wchar_get_basic_ios(this);
5882     }
5883
5884     base->base.vtable = &MSVCP_basic_ostream_short_vtable;
5885     ios_base_Addstd(&base->base);
5886     return this;
5887 }
5888
5889 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
5890 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
5891 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
5892 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
5893 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
5894 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
5895 {
5896     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
5897
5898     /* don't destroy virtual base here */
5899     TRACE("(%p)\n", this);
5900 }
5901
5902 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
5903 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
5904 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
5905 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
5906 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
5907 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
5908 {
5909     TRACE("(%p)\n", this);
5910     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
5911     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
5912 }
5913
5914 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
5915 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
5916 {
5917     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
5918
5919     TRACE("(%p %x)\n", this, flags);
5920
5921     if(flags & 2) {
5922         /* we have an array, with the number of elements stored before the first object */
5923         INT_PTR i, *ptr = (INT_PTR *)this-1;
5924
5925         for(i=*ptr-1; i>=0; i--)
5926             basic_ostream_wchar_vbase_dtor(this+i);
5927         MSVCRT_operator_delete(ptr);
5928     } else {
5929         basic_ostream_wchar_vbase_dtor(this);
5930         if(flags & 1)
5931             MSVCRT_operator_delete(this);
5932     }
5933
5934     return this;
5935 }
5936
5937 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
5938 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
5939 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
5940 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
5941 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
5942 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
5943 {
5944     /* this function is not matching C++ specification */
5945     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5946
5947     TRACE("(%p)\n", this);
5948
5949     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
5950             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
5951         basic_ios_wchar_setstate(base, IOSTATE_badbit);
5952     return this;
5953 }
5954
5955 /* ?flush@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
5956 /* ?flush@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
5957 /* ?flush@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
5958 /* ?flush@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
5959 basic_ostream_wchar* __cdecl flush_ostream_wchar(basic_ostream_wchar *ostream)
5960 {
5961     return basic_ostream_wchar_flush(ostream);
5962 }
5963
5964 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
5965 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
5966 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
5967 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
5968 static void basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
5969 {
5970     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5971
5972     TRACE("(%p)\n", this);
5973
5974     if(base->base.fmtfl & FMTFLAG_unitbuf)
5975         basic_ostream_wchar_flush(this);
5976 }
5977
5978 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
5979 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
5980 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
5981 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
5982 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
5983 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
5984 {
5985     TRACE("(%p)\n", this);
5986     basic_ostream_wchar__Osfx(this);
5987 }
5988
5989 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
5990 {
5991     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
5992
5993     if(basic_ios_wchar_rdbuf_get(base))
5994         basic_streambuf_wchar__Lock(base->strbuf);
5995
5996     if(ios_base_good(&base->base) && base->stream)
5997         basic_ostream_wchar_flush(base->stream);
5998
5999     return ios_base_good(&base->base);
6000 }
6001
6002 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
6003 {
6004     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6005
6006     if(ios_base_good(&base->base) && !__uncaught_exception())
6007         basic_ostream_wchar_osfx(ostr);
6008
6009     if(basic_ios_wchar_rdbuf_get(base))
6010         basic_streambuf_wchar__Unlock(base->strbuf);
6011 }
6012
6013 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
6014 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
6015 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
6016 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
6017 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
6018 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
6019 {
6020     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6021
6022     TRACE("(%p)\n", this);
6023
6024     if(ios_base_good(&base->base) && base->stream)
6025         basic_ostream_wchar_flush(base->stream);
6026     return ios_base_good(&base->base);
6027 }
6028
6029 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
6030 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
6031 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
6032 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
6033 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
6034 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
6035 {
6036     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6037
6038     TRACE("(%p %c)\n", this, ch);
6039
6040     if(!basic_ostream_wchar_sentry_create(this)
6041             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
6042         basic_ostream_wchar_sentry_destroy(this);
6043         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6044         return this;
6045     }
6046
6047     basic_ostream_wchar_sentry_destroy(this);
6048     return this;
6049 }
6050
6051 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6052 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6053 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6054 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6055 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
6056 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
6057 {
6058     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6059
6060     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6061
6062     if(!ios_base_fail(&base->base)) {
6063         fpos_int seek;
6064
6065         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
6066                 &seek, pos, OPENMODE_out);
6067         if(seek.off==-1 && seek.pos==0 && seek.state==0)
6068             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6069     }
6070     return this;
6071 }
6072
6073 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6074 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6075 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6076 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6077 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
6078 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
6079 {
6080     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6081
6082     TRACE("(%p)\n", this);
6083
6084     if(!ios_base_fail(&base->base)) {
6085         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6086                 ret, 0, SEEKDIR_cur, OPENMODE_out);
6087     }else {
6088         ret->off = -1;
6089         ret->pos = 0;
6090         ret->state = 0;
6091     }
6092     return ret;
6093 }
6094
6095 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
6096 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
6097 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
6098 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
6099 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 12)
6100 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
6101 {
6102     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6103
6104     TRACE("(%p %s %ld)\n", this, debugstr_w(str), count);
6105
6106     if(!basic_ostream_wchar_sentry_create(this)
6107             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
6108         basic_ostream_wchar_sentry_destroy(this);
6109         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6110         return this;
6111     }
6112
6113     basic_ostream_wchar_sentry_destroy(this);
6114     return this;
6115 }
6116
6117 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
6118 {
6119     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6120     int state = IOSTATE_goodbit;
6121
6122     TRACE("(%p %d)\n", this, val);
6123
6124     if(basic_ostream_wchar_sentry_create(this)) {
6125         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6126         ostreambuf_iterator_wchar dest = {0, strbuf};
6127
6128         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
6129                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
6130                 ? (LONG)((unsigned short)val) : (LONG)val);
6131     }
6132     basic_ostream_wchar_sentry_destroy(this);
6133
6134     basic_ios_wchar_setstate(base, state);
6135     return this;
6136 }
6137
6138 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
6139 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
6140 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
6141 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
6142 {
6143     return basic_ostream_print_short(this, val, num_put_short_use_facet(
6144                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6145 }
6146
6147 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
6148 {
6149     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6150     int state = IOSTATE_goodbit;
6151
6152     TRACE("(%p %d)\n", this, val);
6153
6154     if(basic_ostream_wchar_sentry_create(this)) {
6155         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6156         ostreambuf_iterator_wchar dest = {0, strbuf};
6157
6158         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6159     }
6160     basic_ostream_wchar_sentry_destroy(this);
6161
6162     basic_ios_wchar_setstate(base, state);
6163     return this;
6164 }
6165
6166 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
6167 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
6168 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
6169 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
6170 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
6171 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
6172 {
6173     return basic_ostream_print_int(this, val, num_put_short_use_facet(
6174                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6175 }
6176
6177 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
6178 {
6179     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6180     int state = IOSTATE_goodbit;
6181
6182     TRACE("(%p %u)\n", this, val);
6183
6184     if(basic_ostream_wchar_sentry_create(this)) {
6185         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6186         ostreambuf_iterator_wchar dest = {0, strbuf};
6187
6188         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6189     }
6190     basic_ostream_wchar_sentry_destroy(this);
6191
6192     basic_ios_wchar_setstate(base, state);
6193     return this;
6194 }
6195
6196 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
6197 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
6198 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
6199 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
6200 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
6201 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
6202 {
6203     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
6204                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6205 }
6206
6207 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
6208 {
6209     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6210     int state = IOSTATE_goodbit;
6211
6212     TRACE("(%p %f)\n", this, val);
6213
6214     if(basic_ostream_wchar_sentry_create(this)) {
6215         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6216         ostreambuf_iterator_wchar dest = {0, strbuf};
6217
6218         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6219     }
6220     basic_ostream_wchar_sentry_destroy(this);
6221
6222     basic_ios_wchar_setstate(base, state);
6223     return this;
6224 }
6225
6226 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
6227 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
6228 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
6229 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
6230 {
6231     return basic_ostream_print_float(this, val, num_put_short_use_facet(
6232                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6233 }
6234
6235 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
6236 {
6237     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6238     int state = IOSTATE_goodbit;
6239
6240     TRACE("(%p %lf)\n", this, val);
6241
6242     if(basic_ostream_wchar_sentry_create(this)) {
6243         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6244         ostreambuf_iterator_wchar dest = {0, strbuf};
6245
6246         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6247     }
6248     basic_ostream_wchar_sentry_destroy(this);
6249
6250     basic_ios_wchar_setstate(base, state);
6251     return this;
6252 }
6253
6254 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
6255 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
6256 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
6257 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
6258 {
6259     return basic_ostream_print_double(this, val, num_put_short_use_facet(
6260                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6261 }
6262
6263 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
6264 {
6265     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6266     int state = IOSTATE_goodbit;
6267
6268     TRACE("(%p %lf)\n", this, val);
6269
6270     if(basic_ostream_wchar_sentry_create(this)) {
6271         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6272         ostreambuf_iterator_wchar dest = {0, strbuf};
6273
6274         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6275     }
6276     basic_ostream_wchar_sentry_destroy(this);
6277
6278     basic_ios_wchar_setstate(base, state);
6279     return this;
6280 }
6281
6282 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
6283 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
6284 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
6285 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
6286 {
6287     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
6288                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6289 }
6290
6291 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6292 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6293 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6294 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6295 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
6296 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
6297 {
6298     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6299     IOSB_iostate state = IOSTATE_badbit;
6300     unsigned short c = '\n';
6301
6302     TRACE("(%p %p)\n", this, val);
6303
6304     if(basic_ostream_wchar_sentry_create(this)) {
6305         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
6306                 c = basic_streambuf_wchar_snextc(val)) {
6307             state = IOSTATE_goodbit;
6308
6309             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
6310                 state = IOSTATE_badbit;
6311                 break;
6312             }
6313         }
6314     }else {
6315         state = IOSTATE_badbit;
6316     }
6317     basic_ostream_wchar_sentry_destroy(this);
6318
6319     ios_base_width_set(&base->base, 0);
6320     basic_ios_wchar_setstate(base, state);
6321     return this;
6322 }
6323
6324 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
6325 {
6326     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6327     int state = IOSTATE_goodbit;
6328
6329     TRACE("(%p %p)\n", this, val);
6330
6331     if(basic_ostream_wchar_sentry_create(this)) {
6332         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6333         ostreambuf_iterator_wchar dest = {0, strbuf};
6334
6335         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6336     }
6337     basic_ostream_wchar_sentry_destroy(this);
6338
6339     basic_ios_wchar_setstate(base, state);
6340     return this;
6341 }
6342
6343 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
6344 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
6345 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
6346 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
6347 {
6348     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
6349                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6350 }
6351
6352 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
6353 {
6354     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6355     int state = IOSTATE_goodbit;
6356
6357     TRACE("(%p)\n", this);
6358
6359     if(basic_ostream_wchar_sentry_create(this)) {
6360         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6361         ostreambuf_iterator_wchar dest = {0, strbuf};
6362
6363         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6364     }
6365     basic_ostream_wchar_sentry_destroy(this);
6366
6367     basic_ios_wchar_setstate(base, state);
6368     return this;
6369 }
6370
6371 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
6372 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
6373 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
6374 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
6375 {
6376     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
6377                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6378 }
6379
6380 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
6381 {
6382     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6383     int state = IOSTATE_goodbit;
6384
6385     TRACE("(%p)\n", this);
6386
6387     if(basic_ostream_wchar_sentry_create(this)) {
6388         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6389         ostreambuf_iterator_wchar dest = {0, strbuf};
6390
6391         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6392     }
6393     basic_ostream_wchar_sentry_destroy(this);
6394
6395     basic_ios_wchar_setstate(base, state);
6396     return this;
6397 }
6398
6399 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
6400 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
6401 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
6402 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6403 {
6404     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
6405                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6406 }
6407
6408 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
6409 {
6410     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6411     int state = IOSTATE_goodbit;
6412
6413     TRACE("(%p %x)\n", this, val);
6414
6415     if(basic_ostream_wchar_sentry_create(this)) {
6416         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6417         ostreambuf_iterator_wchar dest = {0, strbuf};
6418
6419         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6420     }
6421     basic_ostream_wchar_sentry_destroy(this);
6422
6423     basic_ios_wchar_setstate(base, state);
6424     return this;
6425 }
6426
6427 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
6428 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
6429 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
6430 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6431 {
6432     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
6433                 &basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6434 }
6435
6436 /* ?ends@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6437 /* ?ends@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6438 /* ?ends@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6439 /* ?ends@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6440 basic_ostream_wchar* __cdecl basic_ostream_wchar_ends(basic_ostream_wchar *ostr)
6441 {
6442     TRACE("(%p)\n", ostr);
6443
6444     basic_ostream_wchar_put(ostr, 0);
6445     return ostr;
6446 }
6447
6448 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6449 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6450 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6451 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6452 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
6453 {
6454     TRACE("(%p)\n", ostr);
6455
6456     basic_ostream_wchar_put(ostr, '\n');
6457     basic_ostream_wchar_flush(ostr);
6458     return ostr;
6459 }
6460
6461 /* ??$?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 */
6462 /* ??$?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 */
6463 /* ??$?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 */
6464 /* ??$?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 */
6465 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_bstr(basic_ostream_wchar *ostr, const basic_string_wchar *str)
6466 {
6467     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6468     IOSB_iostate state = IOSTATE_goodbit;
6469
6470     TRACE("(%p %p)\n", ostr, str);
6471
6472     if(basic_ostream_wchar_sentry_create(ostr)) {
6473         MSVCP_size_t len = basic_string_wchar_length(str);
6474         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6475
6476         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6477             for(; pad!=0; pad--) {
6478                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6479                     state = IOSTATE_badbit;
6480                     break;
6481                 }
6482             }
6483         }
6484
6485         if(state == IOSTATE_goodbit) {
6486             if(basic_streambuf_wchar_sputn(base->strbuf, basic_string_wchar_c_str(str), len) != len)
6487                 state = IOSTATE_badbit;
6488         }
6489
6490         if(state == IOSTATE_goodbit) {
6491             for(; pad!=0; pad--) {
6492                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6493                     state = IOSTATE_badbit;
6494                     break;
6495                 }
6496             }
6497         }
6498
6499         base->base.wide = 0;
6500     }else {
6501         state = IOSTATE_badbit;
6502     }
6503     basic_ostream_wchar_sentry_destroy(ostr);
6504
6505     basic_ios_wchar_setstate(base, state);
6506     return ostr;
6507 }
6508
6509 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@_W@Z */
6510 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@_W@Z */
6511 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@G@Z */
6512 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@G@Z */
6513 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_ch(basic_ostream_wchar *ostr, wchar_t ch)
6514 {
6515     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6516     IOSB_iostate state = IOSTATE_goodbit;
6517
6518     TRACE("(%p %d)\n", ostr, ch);
6519
6520     if(basic_ostream_wchar_sentry_create(ostr)) {
6521         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6522
6523         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6524             for(; pad!=0; pad--) {
6525                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6526                     state = IOSTATE_badbit;
6527                     break;
6528                 }
6529             }
6530         }
6531
6532         if(state == IOSTATE_goodbit) {
6533             if(basic_streambuf_wchar_sputc(base->strbuf, ch) == WEOF)
6534                 state = IOSTATE_badbit;
6535         }
6536
6537         if(state == IOSTATE_goodbit) {
6538             for(; pad!=0; pad--) {
6539                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6540                     state = IOSTATE_badbit;
6541                     break;
6542                 }
6543             }
6544         }
6545
6546         base->base.wide = 0;
6547     }else {
6548         state = IOSTATE_badbit;
6549     }
6550     basic_ostream_wchar_sentry_destroy(ostr);
6551
6552     basic_ios_wchar_setstate(base, state);
6553     return ostr;
6554 }
6555
6556 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@PB_W@Z */
6557 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@PEB_W@Z */
6558 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@PBG@Z */
6559 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@PEBG@Z */
6560 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_str(basic_ostream_wchar *ostr, const wchar_t *str)
6561 {
6562     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6563     IOSB_iostate state = IOSTATE_goodbit;
6564
6565     TRACE("(%p %s)\n", ostr, debugstr_w(str));
6566
6567     if(basic_ostream_wchar_sentry_create(ostr)) {
6568         MSVCP_size_t len = wcslen(str);
6569         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6570
6571         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6572             for(; pad!=0; pad--) {
6573                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6574                     state = IOSTATE_badbit;
6575                     break;
6576                 }
6577             }
6578         }
6579
6580         if(state == IOSTATE_goodbit) {
6581             if(basic_streambuf_wchar_sputn(base->strbuf, str, len) != len)
6582                                         state = IOSTATE_badbit;
6583         }
6584
6585         if(state == IOSTATE_goodbit) {
6586             for(; pad!=0; pad--) {
6587                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6588                     state = IOSTATE_badbit;
6589                     break;
6590                 }
6591             }
6592         }
6593
6594         base->base.wide = 0;
6595     }else {
6596         state = IOSTATE_badbit;
6597     }
6598     basic_ostream_wchar_sentry_destroy(ostr);
6599
6600     basic_ios_wchar_setstate(base, state);
6601     return ostr;
6602 }
6603
6604 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6605 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6606 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6607 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6608 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
6609 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
6610         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
6611 {
6612     TRACE("(%p %p)\n", this, pfunc);
6613     pfunc(this);
6614     return this;
6615 }
6616
6617 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
6618 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
6619 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
6620 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
6621 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
6622 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
6623         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
6624 {
6625     TRACE("(%p %p)\n", this, pfunc);
6626     pfunc(basic_ostream_wchar_get_basic_ios(this));
6627     return this;
6628 }
6629
6630 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6631 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6632 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6633 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6634 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
6635 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
6636         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
6637 {
6638     TRACE("(%p %p)\n", this, pfunc);
6639     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
6640     return this;
6641 }
6642
6643 /* Caution: basic_istream uses virtual inheritance. */
6644 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
6645 {
6646     return (basic_ios_char*)((char*)this+this->vbtable[1]);
6647 }
6648
6649 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
6650 {
6651     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
6652 }
6653
6654 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
6655 {
6656     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
6657 }
6658
6659 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6660 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
6661 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)
6662 {
6663     basic_ios_char *base;
6664
6665     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
6666
6667     if(virt_init) {
6668         this->vbtable = basic_istream_char_vbtable;
6669         base = basic_istream_char_get_basic_ios(this);
6670         basic_ios_char_ctor(base);
6671     }else {
6672         base = basic_istream_char_get_basic_ios(this);
6673     }
6674
6675     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6676     this->count = 0;
6677     if(!noinit)
6678         basic_ios_char_init(base, strbuf, isstd);
6679     return this;
6680 }
6681
6682 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6683 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
6684 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
6685 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6686 {
6687     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
6688 }
6689
6690 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
6691 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
6692 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
6693 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
6694 {
6695     basic_ios_char *base;
6696
6697     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
6698
6699     if(virt_init) {
6700         this->vbtable = basic_istream_char_vbtable;
6701         base = basic_istream_char_get_basic_ios(this);
6702         basic_ios_char_ctor(base);
6703     }else {
6704         base = basic_istream_char_get_basic_ios(this);
6705     }
6706
6707     base->base.vtable = &MSVCP_basic_istream_char_vtable;
6708     ios_base_Addstd(&base->base);
6709     return this;
6710 }
6711
6712 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
6713 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
6714 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
6715 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
6716 {
6717     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6718
6719     /* don't destroy virtual base here */
6720     TRACE("(%p)\n", this);
6721 }
6722
6723 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6724 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6725 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
6726 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
6727 {
6728     TRACE("(%p)\n", this);
6729     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
6730     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
6731 }
6732
6733 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
6734 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
6735 {
6736     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
6737
6738     TRACE("(%p %x)\n", this, flags);
6739
6740     if(flags & 2) {
6741         /* we have an array, with the number of elements stored before the first object */
6742         INT_PTR i, *ptr = (INT_PTR *)this-1;
6743
6744         for(i=*ptr-1; i>=0; i--)
6745             basic_istream_char_vbase_dtor(this+i);
6746         MSVCRT_operator_delete(ptr);
6747     } else {
6748         basic_istream_char_vbase_dtor(this);
6749         if(flags & 1)
6750             MSVCRT_operator_delete(this);
6751     }
6752
6753     return this;
6754 }
6755
6756 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6757 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6758 static MSVCP_bool basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
6759 {
6760     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6761
6762     TRACE("(%p %d)\n", this, noskip);
6763
6764     if(ios_base_good(&base->base)) {
6765         if(basic_ios_char_tie_get(base))
6766             basic_ostream_char_flush(basic_ios_char_tie_get(base));
6767
6768         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
6769             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6770             const ctype_char *ctype = ctype_char_use_facet(&base->strbuf->loc);
6771             int ch;
6772
6773             for(ch = basic_streambuf_char_sgetc(strbuf); ;
6774                     ch = basic_streambuf_char_snextc(strbuf)) {
6775                 if(ch==EOF || !ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
6776                     break;
6777             }
6778         }
6779     }
6780
6781     if(!ios_base_good(&base->base)) {
6782         basic_ios_char_setstate(base, IOSTATE_failbit);
6783         return FALSE;
6784     }
6785
6786     return TRUE;
6787 }
6788
6789 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
6790 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
6791 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
6792 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
6793 {
6794     return basic_istream_char__Ipfx(this, noskip);
6795 }
6796
6797 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
6798 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
6799 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
6800 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
6801 {
6802     TRACE("(%p)\n", this);
6803 }
6804
6805 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
6806 {
6807     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6808
6809     if(basic_ios_char_rdbuf_get(base))
6810         basic_streambuf_char__Lock(base->strbuf);
6811
6812     return basic_istream_char_ipfx(istr, noskip);
6813 }
6814
6815 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
6816 {
6817     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
6818
6819     if(basic_ios_char_rdbuf_get(base))
6820         basic_streambuf_char__Unlock(base->strbuf);
6821 }
6822
6823 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
6824 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
6825 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
6826 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
6827 {
6828     TRACE("(%p)\n", this);
6829     return this->count;
6830 }
6831
6832 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
6833 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
6834 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
6835 int __thiscall basic_istream_char_get(basic_istream_char *this)
6836 {
6837     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6838     int ret;
6839
6840     TRACE("(%p)\n", this);
6841
6842     this->count = 0;
6843
6844     if(!basic_istream_char_sentry_create(this, TRUE)) {
6845         basic_istream_char_sentry_destroy(this);
6846         return EOF;
6847     }
6848
6849     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
6850     basic_istream_char_sentry_destroy(this);
6851     if(ret == EOF)
6852         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
6853     else
6854         this->count++;
6855
6856     return ret;
6857 }
6858
6859 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
6860 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
6861 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
6862 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
6863 {
6864     int ret;
6865
6866     TRACE("(%p %p)\n", this, ch);
6867
6868     ret = basic_istream_char_get(this);
6869     if(ret != EOF)
6870         *ch = (char)ret;
6871     return this;
6872 }
6873
6874 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
6875 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
6876 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
6877 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
6878 {
6879     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6880     int ch = delim;
6881
6882     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
6883
6884     this->count = 0;
6885
6886     if(basic_istream_char_sentry_create(this, TRUE)) {
6887         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6888
6889         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
6890                 ch = basic_streambuf_char_snextc(strbuf)) {
6891             if(ch==EOF || ch==delim)
6892                 break;
6893
6894             *str++ = ch;
6895             this->count++;
6896             count--;
6897         }
6898     }
6899     basic_istream_char_sentry_destroy(this);
6900
6901     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
6902             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
6903     if(count > 0)
6904         *str = 0;
6905     return this;
6906 }
6907
6908 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
6909 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
6910 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
6911 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
6912 {
6913     return basic_istream_char_get_str_delim(this, str, count, '\n');
6914 }
6915
6916 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
6917 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
6918 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
6919 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
6920 {
6921     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6922     int ch = delim;
6923
6924     TRACE("(%p %p %c)\n", this, strbuf, delim);
6925
6926     this->count = 0;
6927
6928     if(basic_istream_char_sentry_create(this, TRUE)) {
6929         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
6930
6931         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
6932                 ch = basic_streambuf_char_snextc(strbuf_read)) {
6933             if(ch==EOF || ch==delim)
6934                 break;
6935
6936             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
6937                 break;
6938             this->count++;
6939         }
6940     }
6941     basic_istream_char_sentry_destroy(this);
6942
6943     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
6944             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
6945     return this;
6946 }
6947
6948 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
6949 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
6950 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
6951 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
6952 {
6953     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
6954 }
6955
6956 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
6957 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
6958 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
6959 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
6960 {
6961     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6962     int ch = (unsigned char)delim;
6963
6964     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
6965
6966     this->count = 0;
6967
6968     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
6969         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6970
6971         while(count > 1) {
6972             ch = basic_streambuf_char_sbumpc(strbuf);
6973
6974             if(ch==EOF || ch==(unsigned char)delim)
6975                 break;
6976
6977             *str++ = ch;
6978             this->count++;
6979             count--;
6980         }
6981
6982         if(ch == (unsigned char)delim)
6983             this->count++;
6984         else if(ch != EOF) {
6985             ch = basic_streambuf_char_sgetc(strbuf);
6986
6987             if(ch == (unsigned char)delim) {
6988                 basic_streambuf_char__Gninc(strbuf);
6989                 this->count++;
6990             }
6991         }
6992     }
6993     basic_istream_char_sentry_destroy(this);
6994
6995     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
6996             (!this->count || (ch!=(unsigned char)delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
6997     if(count > 0)
6998         *str = 0;
6999     return this;
7000 }
7001
7002 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7003 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7004 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
7005 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
7006 {
7007     return basic_istream_char_getline_delim(this, str, count, '\n');
7008 }
7009
7010 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
7011 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7012 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
7013 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
7014 {
7015     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7016     int ch = (unsigned char)delim;
7017     unsigned int state;
7018
7019     TRACE("(%p %ld %d)\n", this, count, delim);
7020
7021     this->count = 0;
7022
7023     if(basic_istream_char_sentry_create(this, TRUE)) {
7024         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7025         state = IOSTATE_goodbit;
7026
7027         while(count > 0) {
7028             ch = basic_streambuf_char_sbumpc(strbuf);
7029
7030             if(ch==EOF) {
7031                 state = IOSTATE_eofbit;
7032                 break;
7033             }
7034
7035             if(ch==(unsigned char)delim)
7036                 break;
7037
7038             this->count++;
7039             if(count != INT_MAX)
7040                 count--;
7041         }
7042     }else
7043         state = IOSTATE_failbit;
7044     basic_istream_char_sentry_destroy(this);
7045
7046     basic_ios_char_setstate(base, state);
7047     return this;
7048 }
7049
7050 /* ?ws@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@1@AAV21@@Z */
7051 /* ?ws@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
7052 basic_istream_char* __cdecl ws_basic_istream_char(basic_istream_char *istream)
7053 {
7054     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7055     int ch = '\n';
7056
7057     TRACE("(%p)\n", istream);
7058
7059     if(basic_istream_char_sentry_create(istream, TRUE)) {
7060         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7061         const ctype_char *ctype = ctype_char_use_facet(&strbuf->loc);
7062
7063         for(ch = basic_streambuf_char_sgetc(strbuf); ctype_char_is_ch(ctype, _SPACE, ch);
7064                 ch = basic_streambuf_char_snextc(strbuf)) {
7065             if(ch == EOF)
7066                 break;
7067         }
7068     }
7069     basic_istream_char_sentry_destroy(istream);
7070
7071     if(ch == EOF)
7072         basic_ios_char_setstate(base, IOSTATE_eofbit);
7073     return istream;
7074 }
7075
7076 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7077 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7078 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
7079 int __thiscall basic_istream_char_peek(basic_istream_char *this)
7080 {
7081     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7082     int ret = EOF;
7083
7084     TRACE("(%p)\n", this);
7085
7086     this->count = 0;
7087
7088     if(basic_istream_char_sentry_create(this, TRUE))
7089         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7090     basic_istream_char_sentry_destroy(this);
7091
7092     if (ret == EOF)
7093         basic_ios_char_setstate(base, IOSTATE_eofbit);
7094
7095     return ret;
7096 }
7097
7098 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
7099 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
7100 static basic_istream_char* basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7101 {
7102     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7103     IOSB_iostate state = IOSTATE_goodbit;
7104
7105     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7106
7107     if(basic_istream_char_sentry_create(this, TRUE)) {
7108         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7109
7110         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
7111         if(this->count != count)
7112             state |= IOSTATE_failbit | IOSTATE_eofbit;
7113     }else {
7114         this->count = 0;
7115     }
7116     basic_istream_char_sentry_destroy(this);
7117
7118     basic_ios_char_setstate(base, state);
7119     return this;
7120 }
7121
7122 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7123 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7124 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
7125 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
7126 {
7127     return basic_istream_char__Read_s(this, str, count, count);
7128 }
7129
7130 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
7131 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
7132 static streamsize basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7133 {
7134     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7135     IOSB_iostate state = IOSTATE_goodbit;
7136
7137     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7138
7139     this->count = 0;
7140
7141     if(basic_istream_char_sentry_create(this, TRUE)) {
7142         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
7143         if(avail > count)
7144             avail = count;
7145
7146         if(avail == -1)
7147             state |= IOSTATE_eofbit;
7148         else if(avail > 0)
7149             basic_istream_char__Read_s(this, str, size, avail);
7150     }else {
7151         state |= IOSTATE_failbit;
7152     }
7153     basic_istream_char_sentry_destroy(this);
7154
7155     basic_ios_char_setstate(base, state);
7156     return this->count;
7157 }
7158
7159 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
7160 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
7161 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
7162 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
7163 {
7164     return basic_istream_char__Readsome_s(this, str, count, count);
7165 }
7166
7167 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
7168 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
7169 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
7170 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
7171 {
7172     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7173     IOSB_iostate state = IOSTATE_goodbit;
7174
7175     TRACE("(%p %c)\n", this, ch);
7176
7177     this->count = 0;
7178
7179     if(basic_istream_char_sentry_create(this, TRUE)) {
7180         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7181
7182         if(!ios_base_good(&base->base))
7183             state |= IOSTATE_failbit;
7184         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
7185             state |= IOSTATE_badbit;
7186     }
7187     basic_istream_char_sentry_destroy(this);
7188
7189     basic_ios_char_setstate(base, state);
7190     return this;
7191 }
7192
7193 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
7194 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
7195 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
7196 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
7197 {
7198     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7199     IOSB_iostate state = IOSTATE_goodbit;
7200
7201     TRACE("(%p)\n", this);
7202
7203     this->count = 0;
7204
7205     if(basic_istream_char_sentry_create(this, TRUE)) {
7206         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7207
7208         if(!ios_base_good(&base->base))
7209             state |= IOSTATE_failbit;
7210         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
7211             state |= IOSTATE_badbit;
7212     }
7213     basic_istream_char_sentry_destroy(this);
7214
7215     basic_ios_char_setstate(base, state);
7216     return this;
7217 }
7218
7219 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7220 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7221 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
7222 int __thiscall basic_istream_char_sync(basic_istream_char *this)
7223 {
7224     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7225     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7226
7227     TRACE("(%p)\n", this);
7228
7229     if(!strbuf)
7230         return -1;
7231
7232     if(basic_istream_char_sentry_create(this, TRUE)) {
7233         if(basic_streambuf_char_pubsync(strbuf) != -1) {
7234             basic_istream_char_sentry_destroy(this);
7235             return 0;
7236         }
7237     }
7238     basic_istream_char_sentry_destroy(this);
7239
7240     basic_ios_char_setstate(base, IOSTATE_badbit);
7241     return -1;
7242 }
7243
7244 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7245 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7246 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
7247 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
7248 {
7249     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7250
7251     TRACE("(%p %p)\n", this, ret);
7252
7253     if(ios_base_fail(&base->base)) {
7254         ret->off = -1;
7255         ret->pos = 0;
7256         ret->state = 0;
7257         return ret;
7258     }
7259
7260     basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
7261             ret, 0, SEEKDIR_cur, OPENMODE_in);
7262
7263     if(ret->off==-1 && ret->pos==0 && ret->state==0)
7264         basic_ios_char_setstate(base, IOSTATE_failbit);
7265
7266     return ret;
7267 }
7268
7269 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z */
7270 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z */
7271 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
7272 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
7273 {
7274     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7275
7276     TRACE("(%p %ld %d)\n", this, off, dir);
7277
7278     if(!ios_base_fail(&base->base)) {
7279         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7280         fpos_int ret;
7281
7282         basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
7283     }
7284
7285     return this;
7286 }
7287
7288 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7289 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7290 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
7291 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
7292 {
7293     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7294
7295     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7296
7297     if(!ios_base_fail(&base->base)) {
7298         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7299         fpos_int ret;
7300
7301         basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7302     }
7303
7304     return this;
7305 }
7306
7307 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
7308 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
7309 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
7310 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
7311 {
7312     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7313     int state = IOSTATE_goodbit;
7314
7315     TRACE("(%p %p)\n", this, v);
7316
7317     if(basic_istream_char_sentry_create(this, FALSE)) {
7318         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7319         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7320         istreambuf_iterator_char first={0}, last={0};
7321         LONG tmp;
7322
7323         first.strbuf = strbuf;
7324         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7325
7326         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7327             *v = tmp;
7328         else
7329             state |= IOSTATE_failbit;
7330     }
7331     basic_istream_char_sentry_destroy(this);
7332
7333     basic_ios_char_setstate(base, state);
7334     return this;
7335 }
7336
7337 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
7338 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
7339 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
7340 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
7341 {
7342     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7343     int state = IOSTATE_goodbit;
7344
7345     TRACE("(%p %p)\n", this, v);
7346
7347     if(basic_istream_char_sentry_create(this, FALSE)) {
7348         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7349         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7350         istreambuf_iterator_char first={0}, last={0};
7351
7352         first.strbuf = strbuf;
7353         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
7354     }
7355     basic_istream_char_sentry_destroy(this);
7356
7357     basic_ios_char_setstate(base, state);
7358     return this;
7359 }
7360
7361 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
7362 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
7363 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
7364 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
7365 {
7366     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7367     int state = IOSTATE_goodbit;
7368
7369     TRACE("(%p %p)\n", this, v);
7370
7371     if(basic_istream_char_sentry_create(this, FALSE)) {
7372         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7373         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7374         istreambuf_iterator_char first={0}, last={0};
7375
7376         first.strbuf = strbuf;
7377         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7378     }
7379     basic_istream_char_sentry_destroy(this);
7380
7381     basic_ios_char_setstate(base, state);
7382     return this;
7383 }
7384
7385 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
7386 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
7387 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
7388 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *v)
7389 {
7390     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7391     int state = IOSTATE_goodbit;
7392
7393     TRACE("(%p %p)\n", this, v);
7394
7395     if(basic_istream_char_sentry_create(this, FALSE)) {
7396         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7397         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7398         istreambuf_iterator_char first={0}, last={0};
7399
7400         first.strbuf = strbuf;
7401         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
7402     }
7403     basic_istream_char_sentry_destroy(this);
7404
7405     basic_ios_char_setstate(base, state);
7406     return this;
7407 }
7408
7409 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
7410 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
7411 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
7412 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
7413 {
7414     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7415     int state = IOSTATE_goodbit;
7416
7417     TRACE("(%p %p)\n", this, v);
7418
7419     if(basic_istream_char_sentry_create(this, FALSE)) {
7420         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7421         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7422         istreambuf_iterator_char first={0}, last={0};
7423
7424         first.strbuf = strbuf;
7425         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7426     }
7427     basic_istream_char_sentry_destroy(this);
7428
7429     basic_ios_char_setstate(base, state);
7430     return this;
7431 }
7432
7433 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
7434 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
7435 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
7436 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
7437 {
7438     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7439     int state = IOSTATE_goodbit;
7440
7441     TRACE("(%p %p)\n", this, v);
7442
7443     if(basic_istream_char_sentry_create(this, FALSE)) {
7444         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7445         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7446         istreambuf_iterator_char first={0}, last={0};
7447
7448         first.strbuf = strbuf;
7449         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
7450     }
7451     basic_istream_char_sentry_destroy(this);
7452
7453     basic_ios_char_setstate(base, state);
7454     return this;
7455 }
7456
7457 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
7458 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
7459 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
7460 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
7461 {
7462     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7463     int state = IOSTATE_goodbit;
7464
7465     TRACE("(%p %p)\n", this, v);
7466
7467     if(basic_istream_char_sentry_create(this, FALSE)) {
7468         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7469         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7470         istreambuf_iterator_char first={0}, last={0};
7471
7472         first.strbuf = strbuf;
7473         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
7474     }
7475     basic_istream_char_sentry_destroy(this);
7476
7477     basic_ios_char_setstate(base, state);
7478     return this;
7479 }
7480
7481 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
7482 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
7483 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
7484 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
7485 {
7486     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7487     int state = IOSTATE_goodbit;
7488
7489     TRACE("(%p %p)\n", this, v);
7490
7491     if(basic_istream_char_sentry_create(this, FALSE)) {
7492         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7493         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7494         istreambuf_iterator_char first={0}, last={0};
7495
7496         first.strbuf = strbuf;
7497         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
7498     }
7499     basic_istream_char_sentry_destroy(this);
7500
7501     basic_ios_char_setstate(base, state);
7502     return this;
7503 }
7504
7505 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
7506 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
7507 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
7508 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
7509 {
7510     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7511     int state = IOSTATE_goodbit;
7512
7513     TRACE("(%p %p)\n", this, v);
7514
7515     if(basic_istream_char_sentry_create(this, FALSE)) {
7516         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7517         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7518         istreambuf_iterator_char first={0}, last={0};
7519
7520         first.strbuf = strbuf;
7521         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
7522     }
7523     basic_istream_char_sentry_destroy(this);
7524
7525     basic_ios_char_setstate(base, state);
7526     return this;
7527 }
7528
7529 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
7530 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
7531 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
7532 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
7533 {
7534     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7535     int state = IOSTATE_goodbit;
7536
7537     TRACE("(%p %p)\n", this, v);
7538
7539     if(basic_istream_char_sentry_create(this, FALSE)) {
7540         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7541         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7542         istreambuf_iterator_char first={0}, last={0};
7543
7544         first.strbuf = strbuf;
7545         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
7546     }
7547     basic_istream_char_sentry_destroy(this);
7548
7549     basic_ios_char_setstate(base, state);
7550     return this;
7551 }
7552
7553 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
7554 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
7555 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
7556 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
7557 {
7558     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7559     int state = IOSTATE_goodbit;
7560
7561     TRACE("(%p %p)\n", this, v);
7562
7563     if(basic_istream_char_sentry_create(this, FALSE)) {
7564         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7565         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7566         istreambuf_iterator_char first={0}, last={0};
7567
7568         first.strbuf = strbuf;
7569         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
7570     }
7571     basic_istream_char_sentry_destroy(this);
7572
7573     basic_ios_char_setstate(base, state);
7574     return this;
7575 }
7576
7577 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
7578 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
7579 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
7580 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
7581 {
7582     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7583     int state = IOSTATE_goodbit;
7584
7585     TRACE("(%p %p)\n", this, v);
7586
7587     if(basic_istream_char_sentry_create(this, FALSE)) {
7588         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7589         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7590         istreambuf_iterator_char first={0}, last={0};
7591
7592         first.strbuf = strbuf;
7593         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
7594     }
7595     basic_istream_char_sentry_destroy(this);
7596
7597     basic_ios_char_setstate(base, state);
7598     return this;
7599 }
7600
7601 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
7602 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
7603 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
7604 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
7605 {
7606     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7607     int state = IOSTATE_goodbit;
7608
7609     TRACE("(%p %p)\n", this, v);
7610
7611     if(basic_istream_char_sentry_create(this, FALSE)) {
7612         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7613         const num_get *numget = num_get_char_use_facet(&strbuf->loc);
7614         istreambuf_iterator_char first={0}, last={0};
7615
7616         first.strbuf = strbuf;
7617         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
7618     }
7619     basic_istream_char_sentry_destroy(this);
7620
7621     basic_ios_char_setstate(base, state);
7622     return this;
7623 }
7624
7625 /* ??$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 */
7626 /* ??$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 */
7627 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
7628         basic_istream_char *istream, basic_string_char *str, char delim)
7629 {
7630     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7631     IOSB_iostate state = IOSTATE_goodbit;
7632     int c = (unsigned char)delim;
7633
7634     TRACE("(%p %p %c)\n", istream, str, delim);
7635
7636     basic_string_char_clear(str);
7637     if(basic_istream_char_sentry_create(istream, TRUE)) {
7638         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7639
7640         c = basic_streambuf_char_sgetc(strbuf);
7641         for(; c!=(unsigned char)delim && c!=EOF; c = basic_streambuf_char_snextc(strbuf))
7642             basic_string_char_append_ch(str, c);
7643         if(c==EOF) state |= IOSTATE_eofbit;
7644         else if(c==(unsigned char)delim) basic_streambuf_char_sbumpc(strbuf);
7645
7646         if(!basic_string_char_length(str) && c!=(unsigned char)delim) state |= IOSTATE_failbit;
7647     }
7648     basic_istream_char_sentry_destroy(istream);
7649
7650     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream), state);
7651     return istream;
7652 }
7653
7654 /* ??$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 */
7655 /* ??$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 */
7656 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
7657         basic_istream_char *istream, basic_string_char *str)
7658 {
7659     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
7660 }
7661
7662 /* ??$?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 */
7663 /* ??$?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 */
7664 basic_istream_char* __cdecl basic_istream_char_read_bstr(
7665         basic_istream_char *istream, basic_string_char *str)
7666 {
7667     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7668     IOSB_iostate state = IOSTATE_failbit;
7669     int c = '\n';
7670
7671     TRACE("(%p %p)\n", istream, str);
7672
7673     if(basic_istream_char_sentry_create(istream, FALSE)) {
7674         const ctype_char *ctype = ctype_char_use_facet(&base->strbuf->loc);
7675         MSVCP_size_t count = ios_base_width_get(&base->base);
7676
7677         if(!count)
7678             count = -1;
7679
7680         basic_string_char_clear(str);
7681
7682         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7683                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7684                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7685             state = IOSTATE_goodbit;
7686             basic_string_char_append_ch(str, c);
7687         }
7688     }
7689     basic_istream_char_sentry_destroy(istream);
7690
7691     ios_base_width_set(&base->base, 0);
7692     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7693     return istream;
7694 }
7695
7696 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z */
7697 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z */
7698 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAC@Z */
7699 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAC@Z */
7700 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAE@Z */
7701 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAE@Z */
7702 basic_istream_char* __cdecl basic_istream_char_read_str(basic_istream_char *istream, char *str)
7703 {
7704     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7705     IOSB_iostate state = IOSTATE_failbit;
7706     int c = '\n';
7707
7708     TRACE("(%p %p)\n", istream, str);
7709
7710     if(basic_istream_char_sentry_create(istream, FALSE)) {
7711         const ctype_char *ctype = ctype_char_use_facet(&base->strbuf->loc);
7712         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
7713
7714         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7715                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
7716                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
7717             state = IOSTATE_goodbit;
7718             *str++ = c;
7719         }
7720     }
7721     basic_istream_char_sentry_destroy(istream);
7722
7723     *str = 0;
7724     ios_base_width_set(&base->base, 0);
7725     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7726     return istream;
7727 }
7728
7729 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z */
7730 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAD@Z */
7731 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z */
7732 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAC@Z */
7733 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z */
7734 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAE@Z */
7735 basic_istream_char* __cdecl basic_istream_char_read_ch(basic_istream_char *istream, char *ch)
7736 {
7737     IOSB_iostate state = IOSTATE_failbit;
7738     int c = 0;
7739
7740     TRACE("(%p %p)\n", istream, ch);
7741
7742     if(basic_istream_char_sentry_create(istream, FALSE)) {
7743         c = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(
7744                     basic_istream_char_get_basic_ios(istream)));
7745         if(c != EOF) {
7746             state = IOSTATE_goodbit;
7747             *ch = c;
7748         }
7749     }
7750     basic_istream_char_sentry_destroy(istream);
7751
7752     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
7753             state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7754     return istream;
7755 }
7756
7757 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7758 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7759 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
7760 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
7761         basic_istream_char *this, basic_streambuf_char *streambuf)
7762 {
7763     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7764     IOSB_iostate state = IOSTATE_failbit;
7765     int c = '\n';
7766
7767     TRACE("(%p %p)\n", this, streambuf);
7768
7769     if(basic_istream_char_sentry_create(this, FALSE)) {
7770         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
7771                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
7772             state = IOSTATE_goodbit;
7773             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
7774                 break;
7775         }
7776     }
7777     basic_istream_char_sentry_destroy(this);
7778
7779     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7780     return this;
7781 }
7782
7783 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7784 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7785 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
7786 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
7787         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
7788 {
7789     TRACE("(%p %p)\n", this, pfunc);
7790     pfunc(this);
7791     return this;
7792 }
7793
7794 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
7795 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
7796 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
7797 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
7798         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
7799 {
7800     TRACE("(%p %p)\n", this, pfunc);
7801     pfunc(basic_istream_char_get_basic_ios(this));
7802     return this;
7803 }
7804
7805 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7806 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7807 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
7808 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
7809         ios_base* (__cdecl *pfunc)(ios_base*))
7810 {
7811     TRACE("(%p %p)\n", this, pfunc);
7812     pfunc(&basic_istream_char_get_basic_ios(this)->base);
7813     return this;
7814 }
7815
7816 /* Caution: basic_istream uses virtual inheritance. */
7817 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
7818 {
7819     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
7820 }
7821
7822 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
7823 {
7824     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
7825 }
7826
7827 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
7828 {
7829     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
7830 }
7831
7832 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7833 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
7834 static basic_istream_wchar* basic_istream_wchar_ctor_init(basic_istream_wchar *this,
7835         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7836 {
7837     basic_ios_wchar *base;
7838
7839     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
7840
7841     if(virt_init) {
7842         this->vbtable = basic_istream_wchar_vbtable;
7843         base = basic_istream_wchar_get_basic_ios(this);
7844         basic_ios_wchar_ctor(base);
7845     }else {
7846         base = basic_istream_wchar_get_basic_ios(this);
7847     }
7848
7849     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
7850     this->count = 0;
7851     if(!noinit)
7852         basic_ios_wchar_init(base, strbuf, isstd);
7853     return this;
7854 }
7855
7856 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7857 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
7858 static basic_istream_wchar* basic_istream_short_ctor_init(basic_istream_wchar *this,
7859         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7860 {
7861     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
7862     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
7863     return this;
7864 }
7865
7866 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
7867 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
7868 static basic_istream_wchar* basic_istream_wchar_ctor(basic_istream_wchar *this,
7869         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7870 {
7871     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7872 }
7873
7874 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
7875 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
7876 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor, 16)
7877 basic_istream_wchar* __thiscall basic_istream_short_ctor(basic_istream_wchar *this,
7878         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7879 {
7880     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7881 }
7882
7883 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7884 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7885 static basic_istream_wchar* basic_istream_wchar_ctor_uninitialized(
7886         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
7887 {
7888     basic_ios_wchar *base;
7889
7890     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
7891
7892     if(virt_init) {
7893         this->vbtable = basic_istream_wchar_vbtable;
7894         base = basic_istream_wchar_get_basic_ios(this);
7895         basic_ios_wchar_ctor(base);
7896     }else {
7897         base = basic_istream_wchar_get_basic_ios(this);
7898     }
7899
7900     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
7901     ios_base_Addstd(&base->base);
7902     return this;
7903 }
7904
7905 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7906 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7907 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
7908 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
7909         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
7910 {
7911     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
7912     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
7913     return this;
7914 }
7915
7916 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
7917 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
7918 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
7919 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
7920 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
7921 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
7922 {
7923     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
7924
7925     /* don't destroy virtual base here */
7926     TRACE("(%p)\n", this);
7927 }
7928
7929 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
7930 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
7931 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
7932 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
7933 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
7934 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
7935 {
7936     TRACE("(%p)\n", this);
7937     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
7938     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
7939 }
7940
7941 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
7942 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
7943 {
7944     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
7945
7946     TRACE("(%p %x)\n", this, flags);
7947
7948     if(flags & 2) {
7949         /* we have an array, with the number of elements stored before the first object */
7950         INT_PTR i, *ptr = (INT_PTR *)this-1;
7951
7952         for(i=*ptr-1; i>=0; i--)
7953             basic_istream_wchar_vbase_dtor(this+i);
7954         MSVCRT_operator_delete(ptr);
7955     } else {
7956         basic_istream_wchar_vbase_dtor(this);
7957         if(flags & 1)
7958             MSVCRT_operator_delete(this);
7959     }
7960
7961     return this;
7962 }
7963
7964 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
7965 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
7966 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
7967 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
7968 static MSVCP_bool basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
7969 {
7970     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7971
7972     TRACE("(%p %d)\n", this, noskip);
7973
7974     if(ios_base_good(&base->base)) {
7975         if(basic_ios_wchar_tie_get(base))
7976             basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
7977
7978         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
7979             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7980             const ctype_wchar *ctype = ctype_wchar_use_facet(&base->strbuf->loc);
7981             int ch;
7982
7983             for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
7984                     ch = basic_streambuf_wchar_snextc(strbuf)) {
7985                 if(ch==WEOF || !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
7986                     break;
7987             }
7988         }
7989     }
7990
7991     if(!ios_base_good(&base->base)) {
7992         basic_ios_wchar_setstate(base, IOSTATE_failbit);
7993         return FALSE;
7994     }
7995     return TRUE;
7996 }
7997
7998 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
7999 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8000 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8001 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8002 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
8003 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8004 {
8005     return basic_istream_wchar__Ipfx(this, noskip);
8006 }
8007
8008 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8009 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8010 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8011 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8012 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
8013 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
8014 {
8015     TRACE("(%p)\n", this);
8016 }
8017
8018 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
8019 {
8020     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8021
8022     if(basic_ios_wchar_rdbuf_get(base))
8023         basic_streambuf_wchar__Lock(base->strbuf);
8024
8025     return basic_istream_wchar_ipfx(istr, noskip);
8026 }
8027
8028 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
8029 {
8030     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8031
8032     if(basic_ios_wchar_rdbuf_get(base))
8033         basic_streambuf_wchar__Unlock(base->strbuf);
8034 }
8035
8036 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
8037 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
8038 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
8039 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
8040 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
8041 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
8042 {
8043     TRACE("(%p)\n", this);
8044     return this->count;
8045 }
8046
8047 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8048 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8049 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8050 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8051 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
8052 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
8053 {
8054     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8055     int ret;
8056
8057     TRACE("(%p)\n", this);
8058
8059     this->count = 0;
8060
8061     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
8062         basic_istream_wchar_sentry_destroy(this);
8063         return WEOF;
8064     }
8065
8066     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
8067     basic_istream_wchar_sentry_destroy(this);
8068     if(ret == WEOF)
8069         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
8070     else
8071         this->count++;
8072
8073     return ret;
8074 }
8075
8076 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
8077 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
8078 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
8079 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
8080 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
8081 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
8082 {
8083     unsigned short ret;
8084
8085     TRACE("(%p %p)\n", this, ch);
8086
8087     ret = basic_istream_wchar_get(this);
8088     if(ret != WEOF)
8089         *ch = (wchar_t)ret;
8090     return this;
8091 }
8092
8093 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8094 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8095 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8096 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8097 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 16)
8098 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8099 {
8100     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8101     unsigned short ch = delim;
8102
8103     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8104
8105     this->count = 0;
8106
8107     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8108         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8109
8110         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
8111                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8112             if(ch==WEOF || ch==delim)
8113                 break;
8114
8115             *str++ = ch;
8116             this->count++;
8117             count--;
8118         }
8119     }
8120     basic_istream_wchar_sentry_destroy(this);
8121
8122     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8123             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8124     if(count > 0)
8125         *str = 0;
8126     return this;
8127 }
8128
8129 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8130 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8131 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8132 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8133 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 12)
8134 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
8135 {
8136     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
8137 }
8138
8139 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8140 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8141 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8142 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8143 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
8144 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
8145 {
8146     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8147     unsigned short ch = delim;
8148
8149     TRACE("(%p %p %c)\n", this, strbuf, delim);
8150
8151     this->count = 0;
8152
8153     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8154         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
8155
8156         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
8157                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
8158             if(ch==WEOF || ch==delim)
8159                 break;
8160
8161             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
8162                 break;
8163             this->count++;
8164         }
8165     }
8166     basic_istream_wchar_sentry_destroy(this);
8167
8168     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8169             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8170     return this;
8171 }
8172
8173 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8174 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8175 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8176 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8177 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
8178 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
8179 {
8180     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
8181 }
8182
8183 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8184 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8185 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8186 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8187 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 16)
8188 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8189 {
8190     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8191     unsigned short ch = delim;
8192
8193     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8194
8195     this->count = 0;
8196
8197     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
8198         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8199
8200         while(count > 1) {
8201             ch = basic_streambuf_wchar_sbumpc(strbuf);
8202
8203             if(ch==WEOF || ch==delim)
8204                 break;
8205
8206             *str++ = ch;
8207             this->count++;
8208             count--;
8209         }
8210
8211         if(ch == delim)
8212             this->count++;
8213         else if(ch != WEOF) {
8214             ch = basic_streambuf_wchar_sgetc(strbuf);
8215
8216             if(ch == delim) {
8217                 basic_streambuf_wchar__Gninc(strbuf);
8218                 this->count++;
8219             }
8220         }
8221     }
8222     basic_istream_wchar_sentry_destroy(this);
8223
8224     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
8225             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
8226     if(count > 0)
8227         *str = 0;
8228     return this;
8229 }
8230
8231 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8232 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8233 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8234 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8235 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 12)
8236 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
8237 {
8238     return basic_istream_wchar_getline_delim(this, str, count, '\n');
8239 }
8240
8241 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
8242 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
8243 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
8244 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
8245 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 12)
8246 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
8247 {
8248     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8249     unsigned short ch = delim;
8250     unsigned int state;
8251
8252     TRACE("(%p %ld %d)\n", this, count, delim);
8253
8254     this->count = 0;
8255
8256     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8257         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8258         state = IOSTATE_goodbit;
8259
8260         while(count > 0) {
8261             ch = basic_streambuf_wchar_sbumpc(strbuf);
8262
8263             if(ch==WEOF) {
8264                 state = IOSTATE_eofbit;
8265                 break;
8266             }
8267
8268             if(ch==delim)
8269                 break;
8270
8271             this->count++;
8272             if(count != INT_MAX)
8273                 count--;
8274         }
8275     }else
8276         state = IOSTATE_failbit;
8277     basic_istream_wchar_sentry_destroy(this);
8278
8279     basic_ios_wchar_setstate(base, state);
8280     return this;
8281 }
8282
8283 /* ?ws@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
8284 /* ?ws@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
8285 /* ?ws@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@1@AAV21@@Z */
8286 /* ?ws@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
8287 basic_istream_wchar* __cdecl ws_basic_istream_wchar(basic_istream_wchar *istream)
8288 {
8289     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8290     unsigned short ch = '\n';
8291
8292     TRACE("(%p)\n", istream);
8293
8294     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8295         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8296         const ctype_wchar *ctype = ctype_wchar_use_facet(&strbuf->loc);
8297
8298         for(ch = basic_streambuf_wchar_sgetc(strbuf); ctype_wchar_is_ch(ctype, _SPACE, ch);
8299                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8300             if(ch == WEOF)
8301                 break;
8302         }
8303     }
8304     basic_istream_wchar_sentry_destroy(istream);
8305
8306     if(ch == WEOF)
8307         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8308     return istream;
8309 }
8310
8311 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8312 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8313 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8314 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8315 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
8316 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
8317 {
8318     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8319     unsigned short ret = WEOF;
8320
8321     TRACE("(%p)\n", this);
8322
8323     this->count = 0;
8324
8325     if(basic_istream_wchar_sentry_create(this, TRUE))
8326         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8327     basic_istream_wchar_sentry_destroy(this);
8328
8329     if (ret == WEOF)
8330         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8331
8332     return ret;
8333 }
8334
8335 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
8336 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
8337 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
8338 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
8339 static basic_istream_wchar* basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8340 {
8341     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8342     IOSB_iostate state = IOSTATE_goodbit;
8343
8344     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8345
8346     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8347         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8348
8349         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
8350         if(this->count != count)
8351             state |= IOSTATE_failbit | IOSTATE_eofbit;
8352     }else {
8353         this->count = 0;
8354     }
8355     basic_istream_wchar_sentry_destroy(this);
8356
8357     basic_ios_wchar_setstate(base, state);
8358     return this;
8359 }
8360
8361 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8362 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8363 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8364 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8365 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 12)
8366 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
8367 {
8368     return basic_istream_wchar__Read_s(this, str, count, count);
8369 }
8370
8371 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
8372 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
8373 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
8374 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
8375 static streamsize basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8376 {
8377     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8378     IOSB_iostate state = IOSTATE_goodbit;
8379
8380     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8381
8382     this->count = 0;
8383
8384     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8385         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
8386         if(avail > count)
8387             avail = count;
8388
8389         if(avail == -1)
8390             state |= IOSTATE_eofbit;
8391         else if(avail > 0)
8392             basic_istream_wchar__Read_s(this, str, size, avail);
8393     }else {
8394         state |= IOSTATE_failbit;
8395     }
8396     basic_istream_wchar_sentry_destroy(this);
8397
8398     basic_ios_wchar_setstate(base, state);
8399     return this->count;
8400 }
8401
8402 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
8403 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
8404 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
8405 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
8406 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 12)
8407 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
8408 {
8409     return basic_istream_wchar__Readsome_s(this, str, count, count);
8410 }
8411
8412 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
8413 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
8414 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
8415 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
8416 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
8417 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
8418 {
8419     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8420     IOSB_iostate state = IOSTATE_goodbit;
8421
8422     TRACE("(%p %c)\n", this, ch);
8423
8424     this->count = 0;
8425
8426     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8427         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8428
8429         if(!ios_base_good(&base->base))
8430             state |= IOSTATE_failbit;
8431         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
8432             state |= IOSTATE_badbit;
8433     }
8434     basic_istream_wchar_sentry_destroy(this);
8435
8436     basic_ios_wchar_setstate(base, state);
8437     return this;
8438 }
8439
8440 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
8441 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
8442 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
8443 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
8444 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
8445 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
8446 {
8447     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8448     IOSB_iostate state = IOSTATE_goodbit;
8449
8450     TRACE("(%p)\n", this);
8451
8452     this->count = 0;
8453
8454     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8455         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8456
8457         if(!ios_base_good(&base->base))
8458             state |= IOSTATE_failbit;
8459         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
8460             state |= IOSTATE_badbit;
8461     }
8462     basic_istream_wchar_sentry_destroy(this);
8463
8464     basic_ios_wchar_setstate(base, state);
8465     return this;
8466 }
8467
8468 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
8469 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
8470 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
8471 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
8472 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
8473 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
8474 {
8475     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8476     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8477
8478     TRACE("(%p)\n", this);
8479
8480     if(!strbuf)
8481         return -1;
8482
8483     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8484         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
8485             basic_istream_wchar_sentry_destroy(this);
8486             return 0;
8487         }
8488     }
8489     basic_istream_wchar_sentry_destroy(this);
8490
8491     basic_ios_wchar_setstate(base, IOSTATE_badbit);
8492     return -1;
8493 }
8494
8495 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8496 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8497 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
8498 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
8499 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
8500 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
8501 {
8502     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8503
8504     TRACE("(%p %p)\n", this, ret);
8505
8506     if(ios_base_fail(&base->base)) {
8507         ret->off = -1;
8508         ret->pos = 0;
8509         ret->state = 0;
8510         return ret;
8511     }
8512
8513     basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
8514             ret, 0, SEEKDIR_cur, OPENMODE_in);
8515     if(ret->off==-1 && ret->pos==0 && ret->state==0)
8516         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8517
8518     return ret;
8519 }
8520
8521 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JW4seekdir@ios_base@2@@Z */
8522 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JW4seekdir@ios_base@2@@Z */
8523 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 12)
8524 basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir)
8525 {
8526     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8527
8528     TRACE("(%p %ld %d)\n", this, off, dir);
8529
8530     if(!ios_base_fail(&base->base)) {
8531         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8532         fpos_int ret;
8533
8534         basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
8535     }
8536
8537     return this;
8538 }
8539
8540 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8541 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8542 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
8543 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
8544 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
8545 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
8546 {
8547     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8548
8549     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
8550
8551     if(!ios_base_fail(&base->base)) {
8552         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8553         fpos_int ret;
8554
8555         basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
8556     }
8557
8558     return this;
8559 }
8560
8561 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
8562 {
8563     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8564     int state = IOSTATE_goodbit;
8565
8566     TRACE("(%p %p)\n", this, v);
8567
8568     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8569         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8570         istreambuf_iterator_wchar first={0}, last={0};
8571         LONG tmp;
8572
8573         first.strbuf = strbuf;
8574         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
8575
8576         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
8577             *v = tmp;
8578         else
8579             state |= IOSTATE_failbit;
8580     }
8581     basic_istream_wchar_sentry_destroy(this);
8582
8583     basic_ios_wchar_setstate(base, state);
8584     return this;
8585 }
8586
8587 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
8588 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
8589 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
8590 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
8591 {
8592     return basic_istream_read_short(this, v, num_get_short_use_facet(
8593                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8594 }
8595
8596 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
8597 {
8598     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8599     int state = IOSTATE_goodbit;
8600
8601     TRACE("(%p %p)\n", this, v);
8602
8603     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8604         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8605         istreambuf_iterator_wchar first={0}, last={0};
8606
8607         first.strbuf = strbuf;
8608         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8609     }
8610     basic_istream_wchar_sentry_destroy(this);
8611
8612     basic_ios_wchar_setstate(base, state);
8613     return this;
8614 }
8615
8616 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
8617 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
8618 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
8619 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
8620 {
8621     return basic_istream_read_int(this, v, num_get_short_use_facet(
8622                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8623 }
8624
8625 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
8626 {
8627     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8628     int state = IOSTATE_goodbit;
8629
8630     TRACE("(%p %p)\n", this, v);
8631
8632     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8633         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8634         istreambuf_iterator_wchar first={0}, last={0};
8635
8636         first.strbuf = strbuf;
8637         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
8638     }
8639     basic_istream_wchar_sentry_destroy(this);
8640
8641     basic_ios_wchar_setstate(base, state);
8642     return this;
8643 }
8644
8645 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
8646 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
8647 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
8648 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
8649 {
8650     return basic_istream_read_uint(this, v, num_get_short_use_facet(
8651                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8652 }
8653
8654 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
8655 {
8656     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8657     int state = IOSTATE_goodbit;
8658
8659     TRACE("(%p %p)\n", this, v);
8660
8661     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8662         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8663         istreambuf_iterator_wchar first={0}, last={0};
8664
8665         first.strbuf = strbuf;
8666         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
8667     }
8668     basic_istream_wchar_sentry_destroy(this);
8669
8670     basic_ios_wchar_setstate(base, state);
8671     return this;
8672 }
8673
8674 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
8675 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
8676 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
8677 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
8678 {
8679     return basic_istream_read_long(this, v, num_get_short_use_facet(
8680                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8681 }
8682
8683 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
8684 {
8685     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8686     int state = IOSTATE_goodbit;
8687
8688     TRACE("(%p %p)\n", this, v);
8689
8690     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8691         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8692         istreambuf_iterator_wchar first={0}, last={0};
8693
8694         first.strbuf = strbuf;
8695         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
8696     }
8697     basic_istream_wchar_sentry_destroy(this);
8698
8699     basic_ios_wchar_setstate(base, state);
8700     return this;
8701 }
8702
8703 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
8704 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
8705 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
8706 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
8707 {
8708     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
8709                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8710 }
8711
8712 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
8713 {
8714     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8715     int state = IOSTATE_goodbit;
8716
8717     TRACE("(%p %p)\n", this, v);
8718
8719     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8720         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8721         istreambuf_iterator_wchar first={0}, last={0};
8722
8723         first.strbuf = strbuf;
8724         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
8725     }
8726     basic_istream_wchar_sentry_destroy(this);
8727
8728     basic_ios_wchar_setstate(base, state);
8729     return this;
8730 }
8731
8732 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
8733 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
8734 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
8735 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
8736 {
8737     return basic_istream_read_float(this, v, num_get_short_use_facet(
8738                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8739 }
8740
8741 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
8742 {
8743     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8744     int state = IOSTATE_goodbit;
8745
8746     TRACE("(%p %p)\n", this, v);
8747
8748     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8749         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8750         istreambuf_iterator_wchar first={0}, last={0};
8751
8752         first.strbuf = strbuf;
8753         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
8754     }
8755     basic_istream_wchar_sentry_destroy(this);
8756
8757     basic_ios_wchar_setstate(base, state);
8758     return this;
8759 }
8760
8761 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
8762 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
8763 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
8764 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
8765 {
8766     return basic_istream_read_double(this, v, num_get_short_use_facet(
8767                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8768 }
8769
8770 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
8771 {
8772     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8773     int state = IOSTATE_goodbit;
8774
8775     TRACE("(%p %p)\n", this, v);
8776
8777     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8778         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8779         istreambuf_iterator_wchar first={0}, last={0};
8780
8781         first.strbuf = strbuf;
8782         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
8783     }
8784     basic_istream_wchar_sentry_destroy(this);
8785
8786     basic_ios_wchar_setstate(base, state);
8787     return this;
8788 }
8789
8790 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
8791 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
8792 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
8793 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
8794 {
8795     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
8796                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8797 }
8798
8799 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
8800 {
8801     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8802     int state = IOSTATE_goodbit;
8803
8804     TRACE("(%p %p)\n", this, v);
8805
8806     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8807         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8808         istreambuf_iterator_wchar first={0}, last={0};
8809
8810         first.strbuf = strbuf;
8811         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
8812     }
8813     basic_istream_wchar_sentry_destroy(this);
8814
8815     basic_ios_wchar_setstate(base, state);
8816     return this;
8817 }
8818
8819 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
8820 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
8821 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
8822 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
8823 {
8824     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
8825                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8826 }
8827
8828 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
8829 {
8830     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8831     int state = IOSTATE_goodbit;
8832
8833     TRACE("(%p %p)\n", this, v);
8834
8835     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8836         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8837         istreambuf_iterator_wchar first={0}, last={0};
8838
8839         first.strbuf = strbuf;
8840         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
8841     }
8842     basic_istream_wchar_sentry_destroy(this);
8843
8844     basic_ios_wchar_setstate(base, state);
8845     return this;
8846 }
8847
8848 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
8849 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
8850 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
8851 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
8852 {
8853     return basic_istream_read_int64(this, v, num_get_short_use_facet(
8854                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8855 }
8856
8857 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
8858 {
8859     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8860     int state = IOSTATE_goodbit;
8861
8862     TRACE("(%p %p)\n", this, v);
8863
8864     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8865         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8866         istreambuf_iterator_wchar first={0}, last={0};
8867
8868         first.strbuf = strbuf;
8869         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
8870     }
8871     basic_istream_wchar_sentry_destroy(this);
8872
8873     basic_ios_wchar_setstate(base, state);
8874     return this;
8875 }
8876
8877 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
8878 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
8879 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
8880 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
8881 {
8882     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
8883                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8884 }
8885
8886 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
8887 {
8888     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8889     int state = IOSTATE_goodbit;
8890
8891     TRACE("(%p %p)\n", this, v);
8892
8893     if(basic_istream_wchar_sentry_create(this, FALSE)) {
8894         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8895         istreambuf_iterator_wchar first={0}, last={0};
8896
8897         first.strbuf = strbuf;
8898         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
8899     }
8900     basic_istream_wchar_sentry_destroy(this);
8901
8902     basic_ios_wchar_setstate(base, state);
8903     return this;
8904 }
8905
8906 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
8907 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
8908 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
8909 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
8910 {
8911     return basic_istream_read_bool(this, v, num_get_short_use_facet(
8912                 &basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
8913 }
8914
8915 /* ??$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 */
8916 /* ??$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 */
8917 /* ??$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 */
8918 /* ??$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 */
8919 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr_delim(
8920         basic_istream_wchar *istream, basic_string_wchar *str, wchar_t delim)
8921 {
8922     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8923     IOSB_iostate state = IOSTATE_goodbit;
8924     int c = delim;
8925
8926     TRACE("(%p %p %c)\n", istream, str, delim);
8927
8928     basic_string_wchar_clear(str);
8929     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8930         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8931
8932         c = basic_streambuf_wchar_sgetc(strbuf);
8933         for(; c!=delim && c!=WEOF; c = basic_streambuf_wchar_snextc(strbuf))
8934             basic_string_wchar_append_ch(str, c);
8935         if(c==delim) basic_streambuf_wchar_sbumpc(strbuf);
8936         else if(c==WEOF) state |= IOSTATE_eofbit;
8937
8938         if(!basic_string_wchar_length(str) && c!=delim) state |= IOSTATE_failbit;
8939     }
8940     basic_istream_wchar_sentry_destroy(istream);
8941
8942     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream), state);
8943     return istream;
8944 }
8945
8946 /* ??$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 */
8947 /* ??$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 */
8948 /* ??$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 */
8949 /* ??$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 */
8950 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr(
8951         basic_istream_wchar *istream, basic_string_wchar *str)
8952 {
8953     return basic_istream_wchar_getline_bstr_delim(istream, str, '\n');
8954 }
8955
8956 static basic_istream_wchar* basic_istream_read_bstr(basic_istream_wchar *istream,
8957         basic_string_wchar *str, const ctype_wchar *ctype)
8958 {
8959     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8960     IOSB_iostate state = IOSTATE_failbit;
8961     int c = '\n';
8962
8963     TRACE("(%p %p)\n", istream, str);
8964
8965     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
8966         MSVCP_size_t count = ios_base_width_get(&base->base);
8967
8968         if(!count)
8969             count = -1;
8970
8971         basic_string_wchar_clear(str);
8972
8973         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8974                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8975                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
8976             state = IOSTATE_goodbit;
8977             basic_string_wchar_append_ch(str, c);
8978         }
8979     }
8980     basic_istream_wchar_sentry_destroy(istream);
8981
8982     ios_base_width_set(&base->base, 0);
8983     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8984     return istream;
8985 }
8986
8987 /* ??$?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 */
8988 /* ??$?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 */
8989 basic_istream_wchar* __cdecl basic_istream_wchar_read_bstr(
8990         basic_istream_wchar *istream, basic_string_wchar *str)
8991 {
8992     return basic_istream_read_bstr(istream, str, ctype_wchar_use_facet(
8993                 &basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
8994 }
8995
8996 /* ??$?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 */
8997 /* ??$?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 */
8998 basic_istream_wchar* __cdecl basic_istream_short_read_bstr(
8999         basic_istream_wchar *istream, basic_string_wchar *str)
9000 {
9001     return basic_istream_read_bstr(istream, str, ctype_short_use_facet(
9002                 &basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9003 }
9004
9005 static basic_istream_wchar* basic_istream_read_str(basic_istream_wchar *istream, wchar_t *str, const ctype_wchar *ctype)
9006 {
9007     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9008     IOSB_iostate state = IOSTATE_failbit;
9009     unsigned short c = '\n';
9010
9011     TRACE("(%p %p)\n", istream, str);
9012
9013     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9014         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
9015
9016         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9017                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9018                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9019             state = IOSTATE_goodbit;
9020             *str++ = c;
9021         }
9022     }
9023     basic_istream_wchar_sentry_destroy(istream);
9024
9025     *str = 0;
9026     ios_base_width_set(&base->base, 0);
9027     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9028     return istream;
9029 }
9030
9031 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@PAG@Z */
9032 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@PEAG@Z */
9033 basic_istream_wchar* __cdecl basic_istream_short_read_str(basic_istream_wchar *istream, wchar_t *str)
9034 {
9035     return basic_istream_read_str(istream, str, ctype_short_use_facet(
9036                 &basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9037 }
9038
9039 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AA_W@Z */
9040 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEA_W@Z */
9041 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAG@Z */
9042 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAG@Z */
9043 basic_istream_wchar* __cdecl basic_istream_wchar_read_ch(basic_istream_wchar *istream, wchar_t *ch)
9044 {
9045     IOSB_iostate state = IOSTATE_failbit;
9046     unsigned short c = 0;
9047
9048     TRACE("(%p %p)\n", istream, ch);
9049
9050     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9051         c = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(
9052                     basic_istream_wchar_get_basic_ios(istream)));
9053         if(c != WEOF) {
9054             state = IOSTATE_goodbit;
9055             *ch = c;
9056         }
9057     }
9058     basic_istream_wchar_sentry_destroy(istream);
9059
9060     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9061             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9062     return istream;
9063 }
9064
9065 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9066 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9067 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9068 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9069 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
9070 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
9071         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
9072 {
9073     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9074     IOSB_iostate state = IOSTATE_failbit;
9075     unsigned short c = '\n';
9076
9077     TRACE("(%p %p)\n", this, streambuf);
9078
9079     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9080         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
9081                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
9082             state = IOSTATE_goodbit;
9083             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
9084                 break;
9085         }
9086     }
9087     basic_istream_wchar_sentry_destroy(this);
9088
9089     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9090     return this;
9091 }
9092
9093 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9094 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9095 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9096 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9097 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
9098 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
9099         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
9100 {
9101     TRACE("(%p %p)\n", this, pfunc);
9102     pfunc(this);
9103     return this;
9104 }
9105
9106 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
9107 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
9108 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
9109 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
9110 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
9111 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
9112         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
9113 {
9114     TRACE("(%p %p)\n", this, pfunc);
9115     pfunc(basic_istream_wchar_get_basic_ios(this));
9116     return this;
9117 }
9118
9119 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9120 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9121 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9122 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9123 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
9124 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
9125         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
9126 {
9127     TRACE("(%p %p)\n", this, pfunc);
9128     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
9129     return this;
9130 }
9131
9132 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
9133 {
9134     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
9135 }
9136
9137 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
9138 {
9139     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
9140 }
9141
9142 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9143 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9144 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
9145 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
9146 {
9147     basic_ios_char *basic_ios;
9148
9149     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9150
9151     if(virt_init) {
9152         this->base1.vbtable = basic_iostream_char_vbtable1;
9153         this->base2.vbtable = basic_iostream_char_vbtable2;
9154         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9155         basic_ios_char_ctor(basic_ios);
9156     }else {
9157         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9158     }
9159
9160     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
9161
9162     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
9163     basic_ostream_char_ctor(&this->base2, NULL, FALSE, FALSE, FALSE);
9164     return this;
9165 }
9166
9167 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9168 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9169 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
9170 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
9171 {
9172     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9173
9174     TRACE("(%p)\n", this);
9175     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
9176     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
9177 }
9178
9179 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9180 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9181 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
9182 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
9183 {
9184     TRACE("(%p)\n", this);
9185     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
9186     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
9187 }
9188
9189 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
9190 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9191 {
9192     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9193
9194     TRACE("(%p %x)\n", this, flags);
9195
9196     if(flags & 2) {
9197         /* we have an array, with the number of elements stored before the first object */
9198         INT_PTR i, *ptr = (INT_PTR *)this-1;
9199
9200         for(i=*ptr-1; i>=0; i--)
9201             basic_iostream_char_vbase_dtor(this+i);
9202         MSVCRT_operator_delete(ptr);
9203     } else {
9204         basic_iostream_char_vbase_dtor(this);
9205         if(flags & 1)
9206             MSVCRT_operator_delete(this);
9207     }
9208
9209     return this;
9210 }
9211
9212 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
9213 {
9214     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
9215 }
9216
9217 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9218 {
9219     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
9220 }
9221
9222 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9223 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9224 static basic_iostream_wchar* basic_iostream_wchar_ctor(basic_iostream_wchar *this,
9225         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9226 {
9227     basic_ios_wchar *basic_ios;
9228
9229     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9230
9231     if(virt_init) {
9232         this->base1.vbtable = basic_iostream_wchar_vbtable1;
9233         this->base2.vbtable = basic_iostream_wchar_vbtable2;
9234         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9235         basic_ios_wchar_ctor(basic_ios);
9236     }else {
9237         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9238     }
9239
9240     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
9241     basic_ostream_short_ctor(&this->base2, NULL, FALSE, FALSE, FALSE);
9242
9243     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
9244     return this;
9245 }
9246
9247 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9248 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9249 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
9250 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
9251         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9252 {
9253     basic_iostream_wchar_ctor(this, strbuf, virt_init);
9254     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
9255     return this;
9256 }
9257
9258 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9259 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9260 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9261 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9262 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
9263 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
9264 {
9265     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9266
9267     TRACE("(%p)\n", this);
9268     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
9269     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
9270 }
9271
9272 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9273 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9274 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9275 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9276 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
9277 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
9278 {
9279     TRACE("(%p)\n", this);
9280     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
9281     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
9282 }
9283
9284 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
9285 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9286 {
9287     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9288
9289     TRACE("(%p %x)\n", this, flags);
9290
9291     if(flags & 2) {
9292         /* we have an array, with the number of elements stored before the first object */
9293         INT_PTR i, *ptr = (INT_PTR *)this-1;
9294
9295         for(i=*ptr-1; i>=0; i--)
9296             basic_iostream_wchar_vbase_dtor(this+i);
9297         MSVCRT_operator_delete(ptr);
9298     } else {
9299         basic_iostream_wchar_vbase_dtor(this);
9300         if(flags & 1)
9301             MSVCRT_operator_delete(this);
9302     }
9303
9304     return this;
9305 }
9306
9307 static inline basic_ios_char* basic_ofstream_char_to_basic_ios(basic_ofstream_char *ptr)
9308 {
9309     return (basic_ios_char*)((char*)ptr+basic_ofstream_char_vbtable[1]);
9310 }
9311
9312 static inline basic_ofstream_char* basic_ofstream_char_from_basic_ios(basic_ios_char *ptr)
9313 {
9314     return (basic_ofstream_char*)((char*)ptr-basic_ofstream_char_vbtable[1]);
9315 }
9316
9317 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9318 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9319 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
9320 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
9321 {
9322     basic_ios_char *basic_ios;
9323
9324     TRACE("(%p %d)\n", this, virt_init);
9325
9326     if(virt_init) {
9327         this->base.vbtable = basic_ofstream_char_vbtable;
9328         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9329         basic_ios_char_ctor(basic_ios);
9330     }else {
9331         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9332     }
9333
9334     basic_filebuf_char_ctor(&this->filebuf);
9335     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, TRUE, FALSE);
9336     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9337     return this;
9338 }
9339
9340 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
9341 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9342 static basic_ofstream_char* basic_ofstream_char_ctor_file(
9343         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
9344 {
9345     basic_ios_char *basic_ios;
9346
9347     TRACE("(%p %p %d)\n", this, file, virt_init);
9348
9349     if(virt_init) {
9350         this->base.vbtable = basic_ofstream_char_vbtable;
9351         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9352         basic_ios_char_ctor(basic_ios);
9353     }else {
9354         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9355     }
9356
9357     basic_filebuf_char_ctor_file(&this->filebuf, file);
9358     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, TRUE, FALSE);
9359     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
9360     return this;
9361 }
9362
9363 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
9364 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
9365 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_copy_ctor, 12)
9366 basic_ofstream_char* __thiscall basic_ofstream_char_copy_ctor(basic_ofstream_char *this,
9367         basic_ofstream_char *copy, MSVCP_bool virt_init)
9368 {
9369     TRACE("(%p %p %d)\n", this, copy, virt_init);
9370     return basic_ofstream_char_ctor_file(this, copy->filebuf.file, virt_init);
9371 }
9372
9373 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
9374 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
9375 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 16)
9376 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
9377         const char *name, int mode, MSVCP_bool virt_init)
9378 {
9379     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9380
9381     basic_ofstream_char_ctor(this, virt_init);
9382
9383     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9384         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9385         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9386     }
9387     return this;
9388 }
9389
9390 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9391 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9392 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
9393 void __thiscall basic_ofstream_char_dtor(basic_ios_char *base)
9394 {
9395     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9396
9397     TRACE("(%p)\n", this);
9398
9399     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
9400     basic_filebuf_char_dtor(&this->filebuf);
9401 }
9402
9403 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9404 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9405 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
9406 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
9407 {
9408     TRACE("(%p)\n", this);
9409
9410     basic_ofstream_char_dtor(basic_ofstream_char_to_basic_ios(this));
9411     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
9412 }
9413
9414 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vector_dtor, 8)
9415 basic_ofstream_char* __thiscall basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9416 {
9417     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
9418
9419     TRACE("(%p %x)\n", this, flags);
9420
9421     if(flags & 2) {
9422         /* we have an array, with the number of elements stored before the first object */
9423         INT_PTR i, *ptr = (INT_PTR *)this-1;
9424
9425         for(i=*ptr-1; i>=0; i--)
9426             basic_ofstream_char_vbase_dtor(this+i);
9427         MSVCRT_operator_delete(ptr);
9428     } else {
9429         basic_ofstream_char_vbase_dtor(this);
9430         if(flags & 1)
9431             MSVCRT_operator_delete(this);
9432     }
9433
9434     return this;
9435 }
9436
9437 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9438 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9439 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
9440 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
9441 {
9442     TRACE("(%p)\n", this);
9443
9444     if(!basic_filebuf_char_close(&this->filebuf)) {
9445         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9446         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9447     }
9448 }
9449
9450 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
9451 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
9452 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
9453 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
9454 {
9455     TRACE("(%p)\n", this);
9456     return basic_filebuf_char_is_open(&this->filebuf);
9457 }
9458
9459 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
9460 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
9461 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 12)
9462 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
9463         const char *name, int mode)
9464 {
9465     TRACE("(%p %s %d)\n", this, name, mode);
9466
9467     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9468         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
9469         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9470     }
9471 }
9472
9473 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
9474 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
9475 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
9476 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
9477         const char *name, short mode)
9478 {
9479     basic_ofstream_char_open(this, name, mode);
9480 }
9481
9482 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9483 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9484 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
9485 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
9486 {
9487     TRACE("(%p)\n", this);
9488     return (basic_filebuf_char*)&this->filebuf;
9489 }
9490
9491 static inline basic_ios_wchar* basic_ofstream_wchar_to_basic_ios(basic_ofstream_wchar *ptr)
9492 {
9493     return (basic_ios_wchar*)((char*)ptr+basic_ofstream_wchar_vbtable[1]);
9494 }
9495
9496 static inline basic_ofstream_wchar* basic_ofstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9497 {
9498     return (basic_ofstream_wchar*)((char*)ptr-basic_ofstream_wchar_vbtable[1]);
9499 }
9500
9501 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
9502 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
9503 static basic_ofstream_wchar* basic_ofstream_wchar_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9504 {
9505     basic_ios_wchar *basic_ios;
9506
9507     TRACE("(%p %d)\n", this, virt_init);
9508
9509     if(virt_init) {
9510         this->base.vbtable = basic_ofstream_wchar_vbtable;
9511         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9512         basic_ios_wchar_ctor(basic_ios);
9513     }else {
9514         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9515     }
9516
9517     basic_filebuf_wchar_ctor(&this->filebuf);
9518     basic_ostream_short_ctor(&this->base, &this->filebuf.base, FALSE, TRUE, FALSE);
9519     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
9520     return this;
9521 }
9522
9523 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
9524 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
9525 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor, 8)
9526 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
9527 {
9528     basic_ofstream_wchar_ctor(this, virt_init);
9529     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
9530     return this;
9531 }
9532
9533 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
9534 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9535 static basic_ofstream_wchar* basic_ofstream_wchar_ctor_file(
9536         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9537 {
9538     basic_ios_wchar *basic_ios;
9539
9540     TRACE("(%p %p %d)\n", this, file, virt_init);
9541
9542     if(virt_init) {
9543         this->base.vbtable = basic_ofstream_wchar_vbtable;
9544         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9545         basic_ios_wchar_ctor(basic_ios);
9546     }else {
9547         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9548     }
9549
9550     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
9551     basic_ostream_short_ctor(&this->base, &this->filebuf.base, FALSE, TRUE, FALSE);
9552     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
9553     return this;
9554 }
9555
9556 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
9557 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9558 static basic_ofstream_wchar* basic_ofstream_short_ctor_file(
9559         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9560 {
9561     basic_ofstream_wchar_ctor_file(this, file, virt_init);
9562     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
9563     return this;
9564 }
9565
9566 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
9567 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
9568 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_copy_ctor, 12)
9569 basic_ofstream_wchar* __thiscall basic_ofstream_short_copy_ctor(basic_ofstream_wchar *this,
9570         basic_ofstream_wchar *copy, MSVCP_bool virt_init)
9571 {
9572     TRACE("(%p %p %d)\n", this, copy, virt_init);
9573     return basic_ofstream_short_ctor_file(this, copy->filebuf.file, virt_init);
9574 }
9575
9576 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBDH@Z */
9577 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDH@Z */
9578 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name, 16)
9579 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name(basic_ofstream_wchar *this,
9580         const char *name, int mode, MSVCP_bool virt_init)
9581 {
9582     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9583
9584     basic_ofstream_short_ctor(this, virt_init);
9585
9586     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9587         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9588         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9589     }
9590     return this;
9591 }
9592
9593 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9594 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9595 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9596 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9597 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_dtor, 4)
9598 void __thiscall basic_ofstream_wchar_dtor(basic_ios_wchar *base)
9599 {
9600     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9601
9602     TRACE("(%p)\n", this);
9603
9604     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
9605     basic_filebuf_wchar_dtor(&this->filebuf);
9606 }
9607
9608 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9609 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9610 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9611 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9612 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vbase_dtor, 4)
9613 void __thiscall basic_ofstream_wchar_vbase_dtor(basic_ofstream_wchar *this)
9614 {
9615     TRACE("(%p)\n", this);
9616
9617     basic_ofstream_wchar_dtor(basic_ofstream_wchar_to_basic_ios(this));
9618     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
9619 }
9620
9621 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vector_dtor, 8)
9622 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9623 {
9624     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
9625
9626     TRACE("(%p %x)\n", this, flags);
9627
9628     if(flags & 2) {
9629         /* we have an array, with the number of elements stored before the first object */
9630         INT_PTR i, *ptr = (INT_PTR *)this-1;
9631
9632         for(i=*ptr-1; i>=0; i--)
9633             basic_ofstream_wchar_vbase_dtor(this+i);
9634         MSVCRT_operator_delete(ptr);
9635     } else {
9636         basic_ofstream_wchar_vbase_dtor(this);
9637         if(flags & 1)
9638             MSVCRT_operator_delete(this);
9639     }
9640
9641     return this;
9642 }
9643
9644 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9645 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9646 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9647 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9648 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_close, 4)
9649 void __thiscall basic_ofstream_wchar_close(basic_ofstream_wchar *this)
9650 {
9651     TRACE("(%p)\n", this);
9652
9653     if(!basic_filebuf_wchar_close(&this->filebuf)) {
9654         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9655         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9656     }
9657 }
9658
9659 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
9660 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
9661 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
9662 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
9663 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_is_open, 4)
9664 MSVCP_bool __thiscall basic_ofstream_wchar_is_open(const basic_ofstream_wchar *this)
9665 {
9666     TRACE("(%p)\n", this);
9667     return basic_filebuf_wchar_is_open(&this->filebuf);
9668 }
9669
9670 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
9671 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
9672 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open, 12)
9673 void __thiscall basic_ofstream_wchar_open(basic_ofstream_wchar *this,
9674         const char *name, int mode)
9675 {
9676     TRACE("(%p %s %d)\n", this, name, mode);
9677
9678     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, _SH_DENYNO)) {
9679         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
9680         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9681     }
9682 }
9683
9684 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
9685 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
9686 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_old, 12)
9687 void __thiscall basic_ofstream_wchar_open_old(basic_ofstream_wchar *this,
9688         const char *name, int mode)
9689 {
9690     basic_ofstream_wchar_open(this, name, mode);
9691 }
9692
9693 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9694 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
9695 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9696 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
9697 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_rdbuf, 4)
9698 basic_filebuf_wchar* __thiscall basic_ofstream_wchar_rdbuf(const basic_ofstream_wchar *this)
9699 {
9700     TRACE("(%p)\n", this);
9701     return (basic_filebuf_wchar*)&this->filebuf;
9702 }
9703
9704 static inline basic_ios_char* basic_ifstream_char_to_basic_ios(basic_ifstream_char *ptr)
9705 {
9706     return (basic_ios_char*)((char*)ptr+basic_ifstream_char_vbtable[1]);
9707 }
9708
9709 static inline basic_ifstream_char* basic_ifstream_char_from_basic_ios(basic_ios_char *ptr)
9710 {
9711     return (basic_ifstream_char*)((char*)ptr-basic_ifstream_char_vbtable[1]);
9712 }
9713
9714 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
9715 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
9716 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
9717 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
9718 {
9719     basic_ios_char *basic_ios;
9720
9721     TRACE("(%p %d)\n", this, virt_init);
9722
9723     if(virt_init) {
9724         this->base.vbtable = basic_ifstream_char_vbtable;
9725         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9726         basic_ios_char_ctor(basic_ios);
9727     }else {
9728         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9729     }
9730
9731     basic_filebuf_char_ctor(&this->filebuf);
9732     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9733     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
9734     return this;
9735 }
9736
9737 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
9738 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9739 static basic_ifstream_char* basic_ifstream_char_ctor_file(
9740         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
9741 {
9742     basic_ios_char *basic_ios;
9743
9744     TRACE("(%p %p %d)\n", this, file, virt_init);
9745
9746     if(virt_init) {
9747         this->base.vbtable = basic_ifstream_char_vbtable;
9748         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9749         basic_ios_char_ctor(basic_ios);
9750     }else {
9751         basic_ios = basic_istream_char_get_basic_ios(&this->base);
9752     }
9753
9754     basic_filebuf_char_ctor_file(&this->filebuf, file);
9755     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9756     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
9757     return this;
9758 }
9759
9760 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
9761 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
9762 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_copy_ctor, 12)
9763 basic_ifstream_char* __thiscall basic_ifstream_char_copy_ctor(basic_ifstream_char *this,
9764         const basic_ifstream_char *copy, MSVCP_bool virt_init)
9765 {
9766     TRACE("(%p %p %d)\n", this, copy, virt_init);
9767     return basic_ifstream_char_ctor_file(this, copy->filebuf.file, virt_init);
9768 }
9769
9770 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
9771 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
9772 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 16)
9773 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
9774         const char *name, int mode, MSVCP_bool virt_init)
9775 {
9776     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9777
9778     basic_ifstream_char_ctor(this, virt_init);
9779
9780     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9781         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9782         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9783     }
9784     return this;
9785 }
9786
9787 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9788 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9789 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
9790 void __thiscall basic_ifstream_char_dtor(basic_ios_char *base)
9791 {
9792     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9793
9794     TRACE("(%p)\n", this);
9795
9796     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
9797     basic_filebuf_char_dtor(&this->filebuf);
9798 }
9799
9800 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9801 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9802 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
9803 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
9804 {
9805     TRACE("(%p)\n", this);
9806
9807     basic_ifstream_char_dtor(basic_ifstream_char_to_basic_ios(this));
9808     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
9809 }
9810
9811 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vector_dtor, 8)
9812 basic_ifstream_char* __thiscall basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9813 {
9814     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
9815
9816     TRACE("(%p %x)\n", this, flags);
9817
9818     if(flags & 2) {
9819         /* we have an array, with the number of elements stored before the first object */
9820         INT_PTR i, *ptr = (INT_PTR *)this-1;
9821
9822         for(i=*ptr-1; i>=0; i--)
9823             basic_ifstream_char_vbase_dtor(this+i);
9824         MSVCRT_operator_delete(ptr);
9825     } else {
9826         basic_ifstream_char_vbase_dtor(this);
9827         if(flags & 1)
9828             MSVCRT_operator_delete(this);
9829     }
9830
9831     return this;
9832 }
9833
9834 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9835 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9836 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
9837 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
9838 {
9839     TRACE("(%p)\n", this);
9840
9841     if(!basic_filebuf_char_close(&this->filebuf)) {
9842         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9843         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9844     }
9845 }
9846
9847 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
9848 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
9849 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
9850 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
9851 {
9852     TRACE("(%p)\n", this);
9853     return basic_filebuf_char_is_open(&this->filebuf);
9854 }
9855
9856 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
9857 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
9858 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 12)
9859 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
9860         const char *name, int mode)
9861 {
9862     TRACE("(%p %s %d)\n", this, name, mode);
9863
9864     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9865         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
9866         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
9867     }
9868 }
9869
9870 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
9871 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
9872 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
9873 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
9874         const char *name, short mode)
9875 {
9876     basic_ifstream_char_open(this, name, mode);
9877 }
9878
9879 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9880 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
9881 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
9882 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
9883 {
9884     TRACE("(%p)\n", this);
9885     return (basic_filebuf_char*)&this->filebuf;
9886 }
9887
9888 static inline basic_ios_wchar* basic_ifstream_wchar_to_basic_ios(basic_ifstream_wchar *ptr)
9889 {
9890     return (basic_ios_wchar*)((char*)ptr+basic_ifstream_wchar_vbtable[1]);
9891 }
9892
9893 static inline basic_ifstream_wchar* basic_ifstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9894 {
9895     return (basic_ifstream_wchar*)((char*)ptr-basic_ifstream_wchar_vbtable[1]);
9896 }
9897
9898 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
9899 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
9900 static basic_ifstream_wchar* basic_ifstream_wchar_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
9901 {
9902     basic_ios_wchar *basic_ios;
9903
9904     TRACE("(%p %d)\n", this, virt_init);
9905
9906     if(virt_init) {
9907         this->base.vbtable = basic_ifstream_wchar_vbtable;
9908         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9909         basic_ios_wchar_ctor(basic_ios);
9910     }else {
9911         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9912     }
9913
9914     basic_filebuf_wchar_ctor(&this->filebuf);
9915     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9916     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
9917     return this;
9918 }
9919
9920 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
9921 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
9922 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor, 8)
9923 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
9924 {
9925     basic_ifstream_wchar_ctor(this, virt_init);
9926     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
9927     return this;
9928 }
9929
9930 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
9931 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9932 static basic_ifstream_wchar* basic_ifstream_wchar_ctor_file(
9933         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9934 {
9935     basic_ios_wchar *basic_ios;
9936
9937     TRACE("(%p %p %d)\n", this, file, virt_init);
9938
9939     if(virt_init) {
9940         this->base.vbtable = basic_ifstream_wchar_vbtable;
9941         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9942         basic_ios_wchar_ctor(basic_ios);
9943     }else {
9944         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9945     }
9946
9947     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
9948     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
9949     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
9950     return this;
9951 }
9952
9953 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
9954 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
9955 static basic_ifstream_wchar* basic_ifstream_short_ctor_file(
9956         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
9957 {
9958     basic_ifstream_wchar_ctor_file(this, file, virt_init);
9959     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
9960     return this;
9961 }
9962
9963 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
9964 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
9965 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_copy_ctor, 12)
9966 basic_ifstream_wchar* __thiscall basic_ifstream_short_copy_ctor(basic_ifstream_wchar *this,
9967         basic_ifstream_wchar *copy, MSVCP_bool virt_init)
9968 {
9969     TRACE("(%p %p %d)\n", this, copy, virt_init);
9970     return basic_ifstream_short_ctor_file(this, copy->filebuf.file, virt_init);
9971 }
9972
9973 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBDH@Z */
9974 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDH@Z */
9975 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name, 16)
9976 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name(basic_ifstream_wchar *this,
9977         const char *name, int mode, MSVCP_bool virt_init)
9978 {
9979     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
9980
9981     basic_ifstream_short_ctor(this, virt_init);
9982
9983     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
9984         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
9985         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
9986     }
9987     return this;
9988 }
9989
9990 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9991 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9992 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9993 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9994 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_dtor, 4)
9995 void __thiscall basic_ifstream_wchar_dtor(basic_ios_wchar *base)
9996 {
9997     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
9998
9999     TRACE("(%p)\n", this);
10000
10001     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
10002     basic_filebuf_wchar_dtor(&this->filebuf);
10003 }
10004
10005 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10006 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10007 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10008 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10009 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vbase_dtor, 4)
10010 void __thiscall basic_ifstream_wchar_vbase_dtor(basic_ifstream_wchar *this)
10011 {
10012     TRACE("(%p)\n", this);
10013
10014     basic_ifstream_wchar_dtor(basic_ifstream_wchar_to_basic_ios(this));
10015     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
10016 }
10017
10018 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vector_dtor, 8)
10019 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10020 {
10021     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10022
10023     TRACE("(%p %x)\n", this, flags);
10024
10025     if(flags & 2) {
10026         /* we have an array, with the number of elements stored before the first object */
10027         INT_PTR i, *ptr = (INT_PTR *)this-1;
10028
10029         for(i=*ptr-1; i>=0; i--)
10030             basic_ifstream_wchar_vbase_dtor(this+i);
10031         MSVCRT_operator_delete(ptr);
10032     } else {
10033         basic_ifstream_wchar_vbase_dtor(this);
10034         if(flags & 1)
10035             MSVCRT_operator_delete(this);
10036     }
10037
10038     return this;
10039 }
10040
10041 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10042 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10043 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10044 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10045 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_close, 4)
10046 void __thiscall basic_ifstream_wchar_close(basic_ifstream_wchar *this)
10047 {
10048     TRACE("(%p)\n", this);
10049
10050     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10051         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10052         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10053     }
10054 }
10055
10056 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10057 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10058 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10059 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10060 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_is_open, 4)
10061 MSVCP_bool __thiscall basic_ifstream_wchar_is_open(const basic_ifstream_wchar *this)
10062 {
10063     TRACE("(%p)\n", this);
10064     return basic_filebuf_wchar_is_open(&this->filebuf);
10065 }
10066
10067 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDH@Z */
10068 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDH@Z */
10069 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open, 12)
10070 void __thiscall basic_ifstream_wchar_open(basic_ifstream_wchar *this,
10071         const char *name, int mode)
10072 {
10073     TRACE("(%p %s %d)\n", this, name, mode);
10074
10075     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, _SH_DENYNO)) {
10076         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10077         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10078     }
10079 }
10080
10081 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDF@Z */
10082 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDF@Z */
10083 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_old, 12)
10084 void __thiscall basic_ifstream_wchar_open_old(basic_ifstream_wchar *this,
10085         const char *name, short mode)
10086 {
10087     basic_ifstream_wchar_open(this, name, mode);
10088 }
10089
10090 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10091 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10092 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10093 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10094 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_rdbuf, 4)
10095 basic_filebuf_wchar* __thiscall basic_ifstream_wchar_rdbuf(const basic_ifstream_wchar *this)
10096 {
10097     TRACE("(%p)\n", this);
10098     return (basic_filebuf_wchar*)&this->filebuf;
10099 }
10100
10101 static inline basic_ios_char* basic_fstream_char_to_basic_ios(basic_fstream_char *ptr)
10102 {
10103     return (basic_ios_char*)((char*)ptr+basic_fstream_char_vbtable1[1]);
10104 }
10105
10106 static inline basic_fstream_char* basic_fstream_char_from_basic_ios(basic_ios_char *ptr)
10107 {
10108     return (basic_fstream_char*)((char*)ptr-basic_fstream_char_vbtable1[1]);
10109 }
10110
10111 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10112 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10113 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
10114 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
10115 {
10116     basic_ios_char *basic_ios;
10117
10118     TRACE("(%p %d)\n", this, virt_init);
10119
10120     if(virt_init) {
10121         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10122         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10123         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10124         basic_ios_char_ctor(basic_ios);
10125     }else {
10126         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10127     }
10128
10129     basic_filebuf_char_ctor(&this->filebuf);
10130     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10131     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10132     return this;
10133 }
10134
10135 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10136 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10137 static basic_fstream_char* basic_fstream_char_ctor_file(basic_fstream_char *this,
10138         FILE *file, MSVCP_bool virt_init)
10139 {
10140     basic_ios_char *basic_ios;
10141
10142     TRACE("(%p %p %d)\n", this, file, virt_init);
10143
10144     if(virt_init) {
10145         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10146         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10147         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10148         basic_ios_char_ctor(basic_ios);
10149     }else {
10150         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10151     }
10152
10153     basic_filebuf_char_ctor_file(&this->filebuf, file);
10154     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10155     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10156     return this;
10157 }
10158
10159 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@ABV01@@Z */
10160 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@AEBV01@@Z */
10161 DEFINE_THISCALL_WRAPPER(basic_fstream_char_copy_ctor, 12)
10162 basic_fstream_char* __thiscall basic_fstream_char_copy_ctor(basic_fstream_char *this,
10163         basic_fstream_char *copy, MSVCP_bool virt_init)
10164 {
10165     TRACE("(%p %p %d)\n", this, copy, virt_init);
10166     return basic_fstream_char_ctor_file(this, copy->filebuf.file, virt_init);
10167 }
10168
10169 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z */
10170 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDH@Z */
10171 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 16)
10172 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
10173         const char *name, int mode, MSVCP_bool virt_init)
10174 {
10175     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10176
10177     basic_fstream_char_ctor(this, virt_init);
10178
10179     if(!basic_filebuf_char_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10180         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10181         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10182     }
10183     return this;
10184 }
10185
10186 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10187 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10188 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
10189 void __thiscall basic_fstream_char_dtor(basic_ios_char *base)
10190 {
10191     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10192
10193     TRACE("(%p)\n", this);
10194
10195     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
10196     basic_filebuf_char_dtor(&this->filebuf);
10197 }
10198
10199 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10200 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10201 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
10202 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
10203 {
10204     TRACE("(%p)\n", this);
10205
10206     basic_fstream_char_dtor(basic_fstream_char_to_basic_ios(this));
10207     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
10208 }
10209
10210 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vector_dtor, 8)
10211 basic_fstream_char* __thiscall basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10212 {
10213     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10214
10215     TRACE("(%p %x)\n", this, flags);
10216
10217     if(flags & 2) {
10218         /* we have an array, with the number of elements stored before the first object */
10219         INT_PTR i, *ptr = (INT_PTR *)this-1;
10220
10221         for(i=*ptr-1; i>=0; i--)
10222             basic_fstream_char_vbase_dtor(this+i);
10223         MSVCRT_operator_delete(ptr);
10224     } else {
10225         basic_fstream_char_vbase_dtor(this);
10226         if(flags & 1)
10227             MSVCRT_operator_delete(this);
10228     }
10229
10230     return this;
10231 }
10232
10233 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10234 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10235 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
10236 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
10237 {
10238     TRACE("(%p)\n", this);
10239
10240     if(!basic_filebuf_char_close(&this->filebuf)) {
10241         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10242         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10243     }
10244 }
10245
10246 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10247 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10248 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
10249 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
10250 {
10251     TRACE("(%p)\n", this);
10252     return basic_filebuf_char_is_open(&this->filebuf);
10253 }
10254
10255 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDH@Z */
10256 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDH@Z */
10257 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 12)
10258 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
10259         const char *name, int mode)
10260 {
10261     TRACE("(%p %s %d)\n", this, name, mode);
10262
10263     if(!basic_filebuf_char_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10264         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10265         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10266     }
10267 }
10268
10269 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDF@Z */
10270 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDF@Z */
10271 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
10272 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
10273         const char *name, int mode)
10274 {
10275     basic_fstream_char_open(this, name, mode);
10276 }
10277
10278 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10279 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10280 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
10281 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
10282 {
10283     TRACE("(%p)\n", this);
10284     return (basic_filebuf_char*)&this->filebuf;
10285 }
10286
10287 static inline basic_ios_wchar* basic_fstream_wchar_to_basic_ios(basic_fstream_wchar *ptr)
10288 {
10289     return (basic_ios_wchar*)((char*)ptr+basic_fstream_wchar_vbtable1[1]);
10290 }
10291
10292 static inline basic_fstream_wchar* basic_fstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10293 {
10294     return (basic_fstream_wchar*)((char*)ptr-basic_fstream_wchar_vbtable1[1]);
10295 }
10296
10297 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10298 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10299 static basic_fstream_wchar* basic_fstream_wchar_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10300 {
10301     basic_ios_wchar *basic_ios;
10302
10303     TRACE("(%p %d)\n", this, virt_init);
10304
10305     if(virt_init) {
10306         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10307         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10308         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10309         basic_ios_wchar_ctor(basic_ios);
10310     }else {
10311         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10312     }
10313
10314     basic_filebuf_wchar_ctor(&this->filebuf);
10315     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10316     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10317     return this;
10318 }
10319
10320 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10321 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10322 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor, 8)
10323 basic_fstream_wchar* __thiscall basic_fstream_short_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10324 {
10325     basic_fstream_wchar_ctor(this, virt_init);
10326     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
10327     return this;
10328 }
10329
10330 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10331 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10332 static basic_fstream_wchar* basic_fstream_wchar_ctor_file(basic_fstream_wchar *this,
10333         FILE *file, MSVCP_bool virt_init)
10334 {
10335     basic_ios_wchar *basic_ios;
10336
10337     TRACE("(%p %p %d)\n", this, file, virt_init);
10338
10339     if(virt_init) {
10340         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10341         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10342         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10343         basic_ios_wchar_ctor(basic_ios);
10344     }else {
10345         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10346     }
10347
10348     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10349     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10350     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10351     return this;
10352 }
10353
10354 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10355 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10356 static basic_fstream_wchar* basic_fstream_short_ctor_file(basic_fstream_wchar *this,
10357         FILE *file, MSVCP_bool virt_init)
10358 {
10359     basic_fstream_wchar_ctor_file(this, file, virt_init);
10360     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
10361     return this;
10362 }
10363
10364 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@ABV01@@Z */
10365 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@AEBV01@@Z */
10366 DEFINE_THISCALL_WRAPPER(basic_fstream_short_copy_ctor, 12)
10367 basic_fstream_wchar* __thiscall basic_fstream_short_copy_ctor(basic_fstream_wchar *this,
10368         basic_fstream_wchar *copy, MSVCP_bool virt_init)
10369 {
10370     TRACE("(%p %p %d)\n", this, copy, virt_init);
10371     return basic_fstream_short_ctor_file(this, copy->filebuf.file, virt_init);
10372 }
10373
10374 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
10375 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
10376 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name, 16)
10377 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name(basic_fstream_wchar *this,
10378         const char *name, int mode, MSVCP_bool virt_init)
10379 {
10380     TRACE("(%p %s %d %d)\n", this, name, mode, virt_init);
10381
10382     basic_fstream_short_ctor(this, virt_init);
10383
10384     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10385         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10386         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10387     }
10388     return this;
10389 }
10390
10391 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10392 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10393 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10394 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10395 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_dtor, 4)
10396 void __thiscall basic_fstream_wchar_dtor(basic_ios_wchar *base)
10397 {
10398     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10399
10400     TRACE("(%p)\n", this);
10401
10402     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
10403     basic_filebuf_wchar_dtor(&this->filebuf);
10404 }
10405
10406 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10407 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10408 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10409 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10410 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vbase_dtor, 4)
10411 void __thiscall basic_fstream_wchar_vbase_dtor(basic_fstream_wchar *this)
10412 {
10413     TRACE("(%p)\n", this);
10414
10415     basic_fstream_wchar_dtor(basic_fstream_wchar_to_basic_ios(this));
10416     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
10417 }
10418
10419 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vector_dtor, 8)
10420 basic_fstream_wchar* __thiscall basic_fstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10421 {
10422     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
10423
10424     TRACE("(%p %x)\n", this, flags);
10425
10426     if(flags & 2) {
10427         /* we have an array, with the number of elements stored before the first object */
10428         INT_PTR i, *ptr = (INT_PTR *)this-1;
10429
10430         for(i=*ptr-1; i>=0; i--)
10431             basic_fstream_wchar_vbase_dtor(this+i);
10432         MSVCRT_operator_delete(ptr);
10433     } else {
10434         basic_fstream_wchar_vbase_dtor(this);
10435         if(flags & 1)
10436             MSVCRT_operator_delete(this);
10437     }
10438
10439     return this;
10440 }
10441
10442 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10443 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10444 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10445 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10446 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_close, 4)
10447 void __thiscall basic_fstream_wchar_close(basic_fstream_wchar *this)
10448 {
10449     TRACE("(%p)\n", this);
10450
10451     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10452         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10453         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10454     }
10455 }
10456
10457 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10458 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10459 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10460 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10461 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_is_open, 4)
10462 MSVCP_bool __thiscall basic_fstream_wchar_is_open(const basic_fstream_wchar *this)
10463 {
10464     TRACE("(%p)\n", this);
10465     return basic_filebuf_wchar_is_open(&this->filebuf);
10466 }
10467
10468 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDH@Z */
10469 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDH@Z */
10470 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open, 12)
10471 void __thiscall basic_fstream_wchar_open(basic_fstream_wchar *this,
10472         const char *name, int mode)
10473 {
10474     TRACE("(%p %s %d)\n", this, name, mode);
10475
10476     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, _SH_DENYNO)) {
10477         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10478         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10479     }
10480 }
10481
10482 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDF@Z */
10483 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDF@Z */
10484 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_old, 12)
10485 void __thiscall basic_fstream_wchar_open_old(basic_fstream_wchar *this,
10486         const char *name, int mode)
10487 {
10488     basic_fstream_wchar_open(this, name, mode);
10489 }
10490
10491 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10492 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10493 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10494 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10495 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_rdbuf, 4)
10496 basic_filebuf_wchar* __thiscall basic_fstream_wchar_rdbuf(const basic_fstream_wchar *this)
10497 {
10498     TRACE("(%p)\n", this);
10499     return (basic_filebuf_wchar*)&this->filebuf;
10500 }
10501
10502 static inline basic_ios_char* basic_ostringstream_char_to_basic_ios(basic_ostringstream_char *ptr)
10503 {
10504     return (basic_ios_char*)((char*)ptr+basic_ostringstream_char_vbtable[1]);
10505 }
10506
10507 static inline basic_ostringstream_char* basic_ostringstream_char_from_basic_ios(basic_ios_char *ptr)
10508 {
10509     return (basic_ostringstream_char*)((char*)ptr-basic_ostringstream_char_vbtable[1]);
10510 }
10511
10512 /* ??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 */
10513 /* ??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 */
10514 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_str, 16)
10515 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_str(basic_ostringstream_char *this,
10516         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10517 {
10518     basic_ios_char *basic_ios;
10519
10520     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10521
10522     if(virt_init) {
10523         this->base.vbtable = basic_ostringstream_char_vbtable;
10524         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10525         basic_ios_char_ctor(basic_ios);
10526     }else {
10527         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10528     }
10529
10530     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10531     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, TRUE, FALSE);
10532     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10533     return this;
10534 }
10535
10536 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
10537 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
10538 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_mode, 12)
10539 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_mode(
10540         basic_ostringstream_char *this, int mode, MSVCP_bool virt_init)
10541 {
10542     basic_ios_char *basic_ios;
10543
10544     TRACE("(%p %d %d)\n", this, mode, virt_init);
10545
10546     if(virt_init) {
10547         this->base.vbtable = basic_ostringstream_char_vbtable;
10548         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10549         basic_ios_char_ctor(basic_ios);
10550     }else {
10551         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10552     }
10553
10554     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10555     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, TRUE, FALSE);
10556     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
10557     return this;
10558 }
10559
10560 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10561 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10562 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor, 8)
10563 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor(
10564         basic_ostringstream_char *this, MSVCP_bool virt_init)
10565 {
10566     return basic_ostringstream_char_ctor_mode(this, 0, virt_init);
10567 }
10568
10569 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
10570 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
10571 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_dtor, 4)
10572 void __thiscall basic_ostringstream_char_dtor(basic_ios_char *base)
10573 {
10574     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10575
10576     TRACE("(%p)\n", this);
10577
10578     basic_stringbuf_char_dtor(&this->strbuf);
10579     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
10580 }
10581
10582 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10583 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10584 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vbase_dtor, 4)
10585 void __thiscall basic_ostringstream_char_vbase_dtor(basic_ostringstream_char *this)
10586 {
10587     TRACE("(%p)\n", this);
10588
10589     basic_ostringstream_char_dtor(basic_ostringstream_char_to_basic_ios(this));
10590     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
10591 }
10592
10593 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vector_dtor, 8)
10594 basic_ostringstream_char* __thiscall basic_ostringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10595 {
10596     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
10597
10598     TRACE("(%p %x)\n", this, flags);
10599
10600     if(flags & 2) {
10601         /* we have an array, with the number of elements stored before the first object */
10602         INT_PTR i, *ptr = (INT_PTR *)this-1;
10603
10604         for(i=*ptr-1; i>=0; i--)
10605             basic_ostringstream_char_vbase_dtor(this+i);
10606         MSVCRT_operator_delete(ptr);
10607     } else {
10608         basic_ostringstream_char_vbase_dtor(this);
10609         if(flags & 1)
10610             MSVCRT_operator_delete(this);
10611     }
10612
10613     return this;
10614 }
10615
10616 /* ?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 */
10617 /* ?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 */
10618 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_rdbuf, 4)
10619 basic_stringbuf_char* __thiscall basic_ostringstream_char_rdbuf(const basic_ostringstream_char *this)
10620 {
10621     TRACE("(%p)\n", this);
10622     return (basic_stringbuf_char*)&this->strbuf;
10623 }
10624
10625 /* ?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 */
10626 /* ?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 */
10627 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_set, 8)
10628 void __thiscall basic_ostringstream_char_str_set(basic_ostringstream_char *this, const basic_string_char *str)
10629 {
10630     TRACE("(%p %p)\n", this, str);
10631     basic_stringbuf_char_str_set(&this->strbuf, str);
10632 }
10633
10634 /* ?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 */
10635 /* ?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 */
10636 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_get, 8)
10637 basic_string_char* __thiscall basic_ostringstream_char_str_get(const basic_ostringstream_char *this, basic_string_char *ret)
10638 {
10639     TRACE("(%p %p)\n", this, ret);
10640     return basic_stringbuf_char_str_get(&this->strbuf, ret);
10641 }
10642
10643 static inline basic_ios_wchar* basic_ostringstream_wchar_to_basic_ios(basic_ostringstream_wchar *ptr)
10644 {
10645     return (basic_ios_wchar*)((char*)ptr+basic_ostringstream_wchar_vbtable[1]);
10646 }
10647
10648 static inline basic_ostringstream_wchar* basic_ostringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10649 {
10650     return (basic_ostringstream_wchar*)((char*)ptr-basic_ostringstream_wchar_vbtable[1]);
10651 }
10652
10653 /* ??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 */
10654 /* ??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 */
10655 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_str(basic_ostringstream_wchar *this,
10656         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10657 {
10658     basic_ios_wchar *basic_ios;
10659
10660     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10661
10662     if(virt_init) {
10663         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10664         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10665         basic_ios_wchar_ctor(basic_ios);
10666     }else {
10667         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10668     }
10669
10670     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
10671     basic_ostream_short_ctor(&this->base, &this->strbuf.base, FALSE, TRUE, FALSE);
10672     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10673     return this;
10674 }
10675
10676 /* ??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 */
10677 /* ??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 */
10678 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_str, 16)
10679 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_str(basic_ostringstream_wchar *this,
10680         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10681 {
10682     basic_ostringstream_wchar_ctor_str(this, str, mode, virt_init);
10683     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10684     return this;
10685 }
10686
10687 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
10688 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
10689 static basic_ostringstream_wchar* basic_ostringstream_wchar_ctor_mode(
10690         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10691 {
10692     basic_ios_wchar *basic_ios;
10693
10694     TRACE("(%p %d %d)\n", this, mode, virt_init);
10695
10696     if(virt_init) {
10697         this->base.vbtable = basic_ostringstream_wchar_vbtable;
10698         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10699         basic_ios_wchar_ctor(basic_ios);
10700     }else {
10701         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10702     }
10703
10704     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_out);
10705     basic_ostream_short_ctor(&this->base, &this->strbuf.base, FALSE, TRUE, FALSE);
10706     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
10707     return this;
10708 }
10709
10710 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
10711 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
10712 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_mode, 12)
10713 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_mode(
10714         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
10715 {
10716     basic_ostringstream_wchar_ctor_mode(this, mode, virt_init);
10717     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
10718     return this;
10719 }
10720
10721 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10722 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10723 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor, 8)
10724 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor(
10725         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
10726 {
10727     return basic_ostringstream_short_ctor_mode(this, 0, virt_init);
10728 }
10729
10730 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
10731 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
10732 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
10733 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
10734 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_dtor, 4)
10735 void __thiscall basic_ostringstream_wchar_dtor(basic_ios_wchar *base)
10736 {
10737     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10738
10739     TRACE("(%p)\n", this);
10740
10741     basic_stringbuf_wchar_dtor(&this->strbuf);
10742     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
10743 }
10744
10745 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
10746 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
10747 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
10748 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
10749 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vbase_dtor, 4)
10750 void __thiscall basic_ostringstream_wchar_vbase_dtor(basic_ostringstream_wchar *this)
10751 {
10752     TRACE("(%p)\n", this);
10753
10754     basic_ostringstream_wchar_dtor(basic_ostringstream_wchar_to_basic_ios(this));
10755     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
10756 }
10757
10758 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vector_dtor, 8)
10759 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10760 {
10761     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
10762
10763     TRACE("(%p %x)\n", this, flags);
10764
10765     if(flags & 2) {
10766         /* we have an array, with the number of elements stored before the first object */
10767         INT_PTR i, *ptr = (INT_PTR *)this-1;
10768
10769         for(i=*ptr-1; i>=0; i--)
10770             basic_ostringstream_wchar_vbase_dtor(this+i);
10771         MSVCRT_operator_delete(ptr);
10772     } else {
10773         basic_ostringstream_wchar_vbase_dtor(this);
10774         if(flags & 1)
10775             MSVCRT_operator_delete(this);
10776     }
10777
10778     return this;
10779 }
10780
10781 /* ?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 */
10782 /* ?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 */
10783 /* ?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 */
10784 /* ?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 */
10785 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_rdbuf, 4)
10786 basic_stringbuf_wchar* __thiscall basic_ostringstream_wchar_rdbuf(const basic_ostringstream_wchar *this)
10787 {
10788     TRACE("(%p)\n", this);
10789     return (basic_stringbuf_wchar*)&this->strbuf;
10790 }
10791
10792 /* ?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 */
10793 /* ?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 */
10794 /* ?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 */
10795 /* ?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 */
10796 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_set, 8)
10797 void __thiscall basic_ostringstream_wchar_str_set(basic_ostringstream_wchar *this, const basic_string_wchar *str)
10798 {
10799     TRACE("(%p %p)\n", this, str);
10800     basic_stringbuf_wchar_str_set(&this->strbuf, str);
10801 }
10802
10803 /* ?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 */
10804 /* ?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 */
10805 /* ?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 */
10806 /* ?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 */
10807 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_get, 8)
10808 basic_string_wchar* __thiscall basic_ostringstream_wchar_str_get(const basic_ostringstream_wchar *this, basic_string_wchar *ret)
10809 {
10810     TRACE("(%p %p)\n", this, ret);
10811     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
10812 }
10813
10814 static inline basic_ios_char* basic_istringstream_char_to_basic_ios(basic_istringstream_char *ptr)
10815 {
10816     return (basic_ios_char*)((char*)ptr+basic_istringstream_char_vbtable[1]);
10817 }
10818
10819 static inline basic_istringstream_char* basic_istringstream_char_from_basic_ios(basic_ios_char *ptr)
10820 {
10821     return (basic_istringstream_char*)((char*)ptr-basic_istringstream_char_vbtable[1]);
10822 }
10823
10824 /* ??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 */
10825 /* ??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 */
10826 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_str, 16)
10827 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_str(basic_istringstream_char *this,
10828         const basic_string_char *str, int mode, MSVCP_bool virt_init)
10829 {
10830     basic_ios_char *basic_ios;
10831
10832     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10833
10834     if(virt_init) {
10835         this->base.vbtable = basic_istringstream_char_vbtable;
10836         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10837         basic_ios_char_ctor(basic_ios);
10838     }else {
10839         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10840     }
10841
10842     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
10843     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10844     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
10845     return this;
10846 }
10847
10848 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
10849 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
10850 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_mode, 12)
10851 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_mode(
10852         basic_istringstream_char *this, int mode, MSVCP_bool virt_init)
10853 {
10854     basic_ios_char *basic_ios;
10855
10856     TRACE("(%p %d %d)\n", this, mode, virt_init);
10857
10858     if(virt_init) {
10859         this->base.vbtable = basic_istringstream_char_vbtable;
10860         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10861         basic_ios_char_ctor(basic_ios);
10862     }else {
10863         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10864     }
10865
10866     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_in);
10867     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10868     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
10869     return this;
10870 }
10871
10872 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10873 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10874 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor, 8)
10875 basic_istringstream_char* __thiscall basic_istringstream_char_ctor(
10876         basic_istringstream_char *this, MSVCP_bool virt_init)
10877 {
10878     return basic_istringstream_char_ctor_mode(this, 0, virt_init);
10879 }
10880
10881 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
10882 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
10883 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_dtor, 4)
10884 void __thiscall basic_istringstream_char_dtor(basic_ios_char *base)
10885 {
10886     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
10887
10888     TRACE("(%p)\n", this);
10889
10890     basic_stringbuf_char_dtor(&this->strbuf);
10891     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
10892 }
10893
10894 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
10895 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
10896 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vbase_dtor, 4)
10897 void __thiscall basic_istringstream_char_vbase_dtor(basic_istringstream_char *this)
10898 {
10899     TRACE("(%p)\n", this);
10900
10901     basic_istringstream_char_dtor(basic_istringstream_char_to_basic_ios(this));
10902     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
10903 }
10904
10905 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vector_dtor, 8)
10906 basic_istringstream_char* __thiscall basic_istringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10907 {
10908     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
10909
10910     TRACE("(%p %x)\n", this, flags);
10911
10912     if(flags & 2) {
10913         /* we have an array, with the number of elements stored before the first object */
10914         INT_PTR i, *ptr = (INT_PTR *)this-1;
10915
10916         for(i=*ptr-1; i>=0; i--)
10917             basic_istringstream_char_vbase_dtor(this+i);
10918         MSVCRT_operator_delete(ptr);
10919     } else {
10920         basic_istringstream_char_vbase_dtor(this);
10921         if(flags & 1)
10922             MSVCRT_operator_delete(this);
10923     }
10924
10925     return this;
10926 }
10927
10928 /* ?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 */
10929 /* ?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 */
10930 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_rdbuf, 4)
10931 basic_stringbuf_char* __thiscall basic_istringstream_char_rdbuf(const basic_istringstream_char *this)
10932 {
10933     TRACE("(%p)\n", this);
10934     return (basic_stringbuf_char*)&this->strbuf;
10935 }
10936
10937 /* ?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 */
10938 /* ?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 */
10939 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_set, 8)
10940 void __thiscall basic_istringstream_char_str_set(basic_istringstream_char *this, const basic_string_char *str)
10941 {
10942     TRACE("(%p %p)\n", this, str);
10943     basic_stringbuf_char_str_set(&this->strbuf, str);
10944 }
10945
10946 /* ?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 */
10947 /* ?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 */
10948 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_get, 8)
10949 basic_string_char* __thiscall basic_istringstream_char_str_get(const basic_istringstream_char *this, basic_string_char *ret)
10950 {
10951     TRACE("(%p %p)\n", this, ret);
10952     return basic_stringbuf_char_str_get(&this->strbuf, ret);
10953 }
10954
10955 static inline basic_ios_wchar* basic_istringstream_wchar_to_basic_ios(basic_istringstream_wchar *ptr)
10956 {
10957     return (basic_ios_wchar*)((char*)ptr+basic_istringstream_wchar_vbtable[1]);
10958 }
10959
10960 static inline basic_istringstream_wchar* basic_istringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10961 {
10962     return (basic_istringstream_wchar*)((char*)ptr-basic_istringstream_wchar_vbtable[1]);
10963 }
10964
10965 /* ??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 */
10966 /* ??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 */
10967 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_str(basic_istringstream_wchar *this,
10968         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10969 {
10970     basic_ios_wchar *basic_ios;
10971
10972     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
10973
10974     if(virt_init) {
10975         this->base.vbtable = basic_istringstream_wchar_vbtable;
10976         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10977         basic_ios_wchar_ctor(basic_ios);
10978     }else {
10979         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10980     }
10981
10982     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
10983     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
10984     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
10985     return this;
10986 }
10987
10988 /* ??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 */
10989 /* ??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 */
10990 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_str, 16)
10991 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_str(basic_istringstream_wchar *this,
10992         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
10993 {
10994     basic_istringstream_wchar_ctor_str(this, str, mode, virt_init);
10995     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
10996     return this;
10997 }
10998
10999 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11000 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11001 static basic_istringstream_wchar* basic_istringstream_wchar_ctor_mode(
11002         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11003 {
11004     basic_ios_wchar *basic_ios;
11005
11006     TRACE("(%p %d %d)\n", this, mode, virt_init);
11007
11008     if(virt_init) {
11009         this->base.vbtable = basic_istringstream_wchar_vbtable;
11010         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11011         basic_ios_wchar_ctor(basic_ios);
11012     }else {
11013         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11014     }
11015
11016     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11017     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11018     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11019     return this;
11020 }
11021
11022 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11023 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11024 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_mode, 12)
11025 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_mode(
11026         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11027 {
11028     basic_istringstream_wchar_ctor_mode(this, mode, virt_init);
11029     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11030     return this;
11031 }
11032
11033 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11034 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11035 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor, 8)
11036 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor(
11037         basic_istringstream_wchar *this, MSVCP_bool virt_init)
11038 {
11039     return basic_istringstream_short_ctor_mode(this, 0, virt_init);
11040 }
11041
11042 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11043 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11044 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11045 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11046 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_dtor, 4)
11047 void __thiscall basic_istringstream_wchar_dtor(basic_ios_wchar *base)
11048 {
11049     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11050
11051     TRACE("(%p)\n", this);
11052
11053     basic_stringbuf_wchar_dtor(&this->strbuf);
11054     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
11055 }
11056
11057 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11058 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11059 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11060 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11061 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vbase_dtor, 4)
11062 void __thiscall basic_istringstream_wchar_vbase_dtor(basic_istringstream_wchar *this)
11063 {
11064     TRACE("(%p)\n", this);
11065
11066     basic_istringstream_wchar_dtor(basic_istringstream_wchar_to_basic_ios(this));
11067     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
11068 }
11069
11070 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vector_dtor, 8)
11071 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11072 {
11073     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11074
11075     TRACE("(%p %x)\n", this, flags);
11076
11077     if(flags & 2) {
11078         /* we have an array, with the number of elements stored before the first object */
11079         INT_PTR i, *ptr = (INT_PTR *)this-1;
11080
11081         for(i=*ptr-1; i>=0; i--)
11082             basic_istringstream_wchar_vbase_dtor(this+i);
11083         MSVCRT_operator_delete(ptr);
11084     } else {
11085         basic_istringstream_wchar_vbase_dtor(this);
11086         if(flags & 1)
11087             MSVCRT_operator_delete(this);
11088     }
11089
11090     return this;
11091 }
11092
11093 /* ?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 */
11094 /* ?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 */
11095 /* ?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 */
11096 /* ?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 */
11097 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_rdbuf, 4)
11098 basic_stringbuf_wchar* __thiscall basic_istringstream_wchar_rdbuf(const basic_istringstream_wchar *this)
11099 {
11100     TRACE("(%p)\n", this);
11101     return (basic_stringbuf_wchar*)&this->strbuf;
11102 }
11103
11104 /* ?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 */
11105 /* ?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 */
11106 /* ?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 */
11107 /* ?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 */
11108 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_set, 8)
11109 void __thiscall basic_istringstream_wchar_str_set(basic_istringstream_wchar *this, const basic_string_wchar *str)
11110 {
11111     TRACE("(%p %p)\n", this, str);
11112     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11113 }
11114
11115 /* ?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 */
11116 /* ?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 */
11117 /* ?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 */
11118 /* ?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 */
11119 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_get, 8)
11120 basic_string_wchar* __thiscall basic_istringstream_wchar_str_get(const basic_istringstream_wchar *this, basic_string_wchar *ret)
11121 {
11122     TRACE("(%p %p)\n", this, ret);
11123     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11124 }
11125
11126 static inline basic_ios_char* basic_stringstream_char_to_basic_ios(basic_stringstream_char *ptr)
11127 {
11128     return (basic_ios_char*)((char*)ptr+basic_stringstream_char_vbtable1[1]);
11129 }
11130
11131 static inline basic_stringstream_char* basic_stringstream_char_from_basic_ios(basic_ios_char *ptr)
11132 {
11133     return (basic_stringstream_char*)((char*)ptr-basic_stringstream_char_vbtable1[1]);
11134 }
11135
11136 /* ??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 */
11137 /* ??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 */
11138 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_str, 16)
11139 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_str(basic_stringstream_char *this,
11140         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11141 {
11142     basic_ios_char *basic_ios;
11143
11144     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11145
11146     if(virt_init) {
11147         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11148         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11149         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11150         basic_ios_char_ctor(basic_ios);
11151     }else {
11152         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11153     }
11154
11155     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode);
11156     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11157     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11158     return this;
11159 }
11160
11161 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11162 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11163 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_mode, 12)
11164 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_mode(
11165         basic_stringstream_char *this, int mode, MSVCP_bool virt_init)
11166 {
11167     basic_ios_char *basic_ios;
11168
11169     TRACE("(%p %d %d)\n", this, mode, virt_init);
11170
11171     if(virt_init) {
11172         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11173         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11174         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11175         basic_ios_char_ctor(basic_ios);
11176     }else {
11177         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11178     }
11179
11180     basic_stringbuf_char_ctor_mode(&this->strbuf, mode);
11181     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11182     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11183     return this;
11184 }
11185
11186 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11187 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11188 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor, 8)
11189 basic_stringstream_char* __thiscall basic_stringstream_char_ctor(
11190         basic_stringstream_char *this, MSVCP_bool virt_init)
11191 {
11192     return basic_stringstream_char_ctor_mode(
11193             this, OPENMODE_out|OPENMODE_in, virt_init);
11194 }
11195
11196 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11197 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11198 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_dtor, 4)
11199 void __thiscall basic_stringstream_char_dtor(basic_ios_char *base)
11200 {
11201     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11202
11203     TRACE("(%p)\n", this);
11204
11205     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11206     basic_stringbuf_char_dtor(&this->strbuf);
11207 }
11208
11209 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11210 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11211 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vbase_dtor, 4)
11212 void __thiscall basic_stringstream_char_vbase_dtor(basic_stringstream_char *this)
11213 {
11214     TRACE("(%p)\n", this);
11215
11216     basic_stringstream_char_dtor(basic_stringstream_char_to_basic_ios(this));
11217     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11218 }
11219
11220 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vector_dtor, 8)
11221 basic_stringstream_char* __thiscall basic_stringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11222 {
11223     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11224
11225     TRACE("(%p %x)\n", this, flags);
11226
11227     if(flags & 2) {
11228         /* we have an array, with the number of elements stored before the first object */
11229         INT_PTR i, *ptr = (INT_PTR *)this-1;
11230
11231         for(i=*ptr-1; i>=0; i--)
11232             basic_stringstream_char_vbase_dtor(this+i);
11233         MSVCRT_operator_delete(ptr);
11234     } else {
11235         basic_stringstream_char_vbase_dtor(this);
11236         if(flags & 1)
11237             MSVCRT_operator_delete(this);
11238     }
11239
11240     return this;
11241 }
11242
11243 /* ?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 */
11244 /* ?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 */
11245 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_rdbuf, 4)
11246 basic_stringbuf_char* __thiscall basic_stringstream_char_rdbuf(const basic_stringstream_char *this)
11247 {
11248     TRACE("(%p)\n", this);
11249     return (basic_stringbuf_char*)&this->strbuf;
11250 }
11251
11252 /* ?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 */
11253 /* ?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 */
11254 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_set, 8)
11255 void __thiscall basic_stringstream_char_str_set(basic_stringstream_char *this, const basic_string_char *str)
11256 {
11257     TRACE("(%p %p)\n", this, str);
11258     basic_stringbuf_char_str_set(&this->strbuf, str);
11259 }
11260
11261 /* ?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 */
11262 /* ?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 */
11263 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_get, 8)
11264 basic_string_char* __thiscall basic_stringstream_char_str_get(const basic_stringstream_char *this, basic_string_char *ret)
11265 {
11266     TRACE("(%p %p)\n", this, ret);
11267     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11268 }
11269
11270 static inline basic_ios_wchar* basic_stringstream_wchar_to_basic_ios(basic_stringstream_wchar *ptr)
11271 {
11272     return (basic_ios_wchar*)((char*)ptr+basic_stringstream_wchar_vbtable1[1]);
11273 }
11274
11275 static inline basic_stringstream_wchar* basic_stringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11276 {
11277     return (basic_stringstream_wchar*)((char*)ptr-basic_stringstream_wchar_vbtable1[1]);
11278 }
11279
11280 /* ??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 */
11281 /* ??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 */
11282 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_str(basic_stringstream_wchar *this,
11283         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11284 {
11285     basic_ios_wchar *basic_ios;
11286
11287     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11288
11289     if(virt_init) {
11290         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11291         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11292         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11293         basic_ios_wchar_ctor(basic_ios);
11294     }else {
11295         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11296     }
11297
11298     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode);
11299     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11300     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11301     return this;
11302 }
11303
11304 /* ??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 */
11305 /* ??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 */
11306 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_str, 16)
11307 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_str(basic_stringstream_wchar *this,
11308         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11309 {
11310     basic_stringstream_wchar_ctor_str(this, str, mode, virt_init);
11311     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11312     return this;
11313 }
11314
11315 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11316 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11317 static basic_stringstream_wchar* basic_stringstream_wchar_ctor_mode(
11318         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11319 {
11320     basic_ios_wchar *basic_ios;
11321
11322     TRACE("(%p %d %d)\n", this, mode, virt_init);
11323
11324     if(virt_init) {
11325         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11326         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11327         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11328         basic_ios_wchar_ctor(basic_ios);
11329     }else {
11330         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11331     }
11332
11333     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode);
11334     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
11335     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
11336     return this;
11337 }
11338
11339 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11340 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11341 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_mode, 12)
11342 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_mode(
11343         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
11344 {
11345     basic_stringstream_wchar_ctor_mode(this, mode, virt_init);
11346     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
11347     return this;
11348 }
11349
11350 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11351 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11352 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor, 8)
11353 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor(
11354         basic_stringstream_wchar *this, MSVCP_bool virt_init)
11355 {
11356     return basic_stringstream_short_ctor_mode(
11357             this, OPENMODE_out|OPENMODE_in, virt_init);
11358 }
11359
11360 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11361 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11362 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11363 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11364 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_dtor, 4)
11365 void __thiscall basic_stringstream_wchar_dtor(basic_ios_wchar *base)
11366 {
11367     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11368
11369     TRACE("(%p)\n", this);
11370
11371     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
11372     basic_stringbuf_wchar_dtor(&this->strbuf);
11373 }
11374
11375 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11376 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11377 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11378 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11379 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vbase_dtor, 4)
11380 void __thiscall basic_stringstream_wchar_vbase_dtor(basic_stringstream_wchar *this)
11381 {
11382     TRACE("(%p)\n", this);
11383
11384     basic_stringstream_wchar_dtor(basic_stringstream_wchar_to_basic_ios(this));
11385     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
11386 }
11387
11388 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vector_dtor, 8)
11389 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11390 {
11391     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
11392
11393     TRACE("(%p %x)\n", this, flags);
11394
11395     if(flags & 2) {
11396         /* we have an array, with the number of elements stored before the first object */
11397         INT_PTR i, *ptr = (INT_PTR *)this-1;
11398
11399         for(i=*ptr-1; i>=0; i--)
11400             basic_stringstream_wchar_vbase_dtor(this+i);
11401         MSVCRT_operator_delete(ptr);
11402     } else {
11403         basic_stringstream_wchar_vbase_dtor(this);
11404         if(flags & 1)
11405             MSVCRT_operator_delete(this);
11406     }
11407
11408     return this;
11409 }
11410
11411 /* ?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 */
11412 /* ?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 */
11413 /* ?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 */
11414 /* ?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 */
11415 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_rdbuf, 4)
11416 basic_stringbuf_wchar* __thiscall basic_stringstream_wchar_rdbuf(const basic_stringstream_wchar *this)
11417 {
11418     TRACE("(%p)\n", this);
11419     return (basic_stringbuf_wchar*)&this->strbuf;
11420 }
11421
11422 /* ?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 */
11423 /* ?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 */
11424 /* ?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 */
11425 /* ?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 */
11426 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_set, 8)
11427 void __thiscall basic_stringstream_wchar_str_set(basic_stringstream_wchar *this, const basic_string_wchar *str)
11428 {
11429     TRACE("(%p %p)\n", this, str);
11430     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11431 }
11432
11433 /* ?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 */
11434 /* ?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 */
11435 /* ?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 */
11436 /* ?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 */
11437 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_get, 8)
11438 basic_string_wchar* __thiscall basic_stringstream_wchar_str_get(const basic_stringstream_wchar *this, basic_string_wchar *ret)
11439 {
11440     TRACE("(%p %p)\n", this, ret);
11441     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11442 }
11443
11444 /* ?_Init@strstreambuf@std@@IAEXHPAD0H@Z */
11445 /* ?_Init@strstreambuf@std@@IEAAX_JPEAD1H@Z */
11446 DEFINE_THISCALL_WRAPPER(strstreambuf__Init, 20)
11447 void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g, char *p, int mode)
11448 {
11449     TRACE("(%p %ld %p %p %d)\n", this, len, g, p, mode);
11450
11451     this->minsize = 32;
11452     this->endsave = NULL;
11453     this->strmode = mode;
11454     this->palloc = NULL;
11455     this->pfree = NULL;
11456
11457     if(!g) {
11458         this->strmode |= STRSTATE_Dynamic;
11459         if(len > this->minsize)
11460             this->minsize = len;
11461         this->seekhigh = NULL;
11462         return;
11463     }
11464
11465     if(len < 0)
11466         len = INT_MAX;
11467     else if(!len)
11468         len = strlen(g);
11469
11470     this->seekhigh = g+len;
11471     basic_streambuf_char_setg(&this->base, g, g, p ? p : this->seekhigh);
11472     if(p)
11473         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
11474 }
11475
11476 /* ??0strstreambuf@std@@QAE@PACH0@Z */
11477 /* ??0strstreambuf@std@@QEAA@PEAC_J0@Z */
11478 /* ??0strstreambuf@std@@QAE@PADH0@Z */
11479 /* ??0strstreambuf@std@@QEAA@PEAD_J0@Z */
11480 /* ??0strstreambuf@std@@QAE@PAEH0@Z */
11481 /* ??0strstreambuf@std@@QEAA@PEAE_J0@Z */
11482 static strstreambuf* strstreambuf_ctor_get_put(strstreambuf *this, char *g, streamsize len, char *p)
11483 {
11484     TRACE("(%p %p %ld %p)\n", this, g, len, p);
11485
11486     basic_streambuf_char_ctor(&this->base);
11487     this->base.vtable = &MSVCP_strstreambuf_vtable;
11488
11489     strstreambuf__Init(this, len, g, p, 0);
11490     return this;
11491 }
11492
11493 /* ?_Tidy@strstreambuf@std@@IAEXXZ */
11494 /* ?_Tidy@strstreambuf@std@@IEAAXXZ */
11495 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
11496 void __thiscall strstreambuf__Tidy(strstreambuf *this)
11497 {
11498     TRACE("(%p)\n", this);
11499
11500     if((this->strmode & STRSTATE_Allocated) && !(this->strmode & STRSTATE_Frozen)) {
11501         if(this->pfree)
11502             this->pfree(basic_streambuf_char_eback(&this->base));
11503         else
11504             MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
11505     }
11506
11507     this->endsave = NULL;
11508     this->seekhigh = NULL;
11509     this->strmode &= ~(STRSTATE_Allocated | STRSTATE_Frozen);
11510     basic_streambuf_char_setg(&this->base, NULL, NULL, NULL);
11511     basic_streambuf_char_setp(&this->base, NULL, NULL);
11512 }
11513
11514 /* ??1strstreambuf@std@@UAE@XZ */
11515 /* ??1strstreambuf@std@@UEAA@XZ */
11516 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor, 4)
11517 void __thiscall strstreambuf_dtor(strstreambuf *this)
11518 {
11519     TRACE("(%p)\n", this);
11520
11521     strstreambuf__Tidy(this);
11522     basic_streambuf_char_dtor(&this->base);
11523 }
11524
11525 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor, 8)
11526 strstreambuf* __thiscall strstreambuf_vector_dtor(strstreambuf *this, unsigned int flags)
11527 {
11528     TRACE("(%p %x)\n", this, flags);
11529     if(flags & 2) {
11530         /* we have an array, with the number of elements stored before the first object */
11531         INT_PTR i, *ptr = (INT_PTR *)this-1;
11532
11533         for(i=*ptr-1; i>=0; i--)
11534             strstreambuf_dtor(this+i);
11535         MSVCRT_operator_delete(ptr);
11536     } else {
11537         strstreambuf_dtor(this);
11538         if(flags & 1)
11539             MSVCRT_operator_delete(this);
11540     }
11541
11542     return this;
11543 }
11544
11545 /* ?freeze@strstreambuf@std@@QAEX_N@Z */
11546 /* ?freeze@strstreambuf@std@@QEAAX_N@Z */
11547 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze, 8)
11548 void __thiscall strstreambuf_freeze(strstreambuf *this, MSVCP_bool freeze)
11549 {
11550     TRACE("(%p %d)\n", this, freeze);
11551
11552     if(!freeze == !(this->strmode *STRSTATE_Frozen))
11553         return;
11554
11555     if(freeze) {
11556         this->strmode |= STRSTATE_Frozen;
11557         this->endsave = basic_streambuf_char_epptr(&this->base);
11558         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11559                 basic_streambuf_char_pptr(&this->base), basic_streambuf_char_eback(&this->base));
11560     }else {
11561         this->strmode &= ~STRSTATE_Frozen;
11562         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
11563                 basic_streambuf_char_pptr(&this->base), this->endsave);
11564     }
11565 }
11566
11567 /* ?overflow@strstreambuf@std@@MAEHH@Z */
11568 /* ?overflow@strstreambuf@std@@MEAAHH@Z */
11569 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow, 8)
11570 int __thiscall strstreambuf_overflow(strstreambuf *this, int c)
11571 {
11572     MSVCP_size_t old_size, size;
11573     char *ptr, *buf;
11574
11575     TRACE("(%p %d)\n", this, c);
11576
11577     if(c == EOF)
11578         return !EOF;
11579
11580     if(this->strmode & STRSTATE_Frozen)
11581         return EOF;
11582
11583     ptr = basic_streambuf_char_pptr(&this->base);
11584     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
11585         return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11586
11587     if(!(this->strmode & STRSTATE_Dynamic) || (this->strmode & STRSTATE_Constant))
11588         return EOF;
11589
11590     ptr = basic_streambuf_char_eback(&this->base);
11591     old_size = ptr ? basic_streambuf_char_epptr(&this->base) - ptr : 0;
11592
11593     size = old_size + old_size/2;
11594     if(size < this->minsize)
11595         size = this->minsize;
11596
11597     if(this->palloc)
11598         buf = this->palloc(size);
11599     else
11600         buf = MSVCRT_operator_new(size);
11601     if(!buf)
11602         return EOF;
11603
11604     memcpy(buf, ptr, old_size);
11605     if(this->strmode & STRSTATE_Allocated) {
11606         if(this->pfree)
11607             this->pfree(ptr);
11608         else
11609             MSVCRT_operator_delete(ptr);
11610     }
11611
11612     this->strmode |= STRSTATE_Allocated;
11613     if(!old_size) {
11614         this->seekhigh = buf;
11615         basic_streambuf_char_setp(&this->base, buf, buf+size);
11616         basic_streambuf_char_setg(&this->base, buf, buf, buf);
11617     }else {
11618         this->seekhigh = this->seekhigh-ptr+buf;
11619         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base)-ptr+buf,
11620                 basic_streambuf_char_pptr(&this->base)-ptr+buf, buf+size);
11621         basic_streambuf_char_setg(&this->base, buf, basic_streambuf_char_gptr(&this->base)-ptr+buf,
11622                 basic_streambuf_char_pptr(&this->base));
11623     }
11624
11625     return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
11626 }
11627
11628 /* ?pbackfail@strstreambuf@std@@MAEHH@Z */
11629 /* ?pbackfail@strstreambuf@std@@MEAAHH@Z */
11630 DEFINE_THISCALL_WRAPPER(strstreambuf_pbackfail, 8)
11631 int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c)
11632 {
11633     char *ptr = basic_streambuf_char_gptr(&this->base);
11634
11635     TRACE("(%p %d)\n", this, c);
11636
11637     if(ptr<=basic_streambuf_char_eback(&this->base)
11638             || ((this->strmode & STRSTATE_Constant) && c!=ptr[-1]))
11639         return EOF;
11640
11641     basic_streambuf_char_gbump(&this->base, -1);
11642     if(c == EOF)
11643         return !EOF;
11644     if(this->strmode & STRSTATE_Constant)
11645         return (unsigned char)c;
11646
11647     return (unsigned char)(ptr[0] = c);
11648 }
11649
11650 /* ?seekoff@strstreambuf@std@@MAE?AV?$fpos@H@2@JW4seekdir@ios_base@2@H@Z */
11651 /* ?seekoff@strstreambuf@std@@MEAA?AV?$fpos@H@2@_JW4seekdir@ios_base@2@H@Z */
11652 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20)
11653 fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode)
11654 {
11655     char *eback = basic_streambuf_char_eback(&this->base);
11656     char *pptr = basic_streambuf_char_pptr(&this->base);
11657     char *gptr = basic_streambuf_char_gptr(&this->base);
11658
11659     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
11660
11661     ret->off = 0;
11662     ret->state = 0;
11663
11664     if(pptr > this->seekhigh)
11665         this->seekhigh = pptr;
11666
11667     if((mode & OPENMODE_in) && gptr) {
11668         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
11669             off += gptr-eback;
11670         else if(way == SEEKDIR_end)
11671             off += this->seekhigh-eback;
11672         else if(way != SEEKDIR_beg)
11673             off = -1;
11674
11675         if(off<0 || off>this->seekhigh-eback) {
11676             off = -1;
11677         }else {
11678             basic_streambuf_char_gbump(&this->base, eback-gptr+off);
11679             if((mode & OPENMODE_out) && pptr) {
11680                 basic_streambuf_char_setp_next(&this->base, eback,
11681                         gptr, basic_streambuf_char_epptr(&this->base));
11682             }
11683         }
11684     }else if((mode & OPENMODE_out) && pptr) {
11685         if(way == SEEKDIR_cur)
11686             off += pptr-eback;
11687         else if(way == SEEKDIR_end)
11688             off += this->seekhigh-eback;
11689         else if(way != SEEKDIR_beg)
11690             off = -1;
11691
11692          if(off<0 || off>this->seekhigh-eback)
11693              off = -1;
11694          else
11695              basic_streambuf_char_pbump(&this->base, eback-pptr+off);
11696     }else {
11697         off = -1;
11698     }
11699
11700     ret->pos = off;
11701     return ret;
11702 }
11703
11704 /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */
11705 /* ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
11706 DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36)
11707 fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode)
11708 {
11709     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
11710
11711     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
11712         *ret = pos;
11713         return ret;
11714     }
11715
11716     return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
11717 }
11718
11719 /* ?underflow@strstreambuf@std@@MAEHXZ */
11720 /* ?underflow@strstreambuf@std@@MEAAHXZ */
11721 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow, 4)
11722 int __thiscall strstreambuf_underflow(strstreambuf *this)
11723 {
11724     char *gptr = basic_streambuf_char_gptr(&this->base);
11725     char *pptr;
11726
11727     TRACE("(%p)\n", this);
11728
11729     if(!gptr)
11730         return EOF;
11731
11732     if(gptr < basic_streambuf_char_egptr(&this->base))
11733         return (unsigned char)(*gptr);
11734
11735     pptr = basic_streambuf_char_gptr(&this->base);
11736     if(pptr > this->seekhigh)
11737         this->seekhigh = pptr;
11738
11739     if(this->seekhigh <= gptr)
11740         return EOF;
11741
11742     basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base),
11743             gptr, this->seekhigh);
11744     return (unsigned char)(*gptr);
11745 }
11746
11747 static inline basic_ios_char* ostrstream_to_basic_ios(ostrstream *ptr)
11748 {
11749     return (basic_ios_char*)((char*)ptr+ostrstream_vbtable[1]);
11750 }
11751
11752 static inline ostrstream* ostrstream_from_basic_ios(basic_ios_char *ptr)
11753 {
11754     return (ostrstream*)((char*)ptr-ostrstream_vbtable[1]);
11755 }
11756
11757 /* ??0ostrstream@std@@QAE@PADHH@Z */
11758 DEFINE_THISCALL_WRAPPER(ostrstream_ctor, 20)
11759 ostrstream* __thiscall ostrstream_ctor(ostrstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
11760 {
11761     basic_ios_char *basic_ios;
11762
11763     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
11764
11765     if(virt_init) {
11766         this->base.vbtable = ostrstream_vbtable;
11767         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11768         basic_ios_char_ctor(basic_ios);
11769     }else {
11770         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11771     }
11772
11773     strstreambuf_ctor_get_put(&this->buf, buf, size,
11774             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
11775     basic_ostream_char_ctor(&this->base, &this->buf.base, FALSE, TRUE, FALSE);
11776     basic_ios->base.vtable = &MSVCP_ostrstream_vtable;
11777     return this;
11778 }
11779
11780 /* ??1ostrstream@std@@UAE@XZ */
11781 /* ??1ostrstream@std@@UEAA@XZ */
11782 DEFINE_THISCALL_WRAPPER(ostrstream_dtor, 4)
11783 void __thiscall ostrstream_dtor(basic_ios_char *base)
11784 {
11785     ostrstream *this = ostrstream_from_basic_ios(base);
11786
11787     TRACE("(%p)\n", this);
11788
11789     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
11790     strstreambuf_dtor(&this->buf);
11791 }
11792
11793 static void ostrstream_vbase_dtor(ostrstream *this)
11794 {
11795     TRACE("(%p)\n", this);
11796
11797     ostrstream_dtor(ostrstream_to_basic_ios(this));
11798     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
11799 }
11800
11801 DEFINE_THISCALL_WRAPPER(ostrstream_vector_dtor, 8)
11802 ostrstream* __thiscall ostrstream_vector_dtor(basic_ios_char *base, unsigned int flags)
11803 {
11804     ostrstream *this = ostrstream_from_basic_ios(base);
11805
11806     TRACE("(%p %x)\n", this, flags);
11807
11808     if(flags & 2) {
11809         /* we have an array, with the number of elements stored before the first object */
11810         INT_PTR i, *ptr = (INT_PTR *)this-1;
11811
11812         for(i=*ptr-1; i>=0; i--)
11813             ostrstream_vbase_dtor(this+i);
11814         MSVCRT_operator_delete(ptr);
11815     } else {
11816         ostrstream_vbase_dtor(this);
11817         if(flags & 1)
11818             MSVCRT_operator_delete(this);
11819     }
11820
11821     return this;
11822 }
11823
11824 static inline istrstream* istrstream_from_basic_ios(basic_ios_char *ptr)
11825 {
11826     return (istrstream*)((char*)ptr-istrstream_vbtable[1]);
11827 }
11828
11829 /* ??1istrstream@std@@UAE@XZ */
11830 /* ??1istrstream@std@@UEAA@XZ */
11831 DEFINE_THISCALL_WRAPPER(istrstream_dtor, 4)
11832 void __thiscall istrstream_dtor(basic_ios_char *base)
11833 {
11834     istrstream *this = istrstream_from_basic_ios(base);
11835
11836     TRACE("(%p)\n", this);
11837
11838     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11839     strstreambuf_dtor(&this->buf);
11840 }
11841
11842 static inline basic_ios_char* strstream_to_basic_ios(strstream *ptr)
11843 {
11844     return (basic_ios_char*)((char*)ptr+strstream_vbtable1[1]);
11845 }
11846
11847 static inline strstream* strstream_from_basic_ios(basic_ios_char *ptr)
11848 {
11849     return (strstream*)((char*)ptr-strstream_vbtable1[1]);
11850 }
11851
11852 /* ??0strstream@std@@QAE@PADHH@Z */
11853 /* ??0strstream@std@@QEAA@PEAD_JH@Z */
11854 DEFINE_THISCALL_WRAPPER(strstream_ctor, 20)
11855 strstream* __thiscall strstream_ctor(strstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
11856 {
11857     basic_ios_char *basic_ios;
11858
11859     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
11860
11861     if(virt_init) {
11862         this->base.base1.vbtable = strstream_vbtable1;
11863         this->base.base2.vbtable = strstream_vbtable2;
11864         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11865         basic_ios_char_ctor(basic_ios);
11866     }else {
11867         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11868     }
11869
11870     strstreambuf_ctor_get_put(&this->buf, buf, size,
11871             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
11872     basic_iostream_char_ctor(&this->base, &this->buf.base, FALSE);
11873     basic_ios->base.vtable = &MSVCP_strstream_vtable;
11874     return this;
11875 }
11876
11877 /* ??1strstream@std@@UAE@XZ */
11878 /* ??1strstream@std@@UEAA@XZ */
11879 DEFINE_THISCALL_WRAPPER(strstream_dtor, 4)
11880 void __thiscall strstream_dtor(basic_ios_char *base)
11881 {
11882     strstream *this = strstream_from_basic_ios(base);
11883
11884     TRACE("(%p)\n", this);
11885
11886     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11887     strstreambuf_dtor(&this->buf);
11888 }
11889
11890 static void strstream_vbase_dtor(strstream *this)
11891 {
11892     TRACE("(%p)\n", this);
11893
11894     strstream_dtor(strstream_to_basic_ios(this));
11895     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11896 }
11897
11898 DEFINE_THISCALL_WRAPPER(strstream_vector_dtor, 8)
11899 strstream* __thiscall strstream_vector_dtor(basic_ios_char *base, unsigned int flags)
11900 {
11901     strstream *this = strstream_from_basic_ios(base);
11902
11903     TRACE("(%p %x)\n", this, flags);
11904
11905     if(flags & 2) {
11906         /* we have an array, with the number of elements stored before the first object */
11907         INT_PTR i, *ptr = (INT_PTR *)this-1;
11908
11909         for(i=*ptr-1; i>=0; i--)
11910             strstream_vbase_dtor(this+i);
11911         MSVCRT_operator_delete(ptr);
11912     } else {
11913         strstream_vbase_dtor(this);
11914         if(flags & 1)
11915             MSVCRT_operator_delete(this);
11916     }
11917
11918     return this;
11919 }
11920
11921 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
11922 {
11923     ios_base_precision_set(base, prec);
11924 }
11925
11926 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
11927 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
11928 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
11929 {
11930     TRACE("(%p %ld)\n", ret, prec);
11931
11932     ret->pfunc = setprecision_func;
11933     ret->arg = prec;
11934     return ret;
11935 }
11936
11937 static void __cdecl setw_func(ios_base *base, streamsize width)
11938 {
11939     ios_base_width_set(base, width);
11940 }
11941
11942 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
11943 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
11944 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
11945 {
11946     TRACE("(%p %ld)\n", ret, width);
11947
11948     ret->pfunc = setw_func;
11949     ret->arg = width;
11950     return ret;
11951 }
11952
11953 static void __cdecl resetioflags_func(ios_base *base, int mask)
11954 {
11955     ios_base_setf_mask(base, 0, mask);
11956 }
11957
11958 /* ?resetiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
11959 manip_int* __cdecl resetiosflags(manip_int *ret, int mask)
11960 {
11961     TRACE("(%p %d)\n", ret, mask);
11962
11963     ret->pfunc = resetioflags_func;
11964     ret->arg = mask;
11965     return ret;
11966 }
11967
11968 static void __cdecl setiosflags_func(ios_base *base, int mask)
11969 {
11970     ios_base_setf_mask(base, FMTFLAG_mask, mask);
11971 }
11972
11973 /* ?setiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
11974 manip_int* __cdecl setiosflags(manip_int *ret, int mask)
11975 {
11976     TRACE("(%p %d)\n", ret, mask);
11977
11978     ret->pfunc = setiosflags_func;
11979     ret->arg = mask;
11980     return ret;
11981 }
11982
11983 static void __cdecl setbase_func(ios_base *base, int set_base)
11984 {
11985     if(set_base == 10)
11986         set_base = FMTFLAG_dec;
11987     else if(set_base == 8)
11988         set_base = FMTFLAG_oct;
11989     else if(set_base == 16)
11990         set_base = FMTFLAG_hex;
11991     else
11992         set_base = 0;
11993
11994     ios_base_setf_mask(base, set_base, FMTFLAG_basefield);
11995 }
11996
11997 /* ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z */
11998 manip_int* __cdecl setbase(manip_int *ret, int base)
11999 {
12000     TRACE("(%p %d)\n", ret, base);
12001
12002     ret->pfunc = setbase_func;
12003     ret->arg = base;
12004     return ret;
12005 }
12006
12007 static basic_filebuf_char filebuf_char_stdin;
12008 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
12009 struct {
12010     basic_istream_char obj;
12011     basic_ios_char vbase;
12012 } cin = { { 0 } };
12013 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
12014 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
12015 basic_istream_char *_Ptr_cin = &cin.obj;
12016
12017 static basic_filebuf_wchar filebuf_short_stdin;
12018 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
12019 struct {
12020     basic_istream_wchar obj;
12021     basic_ios_wchar vbase;
12022 } ucin = { { 0 } };
12023 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
12024 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
12025 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
12026
12027 static basic_filebuf_wchar filebuf_wchar_stdin;
12028 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12029 struct {
12030     basic_istream_wchar obj;
12031     basic_ios_wchar vbase;
12032 } wcin = { { 0 } };
12033 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12034 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
12035 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
12036
12037 static basic_filebuf_char filebuf_char_stdout;
12038 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12039 struct {
12040     basic_ostream_char obj;
12041     basic_ios_char vbase;
12042 } cout = { { 0 } };
12043 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12044 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12045 basic_ostream_char *_Ptr_cout = &cout.obj;
12046
12047 static basic_filebuf_wchar filebuf_short_stdout;
12048 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12049 struct {
12050     basic_ostream_wchar obj;
12051     basic_ios_wchar vbase;
12052 } ucout = { { 0 } };
12053 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12054 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12055 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
12056
12057 static basic_filebuf_wchar filebuf_wchar_stdout;
12058 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12059 struct {
12060     basic_ostream_wchar obj;
12061     basic_ios_wchar vbase;
12062 } wcout = { { 0 } };
12063 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12064 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12065 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
12066
12067 static basic_filebuf_char filebuf_char_stderr;
12068 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12069 struct {
12070     basic_ostream_char obj;
12071     basic_ios_char vbase;
12072 } cerr = { { 0 } };
12073 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12074 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12075 basic_ostream_char *_Ptr_cerr = &cerr.obj;
12076
12077 static basic_filebuf_wchar filebuf_short_stderr;
12078 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12079 struct {
12080     basic_ostream_wchar obj;
12081     basic_ios_wchar vbase;
12082 } ucerr = { { 0 } };
12083 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12084 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12085 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
12086
12087 static basic_filebuf_wchar filebuf_wchar_stderr;
12088 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12089 struct {
12090     basic_ostream_wchar obj;
12091     basic_ios_wchar vbase;
12092 } wcerr = { { 0 } };
12093 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12094 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12095 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
12096
12097 static basic_filebuf_char filebuf_char_log;
12098 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12099 struct {
12100     basic_ostream_char obj;
12101     basic_ios_char vbase;
12102 } clog = { { 0 } };
12103 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12104 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12105 basic_ostream_char *_Ptr_clog = &clog.obj;
12106
12107 static basic_filebuf_wchar filebuf_short_log;
12108 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12109 struct {
12110     basic_ostream_wchar obj;
12111     basic_ios_wchar vbase;
12112 } uclog = { { 0 } };
12113 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12114 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12115 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
12116
12117 static basic_filebuf_wchar filebuf_wchar_log;
12118 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12119 struct {
12120     basic_ostream_wchar obj;
12121     basic_ios_wchar vbase;
12122 } wclog = { { 0 } };
12123 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12124 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12125 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
12126
12127 /* ?_Init_cnt@Init@ios_base@std@@0HA */
12128 int ios_base_Init__Init_cnt = -1;
12129
12130 /* ?_Init_ctor@Init@ios_base@std@@CAXPAV123@@Z */
12131 /* ?_Init_ctor@Init@ios_base@std@@CAXPEAV123@@Z */
12132 static void ios_base_Init__Init_ctor(void *this)
12133 {
12134     TRACE("(%p)\n", this);
12135
12136     if(ios_base_Init__Init_cnt < 0)
12137         ios_base_Init__Init_cnt = 1;
12138     else
12139         ios_base_Init__Init_cnt++;
12140 }
12141
12142 /* ??0Init@ios_base@std@@QAE@XZ */
12143 /* ??0Init@ios_base@std@@QEAA@XZ */
12144 DEFINE_THISCALL_WRAPPER(ios_base_Init_ctor, 4)
12145 void* __thiscall ios_base_Init_ctor(void *this)
12146 {
12147     ios_base_Init__Init_ctor(this);
12148     return this;
12149 }
12150
12151 /* ?_Init_dtor@Init@ios_base@std@@CAXPAV123@@Z */
12152 /* ?_Init_dtor@Init@ios_base@std@@CAXPEAV123@@Z */
12153 static void ios_base_Init__Init_dtor(void *this)
12154 {
12155     TRACE("(%p)\n", this);
12156
12157     ios_base_Init__Init_cnt--;
12158     if(!ios_base_Init__Init_cnt) {
12159         basic_ostream_char_flush(&cout.obj);
12160         basic_ostream_char_flush(&cerr.obj);
12161         basic_ostream_char_flush(&clog.obj);
12162     }
12163 }
12164
12165 /* ??1Init@ios_base@std@@QAE@XZ */
12166 /* ??1Init@ios_base@std@@QEAA@XZ */
12167 DEFINE_THISCALL_WRAPPER(ios_base_Init_dtor, 4)
12168 void __thiscall ios_base_Init_dtor(void *this)
12169 {
12170     ios_base_Init__Init_dtor(this);
12171 }
12172
12173 /* ??4Init@ios_base@std@@QAEAAV012@ABV012@@Z */
12174 /* ??4Init@ios_base@std@@QEAAAEAV012@AEBV012@@Z */
12175 DEFINE_THISCALL_WRAPPER(ios_base_Init_op_assign, 8)
12176 void* __thiscall ios_base_Init_op_assign(void *this, void *rhs)
12177 {
12178     TRACE("(%p %p)\n", this, rhs);
12179     return this;
12180 }
12181
12182 /* ?_Init_cnt@_Winit@std@@0HA */
12183 int _Winit__Init_cnt = -1;
12184
12185 /* ??0_Winit@std@@QAE@XZ */
12186 /* ??0_Winit@std@@QEAA@XZ */
12187 DEFINE_THISCALL_WRAPPER(_Winit_ctor, 4)
12188 void* __thiscall _Winit_ctor(void *this)
12189 {
12190     TRACE("(%p)\n", this);
12191
12192     if(_Winit__Init_cnt < 0)
12193         _Winit__Init_cnt = 1;
12194     else
12195         _Winit__Init_cnt++;
12196
12197     return this;
12198 }
12199
12200 /* ??1_Winit@std@@QAE@XZ */
12201 /* ??1_Winit@std@@QAE@XZ */
12202 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)
12203 void __thiscall _Winit_dtor(void *this)
12204 {
12205     TRACE("(%p)\n", this);
12206
12207     _Winit__Init_cnt--;
12208     if(!_Winit__Init_cnt) {
12209         basic_ostream_wchar_flush(&wcout.obj);
12210         basic_ostream_wchar_flush(&wcerr.obj);
12211         basic_ostream_wchar_flush(&wclog.obj);
12212     }
12213 }
12214
12215 /* ??4_Winit@std@@QAEAAV01@ABV01@@Z */
12216 /* ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z */
12217 DEFINE_THISCALL_WRAPPER(_Winit_op_assign, 8)
12218 void* __thiscall _Winit_op_assign(void *this, void *rhs)
12219 {
12220     TRACE("(%p %p)\n", this, rhs);
12221     return this;
12222 }
12223
12224 void init_io(void *base)
12225 {
12226 #ifdef __x86_64__
12227     init_iosb_rtti(base);
12228     init_ios_base_rtti(base);
12229     init_basic_ios_char_rtti(base);
12230     init_basic_ios_wchar_rtti(base);
12231     init_basic_ios_short_rtti(base);
12232     init_basic_streambuf_char_rtti(base);
12233     init_basic_streambuf_wchar_rtti(base);
12234     init_basic_streambuf_short_rtti(base);
12235     init_basic_filebuf_char_rtti(base);
12236     init_basic_filebuf_wchar_rtti(base);
12237     init_basic_filebuf_short_rtti(base);
12238     init_basic_stringbuf_char_rtti(base);
12239     init_basic_stringbuf_wchar_rtti(base);
12240     init_basic_stringbuf_short_rtti(base);
12241     init_basic_ostream_char_rtti(base);
12242     init_basic_ostream_wchar_rtti(base);
12243     init_basic_ostream_short_rtti(base);
12244     init_basic_istream_char_rtti(base);
12245     init_basic_istream_wchar_rtti(base);
12246     init_basic_istream_short_rtti(base);
12247     init_basic_iostream_char_rtti(base);
12248     init_basic_iostream_wchar_rtti(base);
12249     init_basic_iostream_short_rtti(base);
12250     init_basic_ofstream_char_rtti(base);
12251     init_basic_ofstream_wchar_rtti(base);
12252     init_basic_ofstream_short_rtti(base);
12253     init_basic_ifstream_char_rtti(base);
12254     init_basic_ifstream_wchar_rtti(base);
12255     init_basic_ifstream_short_rtti(base);
12256     init_basic_fstream_char_rtti(base);
12257     init_basic_fstream_wchar_rtti(base);
12258     init_basic_fstream_short_rtti(base);
12259     init_basic_ostringstream_char_rtti(base);
12260     init_basic_ostringstream_wchar_rtti(base);
12261     init_basic_ostringstream_short_rtti(base);
12262     init_basic_istringstream_char_rtti(base);
12263     init_basic_istringstream_wchar_rtti(base);
12264     init_basic_istringstream_short_rtti(base);
12265     init_basic_stringstream_char_rtti(base);
12266     init_basic_stringstream_wchar_rtti(base);
12267     init_basic_stringstream_short_rtti(base);
12268     init_strstreambuf_rtti(base);
12269     init_strstream_rtti(base);
12270     init_ostrstream_rtti(base);
12271 #endif
12272
12273     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
12274     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
12275
12276     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
12277     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
12278
12279     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
12280     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
12281
12282     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
12283     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE, TRUE);
12284
12285     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
12286     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE, TRUE);
12287
12288     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
12289     basic_ostream_short_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE, TRUE);
12290
12291     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
12292     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE, TRUE);
12293
12294     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
12295     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE, TRUE);
12296
12297     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
12298     basic_ostream_short_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE, TRUE);
12299
12300     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
12301     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE, TRUE);
12302
12303     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
12304     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE, TRUE);
12305
12306     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
12307     basic_ostream_short_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE, TRUE);
12308 }
12309
12310 void free_io(void)
12311 {
12312     basic_istream_char_vbase_dtor(&cin.obj);
12313     basic_filebuf_char_dtor(&filebuf_char_stdin);
12314
12315     basic_istream_wchar_vbase_dtor(&ucin.obj);
12316     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
12317
12318     basic_istream_wchar_vbase_dtor(&wcin.obj);
12319     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
12320
12321     basic_ostream_char_vbase_dtor(&cout.obj);
12322     basic_filebuf_char_dtor(&filebuf_char_stdout);
12323
12324     basic_ostream_wchar_vbase_dtor(&ucout.obj);
12325     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
12326
12327     basic_ostream_wchar_vbase_dtor(&wcout.obj);
12328     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
12329
12330     basic_ostream_char_vbase_dtor(&cerr.obj);
12331     basic_filebuf_char_dtor(&filebuf_char_stderr);
12332
12333     basic_ostream_wchar_vbase_dtor(&ucerr.obj);
12334     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
12335
12336     basic_ostream_wchar_vbase_dtor(&wcerr.obj);
12337     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
12338
12339     basic_ostream_char_vbase_dtor(&clog.obj);
12340     basic_filebuf_char_dtor(&filebuf_char_log);
12341
12342     basic_ostream_wchar_vbase_dtor(&uclog.obj);
12343     basic_filebuf_wchar_dtor(&filebuf_short_log);
12344
12345     basic_ostream_wchar_vbase_dtor(&wclog.obj);
12346     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
12347 }