d3d10core: Implement d3d10_device_GSSetSamplers().
[wine] / dlls / msvcp71 / ios.c
1 /*
2  * Copyright 2011 Piotr Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include <limits.h>
24 #include <share.h>
25
26 #include "msvcp.h"
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
31
32 /* ?_Index@ios_base@std@@0HA */
33 int ios_base_Index = 0;
34 /* ?_Sync@ios_base@std@@0_NA */
35 MSVCP_bool ios_base_Sync = FALSE;
36
37 typedef struct {
38     streamoff off;
39     __int64 DECLSPEC_ALIGN(8) pos;
40     int state;
41 } fpos_int;
42
43 static inline const char* debugstr_fpos_int(fpos_int *fpos)
44 {
45     return wine_dbg_sprintf("fpos(%ld %s %d)", fpos->off, wine_dbgstr_longlong(fpos->pos), fpos->state);
46 }
47
48 typedef struct {
49     void (__cdecl *pfunc)(ios_base*, streamsize);
50     streamsize arg;
51 } manip_streamsize;
52
53 typedef struct {
54     void (__cdecl *pfunc)(ios_base*, int);
55     int arg;
56 } manip_int;
57
58 typedef enum {
59     INITFL_new   = 0,
60     INITFL_open  = 1,
61     INITFL_close = 2
62 } basic_filebuf__Initfl;
63
64 typedef struct {
65     basic_streambuf_char base;
66     codecvt_char *cvt;
67     char putback;
68     MSVCP_bool wrotesome;
69     int state;
70     MSVCP_bool close;
71     FILE *file;
72 } basic_filebuf_char;
73
74 typedef struct {
75     basic_streambuf_wchar base;
76     codecvt_wchar *cvt;
77     wchar_t putback;
78     MSVCP_bool wrotesome;
79     int state;
80     MSVCP_bool close;
81     FILE *file;
82 } basic_filebuf_wchar;
83
84 typedef enum {
85     STRINGBUF_allocated = 1,
86     STRINGBUF_no_write = 2,
87     STRINGBUF_no_read = 4,
88     STRINGBUF_append = 8,
89     STRINGBUF_at_end = 16
90 } basic_stringbuf_state;
91
92 typedef struct {
93     basic_streambuf_char base;
94     char *seekhigh;
95     int state;
96     char allocator; /* empty struct */
97 } basic_stringbuf_char;
98
99 typedef struct {
100     basic_streambuf_wchar base;
101     wchar_t *seekhigh;
102     int state;
103     char allocator; /* empty struct */
104 } basic_stringbuf_wchar;
105
106 typedef struct {
107     ios_base base;
108     basic_streambuf_char *strbuf;
109     struct _basic_ostream_char *stream;
110     char fillch;
111 } basic_ios_char;
112
113 typedef struct {
114     ios_base base;
115     basic_streambuf_wchar *strbuf;
116     struct _basic_ostream_wchar *stream;
117     wchar_t fillch;
118 } basic_ios_wchar;
119
120 typedef struct _basic_ostream_char {
121     const int *vbtable;
122     /* virtual inheritance
123      * basic_ios_char basic_ios;
124      */
125 } basic_ostream_char;
126
127 typedef struct _basic_ostream_wchar {
128     const int *vbtable;
129     /* virtual inheritance
130      * basic_ios_wchar basic_ios;
131      */
132 } basic_ostream_wchar;
133
134 typedef struct {
135     const int *vbtable;
136     streamsize count;
137     /* virtual inheritance
138      * basic_ios_char basic_ios;
139      */
140 } basic_istream_char;
141
142 typedef struct {
143     const int *vbtable;
144     streamsize count;
145     /* virtual inheritance
146      * basic_ios_wchar basic_ios;
147      */
148 } basic_istream_wchar;
149
150 typedef struct {
151     basic_istream_char base1;
152     basic_ostream_char base2;
153     /* virtual inheritance
154      * basic_ios_char basic_ios;
155      */
156 } basic_iostream_char;
157
158 typedef struct {
159     basic_istream_wchar base1;
160     basic_ostream_wchar base2;
161     /* virtual inheritance
162      * basic_ios_wchar basic_ios;
163      */
164 } basic_iostream_wchar;
165
166 typedef struct {
167     basic_ostream_char base;
168     basic_filebuf_char filebuf;
169     /* virtual inheritance
170      * basic_ios_char basic_ios;
171      */
172 } basic_ofstream_char;
173
174 typedef struct {
175     basic_ostream_wchar base;
176     basic_filebuf_wchar filebuf;
177     /* virtual inheritance
178      * basic_ios_wchar basic_ios;
179      */
180 } basic_ofstream_wchar;
181
182 typedef struct {
183     basic_istream_char base;
184     basic_filebuf_char filebuf;
185     /* virtual inheritance
186      * basic_ios_char basic_ios;
187      */
188 } basic_ifstream_char;
189
190 typedef struct {
191     basic_istream_wchar base;
192     basic_filebuf_wchar filebuf;
193     /* virtual inheritance
194      * basic_ios_wchar basic_ios;
195      */
196 } basic_ifstream_wchar;
197
198 typedef struct {
199     basic_iostream_char base;
200     basic_filebuf_char filebuf;
201     /* virtual inheritance
202      * basic_ios_char basic_ios;
203      */
204 } basic_fstream_char;
205
206 typedef struct {
207     basic_iostream_wchar base;
208     basic_filebuf_wchar filebuf;
209     /* virtual inheritance
210      * basic_ios_char basic_ios;
211      */
212 } basic_fstream_wchar;
213
214 typedef struct {
215     basic_ostream_char base;
216     basic_stringbuf_char strbuf;
217     /* virtual inheritance
218      * basic_ios_char basic_ios;
219      */
220 } basic_ostringstream_char;
221
222 typedef struct {
223     basic_ostream_wchar base;
224     basic_stringbuf_wchar strbuf;
225     /* virtual inheritance
226      * basic_ios_wchar basic_ios;
227      */
228 } basic_ostringstream_wchar;
229
230 typedef struct {
231     basic_istream_char base;
232     basic_stringbuf_char strbuf;
233     /* virtual inheritance
234      * basic_ios_char basic_ios;
235      */
236 } basic_istringstream_char;
237
238 typedef struct {
239     basic_istream_wchar base;
240     basic_stringbuf_wchar strbuf;
241     /* virtual inheritance
242      * basic_ios_wchar basic_ios;
243      */
244 } basic_istringstream_wchar;
245
246 typedef struct {
247     basic_iostream_char base;
248     basic_stringbuf_char strbuf;
249     /* virtual inheritance
250      * basic_ios_char basic_ios;
251      */
252 } basic_stringstream_char;
253
254 typedef struct {
255     basic_iostream_wchar base;
256     basic_stringbuf_wchar strbuf;
257     /* virtual inheritance
258      * basic_ios_wchar basic_ios;
259      */
260 } basic_stringstream_wchar;
261
262 typedef enum {
263     STRSTATE_Allocated = 1,
264     STRSTATE_Constant = 2,
265     STRSTATE_Dynamic = 4,
266     STRSTATE_Frozen = 8
267 } strstreambuf__Strstate;
268
269 typedef struct {
270     basic_streambuf_char base;
271     streamsize minsize;
272     char *endsave;
273     char *seekhigh;
274     int strmode;
275     void* (__cdecl *palloc)(MSVCP_size_t);
276     void (__cdecl *pfree)(void*);
277 } strstreambuf;
278
279 typedef struct {
280     basic_ostream_char base;
281     strstreambuf buf;
282     /* virtual inheritance
283      * basic_ios_char basic_ios;
284      */
285 } ostrstream;
286
287 typedef struct {
288     basic_istream_char base;
289     strstreambuf buf;
290     /* virtual inheritance
291      * basic_ios_char basic_ios;
292      */
293 } istrstream;
294
295 typedef struct {
296     basic_iostream_char base;
297     strstreambuf buf;
298     /* virtual inheritance
299      * basic_ios_char basic_ios;
300      */
301 } strstream;
302
303 extern const vtable_ptr MSVCP_iosb_vtable;
304
305 /* ??_7ios_base@std@@6B@ */
306 extern const vtable_ptr MSVCP_ios_base_vtable;
307
308 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
309 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
310
311 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
312 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
313
314 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
315 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
316
317 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
318 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
319
320 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
321 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
322
323 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
324 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
325
326 /* ??_7?$basic_filebuf@DU?$char_traits@D@std@@@std@@6B@ */
327 extern const vtable_ptr MSVCP_basic_filebuf_char_vtable;
328
329 /* ??_7?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@6B@ */
330 extern const vtable_ptr MSVCP_basic_filebuf_wchar_vtable;
331
332 /* ??_7?$basic_filebuf@GU?$char_traits@G@std@@@std@@6B@ */
333 extern const vtable_ptr MSVCP_basic_filebuf_short_vtable;
334
335 /* ??_7?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
336 extern const vtable_ptr MSVCP_basic_stringbuf_char_vtable;
337
338 /* ??_7?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
339 extern const vtable_ptr MSVCP_basic_stringbuf_wchar_vtable;
340
341 /* ??_7?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
342 extern const vtable_ptr MSVCP_basic_stringbuf_short_vtable;
343
344 /* ??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@ */
345 const int basic_ostream_char_vbtable[] = {0, sizeof(basic_ostream_char)};
346 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
347 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
348
349 /* ??_8?$basic_ostream@_WU?$char_traits@_W@std@@@std@@7B@ */
350 const int basic_ostream_wchar_vbtable[] = {0, sizeof(basic_ostream_wchar)};
351 /* ??_7?$basic_ostream@_WU?$char_traits@_W@std@@@std@@6B@ */
352 extern const vtable_ptr MSVCP_basic_ostream_wchar_vtable;
353
354 /* ??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@ */
355 const int basic_ostream_short_vbtable[] = {0, sizeof(basic_ostream_wchar)};
356 /* ??_7?$basic_ostream@GU?$char_traits@G@std@@@std@@6B@ */
357 extern const vtable_ptr MSVCP_basic_ostream_short_vtable;
358
359 /* ??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@ */
360 const int basic_istream_char_vbtable[] = {0, sizeof(basic_istream_char)};
361 /* ??_7?$basic_istream@DU?$char_traits@D@std@@@std@@6B@ */
362 extern const vtable_ptr MSVCP_basic_istream_char_vtable;
363
364 /* ??_8?$basic_istream@_WU?$char_traits@_W@std@@@std@@7B@ */
365 const int basic_istream_wchar_vbtable[] = {0, sizeof(basic_istream_wchar)};
366 /* ??_7?$basic_istream@_WU?$char_traits@_W@std@@@std@@6B@ */
367 extern const vtable_ptr MSVCP_basic_istream_wchar_vtable;
368
369 /* ??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@ */
370 const int basic_istream_short_vbtable[] = {0, sizeof(basic_istream_wchar)};
371 /* ??_7?$basic_istream@GU?$char_traits@G@std@@@std@@6B@ */
372 extern const vtable_ptr MSVCP_basic_istream_short_vtable;
373
374 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
375 const int basic_iostream_char_vbtable1[] = {0, sizeof(basic_iostream_char)};
376 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
377 const int basic_iostream_char_vbtable2[] = {0, sizeof(basic_iostream_char)-FIELD_OFFSET(basic_iostream_char, base2)};
378 /* ??_7?$basic_iostream@DU?$char_traits@D@std@@@std@@6B@ */
379 extern const vtable_ptr MSVCP_basic_iostream_char_vtable;
380
381 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
382 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
383 const int basic_iostream_wchar_vbtable1[] = {0, sizeof(basic_iostream_wchar)};
384 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
385 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
386 const int basic_iostream_wchar_vbtable2[] = {0, sizeof(basic_iostream_wchar)-FIELD_OFFSET(basic_iostream_wchar, base2)};
387 /* ??_7?$basic_iostream@_WU?$char_traits@_W@std@@@std@@6B@ */
388 extern const vtable_ptr MSVCP_basic_iostream_wchar_vtable;
389 /* ??_7?$basic_iostream@GU?$char_traits@G@std@@@std@@6B@ */
390 extern const vtable_ptr MSVCP_basic_iostream_short_vtable;
391
392 /* ??_8?$basic_ofstream@DU?$char_traits@D@std@@@std@@7B@ */
393 const int basic_ofstream_char_vbtable[] = {0, sizeof(basic_ofstream_char)};
394 /* ??_7?$basic_ofstream@DU?$char_traits@D@std@@@std@@6B@ */
395 extern const vtable_ptr MSVCP_basic_ofstream_char_vtable;
396
397 /* ??_8?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@7B@ */
398 const int basic_ofstream_wchar_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
399 /* ??_7?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@6B@ */
400 extern const vtable_ptr MSVCP_basic_ofstream_wchar_vtable;
401
402 /* ??_8?$basic_ofstream@GU?$char_traits@G@std@@@std@@7B@ */
403 const int basic_ofstream_short_vbtable[] = {0, sizeof(basic_ofstream_wchar)};
404 /* ??_7?$basic_ofstream@GU?$char_traits@G@std@@@std@@6B@ */
405 extern const vtable_ptr MSVCP_basic_ofstream_short_vtable;
406
407 /* ??_8?$basic_ifstream@DU?$char_traits@D@std@@@std@@7B@ */
408 const int basic_ifstream_char_vbtable[] = {0, sizeof(basic_ifstream_char)};
409 /* ??_7?$basic_ifstream@DU?$char_traits@D@std@@@std@@6B@ */
410 extern const vtable_ptr MSVCP_basic_ifstream_char_vtable;
411
412 /* ??_8?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@7B@ */
413 const int basic_ifstream_wchar_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
414 /* ??_7?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@6B@ */
415 extern const vtable_ptr MSVCP_basic_ifstream_wchar_vtable;
416
417 /* ??_8?$basic_ifstream@GU?$char_traits@G@std@@@std@@7B@ */
418 const int basic_ifstream_short_vbtable[] = {0, sizeof(basic_ifstream_wchar)};
419 /* ??_7?$basic_ifstream@GU?$char_traits@G@std@@@std@@6B@ */
420 extern const vtable_ptr MSVCP_basic_ifstream_short_vtable;
421
422 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
423 const int basic_fstream_char_vbtable1[] = {0, sizeof(basic_fstream_char)};
424 /* ??_8?$basic_fstream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
425 const int basic_fstream_char_vbtable2[] = {0, sizeof(basic_fstream_char)-FIELD_OFFSET(basic_fstream_char, base.base2)};
426 /* ??_7?$basic_fstream@DU?$char_traits@D@std@@@std@@6B@ */
427 extern const vtable_ptr MSVCP_basic_fstream_char_vtable;
428
429 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
430 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
431 const int basic_fstream_wchar_vbtable1[] = {0, sizeof(basic_fstream_wchar)};
432 /* ??_8?$basic_fstream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
433 /* ??_8?$basic_fstream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
434 const int basic_fstream_wchar_vbtable2[] = {0, sizeof(basic_fstream_wchar)-FIELD_OFFSET(basic_fstream_wchar, base.base2)};
435 /* ??_7?$basic_fstream@_WU?$char_traits@_W@std@@@std@@6B@ */
436 extern const vtable_ptr MSVCP_basic_fstream_wchar_vtable;
437 /* ??_7?$basic_fstream@GU?$char_traits@G@std@@@std@@6B@ */
438 extern const vtable_ptr MSVCP_basic_fstream_short_vtable;
439
440 /* ??_8?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
441 const int basic_ostringstream_char_vbtable[] = {0, sizeof(basic_ostringstream_char)};
442 /* ??_7?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
443 extern const vtable_ptr MSVCP_basic_ostringstream_char_vtable;
444
445 /* ??_8?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
446 const int basic_ostringstream_wchar_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
447 /* ??_7?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
448 extern const vtable_ptr MSVCP_basic_ostringstream_wchar_vtable;
449
450 /* ??_8?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
451 const int basic_ostringstream_short_vbtable[] = {0, sizeof(basic_ostringstream_wchar)};
452 /* ??_7?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
453 extern const vtable_ptr MSVCP_basic_ostringstream_short_vtable;
454
455 /* ??_8?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B@ */
456 const int basic_istringstream_char_vbtable[] = {0, sizeof(basic_istringstream_char)};
457 /* ??_7?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
458 extern const vtable_ptr MSVCP_basic_istringstream_char_vtable;
459
460 /* ??_8?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B@ */
461 const int basic_istringstream_wchar_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
462 /* ??_7?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
463 extern const vtable_ptr MSVCP_basic_istringstream_wchar_vtable;
464
465 /* ??_8?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B@ */
466 const int basic_istringstream_short_vbtable[] = {0, sizeof(basic_istringstream_wchar)};
467 /* ??_7?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
468 extern const vtable_ptr MSVCP_basic_istringstream_short_vtable;
469
470 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
471 const int basic_stringstream_char_vbtable1[] = {0, sizeof(basic_stringstream_char)};
472 /* ??_8?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
473 const int basic_stringstream_char_vbtable2[] = {0, sizeof(basic_stringstream_char)-FIELD_OFFSET(basic_stringstream_char, base.base2)};
474 /* ??_7?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@6B@ */
475 extern const vtable_ptr MSVCP_basic_stringstream_char_vtable;
476
477 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
478 const int basic_stringstream_wchar_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
479 /* ??_8?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
480 const int basic_stringstream_wchar_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
481 /* ??_7?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@6B@ */
482 extern const vtable_ptr MSVCP_basic_stringstream_wchar_vtable;
483
484 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
485 const int basic_stringstream_short_vbtable1[] = {0, sizeof(basic_stringstream_wchar)};
486 /* ??_8?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
487 const int basic_stringstream_short_vbtable2[] = {0, sizeof(basic_stringstream_wchar)-FIELD_OFFSET(basic_stringstream_wchar, base.base2)};
488 /* ??_7?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@6B@ */
489 extern const vtable_ptr MSVCP_basic_stringstream_short_vtable;
490
491 /* ??_7strstreambuf@std@@6B */
492 extern const vtable_ptr MSVCP_strstreambuf_vtable;
493
494 static const int ostrstream_vbtable[] = {0, sizeof(ostrstream)};
495 extern const vtable_ptr MSVCP_ostrstream_vtable;
496
497 static const int istrstream_vbtable[] = {0, sizeof(istrstream)};
498
499 static const int strstream_vbtable1[] = {0, sizeof(strstream)};
500 static const int strstream_vbtable2[] = {0, sizeof(strstream)-FIELD_OFFSET(strstream, base.base2)};
501 extern const vtable_ptr MSVCP_strstream_vtable;
502
503 DEFINE_RTTI_DATA0(iosb, 0, ".?AV?$_Iosb@H@std@@")
504 DEFINE_RTTI_DATA1(ios_base, 0, &iosb_rtti_base_descriptor, ".?AV?$_Iosb@H@std@@")
505 DEFINE_RTTI_DATA2(basic_ios_char, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
506         ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@")
507 DEFINE_RTTI_DATA2(basic_ios_wchar, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
508         ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@")
509 DEFINE_RTTI_DATA2(basic_ios_short, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
510         ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@")
511 DEFINE_RTTI_DATA0(basic_streambuf_char, 0,
512         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@")
513 DEFINE_RTTI_DATA0(basic_streambuf_wchar, 0,
514         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@")
515 DEFINE_RTTI_DATA0(basic_streambuf_short, 0,
516         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@")
517 DEFINE_RTTI_DATA1(basic_filebuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
518         ".?AV?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@")
519 DEFINE_RTTI_DATA1(basic_filebuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
520         ".?AV?$basic_filebuf@GU?$char_traits@G@std@@@std@@")
521 DEFINE_RTTI_DATA1(basic_filebuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
522         ".?AV?$basic_filebuf@DU?$char_traits@D@std@@@std@@")
523 DEFINE_RTTI_DATA1(basic_stringbuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
524         ".?AV?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@")
525 DEFINE_RTTI_DATA1(basic_stringbuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
526         ".?AV?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@")
527 DEFINE_RTTI_DATA1(basic_stringbuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
528         ".?AV?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@")
529 DEFINE_RTTI_DATA3(basic_ostream_char, sizeof(basic_ostream_char), &basic_ios_char_rtti_base_descriptor,
530         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
531         ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@")
532 DEFINE_RTTI_DATA3(basic_ostream_wchar, sizeof(basic_ostream_wchar), &basic_ios_wchar_rtti_base_descriptor,
533         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
534         ".?AV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@")
535 DEFINE_RTTI_DATA3(basic_ostream_short, sizeof(basic_ostream_wchar), &basic_ios_short_rtti_base_descriptor,
536         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
537         ".?AV?$basic_ostream@GU?$char_traits@G@std@@@std@@")
538 DEFINE_RTTI_DATA3(basic_istream_char, sizeof(basic_istream_char), &basic_ios_char_rtti_base_descriptor,
539         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
540         ".?AV?$basic_istream@DU?$char_traits@D@std@@@std@@")
541 DEFINE_RTTI_DATA3(basic_istream_wchar, sizeof(basic_istream_wchar), &basic_ios_wchar_rtti_base_descriptor,
542         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
543         ".?AV?$basic_istream@_WU?$char_traits@_W@std@@@std@@")
544 DEFINE_RTTI_DATA3(basic_istream_short, sizeof(basic_istream_wchar), &basic_ios_short_rtti_base_descriptor,
545         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
546         ".?AV?$basic_istream@GU?$char_traits@G@std@@@std@@")
547 DEFINE_RTTI_DATA8(basic_iostream_char, sizeof(basic_iostream_char),
548         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
549         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
550         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
551         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
552         ".?AV?$basic_iostream@DU?$char_traits@D@std@@@std@@")
553 DEFINE_RTTI_DATA8(basic_iostream_wchar, sizeof(basic_iostream_wchar),
554         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
555         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
556         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
557         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
558         ".?AV?$basic_iostream@_WU?$char_traits@_W@std@@@std@@")
559 DEFINE_RTTI_DATA8(basic_iostream_short, sizeof(basic_iostream_wchar),
560         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
561         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
562         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
563         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
564         ".?AV?$basic_iostream@GU?$char_traits@G@std@@@std@@")
565 DEFINE_RTTI_DATA4(basic_ofstream_char, sizeof(basic_ofstream_char),
566         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
567         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
568         ".?AV?$basic_ofstream@DU?$char_traits@D@std@@@std@@")
569 DEFINE_RTTI_DATA4(basic_ofstream_wchar, sizeof(basic_ofstream_wchar),
570         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
571         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
572         ".?AV?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@")
573 DEFINE_RTTI_DATA4(basic_ofstream_short, sizeof(basic_ofstream_wchar),
574         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
575         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
576         ".?AV?$basic_ofstream@GU?$char_traits@G@std@@@std@@")
577 DEFINE_RTTI_DATA4(basic_ifstream_char, sizeof(basic_ifstream_char),
578         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
579         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
580         ".?AV?$basic_ifstream@DU?$char_traits@D@std@@@std@@")
581 DEFINE_RTTI_DATA4(basic_ifstream_wchar, sizeof(basic_ifstream_wchar),
582         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
583         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
584         ".?AV?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@")
585 DEFINE_RTTI_DATA4(basic_ifstream_short, sizeof(basic_ifstream_wchar),
586         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
587         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
588         ".?AV?$basic_ifstream@GU?$char_traits@G@std@@@std@@")
589 DEFINE_RTTI_DATA8(basic_fstream_char, sizeof(basic_fstream_char),
590         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
591         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
592         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
593         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
594         ".?AV?$basic_fstream@DU?$char_traits@D@std@@@std@@")
595 DEFINE_RTTI_DATA8(basic_fstream_wchar, sizeof(basic_fstream_wchar),
596         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
597         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
598         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
599         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
600         ".?AV?$basic_fstream@_WU?$char_traits@_W@std@@@std@@")
601 DEFINE_RTTI_DATA8(basic_fstream_short, sizeof(basic_fstream_wchar),
602         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
603         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
604         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
605         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
606         ".?AV?$basic_fstream@GU?$char_traits@G@std@@@std@@")
607 DEFINE_RTTI_DATA4(basic_ostringstream_char, sizeof(basic_ostringstream_char),
608         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
609         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
610         ".?AV?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@")
611 DEFINE_RTTI_DATA4(basic_ostringstream_wchar, sizeof(basic_ostringstream_wchar),
612         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
613         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
614         ".?AV?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@")
615 DEFINE_RTTI_DATA4(basic_ostringstream_short, sizeof(basic_ostringstream_wchar),
616         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
617         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
618         ".?AV?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@")
619 DEFINE_RTTI_DATA4(basic_istringstream_char, sizeof(basic_istringstream_char),
620         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
621         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
622         ".?AV?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@")
623 DEFINE_RTTI_DATA4(basic_istringstream_wchar, sizeof(basic_istringstream_wchar),
624         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
625         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
626         ".?AV?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@")
627 DEFINE_RTTI_DATA4(basic_istringstream_short, sizeof(basic_istringstream_wchar),
628         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
629         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
630         ".?AV?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@")
631 DEFINE_RTTI_DATA8(basic_stringstream_char, sizeof(basic_stringstream_char),
632         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
633         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
634         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
635         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
636         ".?AV?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@")
637 DEFINE_RTTI_DATA8(basic_stringstream_wchar, sizeof(basic_stringstream_wchar),
638         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
639         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
640         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
641         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
642         ".?AV?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@")
643 DEFINE_RTTI_DATA8(basic_stringstream_short, sizeof(basic_stringstream_wchar),
644         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
645         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
646         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
647         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
648         ".?AV?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@")
649 DEFINE_RTTI_DATA1(strstreambuf, sizeof(strstreambuf),
650         &basic_streambuf_char_rtti_base_descriptor, ".?AVstrstreambuf@std@@")
651 DEFINE_RTTI_DATA4(ostrstream, sizeof(ostrstream),
652         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
653         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
654         "?AVostrstream@std@@")
655 DEFINE_RTTI_DATA8(strstream, sizeof(strstream),
656         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
657         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
658         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
659         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
660         "?AVstrstream@std@@")
661
662 #ifndef __GNUC__
663 void __asm_dummy_vtables(void) {
664 #endif
665     __ASM_VTABLE(iosb,
666             VTABLE_ADD_FUNC(iosb_vector_dtor));
667     __ASM_VTABLE(ios_base,
668             VTABLE_ADD_FUNC(ios_base_vector_dtor));
669     __ASM_VTABLE(basic_ios_char,
670             VTABLE_ADD_FUNC(basic_ios_char_vector_dtor));
671     __ASM_VTABLE(basic_ios_wchar,
672             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
673     __ASM_VTABLE(basic_ios_short,
674             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
675     __ASM_VTABLE(basic_streambuf_char,
676             VTABLE_ADD_FUNC(basic_streambuf_char_vector_dtor)
677             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
678             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
679             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
680             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
681             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
682             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
683             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
684             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
685             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
686             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
687             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
688             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
689     __ASM_VTABLE(basic_streambuf_wchar,
690             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
691             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
692             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
693             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
694             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
695             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
696             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
697             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
698             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
699             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
700             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
701             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
702             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
703     __ASM_VTABLE(basic_streambuf_short,
704             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
705             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
706             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
707             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
708             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
709             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
710             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
711             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
712             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
713             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
714             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
715             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
716             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
717     __ASM_VTABLE(basic_filebuf_char,
718             VTABLE_ADD_FUNC(basic_filebuf_char_vector_dtor)
719             VTABLE_ADD_FUNC(basic_filebuf_char_overflow)
720             VTABLE_ADD_FUNC(basic_filebuf_char_pbackfail)
721             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
722             VTABLE_ADD_FUNC(basic_filebuf_char_underflow)
723             VTABLE_ADD_FUNC(basic_filebuf_char_uflow)
724             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
725             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
726             VTABLE_ADD_FUNC(basic_filebuf_char_seekoff)
727             VTABLE_ADD_FUNC(basic_filebuf_char_seekpos)
728             VTABLE_ADD_FUNC(basic_filebuf_char_setbuf)
729             VTABLE_ADD_FUNC(basic_filebuf_char_sync)
730             VTABLE_ADD_FUNC(basic_filebuf_char_imbue));
731     __ASM_VTABLE(basic_filebuf_wchar,
732             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
733             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
734             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
735             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
736             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
737             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
738             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
739             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
740             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
741             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
742             VTABLE_ADD_FUNC(basic_filebuf_wchar_setbuf)
743             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
744             VTABLE_ADD_FUNC(basic_filebuf_wchar_imbue));
745     __ASM_VTABLE(basic_filebuf_short,
746             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
747             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
748             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
749             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
750             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
751             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
752             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
753             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
754             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
755             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
756             VTABLE_ADD_FUNC(basic_filebuf_short_setbuf)
757             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
758             VTABLE_ADD_FUNC(basic_filebuf_short_imbue));
759     __ASM_VTABLE(basic_stringbuf_char,
760             VTABLE_ADD_FUNC(basic_stringbuf_char_vector_dtor)
761             VTABLE_ADD_FUNC(basic_stringbuf_char_overflow)
762             VTABLE_ADD_FUNC(basic_stringbuf_char_pbackfail)
763             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
764             VTABLE_ADD_FUNC(basic_stringbuf_char_underflow)
765             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
766             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
767             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
768             VTABLE_ADD_FUNC(basic_stringbuf_char_seekoff)
769             VTABLE_ADD_FUNC(basic_stringbuf_char_seekpos)
770             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
771             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
772             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
773     __ASM_VTABLE(basic_stringbuf_wchar,
774             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
775             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
776             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
777             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
778             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
779             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
780             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
781             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
782             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
783             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
784             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
785             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
786             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
787     __ASM_VTABLE(basic_stringbuf_short,
788             VTABLE_ADD_FUNC(basic_stringbuf_wchar_vector_dtor)
789             VTABLE_ADD_FUNC(basic_stringbuf_wchar_overflow)
790             VTABLE_ADD_FUNC(basic_stringbuf_wchar_pbackfail)
791             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
792             VTABLE_ADD_FUNC(basic_stringbuf_wchar_underflow)
793             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
794             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
795             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
796             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekoff)
797             VTABLE_ADD_FUNC(basic_stringbuf_wchar_seekpos)
798             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
799             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
800             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
801     __ASM_VTABLE(basic_ostream_char,
802             VTABLE_ADD_FUNC(basic_ostream_char_vector_dtor));
803     __ASM_VTABLE(basic_ostream_wchar,
804             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
805     __ASM_VTABLE(basic_ostream_short,
806             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
807     __ASM_VTABLE(basic_istream_char,
808             VTABLE_ADD_FUNC(basic_istream_char_vector_dtor));
809     __ASM_VTABLE(basic_istream_wchar,
810             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
811     __ASM_VTABLE(basic_istream_short,
812             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
813     __ASM_VTABLE(basic_iostream_char,
814             VTABLE_ADD_FUNC(basic_iostream_char_vector_dtor));
815     __ASM_VTABLE(basic_iostream_wchar,
816             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
817     __ASM_VTABLE(basic_iostream_short,
818             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
819     __ASM_VTABLE(basic_ofstream_char,
820             VTABLE_ADD_FUNC(basic_ofstream_char_vector_dtor));
821     __ASM_VTABLE(basic_ofstream_wchar,
822             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
823     __ASM_VTABLE(basic_ofstream_short,
824             VTABLE_ADD_FUNC(basic_ofstream_wchar_vector_dtor));
825     __ASM_VTABLE(basic_ifstream_char,
826             VTABLE_ADD_FUNC(basic_ifstream_char_vector_dtor));
827     __ASM_VTABLE(basic_ifstream_wchar,
828             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
829     __ASM_VTABLE(basic_ifstream_short,
830             VTABLE_ADD_FUNC(basic_ifstream_wchar_vector_dtor));
831     __ASM_VTABLE(basic_fstream_char,
832             VTABLE_ADD_FUNC(basic_fstream_char_vector_dtor));
833     __ASM_VTABLE(basic_fstream_wchar,
834             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
835     __ASM_VTABLE(basic_fstream_short,
836             VTABLE_ADD_FUNC(basic_fstream_wchar_vector_dtor));
837     __ASM_VTABLE(basic_ostringstream_char,
838             VTABLE_ADD_FUNC(basic_ostringstream_char_vector_dtor));
839     __ASM_VTABLE(basic_ostringstream_wchar,
840             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
841     __ASM_VTABLE(basic_ostringstream_short,
842             VTABLE_ADD_FUNC(basic_ostringstream_wchar_vector_dtor));
843     __ASM_VTABLE(basic_istringstream_char,
844             VTABLE_ADD_FUNC(basic_istringstream_char_vector_dtor));
845     __ASM_VTABLE(basic_istringstream_wchar,
846             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
847     __ASM_VTABLE(basic_istringstream_short,
848             VTABLE_ADD_FUNC(basic_istringstream_wchar_vector_dtor));
849     __ASM_VTABLE(basic_stringstream_char,
850             VTABLE_ADD_FUNC(basic_stringstream_char_vector_dtor));
851     __ASM_VTABLE(basic_stringstream_wchar,
852             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
853     __ASM_VTABLE(basic_stringstream_short,
854             VTABLE_ADD_FUNC(basic_stringstream_wchar_vector_dtor));
855     __ASM_VTABLE(strstreambuf,
856             VTABLE_ADD_FUNC(strstreambuf_vector_dtor)
857             VTABLE_ADD_FUNC(strstreambuf_overflow)
858             VTABLE_ADD_FUNC(strstreambuf_pbackfail)
859             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
860             VTABLE_ADD_FUNC(strstreambuf_underflow)
861             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
862             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
863             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
864             VTABLE_ADD_FUNC(strstreambuf_seekoff)
865             VTABLE_ADD_FUNC(strstreambuf_seekpos)
866             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
867             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
868             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
869     __ASM_VTABLE(ostrstream,
870             VTABLE_ADD_FUNC(ostrstream_vector_dtor));
871     __ASM_VTABLE(strstream,
872             VTABLE_ADD_FUNC(strstream_vector_dtor));
873 #ifndef __GNUC__
874 }
875 #endif
876
877 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
878 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
879 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
880 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
881 {
882     TRACE("(%p %p %p %p)\n", this, first, next, last);
883
884     this->wbuf = first;
885     this->wpos = next;
886     this->wsize = last-next;
887 }
888
889 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
890 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
891 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
892 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
893 {
894     basic_streambuf_char_setp_next(this, first, first, last);
895 }
896
897 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
898 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
899 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
900 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
901 {
902     TRACE("(%p %p %p %p)\n", this, first, next, last);
903
904     this->rbuf = first;
905     this->rpos = next;
906     this->rsize = last-next;
907 }
908
909 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
910 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
911 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
912 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
913 {
914     TRACE("(%p)\n", this);
915
916     this->prbuf = &this->rbuf;
917     this->pwbuf = &this->wbuf;
918     this->prpos = &this->rpos;
919     this->pwpos = &this->wpos;
920     this->prsize = &this->rsize;
921     this->pwsize = &this->wsize;
922
923     basic_streambuf_char_setp(this, NULL, NULL);
924     basic_streambuf_char_setg(this, NULL, NULL, NULL);
925 }
926
927 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
928 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
929 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
930 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
931 {
932     TRACE("(%p %d)\n", this, uninitialized);
933     this->vtable = &MSVCP_basic_streambuf_char_vtable;
934     mutex_ctor(&this->lock);
935     return this;
936 }
937
938 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
939 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
940 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
941 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
942 {
943     TRACE("(%p)\n", this);
944
945     this->vtable = &MSVCP_basic_streambuf_char_vtable;
946     mutex_ctor(&this->lock);
947     this->loc = MSVCRT_operator_new(sizeof(locale));
948     locale_ctor(this->loc);
949     basic_streambuf_char__Init_empty(this);
950
951     return this;
952 }
953
954 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
955 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
956 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
957 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
958 {
959     TRACE("(%p)\n", this);
960
961     mutex_dtor(&this->lock);
962     locale_dtor(this->loc);
963     MSVCRT_operator_delete(this->loc);
964 }
965
966 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_vector_dtor, 8)
967 basic_streambuf_char* __thiscall basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
968 {
969     TRACE("(%p %x)\n", this, flags);
970     if(flags & 2) {
971         /* we have an array, with the number of elements stored before the first object */
972         INT_PTR i, *ptr = (INT_PTR *)this-1;
973
974         for(i=*ptr-1; i>=0; i--)
975             basic_streambuf_char_dtor(this+i);
976         MSVCRT_operator_delete(ptr);
977     } else {
978         basic_streambuf_char_dtor(this);
979         if(flags & 1)
980             MSVCRT_operator_delete(this);
981     }
982
983     return this;
984 }
985
986 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
987 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
988 static streamsize basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
989 {
990     TRACE("(%p)\n", this);
991     return *this->prpos ? *this->prsize : 0;
992 }
993
994 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
995 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
996 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
997 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
998 {
999     TRACE("(%p)\n", this);
1000     (*this->prsize)++;
1001     (*this->prpos)--;
1002     return *this->prpos;
1003 }
1004
1005 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1006 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1007 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
1008 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
1009 {
1010     TRACE("(%p)\n", this);
1011     (*this->prsize)--;
1012     return (*this->prpos)++;
1013 }
1014
1015 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
1016 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
1017 static char* basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
1018 {
1019     TRACE("(%p)\n", this);
1020     (*this->prsize)--;
1021     (*this->prpos)++;
1022     return *this->prpos;
1023 }
1024
1025 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
1026 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
1027 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
1028 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
1029 {
1030     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1031
1032     this->prbuf = gf;
1033     this->pwbuf = pf;
1034     this->prpos = gn;
1035     this->pwpos = pn;
1036     this->prsize = gc;
1037     this->pwsize = pc;
1038 }
1039
1040 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1041 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1042 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Lock, 4)
1043 void __thiscall basic_streambuf_char__Lock(basic_streambuf_char *this)
1044 {
1045     TRACE("(%p)\n", this);
1046     mutex_lock(&this->lock);
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 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Unlock, 4)
1141 void __thiscall basic_streambuf_char__Unlock(basic_streambuf_char *this)
1142 {
1143     TRACE("(%p)\n", this);
1144     mutex_unlock(&this->lock);
1145 }
1146
1147 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1148 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1149 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
1150 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
1151 {
1152     TRACE("(%p)\n", this);
1153     return *this->prbuf;
1154 }
1155
1156 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1157 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1158 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
1159 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
1160 {
1161     TRACE("(%p)\n", this);
1162     return *this->prpos;
1163 }
1164
1165 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1166 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1167 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
1168 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
1169 {
1170     TRACE("(%p)\n", this);
1171     return *this->prpos+*this->prsize;
1172 }
1173
1174 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1175 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1176 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
1177 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
1178 {
1179     TRACE("(%p)\n", this);
1180     return *this->pwpos+*this->pwsize;
1181 }
1182
1183 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1184 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1185 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
1186 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
1187 {
1188     TRACE("(%p %d)\n", this, off);
1189     *this->prpos += off;
1190     *this->prsize -= off;
1191 }
1192
1193 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QBE?AVlocale@2@XZ */
1194 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ */
1195 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_getloc, 8)
1196 locale* __thiscall basic_streambuf_char_getloc(const basic_streambuf_char *this, locale *ret)
1197 {
1198     TRACE("(%p)\n", this);
1199     return locale_copy_ctor(ret, this->loc);
1200 }
1201
1202 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
1203 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
1204 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
1205 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1206         void, (basic_streambuf_char*, const locale*), (this, loc))
1207 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
1208 {
1209     TRACE("(%p %p)\n", this, loc);
1210 }
1211
1212 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1213 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1214 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
1215 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1216         int, (basic_streambuf_char*, int), (this, ch))
1217 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
1218 {
1219     TRACE("(%p %d)\n", this, ch);
1220     return EOF;
1221 }
1222
1223 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
1224 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
1225 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
1226 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1227         int, (basic_streambuf_char*, int), (this, ch))
1228 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
1229 {
1230     TRACE("(%p %d)\n", this, ch);
1231     return EOF;
1232 }
1233
1234 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1235 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1236 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
1237 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
1238 {
1239     TRACE("(%p)\n", this);
1240     return *this->pwbuf;
1241 }
1242
1243 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
1244 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
1245 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
1246 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
1247 {
1248     TRACE("(%p %d)\n", this, off);
1249     *this->pwpos += off;
1250     *this->pwsize -= off;
1251 }
1252
1253 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
1254 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
1255 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
1256 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
1257 {
1258     TRACE("(%p)\n", this);
1259     return *this->pwpos;
1260 }
1261
1262 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1263 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1264 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
1265 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
1266 {
1267     TRACE("(%p %p)\n", this, loc);
1268     memcpy(ret, this->loc, sizeof(locale));
1269     call_basic_streambuf_char_imbue(this, loc);
1270     locale_copy_ctor(this->loc, loc);
1271     return ret;
1272 }
1273
1274 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1275 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1276 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 20)
1277 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
1278         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1279 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
1280         fpos_int *ret, streamoff off, int way, int mode)
1281 {
1282     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1283     ret->off = -1;
1284     ret->pos = 0;
1285     ret->state = 0;
1286     return ret;
1287 }
1288
1289 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1290 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1291 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff, 20)
1292 fpos_int* __thiscall basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
1293         fpos_int *ret, streamoff off, int way, int mode)
1294 {
1295     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1296     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
1297 }
1298
1299 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1300 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1301 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff_old, 20)
1302 fpos_int* __thiscall basic_streambuf_char_pubseekoff_old(basic_streambuf_char *this,
1303         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
1304 {
1305     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
1306     return basic_streambuf_char_pubseekoff(this, ret, off, way, mode);
1307 }
1308
1309 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1310 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1311 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
1312 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
1313         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1314 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
1315         fpos_int *ret, fpos_int pos, int mode)
1316 {
1317     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1318     ret->off = -1;
1319     ret->pos = 0;
1320     ret->state = 0;
1321     return ret;
1322 }
1323
1324 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1325 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1326 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
1327 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
1328         fpos_int *ret, fpos_int pos, int mode)
1329 {
1330     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1331     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
1332 }
1333
1334 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1335 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1336 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos_old, 36)
1337 fpos_int* __thiscall basic_streambuf_char_pubseekpos_old(basic_streambuf_char *this,
1338         fpos_int *ret, fpos_int pos, unsigned int mode)
1339 {
1340     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1341     return basic_streambuf_char_pubseekpos(this, ret, pos, mode);
1342 }
1343
1344 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
1345 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
1346 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 12)
1347 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
1348         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
1349 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
1350 {
1351     TRACE("(%p %p %ld)\n", this, buf, count);
1352     return this;
1353 }
1354
1355 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
1356 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
1357 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 12)
1358 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
1359 {
1360     TRACE("(%p %p %ld)\n", this, buf, count);
1361     return call_basic_streambuf_char_setbuf(this, buf, count);
1362 }
1363
1364 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1365 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
1366 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
1367 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 44, \
1368         int, (basic_streambuf_char*), (this))
1369 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
1370 {
1371     TRACE("(%p)\n", this);
1372     return 0;
1373 }
1374
1375 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1376 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1377 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
1378 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
1379 {
1380     TRACE("(%p)\n", this);
1381     return call_basic_streambuf_char_sync(this);
1382 }
1383
1384 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1385 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1386 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 12)
1387 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
1388         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1389 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1390 {
1391     TRACE("(%p %p %ld)\n", this, ptr, count);
1392     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1393 }
1394
1395 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
1396 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
1397 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 12)
1398 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1399 {
1400     TRACE("(%p %p %ld)\n", this, ptr, count);
1401     return call_basic_streambuf_char_xsgetn(this, ptr, count);
1402 }
1403
1404 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
1405 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
1406 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
1407 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
1408         streamsize, (basic_streambuf_char*), (this))
1409 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
1410 {
1411     TRACE("(%p)\n", this);
1412     return 0;
1413 }
1414
1415 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1416 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
1417 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
1418 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
1419 {
1420     streamsize ret;
1421
1422     TRACE("(%p)\n", this);
1423
1424     ret = basic_streambuf_char__Gnavail(this);
1425     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
1426 }
1427
1428 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1429 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1430 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
1431 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
1432 {
1433     TRACE("(%p %d)\n", this, ch);
1434     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1435         (*this->prsize)++;
1436         (*this->prpos)--;
1437         return (unsigned char)ch;
1438     }
1439
1440     return call_basic_streambuf_char_pbackfail(this, (unsigned char)ch);
1441 }
1442
1443 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
1444 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
1445 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
1446 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
1447 {
1448     TRACE("(%p %d)\n", this, ch);
1449     return basic_streambuf_char__Pnavail(this) ?
1450         (*basic_streambuf_char__Pninc(this) = ch) :
1451         call_basic_streambuf_char_overflow(this, (unsigned char)ch);
1452 }
1453
1454 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1455 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1456 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
1457 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
1458 {
1459     TRACE("(%p)\n", this);
1460     if(*this->prpos && *this->prpos>*this->prbuf) {
1461         (*this->prsize)++;
1462         (*this->prpos)--;
1463         return (unsigned char)**this->prpos;
1464     }
1465
1466     return call_basic_streambuf_char_pbackfail(this, EOF);
1467 }
1468
1469 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1470 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1471 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1472 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1473 {
1474     TRACE("(%p)\n", this);
1475     if(basic_streambuf_char__Gnavail(this))
1476         basic_streambuf_char__Gninc(this);
1477     else
1478         call_basic_streambuf_char_uflow(this);
1479 }
1480
1481 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1482 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1483 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1484 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1485 {
1486     TRACE("(%p)\n", this);
1487     return basic_streambuf_char__Gnavail(this) ?
1488         (int)(unsigned char)*basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1489 }
1490
1491 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1492 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1493 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1494 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1495 {
1496     TRACE("(%p)\n", this);
1497     return basic_streambuf_char__Gnavail(this) ?
1498         (int)(unsigned char)*basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1499 }
1500
1501 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1502 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1503 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1504 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1505 {
1506     TRACE("(%p)\n", this);
1507
1508     if(basic_streambuf_char__Gnavail(this) > 1)
1509         return (unsigned char)*basic_streambuf_char__Gnpreinc(this);
1510     return basic_streambuf_char_sbumpc(this)==EOF ?
1511         EOF : basic_streambuf_char_sgetc(this);
1512 }
1513
1514 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1515 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1516 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 12)
1517 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
1518         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1519 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1520 {
1521     streamsize copied, chunk;
1522
1523     TRACE("(%p %p %ld)\n", this, ptr, count);
1524
1525     for(copied=0; copied<count;) {
1526         chunk = basic_streambuf_char__Pnavail(this);
1527         if(chunk > count-copied)
1528             chunk = count-copied;
1529
1530         if(chunk > 0) {
1531             memcpy(*this->pwpos, ptr+copied, chunk);
1532             *this->pwpos += chunk;
1533             *this->pwsize -= chunk;
1534             copied += chunk;
1535         }else if(call_basic_streambuf_char_overflow(this, (unsigned char)ptr[copied]) != EOF) {
1536             copied++;
1537         }else {
1538             break;
1539         }
1540     }
1541
1542     return copied;
1543 }
1544
1545 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1546 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1547 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 12)
1548 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1549 {
1550     TRACE("(%p %p %ld)\n", this, ptr, count);
1551     return call_basic_streambuf_char_xsputn(this, ptr, count);
1552 }
1553
1554 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1555 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1556 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1557 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1558 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1559 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1560 {
1561     TRACE("(%p %p %p %p)\n", this, first, next, last);
1562
1563     this->wbuf = first;
1564     this->wpos = next;
1565     this->wsize = last-next;
1566 }
1567
1568 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1569 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1570 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1571 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1572 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1573 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1574 {
1575     basic_streambuf_wchar_setp_next(this, first, first, last);
1576 }
1577
1578 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1579 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1580 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1581 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1582 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1583 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1584 {
1585     TRACE("(%p %p %p %p)\n", this, first, next, last);
1586
1587     this->rbuf = first;
1588     this->rpos = next;
1589     this->rsize = last-next;
1590 }
1591
1592 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1593 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1594 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1595 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1596 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1597 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1598 {
1599     TRACE("(%p)\n", this);
1600
1601     this->prbuf = &this->rbuf;
1602     this->pwbuf = &this->wbuf;
1603     this->prpos = &this->rpos;
1604     this->pwpos = &this->wpos;
1605     this->prsize = &this->rsize;
1606     this->pwsize = &this->wsize;
1607
1608     basic_streambuf_wchar_setp(this, NULL, NULL);
1609     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1610 }
1611
1612 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1613 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1614 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor_uninitialized, 8)
1615 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1616 {
1617     TRACE("(%p %d)\n", this, uninitialized);
1618     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1619     mutex_ctor(&this->lock);
1620     return this;
1621 }
1622
1623 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1624 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1625 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1626 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1627 {
1628     TRACE("(%p %d)\n", this, uninitialized);
1629     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1630     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1631     return this;
1632 }
1633
1634 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1635 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1636 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor, 4)
1637 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1638 {
1639     TRACE("(%p)\n", this);
1640
1641     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1642     mutex_ctor(&this->lock);
1643     this->loc = MSVCRT_operator_new(sizeof(locale));
1644     locale_ctor(this->loc);
1645     basic_streambuf_wchar__Init_empty(this);
1646
1647     return this;
1648 }
1649
1650 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1651 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1652 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1653 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1654 {
1655     TRACE("(%p)\n", this);
1656     basic_streambuf_wchar_ctor(this);
1657     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1658     return this;
1659 }
1660
1661 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1662 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1663 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1664 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1665 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1666 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1667 {
1668     TRACE("(%p)\n", this);
1669
1670     mutex_dtor(&this->lock);
1671     locale_dtor(this->loc);
1672     MSVCRT_operator_delete(this->loc);
1673 }
1674
1675 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_vector_dtor, 8)
1676 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1677 {
1678     TRACE("(%p %x)\n", this, flags);
1679     if(flags & 2) {
1680         /* we have an array, with the number of elements stored before the first object */
1681         INT_PTR i, *ptr = (INT_PTR *)this-1;
1682
1683         for(i=*ptr-1; i>=0; i--)
1684             basic_streambuf_wchar_dtor(this+i);
1685         MSVCRT_operator_delete(ptr);
1686     } else {
1687         basic_streambuf_wchar_dtor(this);
1688         if(flags & 1)
1689             MSVCRT_operator_delete(this);
1690     }
1691
1692     return this;
1693 }
1694
1695 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1696 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1697 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1698 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1699 static streamsize basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1700 {
1701     TRACE("(%p)\n", this);
1702     return *this->prpos ? *this->prsize : 0;
1703 }
1704
1705 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1706 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1707 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1708 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1709 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1710 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1711 {
1712     TRACE("(%p)\n", this);
1713     (*this->prsize)++;
1714     (*this->prpos)--;
1715     return *this->prpos;
1716 }
1717
1718 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1719 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1720 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1721 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1722 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1723 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1724 {
1725     TRACE("(%p)\n", this);
1726     (*this->prsize)--;
1727     return (*this->prpos)++;
1728 }
1729
1730 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1731 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1732 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1733 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1734 static wchar_t* basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1735 {
1736     TRACE("(%p)\n", this);
1737     (*this->prsize)--;
1738     (*this->prpos)++;
1739     return *this->prpos;
1740 }
1741
1742 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1743 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1744 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1745 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1746 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1747 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)
1748 {
1749     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1750
1751     this->prbuf = gf;
1752     this->pwbuf = pf;
1753     this->prpos = gn;
1754     this->pwpos = pn;
1755     this->prsize = gc;
1756     this->pwsize = pc;
1757 }
1758
1759 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1760 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1761 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1762 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1763 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Lock, 4)
1764 void __thiscall basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1765 {
1766     TRACE("(%p)\n", this);
1767     mutex_lock(&this->lock);
1768 }
1769
1770 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1771 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1772 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1773 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1774 static streamsize basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1775 {
1776     TRACE("(%p)\n", this);
1777     return *this->pwpos ? *this->pwsize : 0;
1778 }
1779
1780 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1781 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1782 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1783 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1784 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1785 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1786 {
1787     TRACE("(%p)\n", this);
1788     (*this->pwsize)--;
1789     return (*this->pwpos)++;
1790 }
1791
1792 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1793 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1794 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1795 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1796 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1797 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 16, \
1798         unsigned short, (basic_streambuf_wchar*), (this))
1799 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1800 {
1801     TRACE("(%p)\n", this);
1802     return WEOF;
1803 }
1804
1805 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1806 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1807 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1808 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1809 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1810 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 20, \
1811         unsigned short, (basic_streambuf_wchar*), (this))
1812 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1813 {
1814     int ret;
1815
1816     TRACE("(%p)\n", this);
1817
1818     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1819         return WEOF;
1820
1821     ret = **this->prpos;
1822     (*this->prsize)--;
1823     (*this->prpos)++;
1824     return ret;
1825 }
1826
1827 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1828 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1829 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1830 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1831 static streamsize basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1832 {
1833     streamsize copied, chunk;
1834     unsigned short c;
1835
1836     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1837
1838     for(copied=0; copied<count && size;) {
1839         chunk = basic_streambuf_wchar__Gnavail(this);
1840         if(chunk > count-copied)
1841             chunk = count-copied;
1842
1843         if(chunk > 0) {
1844             memcpy_s(ptr+copied, size, *this->prpos, chunk*sizeof(wchar_t));
1845             *this->prpos += chunk;
1846             *this->prsize -= chunk;
1847             copied += chunk;
1848             size -= chunk*sizeof(wchar_t);
1849         }else if((c = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1850             ptr[copied] = c;
1851             copied++;
1852             size--;
1853         }else {
1854             break;
1855         }
1856     }
1857
1858     return copied;
1859 }
1860
1861 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1862 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1863 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1864 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1865 static streamsize basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1866 {
1867     TRACE("(%p %p %lu %ld)\n", this, ptr, size, count);
1868     return basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1869 }
1870
1871 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1872 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1873 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1874 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1875 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Unlock, 4)
1876 void __thiscall basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1877 {
1878     TRACE("(%p)\n", this);
1879     mutex_unlock(&this->lock);
1880 }
1881
1882 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1883 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1884 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1885 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1886 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1887 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1888 {
1889     TRACE("(%p)\n", this);
1890     return *this->prbuf;
1891 }
1892
1893 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1894 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1895 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1896 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1897 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1898 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1899 {
1900     TRACE("(%p)\n", this);
1901     return *this->prpos;
1902 }
1903
1904 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1905 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1906 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1907 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1908 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1909 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1910 {
1911     TRACE("(%p)\n", this);
1912     return *this->prpos+*this->prsize;
1913 }
1914
1915 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1916 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1917 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1918 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1919 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1920 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1921 {
1922     TRACE("(%p)\n", this);
1923     return *this->pwpos+*this->pwsize;
1924 }
1925
1926 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1927 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1928 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1929 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1930 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1931 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1932 {
1933     TRACE("(%p %d)\n", this, off);
1934     *this->prpos += off;
1935     *this->prsize -= off;
1936 }
1937
1938 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QBE?AVlocale@2@XZ */
1939 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEBA?AVlocale@2@XZ */
1940 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QBE?AVlocale@2@XZ */
1941 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEBA?AVlocale@2@XZ */
1942 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
1943 locale* __thiscall basic_streambuf_wchar_getloc(const basic_streambuf_wchar *this, locale *ret)
1944 {
1945     TRACE("(%p)\n", this);
1946     return locale_copy_ctor(ret, this->loc);
1947 }
1948
1949 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1950 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1951 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1952 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1953 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1954 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 48, \
1955         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1956 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1957 {
1958     TRACE("(%p %p)\n", this, loc);
1959 }
1960
1961 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1962 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1963 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1964 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1965 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1966 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 4, \
1967         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1968 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1969 {
1970     TRACE("(%p %d)\n", this, ch);
1971     return WEOF;
1972 }
1973
1974 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1975 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1976 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1977 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1978 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1979 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 8, \
1980         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1981 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1982 {
1983     TRACE("(%p %d)\n", this, ch);
1984     return WEOF;
1985 }
1986
1987 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1988 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1989 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1990 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1991 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1992 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1993 {
1994     TRACE("(%p)\n", this);
1995     return *this->pwbuf;
1996 }
1997
1998 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1999 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
2000 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
2001 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
2002 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
2003 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
2004 {
2005     TRACE("(%p %d)\n", this, off);
2006     *this->pwpos += off;
2007     *this->pwsize -= off;
2008 }
2009
2010 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
2011 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
2012 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
2013 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
2014 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
2015 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
2016 {
2017     TRACE("(%p)\n", this);
2018     return *this->pwpos;
2019 }
2020
2021 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2022 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2023 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
2024 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
2025 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
2026 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
2027 {
2028     TRACE("(%p %p)\n", this, loc);
2029     memcpy(ret, this->loc, sizeof(locale));
2030     call_basic_streambuf_wchar_imbue(this, loc);
2031     locale_copy_ctor(this->loc, loc);
2032     return ret;
2033 }
2034
2035 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2036 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2037 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2038 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2039 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 20)
2040 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 32, \
2041         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
2042 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
2043         fpos_int *ret, streamoff off, int way, int mode)
2044 {
2045     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2046     ret->off = -1;
2047     ret->pos = 0;
2048     ret->state = 0;
2049     return ret;
2050 }
2051
2052 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2053 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2054 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
2055 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
2056 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff, 20)
2057 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
2058         fpos_int *ret, streamoff off, int way, int mode)
2059 {
2060     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2061     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
2062 }
2063
2064 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
2065 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
2066 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
2067 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
2068 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff_old, 20)
2069 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff_old(basic_streambuf_wchar *this,
2070         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
2071 {
2072     TRACE("(%p %ld %d %d)\n", this, off, way, mode);
2073     return basic_streambuf_wchar_pubseekoff(this, ret, off, way, mode);
2074 }
2075
2076 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2077 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2078 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2079 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2080 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
2081 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 36, \
2082         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
2083 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
2084         fpos_int *ret, fpos_int pos, int mode)
2085 {
2086     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2087     ret->off = -1;
2088     ret->pos = 0;
2089     ret->state = 0;
2090     return ret;
2091 }
2092
2093 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2094 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2095 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
2096 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
2097 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
2098 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
2099         fpos_int *ret, fpos_int pos, int mode)
2100 {
2101     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2102     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
2103 }
2104
2105 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
2106 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
2107 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
2108 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
2109 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos_old, 36)
2110 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos_old(basic_streambuf_wchar *this,
2111         fpos_int *ret, fpos_int pos, unsigned int mode)
2112 {
2113     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
2114     return basic_streambuf_wchar_pubseekpos(this, ret, pos, mode);
2115 }
2116
2117 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
2118 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
2119 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
2120 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
2121 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 12)
2122 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 40, \
2123         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
2124 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2125 {
2126     TRACE("(%p %p %ld)\n", this, buf, count);
2127     return this;
2128 }
2129
2130 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
2131 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
2132 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
2133 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
2134 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 12)
2135 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
2136 {
2137     TRACE("(%p %p %ld)\n", this, buf, count);
2138     return call_basic_streambuf_wchar_setbuf(this, buf, count);
2139 }
2140
2141 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2142 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2143 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2144 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2145 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
2146 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 44, \
2147         int, (basic_streambuf_wchar*), (this))
2148 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
2149 {
2150     TRACE("(%p)\n", this);
2151     return 0;
2152 }
2153
2154 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2155 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
2156 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2157 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
2158 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
2159 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
2160 {
2161     TRACE("(%p)\n", this);
2162     return call_basic_streambuf_wchar_sync(this);
2163 }
2164
2165 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
2166 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
2167 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
2168 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
2169 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 12)
2170 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 24, \
2171         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
2172 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2173 {
2174     TRACE("(%p %p %ld)\n", this, ptr, count);
2175     return call_basic_streambuf_wchar_xsgetn(this, ptr, count);
2176 }
2177
2178 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
2179 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
2180 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
2181 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
2182 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 12)
2183 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
2184 {
2185     TRACE("(%p %p %ld)\n", this, ptr, count);
2186     return call_basic_streambuf_wchar_xsgetn(this, ptr, count);
2187 }
2188
2189 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2190 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
2191 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2192 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
2193 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
2194 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 12, \
2195         streamsize, (basic_streambuf_wchar*), (this))
2196 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
2197 {
2198     TRACE("(%p)\n", this);
2199     return 0;
2200 }
2201
2202 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
2203 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
2204 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
2205 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
2206 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
2207 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
2208 {
2209     streamsize ret;
2210
2211     TRACE("(%p)\n", this);
2212
2213     ret = basic_streambuf_wchar__Gnavail(this);
2214     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
2215 }
2216
2217 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2218 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2219 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2220 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
2221 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
2222 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
2223 {
2224     TRACE("(%p %d)\n", this, ch);
2225     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
2226         (*this->prsize)++;
2227         (*this->prpos)--;
2228         return ch;
2229     }
2230
2231     return call_basic_streambuf_wchar_pbackfail(this, ch);
2232 }
2233
2234 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
2235 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
2236 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
2237 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
2238 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
2239 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
2240 {
2241     TRACE("(%p %d)\n", this, ch);
2242     return basic_streambuf_wchar__Pnavail(this) ?
2243         (*basic_streambuf_wchar__Pninc(this) = ch) :
2244         call_basic_streambuf_wchar_overflow(this, ch);
2245 }
2246
2247 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2248 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2249 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2250 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2251 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
2252 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
2253 {
2254     TRACE("(%p)\n", this);
2255     if(*this->prpos && *this->prpos>*this->prbuf) {
2256         (*this->prsize)++;
2257         (*this->prpos)--;
2258         return **this->prpos;
2259     }
2260
2261     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
2262 }
2263
2264 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
2265 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
2266 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
2267 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
2268 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
2269 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
2270 {
2271     TRACE("(%p)\n", this);
2272     if(basic_streambuf_wchar__Gnavail(this))
2273         basic_streambuf_wchar__Gninc(this);
2274     else
2275         call_basic_streambuf_wchar_uflow(this);
2276 }
2277
2278 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2279 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2280 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2281 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2282 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
2283 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
2284 {
2285     TRACE("(%p)\n", this);
2286     return basic_streambuf_wchar__Gnavail(this) ?
2287         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
2288 }
2289
2290 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2291 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2292 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2293 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2294 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
2295 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
2296 {
2297     TRACE("(%p)\n", this);
2298     return basic_streambuf_wchar__Gnavail(this) ?
2299         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
2300 }
2301
2302 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
2303 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
2304 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
2305 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
2306 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
2307 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
2308 {
2309     TRACE("(%p)\n", this);
2310
2311     if(basic_streambuf_wchar__Gnavail(this) > 1)
2312         return *basic_streambuf_wchar__Gnpreinc(this);
2313     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
2314         WEOF : basic_streambuf_wchar_sgetc(this);
2315 }
2316
2317 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
2318 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
2319 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
2320 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
2321 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 12)
2322 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 28, \
2323         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
2324 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2325 {
2326     streamsize copied, chunk;
2327
2328     TRACE("(%p %p %ld)\n", this, ptr, count);
2329
2330     for(copied=0; copied<count;) {
2331         chunk = basic_streambuf_wchar__Pnavail(this);
2332         if(chunk > count-copied)
2333             chunk = count-copied;
2334
2335         if(chunk > 0) {
2336             memcpy(*this->pwpos, ptr+copied, chunk*sizeof(wchar_t));
2337             *this->pwpos += chunk;
2338             *this->pwsize -= chunk;
2339             copied += chunk;
2340         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
2341             copied++;
2342         }else {
2343             break;
2344         }
2345     }
2346
2347     return copied;
2348 }
2349
2350 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
2351 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
2352 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
2353 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
2354 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 12)
2355 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
2356 {
2357     TRACE("(%p %p %ld)\n", this, ptr, count);
2358     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
2359 }
2360
2361 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2362 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2363 int basic_filebuf_char__Init__Stinit = 0;
2364
2365 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2366 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2367 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Init, 12)
2368 void __thiscall basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
2369 {
2370     TRACE("(%p %p %d)\n", this, file, which);
2371
2372     this->cvt = NULL;
2373     this->wrotesome = FALSE;
2374     this->state = basic_filebuf_char__Init__Stinit;
2375     this->close = (which == INITFL_open);
2376     this->file = file;
2377
2378     basic_streambuf_char__Init_empty(&this->base);
2379     if(file)
2380         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
2381                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
2382 }
2383
2384 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAV?$codecvt@DDH@2@@Z */
2385 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$codecvt@DDH@2@@Z */
2386 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Initcvt, 8)
2387 void __thiscall basic_filebuf_char__Initcvt(basic_filebuf_char *this, codecvt_char *cvt)
2388 {
2389     TRACE("(%p %p)\n", this, cvt);
2390
2391     if(codecvt_base_always_noconv(&cvt->base)) {
2392         this->cvt = NULL;
2393     }else {
2394         basic_streambuf_char__Init_empty(&this->base);
2395         this->cvt = cvt;
2396     }
2397 }
2398
2399 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAE_NXZ */
2400 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAA_NXZ */
2401 DEFINE_THISCALL_WRAPPER(basic_filebuf_char__Endwrite, 4)
2402 MSVCP_bool __thiscall basic_filebuf_char__Endwrite(basic_filebuf_char *this)
2403 {
2404     TRACE("(%p)\n", this);
2405
2406     if(!this->wrotesome || !this->cvt)
2407         return TRUE;
2408
2409
2410     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2411         return FALSE;
2412
2413     while(1) {
2414         /* TODO: check if we need a dynamic buffer here */
2415         char buf[128];
2416         char *next;
2417         int ret;
2418
2419         ret = codecvt_char_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2420         switch(ret) {
2421         case CODECVT_ok:
2422             this->wrotesome = FALSE;
2423             /* fall through */
2424         case CODECVT_partial:
2425             if(!fwrite(buf, next-buf, 1, this->file))
2426                 return FALSE;
2427             if(this->wrotesome)
2428                 break;
2429             /* fall through */
2430         case CODECVT_noconv:
2431             if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2432                 return FALSE;
2433             return TRUE;
2434         default:
2435             return FALSE;
2436         }
2437     }
2438 }
2439
2440 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
2441 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
2442 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_close, 4)
2443 basic_filebuf_char* __thiscall basic_filebuf_char_close(basic_filebuf_char *this)
2444 {
2445     basic_filebuf_char *ret = this;
2446
2447     TRACE("(%p)\n", this);
2448
2449     if(!this->file)
2450         return NULL;
2451
2452     /* TODO: handle exceptions */
2453     if(!basic_filebuf_char__Endwrite(this))
2454         ret = NULL;
2455     if(fclose(this->file))
2456         ret  = NULL;
2457
2458     basic_filebuf_char__Init(this, NULL, INITFL_close);
2459     return ret;
2460 }
2461
2462 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2463 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2464 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_file, 8)
2465 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2466 {
2467     TRACE("(%p %p)\n", this, file);
2468
2469     basic_streambuf_char_ctor(&this->base);
2470     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2471
2472     basic_filebuf_char__Init(this, file, INITFL_new);
2473     return this;
2474 }
2475
2476 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
2477 /* ??_F?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
2478 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor, 4)
2479 basic_filebuf_char* __thiscall basic_filebuf_char_ctor(basic_filebuf_char *this)
2480 {
2481     return basic_filebuf_char_ctor_file(this, NULL);
2482 }
2483
2484 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
2485 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
2486 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_ctor_uninitialized, 8)
2487 basic_filebuf_char* __thiscall basic_filebuf_char_ctor_uninitialized(basic_filebuf_char *this, int uninitialized)
2488 {
2489     TRACE("(%p %d)\n", this, uninitialized);
2490
2491     basic_streambuf_char_ctor(&this->base);
2492     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2493     return this;
2494 }
2495
2496 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2497 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2498 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_dtor, 4)
2499 void __thiscall basic_filebuf_char_dtor(basic_filebuf_char *this)
2500 {
2501     TRACE("(%p)\n", this);
2502
2503     if(this->close)
2504         basic_filebuf_char_close(this);
2505     basic_streambuf_char_dtor(&this->base);
2506 }
2507
2508 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2509 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2510 {
2511     TRACE("(%p %x)\n", this, flags);
2512     if(flags & 2) {
2513         /* we have an array, with the number of elements stored before the first object */
2514         INT_PTR i, *ptr = (INT_PTR *)this-1;
2515
2516         for(i=*ptr-1; i>=0; i--)
2517             basic_filebuf_char_dtor(this+i);
2518         MSVCRT_operator_delete(ptr);
2519     } else {
2520         basic_filebuf_char_dtor(this);
2521         if(flags & 1)
2522             MSVCRT_operator_delete(this);
2523     }
2524
2525     return this;
2526 }
2527
2528 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2529 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2530 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_is_open, 4)
2531 MSVCP_bool __thiscall basic_filebuf_char_is_open(const basic_filebuf_char *this)
2532 {
2533     TRACE("(%p)\n", this);
2534     return this->file != NULL;
2535 }
2536
2537 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2538 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2539 static FILE* _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2540 {
2541     static const wchar_t rW[] = {'r',0};
2542     static const struct {
2543         int mode;
2544         const wchar_t str[4];
2545         const wchar_t str_bin[4];
2546     } str_mode[] = {
2547         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2548         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2549         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2550         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2551         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2552         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2553         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2554         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2555         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2556     };
2557
2558     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2559     int mode_idx;
2560     FILE *f = NULL;
2561
2562     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2563
2564     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2565         if(str_mode[mode_idx].mode == real_mode)
2566             break;
2567     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2568         return NULL;
2569
2570     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2571         return NULL;
2572     else if(f)
2573         fclose(f);
2574
2575     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2576             && (f = _wfopen(name, rW))) {
2577         fclose(f);
2578         return NULL;
2579     }
2580
2581     /* msvcp60 - msvcp71 are ignoring prot argument */
2582     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2583             : str_mode[mode_idx].str, SH_DENYNO);
2584     if(!f)
2585         return NULL;
2586
2587     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2588         fclose(f);
2589         return NULL;
2590     }
2591
2592     return f;
2593 }
2594
2595 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2596 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2597 FILE* __cdecl _Fiopen(const char *name, int mode, int prot)
2598 {
2599     wchar_t nameW[FILENAME_MAX];
2600
2601     TRACE("(%s %d %d)\n", name, mode, prot);
2602
2603     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2604         return NULL;
2605     return _Fiopen_wchar(nameW, mode, prot);
2606 }
2607
2608 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PB_WHH@Z */
2609 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
2610 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBGHH@Z */
2611 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBGHH@Z */
2612 static basic_filebuf_char* basic_filebuf_char_open_wchar(basic_filebuf_char *this, const wchar_t *name, int mode, int prot)
2613 {
2614     FILE *f = NULL;
2615
2616     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
2617
2618     if(basic_filebuf_char_is_open(this))
2619         return NULL;
2620
2621     if(!(f = _Fiopen_wchar(name, mode, prot)))
2622         return NULL;
2623
2624     basic_filebuf_char__Init(this, f, INITFL_open);
2625     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(this->base.loc));
2626     return this;
2627 }
2628
2629 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDHH@Z */
2630 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDHH@Z */
2631 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open, 16)
2632 basic_filebuf_char* __thiscall basic_filebuf_char_open(basic_filebuf_char *this, const char *name, int mode, int prot)
2633 {
2634     wchar_t nameW[FILENAME_MAX];
2635
2636     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
2637
2638     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2639         return NULL;
2640     return basic_filebuf_char_open_wchar(this, nameW, mode, prot);
2641 }
2642
2643 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PBDI@Z */
2644 /* ?open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEBDI@Z */
2645 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_open_mode, 12)
2646 basic_filebuf_char* __thiscall basic_filebuf_char_open_mode(basic_filebuf_char *this, const char *name, unsigned int mode)
2647 {
2648     return basic_filebuf_char_open(this, name, mode, SH_DENYNO);
2649 }
2650
2651 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2652 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2653 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2654 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2655 {
2656     char buf[8], *dyn_buf;
2657     char ch = c, *to_next;
2658     const char *from_next;
2659     int ret, max_size;
2660
2661
2662     TRACE("(%p %d)\n", this, c);
2663
2664     if(!basic_filebuf_char_is_open(this))
2665         return EOF;
2666     if(c == EOF)
2667         return !c;
2668
2669     if(!this->cvt)
2670         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2671
2672     from_next = &ch;
2673     do {
2674         ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2675                 &from_next, buf, buf+sizeof(buf), &to_next);
2676
2677         switch(ret) {
2678         case CODECVT_partial:
2679             if(to_next == buf)
2680                 break;
2681             /* fall through */
2682         case CODECVT_ok:
2683             if(!fwrite(buf, to_next-buf, 1, this->file))
2684                 return EOF;
2685             if(ret == CODECVT_partial)
2686                 continue;
2687             return c;
2688         case CODECVT_noconv:
2689             return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2690         default:
2691             return EOF;
2692         }
2693
2694         break;
2695     } while(1);
2696
2697     max_size = codecvt_base_max_length(&this->cvt->base);
2698     dyn_buf = malloc(max_size);
2699     if(!dyn_buf)
2700         return EOF;
2701
2702     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2703             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2704
2705     switch(ret) {
2706     case CODECVT_ok:
2707         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2708         free(dyn_buf);
2709         return ret ? c : EOF;
2710     case CODECVT_partial:
2711         ERR("buffer should be big enough to store all output\n");
2712         /* fall through */
2713     default:
2714         free(dyn_buf);
2715         return EOF;
2716     }
2717 }
2718
2719 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2720 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2721 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2722 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2723 {
2724     TRACE("(%p %d)\n", this, c);
2725
2726     if(!basic_filebuf_char_is_open(this))
2727         return EOF;
2728
2729     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2730             && (c==EOF || (int)(unsigned char)basic_streambuf_char_gptr(&this->base)[-1]==c)) {
2731         basic_streambuf_char__Gndec(&this->base);
2732         return c==EOF ? !c : c;
2733     }else if(c!=EOF && !this->cvt) {
2734         return ungetc(c, this->file);
2735     }
2736
2737     return EOF;
2738 }
2739
2740 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2741 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2742 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2743 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2744 {
2745     char ch, buf[128], *to_next;
2746     const char *buf_next;
2747     int c, i;
2748
2749     TRACE("(%p)\n", this);
2750
2751     if(!basic_filebuf_char_is_open(this))
2752         return EOF;
2753
2754     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2755         return (unsigned char)*basic_streambuf_char__Gninc(&this->base);
2756
2757     c = fgetc(this->file);
2758     if(!this->cvt || c==EOF)
2759         return c;
2760
2761     buf_next = buf;
2762     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
2763         buf[i] = c;
2764
2765         switch(codecvt_char_in(this->cvt, &this->state, buf_next,
2766                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2767         case CODECVT_partial:
2768         case CODECVT_ok:
2769             if(to_next == &ch) {
2770                 c = fgetc(this->file);
2771                 if(c == EOF)
2772                     return EOF;
2773                 continue;
2774             }
2775
2776             for(i--; i>=buf_next-buf; i--)
2777                 ungetc(buf[i], this->file);
2778             return ch;
2779         case CODECVT_noconv:
2780             return (unsigned char)buf[0];
2781         default:
2782             return EOF;
2783         }
2784     }
2785
2786     FIXME("buffer is too small\n");
2787     return EOF;
2788 }
2789
2790 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2791 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2792 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2793 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2794 {
2795     int ret;
2796
2797     TRACE("(%p)\n", this);
2798
2799     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2800         return (unsigned char)*basic_streambuf_char_gptr(&this->base);
2801
2802     ret = call_basic_streambuf_char_uflow(&this->base);
2803     if(ret != EOF)
2804         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2805     return ret;
2806 }
2807
2808 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2809 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2810 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 20)
2811 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2812         fpos_int *ret, streamoff off, int way, int mode)
2813 {
2814     fpos_t pos;
2815
2816     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
2817
2818     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2819             || fseek(this->file, off, way)) {
2820         ret->off = -1;
2821         ret->pos = 0;
2822         ret->state = 0;
2823         return ret;
2824     }
2825
2826     fgetpos(this->file, &pos);
2827     ret->off = 0;
2828     ret->pos = pos;
2829     ret->state = this->state;
2830     return ret;
2831 }
2832
2833 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2834 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2835 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2836 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2837         fpos_int *ret, fpos_int pos, int mode)
2838 {
2839     fpos_t fpos;
2840
2841     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2842
2843     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2844             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2845             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2846         ret->off = -1;
2847         ret->pos = 0;
2848         ret->state = 0;
2849         return ret;
2850     }
2851
2852     fgetpos(this->file, &fpos);
2853     ret->off = 0;
2854     ret->pos = fpos;
2855     ret->state = this->state;
2856     return ret;
2857 }
2858
2859 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2860 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2861 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 12)
2862 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2863 {
2864     TRACE("(%p %p %ld)\n", this, buf, count);
2865
2866     if(!basic_filebuf_char_is_open(this))
2867         return NULL;
2868
2869     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2870         return NULL;
2871
2872     basic_filebuf_char__Init(this, this->file, INITFL_open);
2873     return &this->base;
2874 }
2875
2876 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2877 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2878 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2879 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2880 {
2881     TRACE("(%p)\n", this);
2882
2883     if(!basic_filebuf_char_is_open(this))
2884         return 0;
2885
2886     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2887         return 0;
2888     return fflush(this->file);
2889 }
2890
2891 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
2892 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
2893 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_imbue, 8)
2894 void __thiscall basic_filebuf_char_imbue(basic_filebuf_char *this, const locale *loc)
2895 {
2896     TRACE("(%p %p)\n", this, loc);
2897     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(loc));
2898 }
2899
2900 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2901 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2902 int basic_filebuf_wchar__Init__Stinit = 0;
2903
2904 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2905 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2906 int basic_filebuf_short__Init__Stinit = 0;
2907
2908 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2909 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2910 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Init, 12)
2911 void __thiscall basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2912 {
2913     TRACE("(%p %p %d)\n", this, file, which);
2914
2915     this->cvt = NULL;
2916     this->wrotesome = FALSE;
2917     this->state = basic_filebuf_wchar__Init__Stinit;
2918     this->close = (which == INITFL_open);
2919     this->file = file;
2920
2921     basic_streambuf_wchar__Init_empty(&this->base);
2922 }
2923
2924 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2925 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2926 DEFINE_THISCALL_WRAPPER(basic_filebuf_short__Init, 12)
2927 void __thiscall basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2928 {
2929     TRACE("(%p %p %d)\n", this, file, which);
2930
2931     this->cvt = NULL;
2932     this->wrotesome = FALSE;
2933     this->state = basic_filebuf_short__Init__Stinit;
2934     this->close = (which == INITFL_open);
2935     this->file = file;
2936
2937     basic_streambuf_wchar__Init_empty(&this->base);
2938 }
2939
2940 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$codecvt@_WDH@2@@Z */
2941 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$codecvt@_WDH@2@@Z */
2942 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAV?$codecvt@GDH@2@@Z */
2943 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$codecvt@GDH@2@@Z */
2944 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Initcvt, 8)
2945 void __thiscall basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this, codecvt_wchar *cvt)
2946 {
2947     TRACE("(%p %p)\n", this, cvt);
2948
2949     if(codecvt_base_always_noconv(&cvt->base)) {
2950         this->cvt = NULL;
2951     }else {
2952         basic_streambuf_wchar__Init_empty(&this->base);
2953         this->cvt = cvt;
2954     }
2955 }
2956
2957 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAE_NXZ */
2958 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAA_NXZ */
2959 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAE_NXZ */
2960 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAA_NXZ */
2961 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar__Endwrite, 4)
2962 MSVCP_bool __thiscall basic_filebuf_wchar__Endwrite(basic_filebuf_wchar *this)
2963 {
2964     TRACE("(%p)\n", this);
2965
2966     if(!this->wrotesome || !this->cvt)
2967         return TRUE;
2968
2969     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2970         return FALSE;
2971
2972     while(1) {
2973         /* TODO: check if we need a dynamic buffer here */
2974         char buf[128];
2975         char *next;
2976         int ret;
2977
2978         ret = codecvt_wchar_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2979         switch(ret) {
2980         case CODECVT_ok:
2981             this->wrotesome = FALSE;
2982             /* fall through */
2983         case CODECVT_partial:
2984             if(!fwrite(buf, next-buf, 1, this->file))
2985                 return FALSE;
2986             if(this->wrotesome)
2987                 break;
2988             /* fall through */
2989         case CODECVT_noconv:
2990             if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2991                 return FALSE;
2992             return TRUE;
2993         default:
2994             return FALSE;
2995         }
2996     }
2997 }
2998
2999 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
3000 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
3001 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
3002 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
3003 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_close, 4)
3004 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_close(basic_filebuf_wchar *this)
3005 {
3006     basic_filebuf_wchar *ret = this;
3007
3008     TRACE("(%p)\n", this);
3009
3010     if(!this->file)
3011         return NULL;
3012
3013     /* TODO: handle exceptions */
3014     if(!basic_filebuf_wchar__Endwrite(this))
3015         ret = NULL;
3016     if(fclose(this->file))
3017         ret  = NULL;
3018
3019     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
3020     return ret;
3021 }
3022
3023 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
3024 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
3025 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor_file, 8)
3026 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
3027 {
3028     TRACE("(%p %p)\n", this, file);
3029
3030     basic_streambuf_wchar_ctor(&this->base);
3031     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
3032
3033     basic_filebuf_wchar__Init(this, file, INITFL_new);
3034     return this;
3035 }
3036
3037 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
3038 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
3039 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_file, 8)
3040 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
3041 {
3042     TRACE("(%p %p)\n", this, file);
3043
3044     basic_streambuf_short_ctor(&this->base);
3045     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3046
3047     basic_filebuf_short__Init(this, file, INITFL_new);
3048     return this;
3049 }
3050
3051 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
3052 /* ??_F?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
3053 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor, 4)
3054 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor(basic_filebuf_wchar *this)
3055 {
3056     return basic_filebuf_wchar_ctor_file(this, NULL);
3057 }
3058
3059 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
3060 /* ??_F?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
3061 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor, 4)
3062 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor(basic_filebuf_wchar *this)
3063 {
3064     return basic_filebuf_short_ctor_file(this, NULL);
3065 }
3066
3067 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3068 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3069 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_ctor_uninitialized, 8)
3070 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
3071 {
3072     TRACE("(%p %d)\n", this, uninitialized);
3073
3074     basic_streambuf_wchar_ctor(&this->base);
3075     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
3076     return this;
3077 }
3078
3079 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
3080 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
3081 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_ctor_uninitialized, 8)
3082 basic_filebuf_wchar* __thiscall basic_filebuf_short_ctor_uninitialized(basic_filebuf_wchar *this, int uninitialized)
3083 {
3084     TRACE("(%p %d)\n", this, uninitialized);
3085
3086     basic_streambuf_short_ctor(&this->base);
3087     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
3088     return this;
3089 }
3090
3091 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
3092 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
3093 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
3094 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
3095 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_dtor, 4)
3096 void __thiscall basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
3097 {
3098     TRACE("(%p)\n", this);
3099
3100     if(this->close)
3101         basic_filebuf_wchar_close(this);
3102     basic_streambuf_wchar_dtor(&this->base);
3103 }
3104
3105 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
3106 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
3107 {
3108     TRACE("(%p %x)\n", this, flags);
3109     if(flags & 2) {
3110         /* we have an array, with the number of elements stored before the first object */
3111         INT_PTR i, *ptr = (INT_PTR *)this-1;
3112
3113         for(i=*ptr-1; i>=0; i--)
3114             basic_filebuf_wchar_dtor(this+i);
3115         MSVCRT_operator_delete(ptr);
3116     } else {
3117         basic_filebuf_wchar_dtor(this);
3118         if(flags & 1)
3119             MSVCRT_operator_delete(this);
3120     }
3121
3122     return this;
3123 }
3124
3125 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
3126 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
3127 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
3128 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
3129 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_is_open, 4)
3130 MSVCP_bool __thiscall basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
3131 {
3132     TRACE("(%p)\n", this);
3133     return this->file != NULL;
3134 }
3135
3136 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PB_WHH@Z */
3137 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3138 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBGHH@Z */
3139 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3140 static basic_filebuf_wchar* basic_filebuf_wchar_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3141 {
3142     FILE *f = NULL;
3143
3144     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3145
3146     if(basic_filebuf_wchar_is_open(this))
3147         return NULL;
3148
3149     if(!(f = _Fiopen_wchar(name, mode, prot)))
3150         return NULL;
3151
3152     basic_filebuf_wchar__Init(this, f, INITFL_open);
3153     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(this->base.loc));
3154     return this;
3155 }
3156
3157 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PB_WHH@Z */
3158 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEB_WHH@Z */
3159 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBGHH@Z */
3160 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBGHH@Z */
3161 static basic_filebuf_wchar* basic_filebuf_short_open_wchar(basic_filebuf_wchar *this, const wchar_t *name, int mode, int prot)
3162 {
3163     FILE *f = NULL;
3164
3165     TRACE("(%p %s %d %d)\n", this, debugstr_w(name), mode, prot);
3166
3167     if(basic_filebuf_wchar_is_open(this))
3168         return NULL;
3169
3170     if(!(f = _Fiopen_wchar(name, mode, prot)))
3171         return NULL;
3172
3173     basic_filebuf_short__Init(this, f, INITFL_open);
3174     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(this->base.loc));
3175     return this;
3176 }
3177
3178 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDHH@Z */
3179 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3180 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open, 16)
3181 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3182 {
3183     wchar_t nameW[FILENAME_MAX];
3184
3185     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3186
3187     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3188         return NULL;
3189     return basic_filebuf_wchar_open_wchar(this, nameW, mode, prot);
3190 }
3191
3192 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDHH@Z */
3193 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDHH@Z */
3194 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open, 16)
3195 basic_filebuf_wchar* __thiscall basic_filebuf_short_open(basic_filebuf_wchar *this, const char *name, int mode, int prot)
3196 {
3197     wchar_t nameW[FILENAME_MAX];
3198
3199     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
3200
3201     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
3202         return NULL;
3203     return basic_filebuf_short_open_wchar(this, nameW, mode, prot);
3204 }
3205
3206 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PBDI@Z */
3207 /* ?open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEBDI@Z */
3208 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_open_mode, 12)
3209 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_open_mode(basic_filebuf_wchar *this, const char *name, unsigned int mode)
3210 {
3211     return basic_filebuf_wchar_open(this, name, mode, SH_DENYNO);
3212 }
3213
3214 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PBDI@Z */
3215 /* ?open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEBDI@Z */
3216 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_open_mode, 12)
3217 basic_filebuf_wchar* __thiscall basic_filebuf_short_open_mode(basic_filebuf_wchar *this, const char *name, unsigned int mode)
3218 {
3219     return basic_filebuf_short_open(this, name, mode, SH_DENYNO);
3220 }
3221
3222 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3223 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3224 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3225 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3226 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
3227 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
3228 {
3229     char buf[8], *dyn_buf, *to_next;
3230     wchar_t ch = c;
3231     const wchar_t *from_next;
3232     int max_size;
3233     unsigned short ret;
3234
3235
3236     TRACE("(%p %d)\n", this, c);
3237
3238     if(!basic_filebuf_wchar_is_open(this))
3239         return WEOF;
3240     if(c == WEOF)
3241         return !c;
3242
3243     if(!this->cvt)
3244         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3245
3246     from_next = &ch;
3247     do {
3248         ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3249                 &from_next, buf, buf+sizeof(buf), &to_next);
3250
3251         switch(ret) {
3252         case CODECVT_partial:
3253             if(to_next == buf)
3254                 break;
3255             /* fall through */
3256         case CODECVT_ok:
3257             if(!fwrite(buf, to_next-buf, 1, this->file))
3258                 return WEOF;
3259             if(ret == CODECVT_partial)
3260                 continue;
3261             return c;
3262         case CODECVT_noconv:
3263             return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
3264         default:
3265             return WEOF;
3266         }
3267
3268         break;
3269     } while(1);
3270
3271     max_size = codecvt_base_max_length(&this->cvt->base);
3272     dyn_buf = malloc(max_size);
3273     if(!dyn_buf)
3274         return WEOF;
3275
3276     ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
3277             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
3278
3279     switch(ret) {
3280     case CODECVT_ok:
3281         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
3282         free(dyn_buf);
3283         return ret ? c : WEOF;
3284     case CODECVT_partial:
3285         ERR("buffer should be big enough to store all output\n");
3286         /* fall through */
3287     default:
3288         free(dyn_buf);
3289         return WEOF;
3290     }
3291 }
3292
3293 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
3294 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
3295 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
3296 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
3297 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
3298 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
3299 {
3300     TRACE("(%p %d)\n", this, c);
3301
3302     if(!basic_filebuf_wchar_is_open(this))
3303         return WEOF;
3304
3305     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
3306             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==c)) {
3307         basic_streambuf_wchar__Gndec(&this->base);
3308         return c==WEOF ? !c : c;
3309     }else if(c!=WEOF && !this->cvt) {
3310         return ungetwc(c, this->file);
3311     }else if(c!=WEOF && basic_streambuf_wchar_gptr(&this->base)!=&this->putback) {
3312         this->putback = c;
3313         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback, &this->putback+1);
3314         return c;
3315     }
3316
3317     return WEOF;
3318 }
3319
3320 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3321 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3322 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3323 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3324 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
3325 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
3326 {
3327     wchar_t ch, *to_next;
3328     char buf[128];
3329     const char *buf_next;
3330     int c, i;
3331
3332     TRACE("(%p)\n", this);
3333
3334     if(!basic_filebuf_wchar_is_open(this))
3335         return WEOF;
3336
3337     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3338         return *basic_streambuf_wchar__Gninc(&this->base);
3339
3340     if(!this->cvt)
3341         return fgetwc(this->file);
3342
3343     buf_next = buf;
3344     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
3345         if((c = fgetc(this->file)) == EOF)
3346             return WEOF;
3347         buf[i] = c;
3348
3349         switch(codecvt_wchar_in(this->cvt, &this->state, buf_next,
3350                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
3351         case CODECVT_partial:
3352         case CODECVT_ok:
3353             if(to_next == &ch)
3354                 continue;
3355
3356             for(i--; i>=buf_next-buf; i--)
3357                 ungetc(buf[i], this->file);
3358             return ch;
3359         case CODECVT_noconv:
3360             if(i+1 < sizeof(wchar_t))
3361                 continue;
3362
3363             memcpy(&ch, buf, sizeof(wchar_t));
3364             return ch;
3365         default:
3366             return WEOF;
3367         }
3368     }
3369
3370     FIXME("buffer is too small\n");
3371     return WEOF;
3372 }
3373
3374 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
3375 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
3376 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
3377 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
3378 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
3379 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
3380 {
3381     unsigned short ret;
3382
3383     TRACE("(%p)\n", this);
3384
3385     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
3386         return *basic_streambuf_wchar_gptr(&this->base);
3387
3388     ret = call_basic_streambuf_wchar_uflow(&this->base);
3389     if(ret != WEOF)
3390         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
3391     return ret;
3392 }
3393
3394 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3395 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3396 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3397 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3398 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 20)
3399 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
3400         fpos_int *ret, streamoff off, int way, int mode)
3401 {
3402     fpos_t pos;
3403
3404     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3405
3406     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback) {
3407         if(way == SEEKDIR_cur)
3408             off -= sizeof(wchar_t);
3409
3410         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3411     }
3412
3413     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3414             || fseek(this->file, off, way)) {
3415         ret->off = -1;
3416         ret->pos = 0;
3417         ret->state = 0;
3418         return ret;
3419     }
3420
3421     fgetpos(this->file, &pos);
3422     ret->off = 0;
3423     ret->pos = pos;
3424     ret->state = this->state;
3425     return ret;
3426 }
3427
3428 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3429 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3430 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3431 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3432 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
3433 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
3434         fpos_int *ret, fpos_int pos, int mode)
3435 {
3436     fpos_t fpos;
3437
3438     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3439
3440     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
3441             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
3442             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
3443         ret->off = -1;
3444         ret->pos = 0;
3445         ret->state = 0;
3446         return ret;
3447     }
3448
3449     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback)
3450         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
3451
3452     fgetpos(this->file, &fpos);
3453     ret->off = 0;
3454     ret->pos = fpos;
3455     ret->state = this->state;
3456     return ret;
3457 }
3458
3459 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
3460 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
3461 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 12)
3462 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3463 {
3464     TRACE("(%p %p %ld)\n", this, buf, count);
3465
3466     if(!basic_filebuf_wchar_is_open(this))
3467         return NULL;
3468
3469     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3470         return NULL;
3471
3472     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
3473     return &this->base;
3474 }
3475
3476 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
3477 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
3478 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 12)
3479 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
3480 {
3481     TRACE("(%p %p %ld)\n", this, buf, count);
3482
3483     if(!basic_filebuf_wchar_is_open(this))
3484         return NULL;
3485
3486     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
3487         return NULL;
3488
3489     basic_filebuf_short__Init(this, this->file, INITFL_open);
3490     return &this->base;
3491 }
3492
3493 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
3494 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
3495 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
3496 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
3497 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
3498 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
3499 {
3500     TRACE("(%p)\n", this);
3501
3502     if(!basic_filebuf_wchar_is_open(this))
3503         return 0;
3504
3505     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
3506         return 0;
3507     return fflush(this->file);
3508 }
3509
3510 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
3511 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
3512 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_imbue, 8)
3513 void __thiscall basic_filebuf_wchar_imbue(basic_filebuf_wchar *this, const locale *loc)
3514 {
3515     TRACE("(%p %p)\n", this, loc);
3516     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(loc));
3517 }
3518
3519 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
3520 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
3521 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_imbue, 8)
3522 void __thiscall basic_filebuf_short_imbue(basic_filebuf_wchar *this, const locale *loc)
3523 {
3524     TRACE("(%p %p)\n", this, loc);
3525     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(loc));
3526 }
3527
3528 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAEHH@Z */
3529 /* ?_Getstate@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEAAHH@Z */
3530 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Getstate, 8)
3531 int __thiscall basic_stringbuf_char__Getstate(basic_stringbuf_char *this, IOSB_openmode mode)
3532 {
3533     int state = 0;
3534
3535     if(!(mode & OPENMODE_in))
3536         state |= STRINGBUF_no_read;
3537
3538     if(!(mode & OPENMODE_out))
3539         state |= STRINGBUF_no_write;
3540
3541     if(mode & OPENMODE_ate)
3542         state |= STRINGBUF_at_end;
3543
3544     if(mode & OPENMODE_app)
3545         state |= STRINGBUF_append;
3546
3547     return state;
3548 }
3549
3550 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXPBDIH@Z */
3551 /* ?_Init@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXPEBD_KH@Z */
3552 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Init, 16)
3553 void __thiscall basic_stringbuf_char__Init(basic_stringbuf_char *this, const char *str, MSVCP_size_t count, int state)
3554 {
3555     TRACE("(%p, %p, %ld, %d)\n", this, str, count, state);
3556
3557     basic_streambuf_char__Init_empty(&this->base);
3558
3559     this->state = state;
3560     this->seekhigh = NULL;
3561
3562     if(count && str) {
3563         char *buf = MSVCRT_operator_new(count);
3564         if(!buf) {
3565             ERR("Out of memory\n");
3566             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3567         }
3568
3569         memcpy(buf, str, count);
3570         this->seekhigh = buf + count;
3571
3572         this->state |= STRINGBUF_allocated;
3573
3574         if(!(state & STRINGBUF_no_read))
3575             basic_streambuf_char_setg(&this->base, buf, buf, buf + count);
3576
3577         if(!(state & STRINGBUF_no_write)) {
3578             basic_streambuf_char_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3579
3580             if(!basic_streambuf_char_gptr(&this->base))
3581                 basic_streambuf_char_setg(&this->base, buf, 0, buf);
3582         }
3583     }
3584 }
3585
3586 /* ??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 */
3587 /* ??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 */
3588 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_str, 12)
3589 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_str(basic_stringbuf_char *this,
3590         const basic_string_char *str, IOSB_openmode mode)
3591 {
3592     TRACE("(%p %p %d)\n", this, str, mode);
3593
3594     basic_streambuf_char_ctor(&this->base);
3595     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3596
3597     basic_stringbuf_char__Init(this, MSVCP_basic_string_char_c_str(str),
3598             str->size, basic_stringbuf_char__Getstate(this, mode));
3599     return this;
3600 }
3601
3602 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
3603 /* ??0?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
3604 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor_mode, 8)
3605 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor_mode(
3606         basic_stringbuf_char *this, IOSB_openmode mode)
3607 {
3608     TRACE("(%p %d)\n", this, mode);
3609
3610     basic_streambuf_char_ctor(&this->base);
3611     this->base.vtable = &MSVCP_basic_stringbuf_char_vtable;
3612
3613     basic_stringbuf_char__Init(this, NULL, 0, basic_stringbuf_char__Getstate(this, mode));
3614     return this;
3615 }
3616
3617 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
3618 /* ??_F?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
3619 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_ctor, 4)
3620 basic_stringbuf_char* __thiscall basic_stringbuf_char_ctor(basic_stringbuf_char *this)
3621 {
3622     return basic_stringbuf_char_ctor_mode(this, OPENMODE_in|OPENMODE_out);
3623 }
3624
3625 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IAEXXZ */
3626 /* ?_Tidy@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IEAAXXZ */
3627 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char__Tidy, 4)
3628 void __thiscall basic_stringbuf_char__Tidy(basic_stringbuf_char *this)
3629 {
3630     TRACE("(%p)\n", this);
3631
3632     if(this->state & STRINGBUF_allocated) {
3633         MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
3634         this->seekhigh = NULL;
3635         this->state &= ~STRINGBUF_allocated;
3636     }
3637
3638     basic_streambuf_char__Init_empty(&this->base);
3639 }
3640
3641 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
3642 /* ??1?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
3643 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_dtor, 4)
3644 void __thiscall basic_stringbuf_char_dtor(basic_stringbuf_char *this)
3645 {
3646     TRACE("(%p)\n", this);
3647
3648     basic_stringbuf_char__Tidy(this);
3649     basic_streambuf_char_dtor(&this->base);
3650 }
3651
3652 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_vector_dtor, 8)
3653 basic_stringbuf_char* __thiscall basic_stringbuf_char_vector_dtor(basic_stringbuf_char *this, unsigned int flags)
3654 {
3655     TRACE("(%p %x)\n", this, flags);
3656
3657     if(flags & 2) {
3658         /* we have an array, with the number of elements stored before the first object */
3659         INT_PTR i, *ptr = (INT_PTR *) this - 1;
3660
3661         for (i = *ptr - 1; i >= 0; i--)
3662             basic_stringbuf_char_dtor(this+i);
3663
3664         MSVCRT_operator_delete(ptr);
3665     }else {
3666         basic_stringbuf_char_dtor(this);
3667
3668         if(flags & 1)
3669             MSVCRT_operator_delete(this);
3670     }
3671
3672     return this;
3673 }
3674
3675 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3676 /* ?overflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3677 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_overflow, 8)
3678 int __thiscall basic_stringbuf_char_overflow(basic_stringbuf_char *this, int meta)
3679 {
3680     MSVCP_size_t oldsize, size;
3681     char *ptr, *buf;
3682
3683     TRACE("(%p %x)\n", this, meta);
3684
3685     if(meta == EOF)
3686         return !EOF;
3687     if(this->state & STRINGBUF_no_write)
3688         return EOF;
3689
3690     ptr = basic_streambuf_char_pptr(&this->base);
3691     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
3692         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
3693                 this->seekhigh, basic_streambuf_char_epptr(&this->base));
3694
3695     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
3696         return (*basic_streambuf_char__Pninc(&this->base) = meta);
3697
3698     oldsize = (ptr ? basic_streambuf_char_epptr(&this->base)-basic_streambuf_char_eback(&this->base): 0);
3699     size = oldsize|0xf;
3700     size += size/2;
3701     buf = MSVCRT_operator_new(size);
3702     if(!buf) {
3703         ERR("Out of memory\n");
3704         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3705     }
3706
3707     if(!oldsize) {
3708         this->seekhigh = buf;
3709         basic_streambuf_char_setp(&this->base, buf, buf+size);
3710         if(this->state & STRINGBUF_no_read)
3711             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3712         else
3713             basic_streambuf_char_setg(&this->base, buf, buf, buf+1);
3714
3715         this->state |= STRINGBUF_allocated;
3716     }else {
3717         ptr = basic_streambuf_char_eback(&this->base);
3718         memcpy(buf, ptr, oldsize);
3719
3720         this->seekhigh = buf+(this->seekhigh-ptr);
3721         basic_streambuf_char_setp_next(&this->base, buf,
3722                 buf+(basic_streambuf_char_pptr(&this->base)-ptr), buf+size);
3723         if(this->state & STRINGBUF_no_read)
3724             basic_streambuf_char_setg(&this->base, buf, NULL, buf);
3725         else
3726             basic_streambuf_char_setg(&this->base, buf,
3727                     buf+(basic_streambuf_char_gptr(&this->base)-ptr),
3728                     basic_streambuf_char_pptr(&this->base)+1);
3729
3730         MSVCRT_operator_delete(ptr);
3731     }
3732
3733     return (*basic_streambuf_char__Pninc(&this->base) = meta);
3734 }
3735
3736 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHH@Z */
3737 /* ?pbackfail@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHH@Z */
3738 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_pbackfail, 8)
3739 int __thiscall basic_stringbuf_char_pbackfail(basic_stringbuf_char *this, int c)
3740 {
3741     char *cur;
3742
3743     TRACE("(%p %x)\n", this, c);
3744
3745     cur = basic_streambuf_char_gptr(&this->base);
3746     if(!cur || cur==basic_streambuf_char_eback(&this->base)
3747             || (c!=EOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
3748         return EOF;
3749
3750     if(c != EOF)
3751         cur[-1] = c;
3752     basic_streambuf_char_gbump(&this->base, -1);
3753     return c==EOF ? !EOF : c;
3754 }
3755
3756 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAEHXZ */
3757 /* ?underflow@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAAHXZ */
3758 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_underflow, 4)
3759 int __thiscall basic_stringbuf_char_underflow(basic_stringbuf_char *this)
3760 {
3761     char *ptr, *cur;
3762
3763     TRACE("(%p)\n", this);
3764
3765     cur = basic_streambuf_char_gptr(&this->base);
3766     if(!cur || this->state&STRINGBUF_no_read)
3767         return EOF;
3768
3769     ptr  = basic_streambuf_char_pptr(&this->base);
3770     if(this->seekhigh < ptr)
3771         this->seekhigh = ptr;
3772
3773     ptr = basic_streambuf_char_egptr(&this->base);
3774     if(this->seekhigh > ptr)
3775         basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base), cur, this->seekhigh);
3776
3777     if(cur < this->seekhigh)
3778         return (unsigned char)*cur;
3779     return EOF;
3780 }
3781
3782 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
3783 /* ?seekoff@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
3784 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekoff, 20)
3785 fpos_int* __thiscall basic_stringbuf_char_seekoff(basic_stringbuf_char *this,
3786         fpos_int *ret, streamoff off, int way, int mode)
3787 {
3788     char *beg, *cur_r, *cur_w;
3789
3790     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
3791
3792     cur_w = basic_streambuf_char_pptr(&this->base);
3793     if(cur_w > this->seekhigh)
3794         this->seekhigh = cur_w;
3795
3796     ret->off = 0;
3797     ret->pos = 0;
3798     ret->state = 0;
3799
3800     beg = basic_streambuf_char_eback(&this->base);
3801     cur_r = basic_streambuf_char_gptr(&this->base);
3802     if((mode & OPENMODE_in) && cur_r) {
3803         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
3804             off += cur_r-beg;
3805         else if(way == SEEKDIR_end)
3806             off += this->seekhigh-beg;
3807         else if(way != SEEKDIR_beg)
3808             off = -1;
3809
3810         if(off<0 || off>this->seekhigh-beg) {
3811             off = -1;
3812         }else {
3813             basic_streambuf_char_gbump(&this->base, beg-cur_r+off);
3814             if((mode & OPENMODE_out) && cur_w) {
3815                 basic_streambuf_char_setp_next(&this->base, beg,
3816                         basic_streambuf_char_gptr(&this->base),
3817                         basic_streambuf_char_epptr(&this->base));
3818             }
3819         }
3820     }else if((mode & OPENMODE_out) && cur_w) {
3821         if(way == SEEKDIR_cur)
3822             off += cur_w-beg;
3823         else if(way == SEEKDIR_end)
3824             off += this->seekhigh-beg;
3825         else if(way != SEEKDIR_beg)
3826             off = -1;
3827
3828         if(off<0 || off>this->seekhigh-beg)
3829             off = -1;
3830         else
3831             basic_streambuf_char_pbump(&this->base, beg-cur_w+off);
3832     }else {
3833         off = -1;
3834     }
3835
3836     ret->off = off;
3837     return ret;
3838 }
3839
3840 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
3841 /* ?seekpos@?$basic_stringbuf@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
3842 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_seekpos, 36)
3843 fpos_int* __thiscall basic_stringbuf_char_seekpos(basic_stringbuf_char *this,
3844         fpos_int *ret, fpos_int pos, int mode)
3845 {
3846     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
3847
3848     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
3849         *ret = pos;
3850         return ret;
3851     }
3852
3853     return basic_stringbuf_char_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
3854 }
3855
3856 /* ?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 */
3857 /* ?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 */
3858 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_set, 8)
3859 void __thiscall basic_stringbuf_char_str_set(basic_stringbuf_char *this, const basic_string_char *str)
3860 {
3861     TRACE("(%p %p)\n", this, str);
3862
3863     basic_stringbuf_char__Tidy(this);
3864     basic_stringbuf_char__Init(this, MSVCP_basic_string_char_c_str(str), str->size, this->state);
3865 }
3866
3867 /* ?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 */
3868 /* ?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 */
3869 DEFINE_THISCALL_WRAPPER(basic_stringbuf_char_str_get, 8)
3870 basic_string_char* __thiscall basic_stringbuf_char_str_get(const basic_stringbuf_char *this, basic_string_char *ret)
3871 {
3872     char *ptr;
3873
3874     TRACE("(%p)\n", this);
3875
3876     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_char_pptr(&this->base)) {
3877         char *pptr;
3878
3879         ptr = basic_streambuf_char_pbase(&this->base);
3880         pptr = basic_streambuf_char_pptr(&this->base);
3881
3882         return MSVCP_basic_string_char_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
3883     }
3884
3885     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_char_gptr(&this->base)) {
3886         ptr = basic_streambuf_char_eback(&this->base);
3887         return MSVCP_basic_string_char_ctor_cstr_len(ret, ptr, basic_streambuf_char_egptr(&this->base) - ptr);
3888     }
3889
3890     return MSVCP_basic_string_char_ctor(ret);
3891 }
3892
3893 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AAEHH@Z */
3894 /* ?_Getstate@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@AEAAHH@Z */
3895 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AAEHH@Z */
3896 /* ?_Getstate@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@AEAAHH@Z */
3897 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Getstate, 8)
3898 int __thiscall basic_stringbuf_wchar__Getstate(basic_stringbuf_wchar *this, IOSB_openmode mode)
3899 {
3900     int state = 0;
3901
3902     if(!(mode & OPENMODE_in))
3903         state |= STRINGBUF_no_read;
3904
3905     if(!(mode & OPENMODE_out))
3906         state |= STRINGBUF_no_write;
3907
3908     if(mode & OPENMODE_ate)
3909         state |= STRINGBUF_at_end;
3910
3911     if(mode & OPENMODE_app)
3912         state |= STRINGBUF_append;
3913
3914     return state;
3915 }
3916
3917 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXPB_WIH@Z */
3918 /* ?_Init@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXPEB_W_KH@Z */
3919 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXPBGIH@Z */
3920 /* ?_Init@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXPEBG_KH@Z */
3921 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Init, 16)
3922 void __thiscall basic_stringbuf_wchar__Init(basic_stringbuf_wchar *this, const wchar_t *str, MSVCP_size_t count, int state)
3923 {
3924     TRACE("(%p, %p, %lu, %d)\n", this, str, count, state);
3925
3926     basic_streambuf_wchar__Init_empty(&this->base);
3927
3928     this->state = state;
3929     this->seekhigh = NULL;
3930
3931     if(count && str) {
3932         wchar_t *buf = MSVCRT_operator_new(count*sizeof(wchar_t));
3933         if(!buf) {
3934             ERR("Out of memory\n");
3935             throw_exception(EXCEPTION_BAD_ALLOC, NULL);
3936         }
3937
3938         memcpy(buf, str, count*sizeof(wchar_t));
3939         this->seekhigh = buf + count;
3940
3941         this->state |= STRINGBUF_allocated;
3942
3943         if(!(state & STRINGBUF_no_read))
3944             basic_streambuf_wchar_setg(&this->base, buf, buf, buf + count);
3945
3946         if(!(state & STRINGBUF_no_write)) {
3947             basic_streambuf_wchar_setp_next(&this->base, buf, (state & STRINGBUF_at_end) ? buf + count : buf, buf + count);
3948
3949             if(!basic_streambuf_wchar_gptr(&this->base))
3950                 basic_streambuf_wchar_setg(&this->base, buf, 0, buf);
3951         }
3952     }
3953 }
3954
3955 /* ??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 */
3956 /* ??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 */
3957 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor_str, 12)
3958 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor_str(basic_stringbuf_wchar *this,
3959         const basic_string_wchar *str, IOSB_openmode mode)
3960 {
3961     TRACE("(%p %p %d)\n", this, str, mode);
3962
3963     basic_streambuf_wchar_ctor(&this->base);
3964     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3965
3966     basic_stringbuf_wchar__Init(this, MSVCP_basic_string_wchar_c_str(str),
3967             str->size, basic_stringbuf_wchar__Getstate(this, mode));
3968     return this;
3969 }
3970
3971 /* ??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 */
3972 /* ??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 */
3973 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_str, 12)
3974 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_str(basic_stringbuf_wchar *this,
3975         const basic_string_wchar *str, IOSB_openmode mode)
3976 {
3977     basic_stringbuf_wchar_ctor_str(this, str, mode);
3978     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
3979     return this;
3980 }
3981
3982 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
3983 /* ??0?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
3984 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor_mode, 8)
3985 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor_mode(
3986         basic_stringbuf_wchar *this, IOSB_openmode mode)
3987 {
3988     TRACE("(%p %d)\n", this, mode);
3989
3990     basic_streambuf_wchar_ctor(&this->base);
3991     this->base.vtable = &MSVCP_basic_stringbuf_wchar_vtable;
3992
3993     basic_stringbuf_wchar__Init(this, NULL, 0, basic_stringbuf_wchar__Getstate(this, mode));
3994     return this;
3995 }
3996
3997 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
3998 /* ??0?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
3999 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor_mode, 8)
4000 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor_mode(
4001         basic_stringbuf_wchar *this, IOSB_openmode mode)
4002 {
4003     basic_stringbuf_wchar_ctor_mode(this, mode);
4004     this->base.vtable = &MSVCP_basic_stringbuf_short_vtable;
4005     return this;
4006 }
4007
4008 /* ??_F?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
4009 /* ??_F?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
4010 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_ctor, 4)
4011 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_ctor(basic_stringbuf_wchar *this)
4012 {
4013     return basic_stringbuf_wchar_ctor_mode(this, OPENMODE_in|OPENMODE_out);
4014 }
4015
4016 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
4017 /* ??_F?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
4018 DEFINE_THISCALL_WRAPPER(basic_stringbuf_short_ctor, 4)
4019 basic_stringbuf_wchar* __thiscall basic_stringbuf_short_ctor(basic_stringbuf_wchar *this)
4020 {
4021     return basic_stringbuf_short_ctor_mode(this, OPENMODE_in|OPENMODE_out);
4022 }
4023
4024 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IAEXXZ */
4025 /* ?_Tidy@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@IEAAXXZ */
4026 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IAEXXZ */
4027 /* ?_Tidy@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@IEAAXXZ */
4028 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar__Tidy, 4)
4029 void __thiscall basic_stringbuf_wchar__Tidy(basic_stringbuf_wchar *this)
4030 {
4031     TRACE("(%p)\n", this);
4032
4033     if(this->state & STRINGBUF_allocated) {
4034         MSVCRT_operator_delete(basic_streambuf_wchar_eback(&this->base));
4035         this->seekhigh = NULL;
4036         this->state &= ~STRINGBUF_allocated;
4037     }
4038
4039     basic_streambuf_wchar__Init_empty(&this->base);
4040 }
4041
4042 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
4043 /* ??1?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
4044 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
4045 /* ??1?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
4046 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_dtor, 4)
4047 void __thiscall basic_stringbuf_wchar_dtor(basic_stringbuf_wchar *this)
4048 {
4049     TRACE("(%p)\n", this);
4050
4051     basic_stringbuf_wchar__Tidy(this);
4052     basic_streambuf_wchar_dtor(&this->base);
4053 }
4054
4055 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_vector_dtor, 8)
4056 basic_stringbuf_wchar* __thiscall basic_stringbuf_wchar_vector_dtor(basic_stringbuf_wchar *this, unsigned int flags)
4057 {
4058     TRACE("(%p %x)\n", this, flags);
4059
4060     if(flags & 2) {
4061         /* we have an array, with the number of elements stored before the first object */
4062         INT_PTR i, *ptr = (INT_PTR *) this - 1;
4063
4064         for (i = *ptr - 1; i >= 0; i--)
4065             basic_stringbuf_wchar_dtor(this+i);
4066
4067         MSVCRT_operator_delete(ptr);
4068     }else {
4069         basic_stringbuf_wchar_dtor(this);
4070
4071         if(flags & 1)
4072             MSVCRT_operator_delete(this);
4073     }
4074
4075     return this;
4076 }
4077
4078 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4079 /* ?overflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4080 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4081 /* ?overflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4082 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_overflow, 8)
4083 unsigned short __thiscall basic_stringbuf_wchar_overflow(basic_stringbuf_wchar *this, unsigned short meta)
4084 {
4085     MSVCP_size_t oldsize, size;
4086     wchar_t *ptr, *buf;
4087
4088     TRACE("(%p %x)\n", this, meta);
4089
4090     if(meta == WEOF)
4091         return !WEOF;
4092     if(this->state & STRINGBUF_no_write)
4093         return WEOF;
4094
4095     ptr = basic_streambuf_wchar_pptr(&this->base);
4096     if((this->state&STRINGBUF_append) && ptr<this->seekhigh)
4097         basic_streambuf_wchar_setp_next(&this->base, basic_streambuf_wchar_pbase(&this->base),
4098                 this->seekhigh, basic_streambuf_wchar_epptr(&this->base));
4099
4100     if(ptr && ptr<basic_streambuf_wchar_epptr(&this->base))
4101         return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4102
4103     oldsize = (ptr ? basic_streambuf_wchar_epptr(&this->base)-basic_streambuf_wchar_eback(&this->base): 0);
4104     size = oldsize|0xf;
4105     size += size/2;
4106     buf = MSVCRT_operator_new(size*sizeof(wchar_t));
4107     if(!buf) {
4108         ERR("Out of memory\n");
4109         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
4110     }
4111
4112     if(!oldsize) {
4113         this->seekhigh = buf;
4114         basic_streambuf_wchar_setp(&this->base, buf, buf+size);
4115         if(this->state & STRINGBUF_no_read)
4116             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4117         else
4118             basic_streambuf_wchar_setg(&this->base, buf, buf, buf+1);
4119
4120         this->state |= STRINGBUF_allocated;
4121     }else {
4122         ptr = basic_streambuf_wchar_eback(&this->base);
4123         memcpy(buf, ptr, oldsize*sizeof(wchar_t));
4124
4125         this->seekhigh = buf+(this->seekhigh-ptr);
4126         basic_streambuf_wchar_setp_next(&this->base, buf,
4127                 buf+(basic_streambuf_wchar_pptr(&this->base)-ptr), buf+size);
4128         if(this->state & STRINGBUF_no_read)
4129             basic_streambuf_wchar_setg(&this->base, buf, NULL, buf);
4130         else
4131             basic_streambuf_wchar_setg(&this->base, buf,
4132                     buf+(basic_streambuf_wchar_gptr(&this->base)-ptr),
4133                     basic_streambuf_wchar_pptr(&this->base)+1);
4134
4135         MSVCRT_operator_delete(ptr);
4136     }
4137
4138     return (*basic_streambuf_wchar__Pninc(&this->base) = meta);
4139 }
4140
4141 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGG@Z */
4142 /* ?pbackfail@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGG@Z */
4143 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGG@Z */
4144 /* ?pbackfail@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGG@Z */
4145 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_pbackfail, 8)
4146 unsigned short __thiscall basic_stringbuf_wchar_pbackfail(basic_stringbuf_wchar *this, unsigned short c)
4147 {
4148     wchar_t *cur;
4149
4150     TRACE("(%p %x)\n", this, c);
4151
4152     cur = basic_streambuf_wchar_gptr(&this->base);
4153     if(!cur || cur==basic_streambuf_wchar_eback(&this->base)
4154             || (c!=WEOF && c!=cur[-1] && this->state&STRINGBUF_no_write))
4155         return WEOF;
4156
4157     if(c != WEOF)
4158         cur[-1] = c;
4159     basic_streambuf_wchar_gbump(&this->base, -1);
4160     return c==WEOF ? !WEOF : c;
4161 }
4162
4163 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAEGXZ */
4164 /* ?underflow@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAAGXZ */
4165 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAEGXZ */
4166 /* ?underflow@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAAGXZ */
4167 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_underflow, 4)
4168 unsigned short __thiscall basic_stringbuf_wchar_underflow(basic_stringbuf_wchar *this)
4169 {
4170     wchar_t *ptr, *cur;
4171
4172     TRACE("(%p)\n", this);
4173
4174     cur = basic_streambuf_wchar_gptr(&this->base);
4175     if(!cur || this->state&STRINGBUF_no_read)
4176         return WEOF;
4177
4178     ptr  = basic_streambuf_wchar_pptr(&this->base);
4179     if(this->seekhigh < ptr)
4180         this->seekhigh = ptr;
4181
4182     ptr = basic_streambuf_wchar_egptr(&this->base);
4183     if(this->seekhigh > ptr)
4184         basic_streambuf_wchar_setg(&this->base, basic_streambuf_wchar_eback(&this->base), cur, this->seekhigh);
4185
4186     if(cur < this->seekhigh)
4187         return *cur;
4188     return WEOF;
4189 }
4190
4191 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4192 /* ?seekoff@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4193 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@JHH@Z */
4194 /* ?seekoff@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
4195 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekoff, 20)
4196 fpos_int* __thiscall basic_stringbuf_wchar_seekoff(basic_stringbuf_wchar *this,
4197         fpos_int *ret, streamoff off, int way, int mode)
4198 {
4199     wchar_t *beg, *cur_r, *cur_w;
4200
4201     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
4202
4203     cur_w = basic_streambuf_wchar_pptr(&this->base);
4204     if(cur_w > this->seekhigh)
4205         this->seekhigh = cur_w;
4206
4207     ret->off = 0;
4208     ret->pos = 0;
4209     ret->state = 0;
4210
4211     beg = basic_streambuf_wchar_eback(&this->base);
4212     cur_r = basic_streambuf_wchar_gptr(&this->base);
4213     if((mode & OPENMODE_in) && cur_r) {
4214         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
4215             off += cur_r-beg;
4216         else if(way == SEEKDIR_end)
4217             off += this->seekhigh-beg;
4218         else if(way != SEEKDIR_beg)
4219             off = -1;
4220
4221         if(off<0 || off>this->seekhigh-beg) {
4222             off = -1;
4223         }else {
4224             basic_streambuf_wchar_gbump(&this->base, beg-cur_r+off);
4225             if((mode & OPENMODE_out) && cur_w) {
4226                 basic_streambuf_wchar_setp_next(&this->base, beg,
4227                         basic_streambuf_wchar_gptr(&this->base),
4228                         basic_streambuf_wchar_epptr(&this->base));
4229             }
4230         }
4231     }else if((mode & OPENMODE_out) && cur_w) {
4232         if(way == SEEKDIR_cur)
4233             off += cur_w-beg;
4234         else if(way == SEEKDIR_end)
4235             off += this->seekhigh-beg;
4236         else if(way != SEEKDIR_beg)
4237             off = -1;
4238
4239         if(off<0 || off>this->seekhigh-beg)
4240             off = -1;
4241         else
4242             basic_streambuf_wchar_pbump(&this->base, beg-cur_w+off);
4243     }else {
4244         off = -1;
4245     }
4246
4247     ret->off = off;
4248     return ret;
4249 }
4250
4251 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4252 /* ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4253 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
4254 /* ?seekpos@?$basic_stringbuf@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
4255 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_seekpos, 36)
4256 fpos_int* __thiscall basic_stringbuf_wchar_seekpos(basic_stringbuf_wchar *this,
4257         fpos_int *ret, fpos_int pos, int mode)
4258 {
4259     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
4260
4261     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
4262         *ret = pos;
4263         return ret;
4264     }
4265
4266     return basic_stringbuf_wchar_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
4267 }
4268
4269 /* ?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 */
4270 /* ?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 */
4271 /* ?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 */
4272 /* ?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 */
4273 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_set, 8)
4274 void __thiscall basic_stringbuf_wchar_str_set(basic_stringbuf_wchar *this, const basic_string_wchar *str)
4275 {
4276     TRACE("(%p %p)\n", this, str);
4277
4278     basic_stringbuf_wchar__Tidy(this);
4279     basic_stringbuf_wchar__Init(this, MSVCP_basic_string_wchar_c_str(str), str->size, this->state);
4280 }
4281
4282 /* ?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 */
4283 /* ?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 */
4284 /* ?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 */
4285 /* ?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 */
4286 DEFINE_THISCALL_WRAPPER(basic_stringbuf_wchar_str_get, 8)
4287 basic_string_wchar* __thiscall basic_stringbuf_wchar_str_get(const basic_stringbuf_wchar *this, basic_string_wchar *ret)
4288 {
4289     wchar_t *ptr;
4290
4291     TRACE("(%p)\n", this);
4292
4293     if(!(this->state & STRINGBUF_no_write) && basic_streambuf_wchar_pptr(&this->base)) {
4294         wchar_t *pptr;
4295
4296         ptr = basic_streambuf_wchar_pbase(&this->base);
4297         pptr = basic_streambuf_wchar_pptr(&this->base);
4298
4299         return MSVCP_basic_string_wchar_ctor_cstr_len(ret, ptr, (this->seekhigh < pptr ? pptr : this->seekhigh) - ptr);
4300     }
4301
4302     if(!(this->state & STRINGBUF_no_read) && basic_streambuf_wchar_gptr(&this->base)) {
4303         ptr = basic_streambuf_wchar_eback(&this->base);
4304         return MSVCP_basic_string_wchar_ctor_cstr_len(ret, ptr, basic_streambuf_wchar_egptr(&this->base) - ptr);
4305     }
4306
4307     return MSVCP_basic_string_wchar_ctor(ret);
4308 }
4309
4310 /* ??0ios_base@std@@IAE@XZ */
4311 /* ??0ios_base@std@@IEAA@XZ */
4312 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
4313 ios_base* __thiscall ios_base_ctor(ios_base *this)
4314 {
4315     TRACE("(%p)\n", this);
4316     this->vtable = &MSVCP_ios_base_vtable;
4317     return this;
4318 }
4319
4320 /* ??0ios_base@std@@QAE@ABV01@@Z */
4321 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
4322 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
4323 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
4324 {
4325     TRACE("(%p %p)\n", this, copy);
4326     *this = *copy;
4327     this->vtable = &MSVCP_ios_base_vtable;
4328     return this;
4329 }
4330
4331 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
4332 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
4333 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
4334 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
4335 {
4336     IOS_BASE_fnarray *cur;
4337
4338     TRACE("(%p %x)\n", this, event);
4339
4340     for(cur=this->calls; cur; cur=cur->next)
4341         cur->event_handler(event, this, cur->index);
4342 }
4343
4344 /* ?_Tidy@ios_base@std@@AAAXXZ */
4345 /* ?_Tidy@ios_base@std@@AEAAXXZ */
4346 void CDECL ios_base_Tidy(ios_base *this)
4347 {
4348     IOS_BASE_iosarray *arr_cur, *arr_next;
4349     IOS_BASE_fnarray *event_cur, *event_next;
4350
4351     TRACE("(%p)\n", this);
4352
4353     ios_base_Callfns(this, EVENT_erase_event);
4354
4355     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
4356         arr_next = arr_cur->next;
4357         MSVCRT_operator_delete(arr_cur);
4358     }
4359     this->arr = NULL;
4360
4361     for(event_cur=this->calls; event_cur; event_cur=event_next) {
4362         event_next = event_cur->next;
4363         MSVCRT_operator_delete(event_cur);
4364     }
4365     this->calls = NULL;
4366 }
4367
4368 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
4369 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
4370 static void ios_base_Ios_base_dtor(ios_base *obj)
4371 {
4372     TRACE("(%p)\n", obj);
4373     if(obj->loc) {
4374         locale_dtor(obj->loc);
4375         MSVCRT_operator_delete(obj->loc);
4376     }
4377     ios_base_Tidy(obj);
4378 }
4379
4380 /* ??1ios_base@std@@UAE@XZ */
4381 /* ??1ios_base@std@@UEAA@XZ */
4382 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
4383 void __thiscall ios_base_dtor(ios_base *this)
4384 {
4385     ios_base_Ios_base_dtor(this);
4386 }
4387
4388 DEFINE_THISCALL_WRAPPER(ios_base_vector_dtor, 8)
4389 ios_base* __thiscall ios_base_vector_dtor(ios_base *this, unsigned int flags)
4390 {
4391     TRACE("(%p %x)\n", this, flags);
4392     if(flags & 2) {
4393         /* we have an array, with the number of elements stored before the first object */
4394         INT_PTR i, *ptr = (INT_PTR *)this-1;
4395
4396         for(i=*ptr-1; i>=0; i--)
4397             ios_base_dtor(this+i);
4398         MSVCRT_operator_delete(ptr);
4399     } else {
4400         ios_base_dtor(this);
4401         if(flags & 1)
4402             MSVCRT_operator_delete(this);
4403     }
4404
4405     return this;
4406 }
4407
4408 DEFINE_THISCALL_WRAPPER(iosb_vector_dtor, 8)
4409 void* __thiscall iosb_vector_dtor(void *this, unsigned int flags)
4410 {
4411     TRACE("(%p %x)\n", this, flags);
4412     if(flags & 2) {
4413         INT_PTR *ptr = (INT_PTR *)this-1;
4414         MSVCRT_operator_delete(ptr);
4415     } else {
4416         if(flags & 1)
4417             MSVCRT_operator_delete(this);
4418     }
4419
4420     return this;
4421 }
4422
4423 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
4424 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
4425 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
4426 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
4427 {
4428     IOS_BASE_iosarray *p;
4429
4430     TRACE("(%p %d)\n", this, index);
4431
4432     for(p=this->arr; p; p=p->next) {
4433         if(p->index == index)
4434             return p;
4435     }
4436
4437     for(p=this->arr; p; p=p->next) {
4438         if(!p->long_val && !p->ptr_val) {
4439             p->index = index;
4440             return p;
4441         }
4442     }
4443
4444     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
4445     p->next = this->arr;
4446     p->index = index;
4447     p->long_val = 0;
4448     p->ptr_val = NULL;
4449     this->arr = p;
4450     return p;
4451 }
4452
4453 /* ?iword@ios_base@std@@QAEAAJH@Z */
4454 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
4455 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
4456 LONG* __thiscall ios_base_iword(ios_base *this, int index)
4457 {
4458     TRACE("(%p %d)\n", this, index);
4459     return &ios_base_Findarr(this, index)->long_val;
4460 }
4461
4462 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
4463 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
4464 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
4465 void** __thiscall ios_base_pword(ios_base *this, int index)
4466 {
4467     TRACE("(%p %d)\n", this, index);
4468     return &ios_base_Findarr(this, index)->ptr_val;
4469 }
4470
4471 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
4472 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
4473 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
4474 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
4475 {
4476     IOS_BASE_fnarray *event;
4477
4478     TRACE("(%p %p %d)\n", this, callback, index);
4479
4480     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
4481     event->next = this->calls;
4482     event->index = index;
4483     event->event_handler = callback;
4484     this->calls = event;
4485 }
4486
4487 /* ?clear@ios_base@std@@QAEXH_N@Z */
4488 /* ?clear@ios_base@std@@QEAAXH_N@Z */
4489 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
4490 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4491 {
4492     TRACE("(%p %x %x)\n", this, state, reraise);
4493
4494     this->state = state & IOSTATE_mask;
4495     if(!(this->state & this->except))
4496         return;
4497
4498     if(reraise)
4499         throw_exception(EXCEPTION_RERAISE, NULL);
4500     else if(this->state & this->except & IOSTATE_eofbit)
4501         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
4502     else if(this->state & this->except & IOSTATE_failbit)
4503         throw_exception(EXCEPTION_FAILURE, "failbit is set");
4504     else if(this->state & this->except & IOSTATE_badbit)
4505         throw_exception(EXCEPTION_FAILURE, "badbit is set");
4506     else if(this->state & this->except & IOSTATE__Hardfail)
4507         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
4508 }
4509
4510 /* ?clear@ios_base@std@@QAEXH@Z */
4511 /* ?clear@ios_base@std@@QEAAXH@Z */
4512 DEFINE_THISCALL_WRAPPER(ios_base_clear, 8)
4513 void __thiscall ios_base_clear(ios_base *this, IOSB_iostate state)
4514 {
4515     ios_base_clear_reraise(this, state, FALSE);
4516 }
4517
4518 /* ?clear@ios_base@std@@QAEXI@Z */
4519 /* ?clear@ios_base@std@@QEAAXI@Z */
4520 DEFINE_THISCALL_WRAPPER(ios_base_clear_unsigned, 8)
4521 void __thiscall ios_base_clear_unsigned(ios_base *this, unsigned int state)
4522 {
4523     ios_base_clear_reraise(this, (IOSB_iostate)state, FALSE);
4524 }
4525
4526 /* ?exceptions@ios_base@std@@QAEXH@Z */
4527 /* ?exceptions@ios_base@std@@QEAAXH@Z */
4528 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
4529 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
4530 {
4531     TRACE("(%p %x)\n", this, state);
4532     this->except = state & IOSTATE_mask;
4533     ios_base_clear(this, this->state);
4534 }
4535
4536 /* ?exceptions@ios_base@std@@QAEXI@Z */
4537 /* ?exceptions@ios_base@std@@QEAAXI@Z */
4538 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set_unsigned, 8)
4539 void __thiscall ios_base_exceptions_set_unsigned(ios_base *this, unsigned int state)
4540 {
4541     TRACE("(%p %x)\n", this, state);
4542     ios_base_exceptions_set(this, state);
4543 }
4544
4545 /* ?exceptions@ios_base@std@@QBEHXZ */
4546 /* ?exceptions@ios_base@std@@QEBAHXZ */
4547 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
4548 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
4549 {
4550     TRACE("(%p)\n", this);
4551     return this->except;
4552 }
4553
4554 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
4555 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
4556 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
4557 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
4558 {
4559     TRACE("(%p %p)\n", this, rhs);
4560
4561     if(this != rhs) {
4562         IOS_BASE_iosarray *arr_cur;
4563         IOS_BASE_fnarray *event_cur;
4564
4565         ios_base_Tidy(this);
4566
4567         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
4568             if(arr_cur->long_val)
4569                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
4570             if(arr_cur->ptr_val)
4571                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
4572         }
4573         this->stdstr = rhs->stdstr;
4574         this->fmtfl = rhs->fmtfl;
4575         this->prec = rhs->prec;
4576         this->wide = rhs->wide;
4577         locale_operator_assign(this->loc, rhs->loc);
4578
4579         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
4580             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
4581
4582         ios_base_Callfns(this, EVENT_copyfmt_event);
4583         ios_base_exceptions_set(this, rhs->except);
4584     }
4585
4586     return this;
4587 }
4588
4589 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
4590 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
4591 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
4592 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
4593 {
4594     TRACE("(%p %p)\n", this, right);
4595
4596     if(this != right) {
4597         this->state = right->state;
4598         ios_base_copyfmt(this, right);
4599     }
4600
4601     return this;
4602 }
4603
4604 /* ?fail@ios_base@std@@QBE_NXZ */
4605 /* ?fail@ios_base@std@@QEBA_NXZ */
4606 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
4607 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
4608 {
4609     TRACE("(%p)\n", this);
4610     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
4611 }
4612
4613 /* ??7ios_base@std@@QBE_NXZ */
4614 /* ??7ios_base@std@@QEBA_NXZ */
4615 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
4616 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
4617 {
4618     TRACE("(%p)\n", this);
4619     return ios_base_fail(this);
4620 }
4621
4622 /* ??Bios_base@std@@QBEPAXXZ */
4623 /* ??Bios_base@std@@QEBAPEAXXZ */
4624 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
4625 void* __thiscall ios_base_op_fail(const ios_base *this)
4626 {
4627     TRACE("(%p)\n", this);
4628     return ios_base_fail(this) ? NULL : (void*)this;
4629 }
4630
4631 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
4632 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
4633 static void ios_base_Addstd(ios_base *add)
4634 {
4635     FIXME("(%p) stub\n", add);
4636 }
4637
4638 /* ?_Init@ios_base@std@@IAEXXZ */
4639 /* ?_Init@ios_base@std@@IEAAXXZ */
4640 DEFINE_THISCALL_WRAPPER(ios_base__Init, 4)
4641 void __thiscall ios_base__Init(ios_base *this)
4642 {
4643     TRACE("(%p)\n", this);
4644
4645     this->stdstr = 0;
4646     this->state = this->except = IOSTATE_goodbit;
4647     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
4648     this->prec = 6;
4649     this->wide = 0;
4650     this->arr = NULL;
4651     this->calls = NULL;
4652     this->loc = MSVCRT_operator_new(sizeof(locale));
4653     locale_ctor(this->loc);
4654 }
4655
4656 /* ?bad@ios_base@std@@QBE_NXZ */
4657 /* ?bad@ios_base@std@@QEBA_NXZ */
4658 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
4659 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
4660 {
4661     TRACE("(%p)\n", this);
4662     return (this->state & IOSTATE_badbit) != 0;
4663 }
4664
4665 /* ?eof@ios_base@std@@QBE_NXZ */
4666 /* ?eof@ios_base@std@@QEBA_NXZ */
4667 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
4668 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
4669 {
4670     TRACE("(%p)\n", this);
4671     return (this->state & IOSTATE_eofbit) != 0;
4672 }
4673
4674 /* ?flags@ios_base@std@@QAEHH@Z */
4675 /* ?flags@ios_base@std@@QEAAHH@Z */
4676 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
4677 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
4678 {
4679     IOSB_fmtflags ret = this->fmtfl;
4680
4681     TRACE("(%p %x)\n", this, flags);
4682
4683     this->fmtfl = flags & FMTFLAG_mask;
4684     return ret;
4685 }
4686
4687 /* ?flags@ios_base@std@@QBEHXZ */
4688 /* ?flags@ios_base@std@@QEBAHXZ */
4689 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
4690 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
4691 {
4692     TRACE("(%p)\n", this);
4693     return this->fmtfl;
4694 }
4695
4696 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
4697 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
4698 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
4699 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
4700 {
4701     TRACE("(%p)\n", this);
4702     return locale_copy_ctor(ret, this->loc);
4703 }
4704
4705 /* ?good@ios_base@std@@QBE_NXZ */
4706 /* ?good@ios_base@std@@QEBA_NXZ */
4707 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
4708 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
4709 {
4710     TRACE("(%p)\n", this);
4711     return this->state == IOSTATE_goodbit;
4712 }
4713
4714 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
4715 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
4716 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
4717 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
4718 {
4719     TRACE("(%p %p)\n", this, loc);
4720     *ret = *this->loc;
4721     locale_copy_ctor(this->loc, loc);
4722     return ret;
4723 }
4724
4725 /* ?precision@ios_base@std@@QAEHH@Z */
4726 /* ?precision@ios_base@std@@QEAA_J_J@Z */
4727 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 8)
4728 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
4729 {
4730     streamsize ret = this->prec;
4731
4732     TRACE("(%p %ld)\n", this, precision);
4733
4734     this->prec = precision;
4735     return ret;
4736 }
4737
4738 /* ?precision@ios_base@std@@QBEHXZ */
4739 /* ?precision@ios_base@std@@QEBA_JXZ */
4740 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
4741 streamsize __thiscall ios_base_precision_get(const ios_base *this)
4742 {
4743     TRACE("(%p)\n", this);
4744     return this->prec;
4745 }
4746
4747 /* ?rdstate@ios_base@std@@QBEHXZ */
4748 /* ?rdstate@ios_base@std@@QEBAHXZ */
4749 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
4750 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
4751 {
4752     TRACE("(%p)\n", this);
4753     return this->state;
4754 }
4755
4756 /* ?setf@ios_base@std@@QAEHHH@Z */
4757 /* ?setf@ios_base@std@@QEAAHHH@Z */
4758 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
4759 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
4760 {
4761     IOSB_fmtflags ret = this->fmtfl;
4762
4763     TRACE("(%p %x %x)\n", this, flags, mask);
4764
4765     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
4766     return ret;
4767 }
4768
4769 /* ?setf@ios_base@std@@QAEHH@Z */
4770 /* ?setf@ios_base@std@@QEAAHH@Z */
4771 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
4772 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
4773 {
4774     return ios_base_setf_mask(this, flags, ~0);
4775 }
4776
4777 /* ?setstate@ios_base@std@@QAEXH_N@Z */
4778 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
4779 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
4780 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
4781 {
4782     TRACE("(%p %x %x)\n", this, state, reraise);
4783
4784     if(state != IOSTATE_goodbit)
4785         ios_base_clear_reraise(this, this->state | state, reraise);
4786 }
4787
4788 /* ?setstate@ios_base@std@@QAEXH@Z */
4789 /* ?setstate@ios_base@std@@QEAAXH@Z */
4790 DEFINE_THISCALL_WRAPPER(ios_base_setstate, 8)
4791 void __thiscall ios_base_setstate(ios_base *this, IOSB_iostate state)
4792 {
4793     ios_base_setstate_reraise(this, state, FALSE);
4794 }
4795
4796 /* ?setstate@ios_base@std@@QAEXI@Z */
4797 /* ?setstate@ios_base@std@@QEAAXI@Z */
4798 DEFINE_THISCALL_WRAPPER(ios_base_setstate_unsigned, 8)
4799 void __thiscall ios_base_setstate_unsigned(ios_base *this, unsigned int state)
4800 {
4801     ios_base_setstate_reraise(this, (IOSB_iostate)state, FALSE);
4802 }
4803
4804 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
4805 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
4806 {
4807     _Lockit lock;
4808     MSVCP_bool ret;
4809
4810     TRACE("(%x)\n", sync);
4811
4812     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4813     ret = ios_base_Sync;
4814     ios_base_Sync = sync;
4815     _Lockit_dtor(&lock);
4816     return ret;
4817 }
4818
4819 /* ?unsetf@ios_base@std@@QAEXH@Z */
4820 /* ?unsetf@ios_base@std@@QEAAXH@Z */
4821 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
4822 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
4823 {
4824     TRACE("(%p %x)\n", this, flags);
4825     this->fmtfl &= ~flags;
4826 }
4827
4828 /* ?width@ios_base@std@@QAEHH@Z */
4829 /* ?width@ios_base@std@@QEAA_J_J@Z */
4830 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 8)
4831 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
4832 {
4833     streamsize ret = this->wide;
4834
4835     TRACE("(%p %ld)\n", this, width);
4836
4837     this->wide = width;
4838     return ret;
4839 }
4840
4841 /* ?width@ios_base@std@@QBEHXZ */
4842 /* ?width@ios_base@std@@QEBA_JXZ */
4843 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
4844 streamsize __thiscall ios_base_width_get(ios_base *this)
4845 {
4846     TRACE("(%p)\n", this);
4847     return this->wide;
4848 }
4849
4850 /* ?xalloc@ios_base@std@@SAHXZ */
4851 int CDECL ios_base_xalloc(void)
4852 {
4853     _Lockit lock;
4854     int ret;
4855
4856     TRACE("\n");
4857
4858     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
4859     ret = ios_base_Index++;
4860     _Lockit_dtor(&lock);
4861     return ret;
4862 }
4863
4864 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
4865 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
4866 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
4867 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
4868 {
4869     TRACE("(%p)\n", this);
4870
4871     ios_base_ctor(&this->base);
4872     this->base.vtable = &MSVCP_basic_ios_char_vtable;
4873     return this;
4874 }
4875
4876 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4877 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
4878 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
4879 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
4880 {
4881     TRACE("(%p %p %x)\n", this, streambuf, isstd);
4882     ios_base__Init(&this->base);
4883     this->strbuf = streambuf;
4884     this->stream = NULL;
4885     this->fillch = ' ';
4886
4887     if(!streambuf)
4888         ios_base_setstate(&this->base, IOSTATE_badbit);
4889
4890     if(isstd)
4891         FIXME("standard streams not handled yet\n");
4892 }
4893
4894 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4895 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4896 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
4897 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
4898 {
4899     TRACE("(%p %p)\n", this, strbuf);
4900
4901     basic_ios_char_ctor(this);
4902     basic_ios_char_init(this, strbuf, FALSE);
4903     return this;
4904 }
4905
4906 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
4907 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
4908 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
4909 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
4910 {
4911     TRACE("(%p)\n", this);
4912     ios_base_dtor(&this->base);
4913 }
4914
4915 DEFINE_THISCALL_WRAPPER(basic_ios_char_vector_dtor, 8)
4916 basic_ios_char* __thiscall basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
4917 {
4918     TRACE("(%p %x)\n", this, flags);
4919     if(flags & 2) {
4920         /* we have an array, with the number of elements stored before the first object */
4921         INT_PTR i, *ptr = (INT_PTR *)this-1;
4922
4923         for(i=*ptr-1; i>=0; i--)
4924             basic_ios_char_dtor(this+i);
4925         MSVCRT_operator_delete(ptr);
4926     } else {
4927         basic_ios_char_dtor(this);
4928         if(flags & 1)
4929             MSVCRT_operator_delete(this);
4930     }
4931
4932     return this;
4933 }
4934
4935 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
4936 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
4937 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
4938 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
4939 {
4940     TRACE("(%p %x %x)\n", this, state, reraise);
4941     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
4942 }
4943
4944 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
4945 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
4946 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear, 8)
4947 void __thiscall basic_ios_char_clear(basic_ios_char *this, unsigned int state)
4948 {
4949     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
4950 }
4951
4952 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
4953 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
4954 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
4955 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
4956 {
4957     TRACE("(%p %p)\n", this, copy);
4958     if(this == copy)
4959         return this;
4960
4961     this->stream = copy->stream;
4962     this->fillch = copy->fillch;
4963     ios_base_copyfmt(&this->base, &copy->base);
4964     return this;
4965 }
4966
4967 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
4968 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
4969 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
4970 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
4971 {
4972     char ret = this->fillch;
4973
4974     TRACE("(%p %c)\n", this, fill);
4975
4976     this->fillch = fill;
4977     return ret;
4978 }
4979
4980 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
4981 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
4982 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
4983 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
4984 {
4985     TRACE("(%p)\n", this);
4986     return this->fillch;
4987 }
4988
4989 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
4990 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
4991 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
4992 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
4993 {
4994     TRACE("(%p %p %p)\n", this, ret, loc);
4995
4996     if(this->strbuf) {
4997         basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
4998         locale_dtor(ret);
4999     }
5000
5001     return ios_base_imbue(&this->base, ret, loc);
5002 }
5003
5004 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
5005 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
5006 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
5007 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
5008 {
5009     TRACE("(%p %c %c)\n", this, ch, def);
5010     return ctype_char_narrow_ch(ctype_char_use_facet(this->strbuf->loc), ch, def);
5011 }
5012
5013 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
5014 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
5015 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
5016 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
5017 {
5018     basic_streambuf_char *ret = this->strbuf;
5019
5020     TRACE("(%p %p)\n", this, streambuf);
5021
5022     this->strbuf = streambuf;
5023     basic_ios_char_clear(this, IOSTATE_goodbit);
5024     return ret;
5025 }
5026
5027 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
5028 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
5029 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
5030 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
5031 {
5032     TRACE("(%p)\n", this);
5033     return this->strbuf;
5034 }
5035
5036 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
5037 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
5038 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
5039 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
5040 {
5041     TRACE("(%p %x %x)\n", this, state, reraise);
5042
5043     if(state != IOSTATE_goodbit)
5044         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
5045 }
5046
5047 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
5048 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
5049 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate, 8)
5050 void __thiscall basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
5051 {
5052     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
5053 }
5054
5055 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
5056 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
5057 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
5058 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
5059 {
5060     basic_ostream_char *ret = this->stream;
5061
5062     TRACE("(%p %p)\n", this, ostream);
5063
5064     this->stream = ostream;
5065     return ret;
5066 }
5067
5068 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
5069 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
5070 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
5071 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
5072 {
5073     TRACE("(%p)\n", this);
5074     return this->stream;
5075 }
5076
5077 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
5078 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
5079 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
5080 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
5081 {
5082     TRACE("(%p %c)\n", this, ch);
5083     return ctype_char_widen_ch(ctype_char_use_facet(this->strbuf->loc), ch);
5084 }
5085
5086
5087 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
5088 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
5089 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor, 4)
5090 basic_ios_wchar* __thiscall basic_ios_wchar_ctor(basic_ios_wchar *this)
5091 {
5092     TRACE("(%p)\n", this);
5093
5094     ios_base_ctor(&this->base);
5095     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
5096     return this;
5097 }
5098
5099 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
5100 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
5101 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
5102 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
5103 {
5104     basic_ios_wchar_ctor(this);
5105     this->base.vtable = &MSVCP_basic_ios_short_vtable;
5106     return this;
5107 }
5108
5109 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
5110 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
5111 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
5112 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
5113 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
5114 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
5115 {
5116     TRACE("(%p %p %x)\n", this, streambuf, isstd);
5117     ios_base__Init(&this->base);
5118     this->strbuf = streambuf;
5119     this->stream = NULL;
5120     this->fillch = ' ';
5121
5122     if(!streambuf)
5123         ios_base_setstate(&this->base, IOSTATE_badbit);
5124
5125     if(isstd)
5126         FIXME("standard streams not handled yet\n");
5127 }
5128
5129 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5130 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5131 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor_streambuf, 8)
5132 basic_ios_wchar* __thiscall basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
5133 {
5134     TRACE("(%p %p)\n", this, strbuf);
5135
5136     basic_ios_wchar_ctor(this);
5137     basic_ios_wchar_init(this, strbuf, FALSE);
5138     return this;
5139 }
5140
5141 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5142 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5143 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
5144 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
5145 {
5146     basic_ios_wchar_ctor_streambuf(this, strbuf);
5147     this->base.vtable = &MSVCP_basic_ios_short_vtable;
5148     return this;
5149 }
5150
5151 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
5152 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
5153 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
5154 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
5155 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
5156 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
5157 {
5158     TRACE("(%p)\n", this);
5159     ios_base_dtor(&this->base);
5160 }
5161
5162 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_vector_dtor, 8)
5163 basic_ios_wchar* __thiscall basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
5164 {
5165     TRACE("(%p %x)\n", this, flags);
5166     if(flags & 2) {
5167         /* we have an array, with the number of elements stored before the first object */
5168         INT_PTR i, *ptr = (INT_PTR *)this-1;
5169
5170         for(i=*ptr-1; i>=0; i--)
5171             basic_ios_wchar_dtor(this+i);
5172         MSVCRT_operator_delete(ptr);
5173     } else {
5174         basic_ios_wchar_dtor(this);
5175         if(flags & 1)
5176             MSVCRT_operator_delete(this);
5177     }
5178
5179     return this;
5180 }
5181
5182 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5183 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5184 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5185 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5186 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
5187 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5188 {
5189     TRACE("(%p %x %x)\n", this, state, reraise);
5190     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
5191 }
5192
5193 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5194 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5195 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5196 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5197 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear, 8)
5198 void __thiscall basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
5199 {
5200     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
5201 }
5202
5203 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
5204 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5205 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
5206 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
5207 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
5208 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
5209 {
5210     TRACE("(%p %p)\n", this, copy);
5211     if(this == copy)
5212         return this;
5213
5214     this->stream = copy->stream;
5215     this->fillch = copy->fillch;
5216     ios_base_copyfmt(&this->base, &copy->base);
5217     return this;
5218 }
5219
5220 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
5221 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
5222 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
5223 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
5224 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
5225 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
5226 {
5227     wchar_t ret = this->fillch;
5228
5229     TRACE("(%p %c)\n", this, fill);
5230
5231     this->fillch = fill;
5232     return ret;
5233 }
5234
5235 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
5236 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
5237 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
5238 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
5239 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
5240 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
5241 {
5242     TRACE("(%p)\n", this);
5243     return this->fillch;
5244 }
5245
5246 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5247 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5248 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
5249 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
5250 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
5251 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
5252 {
5253     TRACE("(%p %p %p)\n", this, ret, loc);
5254
5255     if(this->strbuf) {
5256         basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
5257         locale_dtor(ret);
5258     }
5259
5260     return ios_base_imbue(&this->base, ret, loc);
5261 }
5262
5263 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
5264 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
5265 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
5266 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
5267 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
5268 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
5269 {
5270     TRACE("(%p %c %c)\n", this, ch, def);
5271     return ctype_wchar_narrow_ch(ctype_wchar_use_facet(this->strbuf->loc), ch, def);
5272 }
5273
5274 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5275 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5276 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
5277 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5278 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
5279 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
5280 {
5281     basic_streambuf_wchar *ret = this->strbuf;
5282
5283     TRACE("(%p %p)\n", this, streambuf);
5284
5285     this->strbuf = streambuf;
5286     basic_ios_wchar_clear(this, IOSTATE_goodbit);
5287     return ret;
5288 }
5289
5290 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5291 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
5292 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5293 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
5294 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
5295 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
5296 {
5297     TRACE("(%p)\n", this);
5298     return this->strbuf;
5299 }
5300
5301 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
5302 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
5303 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
5304 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
5305 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
5306 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
5307 {
5308     TRACE("(%p %x %x)\n", this, state, reraise);
5309
5310     if(state != IOSTATE_goodbit)
5311         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
5312 }
5313
5314 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
5315 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
5316 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
5317 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
5318 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate, 8)
5319 void __thiscall basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
5320 {
5321     basic_ios_wchar_setstate_reraise(this, state, FALSE);
5322 }
5323
5324 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
5325 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
5326 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
5327 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
5328 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
5329 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
5330 {
5331     basic_ostream_wchar *ret = this->stream;
5332
5333     TRACE("(%p %p)\n", this, ostream);
5334
5335     this->stream = ostream;
5336     return ret;
5337 }
5338
5339 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5340 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
5341 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5342 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
5343 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
5344 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
5345 {
5346     TRACE("(%p)\n", this);
5347     return this->stream;
5348 }
5349
5350 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
5351 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
5352 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
5353 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
5354 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
5355 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
5356 {
5357     TRACE("(%p %c)\n", this, ch);
5358     return ctype_wchar_widen_ch(ctype_wchar_use_facet(this->strbuf->loc), ch);
5359 }
5360
5361 /* Caution: basic_ostream uses virtual inheritance.
5362  * All constructors have additional parameter that says if base class should be initialized.
5363  * Base class needs to be accessed using vbtable.
5364  */
5365 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
5366 {
5367     return (basic_ios_char*)((char*)this+this->vbtable[1]);
5368 }
5369
5370 static inline basic_ios_char* basic_ostream_char_to_basic_ios(basic_ostream_char *ptr)
5371 {
5372     return (basic_ios_char*)((char*)ptr+basic_ostream_char_vbtable[1]);
5373 }
5374
5375 static inline basic_ostream_char* basic_ostream_char_from_basic_ios(basic_ios_char *ptr)
5376 {
5377     return (basic_ostream_char*)((char*)ptr-basic_ostream_char_vbtable[1]);
5378 }
5379
5380 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5381 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5382 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor, 16)
5383 basic_ostream_char* __thiscall basic_ostream_char_ctor(basic_ostream_char *this,
5384         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5385 {
5386     basic_ios_char *base;
5387
5388     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
5389
5390     if(virt_init) {
5391         this->vbtable = basic_ostream_char_vbtable;
5392         base = basic_ostream_char_get_basic_ios(this);
5393         basic_ios_char_ctor(base);
5394     }else {
5395         base = basic_ostream_char_get_basic_ios(this);
5396     }
5397
5398     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5399     basic_ios_char_init(base, strbuf, isstd);
5400     return this;
5401 }
5402
5403 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
5404 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
5405 static basic_ostream_char* basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
5406         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
5407 {
5408     basic_ios_char *base;
5409
5410     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
5411
5412     if(virt_init) {
5413         this->vbtable = basic_ostream_char_vbtable;
5414         base = basic_ostream_char_get_basic_ios(this);
5415         basic_ios_char_ctor(base);
5416     }else {
5417         base = basic_ostream_char_get_basic_ios(this);
5418     }
5419
5420     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
5421     if(addstd)
5422         ios_base_Addstd(&base->base);
5423     return this;
5424 }
5425
5426 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5427 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5428 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
5429 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
5430 {
5431     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5432
5433     /* don't destroy virtual base here */
5434     TRACE("(%p)\n", this);
5435 }
5436
5437 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5438 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5439 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
5440 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
5441 {
5442     TRACE("(%p)\n", this);
5443     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
5444     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
5445 }
5446
5447 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
5448 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5449 {
5450     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
5451
5452     TRACE("(%p %x)\n", this, flags);
5453
5454     if(flags & 2) {
5455         /* we have an array, with the number of elements stored before the first object */
5456         INT_PTR i, *ptr = (INT_PTR *)this-1;
5457
5458         for(i=*ptr-1; i>=0; i--)
5459             basic_ostream_char_vbase_dtor(this+i);
5460         MSVCRT_operator_delete(ptr);
5461     } else {
5462         basic_ostream_char_vbase_dtor(this);
5463         if(flags & 1)
5464             MSVCRT_operator_delete(this);
5465     }
5466
5467     return this;
5468 }
5469
5470 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5471 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5472 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
5473 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
5474 {
5475     /* this function is not matching C++ specification */
5476     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5477
5478     TRACE("(%p)\n", this);
5479
5480     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
5481             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
5482         basic_ios_char_setstate(base, IOSTATE_badbit);
5483     return this;
5484 }
5485
5486 /* ?flush@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5487 /* ?flush@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5488 basic_ostream_char* __cdecl flush_ostream_char(basic_ostream_char *ostream)
5489 {
5490     return basic_ostream_char_flush(ostream);
5491 }
5492
5493 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5494 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5495 DEFINE_THISCALL_WRAPPER(basic_ostream_char__Osfx, 4)
5496 void __thiscall basic_ostream_char__Osfx(basic_ostream_char *this)
5497 {
5498     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5499
5500     TRACE("(%p)\n", this);
5501
5502     if(base->base.fmtfl & FMTFLAG_unitbuf)
5503         basic_ostream_char_flush(this);
5504 }
5505
5506 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5507 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5508 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
5509 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
5510 {
5511     TRACE("(%p)\n", this);
5512     basic_ostream_char__Osfx(this);
5513 }
5514
5515 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
5516 {
5517     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5518
5519     if(basic_ios_char_rdbuf_get(base))
5520         basic_streambuf_char__Lock(base->strbuf);
5521
5522     if(ios_base_good(&base->base) && base->stream)
5523         basic_ostream_char_flush(base->stream);
5524
5525     return ios_base_good(&base->base);
5526 }
5527
5528 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
5529 {
5530     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5531
5532     if(ios_base_good(&base->base) && !__uncaught_exception())
5533         basic_ostream_char_osfx(ostr);
5534
5535     if(basic_ios_char_rdbuf_get(base))
5536         basic_streambuf_char__Unlock(base->strbuf);
5537 }
5538
5539 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
5540 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
5541 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
5542 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
5543 {
5544     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5545
5546     TRACE("(%p)\n", this);
5547
5548     if(ios_base_good(&base->base) && base->stream)
5549         basic_ostream_char_flush(base->stream);
5550     return ios_base_good(&base->base);
5551 }
5552
5553 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5554 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5555 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
5556 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
5557 {
5558     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5559
5560     TRACE("(%p %c)\n", this, ch);
5561
5562     if(!basic_ostream_char_sentry_create(this)
5563             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
5564         basic_ostream_char_sentry_destroy(this);
5565         basic_ios_char_setstate(base, IOSTATE_badbit);
5566         return this;
5567     }
5568
5569     basic_ostream_char_sentry_destroy(this);
5570     return this;
5571 }
5572
5573 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
5574 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
5575 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp, 12)
5576 basic_ostream_char* __thiscall basic_ostream_char_seekp(basic_ostream_char *this, streamoff off, int way)
5577 {
5578     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5579
5580     TRACE("(%p %ld %d)\n", this, off, way);
5581
5582     if(!ios_base_fail(&base->base)) {
5583         fpos_int seek;
5584
5585         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5586                 &seek, off, way, OPENMODE_out);
5587         if(seek.off==-1 && seek.pos==0 && seek.state==0)
5588             basic_ios_char_setstate(base, IOSTATE_failbit);
5589     }
5590     return this;
5591 }
5592
5593 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
5594 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
5595 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
5596 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
5597 {
5598     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5599
5600     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
5601
5602     if(!ios_base_fail(&base->base)) {
5603         fpos_int seek;
5604
5605         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
5606                 &seek, pos, OPENMODE_out);
5607         if(seek.off==-1 && seek.pos==0 && seek.state==0)
5608             basic_ios_char_setstate(base, IOSTATE_failbit);
5609     }
5610     return this;
5611 }
5612
5613 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
5614 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
5615 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
5616 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
5617 {
5618     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5619
5620     TRACE("(%p)\n", this);
5621
5622     if(!ios_base_fail(&base->base)) {
5623         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
5624                 ret, 0, SEEKDIR_cur, OPENMODE_out);
5625     }else {
5626         ret->off = -1;
5627         ret->pos = 0;
5628         ret->state = 0;
5629     }
5630     return ret;
5631 }
5632
5633 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
5634 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
5635 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 12)
5636 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
5637 {
5638     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5639
5640     TRACE("(%p %s %ld)\n", this, debugstr_a(str), count);
5641
5642     if(!basic_ostream_char_sentry_create(this)
5643             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
5644         basic_ostream_char_sentry_destroy(this);
5645         basic_ios_char_setstate(base, IOSTATE_badbit);
5646         return this;
5647     }
5648
5649     basic_ostream_char_sentry_destroy(this);
5650     return this;
5651 }
5652
5653 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
5654 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
5655 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
5656 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
5657 {
5658     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5659     int state = IOSTATE_goodbit;
5660
5661     TRACE("(%p %d)\n", this, val);
5662
5663     if(basic_ostream_char_sentry_create(this)) {
5664         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5665         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5666         ostreambuf_iterator_char dest = {0, strbuf};
5667
5668         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
5669                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
5670                 ? (LONG)((unsigned short)val) : (LONG)val);
5671     }
5672     basic_ostream_char_sentry_destroy(this);
5673
5674     basic_ios_char_setstate(base, state);
5675     return this;
5676 }
5677
5678 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
5679 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
5680 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
5681 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
5682 {
5683     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5684     int state = IOSTATE_goodbit;
5685
5686     TRACE("(%p %u)\n", this, val);
5687
5688     if(basic_ostream_char_sentry_create(this)) {
5689         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5690         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5691         ostreambuf_iterator_char dest = {0, strbuf};
5692
5693         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5694     }
5695     basic_ostream_char_sentry_destroy(this);
5696
5697     basic_ios_char_setstate(base, state);
5698     return this;
5699 }
5700
5701 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
5702 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
5703 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
5704 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
5705 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
5706 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
5707 {
5708     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5709     int state = IOSTATE_goodbit;
5710
5711     TRACE("(%p %d)\n", this, val);
5712
5713     if(basic_ostream_char_sentry_create(this)) {
5714         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5715         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5716         ostreambuf_iterator_char dest = {0, strbuf};
5717
5718         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5719     }
5720     basic_ostream_char_sentry_destroy(this);
5721
5722     basic_ios_char_setstate(base, state);
5723     return this;
5724 }
5725
5726 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
5727 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
5728 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
5729 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
5730 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
5731 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
5732 {
5733     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5734     int state = IOSTATE_goodbit;
5735
5736     TRACE("(%p %u)\n", this, val);
5737
5738     if(basic_ostream_char_sentry_create(this)) {
5739         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5740         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5741         ostreambuf_iterator_char dest = {0, strbuf};
5742
5743         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5744     }
5745     basic_ostream_char_sentry_destroy(this);
5746
5747     basic_ios_char_setstate(base, state);
5748     return this;
5749 }
5750
5751 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
5752 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
5753 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
5754 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
5755 {
5756     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5757     int state = IOSTATE_goodbit;
5758
5759     TRACE("(%p %f)\n", this, val);
5760
5761     if(basic_ostream_char_sentry_create(this)) {
5762         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5763         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5764         ostreambuf_iterator_char dest = {0, strbuf};
5765
5766         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5767     }
5768     basic_ostream_char_sentry_destroy(this);
5769
5770     basic_ios_char_setstate(base, state);
5771     return this;
5772 }
5773
5774 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
5775 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
5776 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
5777 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
5778 {
5779     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5780     int state = IOSTATE_goodbit;
5781
5782     TRACE("(%p %lf)\n", this, val);
5783
5784     if(basic_ostream_char_sentry_create(this)) {
5785         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5786         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5787         ostreambuf_iterator_char dest = {0, strbuf};
5788
5789         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5790     }
5791     basic_ostream_char_sentry_destroy(this);
5792
5793     basic_ios_char_setstate(base, state);
5794     return this;
5795 }
5796
5797 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
5798 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
5799 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
5800 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
5801 {
5802     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5803     int state = IOSTATE_goodbit;
5804
5805     TRACE("(%p %lf)\n", this, val);
5806
5807     if(basic_ostream_char_sentry_create(this)) {
5808         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5809         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5810         ostreambuf_iterator_char dest = {0, strbuf};
5811
5812         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5813     }
5814     basic_ostream_char_sentry_destroy(this);
5815
5816     basic_ios_char_setstate(base, state);
5817     return this;
5818 }
5819
5820 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5821 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
5822 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
5823 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
5824 {
5825     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5826     IOSB_iostate state = IOSTATE_badbit;
5827     int c = '\n';
5828
5829     TRACE("(%p %p)\n", this, val);
5830
5831     if(basic_ostream_char_sentry_create(this)) {
5832         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
5833                 c = basic_streambuf_char_snextc(val)) {
5834             state = IOSTATE_goodbit;
5835
5836             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
5837                 state = IOSTATE_badbit;
5838                 break;
5839             }
5840         }
5841     }else {
5842         state = IOSTATE_badbit;
5843     }
5844     basic_ostream_char_sentry_destroy(this);
5845
5846     ios_base_width_set(&base->base, 0);
5847     basic_ios_char_setstate(base, state);
5848     return this;
5849 }
5850
5851 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
5852 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
5853 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
5854 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
5855 {
5856     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5857     int state = IOSTATE_goodbit;
5858
5859     TRACE("(%p %p)\n", this, val);
5860
5861     if(basic_ostream_char_sentry_create(this)) {
5862         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5863         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5864         ostreambuf_iterator_char dest = {0, strbuf};
5865
5866         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5867     }
5868     basic_ostream_char_sentry_destroy(this);
5869
5870     basic_ios_char_setstate(base, state);
5871     return this;
5872 }
5873
5874 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
5875 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
5876 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
5877 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
5878 {
5879     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5880     int state = IOSTATE_goodbit;
5881
5882     TRACE("(%p)\n", this);
5883
5884     if(basic_ostream_char_sentry_create(this)) {
5885         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5886         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5887         ostreambuf_iterator_char dest = {0, strbuf};
5888
5889         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5890     }
5891     basic_ostream_char_sentry_destroy(this);
5892
5893     basic_ios_char_setstate(base, state);
5894     return this;
5895 }
5896
5897 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
5898 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
5899 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
5900 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
5901 {
5902     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5903     int state = IOSTATE_goodbit;
5904
5905     TRACE("(%p)\n", this);
5906
5907     if(basic_ostream_char_sentry_create(this)) {
5908         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5909         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5910         ostreambuf_iterator_char dest = {0, strbuf};
5911
5912         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5913     }
5914     basic_ostream_char_sentry_destroy(this);
5915
5916     basic_ios_char_setstate(base, state);
5917     return this;
5918 }
5919
5920 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
5921 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
5922 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
5923 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
5924 {
5925     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
5926     int state = IOSTATE_goodbit;
5927
5928     TRACE("(%p %x)\n", this, val);
5929
5930     if(basic_ostream_char_sentry_create(this)) {
5931         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5932         const num_put *numput = num_put_char_use_facet(strbuf->loc);
5933         ostreambuf_iterator_char dest = {0, strbuf};
5934
5935         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
5936     }
5937     basic_ostream_char_sentry_destroy(this);
5938
5939     basic_ios_char_setstate(base, state);
5940     return this;
5941 }
5942
5943 /* ?ends@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5944 /* ?ends@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5945 basic_ostream_char* __cdecl basic_ostream_char_ends(basic_ostream_char *ostr)
5946 {
5947     TRACE("(%p)\n", ostr);
5948
5949     basic_ostream_char_put(ostr, 0);
5950     return ostr;
5951 }
5952
5953 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5954 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5955 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
5956 {
5957     TRACE("(%p)\n", ostr);
5958
5959     basic_ostream_char_put(ostr, '\n');
5960     basic_ostream_char_flush(ostr);
5961     return ostr;
5962 }
5963
5964 /* $?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 */
5965 /* ??$?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 */
5966 basic_ostream_char* __cdecl basic_ostream_char_print_bstr(basic_ostream_char *ostr, const basic_string_char *str)
5967 {
5968     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
5969     IOSB_iostate state = IOSTATE_goodbit;
5970
5971     TRACE("(%p %p)\n", ostr, str);
5972
5973     if(basic_ostream_char_sentry_create(ostr)) {
5974         MSVCP_size_t len = MSVCP_basic_string_char_length(str);
5975         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
5976
5977         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
5978             for(; pad!=0; pad--) {
5979                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5980                     state = IOSTATE_badbit;
5981                     break;
5982                 }
5983             }
5984         }
5985
5986         if(state == IOSTATE_goodbit) {
5987             if(basic_streambuf_char_sputn(base->strbuf, MSVCP_basic_string_char_c_str(str), len) != len)
5988                     state = IOSTATE_badbit;
5989         }
5990
5991         if(state == IOSTATE_goodbit) {
5992             for(; pad!=0; pad--) {
5993                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
5994                     state = IOSTATE_badbit;
5995                     break;
5996                 }
5997             }
5998         }
5999
6000         base->base.wide = 0;
6001     }else {
6002         state = IOSTATE_badbit;
6003     }
6004     basic_ostream_char_sentry_destroy(ostr);
6005
6006     basic_ios_char_setstate(base, state);
6007     return ostr;
6008 }
6009
6010 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@C@Z */
6011 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@C@Z */
6012 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@D@Z */
6013 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@D@Z */
6014 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@E@Z */
6015 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@E@Z */
6016 basic_ostream_char* __cdecl basic_ostream_char_print_ch(basic_ostream_char *ostr, char ch)
6017 {
6018     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
6019     IOSB_iostate state = IOSTATE_goodbit;
6020
6021     TRACE("(%p %d)\n", ostr, ch);
6022
6023     if(basic_ostream_char_sentry_create(ostr)) {
6024         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6025
6026         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6027             for(; pad!=0; pad--) {
6028                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6029                     state = IOSTATE_badbit;
6030                     break;
6031                 }
6032             }
6033         }
6034
6035         if(state == IOSTATE_goodbit) {
6036             if(basic_streambuf_char_sputc(base->strbuf, ch) == EOF)
6037                 state = IOSTATE_badbit;
6038         }
6039
6040         if(state == IOSTATE_goodbit) {
6041             for(; pad!=0; pad--) {
6042                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6043                     state = IOSTATE_badbit;
6044                     break;
6045                 }
6046             }
6047         }
6048
6049         base->base.wide = 0;
6050     }else {
6051         state = IOSTATE_badbit;
6052     }
6053     basic_ostream_char_sentry_destroy(ostr);
6054
6055     basic_ios_char_setstate(base, state);
6056     return ostr;
6057 }
6058
6059 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBC@Z */
6060 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBC@Z */
6061 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z */
6062 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBD@Z */
6063 /* ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBE@Z */
6064 /* ??$?6U?$char_traits@D@std@@@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@0@AEAV10@PEBE@Z */
6065 basic_ostream_char* __cdecl basic_ostream_char_print_str(basic_ostream_char *ostr, const char *str)
6066 {
6067     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
6068     IOSB_iostate state = IOSTATE_goodbit;
6069
6070     TRACE("(%p %s)\n", ostr, str);
6071
6072     if(basic_ostream_char_sentry_create(ostr)) {
6073         MSVCP_size_t len = strlen(str);
6074         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6075
6076         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6077             for(; pad!=0; pad--) {
6078                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6079                     state = IOSTATE_badbit;
6080                     break;
6081                 }
6082             }
6083         }
6084
6085         if(state == IOSTATE_goodbit) {
6086             if(basic_streambuf_char_sputn(base->strbuf, str, len) != len)
6087                 state = IOSTATE_badbit;
6088         }
6089
6090         if(state == IOSTATE_goodbit) {
6091             for(; pad!=0; pad--) {
6092                 if(basic_streambuf_char_sputc(base->strbuf, base->fillch) == EOF) {
6093                     state = IOSTATE_badbit;
6094                     break;
6095                 }
6096             }
6097         }
6098
6099         base->base.wide = 0;
6100     }else {
6101         state = IOSTATE_badbit;
6102     }
6103     basic_ostream_char_sentry_destroy(ostr);
6104
6105     basic_ios_char_setstate(base, state);
6106     return ostr;
6107 }
6108
6109 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6110 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6111 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
6112 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
6113         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
6114 {
6115     TRACE("(%p %p)\n", this, pfunc);
6116     pfunc(this);
6117     return this;
6118 }
6119
6120 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
6121 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
6122 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
6123 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
6124         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
6125 {
6126     TRACE("(%p %p)\n", this, pfunc);
6127     pfunc(basic_ostream_char_get_basic_ios(this));
6128     return this;
6129 }
6130
6131 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6132 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6133 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
6134 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
6135         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
6136 {
6137     TRACE("(%p %p)\n", this, pfunc);
6138     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
6139     return this;
6140 }
6141
6142 /* Caution: basic_ostream uses virtual inheritance. */
6143 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
6144 {
6145     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
6146 }
6147
6148 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
6149 {
6150     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
6151 }
6152
6153 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
6154 {
6155     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
6156 }
6157
6158 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6159 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6160 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_ctor, 16)
6161 basic_ostream_wchar* __thiscall basic_ostream_wchar_ctor(basic_ostream_wchar *this,
6162         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6163 {
6164     basic_ios_wchar *base;
6165
6166     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
6167
6168     if(virt_init) {
6169         this->vbtable = basic_ostream_wchar_vbtable;
6170         base = basic_ostream_wchar_get_basic_ios(this);
6171         basic_ios_wchar_ctor(base);
6172     }else {
6173         base = basic_ostream_wchar_get_basic_ios(this);
6174     }
6175
6176     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6177     basic_ios_wchar_init(base, strbuf, isstd);
6178     return this;
6179 }
6180
6181 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6182 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6183 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor, 16)
6184 basic_ostream_wchar* __thiscall basic_ostream_short_ctor(basic_ostream_wchar *this,
6185         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6186 {
6187     basic_ostream_wchar_ctor(this, strbuf, isstd, virt_init);
6188     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
6189     return this;
6190 }
6191
6192 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
6193 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
6194 static basic_ostream_wchar* basic_ostream_wchar_ctor_uninitialized(basic_ostream_wchar *this,
6195         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
6196 {
6197     basic_ios_wchar *base;
6198
6199     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
6200
6201     if(virt_init) {
6202         this->vbtable = basic_ostream_wchar_vbtable;
6203         base = basic_ostream_wchar_get_basic_ios(this);
6204         basic_ios_wchar_ctor(base);
6205     }else {
6206         base = basic_ostream_wchar_get_basic_ios(this);
6207     }
6208
6209     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
6210     if(addstd)
6211         ios_base_Addstd(&base->base);
6212     return this;
6213 }
6214
6215 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
6216 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
6217 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
6218 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
6219 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
6220 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
6221 {
6222     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6223
6224     /* don't destroy virtual base here */
6225     TRACE("(%p)\n", this);
6226 }
6227
6228 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6229 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6230 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6231 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6232 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
6233 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
6234 {
6235     TRACE("(%p)\n", this);
6236     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
6237     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
6238 }
6239
6240 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
6241 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
6242 {
6243     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
6244
6245     TRACE("(%p %x)\n", this, flags);
6246
6247     if(flags & 2) {
6248         /* we have an array, with the number of elements stored before the first object */
6249         INT_PTR i, *ptr = (INT_PTR *)this-1;
6250
6251         for(i=*ptr-1; i>=0; i--)
6252             basic_ostream_wchar_vbase_dtor(this+i);
6253         MSVCRT_operator_delete(ptr);
6254     } else {
6255         basic_ostream_wchar_vbase_dtor(this);
6256         if(flags & 1)
6257             MSVCRT_operator_delete(this);
6258     }
6259
6260     return this;
6261 }
6262
6263 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
6264 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
6265 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
6266 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
6267 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
6268 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
6269 {
6270     /* this function is not matching C++ specification */
6271     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6272
6273     TRACE("(%p)\n", this);
6274
6275     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
6276             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
6277         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6278     return this;
6279 }
6280
6281 /* ?flush@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6282 /* ?flush@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6283 /* ?flush@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6284 /* ?flush@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6285 basic_ostream_wchar* __cdecl flush_ostream_wchar(basic_ostream_wchar *ostream)
6286 {
6287     return basic_ostream_wchar_flush(ostream);
6288 }
6289
6290 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6291 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6292 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6293 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6294 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar__Osfx, 4)
6295 void __thiscall basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
6296 {
6297     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6298
6299     TRACE("(%p)\n", this);
6300
6301     if(base->base.fmtfl & FMTFLAG_unitbuf)
6302         basic_ostream_wchar_flush(this);
6303 }
6304
6305 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6306 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6307 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6308 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6309 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
6310 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
6311 {
6312     TRACE("(%p)\n", this);
6313     basic_ostream_wchar__Osfx(this);
6314 }
6315
6316 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
6317 {
6318     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6319
6320     if(basic_ios_wchar_rdbuf_get(base))
6321         basic_streambuf_wchar__Lock(base->strbuf);
6322
6323     if(ios_base_good(&base->base) && base->stream)
6324         basic_ostream_wchar_flush(base->stream);
6325
6326     return ios_base_good(&base->base);
6327 }
6328
6329 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
6330 {
6331     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6332
6333     if(ios_base_good(&base->base) && !__uncaught_exception())
6334         basic_ostream_wchar_osfx(ostr);
6335
6336     if(basic_ios_wchar_rdbuf_get(base))
6337         basic_streambuf_wchar__Unlock(base->strbuf);
6338 }
6339
6340 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
6341 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
6342 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
6343 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
6344 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
6345 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
6346 {
6347     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6348
6349     TRACE("(%p)\n", this);
6350
6351     if(ios_base_good(&base->base) && base->stream)
6352         basic_ostream_wchar_flush(base->stream);
6353     return ios_base_good(&base->base);
6354 }
6355
6356 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
6357 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
6358 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
6359 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
6360 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
6361 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
6362 {
6363     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6364
6365     TRACE("(%p %c)\n", this, ch);
6366
6367     if(!basic_ostream_wchar_sentry_create(this)
6368             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
6369         basic_ostream_wchar_sentry_destroy(this);
6370         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6371         return this;
6372     }
6373
6374     basic_ostream_wchar_sentry_destroy(this);
6375     return this;
6376 }
6377
6378 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
6379 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
6380 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
6381 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
6382 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp, 12)
6383 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp(basic_ostream_wchar *this, streamoff off, int way)
6384 {
6385     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6386
6387     TRACE("(%p %ld %d)\n", this, off, way);
6388
6389     if(!ios_base_fail(&base->base)) {
6390         fpos_int seek;
6391
6392         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6393                 &seek, off, way, OPENMODE_out);
6394         if(seek.off==-1 && seek.pos==0 && seek.state==0)
6395             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6396     }
6397     return this;
6398 }
6399
6400 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6401 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6402 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6403 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6404 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
6405 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
6406 {
6407     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6408
6409     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6410
6411     if(!ios_base_fail(&base->base)) {
6412         fpos_int seek;
6413
6414         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
6415                 &seek, pos, OPENMODE_out);
6416         if(seek.off==-1 && seek.pos==0 && seek.state==0)
6417             basic_ios_wchar_setstate(base, IOSTATE_failbit);
6418     }
6419     return this;
6420 }
6421
6422 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6423 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6424 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6425 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6426 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
6427 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
6428 {
6429     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6430
6431     TRACE("(%p)\n", this);
6432
6433     if(!ios_base_fail(&base->base)) {
6434         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
6435                 ret, 0, SEEKDIR_cur, OPENMODE_out);
6436     }else {
6437         ret->off = -1;
6438         ret->pos = 0;
6439         ret->state = 0;
6440     }
6441     return ret;
6442 }
6443
6444 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
6445 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
6446 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
6447 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
6448 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 12)
6449 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
6450 {
6451     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6452
6453     TRACE("(%p %s %ld)\n", this, debugstr_w(str), count);
6454
6455     if(!basic_ostream_wchar_sentry_create(this)
6456             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
6457         basic_ostream_wchar_sentry_destroy(this);
6458         basic_ios_wchar_setstate(base, IOSTATE_badbit);
6459         return this;
6460     }
6461
6462     basic_ostream_wchar_sentry_destroy(this);
6463     return this;
6464 }
6465
6466 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
6467 {
6468     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6469     int state = IOSTATE_goodbit;
6470
6471     TRACE("(%p %d)\n", this, val);
6472
6473     if(basic_ostream_wchar_sentry_create(this)) {
6474         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6475         ostreambuf_iterator_wchar dest = {0, strbuf};
6476
6477         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
6478                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
6479                 ? (LONG)((unsigned short)val) : (LONG)val);
6480     }
6481     basic_ostream_wchar_sentry_destroy(this);
6482
6483     basic_ios_wchar_setstate(base, state);
6484     return this;
6485 }
6486
6487 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@F@Z */
6488 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@F@Z */
6489 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_short, 8)
6490 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_short(basic_ostream_wchar *this, short val)
6491 {
6492     return basic_ostream_print_short(this, val, num_put_wchar_use_facet(
6493                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6494 }
6495
6496 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
6497 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
6498 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
6499 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
6500 {
6501     return basic_ostream_print_short(this, val, num_put_short_use_facet(
6502                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6503 }
6504
6505 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@G@Z */
6506 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@G@Z */
6507 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ushort, 8)
6508 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ushort(basic_ostream_wchar *this, unsigned short val)
6509 {
6510     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6511     int state = IOSTATE_goodbit;
6512
6513     TRACE("(%p %u)\n", this, val);
6514
6515     if(basic_ostream_wchar_sentry_create(this)) {
6516         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6517         const num_put *numput = num_put_wchar_use_facet(strbuf->loc);
6518         ostreambuf_iterator_wchar dest = {0, strbuf};
6519
6520         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6521     }
6522     basic_ostream_wchar_sentry_destroy(this);
6523
6524     basic_ios_wchar_setstate(base, state);
6525     return this;
6526 }
6527
6528 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
6529 {
6530     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6531     int state = IOSTATE_goodbit;
6532
6533     TRACE("(%p %d)\n", this, val);
6534
6535     if(basic_ostream_wchar_sentry_create(this)) {
6536         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6537         ostreambuf_iterator_wchar dest = {0, strbuf};
6538
6539         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6540     }
6541     basic_ostream_wchar_sentry_destroy(this);
6542
6543     basic_ios_wchar_setstate(base, state);
6544     return this;
6545 }
6546
6547 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@H@Z */
6548 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@H@Z */
6549 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@J@Z */
6550 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@J@Z */
6551 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int, 8)
6552 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int(basic_ostream_wchar *this, int val)
6553 {
6554     return basic_ostream_print_int(this, val, num_put_wchar_use_facet(
6555                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6556 }
6557
6558 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
6559 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
6560 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
6561 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
6562 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
6563 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
6564 {
6565     return basic_ostream_print_int(this, val, num_put_short_use_facet(
6566                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6567 }
6568
6569 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
6570 {
6571     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6572     int state = IOSTATE_goodbit;
6573
6574     TRACE("(%p %u)\n", this, val);
6575
6576     if(basic_ostream_wchar_sentry_create(this)) {
6577         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6578         ostreambuf_iterator_wchar dest = {0, strbuf};
6579
6580         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6581     }
6582     basic_ostream_wchar_sentry_destroy(this);
6583
6584     basic_ios_wchar_setstate(base, state);
6585     return this;
6586 }
6587
6588 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@I@Z */
6589 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@I@Z */
6590 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@K@Z */
6591 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@K@Z */
6592 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint, 8)
6593 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint(basic_ostream_wchar *this, unsigned int val)
6594 {
6595     return basic_ostream_print_uint(this, val, num_put_wchar_use_facet(
6596                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6597 }
6598
6599 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
6600 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
6601 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
6602 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
6603 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
6604 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
6605 {
6606     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
6607                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6608 }
6609
6610 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
6611 {
6612     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6613     int state = IOSTATE_goodbit;
6614
6615     TRACE("(%p %f)\n", this, val);
6616
6617     if(basic_ostream_wchar_sentry_create(this)) {
6618         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6619         ostreambuf_iterator_wchar dest = {0, strbuf};
6620
6621         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6622     }
6623     basic_ostream_wchar_sentry_destroy(this);
6624
6625     basic_ios_wchar_setstate(base, state);
6626     return this;
6627 }
6628
6629 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@M@Z */
6630 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@M@Z */
6631 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_float, 8)
6632 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_float(basic_ostream_wchar *this, float val)
6633 {
6634     return basic_ostream_print_float(this, val, num_put_wchar_use_facet(
6635                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6636 }
6637
6638 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
6639 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
6640 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
6641 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
6642 {
6643     return basic_ostream_print_float(this, val, num_put_short_use_facet(
6644                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6645 }
6646
6647 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
6648 {
6649     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6650     int state = IOSTATE_goodbit;
6651
6652     TRACE("(%p %lf)\n", this, val);
6653
6654     if(basic_ostream_wchar_sentry_create(this)) {
6655         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6656         ostreambuf_iterator_wchar dest = {0, strbuf};
6657
6658         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6659     }
6660     basic_ostream_wchar_sentry_destroy(this);
6661
6662     basic_ios_wchar_setstate(base, state);
6663     return this;
6664 }
6665
6666 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@N@Z */
6667 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@N@Z */
6668 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_double, 12)
6669 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_double(basic_ostream_wchar *this, double val)
6670 {
6671     return basic_ostream_print_double(this, val, num_put_wchar_use_facet(
6672                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6673 }
6674
6675 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
6676 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
6677 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
6678 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
6679 {
6680     return basic_ostream_print_double(this, val, num_put_short_use_facet(
6681                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6682 }
6683
6684 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
6685 {
6686     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6687     int state = IOSTATE_goodbit;
6688
6689     TRACE("(%p %lf)\n", this, val);
6690
6691     if(basic_ostream_wchar_sentry_create(this)) {
6692         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6693         ostreambuf_iterator_wchar dest = {0, strbuf};
6694
6695         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6696     }
6697     basic_ostream_wchar_sentry_destroy(this);
6698
6699     basic_ios_wchar_setstate(base, state);
6700     return this;
6701 }
6702
6703 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@O@Z */
6704 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@O@Z */
6705 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ldouble, 12)
6706 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ldouble(basic_ostream_wchar *this, double val)
6707 {
6708     return basic_ostream_print_ldouble(this, val, num_put_wchar_use_facet(
6709                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6710 }
6711
6712 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
6713 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
6714 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
6715 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
6716 {
6717     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
6718                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6719 }
6720
6721 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6722 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
6723 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6724 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
6725 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
6726 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
6727 {
6728     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6729     IOSB_iostate state = IOSTATE_badbit;
6730     unsigned short c = '\n';
6731
6732     TRACE("(%p %p)\n", this, val);
6733
6734     if(basic_ostream_wchar_sentry_create(this)) {
6735         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
6736                 c = basic_streambuf_wchar_snextc(val)) {
6737             state = IOSTATE_goodbit;
6738
6739             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
6740                 state = IOSTATE_badbit;
6741                 break;
6742             }
6743         }
6744     }else {
6745         state = IOSTATE_badbit;
6746     }
6747     basic_ostream_wchar_sentry_destroy(this);
6748
6749     ios_base_width_set(&base->base, 0);
6750     basic_ios_wchar_setstate(base, state);
6751     return this;
6752 }
6753
6754 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
6755 {
6756     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6757     int state = IOSTATE_goodbit;
6758
6759     TRACE("(%p %p)\n", this, val);
6760
6761     if(basic_ostream_wchar_sentry_create(this)) {
6762         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6763         ostreambuf_iterator_wchar dest = {0, strbuf};
6764
6765         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6766     }
6767     basic_ostream_wchar_sentry_destroy(this);
6768
6769     basic_ios_wchar_setstate(base, state);
6770     return this;
6771 }
6772
6773 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PBX@Z */
6774 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEBX@Z */
6775 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ptr, 8)
6776 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ptr(basic_ostream_wchar *this, const void *val)
6777 {
6778     return basic_ostream_print_ptr(this, val, num_put_wchar_use_facet(
6779                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6780 }
6781
6782 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
6783 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
6784 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
6785 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
6786 {
6787     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
6788                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6789 }
6790
6791 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
6792 {
6793     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6794     int state = IOSTATE_goodbit;
6795
6796     TRACE("(%p)\n", this);
6797
6798     if(basic_ostream_wchar_sentry_create(this)) {
6799         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6800         ostreambuf_iterator_wchar dest = {0, strbuf};
6801
6802         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6803     }
6804     basic_ostream_wchar_sentry_destroy(this);
6805
6806     basic_ios_wchar_setstate(base, state);
6807     return this;
6808 }
6809
6810 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_J@Z */
6811 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_J@Z */
6812 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int64, 12)
6813 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int64(basic_ostream_wchar *this, __int64 val)
6814 {
6815     return basic_ostream_print_int64(this, val, num_put_wchar_use_facet(
6816                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6817 }
6818
6819 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
6820 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
6821 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
6822 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
6823 {
6824     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
6825                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6826 }
6827
6828 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
6829 {
6830     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6831     int state = IOSTATE_goodbit;
6832
6833     TRACE("(%p)\n", this);
6834
6835     if(basic_ostream_wchar_sentry_create(this)) {
6836         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6837         ostreambuf_iterator_wchar dest = {0, strbuf};
6838
6839         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6840     }
6841     basic_ostream_wchar_sentry_destroy(this);
6842
6843     basic_ios_wchar_setstate(base, state);
6844     return this;
6845 }
6846
6847 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_K@Z */
6848 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_K@Z */
6849 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint64, 12)
6850 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6851 {
6852     return basic_ostream_print_uint64(this, val, num_put_wchar_use_facet(
6853                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6854 }
6855
6856 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
6857 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
6858 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
6859 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
6860 {
6861     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
6862                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6863 }
6864
6865 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
6866 {
6867     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
6868     int state = IOSTATE_goodbit;
6869
6870     TRACE("(%p %x)\n", this, val);
6871
6872     if(basic_ostream_wchar_sentry_create(this)) {
6873         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6874         ostreambuf_iterator_wchar dest = {0, strbuf};
6875
6876         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
6877     }
6878     basic_ostream_wchar_sentry_destroy(this);
6879
6880     basic_ios_wchar_setstate(base, state);
6881     return this;
6882 }
6883
6884 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_N@Z */
6885 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_N@Z */
6886 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_bool, 8)
6887 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6888 {
6889     return basic_ostream_print_bool(this, val, num_put_wchar_use_facet(
6890                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6891 }
6892
6893 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
6894 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
6895 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
6896 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
6897 {
6898     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
6899                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
6900 }
6901
6902 /* ?ends@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6903 /* ?ends@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6904 /* ?ends@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6905 /* ?ends@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6906 basic_ostream_wchar* __cdecl basic_ostream_wchar_ends(basic_ostream_wchar *ostr)
6907 {
6908     TRACE("(%p)\n", ostr);
6909
6910     basic_ostream_wchar_put(ostr, 0);
6911     return ostr;
6912 }
6913
6914 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6915 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6916 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6917 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6918 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
6919 {
6920     TRACE("(%p)\n", ostr);
6921
6922     basic_ostream_wchar_put(ostr, '\n');
6923     basic_ostream_wchar_flush(ostr);
6924     return ostr;
6925 }
6926
6927 /* ??$?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 */
6928 /* ??$?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 */
6929 /* ??$?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 */
6930 /* ??$?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 */
6931 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_bstr(basic_ostream_wchar *ostr, const basic_string_wchar *str)
6932 {
6933     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6934     IOSB_iostate state = IOSTATE_goodbit;
6935
6936     TRACE("(%p %p)\n", ostr, str);
6937
6938     if(basic_ostream_wchar_sentry_create(ostr)) {
6939         MSVCP_size_t len = MSVCP_basic_string_wchar_length(str);
6940         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
6941
6942         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6943             for(; pad!=0; pad--) {
6944                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6945                     state = IOSTATE_badbit;
6946                     break;
6947                 }
6948             }
6949         }
6950
6951         if(state == IOSTATE_goodbit) {
6952             if(basic_streambuf_wchar_sputn(base->strbuf, MSVCP_basic_string_wchar_c_str(str), len) != len)
6953                 state = IOSTATE_badbit;
6954         }
6955
6956         if(state == IOSTATE_goodbit) {
6957             for(; pad!=0; pad--) {
6958                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6959                     state = IOSTATE_badbit;
6960                     break;
6961                 }
6962             }
6963         }
6964
6965         base->base.wide = 0;
6966     }else {
6967         state = IOSTATE_badbit;
6968     }
6969     basic_ostream_wchar_sentry_destroy(ostr);
6970
6971     basic_ios_wchar_setstate(base, state);
6972     return ostr;
6973 }
6974
6975 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@_W@Z */
6976 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@_W@Z */
6977 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@G@Z */
6978 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@G@Z */
6979 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_ch(basic_ostream_wchar *ostr, wchar_t ch)
6980 {
6981     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
6982     IOSB_iostate state = IOSTATE_goodbit;
6983
6984     TRACE("(%p %d)\n", ostr, ch);
6985
6986     if(basic_ostream_wchar_sentry_create(ostr)) {
6987         streamsize pad = (base->base.wide>1 ? base->base.wide-1 : 0);
6988
6989         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
6990             for(; pad!=0; pad--) {
6991                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
6992                     state = IOSTATE_badbit;
6993                     break;
6994                 }
6995             }
6996         }
6997
6998         if(state == IOSTATE_goodbit) {
6999             if(basic_streambuf_wchar_sputc(base->strbuf, ch) == WEOF)
7000                 state = IOSTATE_badbit;
7001         }
7002
7003         if(state == IOSTATE_goodbit) {
7004             for(; pad!=0; pad--) {
7005                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7006                     state = IOSTATE_badbit;
7007                     break;
7008                 }
7009             }
7010         }
7011
7012         base->base.wide = 0;
7013     }else {
7014         state = IOSTATE_badbit;
7015     }
7016     basic_ostream_wchar_sentry_destroy(ostr);
7017
7018     basic_ios_wchar_setstate(base, state);
7019     return ostr;
7020 }
7021
7022 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AAV10@PB_W@Z */
7023 /* ??$?6_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@0@AEAV10@PEB_W@Z */
7024 /* ??$?6GU?$char_traits@G@std@@@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@0@AAV10@PBG@Z */
7025 /* ??$?6GU?$char_traits@G@std@@@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@0@AEAV10@PEBG@Z */
7026 basic_ostream_wchar* __cdecl basic_ostream_wchar_print_str(basic_ostream_wchar *ostr, const wchar_t *str)
7027 {
7028     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
7029     IOSB_iostate state = IOSTATE_goodbit;
7030
7031     TRACE("(%p %s)\n", ostr, debugstr_w(str));
7032
7033     if(basic_ostream_wchar_sentry_create(ostr)) {
7034         MSVCP_size_t len = wcslen(str);
7035         streamsize pad = (base->base.wide>len ? base->base.wide-len : 0);
7036
7037         if((base->base.fmtfl & FMTFLAG_adjustfield) != FMTFLAG_left) {
7038             for(; pad!=0; pad--) {
7039                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7040                     state = IOSTATE_badbit;
7041                     break;
7042                 }
7043             }
7044         }
7045
7046         if(state == IOSTATE_goodbit) {
7047             if(basic_streambuf_wchar_sputn(base->strbuf, str, len) != len)
7048                                         state = IOSTATE_badbit;
7049         }
7050
7051         if(state == IOSTATE_goodbit) {
7052             for(; pad!=0; pad--) {
7053                 if(basic_streambuf_wchar_sputc(base->strbuf, base->fillch) == WEOF) {
7054                     state = IOSTATE_badbit;
7055                     break;
7056                 }
7057             }
7058         }
7059
7060         base->base.wide = 0;
7061     }else {
7062         state = IOSTATE_badbit;
7063     }
7064     basic_ostream_wchar_sentry_destroy(ostr);
7065
7066     basic_ios_wchar_setstate(base, state);
7067     return ostr;
7068 }
7069
7070 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7071 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7072 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7073 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7074 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
7075 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
7076         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
7077 {
7078     TRACE("(%p %p)\n", this, pfunc);
7079     pfunc(this);
7080     return this;
7081 }
7082
7083 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
7084 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
7085 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
7086 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
7087 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
7088 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
7089         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
7090 {
7091     TRACE("(%p %p)\n", this, pfunc);
7092     pfunc(basic_ostream_wchar_get_basic_ios(this));
7093     return this;
7094 }
7095
7096 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7097 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7098 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7099 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7100 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
7101 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
7102         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
7103 {
7104     TRACE("(%p %p)\n", this, pfunc);
7105     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
7106     return this;
7107 }
7108
7109 /* Caution: basic_istream uses virtual inheritance. */
7110 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
7111 {
7112     return (basic_ios_char*)((char*)this+this->vbtable[1]);
7113 }
7114
7115 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
7116 {
7117     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
7118 }
7119
7120 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
7121 {
7122     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
7123 }
7124
7125 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
7126 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
7127 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_init, 20)
7128 basic_istream_char* __thiscall basic_istream_char_ctor_init(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
7129 {
7130     basic_ios_char *base;
7131
7132     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
7133
7134     if(virt_init) {
7135         this->vbtable = basic_istream_char_vbtable;
7136         base = basic_istream_char_get_basic_ios(this);
7137         basic_ios_char_ctor(base);
7138     }else {
7139         base = basic_istream_char_get_basic_ios(this);
7140     }
7141
7142     base->base.vtable = &MSVCP_basic_istream_char_vtable;
7143     this->count = 0;
7144     if(!noinit)
7145         basic_ios_char_init(base, strbuf, isstd);
7146     return this;
7147 }
7148
7149 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
7150 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
7151 static basic_istream_char* basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
7152 {
7153     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
7154 }
7155
7156 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
7157 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
7158 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
7159 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
7160 {
7161     basic_ios_char *base;
7162
7163     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
7164
7165     if(virt_init) {
7166         this->vbtable = basic_istream_char_vbtable;
7167         base = basic_istream_char_get_basic_ios(this);
7168         basic_ios_char_ctor(base);
7169     }else {
7170         base = basic_istream_char_get_basic_ios(this);
7171     }
7172
7173     base->base.vtable = &MSVCP_basic_istream_char_vtable;
7174     ios_base_Addstd(&base->base);
7175     return this;
7176 }
7177
7178 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
7179 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
7180 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
7181 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
7182 {
7183     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
7184
7185     /* don't destroy virtual base here */
7186     TRACE("(%p)\n", this);
7187 }
7188
7189 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
7190 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
7191 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
7192 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
7193 {
7194     TRACE("(%p)\n", this);
7195     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
7196     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
7197 }
7198
7199 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
7200 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
7201 {
7202     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
7203
7204     TRACE("(%p %x)\n", this, flags);
7205
7206     if(flags & 2) {
7207         /* we have an array, with the number of elements stored before the first object */
7208         INT_PTR i, *ptr = (INT_PTR *)this-1;
7209
7210         for(i=*ptr-1; i>=0; i--)
7211             basic_istream_char_vbase_dtor(this+i);
7212         MSVCRT_operator_delete(ptr);
7213     } else {
7214         basic_istream_char_vbase_dtor(this);
7215         if(flags & 1)
7216             MSVCRT_operator_delete(this);
7217     }
7218
7219     return this;
7220 }
7221
7222 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
7223 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
7224 DEFINE_THISCALL_WRAPPER(basic_istream_char__Ipfx, 8)
7225 MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
7226 {
7227     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7228
7229     TRACE("(%p %d)\n", this, noskip);
7230
7231     if(ios_base_good(&base->base)) {
7232         if(basic_ios_char_tie_get(base))
7233             basic_ostream_char_flush(basic_ios_char_tie_get(base));
7234
7235         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
7236             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7237             const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
7238             int ch;
7239
7240             for(ch = basic_streambuf_char_sgetc(strbuf); ;
7241                     ch = basic_streambuf_char_snextc(strbuf)) {
7242                 if(ch == EOF) {
7243                     basic_ios_char_setstate(base, IOSTATE_eofbit);
7244                     break;
7245                 }
7246
7247                 if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
7248                     break;
7249             }
7250         }
7251     }
7252
7253     if(!ios_base_good(&base->base)) {
7254         basic_ios_char_setstate(base, IOSTATE_failbit);
7255         return FALSE;
7256     }
7257
7258     return TRUE;
7259 }
7260
7261 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
7262 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
7263 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
7264 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
7265 {
7266     return basic_istream_char__Ipfx(this, noskip);
7267 }
7268
7269 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
7270 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
7271 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
7272 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
7273 {
7274     TRACE("(%p)\n", this);
7275 }
7276
7277 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
7278 {
7279     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
7280
7281     if(basic_ios_char_rdbuf_get(base))
7282         basic_streambuf_char__Lock(base->strbuf);
7283
7284     return basic_istream_char_ipfx(istr, noskip);
7285 }
7286
7287 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
7288 {
7289     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
7290
7291     if(basic_ios_char_rdbuf_get(base))
7292         basic_streambuf_char__Unlock(base->strbuf);
7293 }
7294
7295 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
7296 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
7297 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
7298 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
7299 {
7300     TRACE("(%p)\n", this);
7301     return this->count;
7302 }
7303
7304 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7305 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7306 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
7307 int __thiscall basic_istream_char_get(basic_istream_char *this)
7308 {
7309     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7310     int ret;
7311
7312     TRACE("(%p)\n", this);
7313
7314     this->count = 0;
7315
7316     if(!basic_istream_char_sentry_create(this, TRUE)) {
7317         basic_istream_char_sentry_destroy(this);
7318         return EOF;
7319     }
7320
7321     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
7322     basic_istream_char_sentry_destroy(this);
7323     if(ret == EOF)
7324         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
7325     else
7326         this->count++;
7327
7328     return ret;
7329 }
7330
7331 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
7332 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
7333 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
7334 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
7335 {
7336     int ret;
7337
7338     TRACE("(%p %p)\n", this, ch);
7339
7340     ret = basic_istream_char_get(this);
7341     if(ret != EOF)
7342         *ch = (char)ret;
7343     return this;
7344 }
7345
7346 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7347 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7348 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 16)
7349 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7350 {
7351     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7352     int ch = delim;
7353
7354     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7355
7356     this->count = 0;
7357
7358     if(basic_istream_char_sentry_create(this, TRUE)) {
7359         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7360
7361         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
7362                 ch = basic_streambuf_char_snextc(strbuf)) {
7363             if(ch==EOF || ch==delim)
7364                 break;
7365
7366             *str++ = ch;
7367             this->count++;
7368             count--;
7369         }
7370     }
7371     basic_istream_char_sentry_destroy(this);
7372
7373     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7374             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7375     if(count > 0)
7376         *str = 0;
7377     return this;
7378 }
7379
7380 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7381 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7382 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 12)
7383 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
7384 {
7385     return basic_istream_char_get_str_delim(this, str, count, '\n');
7386 }
7387
7388 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7389 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
7390 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
7391 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
7392 {
7393     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7394     int ch = delim;
7395
7396     TRACE("(%p %p %c)\n", this, strbuf, delim);
7397
7398     this->count = 0;
7399
7400     if(basic_istream_char_sentry_create(this, TRUE)) {
7401         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
7402
7403         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
7404                 ch = basic_streambuf_char_snextc(strbuf_read)) {
7405             if(ch==EOF || ch==delim)
7406                 break;
7407
7408             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
7409                 break;
7410             this->count++;
7411         }
7412     }
7413     basic_istream_char_sentry_destroy(this);
7414
7415     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
7416             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7417     return this;
7418 }
7419
7420 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7421 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
7422 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
7423 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
7424 {
7425     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
7426 }
7427
7428 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
7429 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
7430 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 16)
7431 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
7432 {
7433     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7434     int ch = (unsigned char)delim;
7435
7436     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
7437
7438     this->count = 0;
7439
7440     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
7441         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7442
7443         while(count > 1) {
7444             ch = basic_streambuf_char_sbumpc(strbuf);
7445
7446             if(ch==EOF || ch==(unsigned char)delim)
7447                 break;
7448
7449             *str++ = ch;
7450             this->count++;
7451             count--;
7452         }
7453
7454         if(ch == (unsigned char)delim)
7455             this->count++;
7456         else if(ch != EOF) {
7457             ch = basic_streambuf_char_sgetc(strbuf);
7458
7459             if(ch == (unsigned char)delim) {
7460                 basic_streambuf_char__Gninc(strbuf);
7461                 this->count++;
7462             }
7463         }
7464     }
7465     basic_istream_char_sentry_destroy(this);
7466
7467     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
7468             (!this->count || (ch!=(unsigned char)delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
7469     if(count > 0)
7470         *str = 0;
7471     return this;
7472 }
7473
7474 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7475 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7476 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 12)
7477 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
7478 {
7479     return basic_istream_char_getline_delim(this, str, count, '\n');
7480 }
7481
7482 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
7483 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7484 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 12)
7485 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
7486 {
7487     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7488     int ch = (unsigned char)delim;
7489     unsigned int state;
7490
7491     TRACE("(%p %ld %d)\n", this, count, delim);
7492
7493     this->count = 0;
7494
7495     if(basic_istream_char_sentry_create(this, TRUE)) {
7496         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7497         state = IOSTATE_goodbit;
7498
7499         while(count > 0) {
7500             ch = basic_streambuf_char_sbumpc(strbuf);
7501
7502             if(ch==EOF) {
7503                 state = IOSTATE_eofbit;
7504                 break;
7505             }
7506
7507             if(ch==(unsigned char)delim)
7508                 break;
7509
7510             this->count++;
7511             if(count != INT_MAX)
7512                 count--;
7513         }
7514     }else
7515         state = IOSTATE_failbit;
7516     basic_istream_char_sentry_destroy(this);
7517
7518     basic_ios_char_setstate(base, state);
7519     return this;
7520 }
7521
7522 /* ?ws@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@1@AAV21@@Z */
7523 /* ?ws@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
7524 basic_istream_char* __cdecl ws_basic_istream_char(basic_istream_char *istream)
7525 {
7526     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
7527     int ch = '\n';
7528
7529     TRACE("(%p)\n", istream);
7530
7531     if(basic_istream_char_sentry_create(istream, TRUE)) {
7532         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7533         const ctype_char *ctype = ctype_char_use_facet(strbuf->loc);
7534
7535         for(ch = basic_streambuf_char_sgetc(strbuf); ctype_char_is_ch(ctype, _SPACE, ch);
7536                 ch = basic_streambuf_char_snextc(strbuf)) {
7537             if(ch == EOF)
7538                 break;
7539         }
7540     }
7541     basic_istream_char_sentry_destroy(istream);
7542
7543     if(ch == EOF)
7544         basic_ios_char_setstate(base, IOSTATE_eofbit);
7545     return istream;
7546 }
7547
7548 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7549 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7550 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
7551 int __thiscall basic_istream_char_peek(basic_istream_char *this)
7552 {
7553     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7554     int ret = EOF;
7555
7556     TRACE("(%p)\n", this);
7557
7558     this->count = 0;
7559
7560     if(basic_istream_char_sentry_create(this, TRUE))
7561         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
7562     basic_istream_char_sentry_destroy(this);
7563
7564     if (ret == EOF)
7565         basic_ios_char_setstate(base, IOSTATE_eofbit);
7566
7567     return ret;
7568 }
7569
7570 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
7571 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
7572 static basic_istream_char* basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7573 {
7574     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7575     IOSB_iostate state = IOSTATE_goodbit;
7576
7577     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7578
7579     if(basic_istream_char_sentry_create(this, TRUE)) {
7580         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7581
7582         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
7583         if(this->count != count)
7584             state |= IOSTATE_failbit | IOSTATE_eofbit;
7585     }else {
7586         this->count = 0;
7587     }
7588     basic_istream_char_sentry_destroy(this);
7589
7590     basic_ios_char_setstate(base, state);
7591     return this;
7592 }
7593
7594 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
7595 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
7596 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 12)
7597 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
7598 {
7599     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7600     IOSB_iostate state = IOSTATE_goodbit;
7601
7602     TRACE("(%p %p %ld)\n", this, str, count);
7603
7604     if(basic_istream_char_sentry_create(this, TRUE)) {
7605         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7606
7607         this->count = basic_streambuf_char_sgetn(strbuf, str, count);
7608         if(this->count != count)
7609             state |= IOSTATE_failbit | IOSTATE_eofbit;
7610     }else {
7611         this->count = 0;
7612     }
7613     basic_istream_char_sentry_destroy(this);
7614
7615     basic_ios_char_setstate(base, state);
7616     return this;
7617 }
7618
7619 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
7620 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
7621 static streamsize basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
7622 {
7623     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7624     IOSB_iostate state = IOSTATE_goodbit;
7625
7626     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
7627
7628     this->count = 0;
7629
7630     if(basic_istream_char_sentry_create(this, TRUE)) {
7631         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
7632         if(avail > count)
7633             avail = count;
7634
7635         if(avail == -1)
7636             state |= IOSTATE_eofbit;
7637         else if(avail > 0)
7638             basic_istream_char__Read_s(this, str, size, avail);
7639     }else {
7640         state |= IOSTATE_failbit;
7641     }
7642     basic_istream_char_sentry_destroy(this);
7643
7644     basic_ios_char_setstate(base, state);
7645     return this->count;
7646 }
7647
7648 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
7649 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
7650 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 12)
7651 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
7652 {
7653     return basic_istream_char__Readsome_s(this, str, count, count);
7654 }
7655
7656 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
7657 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
7658 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
7659 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
7660 {
7661     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7662     IOSB_iostate state = IOSTATE_goodbit;
7663
7664     TRACE("(%p %c)\n", this, ch);
7665
7666     this->count = 0;
7667
7668     if(basic_istream_char_sentry_create(this, TRUE)) {
7669         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7670
7671         if(!ios_base_good(&base->base))
7672             state |= IOSTATE_failbit;
7673         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
7674             state |= IOSTATE_badbit;
7675     }
7676     basic_istream_char_sentry_destroy(this);
7677
7678     basic_ios_char_setstate(base, state);
7679     return this;
7680 }
7681
7682 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
7683 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
7684 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
7685 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
7686 {
7687     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7688     IOSB_iostate state = IOSTATE_goodbit;
7689
7690     TRACE("(%p)\n", this);
7691
7692     this->count = 0;
7693
7694     if(basic_istream_char_sentry_create(this, TRUE)) {
7695         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7696
7697         if(!ios_base_good(&base->base))
7698             state |= IOSTATE_failbit;
7699         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
7700             state |= IOSTATE_badbit;
7701     }
7702     basic_istream_char_sentry_destroy(this);
7703
7704     basic_ios_char_setstate(base, state);
7705     return this;
7706 }
7707
7708 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
7709 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
7710 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
7711 int __thiscall basic_istream_char_sync(basic_istream_char *this)
7712 {
7713     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7714     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7715
7716     TRACE("(%p)\n", this);
7717
7718     if(!strbuf)
7719         return -1;
7720
7721     if(basic_istream_char_sentry_create(this, TRUE)) {
7722         if(basic_streambuf_char_pubsync(strbuf) != -1) {
7723             basic_istream_char_sentry_destroy(this);
7724             return 0;
7725         }
7726     }
7727     basic_istream_char_sentry_destroy(this);
7728
7729     basic_ios_char_setstate(base, IOSTATE_badbit);
7730     return -1;
7731 }
7732
7733 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7734 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7735 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
7736 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
7737 {
7738     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7739
7740     TRACE("(%p %p)\n", this, ret);
7741
7742     if(ios_base_fail(&base->base)) {
7743         ret->off = -1;
7744         ret->pos = 0;
7745         ret->state = 0;
7746         return ret;
7747     }
7748
7749     basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
7750             ret, 0, SEEKDIR_cur, OPENMODE_in);
7751
7752     if(ret->off==-1 && ret->pos==0 && ret->state==0)
7753         basic_ios_char_setstate(base, IOSTATE_failbit);
7754
7755     return ret;
7756 }
7757
7758 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
7759 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
7760 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 12)
7761 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
7762 {
7763     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7764
7765     TRACE("(%p %ld %d)\n", this, off, dir);
7766
7767     if(!ios_base_fail(&base->base)) {
7768         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7769         fpos_int ret;
7770
7771         basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
7772
7773         if(ret.off==-1 && ret.pos==0 && ret.state==0)
7774             basic_ios_char_setstate(base, IOSTATE_failbit);
7775         else
7776             basic_ios_char_clear(base, IOSTATE_goodbit);
7777         return this;
7778     }else
7779         basic_ios_char_clear(base, IOSTATE_goodbit);
7780
7781     return this;
7782 }
7783
7784 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7785 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7786 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
7787 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
7788 {
7789     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7790
7791     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7792
7793     if(!ios_base_fail(&base->base)) {
7794         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7795         fpos_int ret;
7796
7797         basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7798
7799         if(ret.off==-1 && ret.pos==0 && ret.state==0)
7800             basic_ios_char_setstate(base, IOSTATE_failbit);
7801         else
7802             basic_ios_char_clear(base, IOSTATE_goodbit);
7803         return this;
7804     }else
7805         basic_ios_char_clear(base, IOSTATE_goodbit);
7806
7807     return this;
7808 }
7809
7810 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
7811 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
7812 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
7813 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
7814 {
7815     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7816     int state = IOSTATE_goodbit;
7817
7818     TRACE("(%p %p)\n", this, v);
7819
7820     if(basic_istream_char_sentry_create(this, FALSE)) {
7821         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7822         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7823         istreambuf_iterator_char first={0}, last={0};
7824         LONG tmp;
7825
7826         first.strbuf = strbuf;
7827         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7828
7829         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7830             *v = tmp;
7831         else
7832             state |= IOSTATE_failbit;
7833     }
7834     basic_istream_char_sentry_destroy(this);
7835
7836     basic_ios_char_setstate(base, state);
7837     return this;
7838 }
7839
7840 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
7841 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
7842 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
7843 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
7844 {
7845     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7846     int state = IOSTATE_goodbit;
7847
7848     TRACE("(%p %p)\n", this, v);
7849
7850     if(basic_istream_char_sentry_create(this, FALSE)) {
7851         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7852         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7853         istreambuf_iterator_char first={0}, last={0};
7854
7855         first.strbuf = strbuf;
7856         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
7857     }
7858     basic_istream_char_sentry_destroy(this);
7859
7860     basic_ios_char_setstate(base, state);
7861     return this;
7862 }
7863
7864 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
7865 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
7866 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
7867 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
7868 {
7869     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7870     int state = IOSTATE_goodbit;
7871
7872     TRACE("(%p %p)\n", this, v);
7873
7874     if(basic_istream_char_sentry_create(this, FALSE)) {
7875         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7876         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7877         istreambuf_iterator_char first={0}, last={0};
7878
7879         first.strbuf = strbuf;
7880         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7881     }
7882     basic_istream_char_sentry_destroy(this);
7883
7884     basic_ios_char_setstate(base, state);
7885     return this;
7886 }
7887
7888 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
7889 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
7890 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
7891 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *v)
7892 {
7893     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7894     int state = IOSTATE_goodbit;
7895
7896     TRACE("(%p %p)\n", this, v);
7897
7898     if(basic_istream_char_sentry_create(this, FALSE)) {
7899         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7900         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7901         istreambuf_iterator_char first={0}, last={0};
7902
7903         first.strbuf = strbuf;
7904         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
7905     }
7906     basic_istream_char_sentry_destroy(this);
7907
7908     basic_ios_char_setstate(base, state);
7909     return this;
7910 }
7911
7912 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
7913 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
7914 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
7915 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
7916 {
7917     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7918     int state = IOSTATE_goodbit;
7919
7920     TRACE("(%p %p)\n", this, v);
7921
7922     if(basic_istream_char_sentry_create(this, FALSE)) {
7923         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7924         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7925         istreambuf_iterator_char first={0}, last={0};
7926
7927         first.strbuf = strbuf;
7928         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
7929     }
7930     basic_istream_char_sentry_destroy(this);
7931
7932     basic_ios_char_setstate(base, state);
7933     return this;
7934 }
7935
7936 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
7937 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
7938 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
7939 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
7940 {
7941     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7942     int state = IOSTATE_goodbit;
7943
7944     TRACE("(%p %p)\n", this, v);
7945
7946     if(basic_istream_char_sentry_create(this, FALSE)) {
7947         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7948         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7949         istreambuf_iterator_char first={0}, last={0};
7950
7951         first.strbuf = strbuf;
7952         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
7953     }
7954     basic_istream_char_sentry_destroy(this);
7955
7956     basic_ios_char_setstate(base, state);
7957     return this;
7958 }
7959
7960 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
7961 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
7962 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
7963 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
7964 {
7965     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7966     int state = IOSTATE_goodbit;
7967
7968     TRACE("(%p %p)\n", this, v);
7969
7970     if(basic_istream_char_sentry_create(this, FALSE)) {
7971         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7972         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7973         istreambuf_iterator_char first={0}, last={0};
7974
7975         first.strbuf = strbuf;
7976         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
7977     }
7978     basic_istream_char_sentry_destroy(this);
7979
7980     basic_ios_char_setstate(base, state);
7981     return this;
7982 }
7983
7984 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
7985 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
7986 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
7987 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
7988 {
7989     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
7990     int state = IOSTATE_goodbit;
7991
7992     TRACE("(%p %p)\n", this, v);
7993
7994     if(basic_istream_char_sentry_create(this, FALSE)) {
7995         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
7996         const num_get *numget = num_get_char_use_facet(strbuf->loc);
7997         istreambuf_iterator_char first={0}, last={0};
7998
7999         first.strbuf = strbuf;
8000         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
8001     }
8002     basic_istream_char_sentry_destroy(this);
8003
8004     basic_ios_char_setstate(base, state);
8005     return this;
8006 }
8007
8008 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
8009 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
8010 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
8011 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
8012 {
8013     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8014     int state = IOSTATE_goodbit;
8015
8016     TRACE("(%p %p)\n", this, v);
8017
8018     if(basic_istream_char_sentry_create(this, FALSE)) {
8019         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8020         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8021         istreambuf_iterator_char first={0}, last={0};
8022
8023         first.strbuf = strbuf;
8024         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
8025     }
8026     basic_istream_char_sentry_destroy(this);
8027
8028     basic_ios_char_setstate(base, state);
8029     return this;
8030 }
8031
8032 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
8033 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
8034 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
8035 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
8036 {
8037     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8038     int state = IOSTATE_goodbit;
8039
8040     TRACE("(%p %p)\n", this, v);
8041
8042     if(basic_istream_char_sentry_create(this, FALSE)) {
8043         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8044         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8045         istreambuf_iterator_char first={0}, last={0};
8046
8047         first.strbuf = strbuf;
8048         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
8049     }
8050     basic_istream_char_sentry_destroy(this);
8051
8052     basic_ios_char_setstate(base, state);
8053     return this;
8054 }
8055
8056 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
8057 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
8058 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
8059 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
8060 {
8061     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8062     int state = IOSTATE_goodbit;
8063
8064     TRACE("(%p %p)\n", this, v);
8065
8066     if(basic_istream_char_sentry_create(this, FALSE)) {
8067         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8068         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8069         istreambuf_iterator_char first={0}, last={0};
8070
8071         first.strbuf = strbuf;
8072         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
8073     }
8074     basic_istream_char_sentry_destroy(this);
8075
8076     basic_ios_char_setstate(base, state);
8077     return this;
8078 }
8079
8080 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
8081 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
8082 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
8083 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
8084 {
8085     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8086     int state = IOSTATE_goodbit;
8087
8088     TRACE("(%p %p)\n", this, v);
8089
8090     if(basic_istream_char_sentry_create(this, FALSE)) {
8091         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8092         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8093         istreambuf_iterator_char first={0}, last={0};
8094
8095         first.strbuf = strbuf;
8096         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
8097     }
8098     basic_istream_char_sentry_destroy(this);
8099
8100     basic_ios_char_setstate(base, state);
8101     return this;
8102 }
8103
8104 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
8105 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
8106 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
8107 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
8108 {
8109     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8110     int state = IOSTATE_goodbit;
8111
8112     TRACE("(%p %p)\n", this, v);
8113
8114     if(basic_istream_char_sentry_create(this, FALSE)) {
8115         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8116         const num_get *numget = num_get_char_use_facet(strbuf->loc);
8117         istreambuf_iterator_char first={0}, last={0};
8118
8119         first.strbuf = strbuf;
8120         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
8121     }
8122     basic_istream_char_sentry_destroy(this);
8123
8124     basic_ios_char_setstate(base, state);
8125     return this;
8126 }
8127
8128 /* ??$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 */
8129 /* ??$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 */
8130 basic_istream_char* __cdecl basic_istream_char_getline_bstr_delim(
8131         basic_istream_char *istream, basic_string_char *str, char delim)
8132 {
8133     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
8134     IOSB_iostate state = IOSTATE_goodbit;
8135     int c = (unsigned char)delim;
8136
8137     TRACE("(%p %p %c)\n", istream, str, delim);
8138
8139     if(basic_istream_char_sentry_create(istream, TRUE)) {
8140         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
8141         MSVCP_basic_string_char_clear(str);
8142
8143         c = basic_streambuf_char_sgetc(strbuf);
8144         for(; c!=(unsigned char)delim && c!=EOF; c = basic_streambuf_char_snextc(strbuf))
8145             MSVCP_basic_string_char_append_ch(str, c);
8146         if(c==EOF) state |= IOSTATE_eofbit;
8147         else if(c==(unsigned char)delim) basic_streambuf_char_sbumpc(strbuf);
8148
8149         if(!MSVCP_basic_string_char_length(str) && c!=(unsigned char)delim) state |= IOSTATE_failbit;
8150     }
8151     basic_istream_char_sentry_destroy(istream);
8152
8153     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream), state);
8154     return istream;
8155 }
8156
8157 /* ??$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 */
8158 /* ??$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 */
8159 basic_istream_char* __cdecl basic_istream_char_getline_bstr(
8160         basic_istream_char *istream, basic_string_char *str)
8161 {
8162     return basic_istream_char_getline_bstr_delim(istream, str, '\n');
8163 }
8164
8165 /* ??$?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 */
8166 /* ??$?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 */
8167 basic_istream_char* __cdecl basic_istream_char_read_bstr(
8168         basic_istream_char *istream, basic_string_char *str)
8169 {
8170     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
8171     IOSB_iostate state = IOSTATE_failbit;
8172     int c = '\n';
8173
8174     TRACE("(%p %p)\n", istream, str);
8175
8176     if(basic_istream_char_sentry_create(istream, FALSE)) {
8177         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
8178         MSVCP_size_t count = ios_base_width_get(&base->base);
8179
8180         if(!count)
8181             count = -1;
8182
8183         MSVCP_basic_string_char_clear(str);
8184
8185         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
8186                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8187                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
8188             state = IOSTATE_goodbit;
8189             MSVCP_basic_string_char_append_ch(str, c);
8190         }
8191     }
8192     basic_istream_char_sentry_destroy(istream);
8193
8194     ios_base_width_set(&base->base, 0);
8195     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8196     return istream;
8197 }
8198
8199 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAD@Z */
8200 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAD@Z */
8201 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAC@Z */
8202 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAC@Z */
8203 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@PAE@Z */
8204 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@PEAE@Z */
8205 basic_istream_char* __cdecl basic_istream_char_read_str(basic_istream_char *istream, char *str)
8206 {
8207     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
8208     IOSB_iostate state = IOSTATE_failbit;
8209     int c = '\n';
8210
8211     TRACE("(%p %p)\n", istream, str);
8212
8213     if(basic_istream_char_sentry_create(istream, FALSE)) {
8214         const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
8215         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
8216
8217         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
8218                 c!=EOF && !ctype_char_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
8219                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base)), count--) {
8220             state = IOSTATE_goodbit;
8221             *str++ = c;
8222         }
8223     }
8224     basic_istream_char_sentry_destroy(istream);
8225
8226     *str = 0;
8227     ios_base_width_set(&base->base, 0);
8228     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8229     return istream;
8230 }
8231
8232 /* ??$?5DU?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAD@Z */
8233 /* ??$?5DU?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAD@Z */
8234 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAC@Z */
8235 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAC@Z */
8236 /* ??$?5U?$char_traits@D@std@@@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@0@AAV10@AAE@Z */
8237 /* ??$?5U?$char_traits@D@std@@@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@0@AEAV10@AEAE@Z */
8238 basic_istream_char* __cdecl basic_istream_char_read_ch(basic_istream_char *istream, char *ch)
8239 {
8240     IOSB_iostate state = IOSTATE_failbit;
8241     int c = 0;
8242
8243     TRACE("(%p %p)\n", istream, ch);
8244
8245     if(basic_istream_char_sentry_create(istream, FALSE)) {
8246         c = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(
8247                     basic_istream_char_get_basic_ios(istream)));
8248         if(c != EOF) {
8249             state = IOSTATE_goodbit;
8250             *ch = c;
8251         }
8252     }
8253     basic_istream_char_sentry_destroy(istream);
8254
8255     basic_ios_char_setstate(basic_istream_char_get_basic_ios(istream),
8256             state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8257     return istream;
8258 }
8259
8260 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
8261 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
8262 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
8263 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
8264         basic_istream_char *this, basic_streambuf_char *streambuf)
8265 {
8266     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
8267     IOSB_iostate state = IOSTATE_failbit;
8268     int c = '\n';
8269
8270     TRACE("(%p %p)\n", this, streambuf);
8271
8272     if(basic_istream_char_sentry_create(this, FALSE)) {
8273         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
8274                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
8275             state = IOSTATE_goodbit;
8276             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
8277                 break;
8278         }
8279     }
8280     basic_istream_char_sentry_destroy(this);
8281
8282     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8283     return this;
8284 }
8285
8286 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
8287 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
8288 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
8289 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
8290         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
8291 {
8292     TRACE("(%p %p)\n", this, pfunc);
8293     pfunc(this);
8294     return this;
8295 }
8296
8297 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
8298 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
8299 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
8300 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
8301         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
8302 {
8303     TRACE("(%p %p)\n", this, pfunc);
8304     pfunc(basic_istream_char_get_basic_ios(this));
8305     return this;
8306 }
8307
8308 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
8309 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
8310 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
8311 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
8312         ios_base* (__cdecl *pfunc)(ios_base*))
8313 {
8314     TRACE("(%p %p)\n", this, pfunc);
8315     pfunc(&basic_istream_char_get_basic_ios(this)->base);
8316     return this;
8317 }
8318
8319 /* Caution: basic_istream uses virtual inheritance. */
8320 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
8321 {
8322     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
8323 }
8324
8325 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
8326 {
8327     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
8328 }
8329
8330 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
8331 {
8332     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
8333 }
8334
8335 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
8336 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
8337 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_init, 20)
8338 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_init(basic_istream_wchar *this,
8339         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
8340 {
8341     basic_ios_wchar *base;
8342
8343     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
8344
8345     if(virt_init) {
8346         this->vbtable = basic_istream_wchar_vbtable;
8347         base = basic_istream_wchar_get_basic_ios(this);
8348         basic_ios_wchar_ctor(base);
8349     }else {
8350         base = basic_istream_wchar_get_basic_ios(this);
8351     }
8352
8353     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8354     this->count = 0;
8355     if(!noinit)
8356         basic_ios_wchar_init(base, strbuf, isstd);
8357     return this;
8358 }
8359
8360 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
8361 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
8362 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_init, 20)
8363 basic_istream_wchar* __thiscall basic_istream_short_ctor_init(basic_istream_wchar *this,
8364         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
8365 {
8366     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
8367     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8368     return this;
8369 }
8370
8371 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8372 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
8373 static basic_istream_wchar* basic_istream_wchar_ctor(basic_istream_wchar *this,
8374         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8375 {
8376     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8377 }
8378
8379 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8380 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
8381 static basic_istream_wchar* basic_istream_short_ctor(basic_istream_wchar *this,
8382         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
8383 {
8384     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
8385 }
8386
8387 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8388 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8389 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_uninitialized, 12)
8390 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_uninitialized(
8391         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8392 {
8393     basic_ios_wchar *base;
8394
8395     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
8396
8397     if(virt_init) {
8398         this->vbtable = basic_istream_wchar_vbtable;
8399         base = basic_istream_wchar_get_basic_ios(this);
8400         basic_ios_wchar_ctor(base);
8401     }else {
8402         base = basic_istream_wchar_get_basic_ios(this);
8403     }
8404
8405     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
8406     ios_base_Addstd(&base->base);
8407     return this;
8408 }
8409
8410 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
8411 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
8412 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
8413 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
8414         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
8415 {
8416     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
8417     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
8418     return this;
8419 }
8420
8421 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
8422 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
8423 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
8424 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
8425 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
8426 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
8427 {
8428     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8429
8430     /* don't destroy virtual base here */
8431     TRACE("(%p)\n", this);
8432 }
8433
8434 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8435 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8436 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8437 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8438 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
8439 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
8440 {
8441     TRACE("(%p)\n", this);
8442     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
8443     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
8444 }
8445
8446 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
8447 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
8448 {
8449     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
8450
8451     TRACE("(%p %x)\n", this, flags);
8452
8453     if(flags & 2) {
8454         /* we have an array, with the number of elements stored before the first object */
8455         INT_PTR i, *ptr = (INT_PTR *)this-1;
8456
8457         for(i=*ptr-1; i>=0; i--)
8458             basic_istream_wchar_vbase_dtor(this+i);
8459         MSVCRT_operator_delete(ptr);
8460     } else {
8461         basic_istream_wchar_vbase_dtor(this);
8462         if(flags & 1)
8463             MSVCRT_operator_delete(this);
8464     }
8465
8466     return this;
8467 }
8468
8469 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8470 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8471 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8472 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8473 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Ipfx, 8)
8474 MSVCP_bool __thiscall basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8475 {
8476     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8477
8478     TRACE("(%p %d)\n", this, noskip);
8479
8480     if(ios_base_good(&base->base)) {
8481         if(basic_ios_wchar_tie_get(base))
8482             basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
8483
8484         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
8485             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8486             const ctype_wchar *ctype = ctype_wchar_use_facet(base->strbuf->loc);
8487             int ch;
8488
8489             for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
8490                     ch = basic_streambuf_wchar_snextc(strbuf)) {
8491                 if(ch == WEOF) {
8492                     basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8493                     break;
8494                 }
8495
8496                 if(!ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
8497                     break;
8498             }
8499         }
8500     }
8501
8502     if(!ios_base_good(&base->base)) {
8503         basic_ios_wchar_setstate(base, IOSTATE_failbit);
8504         return FALSE;
8505     }
8506     return TRUE;
8507 }
8508
8509 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
8510 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
8511 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
8512 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
8513 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
8514 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
8515 {
8516     return basic_istream_wchar__Ipfx(this, noskip);
8517 }
8518
8519 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
8520 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
8521 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
8522 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
8523 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
8524 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
8525 {
8526     TRACE("(%p)\n", this);
8527 }
8528
8529 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
8530 {
8531     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8532
8533     if(basic_ios_wchar_rdbuf_get(base))
8534         basic_streambuf_wchar__Lock(base->strbuf);
8535
8536     return basic_istream_wchar_ipfx(istr, noskip);
8537 }
8538
8539 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
8540 {
8541     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
8542
8543     if(basic_ios_wchar_rdbuf_get(base))
8544         basic_streambuf_wchar__Unlock(base->strbuf);
8545 }
8546
8547 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
8548 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
8549 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
8550 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
8551 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
8552 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
8553 {
8554     TRACE("(%p)\n", this);
8555     return this->count;
8556 }
8557
8558 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8559 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8560 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8561 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8562 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
8563 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
8564 {
8565     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8566     int ret;
8567
8568     TRACE("(%p)\n", this);
8569
8570     this->count = 0;
8571
8572     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
8573         basic_istream_wchar_sentry_destroy(this);
8574         return WEOF;
8575     }
8576
8577     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
8578     basic_istream_wchar_sentry_destroy(this);
8579     if(ret == WEOF)
8580         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
8581     else
8582         this->count++;
8583
8584     return ret;
8585 }
8586
8587 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
8588 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
8589 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
8590 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
8591 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
8592 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
8593 {
8594     unsigned short ret;
8595
8596     TRACE("(%p %p)\n", this, ch);
8597
8598     ret = basic_istream_wchar_get(this);
8599     if(ret != WEOF)
8600         *ch = (wchar_t)ret;
8601     return this;
8602 }
8603
8604 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8605 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8606 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8607 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8608 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 16)
8609 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8610 {
8611     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8612     unsigned short ch = delim;
8613
8614     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8615
8616     this->count = 0;
8617
8618     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8619         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8620
8621         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
8622                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8623             if(ch==WEOF || ch==delim)
8624                 break;
8625
8626             *str++ = ch;
8627             this->count++;
8628             count--;
8629         }
8630     }
8631     basic_istream_wchar_sentry_destroy(this);
8632
8633     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8634             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8635     if(count > 0)
8636         *str = 0;
8637     return this;
8638 }
8639
8640 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8641 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8642 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8643 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8644 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 12)
8645 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
8646 {
8647     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
8648 }
8649
8650 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8651 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
8652 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8653 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
8654 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
8655 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
8656 {
8657     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8658     unsigned short ch = delim;
8659
8660     TRACE("(%p %p %c)\n", this, strbuf, delim);
8661
8662     this->count = 0;
8663
8664     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8665         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
8666
8667         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
8668                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
8669             if(ch==WEOF || ch==delim)
8670                 break;
8671
8672             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
8673                 break;
8674             this->count++;
8675         }
8676     }
8677     basic_istream_wchar_sentry_destroy(this);
8678
8679     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
8680             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
8681     return this;
8682 }
8683
8684 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8685 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
8686 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8687 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
8688 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
8689 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
8690 {
8691     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
8692 }
8693
8694 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
8695 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
8696 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
8697 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
8698 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 16)
8699 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
8700 {
8701     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8702     unsigned short ch = delim;
8703
8704     TRACE("(%p %p %ld %c)\n", this, str, count, delim);
8705
8706     this->count = 0;
8707
8708     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
8709         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8710
8711         while(count > 1) {
8712             ch = basic_streambuf_wchar_sbumpc(strbuf);
8713
8714             if(ch==WEOF || ch==delim)
8715                 break;
8716
8717             *str++ = ch;
8718             this->count++;
8719             count--;
8720         }
8721
8722         if(ch == delim)
8723             this->count++;
8724         else if(ch != WEOF) {
8725             ch = basic_streambuf_wchar_sgetc(strbuf);
8726
8727             if(ch == delim) {
8728                 basic_streambuf_wchar__Gninc(strbuf);
8729                 this->count++;
8730             }
8731         }
8732     }
8733     basic_istream_wchar_sentry_destroy(this);
8734
8735     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
8736             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
8737     if(count > 0)
8738         *str = 0;
8739     return this;
8740 }
8741
8742 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8743 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8744 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8745 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8746 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 12)
8747 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
8748 {
8749     return basic_istream_wchar_getline_delim(this, str, count, '\n');
8750 }
8751
8752 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
8753 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
8754 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
8755 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
8756 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 12)
8757 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
8758 {
8759     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8760     unsigned short ch = delim;
8761     unsigned int state;
8762
8763     TRACE("(%p %ld %d)\n", this, count, delim);
8764
8765     this->count = 0;
8766
8767     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8768         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8769         state = IOSTATE_goodbit;
8770
8771         while(count > 0) {
8772             ch = basic_streambuf_wchar_sbumpc(strbuf);
8773
8774             if(ch==WEOF) {
8775                 state = IOSTATE_eofbit;
8776                 break;
8777             }
8778
8779             if(ch==delim)
8780                 break;
8781
8782             this->count++;
8783             if(count != INT_MAX)
8784                 count--;
8785         }
8786     }else
8787         state = IOSTATE_failbit;
8788     basic_istream_wchar_sentry_destroy(this);
8789
8790     basic_ios_wchar_setstate(base, state);
8791     return this;
8792 }
8793
8794 /* ?ws@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
8795 /* ?ws@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
8796 /* ?ws@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@1@AAV21@@Z */
8797 /* ?ws@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
8798 basic_istream_wchar* __cdecl ws_basic_istream_wchar(basic_istream_wchar *istream)
8799 {
8800     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
8801     unsigned short ch = '\n';
8802
8803     TRACE("(%p)\n", istream);
8804
8805     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
8806         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8807         const ctype_wchar *ctype = ctype_wchar_use_facet(strbuf->loc);
8808
8809         for(ch = basic_streambuf_wchar_sgetc(strbuf); ctype_wchar_is_ch(ctype, _SPACE, ch);
8810                 ch = basic_streambuf_wchar_snextc(strbuf)) {
8811             if(ch == WEOF)
8812                 break;
8813         }
8814     }
8815     basic_istream_wchar_sentry_destroy(istream);
8816
8817     if(ch == WEOF)
8818         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8819     return istream;
8820 }
8821
8822 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
8823 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
8824 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
8825 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
8826 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
8827 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
8828 {
8829     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8830     unsigned short ret = WEOF;
8831
8832     TRACE("(%p)\n", this);
8833
8834     this->count = 0;
8835
8836     if(basic_istream_wchar_sentry_create(this, TRUE))
8837         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
8838     basic_istream_wchar_sentry_destroy(this);
8839
8840     if (ret == WEOF)
8841         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
8842
8843     return ret;
8844 }
8845
8846 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
8847 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
8848 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
8849 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
8850 static basic_istream_wchar* basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8851 {
8852     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8853     IOSB_iostate state = IOSTATE_goodbit;
8854
8855     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8856
8857     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8858         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8859
8860         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
8861         if(this->count != count)
8862             state |= IOSTATE_failbit | IOSTATE_eofbit;
8863     }else {
8864         this->count = 0;
8865     }
8866     basic_istream_wchar_sentry_destroy(this);
8867
8868     basic_ios_wchar_setstate(base, state);
8869     return this;
8870 }
8871
8872 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
8873 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
8874 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
8875 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
8876 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 12)
8877 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
8878 {
8879     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8880     IOSB_iostate state = IOSTATE_goodbit;
8881
8882     TRACE("(%p %p %ld)\n", this, str, count);
8883
8884     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8885         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8886
8887         this->count = basic_streambuf_wchar_sgetn(strbuf, str, count);
8888         if(this->count != count)
8889             state |= IOSTATE_failbit | IOSTATE_eofbit;
8890     }else {
8891         this->count = 0;
8892     }
8893     basic_istream_wchar_sentry_destroy(this);
8894
8895     basic_ios_wchar_setstate(base, state);
8896     return this;
8897 }
8898
8899 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
8900 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
8901 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
8902 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
8903 static streamsize basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
8904 {
8905     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8906     IOSB_iostate state = IOSTATE_goodbit;
8907
8908     TRACE("(%p %p %lu %ld)\n", this, str, size, count);
8909
8910     this->count = 0;
8911
8912     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8913         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
8914         if(avail > count)
8915             avail = count;
8916
8917         if(avail == -1)
8918             state |= IOSTATE_eofbit;
8919         else if(avail > 0)
8920             basic_istream_wchar__Read_s(this, str, size, avail);
8921     }else {
8922         state |= IOSTATE_failbit;
8923     }
8924     basic_istream_wchar_sentry_destroy(this);
8925
8926     basic_ios_wchar_setstate(base, state);
8927     return this->count;
8928 }
8929
8930 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
8931 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
8932 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
8933 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
8934 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 12)
8935 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
8936 {
8937     return basic_istream_wchar__Readsome_s(this, str, count, count);
8938 }
8939
8940 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
8941 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
8942 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
8943 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
8944 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
8945 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
8946 {
8947     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8948     IOSB_iostate state = IOSTATE_goodbit;
8949
8950     TRACE("(%p %c)\n", this, ch);
8951
8952     this->count = 0;
8953
8954     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8955         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8956
8957         if(!ios_base_good(&base->base))
8958             state |= IOSTATE_failbit;
8959         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
8960             state |= IOSTATE_badbit;
8961     }
8962     basic_istream_wchar_sentry_destroy(this);
8963
8964     basic_ios_wchar_setstate(base, state);
8965     return this;
8966 }
8967
8968 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
8969 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
8970 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
8971 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
8972 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
8973 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
8974 {
8975     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
8976     IOSB_iostate state = IOSTATE_goodbit;
8977
8978     TRACE("(%p)\n", this);
8979
8980     this->count = 0;
8981
8982     if(basic_istream_wchar_sentry_create(this, TRUE)) {
8983         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
8984
8985         if(!ios_base_good(&base->base))
8986             state |= IOSTATE_failbit;
8987         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
8988             state |= IOSTATE_badbit;
8989     }
8990     basic_istream_wchar_sentry_destroy(this);
8991
8992     basic_ios_wchar_setstate(base, state);
8993     return this;
8994 }
8995
8996 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
8997 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
8998 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
8999 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
9000 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
9001 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
9002 {
9003     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9004     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9005
9006     TRACE("(%p)\n", this);
9007
9008     if(!strbuf)
9009         return -1;
9010
9011     if(basic_istream_wchar_sentry_create(this, TRUE)) {
9012         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
9013             basic_istream_wchar_sentry_destroy(this);
9014             return 0;
9015         }
9016     }
9017     basic_istream_wchar_sentry_destroy(this);
9018
9019     basic_ios_wchar_setstate(base, IOSTATE_badbit);
9020     return -1;
9021 }
9022
9023 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
9024 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
9025 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
9026 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
9027 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
9028 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
9029 {
9030     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9031
9032     TRACE("(%p %p)\n", this, ret);
9033
9034     if(ios_base_fail(&base->base)) {
9035         ret->off = -1;
9036         ret->pos = 0;
9037         ret->state = 0;
9038         return ret;
9039     }
9040
9041     basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
9042             ret, 0, SEEKDIR_cur, OPENMODE_in);
9043     if(ret->off==-1 && ret->pos==0 && ret->state==0)
9044         basic_ios_wchar_setstate(base, IOSTATE_failbit);
9045
9046     return ret;
9047 }
9048
9049 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
9050 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
9051 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
9052 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
9053 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 12)
9054 basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir)
9055 {
9056     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9057
9058     TRACE("(%p %ld %d)\n", this, off, dir);
9059
9060     if(!ios_base_fail(&base->base)) {
9061         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9062         fpos_int ret;
9063
9064         basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
9065
9066         if(ret.off==-1 && ret.pos==0 && ret.state==0)
9067             basic_ios_wchar_setstate(base, IOSTATE_failbit);
9068         else
9069             basic_ios_wchar_clear(base, IOSTATE_goodbit);
9070         return this;
9071     }else
9072         basic_ios_wchar_clear(base, IOSTATE_goodbit);
9073
9074     return this;
9075 }
9076
9077 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
9078 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
9079 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
9080 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
9081 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
9082 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
9083 {
9084     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9085
9086     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
9087
9088     if(!ios_base_fail(&base->base)) {
9089         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9090         fpos_int ret;
9091
9092         basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
9093
9094         if(ret.off==-1 && ret.pos==0 && ret.state==0)
9095             basic_ios_wchar_setstate(base, IOSTATE_failbit);
9096         else
9097             basic_ios_wchar_clear(base, IOSTATE_goodbit);
9098         return this;
9099     }else
9100         basic_ios_wchar_clear(base, IOSTATE_goodbit);
9101
9102     return this;
9103 }
9104
9105 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
9106 {
9107     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9108     int state = IOSTATE_goodbit;
9109
9110     TRACE("(%p %p)\n", this, v);
9111
9112     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9113         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9114         istreambuf_iterator_wchar first={0}, last={0};
9115         LONG tmp;
9116
9117         first.strbuf = strbuf;
9118         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
9119
9120         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
9121             *v = tmp;
9122         else
9123             state |= IOSTATE_failbit;
9124     }
9125     basic_istream_wchar_sentry_destroy(this);
9126
9127     basic_ios_wchar_setstate(base, state);
9128     return this;
9129 }
9130
9131 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAF@Z */
9132 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAF@Z */
9133 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_short, 8)
9134 basic_istream_wchar* __thiscall basic_istream_wchar_read_short(basic_istream_wchar *this, short *v)
9135 {
9136     return basic_istream_read_short(this, v, num_get_wchar_use_facet(
9137                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9138 }
9139
9140 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
9141 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
9142 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
9143 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
9144 {
9145     return basic_istream_read_short(this, v, num_get_short_use_facet(
9146                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9147 }
9148
9149 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAG@Z */
9150 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAG@Z */
9151 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ushort, 8)
9152 basic_istream_wchar* __thiscall basic_istream_wchar_read_ushort(basic_istream_wchar *this, unsigned short *v)
9153 {
9154     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9155     int state = IOSTATE_goodbit;
9156
9157     TRACE("(%p %p)\n", this, v);
9158
9159     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9160         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9161         const num_get *numget = num_get_wchar_use_facet(strbuf->loc);
9162         istreambuf_iterator_wchar first={0}, last={0};
9163
9164         first.strbuf = strbuf;
9165         num_get_wchar_get_ushort(numget, &last, first, last, &base->base, &state, v);
9166     }
9167     basic_istream_wchar_sentry_destroy(this);
9168
9169     basic_ios_wchar_setstate(base, state);
9170     return this;
9171 }
9172
9173 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
9174 {
9175     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9176     int state = IOSTATE_goodbit;
9177
9178     TRACE("(%p %p)\n", this, v);
9179
9180     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9181         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9182         istreambuf_iterator_wchar first={0}, last={0};
9183
9184         first.strbuf = strbuf;
9185         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
9186     }
9187     basic_istream_wchar_sentry_destroy(this);
9188
9189     basic_ios_wchar_setstate(base, state);
9190     return this;
9191 }
9192
9193 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAH@Z */
9194 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAH@Z */
9195 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int, 8)
9196 basic_istream_wchar* __thiscall basic_istream_wchar_read_int(basic_istream_wchar *this, int *v)
9197 {
9198     return basic_istream_read_int(this, v, num_get_wchar_use_facet(
9199                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9200 }
9201
9202 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
9203 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
9204 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
9205 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
9206 {
9207     return basic_istream_read_int(this, v, num_get_short_use_facet(
9208                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9209 }
9210
9211 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
9212 {
9213     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9214     int state = IOSTATE_goodbit;
9215
9216     TRACE("(%p %p)\n", this, v);
9217
9218     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9219         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9220         istreambuf_iterator_wchar first={0}, last={0};
9221
9222         first.strbuf = strbuf;
9223         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
9224     }
9225     basic_istream_wchar_sentry_destroy(this);
9226
9227     basic_ios_wchar_setstate(base, state);
9228     return this;
9229 }
9230
9231 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAI@Z */
9232 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAI@Z */
9233 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint, 8)
9234 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint(basic_istream_wchar *this, unsigned int *v)
9235 {
9236     return basic_istream_read_uint(this, v, num_get_wchar_use_facet(
9237                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9238 }
9239
9240 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
9241 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
9242 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
9243 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
9244 {
9245     return basic_istream_read_uint(this, v, num_get_short_use_facet(
9246                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9247 }
9248
9249 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
9250 {
9251     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9252     int state = IOSTATE_goodbit;
9253
9254     TRACE("(%p %p)\n", this, v);
9255
9256     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9257         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9258         istreambuf_iterator_wchar first={0}, last={0};
9259
9260         first.strbuf = strbuf;
9261         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
9262     }
9263     basic_istream_wchar_sentry_destroy(this);
9264
9265     basic_ios_wchar_setstate(base, state);
9266     return this;
9267 }
9268
9269 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
9270 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
9271 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_long, 8)
9272 basic_istream_wchar* __thiscall basic_istream_wchar_read_long(basic_istream_wchar *this, LONG *v)
9273 {
9274     return basic_istream_read_long(this, v, num_get_wchar_use_facet(
9275                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9276 }
9277
9278 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
9279 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
9280 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
9281 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
9282 {
9283     return basic_istream_read_long(this, v, num_get_short_use_facet(
9284                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9285 }
9286
9287 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
9288 {
9289     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9290     int state = IOSTATE_goodbit;
9291
9292     TRACE("(%p %p)\n", this, v);
9293
9294     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9295         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9296         istreambuf_iterator_wchar first={0}, last={0};
9297
9298         first.strbuf = strbuf;
9299         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
9300     }
9301     basic_istream_wchar_sentry_destroy(this);
9302
9303     basic_ios_wchar_setstate(base, state);
9304     return this;
9305 }
9306
9307 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAK@Z */
9308 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAK@Z */
9309 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ulong, 8)
9310 basic_istream_wchar* __thiscall basic_istream_wchar_read_ulong(basic_istream_wchar *this, ULONG *v)
9311 {
9312     return basic_istream_read_ulong(this, v, num_get_wchar_use_facet(
9313                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9314 }
9315
9316 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
9317 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
9318 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
9319 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
9320 {
9321     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
9322                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9323 }
9324
9325 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
9326 {
9327     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9328     int state = IOSTATE_goodbit;
9329
9330     TRACE("(%p %p)\n", this, v);
9331
9332     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9333         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9334         istreambuf_iterator_wchar first={0}, last={0};
9335
9336         first.strbuf = strbuf;
9337         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
9338     }
9339     basic_istream_wchar_sentry_destroy(this);
9340
9341     basic_ios_wchar_setstate(base, state);
9342     return this;
9343 }
9344
9345 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAM@Z */
9346 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAM@Z */
9347 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_float, 8)
9348 basic_istream_wchar* __thiscall basic_istream_wchar_read_float(basic_istream_wchar *this, float *v)
9349 {
9350     return basic_istream_read_float(this, v, num_get_wchar_use_facet(
9351                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9352 }
9353
9354 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
9355 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
9356 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
9357 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
9358 {
9359     return basic_istream_read_float(this, v, num_get_short_use_facet(
9360                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9361 }
9362
9363 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
9364 {
9365     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9366     int state = IOSTATE_goodbit;
9367
9368     TRACE("(%p %p)\n", this, v);
9369
9370     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9371         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9372         istreambuf_iterator_wchar first={0}, last={0};
9373
9374         first.strbuf = strbuf;
9375         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
9376     }
9377     basic_istream_wchar_sentry_destroy(this);
9378
9379     basic_ios_wchar_setstate(base, state);
9380     return this;
9381 }
9382
9383 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAN@Z */
9384 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAN@Z */
9385 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_double, 8)
9386 basic_istream_wchar* __thiscall basic_istream_wchar_read_double(basic_istream_wchar *this, double *v)
9387 {
9388     return basic_istream_read_double(this, v, num_get_wchar_use_facet(
9389                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9390 }
9391
9392 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
9393 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
9394 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
9395 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
9396 {
9397     return basic_istream_read_double(this, v, num_get_short_use_facet(
9398                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9399 }
9400
9401 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
9402 {
9403     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9404     int state = IOSTATE_goodbit;
9405
9406     TRACE("(%p %p)\n", this, v);
9407
9408     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9409         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9410         istreambuf_iterator_wchar first={0}, last={0};
9411
9412         first.strbuf = strbuf;
9413         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
9414     }
9415     basic_istream_wchar_sentry_destroy(this);
9416
9417     basic_ios_wchar_setstate(base, state);
9418     return this;
9419 }
9420
9421 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAO@Z */
9422 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAO@Z */
9423 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ldouble, 8)
9424 basic_istream_wchar* __thiscall basic_istream_wchar_read_ldouble(basic_istream_wchar *this, double *v)
9425 {
9426     return basic_istream_read_ldouble(this, v, num_get_wchar_use_facet(
9427                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9428 }
9429
9430 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
9431 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
9432 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
9433 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
9434 {
9435     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
9436                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9437 }
9438
9439 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
9440 {
9441     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9442     int state = IOSTATE_goodbit;
9443
9444     TRACE("(%p %p)\n", this, v);
9445
9446     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9447         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9448         istreambuf_iterator_wchar first={0}, last={0};
9449
9450         first.strbuf = strbuf;
9451         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
9452     }
9453     basic_istream_wchar_sentry_destroy(this);
9454
9455     basic_ios_wchar_setstate(base, state);
9456     return this;
9457 }
9458
9459 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAPAX@Z */
9460 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
9461 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ptr, 8)
9462 basic_istream_wchar* __thiscall basic_istream_wchar_read_ptr(basic_istream_wchar *this, void **v)
9463 {
9464     return basic_istream_read_ptr(this, v, num_get_wchar_use_facet(
9465                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9466 }
9467
9468 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
9469 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
9470 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
9471 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
9472 {
9473     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
9474                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9475 }
9476
9477 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
9478 {
9479     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9480     int state = IOSTATE_goodbit;
9481
9482     TRACE("(%p %p)\n", this, v);
9483
9484     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9485         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9486         istreambuf_iterator_wchar first={0}, last={0};
9487
9488         first.strbuf = strbuf;
9489         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
9490     }
9491     basic_istream_wchar_sentry_destroy(this);
9492
9493     basic_ios_wchar_setstate(base, state);
9494     return this;
9495 }
9496
9497 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_J@Z */
9498 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_J@Z */
9499 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int64, 8)
9500 basic_istream_wchar* __thiscall basic_istream_wchar_read_int64(basic_istream_wchar *this, __int64 *v)
9501 {
9502     return basic_istream_read_int64(this, v, num_get_wchar_use_facet(
9503                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9504 }
9505
9506 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
9507 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
9508 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
9509 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
9510 {
9511     return basic_istream_read_int64(this, v, num_get_short_use_facet(
9512                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9513 }
9514
9515 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
9516 {
9517     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9518     int state = IOSTATE_goodbit;
9519
9520     TRACE("(%p %p)\n", this, v);
9521
9522     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9523         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9524         istreambuf_iterator_wchar first={0}, last={0};
9525
9526         first.strbuf = strbuf;
9527         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
9528     }
9529     basic_istream_wchar_sentry_destroy(this);
9530
9531     basic_ios_wchar_setstate(base, state);
9532     return this;
9533 }
9534
9535 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_K@Z */
9536 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_K@Z */
9537 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint64, 8)
9538 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9539 {
9540     return basic_istream_read_uint64(this, v, num_get_wchar_use_facet(
9541                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9542 }
9543
9544 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
9545 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
9546 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
9547 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
9548 {
9549     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
9550                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9551 }
9552
9553 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
9554 {
9555     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9556     int state = IOSTATE_goodbit;
9557
9558     TRACE("(%p %p)\n", this, v);
9559
9560     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9561         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9562         istreambuf_iterator_wchar first={0}, last={0};
9563
9564         first.strbuf = strbuf;
9565         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
9566     }
9567     basic_istream_wchar_sentry_destroy(this);
9568
9569     basic_ios_wchar_setstate(base, state);
9570     return this;
9571 }
9572
9573 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_N@Z */
9574 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_N@Z */
9575 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_bool, 8)
9576 basic_istream_wchar* __thiscall basic_istream_wchar_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9577 {
9578     return basic_istream_read_bool(this, v, num_get_wchar_use_facet(
9579                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9580 }
9581
9582 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
9583 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
9584 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
9585 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
9586 {
9587     return basic_istream_read_bool(this, v, num_get_short_use_facet(
9588                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
9589 }
9590
9591 /* ??$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 */
9592 /* ??$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 */
9593 /* ??$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 */
9594 /* ??$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 */
9595 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr_delim(
9596         basic_istream_wchar *istream, basic_string_wchar *str, wchar_t delim)
9597 {
9598     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9599     IOSB_iostate state = IOSTATE_goodbit;
9600     int c = delim;
9601
9602     TRACE("(%p %p %c)\n", istream, str, delim);
9603
9604     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
9605         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
9606         MSVCP_basic_string_wchar_clear(str);
9607
9608         c = basic_streambuf_wchar_sgetc(strbuf);
9609         for(; c!=delim && c!=WEOF; c = basic_streambuf_wchar_snextc(strbuf))
9610             MSVCP_basic_string_wchar_append_ch(str, c);
9611         if(c==delim) basic_streambuf_wchar_sbumpc(strbuf);
9612         else if(c==WEOF) state |= IOSTATE_eofbit;
9613
9614         if(!MSVCP_basic_string_wchar_length(str) && c!=delim) state |= IOSTATE_failbit;
9615     }
9616     basic_istream_wchar_sentry_destroy(istream);
9617
9618     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream), state);
9619     return istream;
9620 }
9621
9622 /* ??$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 */
9623 /* ??$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 */
9624 /* ??$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 */
9625 /* ??$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 */
9626 basic_istream_wchar* __cdecl basic_istream_wchar_getline_bstr(
9627         basic_istream_wchar *istream, basic_string_wchar *str)
9628 {
9629     return basic_istream_wchar_getline_bstr_delim(istream, str, '\n');
9630 }
9631
9632 static basic_istream_wchar* basic_istream_read_bstr(basic_istream_wchar *istream,
9633         basic_string_wchar *str, const ctype_wchar *ctype)
9634 {
9635     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9636     IOSB_iostate state = IOSTATE_failbit;
9637     int c = '\n';
9638
9639     TRACE("(%p %p)\n", istream, str);
9640
9641     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9642         MSVCP_size_t count = ios_base_width_get(&base->base);
9643
9644         if(!count)
9645             count = -1;
9646
9647         MSVCP_basic_string_wchar_clear(str);
9648
9649         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9650                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9651                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9652             state = IOSTATE_goodbit;
9653             MSVCP_basic_string_wchar_append_ch(str, c);
9654         }
9655     }
9656     basic_istream_wchar_sentry_destroy(istream);
9657
9658     ios_base_width_set(&base->base, 0);
9659     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9660     return istream;
9661 }
9662
9663 /* ??$?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 */
9664 /* ??$?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 */
9665 basic_istream_wchar* __cdecl basic_istream_wchar_read_bstr(
9666         basic_istream_wchar *istream, basic_string_wchar *str)
9667 {
9668     return basic_istream_read_bstr(istream, str, ctype_wchar_use_facet(
9669                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9670 }
9671
9672 /* ??$?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 */
9673 /* ??$?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 */
9674 basic_istream_wchar* __cdecl basic_istream_short_read_bstr(
9675         basic_istream_wchar *istream, basic_string_wchar *str)
9676 {
9677     return basic_istream_read_bstr(istream, str, ctype_short_use_facet(
9678                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9679 }
9680
9681 static basic_istream_wchar* basic_istream_read_str(basic_istream_wchar *istream, wchar_t *str, const ctype_wchar *ctype)
9682 {
9683     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
9684     IOSB_iostate state = IOSTATE_failbit;
9685     unsigned short c = '\n';
9686
9687     TRACE("(%p %p)\n", istream, str);
9688
9689     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9690         MSVCP_size_t count = ios_base_width_get(&base->base)-1;
9691
9692         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
9693                 c!=WEOF && !ctype_wchar_is_ch(ctype, _SPACE|_BLANK, c) && count>0;
9694                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base)), count--) {
9695             state = IOSTATE_goodbit;
9696             *str++ = c;
9697         }
9698     }
9699     basic_istream_wchar_sentry_destroy(istream);
9700
9701     *str = 0;
9702     ios_base_width_set(&base->base, 0);
9703     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9704     return istream;
9705 }
9706
9707 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@PA_W@Z */
9708 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@PEA_W@Z */
9709 basic_istream_wchar* __cdecl basic_istream_wchar_read_str(basic_istream_wchar *istream, wchar_t *str)
9710 {
9711     return basic_istream_read_str(istream, str, ctype_wchar_use_facet(
9712                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9713 }
9714
9715 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@PAG@Z */
9716 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@PEAG@Z */
9717 basic_istream_wchar* __cdecl basic_istream_short_read_str(basic_istream_wchar *istream, wchar_t *str)
9718 {
9719     return basic_istream_read_str(istream, str, ctype_short_use_facet(
9720                 basic_istream_wchar_get_basic_ios(istream)->strbuf->loc));
9721 }
9722
9723 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AAV10@AA_W@Z */
9724 /* ??$?5_WU?$char_traits@_W@std@@@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@0@AEAV10@AEA_W@Z */
9725 /* ??$?5GU?$char_traits@G@std@@@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@0@AAV10@AAG@Z */
9726 /* ??$?5GU?$char_traits@G@std@@@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@0@AEAV10@AEAG@Z */
9727 basic_istream_wchar* __cdecl basic_istream_wchar_read_ch(basic_istream_wchar *istream, wchar_t *ch)
9728 {
9729     IOSB_iostate state = IOSTATE_failbit;
9730     unsigned short c = 0;
9731
9732     TRACE("(%p %p)\n", istream, ch);
9733
9734     if(basic_istream_wchar_sentry_create(istream, FALSE)) {
9735         c = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(
9736                     basic_istream_wchar_get_basic_ios(istream)));
9737         if(c != WEOF) {
9738             state = IOSTATE_goodbit;
9739             *ch = c;
9740         }
9741     }
9742     basic_istream_wchar_sentry_destroy(istream);
9743
9744     basic_ios_wchar_setstate(basic_istream_wchar_get_basic_ios(istream),
9745             state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9746     return istream;
9747 }
9748
9749 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9750 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9751 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9752 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9753 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
9754 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
9755         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
9756 {
9757     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
9758     IOSB_iostate state = IOSTATE_failbit;
9759     unsigned short c = '\n';
9760
9761     TRACE("(%p %p)\n", this, streambuf);
9762
9763     if(basic_istream_wchar_sentry_create(this, FALSE)) {
9764         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
9765                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
9766             state = IOSTATE_goodbit;
9767             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
9768                 break;
9769         }
9770     }
9771     basic_istream_wchar_sentry_destroy(this);
9772
9773     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
9774     return this;
9775 }
9776
9777 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9778 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9779 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
9780 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
9781 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
9782 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
9783         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
9784 {
9785     TRACE("(%p %p)\n", this, pfunc);
9786     pfunc(this);
9787     return this;
9788 }
9789
9790 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
9791 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
9792 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
9793 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
9794 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
9795 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
9796         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
9797 {
9798     TRACE("(%p %p)\n", this, pfunc);
9799     pfunc(basic_istream_wchar_get_basic_ios(this));
9800     return this;
9801 }
9802
9803 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9804 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9805 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
9806 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
9807 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
9808 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
9809         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
9810 {
9811     TRACE("(%p %p)\n", this, pfunc);
9812     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
9813     return this;
9814 }
9815
9816 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
9817 {
9818     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
9819 }
9820
9821 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
9822 {
9823     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
9824 }
9825
9826 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9827 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
9828 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
9829 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
9830 {
9831     basic_ios_char *basic_ios;
9832
9833     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9834
9835     if(virt_init) {
9836         this->base1.vbtable = basic_iostream_char_vbtable1;
9837         this->base2.vbtable = basic_iostream_char_vbtable2;
9838         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9839         basic_ios_char_ctor(basic_ios);
9840     }else {
9841         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
9842     }
9843
9844     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
9845
9846     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
9847     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9848     return this;
9849 }
9850
9851 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
9852 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
9853 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
9854 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
9855 {
9856     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9857
9858     TRACE("(%p)\n", this);
9859     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
9860     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
9861 }
9862
9863 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
9864 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
9865 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
9866 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
9867 {
9868     TRACE("(%p)\n", this);
9869     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
9870     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
9871 }
9872
9873 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
9874 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
9875 {
9876     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
9877
9878     TRACE("(%p %x)\n", this, flags);
9879
9880     if(flags & 2) {
9881         /* we have an array, with the number of elements stored before the first object */
9882         INT_PTR i, *ptr = (INT_PTR *)this-1;
9883
9884         for(i=*ptr-1; i>=0; i--)
9885             basic_iostream_char_vbase_dtor(this+i);
9886         MSVCRT_operator_delete(ptr);
9887     } else {
9888         basic_iostream_char_vbase_dtor(this);
9889         if(flags & 1)
9890             MSVCRT_operator_delete(this);
9891     }
9892
9893     return this;
9894 }
9895
9896 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
9897 {
9898     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
9899 }
9900
9901 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
9902 {
9903     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
9904 }
9905
9906 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9907 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
9908 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_ctor, 12)
9909 basic_iostream_wchar* __thiscall basic_iostream_wchar_ctor(basic_iostream_wchar *this,
9910         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9911 {
9912     basic_ios_wchar *basic_ios;
9913
9914     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
9915
9916     if(virt_init) {
9917         this->base1.vbtable = basic_iostream_wchar_vbtable1;
9918         this->base2.vbtable = basic_iostream_wchar_vbtable2;
9919         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9920         basic_ios_wchar_ctor(basic_ios);
9921     }else {
9922         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
9923     }
9924
9925     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
9926     basic_ostream_wchar_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
9927
9928     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
9929     return this;
9930 }
9931
9932 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9933 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
9934 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
9935 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
9936         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
9937 {
9938     basic_iostream_wchar_ctor(this, strbuf, virt_init);
9939     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
9940     return this;
9941 }
9942
9943 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
9944 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
9945 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
9946 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
9947 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
9948 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
9949 {
9950     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9951
9952     TRACE("(%p)\n", this);
9953     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
9954     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
9955 }
9956
9957 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
9958 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
9959 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
9960 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
9961 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
9962 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
9963 {
9964     TRACE("(%p)\n", this);
9965     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
9966     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
9967 }
9968
9969 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
9970 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
9971 {
9972     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
9973
9974     TRACE("(%p %x)\n", this, flags);
9975
9976     if(flags & 2) {
9977         /* we have an array, with the number of elements stored before the first object */
9978         INT_PTR i, *ptr = (INT_PTR *)this-1;
9979
9980         for(i=*ptr-1; i>=0; i--)
9981             basic_iostream_wchar_vbase_dtor(this+i);
9982         MSVCRT_operator_delete(ptr);
9983     } else {
9984         basic_iostream_wchar_vbase_dtor(this);
9985         if(flags & 1)
9986             MSVCRT_operator_delete(this);
9987     }
9988
9989     return this;
9990 }
9991
9992 static inline basic_ios_char* basic_ofstream_char_to_basic_ios(basic_ofstream_char *ptr)
9993 {
9994     return (basic_ios_char*)((char*)ptr+basic_ofstream_char_vbtable[1]);
9995 }
9996
9997 static inline basic_ofstream_char* basic_ofstream_char_from_basic_ios(basic_ios_char *ptr)
9998 {
9999     return (basic_ofstream_char*)((char*)ptr-basic_ofstream_char_vbtable[1]);
10000 }
10001
10002 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10003 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10004 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor, 8)
10005 basic_ofstream_char* __thiscall basic_ofstream_char_ctor(basic_ofstream_char *this, MSVCP_bool virt_init)
10006 {
10007     basic_ios_char *basic_ios;
10008
10009     TRACE("(%p %d)\n", this, virt_init);
10010
10011     if(virt_init) {
10012         this->base.vbtable = basic_ofstream_char_vbtable;
10013         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10014         basic_ios_char_ctor(basic_ios);
10015     }else {
10016         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10017     }
10018
10019     basic_filebuf_char_ctor(&this->filebuf);
10020     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10021     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
10022     return this;
10023 }
10024
10025 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10026 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10027 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_file, 12)
10028 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_file(
10029         basic_ofstream_char *this, FILE *file, MSVCP_bool virt_init)
10030 {
10031     basic_ios_char *basic_ios;
10032
10033     TRACE("(%p %p %d)\n", this, file, virt_init);
10034
10035     if(virt_init) {
10036         this->base.vbtable = basic_ofstream_char_vbtable;
10037         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10038         basic_ios_char_ctor(basic_ios);
10039     }else {
10040         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10041     }
10042
10043     basic_filebuf_char_ctor_file(&this->filebuf, file);
10044     basic_ostream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10045     basic_ios->base.vtable = &MSVCP_basic_ofstream_char_vtable;
10046     return this;
10047 }
10048
10049 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
10050 /* ??0?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
10051 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_ctor_name, 20)
10052 basic_ofstream_char* __thiscall basic_ofstream_char_ctor_name(basic_ofstream_char *this,
10053         const char *name, int mode, int prot, MSVCP_bool virt_init)
10054 {
10055     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10056
10057     basic_ofstream_char_ctor(this, virt_init);
10058
10059     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10060         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10061         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10062     }
10063     return this;
10064 }
10065
10066 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10067 /* ??1?$basic_ofstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10068 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_dtor, 4)
10069 void __thiscall basic_ofstream_char_dtor(basic_ios_char *base)
10070 {
10071     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
10072
10073     TRACE("(%p)\n", this);
10074
10075     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
10076     basic_filebuf_char_dtor(&this->filebuf);
10077 }
10078
10079 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10080 /* ??_D?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10081 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vbase_dtor, 4)
10082 void __thiscall basic_ofstream_char_vbase_dtor(basic_ofstream_char *this)
10083 {
10084     TRACE("(%p)\n", this);
10085
10086     basic_ofstream_char_dtor(basic_ofstream_char_to_basic_ios(this));
10087     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
10088 }
10089
10090 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_vector_dtor, 8)
10091 basic_ofstream_char* __thiscall basic_ofstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10092 {
10093     basic_ofstream_char *this = basic_ofstream_char_from_basic_ios(base);
10094
10095     TRACE("(%p %x)\n", this, flags);
10096
10097     if(flags & 2) {
10098         /* we have an array, with the number of elements stored before the first object */
10099         INT_PTR i, *ptr = (INT_PTR *)this-1;
10100
10101         for(i=*ptr-1; i>=0; i--)
10102             basic_ofstream_char_vbase_dtor(this+i);
10103         MSVCRT_operator_delete(ptr);
10104     } else {
10105         basic_ofstream_char_vbase_dtor(this);
10106         if(flags & 1)
10107             MSVCRT_operator_delete(this);
10108     }
10109
10110     return this;
10111 }
10112
10113 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10114 /* ?close@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10115 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_close, 4)
10116 void __thiscall basic_ofstream_char_close(basic_ofstream_char *this)
10117 {
10118     TRACE("(%p)\n", this);
10119
10120     if(!basic_filebuf_char_close(&this->filebuf)) {
10121         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10122         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10123     }
10124 }
10125
10126 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10127 /* ?is_open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10128 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_is_open, 4)
10129 MSVCP_bool __thiscall basic_ofstream_char_is_open(const basic_ofstream_char *this)
10130 {
10131     TRACE("(%p)\n", this);
10132     return basic_filebuf_char_is_open(&this->filebuf);
10133 }
10134
10135 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
10136 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
10137 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open, 16)
10138 void __thiscall basic_ofstream_char_open(basic_ofstream_char *this,
10139         const char *name, int mode, int prot)
10140 {
10141     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10142
10143     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10144         basic_ios_char *basic_ios = basic_ostream_char_get_basic_ios(&this->base);
10145         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10146     }
10147 }
10148
10149 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
10150 /* ?open@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
10151 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_open_old, 12)
10152 void __thiscall basic_ofstream_char_open_old(basic_ofstream_char *this,
10153         const char *name, unsigned int mode)
10154 {
10155     basic_ofstream_char_open(this, name, mode, _SH_DENYNO);
10156 }
10157
10158 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10159 /* ?rdbuf@?$basic_ofstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10160 DEFINE_THISCALL_WRAPPER(basic_ofstream_char_rdbuf, 4)
10161 basic_filebuf_char* __thiscall basic_ofstream_char_rdbuf(const basic_ofstream_char *this)
10162 {
10163     TRACE("(%p)\n", this);
10164     return (basic_filebuf_char*)&this->filebuf;
10165 }
10166
10167 static inline basic_ios_wchar* basic_ofstream_wchar_to_basic_ios(basic_ofstream_wchar *ptr)
10168 {
10169     return (basic_ios_wchar*)((char*)ptr+basic_ofstream_wchar_vbtable[1]);
10170 }
10171
10172 static inline basic_ofstream_wchar* basic_ofstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10173 {
10174     return (basic_ofstream_wchar*)((char*)ptr-basic_ofstream_wchar_vbtable[1]);
10175 }
10176
10177 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10178 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10179 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor, 8)
10180 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
10181 {
10182     basic_ios_wchar *basic_ios;
10183
10184     TRACE("(%p %d)\n", this, virt_init);
10185
10186     if(virt_init) {
10187         this->base.vbtable = basic_ofstream_wchar_vbtable;
10188         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10189         basic_ios_wchar_ctor(basic_ios);
10190     }else {
10191         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10192     }
10193
10194     basic_filebuf_wchar_ctor(&this->filebuf);
10195     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10196     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
10197     return this;
10198 }
10199
10200 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10201 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10202 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor, 8)
10203 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor(basic_ofstream_wchar *this, MSVCP_bool virt_init)
10204 {
10205     basic_ofstream_wchar_ctor(this, virt_init);
10206     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10207     return this;
10208 }
10209
10210 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10211 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10212 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_file, 12)
10213 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_file(
10214         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10215 {
10216     basic_ios_wchar *basic_ios;
10217
10218     TRACE("(%p %p %d)\n", this, file, virt_init);
10219
10220     if(virt_init) {
10221         this->base.vbtable = basic_ofstream_wchar_vbtable;
10222         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10223         basic_ios_wchar_ctor(basic_ios);
10224     }else {
10225         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10226     }
10227
10228     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10229     basic_ostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10230     basic_ios->base.vtable = &MSVCP_basic_ofstream_wchar_vtable;
10231     return this;
10232 }
10233
10234 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10235 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10236 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_file, 12)
10237 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_file(
10238         basic_ofstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10239 {
10240     basic_ofstream_wchar_ctor_file(this, file, virt_init);
10241     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10242     return this;
10243 }
10244
10245 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z */
10246 /* ??0?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z */
10247 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_ctor_name, 20)
10248 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_ctor_name(basic_ofstream_wchar *this,
10249         const char *name, int mode, int prot, MSVCP_bool virt_init)
10250 {
10251     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10252
10253     basic_ofstream_wchar_ctor(this, virt_init);
10254
10255     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10256         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10257         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10258     }
10259     return this;
10260 }
10261
10262 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAE@PBDHH@Z */
10263 /* ??0?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDHH@Z */
10264 DEFINE_THISCALL_WRAPPER(basic_ofstream_short_ctor_name, 20)
10265 basic_ofstream_wchar* __thiscall basic_ofstream_short_ctor_name(basic_ofstream_wchar *this,
10266         const char *name, int mode, int prot, MSVCP_bool virt_init)
10267 {
10268     basic_ofstream_wchar_ctor_name(this, name, mode, prot, virt_init);
10269     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ofstream_short_vtable;
10270     return this;
10271 }
10272
10273 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10274 /* ??1?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10275 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10276 /* ??1?$basic_ofstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10277 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_dtor, 4)
10278 void __thiscall basic_ofstream_wchar_dtor(basic_ios_wchar *base)
10279 {
10280     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
10281
10282     TRACE("(%p)\n", this);
10283
10284     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
10285     basic_filebuf_wchar_dtor(&this->filebuf);
10286 }
10287
10288 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10289 /* ??_D?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10290 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10291 /* ??_D?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10292 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vbase_dtor, 4)
10293 void __thiscall basic_ofstream_wchar_vbase_dtor(basic_ofstream_wchar *this)
10294 {
10295     TRACE("(%p)\n", this);
10296
10297     basic_ofstream_wchar_dtor(basic_ofstream_wchar_to_basic_ios(this));
10298     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
10299 }
10300
10301 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_vector_dtor, 8)
10302 basic_ofstream_wchar* __thiscall basic_ofstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10303 {
10304     basic_ofstream_wchar *this = basic_ofstream_wchar_from_basic_ios(base);
10305
10306     TRACE("(%p %x)\n", this, flags);
10307
10308     if(flags & 2) {
10309         /* we have an array, with the number of elements stored before the first object */
10310         INT_PTR i, *ptr = (INT_PTR *)this-1;
10311
10312         for(i=*ptr-1; i>=0; i--)
10313             basic_ofstream_wchar_vbase_dtor(this+i);
10314         MSVCRT_operator_delete(ptr);
10315     } else {
10316         basic_ofstream_wchar_vbase_dtor(this);
10317         if(flags & 1)
10318             MSVCRT_operator_delete(this);
10319     }
10320
10321     return this;
10322 }
10323
10324 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10325 /* ?close@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10326 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10327 /* ?close@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10328 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_close, 4)
10329 void __thiscall basic_ofstream_wchar_close(basic_ofstream_wchar *this)
10330 {
10331     TRACE("(%p)\n", this);
10332
10333     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10334         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10335         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10336     }
10337 }
10338
10339 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10340 /* ?is_open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10341 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10342 /* ?is_open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10343 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_is_open, 4)
10344 MSVCP_bool __thiscall basic_ofstream_wchar_is_open(const basic_ofstream_wchar *this)
10345 {
10346     TRACE("(%p)\n", this);
10347     return basic_filebuf_wchar_is_open(&this->filebuf);
10348 }
10349
10350 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
10351 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
10352 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
10353 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
10354 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open, 16)
10355 void __thiscall basic_ofstream_wchar_open(basic_ofstream_wchar *this,
10356         const char *name, int mode, int prot)
10357 {
10358     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10359
10360     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_out, prot)) {
10361         basic_ios_wchar *basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
10362         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10363     }
10364 }
10365
10366 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
10367 /* ?open@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
10368 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
10369 /* ?open@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
10370 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_open_old, 12)
10371 void __thiscall basic_ofstream_wchar_open_old(basic_ofstream_wchar *this,
10372         const char *name, unsigned int mode)
10373 {
10374     basic_ofstream_wchar_open(this, name, mode, _SH_DENYNO);
10375 }
10376
10377 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10378 /* ?rdbuf@?$basic_ofstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10379 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10380 /* ?rdbuf@?$basic_ofstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10381 DEFINE_THISCALL_WRAPPER(basic_ofstream_wchar_rdbuf, 4)
10382 basic_filebuf_wchar* __thiscall basic_ofstream_wchar_rdbuf(const basic_ofstream_wchar *this)
10383 {
10384     TRACE("(%p)\n", this);
10385     return (basic_filebuf_wchar*)&this->filebuf;
10386 }
10387
10388 static inline basic_ios_char* basic_ifstream_char_to_basic_ios(basic_ifstream_char *ptr)
10389 {
10390     return (basic_ios_char*)((char*)ptr+basic_ifstream_char_vbtable[1]);
10391 }
10392
10393 static inline basic_ifstream_char* basic_ifstream_char_from_basic_ios(basic_ios_char *ptr)
10394 {
10395     return (basic_ifstream_char*)((char*)ptr-basic_ifstream_char_vbtable[1]);
10396 }
10397
10398 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10399 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10400 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor, 8)
10401 basic_ifstream_char* __thiscall basic_ifstream_char_ctor(basic_ifstream_char *this, MSVCP_bool virt_init)
10402 {
10403     basic_ios_char *basic_ios;
10404
10405     TRACE("(%p %d)\n", this, virt_init);
10406
10407     if(virt_init) {
10408         this->base.vbtable = basic_ifstream_char_vbtable;
10409         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10410         basic_ios_char_ctor(basic_ios);
10411     }else {
10412         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10413     }
10414
10415     basic_filebuf_char_ctor(&this->filebuf);
10416     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10417     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
10418     return this;
10419 }
10420
10421 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10422 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10423 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_file, 12)
10424 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_file(
10425         basic_ifstream_char *this, FILE *file, MSVCP_bool virt_init)
10426 {
10427     basic_ios_char *basic_ios;
10428
10429     TRACE("(%p %p %d)\n", this, file, virt_init);
10430
10431     if(virt_init) {
10432         this->base.vbtable = basic_ifstream_char_vbtable;
10433         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10434         basic_ios_char_ctor(basic_ios);
10435     }else {
10436         basic_ios = basic_istream_char_get_basic_ios(&this->base);
10437     }
10438
10439     basic_filebuf_char_ctor_file(&this->filebuf, file);
10440     basic_istream_char_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10441     basic_ios->base.vtable = &MSVCP_basic_ifstream_char_vtable;
10442     return this;
10443 }
10444
10445 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
10446 /* ??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
10447 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_ctor_name, 20)
10448 basic_ifstream_char* __thiscall basic_ifstream_char_ctor_name(basic_ifstream_char *this,
10449         const char *name, int mode, int prot, MSVCP_bool virt_init)
10450 {
10451     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10452
10453     basic_ifstream_char_ctor(this, virt_init);
10454
10455     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10456         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10457         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10458     }
10459     return this;
10460 }
10461
10462 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10463 /* ??1?$basic_ifstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10464 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_dtor, 4)
10465 void __thiscall basic_ifstream_char_dtor(basic_ios_char *base)
10466 {
10467     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
10468
10469     TRACE("(%p)\n", this);
10470
10471     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
10472     basic_filebuf_char_dtor(&this->filebuf);
10473 }
10474
10475 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10476 /* ??_D?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10477 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vbase_dtor, 4)
10478 void __thiscall basic_ifstream_char_vbase_dtor(basic_ifstream_char *this)
10479 {
10480     TRACE("(%p)\n", this);
10481
10482     basic_ifstream_char_dtor(basic_ifstream_char_to_basic_ios(this));
10483     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
10484 }
10485
10486 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_vector_dtor, 8)
10487 basic_ifstream_char* __thiscall basic_ifstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10488 {
10489     basic_ifstream_char *this = basic_ifstream_char_from_basic_ios(base);
10490
10491     TRACE("(%p %x)\n", this, flags);
10492
10493     if(flags & 2) {
10494         /* we have an array, with the number of elements stored before the first object */
10495         INT_PTR i, *ptr = (INT_PTR *)this-1;
10496
10497         for(i=*ptr-1; i>=0; i--)
10498             basic_ifstream_char_vbase_dtor(this+i);
10499         MSVCRT_operator_delete(ptr);
10500     } else {
10501         basic_ifstream_char_vbase_dtor(this);
10502         if(flags & 1)
10503             MSVCRT_operator_delete(this);
10504     }
10505
10506     return this;
10507 }
10508
10509 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10510 /* ?close@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10511 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_close, 4)
10512 void __thiscall basic_ifstream_char_close(basic_ifstream_char *this)
10513 {
10514     TRACE("(%p)\n", this);
10515
10516     if(!basic_filebuf_char_close(&this->filebuf)) {
10517         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10518         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10519     }
10520 }
10521
10522 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10523 /* ?is_open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10524 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_is_open, 4)
10525 MSVCP_bool __thiscall basic_ifstream_char_is_open(const basic_ifstream_char *this)
10526 {
10527     TRACE("(%p)\n", this);
10528     return basic_filebuf_char_is_open(&this->filebuf);
10529 }
10530
10531 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
10532 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
10533 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open, 16)
10534 void __thiscall basic_ifstream_char_open(basic_ifstream_char *this,
10535         const char *name, int mode, int prot)
10536 {
10537     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10538
10539     if(!basic_filebuf_char_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10540         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base);
10541         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10542     }
10543 }
10544
10545 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
10546 /* ?open@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
10547 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_open_old, 12)
10548 void __thiscall basic_ifstream_char_open_old(basic_ifstream_char *this,
10549         const char *name, unsigned int mode)
10550 {
10551     basic_ifstream_char_open(this, name, mode, _SH_DENYNO);
10552 }
10553
10554 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10555 /* ?rdbuf@?$basic_ifstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10556 DEFINE_THISCALL_WRAPPER(basic_ifstream_char_rdbuf, 4)
10557 basic_filebuf_char* __thiscall basic_ifstream_char_rdbuf(const basic_ifstream_char *this)
10558 {
10559     TRACE("(%p)\n", this);
10560     return (basic_filebuf_char*)&this->filebuf;
10561 }
10562
10563 static inline basic_ios_wchar* basic_ifstream_wchar_to_basic_ios(basic_ifstream_wchar *ptr)
10564 {
10565     return (basic_ios_wchar*)((char*)ptr+basic_ifstream_wchar_vbtable[1]);
10566 }
10567
10568 static inline basic_ifstream_wchar* basic_ifstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10569 {
10570     return (basic_ifstream_wchar*)((char*)ptr-basic_ifstream_wchar_vbtable[1]);
10571 }
10572
10573 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10574 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10575 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor, 8)
10576 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10577 {
10578     basic_ios_wchar *basic_ios;
10579
10580     TRACE("(%p %d)\n", this, virt_init);
10581
10582     if(virt_init) {
10583         this->base.vbtable = basic_ifstream_wchar_vbtable;
10584         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10585         basic_ios_wchar_ctor(basic_ios);
10586     }else {
10587         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10588     }
10589
10590     basic_filebuf_wchar_ctor(&this->filebuf);
10591     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10592     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10593     return this;
10594 }
10595
10596 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10597 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10598 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor, 8)
10599 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor(basic_ifstream_wchar *this, MSVCP_bool virt_init)
10600 {
10601     basic_ifstream_wchar_ctor(this, virt_init);
10602     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10603     return this;
10604 }
10605
10606 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
10607 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10608 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_file, 12)
10609 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_file(
10610         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10611 {
10612     basic_ios_wchar *basic_ios;
10613
10614     TRACE("(%p %p %d)\n", this, file, virt_init);
10615
10616     if(virt_init) {
10617         this->base.vbtable = basic_ifstream_wchar_vbtable;
10618         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10619         basic_ios_wchar_ctor(basic_ios);
10620     }else {
10621         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10622     }
10623
10624     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
10625     basic_istream_wchar_ctor(&this->base, &this->filebuf.base, FALSE, FALSE);
10626     basic_ios->base.vtable = &MSVCP_basic_ifstream_wchar_vtable;
10627     return this;
10628 }
10629
10630 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
10631 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10632 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_file, 12)
10633 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_file(
10634         basic_ifstream_wchar *this, FILE *file, MSVCP_bool virt_init)
10635 {
10636     basic_ifstream_wchar_ctor_file(this, file, virt_init);
10637     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10638     return this;
10639 }
10640
10641 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAE@PBDHH@Z */
10642 /* ??0?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEBDHH@Z */
10643 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_ctor_name, 20)
10644 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_ctor_name(basic_ifstream_wchar *this,
10645         const char *name, int mode, int prot, MSVCP_bool virt_init)
10646 {
10647     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10648
10649     basic_ifstream_wchar_ctor(this, virt_init);
10650
10651     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10652         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10653         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10654     }
10655     return this;
10656 }
10657
10658 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAE@PBDHH@Z */
10659 /* ??0?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAA@PEBDHH@Z */
10660 DEFINE_THISCALL_WRAPPER(basic_ifstream_short_ctor_name, 20)
10661 basic_ifstream_wchar* __thiscall basic_ifstream_short_ctor_name(basic_ifstream_wchar *this,
10662         const char *name, int mode, int prot, MSVCP_bool virt_init)
10663 {
10664     basic_ifstream_wchar_ctor_name(this, name, mode, prot, virt_init);
10665     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ifstream_short_vtable;
10666     return this;
10667 }
10668
10669 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
10670 /* ??1?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
10671 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
10672 /* ??1?$basic_ifstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
10673 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_dtor, 4)
10674 void __thiscall basic_ifstream_wchar_dtor(basic_ios_wchar *base)
10675 {
10676     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10677
10678     TRACE("(%p)\n", this);
10679
10680     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
10681     basic_filebuf_wchar_dtor(&this->filebuf);
10682 }
10683
10684 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10685 /* ??_D?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10686 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10687 /* ??_D?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10688 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vbase_dtor, 4)
10689 void __thiscall basic_ifstream_wchar_vbase_dtor(basic_ifstream_wchar *this)
10690 {
10691     TRACE("(%p)\n", this);
10692
10693     basic_ifstream_wchar_dtor(basic_ifstream_wchar_to_basic_ios(this));
10694     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
10695 }
10696
10697 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_vector_dtor, 8)
10698 basic_ifstream_wchar* __thiscall basic_ifstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
10699 {
10700     basic_ifstream_wchar *this = basic_ifstream_wchar_from_basic_ios(base);
10701
10702     TRACE("(%p %x)\n", this, flags);
10703
10704     if(flags & 2) {
10705         /* we have an array, with the number of elements stored before the first object */
10706         INT_PTR i, *ptr = (INT_PTR *)this-1;
10707
10708         for(i=*ptr-1; i>=0; i--)
10709             basic_ifstream_wchar_vbase_dtor(this+i);
10710         MSVCRT_operator_delete(ptr);
10711     } else {
10712         basic_ifstream_wchar_vbase_dtor(this);
10713         if(flags & 1)
10714             MSVCRT_operator_delete(this);
10715     }
10716
10717     return this;
10718 }
10719
10720 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
10721 /* ?close@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
10722 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
10723 /* ?close@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
10724 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_close, 4)
10725 void __thiscall basic_ifstream_wchar_close(basic_ifstream_wchar *this)
10726 {
10727     TRACE("(%p)\n", this);
10728
10729     if(!basic_filebuf_wchar_close(&this->filebuf)) {
10730         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10731         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10732     }
10733 }
10734
10735 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
10736 /* ?is_open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
10737 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
10738 /* ?is_open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
10739 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_is_open, 4)
10740 MSVCP_bool __thiscall basic_ifstream_wchar_is_open(const basic_ifstream_wchar *this)
10741 {
10742     TRACE("(%p)\n", this);
10743     return basic_filebuf_wchar_is_open(&this->filebuf);
10744 }
10745
10746 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
10747 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
10748 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
10749 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
10750 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open, 16)
10751 void __thiscall basic_ifstream_wchar_open(basic_ifstream_wchar *this,
10752         const char *name, int mode, int prot)
10753 {
10754     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10755
10756     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode|OPENMODE_in, prot)) {
10757         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
10758         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
10759     }
10760 }
10761
10762 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
10763 /* ?open@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
10764 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
10765 /* ?open@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
10766 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_open_old, 12)
10767 void __thiscall basic_ifstream_wchar_open_old(basic_ifstream_wchar *this,
10768         const char *name, unsigned int mode)
10769 {
10770     basic_ifstream_wchar_open(this, name, mode, _SH_DENYNO);
10771 }
10772
10773 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10774 /* ?rdbuf@?$basic_ifstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
10775 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10776 /* ?rdbuf@?$basic_ifstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
10777 DEFINE_THISCALL_WRAPPER(basic_ifstream_wchar_rdbuf, 4)
10778 basic_filebuf_wchar* __thiscall basic_ifstream_wchar_rdbuf(const basic_ifstream_wchar *this)
10779 {
10780     TRACE("(%p)\n", this);
10781     return (basic_filebuf_wchar*)&this->filebuf;
10782 }
10783
10784 static inline basic_ios_char* basic_fstream_char_to_basic_ios(basic_fstream_char *ptr)
10785 {
10786     return (basic_ios_char*)((char*)ptr+basic_fstream_char_vbtable1[1]);
10787 }
10788
10789 static inline basic_fstream_char* basic_fstream_char_from_basic_ios(basic_ios_char *ptr)
10790 {
10791     return (basic_fstream_char*)((char*)ptr-basic_fstream_char_vbtable1[1]);
10792 }
10793
10794 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@XZ */
10795 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@XZ */
10796 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor, 8)
10797 basic_fstream_char* __thiscall basic_fstream_char_ctor(basic_fstream_char *this, MSVCP_bool virt_init)
10798 {
10799     basic_ios_char *basic_ios;
10800
10801     TRACE("(%p %d)\n", this, virt_init);
10802
10803     if(virt_init) {
10804         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10805         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10806         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10807         basic_ios_char_ctor(basic_ios);
10808     }else {
10809         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10810     }
10811
10812     basic_filebuf_char_ctor(&this->filebuf);
10813     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10814     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10815     return this;
10816 }
10817
10818 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
10819 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
10820 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_file, 12)
10821 basic_fstream_char* __thiscall basic_fstream_char_ctor_file(basic_fstream_char *this,
10822         FILE *file, MSVCP_bool virt_init)
10823 {
10824     basic_ios_char *basic_ios;
10825
10826     TRACE("(%p %p %d)\n", this, file, virt_init);
10827
10828     if(virt_init) {
10829         this->base.base1.vbtable = basic_fstream_char_vbtable1;
10830         this->base.base2.vbtable = basic_fstream_char_vbtable2;
10831         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10832         basic_ios_char_ctor(basic_ios);
10833     }else {
10834         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10835     }
10836
10837     basic_filebuf_char_ctor_file(&this->filebuf, file);
10838     basic_iostream_char_ctor(&this->base, &this->filebuf.base, FALSE);
10839     basic_ios->base.vtable = &MSVCP_basic_fstream_char_vtable;
10840     return this;
10841 }
10842
10843 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QAE@PBDHH@Z */
10844 /* ??0?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAA@PEBDHH@Z */
10845 DEFINE_THISCALL_WRAPPER(basic_fstream_char_ctor_name, 20)
10846 basic_fstream_char* __thiscall basic_fstream_char_ctor_name(basic_fstream_char *this,
10847         const char *name, int mode, int prot, MSVCP_bool virt_init)
10848 {
10849     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
10850
10851     basic_fstream_char_ctor(this, virt_init);
10852
10853     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
10854         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10855         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10856     }
10857     return this;
10858 }
10859
10860 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UAE@XZ */
10861 /* ??1?$basic_fstream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
10862 DEFINE_THISCALL_WRAPPER(basic_fstream_char_dtor, 4)
10863 void __thiscall basic_fstream_char_dtor(basic_ios_char *base)
10864 {
10865     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10866
10867     TRACE("(%p)\n", this);
10868
10869     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
10870     basic_filebuf_char_dtor(&this->filebuf);
10871 }
10872
10873 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10874 /* ??_D?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10875 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vbase_dtor, 4)
10876 void __thiscall basic_fstream_char_vbase_dtor(basic_fstream_char *this)
10877 {
10878     TRACE("(%p)\n", this);
10879
10880     basic_fstream_char_dtor(basic_fstream_char_to_basic_ios(this));
10881     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
10882 }
10883
10884 DEFINE_THISCALL_WRAPPER(basic_fstream_char_vector_dtor, 8)
10885 basic_fstream_char* __thiscall basic_fstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
10886 {
10887     basic_fstream_char *this = basic_fstream_char_from_basic_ios(base);
10888
10889     TRACE("(%p %x)\n", this, flags);
10890
10891     if(flags & 2) {
10892         /* we have an array, with the number of elements stored before the first object */
10893         INT_PTR i, *ptr = (INT_PTR *)this-1;
10894
10895         for(i=*ptr-1; i>=0; i--)
10896             basic_fstream_char_vbase_dtor(this+i);
10897         MSVCRT_operator_delete(ptr);
10898     } else {
10899         basic_fstream_char_vbase_dtor(this);
10900         if(flags & 1)
10901             MSVCRT_operator_delete(this);
10902     }
10903
10904     return this;
10905 }
10906
10907 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXXZ */
10908 /* ?close@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
10909 DEFINE_THISCALL_WRAPPER(basic_fstream_char_close, 4)
10910 void __thiscall basic_fstream_char_close(basic_fstream_char *this)
10911 {
10912     TRACE("(%p)\n", this);
10913
10914     if(!basic_filebuf_char_close(&this->filebuf)) {
10915         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10916         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10917     }
10918 }
10919
10920 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBE_NXZ */
10921 /* ?is_open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
10922 DEFINE_THISCALL_WRAPPER(basic_fstream_char_is_open, 4)
10923 MSVCP_bool __thiscall basic_fstream_char_is_open(const basic_fstream_char *this)
10924 {
10925     TRACE("(%p)\n", this);
10926     return basic_filebuf_char_is_open(&this->filebuf);
10927 }
10928
10929 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDHH@Z */
10930 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDHH@Z */
10931 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open, 16)
10932 void __thiscall basic_fstream_char_open(basic_fstream_char *this,
10933         const char *name, int mode, int prot)
10934 {
10935     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
10936
10937     if(!basic_filebuf_char_open(&this->filebuf, name, mode, prot)) {
10938         basic_ios_char *basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
10939         basic_ios_char_setstate(basic_ios, IOSTATE_failbit);
10940     }
10941 }
10942
10943 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QAEXPBDI@Z */
10944 /* ?open@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEAAXPEBDI@Z */
10945 DEFINE_THISCALL_WRAPPER(basic_fstream_char_open_old, 12)
10946 void __thiscall basic_fstream_char_open_old(basic_fstream_char *this,
10947         const char *name, unsigned int mode)
10948 {
10949     basic_fstream_char_open(this, name, mode, _SH_DENYNO);
10950 }
10951
10952 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10953 /* ?rdbuf@?$basic_fstream@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_filebuf@DU?$char_traits@D@std@@@2@XZ */
10954 DEFINE_THISCALL_WRAPPER(basic_fstream_char_rdbuf, 4)
10955 basic_filebuf_char* __thiscall basic_fstream_char_rdbuf(const basic_fstream_char *this)
10956 {
10957     TRACE("(%p)\n", this);
10958     return (basic_filebuf_char*)&this->filebuf;
10959 }
10960
10961 static inline basic_ios_wchar* basic_fstream_wchar_to_basic_ios(basic_fstream_wchar *ptr)
10962 {
10963     return (basic_ios_wchar*)((char*)ptr+basic_fstream_wchar_vbtable1[1]);
10964 }
10965
10966 static inline basic_fstream_wchar* basic_fstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
10967 {
10968     return (basic_fstream_wchar*)((char*)ptr-basic_fstream_wchar_vbtable1[1]);
10969 }
10970
10971 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@XZ */
10972 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@XZ */
10973 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor, 8)
10974 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10975 {
10976     basic_ios_wchar *basic_ios;
10977
10978     TRACE("(%p %d)\n", this, virt_init);
10979
10980     if(virt_init) {
10981         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
10982         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
10983         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10984         basic_ios_wchar_ctor(basic_ios);
10985     }else {
10986         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
10987     }
10988
10989     basic_filebuf_wchar_ctor(&this->filebuf);
10990     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
10991     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
10992     return this;
10993 }
10994
10995 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@XZ */
10996 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@XZ */
10997 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor, 8)
10998 basic_fstream_wchar* __thiscall basic_fstream_short_ctor(basic_fstream_wchar *this, MSVCP_bool virt_init)
10999 {
11000     basic_fstream_wchar_ctor(this, virt_init);
11001     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11002     return this;
11003 }
11004
11005 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
11006 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11007 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_file, 12)
11008 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_file(basic_fstream_wchar *this,
11009         FILE *file, MSVCP_bool virt_init)
11010 {
11011     basic_ios_wchar *basic_ios;
11012
11013     TRACE("(%p %p %d)\n", this, file, virt_init);
11014
11015     if(virt_init) {
11016         this->base.base1.vbtable = basic_fstream_wchar_vbtable1;
11017         this->base.base2.vbtable = basic_fstream_wchar_vbtable2;
11018         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11019         basic_ios_wchar_ctor(basic_ios);
11020     }else {
11021         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11022     }
11023
11024     basic_filebuf_wchar_ctor_file(&this->filebuf, file);
11025     basic_iostream_wchar_ctor(&this->base, &this->filebuf.base, FALSE);
11026     basic_ios->base.vtable = &MSVCP_basic_fstream_wchar_vtable;
11027     return this;
11028 }
11029
11030 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
11031 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
11032 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_file, 12)
11033 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_file(basic_fstream_wchar *this,
11034         FILE *file, MSVCP_bool virt_init)
11035 {
11036     basic_fstream_wchar_ctor_file(this, file, virt_init);
11037     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11038     return this;
11039 }
11040
11041 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAE@PB_WHH@Z */
11042 /* ??0?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAA@PEB_WHH@Z */
11043 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_ctor_name, 20)
11044 basic_fstream_wchar* __thiscall basic_fstream_wchar_ctor_name(basic_fstream_wchar *this,
11045         const char *name, int mode, int prot, MSVCP_bool virt_init)
11046 {
11047     TRACE("(%p %s %d %d %d)\n", this, name, mode, prot, virt_init);
11048
11049     basic_fstream_wchar_ctor(this, virt_init);
11050
11051     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, prot)) {
11052         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11053         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11054     }
11055     return this;
11056 }
11057
11058 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QAE@PBGHH@Z */
11059 /* ??0?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAA@PEBGHH@Z */
11060 DEFINE_THISCALL_WRAPPER(basic_fstream_short_ctor_name, 20)
11061 basic_fstream_wchar* __thiscall basic_fstream_short_ctor_name(basic_fstream_wchar *this,
11062         const char *name, int mode, int prot, MSVCP_bool virt_init)
11063 {
11064     basic_fstream_wchar_ctor_name(this, name, mode, prot, virt_init);
11065     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_fstream_short_vtable;
11066     return this;
11067 }
11068
11069 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
11070 /* ??1?$basic_fstream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
11071 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UAE@XZ */
11072 /* ??1?$basic_fstream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
11073 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_dtor, 4)
11074 void __thiscall basic_fstream_wchar_dtor(basic_ios_wchar *base)
11075 {
11076     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
11077
11078     TRACE("(%p)\n", this);
11079
11080     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
11081     basic_filebuf_wchar_dtor(&this->filebuf);
11082 }
11083
11084 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
11085 /* ??_D?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
11086 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
11087 /* ??_D?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
11088 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vbase_dtor, 4)
11089 void __thiscall basic_fstream_wchar_vbase_dtor(basic_fstream_wchar *this)
11090 {
11091     TRACE("(%p)\n", this);
11092
11093     basic_fstream_wchar_dtor(basic_fstream_wchar_to_basic_ios(this));
11094     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
11095 }
11096
11097 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_vector_dtor, 8)
11098 basic_fstream_wchar* __thiscall basic_fstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11099 {
11100     basic_fstream_wchar *this = basic_fstream_wchar_from_basic_ios(base);
11101
11102     TRACE("(%p %x)\n", this, flags);
11103
11104     if(flags & 2) {
11105         /* we have an array, with the number of elements stored before the first object */
11106         INT_PTR i, *ptr = (INT_PTR *)this-1;
11107
11108         for(i=*ptr-1; i>=0; i--)
11109             basic_fstream_wchar_vbase_dtor(this+i);
11110         MSVCRT_operator_delete(ptr);
11111     } else {
11112         basic_fstream_wchar_vbase_dtor(this);
11113         if(flags & 1)
11114             MSVCRT_operator_delete(this);
11115     }
11116
11117     return this;
11118 }
11119
11120 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
11121 /* ?close@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
11122 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXXZ */
11123 /* ?close@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
11124 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_close, 4)
11125 void __thiscall basic_fstream_wchar_close(basic_fstream_wchar *this)
11126 {
11127     TRACE("(%p)\n", this);
11128
11129     if(!basic_filebuf_wchar_close(&this->filebuf)) {
11130         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11131         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11132     }
11133 }
11134
11135 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
11136 /* ?is_open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
11137 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBE_NXZ */
11138 /* ?is_open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
11139 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_is_open, 4)
11140 MSVCP_bool __thiscall basic_fstream_wchar_is_open(const basic_fstream_wchar *this)
11141 {
11142     TRACE("(%p)\n", this);
11143     return basic_filebuf_wchar_is_open(&this->filebuf);
11144 }
11145
11146 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDHH@Z */
11147 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDHH@Z */
11148 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBDHH@Z */
11149 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDHH@Z */
11150 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open, 16)
11151 void __thiscall basic_fstream_wchar_open(basic_fstream_wchar *this,
11152         const char *name, int mode, int prot)
11153 {
11154     TRACE("(%p %s %d %d)\n", this, name, mode, prot);
11155
11156     if(!basic_filebuf_wchar_open(&this->filebuf, name, mode, prot)) {
11157         basic_ios_wchar *basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11158         basic_ios_wchar_setstate(basic_ios, IOSTATE_failbit);
11159     }
11160 }
11161
11162 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QAEXPBDI@Z */
11163 /* ?open@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEAAXPEBDI@Z */
11164 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QAEXPBDI@Z */
11165 /* ?open@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEAAXPEBDI@Z */
11166 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_open_old, 12)
11167 void __thiscall basic_fstream_wchar_open_old(basic_fstream_wchar *this,
11168         const char *name, unsigned int mode)
11169 {
11170     basic_fstream_wchar_open(this, name, mode, _SH_DENYNO);
11171 }
11172
11173 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
11174 /* ?rdbuf@?$basic_fstream@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_filebuf@_WU?$char_traits@_W@std@@@2@XZ */
11175 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
11176 /* ?rdbuf@?$basic_fstream@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_filebuf@GU?$char_traits@G@std@@@2@XZ */
11177 DEFINE_THISCALL_WRAPPER(basic_fstream_wchar_rdbuf, 4)
11178 basic_filebuf_wchar* __thiscall basic_fstream_wchar_rdbuf(const basic_fstream_wchar *this)
11179 {
11180     TRACE("(%p)\n", this);
11181     return (basic_filebuf_wchar*)&this->filebuf;
11182 }
11183
11184 static inline basic_ios_char* basic_ostringstream_char_to_basic_ios(basic_ostringstream_char *ptr)
11185 {
11186     return (basic_ios_char*)((char*)ptr+basic_ostringstream_char_vbtable[1]);
11187 }
11188
11189 static inline basic_ostringstream_char* basic_ostringstream_char_from_basic_ios(basic_ios_char *ptr)
11190 {
11191     return (basic_ostringstream_char*)((char*)ptr-basic_ostringstream_char_vbtable[1]);
11192 }
11193
11194 /* ??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 */
11195 /* ??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 */
11196 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_str, 16)
11197 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_str(basic_ostringstream_char *this,
11198         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11199 {
11200     basic_ios_char *basic_ios;
11201
11202     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11203
11204     if(virt_init) {
11205         this->base.vbtable = basic_ostringstream_char_vbtable;
11206         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11207         basic_ios_char_ctor(basic_ios);
11208     }else {
11209         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11210     }
11211
11212     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
11213     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11214     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
11215     return this;
11216 }
11217
11218 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11219 /* ??0?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11220 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor_mode, 12)
11221 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor_mode(
11222         basic_ostringstream_char *this, int mode, MSVCP_bool virt_init)
11223 {
11224     basic_ios_char *basic_ios;
11225
11226     TRACE("(%p %d %d)\n", this, mode, virt_init);
11227
11228     if(virt_init) {
11229         this->base.vbtable = basic_ostringstream_char_vbtable;
11230         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11231         basic_ios_char_ctor(basic_ios);
11232     }else {
11233         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
11234     }
11235
11236     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_out);
11237     basic_ostream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11238     basic_ios->base.vtable = &MSVCP_basic_ostringstream_char_vtable;
11239     return this;
11240 }
11241
11242 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11243 /* ??_F?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11244 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_ctor, 8)
11245 basic_ostringstream_char* __thiscall basic_ostringstream_char_ctor(
11246         basic_ostringstream_char *this, MSVCP_bool virt_init)
11247 {
11248     return basic_ostringstream_char_ctor_mode(this, 0, virt_init);
11249 }
11250
11251 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11252 /* ??1?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11253 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_dtor, 4)
11254 void __thiscall basic_ostringstream_char_dtor(basic_ios_char *base)
11255 {
11256     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
11257
11258     TRACE("(%p)\n", this);
11259
11260     basic_stringbuf_char_dtor(&this->strbuf);
11261     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
11262 }
11263
11264 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11265 /* ??_D?$basic_ostringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11266 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vbase_dtor, 4)
11267 void __thiscall basic_ostringstream_char_vbase_dtor(basic_ostringstream_char *this)
11268 {
11269     TRACE("(%p)\n", this);
11270
11271     basic_ostringstream_char_dtor(basic_ostringstream_char_to_basic_ios(this));
11272     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
11273 }
11274
11275 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_vector_dtor, 8)
11276 basic_ostringstream_char* __thiscall basic_ostringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11277 {
11278     basic_ostringstream_char *this = basic_ostringstream_char_from_basic_ios(base);
11279
11280     TRACE("(%p %x)\n", this, flags);
11281
11282     if(flags & 2) {
11283         /* we have an array, with the number of elements stored before the first object */
11284         INT_PTR i, *ptr = (INT_PTR *)this-1;
11285
11286         for(i=*ptr-1; i>=0; i--)
11287             basic_ostringstream_char_vbase_dtor(this+i);
11288         MSVCRT_operator_delete(ptr);
11289     } else {
11290         basic_ostringstream_char_vbase_dtor(this);
11291         if(flags & 1)
11292             MSVCRT_operator_delete(this);
11293     }
11294
11295     return this;
11296 }
11297
11298 /* ?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 */
11299 /* ?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 */
11300 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_rdbuf, 4)
11301 basic_stringbuf_char* __thiscall basic_ostringstream_char_rdbuf(const basic_ostringstream_char *this)
11302 {
11303     TRACE("(%p)\n", this);
11304     return (basic_stringbuf_char*)&this->strbuf;
11305 }
11306
11307 /* ?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 */
11308 /* ?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 */
11309 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_set, 8)
11310 void __thiscall basic_ostringstream_char_str_set(basic_ostringstream_char *this, const basic_string_char *str)
11311 {
11312     TRACE("(%p %p)\n", this, str);
11313     basic_stringbuf_char_str_set(&this->strbuf, str);
11314 }
11315
11316 /* ?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 */
11317 /* ?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 */
11318 DEFINE_THISCALL_WRAPPER(basic_ostringstream_char_str_get, 8)
11319 basic_string_char* __thiscall basic_ostringstream_char_str_get(const basic_ostringstream_char *this, basic_string_char *ret)
11320 {
11321     TRACE("(%p %p)\n", this, ret);
11322     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11323 }
11324
11325 static inline basic_ios_wchar* basic_ostringstream_wchar_to_basic_ios(basic_ostringstream_wchar *ptr)
11326 {
11327     return (basic_ios_wchar*)((char*)ptr+basic_ostringstream_wchar_vbtable[1]);
11328 }
11329
11330 static inline basic_ostringstream_wchar* basic_ostringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11331 {
11332     return (basic_ostringstream_wchar*)((char*)ptr-basic_ostringstream_wchar_vbtable[1]);
11333 }
11334
11335 /* ??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 */
11336 /* ??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 */
11337 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor_str, 16)
11338 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor_str(basic_ostringstream_wchar *this,
11339         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11340 {
11341     basic_ios_wchar *basic_ios;
11342
11343     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11344
11345     if(virt_init) {
11346         this->base.vbtable = basic_ostringstream_wchar_vbtable;
11347         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11348         basic_ios_wchar_ctor(basic_ios);
11349     }else {
11350         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11351     }
11352
11353     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_out);
11354     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11355     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
11356     return this;
11357 }
11358
11359 /* ??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 */
11360 /* ??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 */
11361 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_str, 16)
11362 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_str(basic_ostringstream_wchar *this,
11363         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11364 {
11365     basic_ostringstream_wchar_ctor_str(this, str, mode, virt_init);
11366     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
11367     return this;
11368 }
11369
11370 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11371 /* ??0?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11372 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor_mode, 12)
11373 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor_mode(
11374         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
11375 {
11376     basic_ios_wchar *basic_ios;
11377
11378     TRACE("(%p %d %d)\n", this, mode, virt_init);
11379
11380     if(virt_init) {
11381         this->base.vbtable = basic_ostringstream_wchar_vbtable;
11382         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11383         basic_ios_wchar_ctor(basic_ios);
11384     }else {
11385         basic_ios = basic_ostream_wchar_get_basic_ios(&this->base);
11386     }
11387
11388     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_out);
11389     basic_ostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11390     basic_ios->base.vtable = &MSVCP_basic_ostringstream_wchar_vtable;
11391     return this;
11392 }
11393
11394 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11395 /* ??0?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11396 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor_mode, 12)
11397 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor_mode(
11398         basic_ostringstream_wchar *this, int mode, MSVCP_bool virt_init)
11399 {
11400     basic_ostringstream_wchar_ctor_mode(this, mode, virt_init);
11401     basic_ostream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_ostringstream_short_vtable;
11402     return this;
11403 }
11404
11405 /* ??_F?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11406 /* ??_F?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11407 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_ctor, 8)
11408 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_ctor(
11409         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
11410 {
11411     return basic_ostringstream_wchar_ctor_mode(this, 0, virt_init);
11412 }
11413
11414 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11415 /* ??_F?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11416 DEFINE_THISCALL_WRAPPER(basic_ostringstream_short_ctor, 8)
11417 basic_ostringstream_wchar* __thiscall basic_ostringstream_short_ctor(
11418         basic_ostringstream_wchar *this, MSVCP_bool virt_init)
11419 {
11420     return basic_ostringstream_short_ctor_mode(this, 0, virt_init);
11421 }
11422
11423 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11424 /* ??1?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11425 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11426 /* ??1?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11427 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_dtor, 4)
11428 void __thiscall basic_ostringstream_wchar_dtor(basic_ios_wchar *base)
11429 {
11430     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
11431
11432     TRACE("(%p)\n", this);
11433
11434     basic_stringbuf_wchar_dtor(&this->strbuf);
11435     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base));
11436 }
11437
11438 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11439 /* ??_D?$basic_ostringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11440 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11441 /* ??_D?$basic_ostringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11442 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vbase_dtor, 4)
11443 void __thiscall basic_ostringstream_wchar_vbase_dtor(basic_ostringstream_wchar *this)
11444 {
11445     TRACE("(%p)\n", this);
11446
11447     basic_ostringstream_wchar_dtor(basic_ostringstream_wchar_to_basic_ios(this));
11448     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(&this->base));
11449 }
11450
11451 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_vector_dtor, 8)
11452 basic_ostringstream_wchar* __thiscall basic_ostringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11453 {
11454     basic_ostringstream_wchar *this = basic_ostringstream_wchar_from_basic_ios(base);
11455
11456     TRACE("(%p %x)\n", this, flags);
11457
11458     if(flags & 2) {
11459         /* we have an array, with the number of elements stored before the first object */
11460         INT_PTR i, *ptr = (INT_PTR *)this-1;
11461
11462         for(i=*ptr-1; i>=0; i--)
11463             basic_ostringstream_wchar_vbase_dtor(this+i);
11464         MSVCRT_operator_delete(ptr);
11465     } else {
11466         basic_ostringstream_wchar_vbase_dtor(this);
11467         if(flags & 1)
11468             MSVCRT_operator_delete(this);
11469     }
11470
11471     return this;
11472 }
11473
11474 /* ?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 */
11475 /* ?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 */
11476 /* ?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 */
11477 /* ?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 */
11478 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_rdbuf, 4)
11479 basic_stringbuf_wchar* __thiscall basic_ostringstream_wchar_rdbuf(const basic_ostringstream_wchar *this)
11480 {
11481     TRACE("(%p)\n", this);
11482     return (basic_stringbuf_wchar*)&this->strbuf;
11483 }
11484
11485 /* ?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 */
11486 /* ?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 */
11487 /* ?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 */
11488 /* ?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 */
11489 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_set, 8)
11490 void __thiscall basic_ostringstream_wchar_str_set(basic_ostringstream_wchar *this, const basic_string_wchar *str)
11491 {
11492     TRACE("(%p %p)\n", this, str);
11493     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11494 }
11495
11496 /* ?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 */
11497 /* ?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 */
11498 /* ?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 */
11499 /* ?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 */
11500 DEFINE_THISCALL_WRAPPER(basic_ostringstream_wchar_str_get, 8)
11501 basic_string_wchar* __thiscall basic_ostringstream_wchar_str_get(const basic_ostringstream_wchar *this, basic_string_wchar *ret)
11502 {
11503     TRACE("(%p %p)\n", this, ret);
11504     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11505 }
11506
11507 static inline basic_ios_char* basic_istringstream_char_to_basic_ios(basic_istringstream_char *ptr)
11508 {
11509     return (basic_ios_char*)((char*)ptr+basic_istringstream_char_vbtable[1]);
11510 }
11511
11512 static inline basic_istringstream_char* basic_istringstream_char_from_basic_ios(basic_ios_char *ptr)
11513 {
11514     return (basic_istringstream_char*)((char*)ptr-basic_istringstream_char_vbtable[1]);
11515 }
11516
11517 /* ??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 */
11518 /* ??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 */
11519 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_str, 16)
11520 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_str(basic_istringstream_char *this,
11521         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11522 {
11523     basic_ios_char *basic_ios;
11524
11525     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11526
11527     if(virt_init) {
11528         this->base.vbtable = basic_istringstream_char_vbtable;
11529         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11530         basic_ios_char_ctor(basic_ios);
11531     }else {
11532         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11533     }
11534
11535     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
11536     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11537     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11538     return this;
11539 }
11540
11541 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11542 /* ??0?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11543 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor_mode, 12)
11544 basic_istringstream_char* __thiscall basic_istringstream_char_ctor_mode(
11545         basic_istringstream_char *this, int mode, MSVCP_bool virt_init)
11546 {
11547     basic_ios_char *basic_ios;
11548
11549     TRACE("(%p %d %d)\n", this, mode, virt_init);
11550
11551     if(virt_init) {
11552         this->base.vbtable = basic_istringstream_char_vbtable;
11553         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11554         basic_ios_char_ctor(basic_ios);
11555     }else {
11556         basic_ios = basic_istream_char_get_basic_ios(&this->base);
11557     }
11558
11559     basic_stringbuf_char_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11560     basic_istream_char_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11561     basic_ios->base.vtable = &MSVCP_basic_istringstream_char_vtable;
11562     return this;
11563 }
11564
11565 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11566 /* ??_F?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11567 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_ctor, 8)
11568 basic_istringstream_char* __thiscall basic_istringstream_char_ctor(
11569         basic_istringstream_char *this, MSVCP_bool virt_init)
11570 {
11571     return basic_istringstream_char_ctor_mode(this, 0, virt_init);
11572 }
11573
11574 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11575 /* ??1?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11576 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_dtor, 4)
11577 void __thiscall basic_istringstream_char_dtor(basic_ios_char *base)
11578 {
11579     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11580
11581     TRACE("(%p)\n", this);
11582
11583     basic_stringbuf_char_dtor(&this->strbuf);
11584     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
11585 }
11586
11587 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11588 /* ??_D?$basic_istringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11589 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vbase_dtor, 4)
11590 void __thiscall basic_istringstream_char_vbase_dtor(basic_istringstream_char *this)
11591 {
11592     TRACE("(%p)\n", this);
11593
11594     basic_istringstream_char_dtor(basic_istringstream_char_to_basic_ios(this));
11595     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base));
11596 }
11597
11598 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_vector_dtor, 8)
11599 basic_istringstream_char* __thiscall basic_istringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11600 {
11601     basic_istringstream_char *this = basic_istringstream_char_from_basic_ios(base);
11602
11603     TRACE("(%p %x)\n", this, flags);
11604
11605     if(flags & 2) {
11606         /* we have an array, with the number of elements stored before the first object */
11607         INT_PTR i, *ptr = (INT_PTR *)this-1;
11608
11609         for(i=*ptr-1; i>=0; i--)
11610             basic_istringstream_char_vbase_dtor(this+i);
11611         MSVCRT_operator_delete(ptr);
11612     } else {
11613         basic_istringstream_char_vbase_dtor(this);
11614         if(flags & 1)
11615             MSVCRT_operator_delete(this);
11616     }
11617
11618     return this;
11619 }
11620
11621 /* ?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 */
11622 /* ?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 */
11623 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_rdbuf, 4)
11624 basic_stringbuf_char* __thiscall basic_istringstream_char_rdbuf(const basic_istringstream_char *this)
11625 {
11626     TRACE("(%p)\n", this);
11627     return (basic_stringbuf_char*)&this->strbuf;
11628 }
11629
11630 /* ?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 */
11631 /* ?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 */
11632 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_set, 8)
11633 void __thiscall basic_istringstream_char_str_set(basic_istringstream_char *this, const basic_string_char *str)
11634 {
11635     TRACE("(%p %p)\n", this, str);
11636     basic_stringbuf_char_str_set(&this->strbuf, str);
11637 }
11638
11639 /* ?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 */
11640 /* ?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 */
11641 DEFINE_THISCALL_WRAPPER(basic_istringstream_char_str_get, 8)
11642 basic_string_char* __thiscall basic_istringstream_char_str_get(const basic_istringstream_char *this, basic_string_char *ret)
11643 {
11644     TRACE("(%p %p)\n", this, ret);
11645     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11646 }
11647
11648 static inline basic_ios_wchar* basic_istringstream_wchar_to_basic_ios(basic_istringstream_wchar *ptr)
11649 {
11650     return (basic_ios_wchar*)((char*)ptr+basic_istringstream_wchar_vbtable[1]);
11651 }
11652
11653 static inline basic_istringstream_wchar* basic_istringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11654 {
11655     return (basic_istringstream_wchar*)((char*)ptr-basic_istringstream_wchar_vbtable[1]);
11656 }
11657
11658 /* ??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 */
11659 /* ??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 */
11660 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor_str, 16)
11661 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor_str(basic_istringstream_wchar *this,
11662         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11663 {
11664     basic_ios_wchar *basic_ios;
11665
11666     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11667
11668     if(virt_init) {
11669         this->base.vbtable = basic_istringstream_wchar_vbtable;
11670         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11671         basic_ios_wchar_ctor(basic_ios);
11672     }else {
11673         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11674     }
11675
11676     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode|OPENMODE_in);
11677     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11678     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11679     return this;
11680 }
11681
11682 /* ??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 */
11683 /* ??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 */
11684 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_str, 16)
11685 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_str(basic_istringstream_wchar *this,
11686         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11687 {
11688     basic_istringstream_wchar_ctor_str(this, str, mode, virt_init);
11689     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11690     return this;
11691 }
11692
11693 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
11694 /* ??0?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
11695 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor_mode, 12)
11696 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor_mode(
11697         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11698 {
11699     basic_ios_wchar *basic_ios;
11700
11701     TRACE("(%p %d %d)\n", this, mode, virt_init);
11702
11703     if(virt_init) {
11704         this->base.vbtable = basic_istringstream_wchar_vbtable;
11705         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11706         basic_ios_wchar_ctor(basic_ios);
11707     }else {
11708         basic_ios = basic_istream_wchar_get_basic_ios(&this->base);
11709     }
11710
11711     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode|OPENMODE_in);
11712     basic_istream_wchar_ctor(&this->base, &this->strbuf.base, FALSE, FALSE);
11713     basic_ios->base.vtable = &MSVCP_basic_istringstream_wchar_vtable;
11714     return this;
11715 }
11716
11717 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
11718 /* ??0?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
11719 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor_mode, 12)
11720 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor_mode(
11721         basic_istringstream_wchar *this, int mode, MSVCP_bool virt_init)
11722 {
11723     basic_istringstream_wchar_ctor_mode(this, mode, virt_init);
11724     basic_istream_wchar_get_basic_ios(&this->base)->base.vtable = &MSVCP_basic_istringstream_short_vtable;
11725     return this;
11726 }
11727
11728 /* ??_F?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11729 /* ??_F?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11730 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_ctor, 8)
11731 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_ctor(
11732         basic_istringstream_wchar *this, MSVCP_bool virt_init)
11733 {
11734     return basic_istringstream_wchar_ctor_mode(this, 0, virt_init);
11735 }
11736
11737 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11738 /* ??_F?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11739 DEFINE_THISCALL_WRAPPER(basic_istringstream_short_ctor, 8)
11740 basic_istringstream_wchar* __thiscall basic_istringstream_short_ctor(
11741         basic_istringstream_wchar *this, MSVCP_bool virt_init)
11742 {
11743     return basic_istringstream_short_ctor_mode(this, 0, virt_init);
11744 }
11745
11746 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
11747 /* ??1?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
11748 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
11749 /* ??1?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
11750 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_dtor, 4)
11751 void __thiscall basic_istringstream_wchar_dtor(basic_ios_wchar *base)
11752 {
11753     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11754
11755     TRACE("(%p)\n", this);
11756
11757     basic_stringbuf_wchar_dtor(&this->strbuf);
11758     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base));
11759 }
11760
11761 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
11762 /* ??_D?$basic_istringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
11763 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
11764 /* ??_D?$basic_istringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
11765 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vbase_dtor, 4)
11766 void __thiscall basic_istringstream_wchar_vbase_dtor(basic_istringstream_wchar *this)
11767 {
11768     TRACE("(%p)\n", this);
11769
11770     basic_istringstream_wchar_dtor(basic_istringstream_wchar_to_basic_ios(this));
11771     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base));
11772 }
11773
11774 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_vector_dtor, 8)
11775 basic_istringstream_wchar* __thiscall basic_istringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
11776 {
11777     basic_istringstream_wchar *this = basic_istringstream_wchar_from_basic_ios(base);
11778
11779     TRACE("(%p %x)\n", this, flags);
11780
11781     if(flags & 2) {
11782         /* we have an array, with the number of elements stored before the first object */
11783         INT_PTR i, *ptr = (INT_PTR *)this-1;
11784
11785         for(i=*ptr-1; i>=0; i--)
11786             basic_istringstream_wchar_vbase_dtor(this+i);
11787         MSVCRT_operator_delete(ptr);
11788     } else {
11789         basic_istringstream_wchar_vbase_dtor(this);
11790         if(flags & 1)
11791             MSVCRT_operator_delete(this);
11792     }
11793
11794     return this;
11795 }
11796
11797 /* ?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 */
11798 /* ?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 */
11799 /* ?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 */
11800 /* ?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 */
11801 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_rdbuf, 4)
11802 basic_stringbuf_wchar* __thiscall basic_istringstream_wchar_rdbuf(const basic_istringstream_wchar *this)
11803 {
11804     TRACE("(%p)\n", this);
11805     return (basic_stringbuf_wchar*)&this->strbuf;
11806 }
11807
11808 /* ?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 */
11809 /* ?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 */
11810 /* ?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 */
11811 /* ?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 */
11812 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_set, 8)
11813 void __thiscall basic_istringstream_wchar_str_set(basic_istringstream_wchar *this, const basic_string_wchar *str)
11814 {
11815     TRACE("(%p %p)\n", this, str);
11816     basic_stringbuf_wchar_str_set(&this->strbuf, str);
11817 }
11818
11819 /* ?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 */
11820 /* ?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 */
11821 /* ?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 */
11822 /* ?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 */
11823 DEFINE_THISCALL_WRAPPER(basic_istringstream_wchar_str_get, 8)
11824 basic_string_wchar* __thiscall basic_istringstream_wchar_str_get(const basic_istringstream_wchar *this, basic_string_wchar *ret)
11825 {
11826     TRACE("(%p %p)\n", this, ret);
11827     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
11828 }
11829
11830 static inline basic_ios_char* basic_stringstream_char_to_basic_ios(basic_stringstream_char *ptr)
11831 {
11832     return (basic_ios_char*)((char*)ptr+basic_stringstream_char_vbtable1[1]);
11833 }
11834
11835 static inline basic_stringstream_char* basic_stringstream_char_from_basic_ios(basic_ios_char *ptr)
11836 {
11837     return (basic_stringstream_char*)((char*)ptr-basic_stringstream_char_vbtable1[1]);
11838 }
11839
11840 /* ??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 */
11841 /* ??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 */
11842 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_str, 16)
11843 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_str(basic_stringstream_char *this,
11844         const basic_string_char *str, int mode, MSVCP_bool virt_init)
11845 {
11846     basic_ios_char *basic_ios;
11847
11848     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11849
11850     if(virt_init) {
11851         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11852         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11853         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11854         basic_ios_char_ctor(basic_ios);
11855     }else {
11856         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11857     }
11858
11859     basic_stringbuf_char_ctor_str(&this->strbuf, str, mode);
11860     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11861     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11862     return this;
11863 }
11864
11865 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@H@Z */
11866 /* ??0?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA@H@Z */
11867 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor_mode, 12)
11868 basic_stringstream_char* __thiscall basic_stringstream_char_ctor_mode(
11869         basic_stringstream_char *this, int mode, MSVCP_bool virt_init)
11870 {
11871     basic_ios_char *basic_ios;
11872
11873     TRACE("(%p %d %d)\n", this, mode, virt_init);
11874
11875     if(virt_init) {
11876         this->base.base1.vbtable = basic_stringstream_char_vbtable1;
11877         this->base.base2.vbtable = basic_stringstream_char_vbtable2;
11878         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11879         basic_ios_char_ctor(basic_ios);
11880     }else {
11881         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
11882     }
11883
11884     basic_stringbuf_char_ctor_mode(&this->strbuf, mode);
11885     basic_iostream_char_ctor(&this->base, &this->strbuf.base, FALSE);
11886     basic_ios->base.vtable = &MSVCP_basic_stringstream_char_vtable;
11887     return this;
11888 }
11889
11890 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11891 /* ??_F?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11892 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_ctor, 8)
11893 basic_stringstream_char* __thiscall basic_stringstream_char_ctor(
11894         basic_stringstream_char *this, MSVCP_bool virt_init)
11895 {
11896     return basic_stringstream_char_ctor_mode(
11897             this, OPENMODE_out|OPENMODE_in, virt_init);
11898 }
11899
11900 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UAE@XZ */
11901 /* ??1?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@UEAA@XZ */
11902 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_dtor, 4)
11903 void __thiscall basic_stringstream_char_dtor(basic_ios_char *base)
11904 {
11905     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11906
11907     TRACE("(%p)\n", this);
11908
11909     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
11910     basic_stringbuf_char_dtor(&this->strbuf);
11911 }
11912
11913 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAEXXZ */
11914 /* ??_D?$basic_stringstream@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAAXXZ */
11915 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vbase_dtor, 4)
11916 void __thiscall basic_stringstream_char_vbase_dtor(basic_stringstream_char *this)
11917 {
11918     TRACE("(%p)\n", this);
11919
11920     basic_stringstream_char_dtor(basic_stringstream_char_to_basic_ios(this));
11921     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
11922 }
11923
11924 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_vector_dtor, 8)
11925 basic_stringstream_char* __thiscall basic_stringstream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
11926 {
11927     basic_stringstream_char *this = basic_stringstream_char_from_basic_ios(base);
11928
11929     TRACE("(%p %x)\n", this, flags);
11930
11931     if(flags & 2) {
11932         /* we have an array, with the number of elements stored before the first object */
11933         INT_PTR i, *ptr = (INT_PTR *)this-1;
11934
11935         for(i=*ptr-1; i>=0; i--)
11936             basic_stringstream_char_vbase_dtor(this+i);
11937         MSVCRT_operator_delete(ptr);
11938     } else {
11939         basic_stringstream_char_vbase_dtor(this);
11940         if(flags & 1)
11941             MSVCRT_operator_delete(this);
11942     }
11943
11944     return this;
11945 }
11946
11947 /* ?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 */
11948 /* ?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 */
11949 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_rdbuf, 4)
11950 basic_stringbuf_char* __thiscall basic_stringstream_char_rdbuf(const basic_stringstream_char *this)
11951 {
11952     TRACE("(%p)\n", this);
11953     return (basic_stringbuf_char*)&this->strbuf;
11954 }
11955
11956 /* ?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 */
11957 /* ?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 */
11958 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_set, 8)
11959 void __thiscall basic_stringstream_char_str_set(basic_stringstream_char *this, const basic_string_char *str)
11960 {
11961     TRACE("(%p %p)\n", this, str);
11962     basic_stringbuf_char_str_set(&this->strbuf, str);
11963 }
11964
11965 /* ?str@?$basic_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 */
11966 /* ?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 */
11967 DEFINE_THISCALL_WRAPPER(basic_stringstream_char_str_get, 8)
11968 basic_string_char* __thiscall basic_stringstream_char_str_get(const basic_stringstream_char *this, basic_string_char *ret)
11969 {
11970     TRACE("(%p %p)\n", this, ret);
11971     return basic_stringbuf_char_str_get(&this->strbuf, ret);
11972 }
11973
11974 static inline basic_ios_wchar* basic_stringstream_wchar_to_basic_ios(basic_stringstream_wchar *ptr)
11975 {
11976     return (basic_ios_wchar*)((char*)ptr+basic_stringstream_wchar_vbtable1[1]);
11977 }
11978
11979 static inline basic_stringstream_wchar* basic_stringstream_wchar_from_basic_ios(basic_ios_wchar *ptr)
11980 {
11981     return (basic_stringstream_wchar*)((char*)ptr-basic_stringstream_wchar_vbtable1[1]);
11982 }
11983
11984 /* ??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 */
11985 /* ??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 */
11986 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor_str, 16)
11987 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor_str(basic_stringstream_wchar *this,
11988         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
11989 {
11990     basic_ios_wchar *basic_ios;
11991
11992     TRACE("(%p %p %d %d)\n", this, str, mode, virt_init);
11993
11994     if(virt_init) {
11995         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
11996         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
11997         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
11998         basic_ios_wchar_ctor(basic_ios);
11999     }else {
12000         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12001     }
12002
12003     basic_stringbuf_wchar_ctor_str(&this->strbuf, str, mode);
12004     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
12005     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
12006     return this;
12007 }
12008
12009 /* ??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 */
12010 /* ??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 */
12011 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_str, 16)
12012 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_str(basic_stringstream_wchar *this,
12013         const basic_string_wchar *str, int mode, MSVCP_bool virt_init)
12014 {
12015     basic_stringstream_wchar_ctor_str(this, str, mode, virt_init);
12016     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
12017     return this;
12018 }
12019
12020 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE@H@Z */
12021 /* ??0?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA@H@Z */
12022 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor_mode, 12)
12023 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor_mode(
12024         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
12025 {
12026     basic_ios_wchar *basic_ios;
12027
12028     TRACE("(%p %d %d)\n", this, mode, virt_init);
12029
12030     if(virt_init) {
12031         this->base.base1.vbtable = basic_stringstream_wchar_vbtable1;
12032         this->base.base2.vbtable = basic_stringstream_wchar_vbtable2;
12033         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12034         basic_ios_wchar_ctor(basic_ios);
12035     }else {
12036         basic_ios = basic_istream_wchar_get_basic_ios(&this->base.base1);
12037     }
12038
12039     basic_stringbuf_wchar_ctor_mode(&this->strbuf, mode);
12040     basic_iostream_wchar_ctor(&this->base, &this->strbuf.base, FALSE);
12041     basic_ios->base.vtable = &MSVCP_basic_stringstream_wchar_vtable;
12042     return this;
12043 }
12044
12045 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE@H@Z */
12046 /* ??0?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA@H@Z */
12047 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor_mode, 12)
12048 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor_mode(
12049         basic_stringstream_wchar *this, int mode, MSVCP_bool virt_init)
12050 {
12051     basic_stringstream_wchar_ctor_mode(this, mode, virt_init);
12052     basic_istream_wchar_get_basic_ios(&this->base.base1)->base.vtable = &MSVCP_basic_stringstream_short_vtable;
12053     return this;
12054 }
12055
12056 /* ??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12057 /* ??_F?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12058 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_ctor, 8)
12059 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_ctor(
12060         basic_stringstream_wchar *this, MSVCP_bool virt_init)
12061 {
12062     return basic_stringstream_wchar_ctor_mode(
12063             this, OPENMODE_out|OPENMODE_in, virt_init);
12064 }
12065
12066 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12067 /* ??_F?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12068 DEFINE_THISCALL_WRAPPER(basic_stringstream_short_ctor, 8)
12069 basic_stringstream_wchar* __thiscall basic_stringstream_short_ctor(
12070         basic_stringstream_wchar *this, MSVCP_bool virt_init)
12071 {
12072     return basic_stringstream_short_ctor_mode(
12073             this, OPENMODE_out|OPENMODE_in, virt_init);
12074 }
12075
12076 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UAE@XZ */
12077 /* ??1?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@UEAA@XZ */
12078 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UAE@XZ */
12079 /* ??1?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@UEAA@XZ */
12080 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_dtor, 4)
12081 void __thiscall basic_stringstream_wchar_dtor(basic_ios_wchar *base)
12082 {
12083     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
12084
12085     TRACE("(%p)\n", this);
12086
12087     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(&this->base));
12088     basic_stringbuf_wchar_dtor(&this->strbuf);
12089 }
12090
12091 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAEXXZ */
12092 /* ??_D?$basic_stringstream@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAAXXZ */
12093 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAEXXZ */
12094 /* ??_D?$basic_stringstream@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAAXXZ */
12095 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vbase_dtor, 4)
12096 void __thiscall basic_stringstream_wchar_vbase_dtor(basic_stringstream_wchar *this)
12097 {
12098     TRACE("(%p)\n", this);
12099
12100     basic_stringstream_wchar_dtor(basic_stringstream_wchar_to_basic_ios(this));
12101     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base.base1));
12102 }
12103
12104 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_vector_dtor, 8)
12105 basic_stringstream_wchar* __thiscall basic_stringstream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
12106 {
12107     basic_stringstream_wchar *this = basic_stringstream_wchar_from_basic_ios(base);
12108
12109     TRACE("(%p %x)\n", this, flags);
12110
12111     if(flags & 2) {
12112         /* we have an array, with the number of elements stored before the first object */
12113         INT_PTR i, *ptr = (INT_PTR *)this-1;
12114
12115         for(i=*ptr-1; i>=0; i--)
12116             basic_stringstream_wchar_vbase_dtor(this+i);
12117         MSVCRT_operator_delete(ptr);
12118     } else {
12119         basic_stringstream_wchar_vbase_dtor(this);
12120         if(flags & 1)
12121             MSVCRT_operator_delete(this);
12122     }
12123
12124     return this;
12125 }
12126
12127 /* ?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 */
12128 /* ?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 */
12129 /* ?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 */
12130 /* ?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 */
12131 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_rdbuf, 4)
12132 basic_stringbuf_wchar* __thiscall basic_stringstream_wchar_rdbuf(const basic_stringstream_wchar *this)
12133 {
12134     TRACE("(%p)\n", this);
12135     return (basic_stringbuf_wchar*)&this->strbuf;
12136 }
12137
12138 /* ?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 */
12139 /* ?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 */
12140 /* ?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 */
12141 /* ?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 */
12142 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_set, 8)
12143 void __thiscall basic_stringstream_wchar_str_set(basic_stringstream_wchar *this, const basic_string_wchar *str)
12144 {
12145     TRACE("(%p %p)\n", this, str);
12146     basic_stringbuf_wchar_str_set(&this->strbuf, str);
12147 }
12148
12149 /* ?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 */
12150 /* ?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 */
12151 /* ?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 */
12152 /* ?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 */
12153 DEFINE_THISCALL_WRAPPER(basic_stringstream_wchar_str_get, 8)
12154 basic_string_wchar* __thiscall basic_stringstream_wchar_str_get(const basic_stringstream_wchar *this, basic_string_wchar *ret)
12155 {
12156     TRACE("(%p %p)\n", this, ret);
12157     return basic_stringbuf_wchar_str_get(&this->strbuf, ret);
12158 }
12159
12160 /* ?_Init@strstreambuf@std@@IAEXHPAD0H@Z */
12161 /* ?_Init@strstreambuf@std@@IEAAX_JPEAD1H@Z */
12162 DEFINE_THISCALL_WRAPPER(strstreambuf__Init, 20)
12163 void __thiscall strstreambuf__Init(strstreambuf *this, streamsize len, char *g, char *p, int mode)
12164 {
12165     TRACE("(%p %ld %p %p %d)\n", this, len, g, p, mode);
12166
12167     this->minsize = 32;
12168     this->endsave = NULL;
12169     this->strmode = mode;
12170     this->palloc = NULL;
12171     this->pfree = NULL;
12172
12173     if(!g) {
12174         this->strmode |= STRSTATE_Dynamic;
12175         if(len > this->minsize)
12176             this->minsize = len;
12177         this->seekhigh = NULL;
12178         return;
12179     }
12180
12181     if(len < 0)
12182         len = INT_MAX;
12183     else if(!len)
12184         len = strlen(g);
12185
12186     this->seekhigh = g+len;
12187     basic_streambuf_char_setg(&this->base, g, g, p ? p : this->seekhigh);
12188     if(p)
12189         basic_streambuf_char_setp(&this->base, p, this->seekhigh);
12190 }
12191
12192 /* ??0strstreambuf@std@@QAE@PACH0@Z */
12193 /* ??0strstreambuf@std@@QEAA@PEAC_J0@Z */
12194 /* ??0strstreambuf@std@@QAE@PADH0@Z */
12195 /* ??0strstreambuf@std@@QEAA@PEAD_J0@Z */
12196 /* ??0strstreambuf@std@@QAE@PAEH0@Z */
12197 /* ??0strstreambuf@std@@QEAA@PEAE_J0@Z */
12198 static strstreambuf* strstreambuf_ctor_get_put(strstreambuf *this, char *g, streamsize len, char *p)
12199 {
12200     TRACE("(%p %p %ld %p)\n", this, g, len, p);
12201
12202     basic_streambuf_char_ctor(&this->base);
12203     this->base.vtable = &MSVCP_strstreambuf_vtable;
12204
12205     strstreambuf__Init(this, len, g, p, 0);
12206     return this;
12207 }
12208
12209 /* ?_Tidy@strstreambuf@std@@IAEXXZ */
12210 /* ?_Tidy@strstreambuf@std@@IEAAXXZ */
12211 DEFINE_THISCALL_WRAPPER(strstreambuf__Tidy, 4)
12212 void __thiscall strstreambuf__Tidy(strstreambuf *this)
12213 {
12214     TRACE("(%p)\n", this);
12215
12216     if((this->strmode & STRSTATE_Allocated) && !(this->strmode & STRSTATE_Frozen)) {
12217         if(this->pfree)
12218             this->pfree(basic_streambuf_char_eback(&this->base));
12219         else
12220             MSVCRT_operator_delete(basic_streambuf_char_eback(&this->base));
12221     }
12222
12223     this->endsave = NULL;
12224     this->seekhigh = NULL;
12225     this->strmode &= ~(STRSTATE_Allocated | STRSTATE_Frozen);
12226     basic_streambuf_char_setg(&this->base, NULL, NULL, NULL);
12227     basic_streambuf_char_setp(&this->base, NULL, NULL);
12228 }
12229
12230 /* ??1strstreambuf@std@@UAE@XZ */
12231 /* ??1strstreambuf@std@@UEAA@XZ */
12232 DEFINE_THISCALL_WRAPPER(strstreambuf_dtor, 4)
12233 void __thiscall strstreambuf_dtor(strstreambuf *this)
12234 {
12235     TRACE("(%p)\n", this);
12236
12237     strstreambuf__Tidy(this);
12238     basic_streambuf_char_dtor(&this->base);
12239 }
12240
12241 DEFINE_THISCALL_WRAPPER(strstreambuf_vector_dtor, 8)
12242 strstreambuf* __thiscall strstreambuf_vector_dtor(strstreambuf *this, unsigned int flags)
12243 {
12244     TRACE("(%p %x)\n", this, flags);
12245     if(flags & 2) {
12246         /* we have an array, with the number of elements stored before the first object */
12247         INT_PTR i, *ptr = (INT_PTR *)this-1;
12248
12249         for(i=*ptr-1; i>=0; i--)
12250             strstreambuf_dtor(this+i);
12251         MSVCRT_operator_delete(ptr);
12252     } else {
12253         strstreambuf_dtor(this);
12254         if(flags & 1)
12255             MSVCRT_operator_delete(this);
12256     }
12257
12258     return this;
12259 }
12260
12261 /* ?freeze@strstreambuf@std@@QAEX_N@Z */
12262 /* ?freeze@strstreambuf@std@@QEAAX_N@Z */
12263 DEFINE_THISCALL_WRAPPER(strstreambuf_freeze, 8)
12264 void __thiscall strstreambuf_freeze(strstreambuf *this, MSVCP_bool freeze)
12265 {
12266     TRACE("(%p %d)\n", this, freeze);
12267
12268     if(!freeze == !(this->strmode *STRSTATE_Frozen))
12269         return;
12270
12271     if(freeze) {
12272         this->strmode |= STRSTATE_Frozen;
12273         this->endsave = basic_streambuf_char_epptr(&this->base);
12274         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
12275                 basic_streambuf_char_pptr(&this->base), basic_streambuf_char_eback(&this->base));
12276     }else {
12277         this->strmode &= ~STRSTATE_Frozen;
12278         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base),
12279                 basic_streambuf_char_pptr(&this->base), this->endsave);
12280     }
12281 }
12282
12283 /* ?overflow@strstreambuf@std@@MAEHH@Z */
12284 /* ?overflow@strstreambuf@std@@MEAAHH@Z */
12285 DEFINE_THISCALL_WRAPPER(strstreambuf_overflow, 8)
12286 int __thiscall strstreambuf_overflow(strstreambuf *this, int c)
12287 {
12288     MSVCP_size_t old_size, size;
12289     char *ptr, *buf;
12290
12291     TRACE("(%p %d)\n", this, c);
12292
12293     if(c == EOF)
12294         return !EOF;
12295
12296     if(this->strmode & STRSTATE_Frozen)
12297         return EOF;
12298
12299     ptr = basic_streambuf_char_pptr(&this->base);
12300     if(ptr && ptr<basic_streambuf_char_epptr(&this->base))
12301         return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
12302
12303     if(!(this->strmode & STRSTATE_Dynamic) || (this->strmode & STRSTATE_Constant))
12304         return EOF;
12305
12306     ptr = basic_streambuf_char_eback(&this->base);
12307     old_size = ptr ? basic_streambuf_char_epptr(&this->base) - ptr : 0;
12308
12309     size = old_size + old_size/2;
12310     if(size < this->minsize)
12311         size = this->minsize;
12312
12313     if(this->palloc)
12314         buf = this->palloc(size);
12315     else
12316         buf = MSVCRT_operator_new(size);
12317     if(!buf)
12318         return EOF;
12319
12320     memcpy(buf, ptr, old_size);
12321     if(this->strmode & STRSTATE_Allocated) {
12322         if(this->pfree)
12323             this->pfree(ptr);
12324         else
12325             MSVCRT_operator_delete(ptr);
12326     }
12327
12328     this->strmode |= STRSTATE_Allocated;
12329     if(!old_size) {
12330         this->seekhigh = buf;
12331         basic_streambuf_char_setp(&this->base, buf, buf+size);
12332         basic_streambuf_char_setg(&this->base, buf, buf, buf);
12333     }else {
12334         this->seekhigh = this->seekhigh-ptr+buf;
12335         basic_streambuf_char_setp_next(&this->base, basic_streambuf_char_pbase(&this->base)-ptr+buf,
12336                 basic_streambuf_char_pptr(&this->base)-ptr+buf, buf+size);
12337         basic_streambuf_char_setg(&this->base, buf, basic_streambuf_char_gptr(&this->base)-ptr+buf,
12338                 basic_streambuf_char_pptr(&this->base));
12339     }
12340
12341     return (unsigned char)(*basic_streambuf_char__Pninc(&this->base) = c);
12342 }
12343
12344 /* ?pbackfail@strstreambuf@std@@MAEHH@Z */
12345 /* ?pbackfail@strstreambuf@std@@MEAAHH@Z */
12346 DEFINE_THISCALL_WRAPPER(strstreambuf_pbackfail, 8)
12347 int __thiscall strstreambuf_pbackfail(strstreambuf *this, int c)
12348 {
12349     char *ptr = basic_streambuf_char_gptr(&this->base);
12350
12351     TRACE("(%p %d)\n", this, c);
12352
12353     if(ptr<=basic_streambuf_char_eback(&this->base)
12354             || ((this->strmode & STRSTATE_Constant) && c!=ptr[-1]))
12355         return EOF;
12356
12357     basic_streambuf_char_gbump(&this->base, -1);
12358     if(c == EOF)
12359         return !EOF;
12360     if(this->strmode & STRSTATE_Constant)
12361         return (unsigned char)c;
12362
12363     return (unsigned char)(ptr[0] = c);
12364 }
12365
12366 /* ?seekoff@strstreambuf@std@@MAE?AV?$fpos@H@2@JHH@Z */
12367 /* ?seekoff@strstreambuf@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
12368 DEFINE_THISCALL_WRAPPER(strstreambuf_seekoff, 20)
12369 fpos_int* __thiscall strstreambuf_seekoff(strstreambuf *this, fpos_int *ret, streamoff off, int way, int mode)
12370 {
12371     char *eback = basic_streambuf_char_eback(&this->base);
12372     char *pptr = basic_streambuf_char_pptr(&this->base);
12373     char *gptr = basic_streambuf_char_gptr(&this->base);
12374
12375     TRACE("(%p %p %ld %d %d)\n", this, ret, off, way, mode);
12376
12377     ret->off = 0;
12378     ret->state = 0;
12379
12380     if(pptr > this->seekhigh)
12381         this->seekhigh = pptr;
12382
12383     if((mode & OPENMODE_in) && gptr) {
12384         if(way==SEEKDIR_cur && !(mode & OPENMODE_out))
12385             off += gptr-eback;
12386         else if(way == SEEKDIR_end)
12387             off += this->seekhigh-eback;
12388         else if(way != SEEKDIR_beg)
12389             off = -1;
12390
12391         if(off<0 || off>this->seekhigh-eback) {
12392             off = -1;
12393         }else {
12394             basic_streambuf_char_gbump(&this->base, eback-gptr+off);
12395             if((mode & OPENMODE_out) && pptr) {
12396                 basic_streambuf_char_setp_next(&this->base, eback,
12397                         gptr, basic_streambuf_char_epptr(&this->base));
12398             }
12399         }
12400     }else if((mode & OPENMODE_out) && pptr) {
12401         if(way == SEEKDIR_cur)
12402             off += pptr-eback;
12403         else if(way == SEEKDIR_end)
12404             off += this->seekhigh-eback;
12405         else if(way != SEEKDIR_beg)
12406             off = -1;
12407
12408          if(off<0 || off>this->seekhigh-eback)
12409              off = -1;
12410          else
12411              basic_streambuf_char_pbump(&this->base, eback-pptr+off);
12412     }else {
12413         off = -1;
12414     }
12415
12416     ret->pos = off;
12417     return ret;
12418 }
12419
12420 /* ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z */
12421 /* ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
12422 DEFINE_THISCALL_WRAPPER(strstreambuf_seekpos, 36)
12423 fpos_int* __thiscall strstreambuf_seekpos(strstreambuf *this, fpos_int *ret, fpos_int pos, int mode)
12424 {
12425     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
12426
12427     if(pos.off==-1 && pos.pos==0 && pos.state==0) {
12428         *ret = pos;
12429         return ret;
12430     }
12431
12432     return strstreambuf_seekoff(this, ret, pos.off, SEEKDIR_beg, mode);
12433 }
12434
12435 /* ?underflow@strstreambuf@std@@MAEHXZ */
12436 /* ?underflow@strstreambuf@std@@MEAAHXZ */
12437 DEFINE_THISCALL_WRAPPER(strstreambuf_underflow, 4)
12438 int __thiscall strstreambuf_underflow(strstreambuf *this)
12439 {
12440     char *gptr = basic_streambuf_char_gptr(&this->base);
12441     char *pptr;
12442
12443     TRACE("(%p)\n", this);
12444
12445     if(!gptr)
12446         return EOF;
12447
12448     if(gptr < basic_streambuf_char_egptr(&this->base))
12449         return (unsigned char)(*gptr);
12450
12451     pptr = basic_streambuf_char_gptr(&this->base);
12452     if(pptr > this->seekhigh)
12453         this->seekhigh = pptr;
12454
12455     if(this->seekhigh <= gptr)
12456         return EOF;
12457
12458     basic_streambuf_char_setg(&this->base, basic_streambuf_char_eback(&this->base),
12459             gptr, this->seekhigh);
12460     return (unsigned char)(*gptr);
12461 }
12462
12463 static inline basic_ios_char* ostrstream_to_basic_ios(ostrstream *ptr)
12464 {
12465     return (basic_ios_char*)((char*)ptr+ostrstream_vbtable[1]);
12466 }
12467
12468 static inline ostrstream* ostrstream_from_basic_ios(basic_ios_char *ptr)
12469 {
12470     return (ostrstream*)((char*)ptr-ostrstream_vbtable[1]);
12471 }
12472
12473 /* ??0ostrstream@std@@QAE@PADHH@Z */
12474 DEFINE_THISCALL_WRAPPER(ostrstream_ctor, 20)
12475 ostrstream* __thiscall ostrstream_ctor(ostrstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
12476 {
12477     basic_ios_char *basic_ios;
12478
12479     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
12480
12481     if(virt_init) {
12482         this->base.vbtable = ostrstream_vbtable;
12483         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
12484         basic_ios_char_ctor(basic_ios);
12485     }else {
12486         basic_ios = basic_ostream_char_get_basic_ios(&this->base);
12487     }
12488
12489     strstreambuf_ctor_get_put(&this->buf, buf, size,
12490             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
12491     basic_ostream_char_ctor(&this->base, &this->buf.base, FALSE, FALSE);
12492     basic_ios->base.vtable = &MSVCP_ostrstream_vtable;
12493     return this;
12494 }
12495
12496 /* ??1ostrstream@std@@UAE@XZ */
12497 /* ??1ostrstream@std@@UEAA@XZ */
12498 DEFINE_THISCALL_WRAPPER(ostrstream_dtor, 4)
12499 void __thiscall ostrstream_dtor(basic_ios_char *base)
12500 {
12501     ostrstream *this = ostrstream_from_basic_ios(base);
12502
12503     TRACE("(%p)\n", this);
12504
12505     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base));
12506     strstreambuf_dtor(&this->buf);
12507 }
12508
12509 static void ostrstream_vbase_dtor(ostrstream *this)
12510 {
12511     TRACE("(%p)\n", this);
12512
12513     ostrstream_dtor(ostrstream_to_basic_ios(this));
12514     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(&this->base));
12515 }
12516
12517 DEFINE_THISCALL_WRAPPER(ostrstream_vector_dtor, 8)
12518 ostrstream* __thiscall ostrstream_vector_dtor(basic_ios_char *base, unsigned int flags)
12519 {
12520     ostrstream *this = ostrstream_from_basic_ios(base);
12521
12522     TRACE("(%p %x)\n", this, flags);
12523
12524     if(flags & 2) {
12525         /* we have an array, with the number of elements stored before the first object */
12526         INT_PTR i, *ptr = (INT_PTR *)this-1;
12527
12528         for(i=*ptr-1; i>=0; i--)
12529             ostrstream_vbase_dtor(this+i);
12530         MSVCRT_operator_delete(ptr);
12531     } else {
12532         ostrstream_vbase_dtor(this);
12533         if(flags & 1)
12534             MSVCRT_operator_delete(this);
12535     }
12536
12537     return this;
12538 }
12539
12540 static inline istrstream* istrstream_from_basic_ios(basic_ios_char *ptr)
12541 {
12542     return (istrstream*)((char*)ptr-istrstream_vbtable[1]);
12543 }
12544
12545 /* ??1istrstream@std@@UAE@XZ */
12546 /* ??1istrstream@std@@UEAA@XZ */
12547 DEFINE_THISCALL_WRAPPER(istrstream_dtor, 4)
12548 void __thiscall istrstream_dtor(basic_ios_char *base)
12549 {
12550     istrstream *this = istrstream_from_basic_ios(base);
12551
12552     TRACE("(%p)\n", this);
12553
12554     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base));
12555     strstreambuf_dtor(&this->buf);
12556 }
12557
12558 static inline basic_ios_char* strstream_to_basic_ios(strstream *ptr)
12559 {
12560     return (basic_ios_char*)((char*)ptr+strstream_vbtable1[1]);
12561 }
12562
12563 static inline strstream* strstream_from_basic_ios(basic_ios_char *ptr)
12564 {
12565     return (strstream*)((char*)ptr-strstream_vbtable1[1]);
12566 }
12567
12568 /* ??0strstream@std@@QAE@PADHH@Z */
12569 /* ??0strstream@std@@QEAA@PEAD_JH@Z */
12570 DEFINE_THISCALL_WRAPPER(strstream_ctor, 20)
12571 strstream* __thiscall strstream_ctor(strstream *this, char *buf, streamsize size, int mode, MSVCP_bool virt_init)
12572 {
12573     basic_ios_char *basic_ios;
12574
12575     TRACE("(%p %p %ld %d %d)\n", this, buf, size, mode, virt_init);
12576
12577     if(virt_init) {
12578         this->base.base1.vbtable = strstream_vbtable1;
12579         this->base.base2.vbtable = strstream_vbtable2;
12580         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12581         basic_ios_char_ctor(basic_ios);
12582     }else {
12583         basic_ios = basic_istream_char_get_basic_ios(&this->base.base1);
12584     }
12585
12586     strstreambuf_ctor_get_put(&this->buf, buf, size,
12587             buf && (mode & OPENMODE_app) ? buf+strlen(buf) : buf);
12588     basic_iostream_char_ctor(&this->base, &this->buf.base, FALSE);
12589     basic_ios->base.vtable = &MSVCP_strstream_vtable;
12590     return this;
12591 }
12592
12593 /* ??1strstream@std@@UAE@XZ */
12594 /* ??1strstream@std@@UEAA@XZ */
12595 DEFINE_THISCALL_WRAPPER(strstream_dtor, 4)
12596 void __thiscall strstream_dtor(basic_ios_char *base)
12597 {
12598     strstream *this = strstream_from_basic_ios(base);
12599
12600     TRACE("(%p)\n", this);
12601
12602     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(&this->base));
12603     strstreambuf_dtor(&this->buf);
12604 }
12605
12606 static void strstream_vbase_dtor(strstream *this)
12607 {
12608     TRACE("(%p)\n", this);
12609
12610     strstream_dtor(strstream_to_basic_ios(this));
12611     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base.base1));
12612 }
12613
12614 DEFINE_THISCALL_WRAPPER(strstream_vector_dtor, 8)
12615 strstream* __thiscall strstream_vector_dtor(basic_ios_char *base, unsigned int flags)
12616 {
12617     strstream *this = strstream_from_basic_ios(base);
12618
12619     TRACE("(%p %x)\n", this, flags);
12620
12621     if(flags & 2) {
12622         /* we have an array, with the number of elements stored before the first object */
12623         INT_PTR i, *ptr = (INT_PTR *)this-1;
12624
12625         for(i=*ptr-1; i>=0; i--)
12626             strstream_vbase_dtor(this+i);
12627         MSVCRT_operator_delete(ptr);
12628     } else {
12629         strstream_vbase_dtor(this);
12630         if(flags & 1)
12631             MSVCRT_operator_delete(this);
12632     }
12633
12634     return this;
12635 }
12636
12637 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
12638 {
12639     ios_base_precision_set(base, prec);
12640 }
12641
12642 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
12643 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12644 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
12645 {
12646     TRACE("(%p %ld)\n", ret, prec);
12647
12648     ret->pfunc = setprecision_func;
12649     ret->arg = prec;
12650     return ret;
12651 }
12652
12653 static void __cdecl setw_func(ios_base *base, streamsize width)
12654 {
12655     ios_base_width_set(base, width);
12656 }
12657
12658 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
12659 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
12660 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
12661 {
12662     TRACE("(%p %ld)\n", ret, width);
12663
12664     ret->pfunc = setw_func;
12665     ret->arg = width;
12666     return ret;
12667 }
12668
12669 static void __cdecl resetioflags_func(ios_base *base, int mask)
12670 {
12671     ios_base_setf_mask(base, 0, mask);
12672 }
12673
12674 /* ?resetiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12675 manip_int* __cdecl resetiosflags(manip_int *ret, int mask)
12676 {
12677     TRACE("(%p %d)\n", ret, mask);
12678
12679     ret->pfunc = resetioflags_func;
12680     ret->arg = mask;
12681     return ret;
12682 }
12683
12684 static void __cdecl setiosflags_func(ios_base *base, int mask)
12685 {
12686     ios_base_setf_mask(base, FMTFLAG_mask, mask);
12687 }
12688
12689 /* ?setiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
12690 manip_int* __cdecl setiosflags(manip_int *ret, int mask)
12691 {
12692     TRACE("(%p %d)\n", ret, mask);
12693
12694     ret->pfunc = setiosflags_func;
12695     ret->arg = mask;
12696     return ret;
12697 }
12698
12699 static void __cdecl setbase_func(ios_base *base, int set_base)
12700 {
12701     if(set_base == 10)
12702         set_base = FMTFLAG_dec;
12703     else if(set_base == 8)
12704         set_base = FMTFLAG_oct;
12705     else if(set_base == 16)
12706         set_base = FMTFLAG_hex;
12707     else
12708         set_base = 0;
12709
12710     ios_base_setf_mask(base, set_base, FMTFLAG_basefield);
12711 }
12712
12713 /* ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z */
12714 manip_int* __cdecl setbase(manip_int *ret, int base)
12715 {
12716     TRACE("(%p %d)\n", ret, base);
12717
12718     ret->pfunc = setbase_func;
12719     ret->arg = base;
12720     return ret;
12721 }
12722
12723 static basic_filebuf_char filebuf_char_stdin;
12724 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
12725 struct {
12726     basic_istream_char obj;
12727     basic_ios_char vbase;
12728 } cin = { { 0 } };
12729 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
12730 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
12731 basic_istream_char *_Ptr_cin = &cin.obj;
12732
12733 static basic_filebuf_wchar filebuf_short_stdin;
12734 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
12735 struct {
12736     basic_istream_wchar obj;
12737     basic_ios_wchar vbase;
12738 } ucin = { { 0 } };
12739 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
12740 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
12741 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
12742
12743 static basic_filebuf_wchar filebuf_wchar_stdin;
12744 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12745 struct {
12746     basic_istream_wchar obj;
12747     basic_ios_wchar vbase;
12748 } wcin = { { 0 } };
12749 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
12750 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
12751 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
12752
12753 static basic_filebuf_char filebuf_char_stdout;
12754 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12755 struct {
12756     basic_ostream_char obj;
12757     basic_ios_char vbase;
12758 } cout = { { 0 } };
12759 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12760 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12761 basic_ostream_char *_Ptr_cout = &cout.obj;
12762
12763 static basic_filebuf_wchar filebuf_short_stdout;
12764 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12765 struct {
12766     basic_ostream_wchar obj;
12767     basic_ios_wchar vbase;
12768 } ucout = { { 0 } };
12769 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12770 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12771 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
12772
12773 static basic_filebuf_wchar filebuf_wchar_stdout;
12774 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12775 struct {
12776     basic_ostream_wchar obj;
12777     basic_ios_wchar vbase;
12778 } wcout = { { 0 } };
12779 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12780 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12781 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
12782
12783 static basic_filebuf_char filebuf_char_stderr;
12784 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12785 struct {
12786     basic_ostream_char obj;
12787     basic_ios_char vbase;
12788 } cerr = { { 0 } };
12789 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12790 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12791 basic_ostream_char *_Ptr_cerr = &cerr.obj;
12792
12793 static basic_filebuf_wchar filebuf_short_stderr;
12794 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12795 struct {
12796     basic_ostream_wchar obj;
12797     basic_ios_wchar vbase;
12798 } ucerr = { { 0 } };
12799 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12800 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12801 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
12802
12803 static basic_filebuf_wchar filebuf_wchar_stderr;
12804 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12805 struct {
12806     basic_ostream_wchar obj;
12807     basic_ios_wchar vbase;
12808 } wcerr = { { 0 } };
12809 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12810 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12811 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
12812
12813 static basic_filebuf_char filebuf_char_log;
12814 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12815 struct {
12816     basic_ostream_char obj;
12817     basic_ios_char vbase;
12818 } clog = { { 0 } };
12819 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
12820 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
12821 basic_ostream_char *_Ptr_clog = &clog.obj;
12822
12823 static basic_filebuf_wchar filebuf_short_log;
12824 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12825 struct {
12826     basic_ostream_wchar obj;
12827     basic_ios_wchar vbase;
12828 } uclog = { { 0 } };
12829 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
12830 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
12831 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
12832
12833 static basic_filebuf_wchar filebuf_wchar_log;
12834 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12835 struct {
12836     basic_ostream_wchar obj;
12837     basic_ios_wchar vbase;
12838 } wclog = { { 0 } };
12839 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
12840 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
12841 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
12842
12843 /* ?_Init_cnt@Init@ios_base@std@@0HA */
12844 int ios_base_Init__Init_cnt = -1;
12845
12846 /* ?_Init_ctor@Init@ios_base@std@@CAXPAV123@@Z */
12847 /* ?_Init_ctor@Init@ios_base@std@@CAXPEAV123@@Z */
12848 static void ios_base_Init__Init_ctor(void *this)
12849 {
12850     TRACE("(%p)\n", this);
12851
12852     if(ios_base_Init__Init_cnt < 0)
12853         ios_base_Init__Init_cnt = 1;
12854     else
12855         ios_base_Init__Init_cnt++;
12856 }
12857
12858 /* ??0Init@ios_base@std@@QAE@XZ */
12859 /* ??0Init@ios_base@std@@QEAA@XZ */
12860 DEFINE_THISCALL_WRAPPER(ios_base_Init_ctor, 4)
12861 void* __thiscall ios_base_Init_ctor(void *this)
12862 {
12863     ios_base_Init__Init_ctor(this);
12864     return this;
12865 }
12866
12867 /* ?_Init_dtor@Init@ios_base@std@@CAXPAV123@@Z */
12868 /* ?_Init_dtor@Init@ios_base@std@@CAXPEAV123@@Z */
12869 static void ios_base_Init__Init_dtor(void *this)
12870 {
12871     TRACE("(%p)\n", this);
12872
12873     ios_base_Init__Init_cnt--;
12874     if(!ios_base_Init__Init_cnt) {
12875         basic_ostream_char_flush(&cout.obj);
12876         basic_ostream_char_flush(&cerr.obj);
12877         basic_ostream_char_flush(&clog.obj);
12878     }
12879 }
12880
12881 /* ??1Init@ios_base@std@@QAE@XZ */
12882 /* ??1Init@ios_base@std@@QEAA@XZ */
12883 DEFINE_THISCALL_WRAPPER(ios_base_Init_dtor, 4)
12884 void __thiscall ios_base_Init_dtor(void *this)
12885 {
12886     ios_base_Init__Init_dtor(this);
12887 }
12888
12889 /* ??4Init@ios_base@std@@QAEAAV012@ABV012@@Z */
12890 /* ??4Init@ios_base@std@@QEAAAEAV012@AEBV012@@Z */
12891 DEFINE_THISCALL_WRAPPER(ios_base_Init_op_assign, 8)
12892 void* __thiscall ios_base_Init_op_assign(void *this, void *rhs)
12893 {
12894     TRACE("(%p %p)\n", this, rhs);
12895     return this;
12896 }
12897
12898 /* ?_Init_cnt@_Winit@std@@0HA */
12899 int _Winit__Init_cnt = -1;
12900
12901 /* ??0_Winit@std@@QAE@XZ */
12902 /* ??0_Winit@std@@QEAA@XZ */
12903 DEFINE_THISCALL_WRAPPER(_Winit_ctor, 4)
12904 void* __thiscall _Winit_ctor(void *this)
12905 {
12906     TRACE("(%p)\n", this);
12907
12908     if(_Winit__Init_cnt < 0)
12909         _Winit__Init_cnt = 1;
12910     else
12911         _Winit__Init_cnt++;
12912
12913     return this;
12914 }
12915
12916 /* ??1_Winit@std@@QAE@XZ */
12917 /* ??1_Winit@std@@QAE@XZ */
12918 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)
12919 void __thiscall _Winit_dtor(void *this)
12920 {
12921     TRACE("(%p)\n", this);
12922
12923     _Winit__Init_cnt--;
12924     if(!_Winit__Init_cnt) {
12925         basic_ostream_wchar_flush(&wcout.obj);
12926         basic_ostream_wchar_flush(&wcerr.obj);
12927         basic_ostream_wchar_flush(&wclog.obj);
12928     }
12929 }
12930
12931 /* ??4_Winit@std@@QAEAAV01@ABV01@@Z */
12932 /* ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z */
12933 DEFINE_THISCALL_WRAPPER(_Winit_op_assign, 8)
12934 void* __thiscall _Winit_op_assign(void *this, void *rhs)
12935 {
12936     TRACE("(%p %p)\n", this, rhs);
12937     return this;
12938 }
12939
12940 void init_io(void *base)
12941 {
12942 #ifdef __x86_64__
12943     init_iosb_rtti(base);
12944     init_ios_base_rtti(base);
12945     init_basic_ios_char_rtti(base);
12946     init_basic_ios_wchar_rtti(base);
12947     init_basic_ios_short_rtti(base);
12948     init_basic_streambuf_char_rtti(base);
12949     init_basic_streambuf_wchar_rtti(base);
12950     init_basic_streambuf_short_rtti(base);
12951     init_basic_filebuf_char_rtti(base);
12952     init_basic_filebuf_wchar_rtti(base);
12953     init_basic_filebuf_short_rtti(base);
12954     init_basic_stringbuf_char_rtti(base);
12955     init_basic_stringbuf_wchar_rtti(base);
12956     init_basic_stringbuf_short_rtti(base);
12957     init_basic_ostream_char_rtti(base);
12958     init_basic_ostream_wchar_rtti(base);
12959     init_basic_ostream_short_rtti(base);
12960     init_basic_istream_char_rtti(base);
12961     init_basic_istream_wchar_rtti(base);
12962     init_basic_istream_short_rtti(base);
12963     init_basic_iostream_char_rtti(base);
12964     init_basic_iostream_wchar_rtti(base);
12965     init_basic_iostream_short_rtti(base);
12966     init_basic_ofstream_char_rtti(base);
12967     init_basic_ofstream_wchar_rtti(base);
12968     init_basic_ofstream_short_rtti(base);
12969     init_basic_ifstream_char_rtti(base);
12970     init_basic_ifstream_wchar_rtti(base);
12971     init_basic_ifstream_short_rtti(base);
12972     init_basic_fstream_char_rtti(base);
12973     init_basic_fstream_wchar_rtti(base);
12974     init_basic_fstream_short_rtti(base);
12975     init_basic_ostringstream_char_rtti(base);
12976     init_basic_ostringstream_wchar_rtti(base);
12977     init_basic_ostringstream_short_rtti(base);
12978     init_basic_istringstream_char_rtti(base);
12979     init_basic_istringstream_wchar_rtti(base);
12980     init_basic_istringstream_short_rtti(base);
12981     init_basic_stringstream_char_rtti(base);
12982     init_basic_stringstream_wchar_rtti(base);
12983     init_basic_stringstream_short_rtti(base);
12984     init_strstreambuf_rtti(base);
12985     init_strstream_rtti(base);
12986     init_ostrstream_rtti(base);
12987 #endif
12988
12989     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
12990     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
12991
12992     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
12993     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
12994
12995     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
12996     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
12997
12998     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
12999     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE);
13000
13001     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
13002     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE);
13003
13004     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
13005     basic_ostream_wchar_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE);
13006
13007     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
13008     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE);
13009
13010     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
13011     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE);
13012
13013     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
13014     basic_ostream_wchar_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE);
13015
13016     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
13017     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE);
13018
13019     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
13020     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE);
13021
13022     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
13023     basic_ostream_wchar_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE);
13024 }
13025
13026 void free_io(void)
13027 {
13028     basic_istream_char_vbase_dtor(&cin.obj);
13029     basic_filebuf_char_dtor(&filebuf_char_stdin);
13030
13031     basic_istream_wchar_vbase_dtor(&ucin.obj);
13032     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
13033
13034     basic_istream_wchar_vbase_dtor(&wcin.obj);
13035     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
13036
13037     basic_ostream_char_vbase_dtor(&cout.obj);
13038     basic_filebuf_char_dtor(&filebuf_char_stdout);
13039
13040     basic_ostream_wchar_vbase_dtor(&ucout.obj);
13041     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
13042
13043     basic_ostream_wchar_vbase_dtor(&wcout.obj);
13044     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
13045
13046     basic_ostream_char_vbase_dtor(&cerr.obj);
13047     basic_filebuf_char_dtor(&filebuf_char_stderr);
13048
13049     basic_ostream_wchar_vbase_dtor(&ucerr.obj);
13050     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
13051
13052     basic_ostream_wchar_vbase_dtor(&wcerr.obj);
13053     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
13054
13055     basic_ostream_char_vbase_dtor(&clog.obj);
13056     basic_filebuf_char_dtor(&filebuf_char_log);
13057
13058     basic_ostream_wchar_vbase_dtor(&uclog.obj);
13059     basic_filebuf_wchar_dtor(&filebuf_short_log);
13060
13061     basic_ostream_wchar_vbase_dtor(&wclog.obj);
13062     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
13063 }