dmusic: Set instrument stream position where the instrument begins, not at the beginn...
[wine] / dlls / msvcp100 / 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(%s %s %d)", wine_dbgstr_longlong(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 struct {
85     ios_base base;
86     basic_streambuf_char *strbuf;
87     struct _basic_ostream_char *stream;
88     char fillch;
89 } basic_ios_char;
90
91 typedef struct {
92     ios_base base;
93     basic_streambuf_wchar *strbuf;
94     struct _basic_ostream_wchar *stream;
95     wchar_t fillch;
96 } basic_ios_wchar;
97
98 typedef struct _basic_ostream_char {
99     const int *vbtable;
100     /* virtual inheritance
101      * basic_ios_char basic_ios;
102      */
103 } basic_ostream_char;
104
105 typedef struct _basic_ostream_wchar {
106     const int *vbtable;
107     /* virtual inheritance
108      * basic_ios_wchar basic_ios;
109      */
110 } basic_ostream_wchar;
111
112 typedef struct {
113     const int *vbtable;
114     streamsize count;
115     /* virtual inheritance
116      * basic_ios_char basic_ios;
117      */
118 } basic_istream_char;
119
120 typedef struct {
121     const int *vbtable;
122     streamsize count;
123     /* virtual inheritance
124      * basic_ios_wchar basic_ios;
125      */
126 } basic_istream_wchar;
127
128 typedef struct {
129     basic_istream_char base1;
130     basic_ostream_char base2;
131     /* virtual inheritance
132      * basic_ios_char basic_ios;
133      */
134 } basic_iostream_char;
135
136 typedef struct {
137     basic_istream_wchar base1;
138     basic_ostream_wchar base2;
139     /* virtual inheritance
140      * basic_ios_wchar basic_ios;
141      */
142 } basic_iostream_wchar;
143
144 extern const vtable_ptr MSVCP_iosb_vtable;
145
146 /* ??_7ios_base@std@@6B@ */
147 extern const vtable_ptr MSVCP_ios_base_vtable;
148
149 /* ??_7?$basic_ios@DU?$char_traits@D@std@@@std@@6B@ */
150 extern const vtable_ptr MSVCP_basic_ios_char_vtable;
151
152 /* ??_7?$basic_ios@_WU?$char_traits@_W@std@@@std@@6B@ */
153 extern const vtable_ptr MSVCP_basic_ios_wchar_vtable;
154
155 /* ??_7?$basic_ios@GU?$char_traits@G@std@@@std@@6B@ */
156 extern const vtable_ptr MSVCP_basic_ios_short_vtable;
157
158 /* ??_7?$basic_streambuf@DU?$char_traits@D@std@@@std@@6B@ */
159 extern const vtable_ptr MSVCP_basic_streambuf_char_vtable;
160
161 /* ??_7?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@6B@ */
162 extern const vtable_ptr MSVCP_basic_streambuf_wchar_vtable;
163
164 /* ??_7?$basic_streambuf@GU?$char_traits@G@std@@@std@@6B@ */
165 extern const vtable_ptr MSVCP_basic_streambuf_short_vtable;
166
167 /* ??_7?$basic_filebuf@DU?$char_traits@D@std@@@std@@6B@ */
168 extern const vtable_ptr MSVCP_basic_filebuf_char_vtable;
169
170 /* ??_7?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@6B@ */
171 extern const vtable_ptr MSVCP_basic_filebuf_wchar_vtable;
172
173 /* ??_7?$basic_filebuf@GU?$char_traits@G@std@@@std@@6B@ */
174 extern const vtable_ptr MSVCP_basic_filebuf_short_vtable;
175
176 /* ??_8?$basic_ostream@DU?$char_traits@D@std@@@std@@7B@ */
177 const int basic_ostream_char_vbtable[] = {0, ALIGNED_SIZE(sizeof(basic_ostream_char), 8)};
178 /* ??_7?$basic_ostream@DU?$char_traits@D@std@@@std@@6B@ */
179 extern const vtable_ptr MSVCP_basic_ostream_char_vtable;
180
181 /* ??_8?$basic_ostream@_WU?$char_traits@_W@std@@@std@@7B@ */
182 const int basic_ostream_wchar_vbtable[] = {0, ALIGNED_SIZE(sizeof(basic_ostream_wchar), 8)};
183 /* ??_7?$basic_ostream@_WU?$char_traits@_W@std@@@std@@6B@ */
184 extern const vtable_ptr MSVCP_basic_ostream_wchar_vtable;
185
186 /* ??_8?$basic_ostream@GU?$char_traits@G@std@@@std@@7B@ */
187 const int basic_ostream_short_vbtable[] = {0, ALIGNED_SIZE(sizeof(basic_ostream_wchar), 8)};
188 /* ??_7?$basic_ostream@GU?$char_traits@G@std@@@std@@6B@ */
189 extern const vtable_ptr MSVCP_basic_ostream_short_vtable;
190
191 /* ??_8?$basic_istream@DU?$char_traits@D@std@@@std@@7B@ */
192 const int basic_istream_char_vbtable[] = {0, ALIGNED_SIZE(sizeof(basic_istream_char), 8)};
193 /* ??_7?$basic_istream@DU?$char_traits@D@std@@@std@@6B@ */
194 extern const vtable_ptr MSVCP_basic_istream_char_vtable;
195
196 /* ??_8?$basic_istream@_WU?$char_traits@_W@std@@@std@@7B@ */
197 const int basic_istream_wchar_vbtable[] = {0, ALIGNED_SIZE(sizeof(basic_istream_wchar), 8)};
198 /* ??_7?$basic_istream@_WU?$char_traits@_W@std@@@std@@6B@ */
199 extern const vtable_ptr MSVCP_basic_istream_wchar_vtable;
200
201 /* ??_8?$basic_istream@GU?$char_traits@G@std@@@std@@7B@ */
202 const int basic_istream_short_vbtable[] = {0, ALIGNED_SIZE(sizeof(basic_istream_wchar), 8)};
203 /* ??_7?$basic_istream@GU?$char_traits@G@std@@@std@@6B@ */
204 extern const vtable_ptr MSVCP_basic_istream_short_vtable;
205
206 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_istream@DU?$char_traits@D@std@@@1@@ */
207 const int basic_iostream_char_vbtable1[] = {0, ALIGNED_SIZE(sizeof(basic_iostream_char), 8)};
208 /* ??_8?$basic_iostream@DU?$char_traits@D@std@@@std@@7B?$basic_ostream@DU?$char_traits@D@std@@@1@@ */
209 const int basic_iostream_char_vbtable2[] = {0, ALIGNED_SIZE(sizeof(basic_iostream_char), 8)-FIELD_OFFSET(basic_iostream_char, base2)};
210 /* ??_7?$basic_iostream@DU?$char_traits@D@std@@@std@@6B@ */
211 extern const vtable_ptr MSVCP_basic_iostream_char_vtable;
212
213 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_istream@_WU?$char_traits@_W@std@@@1@@ */
214 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_istream@GU?$char_traits@G@std@@@1@@ */
215 const int basic_iostream_wchar_vbtable1[] = {0, ALIGNED_SIZE(sizeof(basic_iostream_wchar), 8)};
216 /* ??_8?$basic_iostream@_WU?$char_traits@_W@std@@@std@@7B?$basic_ostream@_WU?$char_traits@_W@std@@@1@@ */
217 /* ??_8?$basic_iostream@GU?$char_traits@G@std@@@std@@7B?$basic_ostream@GU?$char_traits@G@std@@@1@@ */
218 const int basic_iostream_wchar_vbtable2[] = {0, ALIGNED_SIZE(sizeof(basic_iostream_wchar), 8)-FIELD_OFFSET(basic_iostream_wchar, base2)};
219 /* ??_7?$basic_iostream@_WU?$char_traits@_W@std@@@std@@6B@ */
220 extern const vtable_ptr MSVCP_basic_iostream_wchar_vtable;
221 /* ??_7?$basic_iostream@GU?$char_traits@G@std@@@std@@6B@ */
222 extern const vtable_ptr MSVCP_basic_iostream_short_vtable;
223
224 DEFINE_RTTI_DATA0(iosb, 0, ".?AV?$_Iosb@H@std@@")
225 DEFINE_RTTI_DATA1(ios_base, 0, &iosb_rtti_base_descriptor, ".?AV?$_Iosb@H@std@@")
226 DEFINE_RTTI_DATA2(basic_ios_char, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
227         ".?AV?$basic_ios@DU?$char_traits@D@std@@@std@@")
228 DEFINE_RTTI_DATA2(basic_ios_wchar, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
229         ".?AV?$basic_ios@_WU?$char_traits@_W@std@@@std@@")
230 DEFINE_RTTI_DATA2(basic_ios_short, 0, &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
231         ".?AV?$basic_ios@GU?$char_traits@G@std@@@std@@")
232 DEFINE_RTTI_DATA0(basic_streambuf_char, 0,
233         ".?AV?$basic_streambuf@DU?$char_traits@D@std@@@std@@")
234 DEFINE_RTTI_DATA0(basic_streambuf_wchar, 0,
235         ".?AV?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@")
236 DEFINE_RTTI_DATA0(basic_streambuf_short, 0,
237         ".?AV?$basic_streambuf@GU?$char_traits@G@std@@@std@@")
238 DEFINE_RTTI_DATA1(basic_filebuf_char, 0, &basic_streambuf_char_rtti_base_descriptor,
239         ".?AV?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@")
240 DEFINE_RTTI_DATA1(basic_filebuf_wchar, 0, &basic_streambuf_wchar_rtti_base_descriptor,
241         ".?AV?$basic_filebuf@GU?$char_traits@G@std@@@std@@")
242 DEFINE_RTTI_DATA1(basic_filebuf_short, 0, &basic_streambuf_short_rtti_base_descriptor,
243         ".?AV?$basic_filebuf@DU?$char_traits@D@std@@@std@@")
244 DEFINE_RTTI_DATA3(basic_ostream_char, sizeof(basic_ostream_char), &basic_ios_char_rtti_base_descriptor,
245         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
246         ".?AV?$basic_ostream@DU?$char_traits@D@std@@@std@@")
247 DEFINE_RTTI_DATA3(basic_ostream_wchar, sizeof(basic_ostream_wchar), &basic_ios_wchar_rtti_base_descriptor,
248         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
249         ".?AV?$basic_ostream@_WU?$char_traits@_W@std@@@std@@")
250 DEFINE_RTTI_DATA3(basic_ostream_short, sizeof(basic_ostream_wchar), &basic_ios_short_rtti_base_descriptor,
251         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
252         ".?AV?$basic_ostream@GU?$char_traits@G@std@@@std@@")
253 DEFINE_RTTI_DATA3(basic_istream_char, sizeof(basic_istream_char), &basic_ios_char_rtti_base_descriptor,
254         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
255         ".?AV?$basic_istream@DU?$char_traits@D@std@@@std@@")
256 DEFINE_RTTI_DATA3(basic_istream_wchar, sizeof(basic_istream_wchar), &basic_ios_wchar_rtti_base_descriptor,
257         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
258         ".?AV?$basic_istream@_WU?$char_traits@_W@std@@@std@@")
259 DEFINE_RTTI_DATA3(basic_istream_short, sizeof(basic_istream_wchar), &basic_ios_short_rtti_base_descriptor,
260         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
261         ".?AV?$basic_istream@GU?$char_traits@G@std@@@std@@")
262 DEFINE_RTTI_DATA8(basic_iostream_char, sizeof(basic_iostream_char),
263         &basic_istream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
264         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
265         &basic_ostream_char_rtti_base_descriptor, &basic_ios_char_rtti_base_descriptor,
266         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
267         ".?AV?$basic_iostream@DU?$char_traits@D@std@@@std@@")
268 DEFINE_RTTI_DATA8(basic_iostream_wchar, sizeof(basic_iostream_wchar),
269         &basic_istream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
270         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
271         &basic_ostream_wchar_rtti_base_descriptor, &basic_ios_wchar_rtti_base_descriptor,
272         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
273         ".?AV?$basic_iostream@_WU?$char_traits@_W@std@@@std@@")
274 DEFINE_RTTI_DATA8(basic_iostream_short, sizeof(basic_iostream_wchar),
275         &basic_istream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
276         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
277         &basic_ostream_short_rtti_base_descriptor, &basic_ios_short_rtti_base_descriptor,
278         &ios_base_rtti_base_descriptor, &iosb_rtti_base_descriptor,
279         ".?AV?$basic_iostream@GU?$char_traits@G@std@@@std@@")
280
281 #ifndef __GNUC__
282 void __asm_dummy_vtables(void) {
283 #endif
284     __ASM_VTABLE(iosb,
285             VTABLE_ADD_FUNC(iosb_vector_dtor));
286     __ASM_VTABLE(ios_base,
287             VTABLE_ADD_FUNC(ios_base_vector_dtor));
288     __ASM_VTABLE(basic_ios_char,
289             VTABLE_ADD_FUNC(basic_ios_char_vector_dtor));
290     __ASM_VTABLE(basic_ios_wchar,
291             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
292     __ASM_VTABLE(basic_ios_short,
293             VTABLE_ADD_FUNC(basic_ios_wchar_vector_dtor));
294     __ASM_VTABLE(basic_streambuf_char,
295             VTABLE_ADD_FUNC(basic_streambuf_char_vector_dtor)
296             VTABLE_ADD_FUNC(basic_streambuf_char__Lock)
297             VTABLE_ADD_FUNC(basic_streambuf_char__Unlock)
298             VTABLE_ADD_FUNC(basic_streambuf_char_overflow)
299             VTABLE_ADD_FUNC(basic_streambuf_char_pbackfail)
300             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
301             VTABLE_ADD_FUNC(basic_streambuf_char_underflow)
302             VTABLE_ADD_FUNC(basic_streambuf_char_uflow)
303             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
304             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
305             VTABLE_ADD_FUNC(basic_streambuf_char_seekoff)
306             VTABLE_ADD_FUNC(basic_streambuf_char_seekpos)
307             VTABLE_ADD_FUNC(basic_streambuf_char_setbuf)
308             VTABLE_ADD_FUNC(basic_streambuf_char_sync)
309             VTABLE_ADD_FUNC(basic_streambuf_char_imbue));
310     __ASM_VTABLE(basic_streambuf_wchar,
311             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
312             VTABLE_ADD_FUNC(basic_streambuf_wchar__Lock)
313             VTABLE_ADD_FUNC(basic_streambuf_wchar__Unlock)
314             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
315             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
316             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
317             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
318             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
319             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
320             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
321             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
322             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
323             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
324             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
325             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
326     __ASM_VTABLE(basic_streambuf_short,
327             VTABLE_ADD_FUNC(basic_streambuf_wchar_vector_dtor)
328             VTABLE_ADD_FUNC(basic_streambuf_wchar__Lock)
329             VTABLE_ADD_FUNC(basic_streambuf_wchar__Unlock)
330             VTABLE_ADD_FUNC(basic_streambuf_wchar_overflow)
331             VTABLE_ADD_FUNC(basic_streambuf_wchar_pbackfail)
332             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
333             VTABLE_ADD_FUNC(basic_streambuf_wchar_underflow)
334             VTABLE_ADD_FUNC(basic_streambuf_wchar_uflow)
335             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
336             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
337             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekoff)
338             VTABLE_ADD_FUNC(basic_streambuf_wchar_seekpos)
339             VTABLE_ADD_FUNC(basic_streambuf_wchar_setbuf)
340             VTABLE_ADD_FUNC(basic_streambuf_wchar_sync)
341             VTABLE_ADD_FUNC(basic_streambuf_wchar_imbue));
342     __ASM_VTABLE(basic_filebuf_char,
343             VTABLE_ADD_FUNC(basic_filebuf_char_vector_dtor)
344             VTABLE_ADD_FUNC(basic_streambuf_char__Lock)
345             VTABLE_ADD_FUNC(basic_streambuf_char__Unlock)
346             VTABLE_ADD_FUNC(basic_filebuf_char_overflow)
347             VTABLE_ADD_FUNC(basic_filebuf_char_pbackfail)
348             VTABLE_ADD_FUNC(basic_streambuf_char_showmanyc)
349             VTABLE_ADD_FUNC(basic_filebuf_char_underflow)
350             VTABLE_ADD_FUNC(basic_filebuf_char_uflow)
351             VTABLE_ADD_FUNC(basic_streambuf_char_xsgetn)
352             VTABLE_ADD_FUNC(basic_streambuf_char_xsputn)
353             VTABLE_ADD_FUNC(basic_filebuf_char_seekoff)
354             VTABLE_ADD_FUNC(basic_filebuf_char_seekpos)
355             VTABLE_ADD_FUNC(basic_filebuf_char_setbuf)
356             VTABLE_ADD_FUNC(basic_filebuf_char_sync)
357             VTABLE_ADD_FUNC(basic_filebuf_char_imbue));
358     __ASM_VTABLE(basic_filebuf_wchar,
359             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
360             VTABLE_ADD_FUNC(basic_streambuf_wchar__Lock)
361             VTABLE_ADD_FUNC(basic_streambuf_wchar__Unlock)
362             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
363             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
364             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
365             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
366             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
367             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
368             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
369             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
370             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
371             VTABLE_ADD_FUNC(basic_filebuf_wchar_setbuf)
372             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
373             VTABLE_ADD_FUNC(basic_filebuf_wchar_imbue));
374     __ASM_VTABLE(basic_filebuf_short,
375             VTABLE_ADD_FUNC(basic_filebuf_wchar_vector_dtor)
376             VTABLE_ADD_FUNC(basic_streambuf_wchar__Lock)
377             VTABLE_ADD_FUNC(basic_streambuf_wchar__Unlock)
378             VTABLE_ADD_FUNC(basic_filebuf_wchar_overflow)
379             VTABLE_ADD_FUNC(basic_filebuf_wchar_pbackfail)
380             VTABLE_ADD_FUNC(basic_streambuf_wchar_showmanyc)
381             VTABLE_ADD_FUNC(basic_filebuf_wchar_underflow)
382             VTABLE_ADD_FUNC(basic_filebuf_wchar_uflow)
383             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsgetn)
384             VTABLE_ADD_FUNC(basic_streambuf_wchar_xsputn)
385             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekoff)
386             VTABLE_ADD_FUNC(basic_filebuf_wchar_seekpos)
387             VTABLE_ADD_FUNC(basic_filebuf_short_setbuf)
388             VTABLE_ADD_FUNC(basic_filebuf_wchar_sync)
389             VTABLE_ADD_FUNC(basic_filebuf_short_imbue));
390     __ASM_VTABLE(basic_ostream_char,
391             VTABLE_ADD_FUNC(basic_ostream_char_vector_dtor));
392     __ASM_VTABLE(basic_ostream_wchar,
393             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
394     __ASM_VTABLE(basic_ostream_short,
395             VTABLE_ADD_FUNC(basic_ostream_wchar_vector_dtor));
396     __ASM_VTABLE(basic_istream_char,
397             VTABLE_ADD_FUNC(basic_istream_char_vector_dtor));
398     __ASM_VTABLE(basic_istream_wchar,
399             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
400     __ASM_VTABLE(basic_istream_short,
401             VTABLE_ADD_FUNC(basic_istream_wchar_vector_dtor));
402     __ASM_VTABLE(basic_iostream_char,
403             VTABLE_ADD_FUNC(basic_iostream_char_vector_dtor));
404     __ASM_VTABLE(basic_iostream_wchar,
405             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
406     __ASM_VTABLE(basic_iostream_short,
407             VTABLE_ADD_FUNC(basic_iostream_wchar_vector_dtor));
408 #ifndef __GNUC__
409 }
410 #endif
411
412 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
413 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
414 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp_next, 16)
415 void __thiscall basic_streambuf_char_setp_next(basic_streambuf_char *this, char *first, char *next, char *last)
416 {
417     TRACE("(%p %p %p %p)\n", this, first, next, last);
418
419     this->wbuf = first;
420     this->wpos = next;
421     this->wsize = last-next;
422 }
423
424 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD0@Z */
425 /* ?setp@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD0@Z */
426 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setp, 12)
427 void __thiscall basic_streambuf_char_setp(basic_streambuf_char *this, char *first, char *last)
428 {
429     basic_streambuf_char_setp_next(this, first, first, last);
430 }
431
432 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAD00@Z */
433 /* ?setg@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAD00@Z */
434 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setg, 16)
435 void __thiscall basic_streambuf_char_setg(basic_streambuf_char *this, char *first, char *next, char *last)
436 {
437     TRACE("(%p %p %p %p)\n", this, first, next, last);
438
439     this->rbuf = first;
440     this->rpos = next;
441     this->rsize = last-next;
442 }
443
444 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXXZ */
445 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXXZ */
446 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init_empty, 4)
447 void __thiscall basic_streambuf_char__Init_empty(basic_streambuf_char *this)
448 {
449     TRACE("(%p)\n", this);
450
451     this->prbuf = &this->rbuf;
452     this->pwbuf = &this->wbuf;
453     this->prpos = &this->rpos;
454     this->pwpos = &this->wpos;
455     this->prsize = &this->rsize;
456     this->pwsize = &this->wsize;
457
458     basic_streambuf_char_setp(this, NULL, NULL);
459     basic_streambuf_char_setg(this, NULL, NULL, NULL);
460 }
461
462 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@W4_Uninitialized@1@@Z */
463 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
464 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor_uninitialized, 8)
465 basic_streambuf_char* __thiscall basic_streambuf_char_ctor_uninitialized(basic_streambuf_char *this, int uninitialized)
466 {
467     TRACE("(%p %d)\n", this, uninitialized);
468     this->vtable = &MSVCP_basic_streambuf_char_vtable;
469     mutex_ctor(&this->lock);
470     return this;
471 }
472
473 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAE@XZ */
474 /* ??0?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAA@XZ */
475 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_ctor, 4)
476 basic_streambuf_char* __thiscall basic_streambuf_char_ctor(basic_streambuf_char *this)
477 {
478     TRACE("(%p)\n", this);
479
480     this->vtable = &MSVCP_basic_streambuf_char_vtable;
481     mutex_ctor(&this->lock);
482     this->loc = MSVCRT_operator_new(sizeof(locale));
483     locale_ctor(this->loc);
484     basic_streambuf_char__Init_empty(this);
485
486     return this;
487 }
488
489 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
490 /* ??1?$basic_streambuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
491 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_dtor, 4)
492 void __thiscall basic_streambuf_char_dtor(basic_streambuf_char *this)
493 {
494     TRACE("(%p)\n", this);
495
496     mutex_dtor(&this->lock);
497     locale_dtor(this->loc);
498     MSVCRT_operator_delete(this->loc);
499 }
500
501 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_vector_dtor, 8)
502 basic_streambuf_char* __thiscall basic_streambuf_char_vector_dtor(basic_streambuf_char *this, unsigned int flags)
503 {
504     TRACE("(%p %x)\n", this, flags);
505     if(flags & 2) {
506         /* we have an array, with the number of elements stored before the first object */
507         INT_PTR i, *ptr = (INT_PTR *)this-1;
508
509         for(i=*ptr-1; i>=0; i--)
510             basic_streambuf_char_dtor(this+i);
511         MSVCRT_operator_delete(ptr);
512     } else {
513         basic_streambuf_char_dtor(this);
514         if(flags & 1)
515             MSVCRT_operator_delete(this);
516     }
517
518     return this;
519 }
520
521 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
522 /* ?_Gnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
523 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnavail, 4)
524 streamsize __thiscall basic_streambuf_char__Gnavail(const basic_streambuf_char *this)
525 {
526     TRACE("(%p)\n", this);
527     return *this->prpos ? *this->prsize : 0;
528 }
529
530 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
531 /* ?_Gndec@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
532 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gndec, 4)
533 char* __thiscall basic_streambuf_char__Gndec(basic_streambuf_char *this)
534 {
535     TRACE("(%p)\n", this);
536     (*this->prsize)++;
537     (*this->prpos)--;
538     return *this->prpos;
539 }
540
541 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
542 /* ?_Gninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
543 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gninc, 4)
544 char* __thiscall basic_streambuf_char__Gninc(basic_streambuf_char *this)
545 {
546     TRACE("(%p)\n", this);
547     (*this->prsize)--;
548     return (*this->prpos)++;
549 }
550
551 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
552 /* ?_Gnpreinc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
553 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Gnpreinc, 4)
554 char* __thiscall basic_streambuf_char__Gnpreinc(basic_streambuf_char *this)
555 {
556     TRACE("(%p)\n", this);
557     (*this->prsize)--;
558     (*this->prpos)++;
559     return *this->prpos;
560 }
561
562 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXPAPAD0PAH001@Z */
563 /* ?_Init@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXPEAPEAD0PEAH001@Z */
564 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Init, 28)
565 void __thiscall basic_streambuf_char__Init(basic_streambuf_char *this, char **gf, char **gn, int *gc, char **pf, char **pn, int *pc)
566 {
567     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
568
569     this->prbuf = gf;
570     this->pwbuf = pf;
571     this->prpos = gn;
572     this->pwpos = pn;
573     this->prsize = gc;
574     this->pwsize = pc;
575 }
576
577 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
578 /* ?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
579 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Lock, 4)
580 #define call_basic_streambuf_char__Lock(this) CALL_VTBL_FUNC(this, 4, \
581         void, (basic_streambuf_char*), (this))
582 void __thiscall basic_streambuf_char__Lock(basic_streambuf_char *this)
583 {
584     TRACE("(%p)\n", this);
585     mutex_lock(&this->lock);
586 }
587
588 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEHXZ */
589 /* ?_Pnavail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBA_JXZ */
590 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pnavail, 4)
591 streamsize __thiscall basic_streambuf_char__Pnavail(const basic_streambuf_char *this)
592 {
593     TRACE("(%p)\n", this);
594     return *this->pwpos ? *this->pwsize : 0;
595 }
596
597 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEPADXZ */
598 /* ?_Pninc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAPEADXZ */
599 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Pninc, 4)
600 char* __thiscall basic_streambuf_char__Pninc(basic_streambuf_char *this)
601 {
602     TRACE("(%p)\n", this);
603     (*this->pwsize)--;
604     return (*this->pwpos)++;
605 }
606
607 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
608 /* ?underflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
609 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_underflow, 4)
610 #define call_basic_streambuf_char_underflow(this) CALL_VTBL_FUNC(this, 24, \
611         int, (basic_streambuf_char*), (this))
612 int __thiscall basic_streambuf_char_underflow(basic_streambuf_char *this)
613 {
614     TRACE("(%p)\n", this);
615     return EOF;
616 }
617
618 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
619 /* ?uflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
620 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_uflow, 4)
621 #define call_basic_streambuf_char_uflow(this) CALL_VTBL_FUNC(this, 28, \
622         int, (basic_streambuf_char*), (this))
623 int __thiscall basic_streambuf_char_uflow(basic_streambuf_char *this)
624 {
625     int ret;
626
627     TRACE("(%p)\n", this);
628
629     if(call_basic_streambuf_char_underflow(this)==EOF)
630         return EOF;
631
632     ret = (unsigned char)**this->prpos;
633     (*this->prsize)--;
634     (*this->prpos)++;
635     return ret;
636 }
637
638 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADIH@Z */
639 /* ?_Xsgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_K_J@Z */
640 static streamsize basic_streambuf_char__Xsgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
641 {
642     streamsize copied, chunk;
643     int c;
644
645     TRACE("(%p %p %lu %s)\n", this, ptr, size, wine_dbgstr_longlong(count));
646
647     for(copied=0; copied<count && size;) {
648         chunk = basic_streambuf_char__Gnavail(this);
649         if(chunk > count-copied)
650             chunk = count-copied;
651
652         if(chunk > 0) {
653             memcpy_s(ptr+copied, size, *this->prpos, chunk);
654             *this->prpos += chunk;
655             *this->prsize -= chunk;
656             copied += chunk;
657             size -= chunk;
658         }else if((c = call_basic_streambuf_char_uflow(this)) != EOF) {
659             ptr[copied] = c;
660             copied++;
661             size--;
662         }else {
663             break;
664         }
665     }
666
667     return copied;
668 }
669
670 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
671 /* ?_Sgetn_s@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
672 static streamsize basic_streambuf_char__Sgetn_s(basic_streambuf_char *this, char *ptr, MSVCP_size_t size, streamsize count)
673 {
674     TRACE("(%p %p %lu %s)\n", this, ptr, size, wine_dbgstr_longlong(count));
675     return basic_streambuf_char__Xsgetn_s(this, ptr, size, count);
676 }
677
678 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
679 /* ?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
680 DEFINE_THISCALL_WRAPPER(basic_streambuf_char__Unlock, 4)
681 #define call_basic_streambuf_char__Unlock(this) CALL_VTBL_FUNC(this, 8, \
682         void, (basic_streambuf_char*), (this))
683 void __thiscall basic_streambuf_char__Unlock(basic_streambuf_char *this)
684 {
685     TRACE("(%p)\n", this);
686     mutex_unlock(&this->lock);
687 }
688
689 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
690 /* ?eback@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
691 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_eback, 4)
692 char* __thiscall basic_streambuf_char_eback(const basic_streambuf_char *this)
693 {
694     TRACE("(%p)\n", this);
695     return *this->prbuf;
696 }
697
698 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
699 /* ?gptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
700 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gptr, 4)
701 char* __thiscall basic_streambuf_char_gptr(const basic_streambuf_char *this)
702 {
703     TRACE("(%p)\n", this);
704     return *this->prpos;
705 }
706
707 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
708 /* ?egptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
709 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_egptr, 4)
710 char* __thiscall basic_streambuf_char_egptr(const basic_streambuf_char *this)
711 {
712     TRACE("(%p)\n", this);
713     return *this->prpos+*this->prsize;
714 }
715
716 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
717 /* ?epptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
718 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_epptr, 4)
719 char* __thiscall basic_streambuf_char_epptr(const basic_streambuf_char *this)
720 {
721     TRACE("(%p)\n", this);
722     return *this->pwpos+*this->pwsize;
723 }
724
725 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
726 /* ?gbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
727 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_gbump, 8)
728 void __thiscall basic_streambuf_char_gbump(basic_streambuf_char *this, int off)
729 {
730     TRACE("(%p %d)\n", this, off);
731     *this->prpos += off;
732     *this->prsize -= off;
733 }
734
735 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QBE?AVlocale@2@XZ */
736 /* ?getloc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEBA?AVlocale@2@XZ */
737 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_getloc, 8)
738 locale* __thiscall basic_streambuf_char_getloc(const basic_streambuf_char *this, locale *ret)
739 {
740     TRACE("(%p)\n", this);
741     return locale_copy_ctor(ret, this->loc);
742 }
743
744 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
745 /* ?imbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
746 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_imbue, 8)
747 #define call_basic_streambuf_char_imbue(this, loc) CALL_VTBL_FUNC(this, 56, \
748         void, (basic_streambuf_char*, const locale*), (this, loc))
749 void __thiscall basic_streambuf_char_imbue(basic_streambuf_char *this, const locale *loc)
750 {
751     TRACE("(%p %p)\n", this, loc);
752 }
753
754 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
755 /* ?overflow@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
756 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_overflow, 8)
757 #define call_basic_streambuf_char_overflow(this, ch) CALL_VTBL_FUNC(this, 12, \
758         int, (basic_streambuf_char*, int), (this, ch))
759 int __thiscall basic_streambuf_char_overflow(basic_streambuf_char *this, int ch)
760 {
761     TRACE("(%p %d)\n", this, ch);
762     return EOF;
763 }
764
765 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
766 /* ?pbackfail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
767 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbackfail, 8)
768 #define call_basic_streambuf_char_pbackfail(this, ch) CALL_VTBL_FUNC(this, 16, \
769         int, (basic_streambuf_char*, int), (this, ch))
770 int __thiscall basic_streambuf_char_pbackfail(basic_streambuf_char *this, int ch)
771 {
772     TRACE("(%p %d)\n", this, ch);
773     return EOF;
774 }
775
776 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
777 /* ?pbase@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
778 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbase, 4)
779 char* __thiscall basic_streambuf_char_pbase(const basic_streambuf_char *this)
780 {
781     TRACE("(%p)\n", this);
782     return *this->pwbuf;
783 }
784
785 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IAEXH@Z */
786 /* ?pbump@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEAAXH@Z */
787 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pbump, 8)
788 void __thiscall basic_streambuf_char_pbump(basic_streambuf_char *this, int off)
789 {
790     TRACE("(%p %d)\n", this, off);
791     *this->pwpos += off;
792     *this->pwsize -= off;
793 }
794
795 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IBEPADXZ */
796 /* ?pptr@?$basic_streambuf@DU?$char_traits@D@std@@@std@@IEBAPEADXZ */
797 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pptr, 4)
798 char* __thiscall basic_streambuf_char_pptr(const basic_streambuf_char *this)
799 {
800     TRACE("(%p)\n", this);
801     return *this->pwpos;
802 }
803
804 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
805 /* ?pubimbue@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
806 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubimbue, 12)
807 locale* __thiscall basic_streambuf_char_pubimbue(basic_streambuf_char *this, locale *ret, const locale *loc)
808 {
809     TRACE("(%p %p)\n", this, loc);
810     memcpy(ret, this->loc, sizeof(locale));
811     call_basic_streambuf_char_imbue(this, loc);
812     locale_copy_ctor(this->loc, loc);
813     return ret;
814 }
815
816 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
817 /* ?seekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
818 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekoff, 24)
819 #define call_basic_streambuf_char_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 40, \
820         fpos_int*, (basic_streambuf_char*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
821 fpos_int* __thiscall basic_streambuf_char_seekoff(basic_streambuf_char *this,
822         fpos_int *ret, streamoff off, int way, int mode)
823 {
824     TRACE("(%p %s %d %d)\n", this, wine_dbgstr_longlong(off), way, mode);
825     ret->off = -1;
826     ret->pos = 0;
827     ret->state = 0;
828     return ret;
829 }
830
831 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
832 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
833 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff, 24)
834 fpos_int* __thiscall basic_streambuf_char_pubseekoff(basic_streambuf_char *this,
835         fpos_int *ret, streamoff off, int way, int mode)
836 {
837     TRACE("(%p %s %d %d)\n", this, wine_dbgstr_longlong(off), way, mode);
838     return call_basic_streambuf_char_seekoff(this, ret, off, way, mode);
839 }
840
841 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
842 /* ?pubseekoff@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
843 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekoff_old, 24)
844 fpos_int* __thiscall basic_streambuf_char_pubseekoff_old(basic_streambuf_char *this,
845         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
846 {
847     TRACE("(%p %s %d %d)\n", this, wine_dbgstr_longlong(off), way, mode);
848     return basic_streambuf_char_pubseekoff(this, ret, off, way, mode);
849 }
850
851 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
852 /* ?seekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
853 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_seekpos, 36)
854 #define call_basic_streambuf_char_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 44, \
855         fpos_int*, (basic_streambuf_char*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
856 fpos_int* __thiscall basic_streambuf_char_seekpos(basic_streambuf_char *this,
857         fpos_int *ret, fpos_int pos, int mode)
858 {
859     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
860     ret->off = -1;
861     ret->pos = 0;
862     ret->state = 0;
863     return ret;
864 }
865
866 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
867 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
868 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos, 36)
869 fpos_int* __thiscall basic_streambuf_char_pubseekpos(basic_streambuf_char *this,
870         fpos_int *ret, fpos_int pos, int mode)
871 {
872     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
873     return call_basic_streambuf_char_seekpos(this, ret, pos, mode);
874 }
875
876 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
877 /* ?pubseekpos@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
878 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubseekpos_old, 36)
879 fpos_int* __thiscall basic_streambuf_char_pubseekpos_old(basic_streambuf_char *this,
880         fpos_int *ret, fpos_int pos, unsigned int mode)
881 {
882     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
883     return basic_streambuf_char_pubseekpos(this, ret, pos, mode);
884 }
885
886 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEPAV12@PADH@Z */
887 /* ?setbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAPEAV12@PEAD_J@Z */
888 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_setbuf, 16)
889 #define call_basic_streambuf_char_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 48, \
890         basic_streambuf_char*, (basic_streambuf_char*, char*, streamsize), (this, buf, count))
891 basic_streambuf_char* __thiscall basic_streambuf_char_setbuf(basic_streambuf_char *this, char *buf, streamsize count)
892 {
893     TRACE("(%p %p %s)\n", this, buf, wine_dbgstr_longlong(count));
894     return this;
895 }
896
897 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEPAV12@PADH@Z */
898 /* ?pubsetbuf@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@PEAD_J@Z */
899 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsetbuf, 16)
900 basic_streambuf_char* __thiscall basic_streambuf_char_pubsetbuf(basic_streambuf_char *this, char *buf, streamsize count)
901 {
902     TRACE("(%p %p %s)\n", this, buf, wine_dbgstr_longlong(count));
903     return call_basic_streambuf_char_setbuf(this, buf, count);
904 }
905
906 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
907 /* ?sync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
908 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sync, 4)
909 #define call_basic_streambuf_char_sync(this) CALL_VTBL_FUNC(this, 52, \
910         int, (basic_streambuf_char*), (this))
911 int __thiscall basic_streambuf_char_sync(basic_streambuf_char *this)
912 {
913     TRACE("(%p)\n", this);
914     return 0;
915 }
916
917 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
918 /* ?pubsync@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
919 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_pubsync, 4)
920 int __thiscall basic_streambuf_char_pubsync(basic_streambuf_char *this)
921 {
922     TRACE("(%p)\n", this);
923     return call_basic_streambuf_char_sync(this);
924 }
925
926 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
927 /* ?sgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
928 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetn, 16)
929 streamsize __thiscall basic_streambuf_char_sgetn(basic_streambuf_char *this, char *ptr, streamsize count)
930 {
931     TRACE("(%p %p %s)\n", this, ptr, wine_dbgstr_longlong(count));
932     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
933 }
934
935 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
936 /* ?showmanyc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JXZ */
937 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_showmanyc, 4)
938 #define call_basic_streambuf_char_showmanyc(this) CALL_VTBL_FUNC(this, 20, \
939         streamsize, (basic_streambuf_char*), (this))
940 streamsize __thiscall basic_streambuf_char_showmanyc(basic_streambuf_char *this)
941 {
942     TRACE("(%p)\n", this);
943     return 0;
944 }
945
946 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
947 /* ?in_avail@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JXZ */
948 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_in_avail, 4)
949 streamsize __thiscall basic_streambuf_char_in_avail(basic_streambuf_char *this)
950 {
951     streamsize ret;
952
953     TRACE("(%p)\n", this);
954
955     ret = basic_streambuf_char__Gnavail(this);
956     return ret ? ret : call_basic_streambuf_char_showmanyc(this);
957 }
958
959 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
960 /* ?sputbackc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
961 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputbackc, 8)
962 int __thiscall basic_streambuf_char_sputbackc(basic_streambuf_char *this, char ch)
963 {
964     TRACE("(%p %d)\n", this, ch);
965     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
966         (*this->prsize)++;
967         (*this->prpos)--;
968         return (unsigned char)ch;
969     }
970
971     return call_basic_streambuf_char_pbackfail(this, (unsigned char)ch);
972 }
973
974 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z */
975 /* ?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHD@Z */
976 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputc, 8)
977 int __thiscall basic_streambuf_char_sputc(basic_streambuf_char *this, char ch)
978 {
979     TRACE("(%p %d)\n", this, ch);
980     return basic_streambuf_char__Pnavail(this) ?
981         (*basic_streambuf_char__Pninc(this) = ch) :
982         call_basic_streambuf_char_overflow(this, (unsigned char)ch);
983 }
984
985 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
986 /* ?sungetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
987 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sungetc, 4)
988 int __thiscall basic_streambuf_char_sungetc(basic_streambuf_char *this)
989 {
990     TRACE("(%p)\n", this);
991     if(*this->prpos && *this->prpos>*this->prbuf) {
992         (*this->prsize)++;
993         (*this->prpos)--;
994         return (unsigned char)**this->prpos;
995     }
996
997     return call_basic_streambuf_char_pbackfail(this, EOF);
998 }
999
1000 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ */
1001 /* ?stossc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAXXZ */
1002 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_stossc, 4)
1003 void __thiscall basic_streambuf_char_stossc(basic_streambuf_char *this)
1004 {
1005     TRACE("(%p)\n", this);
1006     if(basic_streambuf_char__Gnavail(this))
1007         basic_streambuf_char__Gninc(this);
1008     else
1009         call_basic_streambuf_char_uflow(this);
1010 }
1011
1012 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1013 /* ?sbumpc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1014 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sbumpc, 4)
1015 int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char *this)
1016 {
1017     TRACE("(%p)\n", this);
1018     return basic_streambuf_char__Gnavail(this) ?
1019         (int)(unsigned char)*basic_streambuf_char__Gninc(this) : call_basic_streambuf_char_uflow(this);
1020 }
1021
1022 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1023 /* ?sgetc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1024 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sgetc, 4)
1025 int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char *this)
1026 {
1027     TRACE("(%p)\n", this);
1028     return basic_streambuf_char__Gnavail(this) ?
1029         (int)(unsigned char)*basic_streambuf_char_gptr(this) : call_basic_streambuf_char_underflow(this);
1030 }
1031
1032 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHXZ */
1033 /* ?snextc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAAHXZ */
1034 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_snextc, 4)
1035 int __thiscall basic_streambuf_char_snextc(basic_streambuf_char *this)
1036 {
1037     TRACE("(%p)\n", this);
1038
1039     if(basic_streambuf_char__Gnavail(this) > 1)
1040         return (unsigned char)*basic_streambuf_char__Gnpreinc(this);
1041     return basic_streambuf_char_sbumpc(this)==EOF ?
1042         EOF : basic_streambuf_char_sgetc(this);
1043 }
1044
1045 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPADH@Z */
1046 /* ?xsgetn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEAD_J@Z */
1047 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsgetn, 16)
1048 #define call_basic_streambuf_char_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
1049         streamsize, (basic_streambuf_char*, char*, streamsize), (this, ptr, count))
1050 streamsize __thiscall basic_streambuf_char_xsgetn(basic_streambuf_char *this, char *ptr, streamsize count)
1051 {
1052     TRACE("(%p %p %s)\n", this, ptr, wine_dbgstr_longlong(count));
1053     return basic_streambuf_char__Xsgetn_s(this, ptr, -1, count);
1054 }
1055
1056 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MAEHPBDH@Z */
1057 /* ?xsputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@MEAA_JPEBD_J@Z */
1058 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_xsputn, 16)
1059 #define call_basic_streambuf_char_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 36, \
1060         streamsize, (basic_streambuf_char*, const char*, streamsize), (this, ptr, count))
1061 streamsize __thiscall basic_streambuf_char_xsputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1062 {
1063     streamsize copied, chunk;
1064
1065     TRACE("(%p %p %s)\n", this, ptr, wine_dbgstr_longlong(count));
1066
1067     for(copied=0; copied<count;) {
1068         chunk = basic_streambuf_char__Pnavail(this);
1069         if(chunk > count-copied)
1070             chunk = count-copied;
1071
1072         if(chunk > 0) {
1073             memcpy(*this->pwpos, ptr+copied, chunk);
1074             *this->pwpos += chunk;
1075             *this->pwsize -= chunk;
1076             copied += chunk;
1077         }else if(call_basic_streambuf_char_overflow(this, (unsigned char)ptr[copied]) != EOF) {
1078             copied++;
1079         }else {
1080             break;
1081         }
1082     }
1083
1084     return copied;
1085 }
1086
1087 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z */
1088 /* ?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QEAA_JPEBD_J@Z */
1089 DEFINE_THISCALL_WRAPPER(basic_streambuf_char_sputn, 16)
1090 streamsize __thiscall basic_streambuf_char_sputn(basic_streambuf_char *this, const char *ptr, streamsize count)
1091 {
1092     TRACE("(%p %p %s)\n", this, ptr, wine_dbgstr_longlong(count));
1093     return call_basic_streambuf_char_xsputn(this, ptr, count);
1094 }
1095
1096 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1097 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1098 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1099 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1100 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp_next, 16)
1101 void __thiscall basic_streambuf_wchar_setp_next(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1102 {
1103     TRACE("(%p %p %p %p)\n", this, first, next, last);
1104
1105     this->wbuf = first;
1106     this->wpos = next;
1107     this->wsize = last-next;
1108 }
1109
1110 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W0@Z */
1111 /* ?setp@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W0@Z */
1112 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG0@Z */
1113 /* ?setp@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG0@Z */
1114 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setp, 12)
1115 void __thiscall basic_streambuf_wchar_setp(basic_streambuf_wchar *this, wchar_t *first, wchar_t *last)
1116 {
1117     basic_streambuf_wchar_setp_next(this, first, first, last);
1118 }
1119
1120 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPA_W00@Z */
1121 /* ?setg@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEA_W00@Z */
1122 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAG00@Z */
1123 /* ?setg@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAG00@Z */
1124 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setg, 16)
1125 void __thiscall basic_streambuf_wchar_setg(basic_streambuf_wchar *this, wchar_t *first, wchar_t *next, wchar_t *last)
1126 {
1127     TRACE("(%p %p %p %p)\n", this, first, next, last);
1128
1129     this->rbuf = first;
1130     this->rpos = next;
1131     this->rsize = last-next;
1132 }
1133
1134 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXXZ */
1135 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXXZ */
1136 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXXZ */
1137 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXXZ */
1138 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init_empty, 4)
1139 void __thiscall basic_streambuf_wchar__Init_empty(basic_streambuf_wchar *this)
1140 {
1141     TRACE("(%p)\n", this);
1142
1143     this->prbuf = &this->rbuf;
1144     this->pwbuf = &this->wbuf;
1145     this->prpos = &this->rpos;
1146     this->pwpos = &this->wpos;
1147     this->prsize = &this->rsize;
1148     this->pwsize = &this->wsize;
1149
1150     basic_streambuf_wchar_setp(this, NULL, NULL);
1151     basic_streambuf_wchar_setg(this, NULL, NULL, NULL);
1152 }
1153
1154 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1155 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1156 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor_uninitialized, 8)
1157 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1158 {
1159     TRACE("(%p %d)\n", this, uninitialized);
1160     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1161     mutex_ctor(&this->lock);
1162     return this;
1163 }
1164
1165 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@W4_Uninitialized@1@@Z */
1166 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@W4_Uninitialized@1@@Z */
1167 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor_uninitialized, 8)
1168 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor_uninitialized(basic_streambuf_wchar *this, int uninitialized)
1169 {
1170     TRACE("(%p %d)\n", this, uninitialized);
1171     basic_streambuf_wchar_ctor_uninitialized(this, uninitialized);
1172     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1173     return this;
1174 }
1175
1176 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
1177 /* ??0?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
1178 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_ctor, 4)
1179 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_ctor(basic_streambuf_wchar *this)
1180 {
1181     TRACE("(%p)\n", this);
1182
1183     this->vtable = &MSVCP_basic_streambuf_wchar_vtable;
1184     mutex_ctor(&this->lock);
1185     this->loc = MSVCRT_operator_new(sizeof(locale));
1186     locale_ctor(this->loc);
1187     basic_streambuf_wchar__Init_empty(this);
1188
1189     return this;
1190 }
1191
1192 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAE@XZ */
1193 /* ??0?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAA@XZ */
1194 DEFINE_THISCALL_WRAPPER(basic_streambuf_short_ctor, 4)
1195 basic_streambuf_wchar* __thiscall basic_streambuf_short_ctor(basic_streambuf_wchar *this)
1196 {
1197     TRACE("(%p)\n", this);
1198     basic_streambuf_wchar_ctor(this);
1199     this->vtable = &MSVCP_basic_streambuf_short_vtable;
1200     return this;
1201 }
1202
1203 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
1204 /* ??1?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
1205 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
1206 /* ??1?$basic_streambuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
1207 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_dtor, 4)
1208 void __thiscall basic_streambuf_wchar_dtor(basic_streambuf_wchar *this)
1209 {
1210     TRACE("(%p)\n", this);
1211
1212     mutex_dtor(&this->lock);
1213     locale_dtor(this->loc);
1214     MSVCRT_operator_delete(this->loc);
1215 }
1216
1217 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_vector_dtor, 8)
1218 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_vector_dtor(basic_streambuf_wchar *this, unsigned int flags)
1219 {
1220     TRACE("(%p %x)\n", this, flags);
1221     if(flags & 2) {
1222         /* we have an array, with the number of elements stored before the first object */
1223         INT_PTR i, *ptr = (INT_PTR *)this-1;
1224
1225         for(i=*ptr-1; i>=0; i--)
1226             basic_streambuf_wchar_dtor(this+i);
1227         MSVCRT_operator_delete(ptr);
1228     } else {
1229         basic_streambuf_wchar_dtor(this);
1230         if(flags & 1)
1231             MSVCRT_operator_delete(this);
1232     }
1233
1234     return this;
1235 }
1236
1237 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1238 /* ?_Gnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1239 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1240 /* ?_Gnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1241 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnavail, 4)
1242 streamsize __thiscall basic_streambuf_wchar__Gnavail(const basic_streambuf_wchar *this)
1243 {
1244     TRACE("(%p)\n", this);
1245     return *this->prpos ? *this->prsize : 0;
1246 }
1247
1248 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1249 /* ?_Gndec@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1250 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1251 /* ?_Gndec@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1252 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gndec, 4)
1253 wchar_t* __thiscall basic_streambuf_wchar__Gndec(basic_streambuf_wchar *this)
1254 {
1255     TRACE("(%p)\n", this);
1256     (*this->prsize)++;
1257     (*this->prpos)--;
1258     return *this->prpos;
1259 }
1260
1261 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1262 /* ?_Gninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1263 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1264 /* ?_Gninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1265 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gninc, 4)
1266 wchar_t* __thiscall basic_streambuf_wchar__Gninc(basic_streambuf_wchar *this)
1267 {
1268     TRACE("(%p)\n", this);
1269     (*this->prsize)--;
1270     return (*this->prpos)++;
1271 }
1272
1273 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1274 /* ?_Gnpreinc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1275 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1276 /* ?_Gnpreinc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1277 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Gnpreinc, 4)
1278 wchar_t* __thiscall basic_streambuf_wchar__Gnpreinc(basic_streambuf_wchar *this)
1279 {
1280     TRACE("(%p)\n", this);
1281     (*this->prsize)--;
1282     (*this->prpos)++;
1283     return *this->prpos;
1284 }
1285
1286 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXPAPA_W0PAH001@Z */
1287 /* ?_Init@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAPEA_W0PEAH001@Z */
1288 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXPAPAG0PAH001@Z */
1289 /* ?_Init@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXPEAPEAG0PEAH001@Z */
1290 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Init, 28)
1291 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)
1292 {
1293     TRACE("(%p %p %p %p %p %p %p)\n", this, gf, gn, gc, pf, pn, pc);
1294
1295     this->prbuf = gf;
1296     this->pwbuf = pf;
1297     this->prpos = gn;
1298     this->pwpos = pn;
1299     this->prsize = gc;
1300     this->pwsize = pc;
1301 }
1302
1303 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1304 /* ?_Lock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1305 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1306 /* ?_Lock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1307 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Lock, 4)
1308 void __thiscall basic_streambuf_wchar__Lock(basic_streambuf_wchar *this)
1309 {
1310     TRACE("(%p)\n", this);
1311     mutex_lock(&this->lock);
1312 }
1313
1314 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEHXZ */
1315 /* ?_Pnavail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBA_JXZ */
1316 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEHXZ */
1317 /* ?_Pnavail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBA_JXZ */
1318 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pnavail, 4)
1319 streamsize __thiscall basic_streambuf_wchar__Pnavail(const basic_streambuf_wchar *this)
1320 {
1321     TRACE("(%p)\n", this);
1322     return *this->pwpos ? *this->pwsize : 0;
1323 }
1324
1325 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEPA_WXZ */
1326 /* ?_Pninc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAPEA_WXZ */
1327 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEPAGXZ */
1328 /* ?_Pninc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAPEAGXZ */
1329 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Pninc, 4)
1330 wchar_t* __thiscall basic_streambuf_wchar__Pninc(basic_streambuf_wchar *this)
1331 {
1332     TRACE("(%p)\n", this);
1333     (*this->pwsize)--;
1334     return (*this->pwpos)++;
1335 }
1336
1337 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1338 /* ?underflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1339 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1340 /* ?underflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1341 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_underflow, 4)
1342 #define call_basic_streambuf_wchar_underflow(this) CALL_VTBL_FUNC(this, 24, \
1343         unsigned short, (basic_streambuf_wchar*), (this))
1344 unsigned short __thiscall basic_streambuf_wchar_underflow(basic_streambuf_wchar *this)
1345 {
1346     TRACE("(%p)\n", this);
1347     return WEOF;
1348 }
1349
1350 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
1351 /* ?uflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
1352 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
1353 /* ?uflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
1354 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_uflow, 4)
1355 #define call_basic_streambuf_wchar_uflow(this) CALL_VTBL_FUNC(this, 28, \
1356         unsigned short, (basic_streambuf_wchar*), (this))
1357 unsigned short __thiscall basic_streambuf_wchar_uflow(basic_streambuf_wchar *this)
1358 {
1359     int ret;
1360
1361     TRACE("(%p)\n", this);
1362
1363     if(call_basic_streambuf_wchar_underflow(this)==WEOF)
1364         return WEOF;
1365
1366     ret = **this->prpos;
1367     (*this->prsize)--;
1368     (*this->prpos)++;
1369     return ret;
1370 }
1371
1372 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WIH@Z */
1373 /* ?_Xsgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_K_J@Z */
1374 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGIH@Z */
1375 /* ?_Xsgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_K_J@Z */
1376 static streamsize basic_streambuf_wchar__Xsgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1377 {
1378     streamsize copied, chunk;
1379     unsigned short c;
1380
1381     TRACE("(%p %p %lu %s)\n", this, ptr, size, wine_dbgstr_longlong(count));
1382
1383     for(copied=0; copied<count && size;) {
1384         chunk = basic_streambuf_wchar__Gnavail(this);
1385         if(chunk > count-copied)
1386             chunk = count-copied;
1387
1388         if(chunk > 0) {
1389             memcpy_s(ptr+copied, size, *this->prpos, chunk*sizeof(wchar_t));
1390             *this->prpos += chunk;
1391             *this->prsize -= chunk;
1392             copied += chunk;
1393             size -= chunk*sizeof(wchar_t);
1394         }else if((c = call_basic_streambuf_wchar_uflow(this)) != WEOF) {
1395             ptr[copied] = c;
1396             copied++;
1397             size--;
1398         }else {
1399             break;
1400         }
1401     }
1402
1403     return copied;
1404 }
1405
1406 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
1407 /* ?_Sgetn_s@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
1408 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
1409 /* ?_Sgetn_s@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
1410 static streamsize basic_streambuf_wchar__Sgetn_s(basic_streambuf_wchar *this, wchar_t *ptr, MSVCP_size_t size, streamsize count)
1411 {
1412     TRACE("(%p %p %lu %s)\n", this, ptr, size, wine_dbgstr_longlong(count));
1413     return basic_streambuf_wchar__Xsgetn_s(this, ptr, size, count);
1414 }
1415
1416 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1417 /* ?_Unlock@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1418 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1419 /* ?_Unlock@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1420 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar__Unlock, 4)
1421 void __thiscall basic_streambuf_wchar__Unlock(basic_streambuf_wchar *this)
1422 {
1423     TRACE("(%p)\n", this);
1424     mutex_unlock(&this->lock);
1425 }
1426
1427 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1428 /* ?eback@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1429 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1430 /* ?eback@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1431 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_eback, 4)
1432 wchar_t* __thiscall basic_streambuf_wchar_eback(const basic_streambuf_wchar *this)
1433 {
1434     TRACE("(%p)\n", this);
1435     return *this->prbuf;
1436 }
1437
1438 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1439 /* ?gptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1440 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1441 /* ?gptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1442 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gptr, 4)
1443 wchar_t* __thiscall basic_streambuf_wchar_gptr(const basic_streambuf_wchar *this)
1444 {
1445     TRACE("(%p)\n", this);
1446     return *this->prpos;
1447 }
1448
1449 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1450 /* ?egptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1451 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1452 /* ?egptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1453 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_egptr, 4)
1454 wchar_t* __thiscall basic_streambuf_wchar_egptr(const basic_streambuf_wchar *this)
1455 {
1456     TRACE("(%p)\n", this);
1457     return *this->prpos+*this->prsize;
1458 }
1459
1460 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1461 /* ?epptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1462 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1463 /* ?epptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1464 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_epptr, 4)
1465 wchar_t* __thiscall basic_streambuf_wchar_epptr(const basic_streambuf_wchar *this)
1466 {
1467     TRACE("(%p)\n", this);
1468     return *this->pwpos+*this->pwsize;
1469 }
1470
1471 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1472 /* ?gbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1473 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1474 /* ?gbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1475 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_gbump, 8)
1476 void __thiscall basic_streambuf_wchar_gbump(basic_streambuf_wchar *this, int off)
1477 {
1478     TRACE("(%p %d)\n", this, off);
1479     *this->prpos += off;
1480     *this->prsize -= off;
1481 }
1482
1483 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QBE?AVlocale@2@XZ */
1484 /* ?getloc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEBA?AVlocale@2@XZ */
1485 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QBE?AVlocale@2@XZ */
1486 /* ?getloc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEBA?AVlocale@2@XZ */
1487 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_getloc, 8)
1488 locale* __thiscall basic_streambuf_wchar_getloc(const basic_streambuf_wchar *this, locale *ret)
1489 {
1490     TRACE("(%p)\n", this);
1491     return locale_copy_ctor(ret, this->loc);
1492 }
1493
1494 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
1495 /* ?imbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
1496 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
1497 /* ?imbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
1498 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_imbue, 8)
1499 #define call_basic_streambuf_wchar_imbue(this, loc) CALL_VTBL_FUNC(this, 56, \
1500         void, (basic_streambuf_wchar*, const locale*), (this, loc))
1501 void __thiscall basic_streambuf_wchar_imbue(basic_streambuf_wchar *this, const locale *loc)
1502 {
1503     TRACE("(%p %p)\n", this, loc);
1504 }
1505
1506 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1507 /* ?overflow@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1508 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1509 /* ?overflow@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1510 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_overflow, 8)
1511 #define call_basic_streambuf_wchar_overflow(this, ch) CALL_VTBL_FUNC(this, 12, \
1512         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1513 unsigned short __thiscall basic_streambuf_wchar_overflow(basic_streambuf_wchar *this, unsigned short ch)
1514 {
1515     TRACE("(%p %d)\n", this, ch);
1516     return WEOF;
1517 }
1518
1519 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
1520 /* ?pbackfail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
1521 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
1522 /* ?pbackfail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
1523 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbackfail, 8)
1524 #define call_basic_streambuf_wchar_pbackfail(this, ch) CALL_VTBL_FUNC(this, 16, \
1525         unsigned short, (basic_streambuf_wchar*, unsigned short), (this, ch))
1526 unsigned short __thiscall basic_streambuf_wchar_pbackfail(basic_streambuf_wchar *this, unsigned short ch)
1527 {
1528     TRACE("(%p %d)\n", this, ch);
1529     return WEOF;
1530 }
1531
1532 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1533 /* ?pbase@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1534 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1535 /* ?pbase@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1536 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbase, 4)
1537 wchar_t* __thiscall basic_streambuf_wchar_pbase(const basic_streambuf_wchar *this)
1538 {
1539     TRACE("(%p)\n", this);
1540     return *this->pwbuf;
1541 }
1542
1543 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IAEXH@Z */
1544 /* ?pbump@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEAAXH@Z */
1545 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IAEXH@Z */
1546 /* ?pbump@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEAAXH@Z */
1547 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pbump, 8)
1548 void __thiscall basic_streambuf_wchar_pbump(basic_streambuf_wchar *this, int off)
1549 {
1550     TRACE("(%p %d)\n", this, off);
1551     *this->pwpos += off;
1552     *this->pwsize -= off;
1553 }
1554
1555 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IBEPA_WXZ */
1556 /* ?pptr@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@IEBAPEA_WXZ */
1557 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IBEPAGXZ */
1558 /* ?pptr@?$basic_streambuf@GU?$char_traits@G@std@@@std@@IEBAPEAGXZ */
1559 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pptr, 4)
1560 wchar_t* __thiscall basic_streambuf_wchar_pptr(const basic_streambuf_wchar *this)
1561 {
1562     TRACE("(%p)\n", this);
1563     return *this->pwpos;
1564 }
1565
1566 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1567 /* ?pubimbue@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1568 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
1569 /* ?pubimbue@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
1570 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubimbue, 12)
1571 locale* __thiscall basic_streambuf_wchar_pubimbue(basic_streambuf_wchar *this, locale *ret, const locale *loc)
1572 {
1573     TRACE("(%p %p)\n", this, loc);
1574     memcpy(ret, this->loc, sizeof(locale));
1575     call_basic_streambuf_wchar_imbue(this, loc);
1576     locale_copy_ctor(this->loc, loc);
1577     return ret;
1578 }
1579
1580 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1581 /* ?seekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1582 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
1583 /* ?seekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
1584 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekoff, 24)
1585 #define call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode) CALL_VTBL_FUNC(this, 40, \
1586         fpos_int*, (basic_streambuf_wchar*, fpos_int*, streamoff, int, int), (this, ret, off, way, mode))
1587 fpos_int* __thiscall basic_streambuf_wchar_seekoff(basic_streambuf_wchar *this,
1588         fpos_int *ret, streamoff off, int way, int mode)
1589 {
1590     TRACE("(%p %s %d %d)\n", this, wine_dbgstr_longlong(off), way, mode);
1591     ret->off = -1;
1592     ret->pos = 0;
1593     ret->state = 0;
1594     return ret;
1595 }
1596
1597 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1598 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1599 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JHH@Z */
1600 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JHH@Z */
1601 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff, 24)
1602 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff(basic_streambuf_wchar *this,
1603         fpos_int *ret, streamoff off, int way, int mode)
1604 {
1605     TRACE("(%p %s %d %d)\n", this, wine_dbgstr_longlong(off), way, mode);
1606     return call_basic_streambuf_wchar_seekoff(this, ret, off, way, mode);
1607 }
1608
1609 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1610 /* ?pubseekoff@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1611 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@JII@Z */
1612 /* ?pubseekoff@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@_JII@Z */
1613 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekoff_old, 24)
1614 fpos_int* __thiscall basic_streambuf_wchar_pubseekoff_old(basic_streambuf_wchar *this,
1615         fpos_int *ret, streamoff off, unsigned int way, unsigned int mode)
1616 {
1617     TRACE("(%p %s %d %d)\n", this, wine_dbgstr_longlong(off), way, mode);
1618     return basic_streambuf_wchar_pubseekoff(this, ret, off, way, mode);
1619 }
1620
1621 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1622 /* ?seekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1623 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
1624 /* ?seekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
1625 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_seekpos, 36)
1626 #define call_basic_streambuf_wchar_seekpos(this, ret, pos, mode) CALL_VTBL_FUNC(this, 44, \
1627         fpos_int*, (basic_streambuf_wchar*, fpos_int*, fpos_int, int), (this, ret, pos, mode))
1628 fpos_int* __thiscall basic_streambuf_wchar_seekpos(basic_streambuf_wchar *this,
1629         fpos_int *ret, fpos_int pos, int mode)
1630 {
1631     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1632     ret->off = -1;
1633     ret->pos = 0;
1634     ret->state = 0;
1635     return ret;
1636 }
1637
1638 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1639 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1640 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@H@Z */
1641 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@H@Z */
1642 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos, 36)
1643 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos(basic_streambuf_wchar *this,
1644         fpos_int *ret, fpos_int pos, int mode)
1645 {
1646     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1647     return call_basic_streambuf_wchar_seekpos(this, ret, pos, mode);
1648 }
1649
1650 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1651 /* ?pubseekpos@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1652 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@V32@I@Z */
1653 /* ?pubseekpos@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@V32@I@Z */
1654 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubseekpos_old, 36)
1655 fpos_int* __thiscall basic_streambuf_wchar_pubseekpos_old(basic_streambuf_wchar *this,
1656         fpos_int *ret, fpos_int pos, unsigned int mode)
1657 {
1658     TRACE("(%p %s %d)\n", this, debugstr_fpos_int(&pos), mode);
1659     return basic_streambuf_wchar_pubseekpos(this, ret, pos, mode);
1660 }
1661
1662 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEPAV12@PA_WH@Z */
1663 /* ?setbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV12@PEA_W_J@Z */
1664 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEPAV12@PAGH@Z */
1665 /* ?setbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAPEAV12@PEAG_J@Z */
1666 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_setbuf, 16)
1667 #define call_basic_streambuf_wchar_setbuf(this, buf, count) CALL_VTBL_FUNC(this, 48, \
1668         basic_streambuf_wchar*, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, buf, count))
1669 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_setbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
1670 {
1671     TRACE("(%p %p %s)\n", this, buf, wine_dbgstr_longlong(count));
1672     return this;
1673 }
1674
1675 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@PA_WH@Z */
1676 /* ?pubsetbuf@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@PEA_W_J@Z */
1677 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEPAV12@PAGH@Z */
1678 /* ?pubsetbuf@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@PEAG_J@Z */
1679 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsetbuf, 16)
1680 basic_streambuf_wchar* __thiscall basic_streambuf_wchar_pubsetbuf(basic_streambuf_wchar *this, wchar_t *buf, streamsize count)
1681 {
1682     TRACE("(%p %p %s)\n", this, buf, wine_dbgstr_longlong(count));
1683     return call_basic_streambuf_wchar_setbuf(this, buf, count);
1684 }
1685
1686 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
1687 /* ?sync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
1688 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
1689 /* ?sync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
1690 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sync, 4)
1691 #define call_basic_streambuf_wchar_sync(this) CALL_VTBL_FUNC(this, 52, \
1692         int, (basic_streambuf_wchar*), (this))
1693 int __thiscall basic_streambuf_wchar_sync(basic_streambuf_wchar *this)
1694 {
1695     TRACE("(%p)\n", this);
1696     return 0;
1697 }
1698
1699 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
1700 /* ?pubsync@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
1701 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
1702 /* ?pubsync@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHXZ */
1703 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_pubsync, 4)
1704 int __thiscall basic_streambuf_wchar_pubsync(basic_streambuf_wchar *this)
1705 {
1706     TRACE("(%p)\n", this);
1707     return call_basic_streambuf_wchar_sync(this);
1708 }
1709
1710 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
1711 /* ?sgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
1712 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
1713 /* ?sgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
1714 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetn, 16)
1715 streamsize __thiscall basic_streambuf_wchar_sgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
1716 {
1717     TRACE("(%p %p %s)\n", this, ptr, wine_dbgstr_longlong(count));
1718     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
1719 }
1720
1721 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
1722 /* ?showmanyc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JXZ */
1723 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
1724 /* ?showmanyc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JXZ */
1725 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_showmanyc, 4)
1726 #define call_basic_streambuf_wchar_showmanyc(this) CALL_VTBL_FUNC(this, 20, \
1727         streamsize, (basic_streambuf_wchar*), (this))
1728 streamsize __thiscall basic_streambuf_wchar_showmanyc(basic_streambuf_wchar *this)
1729 {
1730     TRACE("(%p)\n", this);
1731     return 0;
1732 }
1733
1734 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
1735 /* ?in_avail@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JXZ */
1736 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHXZ */
1737 /* ?in_avail@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JXZ */
1738 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_in_avail, 4)
1739 streamsize __thiscall basic_streambuf_wchar_in_avail(basic_streambuf_wchar *this)
1740 {
1741     streamsize ret;
1742
1743     TRACE("(%p)\n", this);
1744
1745     ret = basic_streambuf_wchar__Gnavail(this);
1746     return ret ? ret : call_basic_streambuf_wchar_showmanyc(this);
1747 }
1748
1749 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
1750 /* ?sputbackc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
1751 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
1752 /* ?sputbackc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
1753 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputbackc, 8)
1754 unsigned short __thiscall basic_streambuf_wchar_sputbackc(basic_streambuf_wchar *this, wchar_t ch)
1755 {
1756     TRACE("(%p %d)\n", this, ch);
1757     if(*this->prpos && *this->prpos>*this->prbuf && (*this->prpos)[-1]==ch) {
1758         (*this->prsize)++;
1759         (*this->prpos)--;
1760         return ch;
1761     }
1762
1763     return call_basic_streambuf_wchar_pbackfail(this, ch);
1764 }
1765
1766 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEG_W@Z */
1767 /* ?sputc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAG_W@Z */
1768 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGG@Z */
1769 /* ?sputc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAHG@Z */
1770 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputc, 8)
1771 unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar *this, wchar_t ch)
1772 {
1773     TRACE("(%p %d)\n", this, ch);
1774     return basic_streambuf_wchar__Pnavail(this) ?
1775         (*basic_streambuf_wchar__Pninc(this) = ch) :
1776         call_basic_streambuf_wchar_overflow(this, ch);
1777 }
1778
1779 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1780 /* ?sungetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1781 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1782 /* ?sungetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1783 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sungetc, 4)
1784 unsigned short __thiscall basic_streambuf_wchar_sungetc(basic_streambuf_wchar *this)
1785 {
1786     TRACE("(%p)\n", this);
1787     if(*this->prpos && *this->prpos>*this->prbuf) {
1788         (*this->prsize)++;
1789         (*this->prpos)--;
1790         return **this->prpos;
1791     }
1792
1793     return call_basic_streambuf_wchar_pbackfail(this, WEOF);
1794 }
1795
1796 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
1797 /* ?stossc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
1798 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEXXZ */
1799 /* ?stossc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAXXZ */
1800 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_stossc, 4)
1801 void __thiscall basic_streambuf_wchar_stossc(basic_streambuf_wchar *this)
1802 {
1803     TRACE("(%p)\n", this);
1804     if(basic_streambuf_wchar__Gnavail(this))
1805         basic_streambuf_wchar__Gninc(this);
1806     else
1807         call_basic_streambuf_wchar_uflow(this);
1808 }
1809
1810 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1811 /* ?sbumpc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1812 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1813 /* ?sbumpc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1814 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sbumpc, 4)
1815 unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar *this)
1816 {
1817     TRACE("(%p)\n", this);
1818     return basic_streambuf_wchar__Gnavail(this) ?
1819         *basic_streambuf_wchar__Gninc(this) : call_basic_streambuf_wchar_uflow(this);
1820 }
1821
1822 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1823 /* ?sgetc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1824 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1825 /* ?sgetc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1826 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sgetc, 4)
1827 unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar *this)
1828 {
1829     TRACE("(%p)\n", this);
1830     return basic_streambuf_wchar__Gnavail(this) ?
1831         *basic_streambuf_wchar_gptr(this) : call_basic_streambuf_wchar_underflow(this);
1832 }
1833
1834 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
1835 /* ?snextc@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
1836 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEGXZ */
1837 /* ?snextc@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAAGXZ */
1838 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_snextc, 4)
1839 unsigned short __thiscall basic_streambuf_wchar_snextc(basic_streambuf_wchar *this)
1840 {
1841     TRACE("(%p)\n", this);
1842
1843     if(basic_streambuf_wchar__Gnavail(this) > 1)
1844         return *basic_streambuf_wchar__Gnpreinc(this);
1845     return basic_streambuf_wchar_sbumpc(this)==WEOF ?
1846         WEOF : basic_streambuf_wchar_sgetc(this);
1847 }
1848
1849 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPA_WH@Z */
1850 /* ?xsgetn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEA_W_J@Z */
1851 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPAGH@Z */
1852 /* ?xsgetn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEAG_J@Z */
1853 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsgetn, 16)
1854 #define call_basic_streambuf_wchar_xsgetn(this, ptr, count) CALL_VTBL_FUNC(this, 32, \
1855         streamsize, (basic_streambuf_wchar*, wchar_t*, streamsize), (this, ptr, count))
1856 streamsize __thiscall basic_streambuf_wchar_xsgetn(basic_streambuf_wchar *this, wchar_t *ptr, streamsize count)
1857 {
1858     TRACE("(%p %p %s)\n", this, ptr, wine_dbgstr_longlong(count));
1859     return basic_streambuf_wchar__Xsgetn_s(this, ptr, -1, count);
1860 }
1861
1862 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MAEHPB_WH@Z */
1863 /* ?xsputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@MEAA_JPEB_W_J@Z */
1864 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MAEHPBGH@Z */
1865 /* ?xsputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@MEAA_JPEBG_J@Z */
1866 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_xsputn, 16)
1867 #define call_basic_streambuf_wchar_xsputn(this, ptr, count) CALL_VTBL_FUNC(this, 36, \
1868         streamsize, (basic_streambuf_wchar*, const wchar_t*, streamsize), (this, ptr, count))
1869 streamsize __thiscall basic_streambuf_wchar_xsputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
1870 {
1871     streamsize copied, chunk;
1872
1873     TRACE("(%p %p %s)\n", this, ptr, wine_dbgstr_longlong(count));
1874
1875     for(copied=0; copied<count;) {
1876         chunk = basic_streambuf_wchar__Pnavail(this);
1877         if(chunk > count-copied)
1878             chunk = count-copied;
1879
1880         if(chunk > 0) {
1881             memcpy(*this->pwpos, ptr+copied, chunk*sizeof(wchar_t));
1882             *this->pwpos += chunk;
1883             *this->pwsize -= chunk;
1884             copied += chunk;
1885         }else if(call_basic_streambuf_wchar_overflow(this, ptr[copied]) != WEOF) {
1886             copied++;
1887         }else {
1888             break;
1889         }
1890     }
1891
1892     return copied;
1893 }
1894
1895 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QAEHPB_WH@Z */
1896 /* ?sputn@?$basic_streambuf@_WU?$char_traits@_W@std@@@std@@QEAA_JPEB_W_J@Z */
1897 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QAEHPBGH@Z */
1898 /* ?sputn@?$basic_streambuf@GU?$char_traits@G@std@@@std@@QEAA_JPEBG_J@Z */
1899 DEFINE_THISCALL_WRAPPER(basic_streambuf_wchar_sputn, 16)
1900 streamsize __thiscall basic_streambuf_wchar_sputn(basic_streambuf_wchar *this, const wchar_t *ptr, streamsize count)
1901 {
1902     TRACE("(%p %p %s)\n", this, ptr, wine_dbgstr_longlong(count));
1903     return call_basic_streambuf_wchar_xsputn(this, ptr, count);
1904 }
1905
1906 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
1907 /* ?_Stinit@?1??_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
1908 static int basic_filebuf_char__Init__Stinit = 0;
1909
1910 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
1911 /* ?_Init@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
1912 static void basic_filebuf_char__Init(basic_filebuf_char *this, FILE *file, basic_filebuf__Initfl which)
1913 {
1914     TRACE("(%p %p %d)\n", this, file, which);
1915
1916     this->cvt = NULL;
1917     this->wrotesome = FALSE;
1918     this->state = basic_filebuf_char__Init__Stinit;
1919     this->close = (which == INITFL_open);
1920     this->file = file;
1921
1922     basic_streambuf_char__Init_empty(&this->base);
1923     if(file)
1924         basic_streambuf_char__Init(&this->base, &file->_base, &file->_ptr,
1925                 &file->_cnt, &file->_base, &file->_ptr, &file->_cnt);
1926 }
1927
1928 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAEXPAV?$codecvt@DDH@2@@Z */
1929 /* ?_Initcvt@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$codecvt@DDH@2@@Z */
1930 static void basic_filebuf_char__Initcvt(basic_filebuf_char *this, codecvt_char *cvt)
1931 {
1932     TRACE("(%p %p)\n", this, cvt);
1933
1934     if(codecvt_base_always_noconv(&cvt->base)) {
1935         this->cvt = NULL;
1936     }else {
1937         basic_streambuf_char__Init_empty(&this->base);
1938         this->cvt = cvt;
1939     }
1940 }
1941
1942 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IAE_NXZ */
1943 /* ?_Endwrite@?$basic_filebuf@DU?$char_traits@D@std@@@std@@IEAA_NXZ */
1944 static MSVCP_bool basic_filebuf_char__Endwrite(basic_filebuf_char *this)
1945 {
1946     TRACE("(%p)\n", this);
1947
1948     if(!this->wrotesome || !this->cvt)
1949         return TRUE;
1950
1951
1952     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
1953         return FALSE;
1954
1955     while(1) {
1956         /* TODO: check if we need a dynamic buffer here */
1957         char buf[128];
1958         char *next;
1959         int ret;
1960
1961         ret = codecvt_char_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
1962         switch(ret) {
1963         case CODECVT_ok:
1964             this->wrotesome = FALSE;
1965             /* fall through */
1966         case CODECVT_partial:
1967             if(!fwrite(buf, next-buf, 1, this->file))
1968                 return FALSE;
1969             if(this->wrotesome)
1970                 break;
1971             /* fall through */
1972         case CODECVT_noconv:
1973             if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
1974                 return FALSE;
1975             return TRUE;
1976         default:
1977             return FALSE;
1978         }
1979     }
1980 }
1981
1982 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAEPAV12@XZ */
1983 /* ?close@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAAPEAV12@XZ */
1984 static basic_filebuf_char* basic_filebuf_char_close(basic_filebuf_char *this)
1985 {
1986     basic_filebuf_char *ret = this;
1987
1988     TRACE("(%p)\n", this);
1989
1990     if(!this->file)
1991         return NULL;
1992
1993     /* TODO: handle exceptions */
1994     if(!basic_filebuf_char__Endwrite(this))
1995         ret = NULL;
1996     if(fclose(this->file))
1997         ret  = NULL;
1998
1999     basic_filebuf_char__Init(this, NULL, INITFL_close);
2000     return ret;
2001 }
2002
2003 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QAE@PAU_iobuf@@@Z */
2004 /* ??0?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2005 static basic_filebuf_char* basic_filebuf_char_ctor_file(basic_filebuf_char *this, FILE *file)
2006 {
2007     TRACE("(%p %p)\n", this, file);
2008
2009     basic_streambuf_char_ctor(&this->base);
2010     this->base.vtable = &MSVCP_basic_filebuf_char_vtable;
2011
2012     basic_filebuf_char__Init(this, file, INITFL_new);
2013     return this;
2014 }
2015
2016 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UAE@XZ */
2017 /* ??1?$basic_filebuf@DU?$char_traits@D@std@@@std@@UEAA@XZ */
2018 static void basic_filebuf_char_dtor(basic_filebuf_char *this)
2019 {
2020     TRACE("(%p)\n", this);
2021
2022     if(this->close)
2023         basic_filebuf_char_close(this);
2024     basic_streambuf_char_dtor(&this->base);
2025 }
2026
2027 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_vector_dtor, 8)
2028 basic_filebuf_char* __thiscall basic_filebuf_char_vector_dtor(basic_filebuf_char *this, unsigned int flags)
2029 {
2030     TRACE("(%p %x)\n", this, flags);
2031     if(flags & 2) {
2032         /* we have an array, with the number of elements stored before the first object */
2033         INT_PTR i, *ptr = (INT_PTR *)this-1;
2034
2035         for(i=*ptr-1; i>=0; i--)
2036             basic_filebuf_char_dtor(this+i);
2037         MSVCRT_operator_delete(ptr);
2038     } else {
2039         basic_filebuf_char_dtor(this);
2040         if(flags & 1)
2041             MSVCRT_operator_delete(this);
2042     }
2043
2044     return this;
2045 }
2046
2047 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QBE_NXZ */
2048 /* ?is_open@?$basic_filebuf@DU?$char_traits@D@std@@@std@@QEBA_NXZ */
2049 static MSVCP_bool basic_filebuf_char_is_open(const basic_filebuf_char *this)
2050 {
2051     TRACE("(%p)\n", this);
2052     return this->file != NULL;
2053 }
2054
2055 /* ?_Fiopen@std@@YAPAU_iobuf@@PB_WHH@Z */
2056 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEB_WHH@Z */
2057 FILE* __cdecl _Fiopen_wchar(const wchar_t *name, int mode, int prot)
2058 {
2059     static const wchar_t rW[] = {'r',0};
2060     static const struct {
2061         int mode;
2062         const wchar_t str[4];
2063         const wchar_t str_bin[4];
2064     } str_mode[] = {
2065         {OPENMODE_out,                            {'w',0},     {'w','b',0}},
2066         {OPENMODE_out|OPENMODE_app,               {'a',0},     {'a','b',0}},
2067         {OPENMODE_app,                            {'a',0},     {'a','b',0}},
2068         {OPENMODE_out|OPENMODE_trunc,             {'w',0},     {'w','b',0}},
2069         {OPENMODE_in,                             {'r',0},     {'r','b',0}},
2070         {OPENMODE_in|OPENMODE_out,                {'r','+',0}, {'r','+','b',0}},
2071         {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, {'w','+',0}, {'w','+','b',0}},
2072         {OPENMODE_in|OPENMODE_out|OPENMODE_app,   {'a','+',0}, {'a','+','b',0}},
2073         {OPENMODE_in|OPENMODE_app,                {'a','+',0}, {'a','+','b',0}}
2074     };
2075
2076     int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary);
2077     size_t mode_idx;
2078     FILE *f = NULL;
2079
2080     TRACE("(%s %d %d)\n", debugstr_w(name), mode, prot);
2081
2082     for(mode_idx=0; mode_idx<sizeof(str_mode)/sizeof(str_mode[0]); mode_idx++)
2083         if(str_mode[mode_idx].mode == real_mode)
2084             break;
2085     if(mode_idx == sizeof(str_mode)/sizeof(str_mode[0]))
2086         return NULL;
2087
2088     if((mode & OPENMODE__Nocreate) && !(f = _wfopen(name, rW)))
2089         return NULL;
2090     else if(f)
2091         fclose(f);
2092
2093     if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app))
2094             && (f = _wfopen(name, rW))) {
2095         fclose(f);
2096         return NULL;
2097     }
2098
2099     f = _wfsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin
2100             : str_mode[mode_idx].str, prot);
2101     if(!f)
2102         return NULL;
2103
2104     if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) {
2105         fclose(f);
2106         return NULL;
2107     }
2108
2109     return f;
2110 }
2111
2112 /* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */
2113 /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */
2114 FILE* __cdecl _Fiopen(const char *name, int mode, int prot)
2115 {
2116     wchar_t nameW[FILENAME_MAX];
2117
2118     TRACE("(%s %d %d)\n", name, mode, prot);
2119
2120     if(mbstowcs_s(NULL, nameW, FILENAME_MAX, name, FILENAME_MAX-1) != 0)
2121         return NULL;
2122     return _Fiopen_wchar(nameW, mode, prot);
2123 }
2124
2125 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2126 /* ?overflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2127 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_overflow, 8)
2128 int __thiscall basic_filebuf_char_overflow(basic_filebuf_char *this, int c)
2129 {
2130     char buf[8], *dyn_buf;
2131     char ch = c, *to_next;
2132     const char *from_next;
2133     int ret, max_size;
2134
2135
2136     TRACE("(%p %d)\n", this, c);
2137
2138     if(!basic_filebuf_char_is_open(this))
2139         return EOF;
2140     if(c == EOF)
2141         return !c;
2142
2143     if(!this->cvt)
2144         return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2145
2146     from_next = &ch;
2147     do {
2148         ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2149                 &from_next, buf, buf+sizeof(buf), &to_next);
2150
2151         switch(ret) {
2152         case CODECVT_partial:
2153             if(to_next == buf)
2154                 break;
2155             /* fall through */
2156         case CODECVT_ok:
2157             if(!fwrite(buf, to_next-buf, 1, this->file))
2158                 return EOF;
2159             if(ret == CODECVT_partial)
2160                 continue;
2161             return c;
2162         case CODECVT_noconv:
2163             return fwrite(&ch, sizeof(char), 1, this->file) ? c : EOF;
2164         default:
2165             return EOF;
2166         }
2167
2168         break;
2169     } while(1);
2170
2171     max_size = codecvt_base_max_length(&this->cvt->base);
2172     dyn_buf = malloc(max_size);
2173     if(!dyn_buf)
2174         return EOF;
2175
2176     ret = codecvt_char_out(this->cvt, &this->state, from_next, &ch+1,
2177             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2178
2179     switch(ret) {
2180     case CODECVT_ok:
2181         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2182         free(dyn_buf);
2183         return ret ? c : EOF;
2184     case CODECVT_partial:
2185         ERR("buffer should be big enough to store all output\n");
2186         /* fall through */
2187     default:
2188         free(dyn_buf);
2189         return EOF;
2190     }
2191 }
2192
2193 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHH@Z */
2194 /* ?pbackfail@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHH@Z */
2195 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_pbackfail, 8)
2196 int __thiscall basic_filebuf_char_pbackfail(basic_filebuf_char *this, int c)
2197 {
2198     TRACE("(%p %d)\n", this, c);
2199
2200     if(!basic_filebuf_char_is_open(this))
2201         return EOF;
2202
2203     if(basic_streambuf_char_gptr(&this->base)>basic_streambuf_char_eback(&this->base)
2204             && (c==EOF || (int)(unsigned char)basic_streambuf_char_gptr(&this->base)[-1]==c)) {
2205         basic_streambuf_char__Gndec(&this->base);
2206         return c==EOF ? !c : c;
2207     }else if(c!=EOF && !this->cvt) {
2208         return ungetc(c, this->file);
2209     }
2210
2211     return EOF;
2212 }
2213
2214 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2215 /* ?uflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2216 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_uflow, 4)
2217 int __thiscall basic_filebuf_char_uflow(basic_filebuf_char *this)
2218 {
2219     char ch, buf[128], *to_next;
2220     const char *buf_next;
2221     int c;
2222     size_t i;
2223
2224     TRACE("(%p)\n", this);
2225
2226     if(!basic_filebuf_char_is_open(this))
2227         return EOF;
2228
2229     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2230         return (unsigned char)*basic_streambuf_char__Gninc(&this->base);
2231
2232     c = fgetc(this->file);
2233     if(!this->cvt || c==EOF)
2234         return c;
2235
2236     buf_next = buf;
2237     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
2238         buf[i] = c;
2239
2240         switch(codecvt_char_in(this->cvt, &this->state, buf_next,
2241                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2242         case CODECVT_partial:
2243         case CODECVT_ok:
2244             if(to_next == &ch) {
2245                 c = fgetc(this->file);
2246                 if(c == EOF)
2247                     return EOF;
2248                 continue;
2249             }
2250
2251             {
2252                 ptrdiff_t j;
2253
2254                 for(j = --i; j >= buf_next-buf; j--)
2255                     ungetc(buf[j], this->file);
2256             }
2257             return ch;
2258         case CODECVT_noconv:
2259             return (unsigned char)buf[0];
2260         default:
2261             return EOF;
2262         }
2263     }
2264
2265     FIXME("buffer is too small\n");
2266     return EOF;
2267 }
2268
2269 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2270 /* ?underflow@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2271 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_underflow, 4)
2272 int __thiscall basic_filebuf_char_underflow(basic_filebuf_char *this)
2273 {
2274     int ret;
2275
2276     TRACE("(%p)\n", this);
2277
2278     if(basic_streambuf_char_gptr(&this->base) < basic_streambuf_char_egptr(&this->base))
2279         return (unsigned char)*basic_streambuf_char_gptr(&this->base);
2280
2281     ret = call_basic_streambuf_char_uflow(&this->base);
2282     if(ret != EOF)
2283         ret = call_basic_streambuf_char_pbackfail(&this->base, ret);
2284     return ret;
2285 }
2286
2287 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2288 /* ?seekoff@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2289 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekoff, 24)
2290 fpos_int* __thiscall basic_filebuf_char_seekoff(basic_filebuf_char *this,
2291         fpos_int *ret, streamoff off, int way, int mode)
2292 {
2293     fpos_t pos;
2294
2295     TRACE("(%p %p %s %d %d)\n", this, ret, wine_dbgstr_longlong(off), way, mode);
2296
2297     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2298             || fseek(this->file, off, way)) {
2299         ret->off = -1;
2300         ret->pos = 0;
2301         ret->state = 0;
2302         return ret;
2303     }
2304
2305     fgetpos(this->file, &pos);
2306     ret->off = 0;
2307     ret->pos = pos;
2308     ret->state = this->state;
2309     return ret;
2310 }
2311
2312 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2313 /* ?seekpos@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2314 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_seekpos, 36)
2315 fpos_int* __thiscall basic_filebuf_char_seekpos(basic_filebuf_char *this,
2316         fpos_int *ret, fpos_int pos, int mode)
2317 {
2318     fpos_t fpos;
2319
2320     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2321
2322     if(!basic_filebuf_char_is_open(this) || !basic_filebuf_char__Endwrite(this)
2323             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2324             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2325         ret->off = -1;
2326         ret->pos = 0;
2327         ret->state = 0;
2328         return ret;
2329     }
2330
2331     fgetpos(this->file, &fpos);
2332     ret->off = 0;
2333     ret->pos = fpos;
2334     ret->state = this->state;
2335     return ret;
2336 }
2337
2338 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z */
2339 /* ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z */
2340 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_setbuf, 16)
2341 basic_streambuf_char* __thiscall basic_filebuf_char_setbuf(basic_filebuf_char *this, char *buf, streamsize count)
2342 {
2343     TRACE("(%p %p %s)\n", this, buf, wine_dbgstr_longlong(count));
2344
2345     if(!basic_filebuf_char_is_open(this))
2346         return NULL;
2347
2348     if(setvbuf(this->file, buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count))
2349         return NULL;
2350
2351     basic_filebuf_char__Init(this, this->file, INITFL_open);
2352     return &this->base;
2353 }
2354
2355 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEHXZ */
2356 /* ?sync@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAHXZ */
2357 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_sync, 4)
2358 int __thiscall basic_filebuf_char_sync(basic_filebuf_char *this)
2359 {
2360     TRACE("(%p)\n", this);
2361
2362     if(!basic_filebuf_char_is_open(this))
2363         return 0;
2364
2365     if(call_basic_streambuf_char_overflow(&this->base, EOF) == EOF)
2366         return 0;
2367     return fflush(this->file);
2368 }
2369
2370 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEXABVlocale@2@@Z */
2371 /* ?imbue@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAXAEBVlocale@2@@Z */
2372 DEFINE_THISCALL_WRAPPER(basic_filebuf_char_imbue, 8)
2373 void __thiscall basic_filebuf_char_imbue(basic_filebuf_char *this, const locale *loc)
2374 {
2375     TRACE("(%p %p)\n", this, loc);
2376     basic_filebuf_char__Initcvt(this, codecvt_char_use_facet(loc));
2377 }
2378
2379 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2380 /* ?_Stinit@?1??_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2381 static int basic_filebuf_wchar__Init__Stinit = 0;
2382
2383 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@23@@Z@4HA */
2384 /* ?_Stinit@?1??_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@23@@Z@4HA */
2385 static int basic_filebuf_short__Init__Stinit = 0;
2386
2387 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2388 /* ?_Init@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2389 static void basic_filebuf_wchar__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2390 {
2391     TRACE("(%p %p %d)\n", this, file, which);
2392
2393     this->cvt = NULL;
2394     this->wrotesome = FALSE;
2395     this->state = basic_filebuf_wchar__Init__Stinit;
2396     this->close = (which == INITFL_open);
2397     this->file = file;
2398
2399     basic_streambuf_wchar__Init_empty(&this->base);
2400 }
2401
2402 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAU_iobuf@@W4_Initfl@12@@Z */
2403 /* ?_Init@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAU_iobuf@@W4_Initfl@12@@Z */
2404 static void basic_filebuf_short__Init(basic_filebuf_wchar *this, FILE *file, basic_filebuf__Initfl which)
2405 {
2406     TRACE("(%p %p %d)\n", this, file, which);
2407
2408     this->cvt = NULL;
2409     this->wrotesome = FALSE;
2410     this->state = basic_filebuf_short__Init__Stinit;
2411     this->close = (which == INITFL_open);
2412     this->file = file;
2413
2414     basic_streambuf_wchar__Init_empty(&this->base);
2415 }
2416
2417 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$codecvt@_WDH@2@@Z */
2418 /* ?_Initcvt@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$codecvt@_WDH@2@@Z */
2419 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAEXPAV?$codecvt@GDH@2@@Z */
2420 /* ?_Initcvt@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$codecvt@GDH@2@@Z */
2421 static void basic_filebuf_wchar__Initcvt(basic_filebuf_wchar *this, codecvt_wchar *cvt)
2422 {
2423     TRACE("(%p %p)\n", this, cvt);
2424
2425     if(codecvt_base_always_noconv(&cvt->base)) {
2426         this->cvt = NULL;
2427     }else {
2428         basic_streambuf_wchar__Init_empty(&this->base);
2429         this->cvt = cvt;
2430     }
2431 }
2432
2433 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IAE_NXZ */
2434 /* ?_Endwrite@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@IEAA_NXZ */
2435 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IAE_NXZ */
2436 /* ?_Endwrite@?$basic_filebuf@GU?$char_traits@G@std@@@std@@IEAA_NXZ */
2437 static MSVCP_bool basic_filebuf_wchar__Endwrite(basic_filebuf_wchar *this)
2438 {
2439     TRACE("(%p)\n", this);
2440
2441     if(!this->wrotesome || !this->cvt)
2442         return TRUE;
2443
2444     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2445         return FALSE;
2446
2447     while(1) {
2448         /* TODO: check if we need a dynamic buffer here */
2449         char buf[128];
2450         char *next;
2451         int ret;
2452
2453         ret = codecvt_wchar_unshift(this->cvt, &this->state, buf, buf+sizeof(buf), &next);
2454         switch(ret) {
2455         case CODECVT_ok:
2456             this->wrotesome = FALSE;
2457             /* fall through */
2458         case CODECVT_partial:
2459             if(!fwrite(buf, next-buf, 1, this->file))
2460                 return FALSE;
2461             if(this->wrotesome)
2462                 break;
2463             /* fall through */
2464         case CODECVT_noconv:
2465             if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2466                 return FALSE;
2467             return TRUE;
2468         default:
2469             return FALSE;
2470         }
2471     }
2472 }
2473
2474 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAEPAV12@XZ */
2475 /* ?close@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAAPEAV12@XZ */
2476 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAEPAV12@XZ */
2477 /* ?close@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAAPEAV12@XZ */
2478 static basic_filebuf_wchar* basic_filebuf_wchar_close(basic_filebuf_wchar *this)
2479 {
2480     basic_filebuf_wchar *ret = this;
2481
2482     TRACE("(%p)\n", this);
2483
2484     if(!this->file)
2485         return NULL;
2486
2487     /* TODO: handle exceptions */
2488     if(!basic_filebuf_wchar__Endwrite(this))
2489         ret = NULL;
2490     if(fclose(this->file))
2491         ret  = NULL;
2492
2493     basic_filebuf_wchar__Init(this, NULL, INITFL_close);
2494     return ret;
2495 }
2496
2497 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QAE@PAU_iobuf@@@Z */
2498 /* ??0?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2499 static basic_filebuf_wchar* basic_filebuf_wchar_ctor_file(basic_filebuf_wchar *this, FILE *file)
2500 {
2501     TRACE("(%p %p)\n", this, file);
2502
2503     basic_streambuf_wchar_ctor(&this->base);
2504     this->base.vtable = &MSVCP_basic_filebuf_wchar_vtable;
2505
2506     basic_filebuf_wchar__Init(this, file, INITFL_new);
2507     return this;
2508 }
2509
2510 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QAE@PAU_iobuf@@@Z */
2511 /* ??0?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEAA@PEAU_iobuf@@@Z */
2512 static basic_filebuf_wchar* basic_filebuf_short_ctor_file(basic_filebuf_wchar *this, FILE *file)
2513 {
2514     TRACE("(%p %p)\n", this, file);
2515
2516     basic_streambuf_short_ctor(&this->base);
2517     this->base.vtable = &MSVCP_basic_filebuf_short_vtable;
2518
2519     basic_filebuf_short__Init(this, file, INITFL_new);
2520     return this;
2521 }
2522
2523 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
2524 /* ??1?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
2525 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UAE@XZ */
2526 /* ??1?$basic_filebuf@GU?$char_traits@G@std@@@std@@UEAA@XZ */
2527 static void basic_filebuf_wchar_dtor(basic_filebuf_wchar *this)
2528 {
2529     TRACE("(%p)\n", this);
2530
2531     if(this->close)
2532         basic_filebuf_wchar_close(this);
2533     basic_streambuf_wchar_dtor(&this->base);
2534 }
2535
2536 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_vector_dtor, 8)
2537 basic_filebuf_wchar* __thiscall basic_filebuf_wchar_vector_dtor(basic_filebuf_wchar *this, unsigned int flags)
2538 {
2539     TRACE("(%p %x)\n", this, flags);
2540     if(flags & 2) {
2541         /* we have an array, with the number of elements stored before the first object */
2542         INT_PTR i, *ptr = (INT_PTR *)this-1;
2543
2544         for(i=*ptr-1; i>=0; i--)
2545             basic_filebuf_wchar_dtor(this+i);
2546         MSVCRT_operator_delete(ptr);
2547     } else {
2548         basic_filebuf_wchar_dtor(this);
2549         if(flags & 1)
2550             MSVCRT_operator_delete(this);
2551     }
2552
2553     return this;
2554 }
2555
2556 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QBE_NXZ */
2557 /* ?is_open@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@QEBA_NXZ */
2558 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QBE_NXZ */
2559 /* ?is_open@?$basic_filebuf@GU?$char_traits@G@std@@@std@@QEBA_NXZ */
2560 static MSVCP_bool basic_filebuf_wchar_is_open(const basic_filebuf_wchar *this)
2561 {
2562     TRACE("(%p)\n", this);
2563     return this->file != NULL;
2564 }
2565
2566 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
2567 /* ?overflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
2568 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
2569 /* ?overflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
2570 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_overflow, 8)
2571 unsigned short __thiscall basic_filebuf_wchar_overflow(basic_filebuf_wchar *this, unsigned short c)
2572 {
2573     char buf[8], *dyn_buf, *to_next;
2574     wchar_t ch = c;
2575     const wchar_t *from_next;
2576     int max_size;
2577     unsigned short ret;
2578
2579
2580     TRACE("(%p %d)\n", this, c);
2581
2582     if(!basic_filebuf_wchar_is_open(this))
2583         return WEOF;
2584     if(c == WEOF)
2585         return !c;
2586
2587     if(!this->cvt)
2588         return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
2589
2590     from_next = &ch;
2591     do {
2592         ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
2593                 &from_next, buf, buf+sizeof(buf), &to_next);
2594
2595         switch(ret) {
2596         case CODECVT_partial:
2597             if(to_next == buf)
2598                 break;
2599             /* fall through */
2600         case CODECVT_ok:
2601             if(!fwrite(buf, to_next-buf, 1, this->file))
2602                 return WEOF;
2603             if(ret == CODECVT_partial)
2604                 continue;
2605             return c;
2606         case CODECVT_noconv:
2607             return fwrite(&ch, sizeof(wchar_t), 1, this->file) ? c : WEOF;
2608         default:
2609             return WEOF;
2610         }
2611
2612         break;
2613     } while(1);
2614
2615     max_size = codecvt_base_max_length(&this->cvt->base);
2616     dyn_buf = malloc(max_size);
2617     if(!dyn_buf)
2618         return WEOF;
2619
2620     ret = codecvt_wchar_out(this->cvt, &this->state, from_next, &ch+1,
2621             &from_next, dyn_buf, dyn_buf+max_size, &to_next);
2622
2623     switch(ret) {
2624     case CODECVT_ok:
2625         ret = fwrite(dyn_buf, to_next-dyn_buf, 1, this->file);
2626         free(dyn_buf);
2627         return ret ? c : WEOF;
2628     case CODECVT_partial:
2629         ERR("buffer should be big enough to store all output\n");
2630         /* fall through */
2631     default:
2632         free(dyn_buf);
2633         return WEOF;
2634     }
2635 }
2636
2637 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGG@Z */
2638 /* ?pbackfail@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGG@Z */
2639 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGG@Z */
2640 /* ?pbackfail@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGG@Z */
2641 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_pbackfail, 8)
2642 unsigned short __thiscall basic_filebuf_wchar_pbackfail(basic_filebuf_wchar *this, unsigned short c)
2643 {
2644     TRACE("(%p %d)\n", this, c);
2645
2646     if(!basic_filebuf_wchar_is_open(this))
2647         return WEOF;
2648
2649     if(basic_streambuf_wchar_gptr(&this->base)>basic_streambuf_wchar_eback(&this->base)
2650             && (c==WEOF || basic_streambuf_wchar_gptr(&this->base)[-1]==c)) {
2651         basic_streambuf_wchar__Gndec(&this->base);
2652         return c==WEOF ? !c : c;
2653     }else if(c!=WEOF && !this->cvt) {
2654         return ungetwc(c, this->file);
2655     }else if(c!=WEOF && basic_streambuf_wchar_gptr(&this->base)!=&this->putback) {
2656         this->putback = c;
2657         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback, &this->putback+1);
2658         return c;
2659     }
2660
2661     return WEOF;
2662 }
2663
2664 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
2665 /* ?uflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
2666 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
2667 /* ?uflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
2668 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_uflow, 4)
2669 unsigned short __thiscall basic_filebuf_wchar_uflow(basic_filebuf_wchar *this)
2670 {
2671     wchar_t ch, *to_next;
2672     char buf[128];
2673     const char *buf_next;
2674     int c;
2675     size_t i;
2676
2677     TRACE("(%p)\n", this);
2678
2679     if(!basic_filebuf_wchar_is_open(this))
2680         return WEOF;
2681
2682     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
2683         return *basic_streambuf_wchar__Gninc(&this->base);
2684
2685     if(!this->cvt)
2686         return fgetwc(this->file);
2687
2688     buf_next = buf;
2689     for(i=0; i < sizeof(buf)/sizeof(buf[0]); i++) {
2690         if((c = fgetc(this->file)) == EOF)
2691             return WEOF;
2692         buf[i] = c;
2693
2694         switch(codecvt_wchar_in(this->cvt, &this->state, buf_next,
2695                     buf+i+1, &buf_next, &ch, &ch+1, &to_next)) {
2696         case CODECVT_partial:
2697         case CODECVT_ok:
2698             if(to_next == &ch)
2699                 continue;
2700
2701             {
2702                 ptrdiff_t j;
2703
2704                 for(j = --i; j >= buf_next-buf; j--)
2705                     ungetc(buf[j], this->file);
2706             }
2707             return ch;
2708         case CODECVT_noconv:
2709             if(i+1 < sizeof(wchar_t))
2710                 continue;
2711
2712             memcpy(&ch, buf, sizeof(wchar_t));
2713             return ch;
2714         default:
2715             return WEOF;
2716         }
2717     }
2718
2719     FIXME("buffer is too small\n");
2720     return WEOF;
2721 }
2722
2723 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEGXZ */
2724 /* ?underflow@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAGXZ */
2725 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEGXZ */
2726 /* ?underflow@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAGXZ */
2727 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_underflow, 4)
2728 unsigned short __thiscall basic_filebuf_wchar_underflow(basic_filebuf_wchar *this)
2729 {
2730     unsigned short ret;
2731
2732     TRACE("(%p)\n", this);
2733
2734     if(basic_streambuf_wchar_gptr(&this->base) < basic_streambuf_wchar_egptr(&this->base))
2735         return *basic_streambuf_wchar_gptr(&this->base);
2736
2737     ret = call_basic_streambuf_wchar_uflow(&this->base);
2738     if(ret != WEOF)
2739         ret = call_basic_streambuf_wchar_pbackfail(&this->base, ret);
2740     return ret;
2741 }
2742
2743 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2744 /* ?seekoff@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2745 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@JHH@Z */
2746 /* ?seekoff@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@_JHH@Z */
2747 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekoff, 24)
2748 fpos_int* __thiscall basic_filebuf_wchar_seekoff(basic_filebuf_wchar *this,
2749         fpos_int *ret, streamoff off, int way, int mode)
2750 {
2751     fpos_t pos;
2752
2753     TRACE("(%p %p %s %d %d)\n", this, ret, wine_dbgstr_longlong(off), way, mode);
2754
2755     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback) {
2756         if(way == SEEKDIR_cur)
2757             off -= sizeof(wchar_t);
2758
2759         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
2760     }
2761
2762     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
2763             || fseek(this->file, off, way)) {
2764         ret->off = -1;
2765         ret->pos = 0;
2766         ret->state = 0;
2767         return ret;
2768     }
2769
2770     fgetpos(this->file, &pos);
2771     ret->off = 0;
2772     ret->pos = pos;
2773     ret->state = this->state;
2774     return ret;
2775 }
2776
2777 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2778 /* ?seekpos@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2779 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAE?AV?$fpos@H@2@V32@H@Z */
2780 /* ?seekpos@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAA?AV?$fpos@H@2@V32@H@Z */
2781 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_seekpos, 36)
2782 fpos_int* __thiscall basic_filebuf_wchar_seekpos(basic_filebuf_wchar *this,
2783         fpos_int *ret, fpos_int pos, int mode)
2784 {
2785     fpos_t fpos;
2786
2787     TRACE("(%p %p %s %d)\n", this, ret, debugstr_fpos_int(&pos), mode);
2788
2789     if(!basic_filebuf_wchar_is_open(this) || !basic_filebuf_wchar__Endwrite(this)
2790             || fseek(this->file, (LONG)pos.pos, SEEK_SET)
2791             || (pos.off && fseek(this->file, pos.off, SEEK_CUR))) {
2792         ret->off = -1;
2793         ret->pos = 0;
2794         ret->state = 0;
2795         return ret;
2796     }
2797
2798     if(basic_streambuf_wchar_gptr(&this->base) == &this->putback)
2799         basic_streambuf_wchar_setg(&this->base, &this->putback, &this->putback+1, &this->putback+1);
2800
2801     fgetpos(this->file, &fpos);
2802     ret->off = 0;
2803     ret->pos = fpos;
2804     ret->state = this->state;
2805     return ret;
2806 }
2807
2808 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PA_WH@Z */
2809 /* ?setbuf@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEA_W_J@Z */
2810 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_setbuf, 16)
2811 basic_streambuf_wchar* __thiscall basic_filebuf_wchar_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
2812 {
2813     TRACE("(%p %p %s)\n", this, buf, wine_dbgstr_longlong(count));
2814
2815     if(!basic_filebuf_wchar_is_open(this))
2816         return NULL;
2817
2818     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
2819         return NULL;
2820
2821     basic_filebuf_wchar__Init(this, this->file, INITFL_open);
2822     return &this->base;
2823 }
2824
2825 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAGH@Z */
2826 /* ?setbuf@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAG_J@Z */
2827 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_setbuf, 16)
2828 basic_streambuf_wchar* __thiscall basic_filebuf_short_setbuf(basic_filebuf_wchar *this, wchar_t *buf, streamsize count)
2829 {
2830     TRACE("(%p %p %s)\n", this, buf, wine_dbgstr_longlong(count));
2831
2832     if(!basic_filebuf_wchar_is_open(this))
2833         return NULL;
2834
2835     if(setvbuf(this->file, (char*)buf, (buf==NULL && count==0) ? _IONBF : _IOFBF, count*sizeof(wchar_t)))
2836         return NULL;
2837
2838     basic_filebuf_short__Init(this, this->file, INITFL_open);
2839     return &this->base;
2840 }
2841
2842 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEHXZ */
2843 /* ?sync@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAHXZ */
2844 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEHXZ */
2845 /* ?sync@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAHXZ */
2846 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_sync, 4)
2847 int __thiscall basic_filebuf_wchar_sync(basic_filebuf_wchar *this)
2848 {
2849     TRACE("(%p)\n", this);
2850
2851     if(!basic_filebuf_wchar_is_open(this))
2852         return 0;
2853
2854     if(call_basic_streambuf_wchar_overflow(&this->base, WEOF) == WEOF)
2855         return 0;
2856     return fflush(this->file);
2857 }
2858
2859 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MAEXABVlocale@2@@Z */
2860 /* ?imbue@?$basic_filebuf@_WU?$char_traits@_W@std@@@std@@MEAAXAEBVlocale@2@@Z */
2861 DEFINE_THISCALL_WRAPPER(basic_filebuf_wchar_imbue, 8)
2862 void __thiscall basic_filebuf_wchar_imbue(basic_filebuf_wchar *this, const locale *loc)
2863 {
2864     TRACE("(%p %p)\n", this, loc);
2865     basic_filebuf_wchar__Initcvt(this, codecvt_wchar_use_facet(loc));
2866 }
2867
2868 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MAEXABVlocale@2@@Z */
2869 /* ?imbue@?$basic_filebuf@GU?$char_traits@G@std@@@std@@MEAAXAEBVlocale@2@@Z */
2870 DEFINE_THISCALL_WRAPPER(basic_filebuf_short_imbue, 8)
2871 void __thiscall basic_filebuf_short_imbue(basic_filebuf_wchar *this, const locale *loc)
2872 {
2873     TRACE("(%p %p)\n", this, loc);
2874     basic_filebuf_wchar__Initcvt(this, codecvt_short_use_facet(loc));
2875 }
2876
2877 /* ??0ios_base@std@@IAE@XZ */
2878 /* ??0ios_base@std@@IEAA@XZ */
2879 DEFINE_THISCALL_WRAPPER(ios_base_ctor, 4)
2880 ios_base* __thiscall ios_base_ctor(ios_base *this)
2881 {
2882     TRACE("(%p)\n", this);
2883     this->vtable = &MSVCP_ios_base_vtable;
2884     return this;
2885 }
2886
2887 /* ??0ios_base@std@@QAE@ABV01@@Z */
2888 /* ??0ios_base@std@@QEAA@AEBV01@@Z */
2889 DEFINE_THISCALL_WRAPPER(ios_base_copy_ctor, 8)
2890 ios_base* __thiscall ios_base_copy_ctor(ios_base *this, const ios_base *copy)
2891 {
2892     TRACE("(%p %p)\n", this, copy);
2893     *this = *copy;
2894     this->vtable = &MSVCP_ios_base_vtable;
2895     return this;
2896 }
2897
2898 /* ?_Callfns@ios_base@std@@AAEXW4event@12@@Z */
2899 /* ?_Callfns@ios_base@std@@AEAAXW4event@12@@Z */
2900 DEFINE_THISCALL_WRAPPER(ios_base_Callfns, 8)
2901 void __thiscall ios_base_Callfns(ios_base *this, IOS_BASE_event event)
2902 {
2903     IOS_BASE_fnarray *cur;
2904
2905     TRACE("(%p %x)\n", this, event);
2906
2907     for(cur=this->calls; cur; cur=cur->next)
2908         cur->event_handler(event, this, cur->index);
2909 }
2910
2911 /* ?_Tidy@ios_base@std@@AAAXXZ */
2912 /* ?_Tidy@ios_base@std@@AEAAXXZ */
2913 void CDECL ios_base_Tidy(ios_base *this)
2914 {
2915     IOS_BASE_iosarray *arr_cur, *arr_next;
2916     IOS_BASE_fnarray *event_cur, *event_next;
2917
2918     TRACE("(%p)\n", this);
2919
2920     ios_base_Callfns(this, EVENT_erase_event);
2921
2922     for(arr_cur=this->arr; arr_cur; arr_cur=arr_next) {
2923         arr_next = arr_cur->next;
2924         MSVCRT_operator_delete(arr_cur);
2925     }
2926     this->arr = NULL;
2927
2928     for(event_cur=this->calls; event_cur; event_cur=event_next) {
2929         event_next = event_cur->next;
2930         MSVCRT_operator_delete(event_cur);
2931     }
2932     this->calls = NULL;
2933 }
2934
2935 /* ?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z */
2936 /* ?_Ios_base_dtor@ios_base@std@@CAXPEAV12@@Z */
2937 void CDECL ios_base_Ios_base_dtor(ios_base *obj)
2938 {
2939     TRACE("(%p)\n", obj);
2940     if(obj->loc) {
2941         locale_dtor(obj->loc);
2942         MSVCRT_operator_delete(obj->loc);
2943     }
2944     ios_base_Tidy(obj);
2945 }
2946
2947 /* ??1ios_base@std@@UAE@XZ */
2948 /* ??1ios_base@std@@UEAA@XZ */
2949 DEFINE_THISCALL_WRAPPER(ios_base_dtor, 4)
2950 void __thiscall ios_base_dtor(ios_base *this)
2951 {
2952     ios_base_Ios_base_dtor(this);
2953 }
2954
2955 DEFINE_THISCALL_WRAPPER(ios_base_vector_dtor, 8)
2956 ios_base* __thiscall ios_base_vector_dtor(ios_base *this, unsigned int flags)
2957 {
2958     TRACE("(%p %x)\n", this, flags);
2959     if(flags & 2) {
2960         /* we have an array, with the number of elements stored before the first object */
2961         INT_PTR i, *ptr = (INT_PTR *)this-1;
2962
2963         for(i=*ptr-1; i>=0; i--)
2964             ios_base_dtor(this+i);
2965         MSVCRT_operator_delete(ptr);
2966     } else {
2967         ios_base_dtor(this);
2968         if(flags & 1)
2969             MSVCRT_operator_delete(this);
2970     }
2971
2972     return this;
2973 }
2974
2975 DEFINE_THISCALL_WRAPPER(iosb_vector_dtor, 8)
2976 void* __thiscall iosb_vector_dtor(void *this, unsigned int flags)
2977 {
2978     TRACE("(%p %x)\n", this, flags);
2979     if(flags & 2) {
2980         INT_PTR *ptr = (INT_PTR *)this-1;
2981         MSVCRT_operator_delete(ptr);
2982     } else {
2983         if(flags & 1)
2984             MSVCRT_operator_delete(this);
2985     }
2986
2987     return this;
2988 }
2989
2990 /* ?_Findarr@ios_base@std@@AAEAAU_Iosarray@12@H@Z */
2991 /* ?_Findarr@ios_base@std@@AEAAAEAU_Iosarray@12@H@Z */
2992 DEFINE_THISCALL_WRAPPER(ios_base_Findarr, 8)
2993 IOS_BASE_iosarray* __thiscall ios_base_Findarr(ios_base *this, int index)
2994 {
2995     IOS_BASE_iosarray *p;
2996
2997     TRACE("(%p %d)\n", this, index);
2998
2999     for(p=this->arr; p; p=p->next) {
3000         if(p->index == index)
3001             return p;
3002     }
3003
3004     for(p=this->arr; p; p=p->next) {
3005         if(!p->long_val && !p->ptr_val) {
3006             p->index = index;
3007             return p;
3008         }
3009     }
3010
3011     p = MSVCRT_operator_new(sizeof(IOS_BASE_iosarray));
3012     p->next = this->arr;
3013     p->index = index;
3014     p->long_val = 0;
3015     p->ptr_val = NULL;
3016     this->arr = p;
3017     return p;
3018 }
3019
3020 /* ?iword@ios_base@std@@QAEAAJH@Z */
3021 /* ?iword@ios_base@std@@QEAAAEAJH@Z */
3022 DEFINE_THISCALL_WRAPPER(ios_base_iword, 8)
3023 LONG* __thiscall ios_base_iword(ios_base *this, int index)
3024 {
3025     TRACE("(%p %d)\n", this, index);
3026     return &ios_base_Findarr(this, index)->long_val;
3027 }
3028
3029 /* ?pword@ios_base@std@@QAEAAPAXH@Z */
3030 /* ?pword@ios_base@std@@QEAAAEAPEAXH@Z */
3031 DEFINE_THISCALL_WRAPPER(ios_base_pword, 8)
3032 void** __thiscall ios_base_pword(ios_base *this, int index)
3033 {
3034     TRACE("(%p %d)\n", this, index);
3035     return &ios_base_Findarr(this, index)->ptr_val;
3036 }
3037
3038 /* ?register_callback@ios_base@std@@QAEXP6AXW4event@12@AAV12@H@ZH@Z */
3039 /* ?register_callback@ios_base@std@@QEAAXP6AXW4event@12@AEAV12@H@ZH@Z */
3040 DEFINE_THISCALL_WRAPPER(ios_base_register_callback, 12)
3041 void __thiscall ios_base_register_callback(ios_base *this, IOS_BASE_event_callback callback, int index)
3042 {
3043     IOS_BASE_fnarray *event;
3044
3045     TRACE("(%p %p %d)\n", this, callback, index);
3046
3047     event = MSVCRT_operator_new(sizeof(IOS_BASE_fnarray));
3048     event->next = this->calls;
3049     event->index = index;
3050     event->event_handler = callback;
3051     this->calls = event;
3052 }
3053
3054 /* ?clear@ios_base@std@@QAEXH_N@Z */
3055 /* ?clear@ios_base@std@@QEAAXH_N@Z */
3056 DEFINE_THISCALL_WRAPPER(ios_base_clear_reraise, 12)
3057 void __thiscall ios_base_clear_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
3058 {
3059     TRACE("(%p %x %x)\n", this, state, reraise);
3060
3061     this->state = state & IOSTATE_mask;
3062     if(!(this->state & this->except))
3063         return;
3064
3065     if(reraise)
3066         throw_exception(EXCEPTION_RERAISE, NULL);
3067     else if(this->state & this->except & IOSTATE_eofbit)
3068         throw_exception(EXCEPTION_FAILURE, "eofbit is set");
3069     else if(this->state & this->except & IOSTATE_failbit)
3070         throw_exception(EXCEPTION_FAILURE, "failbit is set");
3071     else if(this->state & this->except & IOSTATE_badbit)
3072         throw_exception(EXCEPTION_FAILURE, "badbit is set");
3073     else if(this->state & this->except & IOSTATE__Hardfail)
3074         throw_exception(EXCEPTION_FAILURE, "_Hardfail is set");
3075 }
3076
3077 /* ?clear@ios_base@std@@QAEXH@Z */
3078 /* ?clear@ios_base@std@@QEAAXH@Z */
3079 DEFINE_THISCALL_WRAPPER(ios_base_clear, 8)
3080 void __thiscall ios_base_clear(ios_base *this, IOSB_iostate state)
3081 {
3082     ios_base_clear_reraise(this, state, FALSE);
3083 }
3084
3085 /* ?clear@ios_base@std@@QAEXI@Z */
3086 /* ?clear@ios_base@std@@QEAAXI@Z */
3087 DEFINE_THISCALL_WRAPPER(ios_base_clear_unsigned, 8)
3088 void __thiscall ios_base_clear_unsigned(ios_base *this, unsigned int state)
3089 {
3090     ios_base_clear_reraise(this, (IOSB_iostate)state, FALSE);
3091 }
3092
3093 /* ?exceptions@ios_base@std@@QAEXH@Z */
3094 /* ?exceptions@ios_base@std@@QEAAXH@Z */
3095 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set, 8)
3096 void __thiscall ios_base_exceptions_set(ios_base *this, IOSB_iostate state)
3097 {
3098     TRACE("(%p %x)\n", this, state);
3099     this->except = state & IOSTATE_mask;
3100     ios_base_clear(this, this->state);
3101 }
3102
3103 /* ?exceptions@ios_base@std@@QAEXI@Z */
3104 /* ?exceptions@ios_base@std@@QEAAXI@Z */
3105 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_set_unsigned, 8)
3106 void __thiscall ios_base_exceptions_set_unsigned(ios_base *this, unsigned int state)
3107 {
3108     TRACE("(%p %x)\n", this, state);
3109     ios_base_exceptions_set(this, state);
3110 }
3111
3112 /* ?exceptions@ios_base@std@@QBEHXZ */
3113 /* ?exceptions@ios_base@std@@QEBAHXZ */
3114 DEFINE_THISCALL_WRAPPER(ios_base_exceptions_get, 4)
3115 IOSB_iostate __thiscall ios_base_exceptions_get(ios_base *this)
3116 {
3117     TRACE("(%p)\n", this);
3118     return this->except;
3119 }
3120
3121 /* ?copyfmt@ios_base@std@@QAEAAV12@ABV12@@Z */
3122 /* ?copyfmt@ios_base@std@@QEAAAEAV12@AEBV12@@Z */
3123 DEFINE_THISCALL_WRAPPER(ios_base_copyfmt, 8)
3124 ios_base* __thiscall ios_base_copyfmt(ios_base *this, const ios_base *rhs)
3125 {
3126     TRACE("(%p %p)\n", this, rhs);
3127
3128     if(this != rhs) {
3129         IOS_BASE_iosarray *arr_cur;
3130         IOS_BASE_fnarray *event_cur;
3131
3132         ios_base_Tidy(this);
3133
3134         for(arr_cur=rhs->arr; arr_cur; arr_cur=arr_cur->next) {
3135             if(arr_cur->long_val)
3136                 *ios_base_iword(this, arr_cur->index) = arr_cur->long_val;
3137             if(arr_cur->ptr_val)
3138                 *ios_base_pword(this, arr_cur->index) = arr_cur->ptr_val;
3139         }
3140         this->stdstr = rhs->stdstr;
3141         this->fmtfl = rhs->fmtfl;
3142         this->prec = rhs->prec;
3143         this->wide = rhs->wide;
3144         locale_operator_assign(this->loc, rhs->loc);
3145
3146         for(event_cur=rhs->calls; event_cur; event_cur=event_cur->next)
3147             ios_base_register_callback(this, event_cur->event_handler, event_cur->index);
3148
3149         ios_base_Callfns(this, EVENT_copyfmt_event);
3150         ios_base_exceptions_set(this, rhs->except);
3151     }
3152
3153     return this;
3154 }
3155
3156 /* ??4ios_base@std@@QAEAAV01@ABV01@@Z */
3157 /* ??4ios_base@std@@QEAAAEAV01@AEBV01@@Z */
3158 DEFINE_THISCALL_WRAPPER(ios_base_assign, 8)
3159 ios_base* __thiscall ios_base_assign(ios_base *this, const ios_base *right)
3160 {
3161     TRACE("(%p %p)\n", this, right);
3162
3163     if(this != right) {
3164         this->state = right->state;
3165         ios_base_copyfmt(this, right);
3166     }
3167
3168     return this;
3169 }
3170
3171 /* ?fail@ios_base@std@@QBE_NXZ */
3172 /* ?fail@ios_base@std@@QEBA_NXZ */
3173 DEFINE_THISCALL_WRAPPER(ios_base_fail, 4)
3174 MSVCP_bool __thiscall ios_base_fail(const ios_base *this)
3175 {
3176     TRACE("(%p)\n", this);
3177     return (this->state & (IOSTATE_failbit|IOSTATE_badbit)) != 0;
3178 }
3179
3180 /* ??7ios_base@std@@QBE_NXZ */
3181 /* ??7ios_base@std@@QEBA_NXZ */
3182 DEFINE_THISCALL_WRAPPER(ios_base_op_succ, 4)
3183 MSVCP_bool __thiscall ios_base_op_succ(const ios_base *this)
3184 {
3185     TRACE("(%p)\n", this);
3186     return ios_base_fail(this);
3187 }
3188
3189 /* ??Bios_base@std@@QBEPAXXZ */
3190 /* ??Bios_base@std@@QEBAPEAXXZ */
3191 DEFINE_THISCALL_WRAPPER(ios_base_op_fail, 4)
3192 void* __thiscall ios_base_op_fail(const ios_base *this)
3193 {
3194     TRACE("(%p)\n", this);
3195     return ios_base_fail(this) ? NULL : (void*)this;
3196 }
3197
3198 /* ?_Addstd@ios_base@std@@SAXPAV12@@Z */
3199 /* ?_Addstd@ios_base@std@@SAXPEAV12@@Z */
3200 void CDECL ios_base_Addstd(ios_base *add)
3201 {
3202     FIXME("(%p) stub\n", add);
3203 }
3204
3205 /* ?_Init@ios_base@std@@IAEXXZ */
3206 /* ?_Init@ios_base@std@@IEAAXXZ */
3207 DEFINE_THISCALL_WRAPPER(ios_base__Init, 4)
3208 void __thiscall ios_base__Init(ios_base *this)
3209 {
3210     TRACE("(%p)\n", this);
3211
3212     this->stdstr = 0;
3213     this->state = this->except = IOSTATE_goodbit;
3214     this->fmtfl = FMTFLAG_skipws | FMTFLAG_dec;
3215     this->prec = 6;
3216     this->wide = 0;
3217     this->arr = NULL;
3218     this->calls = NULL;
3219     this->loc = MSVCRT_operator_new(sizeof(locale));
3220     locale_ctor(this->loc);
3221 }
3222
3223 /* ?bad@ios_base@std@@QBE_NXZ */
3224 /* ?bad@ios_base@std@@QEBA_NXZ */
3225 DEFINE_THISCALL_WRAPPER(ios_base_bad, 4)
3226 MSVCP_bool __thiscall ios_base_bad(const ios_base *this)
3227 {
3228     TRACE("(%p)\n", this);
3229     return (this->state & IOSTATE_badbit) != 0;
3230 }
3231
3232 /* ?eof@ios_base@std@@QBE_NXZ */
3233 /* ?eof@ios_base@std@@QEBA_NXZ */
3234 DEFINE_THISCALL_WRAPPER(ios_base_eof, 4)
3235 MSVCP_bool __thiscall ios_base_eof(const ios_base *this)
3236 {
3237     TRACE("(%p)\n", this);
3238     return (this->state & IOSTATE_eofbit) != 0;
3239 }
3240
3241 /* ?flags@ios_base@std@@QAEHH@Z */
3242 /* ?flags@ios_base@std@@QEAAHH@Z */
3243 DEFINE_THISCALL_WRAPPER(ios_base_flags_set, 8)
3244 IOSB_fmtflags __thiscall ios_base_flags_set(ios_base *this, IOSB_fmtflags flags)
3245 {
3246     IOSB_fmtflags ret = this->fmtfl;
3247
3248     TRACE("(%p %x)\n", this, flags);
3249
3250     this->fmtfl = flags & FMTFLAG_mask;
3251     return ret;
3252 }
3253
3254 /* ?flags@ios_base@std@@QBEHXZ */
3255 /* ?flags@ios_base@std@@QEBAHXZ */
3256 DEFINE_THISCALL_WRAPPER(ios_base_flags_get, 4)
3257 IOSB_fmtflags __thiscall ios_base_flags_get(const ios_base *this)
3258 {
3259     TRACE("(%p)\n", this);
3260     return this->fmtfl;
3261 }
3262
3263 /* ?getloc@ios_base@std@@QBE?AVlocale@2@XZ */
3264 /* ?getloc@ios_base@std@@QEBA?AVlocale@2@XZ */
3265 DEFINE_THISCALL_WRAPPER(ios_base_getloc, 8)
3266 locale* __thiscall ios_base_getloc(const ios_base *this, locale *ret)
3267 {
3268     TRACE("(%p)\n", this);
3269     return locale_copy_ctor(ret, this->loc);
3270 }
3271
3272 /* ?good@ios_base@std@@QBE_NXZ */
3273 /* ?good@ios_base@std@@QEBA_NXZ */
3274 DEFINE_THISCALL_WRAPPER(ios_base_good, 4)
3275 MSVCP_bool __thiscall ios_base_good(const ios_base *this)
3276 {
3277     TRACE("(%p)\n", this);
3278     return this->state == IOSTATE_goodbit;
3279 }
3280
3281 /* ?imbue@ios_base@std@@QAE?AVlocale@2@ABV32@@Z */
3282 /* ?imbue@ios_base@std@@QEAA?AVlocale@2@AEBV32@@Z */
3283 DEFINE_THISCALL_WRAPPER(ios_base_imbue, 12)
3284 locale* __thiscall ios_base_imbue(ios_base *this, locale *ret, const locale *loc)
3285 {
3286     TRACE("(%p %p)\n", this, loc);
3287     *ret = *this->loc;
3288     locale_copy_ctor(this->loc, loc);
3289     return ret;
3290 }
3291
3292 /* ?precision@ios_base@std@@QAEHH@Z */
3293 /* ?precision@ios_base@std@@QEAA_J_J@Z */
3294 DEFINE_THISCALL_WRAPPER(ios_base_precision_set, 12)
3295 streamsize __thiscall ios_base_precision_set(ios_base *this, streamsize precision)
3296 {
3297     streamsize ret = this->prec;
3298
3299     TRACE("(%p %s)\n", this, wine_dbgstr_longlong(precision));
3300
3301     this->prec = precision;
3302     return ret;
3303 }
3304
3305 /* ?precision@ios_base@std@@QBEHXZ */
3306 /* ?precision@ios_base@std@@QEBA_JXZ */
3307 DEFINE_THISCALL_WRAPPER(ios_base_precision_get, 4)
3308 streamsize __thiscall ios_base_precision_get(const ios_base *this)
3309 {
3310     TRACE("(%p)\n", this);
3311     return this->prec;
3312 }
3313
3314 /* ?rdstate@ios_base@std@@QBEHXZ */
3315 /* ?rdstate@ios_base@std@@QEBAHXZ */
3316 DEFINE_THISCALL_WRAPPER(ios_base_rdstate, 4)
3317 IOSB_iostate __thiscall ios_base_rdstate(const ios_base *this)
3318 {
3319     TRACE("(%p)\n", this);
3320     return this->state;
3321 }
3322
3323 /* ?setf@ios_base@std@@QAEHHH@Z */
3324 /* ?setf@ios_base@std@@QEAAHHH@Z */
3325 DEFINE_THISCALL_WRAPPER(ios_base_setf_mask, 12)
3326 IOSB_fmtflags __thiscall ios_base_setf_mask(ios_base *this, IOSB_fmtflags flags, IOSB_fmtflags mask)
3327 {
3328     IOSB_fmtflags ret = this->fmtfl;
3329
3330     TRACE("(%p %x %x)\n", this, flags, mask);
3331
3332     this->fmtfl = (this->fmtfl & (~mask)) | (flags & mask & FMTFLAG_mask);
3333     return ret;
3334 }
3335
3336 /* ?setf@ios_base@std@@QAEHH@Z */
3337 /* ?setf@ios_base@std@@QEAAHH@Z */
3338 DEFINE_THISCALL_WRAPPER(ios_base_setf, 8)
3339 IOSB_fmtflags __thiscall ios_base_setf(ios_base *this, IOSB_fmtflags flags)
3340 {
3341     return ios_base_setf_mask(this, flags, ~0);
3342 }
3343
3344 /* ?setstate@ios_base@std@@QAEXH_N@Z */
3345 /* ?setstate@ios_base@std@@QEAAXH_N@Z */
3346 DEFINE_THISCALL_WRAPPER(ios_base_setstate_reraise, 12)
3347 void __thiscall ios_base_setstate_reraise(ios_base *this, IOSB_iostate state, MSVCP_bool reraise)
3348 {
3349     TRACE("(%p %x %x)\n", this, state, reraise);
3350
3351     if(state != IOSTATE_goodbit)
3352         ios_base_clear_reraise(this, this->state | state, reraise);
3353 }
3354
3355 /* ?setstate@ios_base@std@@QAEXH@Z */
3356 /* ?setstate@ios_base@std@@QEAAXH@Z */
3357 DEFINE_THISCALL_WRAPPER(ios_base_setstate, 8)
3358 void __thiscall ios_base_setstate(ios_base *this, IOSB_iostate state)
3359 {
3360     ios_base_setstate_reraise(this, state, FALSE);
3361 }
3362
3363 /* ?setstate@ios_base@std@@QAEXI@Z */
3364 /* ?setstate@ios_base@std@@QEAAXI@Z */
3365 DEFINE_THISCALL_WRAPPER(ios_base_setstate_unsigned, 8)
3366 void __thiscall ios_base_setstate_unsigned(ios_base *this, unsigned int state)
3367 {
3368     ios_base_setstate_reraise(this, (IOSB_iostate)state, FALSE);
3369 }
3370
3371 /* ?sync_with_stdio@ios_base@std@@SA_N_N@Z */
3372 MSVCP_bool CDECL ios_base_sync_with_stdio(MSVCP_bool sync)
3373 {
3374     _Lockit lock;
3375     MSVCP_bool ret;
3376
3377     TRACE("(%x)\n", sync);
3378
3379     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
3380     ret = ios_base_Sync;
3381     ios_base_Sync = sync;
3382     _Lockit_dtor(&lock);
3383     return ret;
3384 }
3385
3386 /* ?unsetf@ios_base@std@@QAEXH@Z */
3387 /* ?unsetf@ios_base@std@@QEAAXH@Z */
3388 DEFINE_THISCALL_WRAPPER(ios_base_unsetf, 8)
3389 void __thiscall ios_base_unsetf(ios_base *this, IOSB_fmtflags flags)
3390 {
3391     TRACE("(%p %x)\n", this, flags);
3392     this->fmtfl &= ~flags;
3393 }
3394
3395 /* ?width@ios_base@std@@QAEHH@Z */
3396 /* ?width@ios_base@std@@QEAA_J_J@Z */
3397 DEFINE_THISCALL_WRAPPER(ios_base_width_set, 12)
3398 streamsize __thiscall ios_base_width_set(ios_base *this, streamsize width)
3399 {
3400     streamsize ret = this->wide;
3401
3402     TRACE("(%p %s)\n", this, wine_dbgstr_longlong(width));
3403
3404     this->wide = width;
3405     return ret;
3406 }
3407
3408 /* ?width@ios_base@std@@QBEHXZ */
3409 /* ?width@ios_base@std@@QEBA_JXZ */
3410 DEFINE_THISCALL_WRAPPER(ios_base_width_get, 4)
3411 streamsize __thiscall ios_base_width_get(ios_base *this)
3412 {
3413     TRACE("(%p)\n", this);
3414     return this->wide;
3415 }
3416
3417 /* ?xalloc@ios_base@std@@SAHXZ */
3418 int CDECL ios_base_xalloc(void)
3419 {
3420     _Lockit lock;
3421     int ret;
3422
3423     TRACE("\n");
3424
3425     _Lockit_ctor_locktype(&lock, _LOCK_STREAM);
3426     ret = ios_base_Index++;
3427     _Lockit_dtor(&lock);
3428     return ret;
3429 }
3430
3431 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IAE@XZ */
3432 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@IEAA@XZ */
3433 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor, 4)
3434 basic_ios_char* __thiscall basic_ios_char_ctor(basic_ios_char *this)
3435 {
3436     TRACE("(%p)\n", this);
3437
3438     ios_base_ctor(&this->base);
3439     this->base.vtable = &MSVCP_basic_ios_char_vtable;
3440     return this;
3441 }
3442
3443 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IAEXPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
3444 /* ?init@?$basic_ios@DU?$char_traits@D@std@@@std@@IEAAXPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@_N@Z */
3445 DEFINE_THISCALL_WRAPPER(basic_ios_char_init, 12)
3446 void __thiscall basic_ios_char_init(basic_ios_char *this, basic_streambuf_char *streambuf, MSVCP_bool isstd)
3447 {
3448     TRACE("(%p %p %x)\n", this, streambuf, isstd);
3449     ios_base__Init(&this->base);
3450     this->strbuf = streambuf;
3451     this->stream = NULL;
3452     this->fillch = ' ';
3453
3454     if(!streambuf)
3455         ios_base_setstate(&this->base, IOSTATE_badbit);
3456
3457     if(isstd)
3458         FIXME("standard streams not handled yet\n");
3459 }
3460
3461 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
3462 /* ??0?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
3463 DEFINE_THISCALL_WRAPPER(basic_ios_char_ctor_streambuf, 8)
3464 basic_ios_char* __thiscall basic_ios_char_ctor_streambuf(basic_ios_char *this, basic_streambuf_char *strbuf)
3465 {
3466     TRACE("(%p %p)\n", this, strbuf);
3467
3468     basic_ios_char_ctor(this);
3469     basic_ios_char_init(this, strbuf, FALSE);
3470     return this;
3471 }
3472
3473 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UAE@XZ */
3474 /* ??1?$basic_ios@DU?$char_traits@D@std@@@std@@UEAA@XZ */
3475 DEFINE_THISCALL_WRAPPER(basic_ios_char_dtor, 4)
3476 void __thiscall basic_ios_char_dtor(basic_ios_char *this)
3477 {
3478     TRACE("(%p)\n", this);
3479     ios_base_dtor(&this->base);
3480 }
3481
3482 DEFINE_THISCALL_WRAPPER(basic_ios_char_vector_dtor, 8)
3483 basic_ios_char* __thiscall basic_ios_char_vector_dtor(basic_ios_char *this, unsigned int flags)
3484 {
3485     TRACE("(%p %x)\n", this, flags);
3486     if(flags & 2) {
3487         /* we have an array, with the number of elements stored before the first object */
3488         INT_PTR i, *ptr = (INT_PTR *)this-1;
3489
3490         for(i=*ptr-1; i>=0; i--)
3491             basic_ios_char_dtor(this+i);
3492         MSVCRT_operator_delete(ptr);
3493     } else {
3494         basic_ios_char_dtor(this);
3495         if(flags & 1)
3496             MSVCRT_operator_delete(this);
3497     }
3498
3499     return this;
3500 }
3501
3502 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
3503 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
3504 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear_reraise, 12)
3505 void __thiscall basic_ios_char_clear_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
3506 {
3507     TRACE("(%p %x %x)\n", this, state, reraise);
3508     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
3509 }
3510
3511 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
3512 /* ?clear@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
3513 DEFINE_THISCALL_WRAPPER(basic_ios_char_clear, 8)
3514 void __thiscall basic_ios_char_clear(basic_ios_char *this, unsigned int state)
3515 {
3516     basic_ios_char_clear_reraise(this, (IOSB_iostate)state, FALSE);
3517 }
3518
3519 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEAAV12@ABV12@@Z */
3520 /* ?copyfmt@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEBV12@@Z */
3521 DEFINE_THISCALL_WRAPPER(basic_ios_char_copyfmt, 8)
3522 basic_ios_char* __thiscall basic_ios_char_copyfmt(basic_ios_char *this, basic_ios_char *copy)
3523 {
3524     TRACE("(%p %p)\n", this, copy);
3525     if(this == copy)
3526         return this;
3527
3528     this->stream = copy->stream;
3529     this->fillch = copy->fillch;
3530     ios_base_copyfmt(&this->base, &copy->base);
3531     return this;
3532 }
3533
3534 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEDD@Z */
3535 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAADD@Z */
3536 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_set, 8)
3537 char __thiscall basic_ios_char_fill_set(basic_ios_char *this, char fill)
3538 {
3539     char ret = this->fillch;
3540
3541     TRACE("(%p %c)\n", this, fill);
3542
3543     this->fillch = fill;
3544     return ret;
3545 }
3546
3547 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ */
3548 /* ?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADXZ */
3549 DEFINE_THISCALL_WRAPPER(basic_ios_char_fill_get, 4)
3550 char __thiscall basic_ios_char_fill_get(basic_ios_char *this)
3551 {
3552     TRACE("(%p)\n", this);
3553     return this->fillch;
3554 }
3555
3556 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
3557 /* ?imbue@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
3558 DEFINE_THISCALL_WRAPPER(basic_ios_char_imbue, 12)
3559 locale *__thiscall basic_ios_char_imbue(basic_ios_char *this, locale *ret, const locale *loc)
3560 {
3561     TRACE("(%p %p %p)\n", this, ret, loc);
3562
3563     if(this->strbuf) {
3564         basic_streambuf_char_pubimbue(this->strbuf, ret, loc);
3565         locale_dtor(ret);
3566     }
3567
3568     return ios_base_imbue(&this->base, ret, loc);
3569 }
3570
3571 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDDD@Z */
3572 /* ?narrow@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADDD@Z */
3573 DEFINE_THISCALL_WRAPPER(basic_ios_char_narrow, 12)
3574 char __thiscall basic_ios_char_narrow(basic_ios_char *this, char ch, char def)
3575 {
3576     TRACE("(%p %c %c)\n", this, ch, def);
3577     return ctype_char_narrow_ch(ctype_char_use_facet(this->strbuf->loc), ch, def);
3578 }
3579
3580 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PAV32@@Z */
3581 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAV32@@Z */
3582 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_set, 8)
3583 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_set(basic_ios_char *this, basic_streambuf_char *streambuf)
3584 {
3585     basic_streambuf_char *ret = this->strbuf;
3586
3587     TRACE("(%p %p)\n", this, streambuf);
3588
3589     this->strbuf = streambuf;
3590     basic_ios_char_clear(this, IOSTATE_goodbit);
3591     return ret;
3592 }
3593
3594 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
3595 /* ?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ */
3596 DEFINE_THISCALL_WRAPPER(basic_ios_char_rdbuf_get, 4)
3597 basic_streambuf_char* __thiscall basic_ios_char_rdbuf_get(const basic_ios_char *this)
3598 {
3599     TRACE("(%p)\n", this);
3600     return this->strbuf;
3601 }
3602
3603 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z */
3604 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXH_N@Z */
3605 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate_reraise, 12)
3606 void __thiscall basic_ios_char_setstate_reraise(basic_ios_char *this, IOSB_iostate state, MSVCP_bool reraise)
3607 {
3608     TRACE("(%p %x %x)\n", this, state, reraise);
3609
3610     if(state != IOSTATE_goodbit)
3611         basic_ios_char_clear_reraise(this, this->base.state | state, reraise);
3612 }
3613
3614 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXI@Z */
3615 /* ?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAXI@Z */
3616 DEFINE_THISCALL_WRAPPER(basic_ios_char_setstate, 8)
3617 void __thiscall basic_ios_char_setstate(basic_ios_char *this, unsigned int state)
3618 {
3619     basic_ios_char_setstate_reraise(this, (IOSB_iostate)state, FALSE);
3620 }
3621
3622 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@PAV32@@Z */
3623 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEAAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@PEAV32@@Z */
3624 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_set, 8)
3625 basic_ostream_char* __thiscall basic_ios_char_tie_set(basic_ios_char *this, basic_ostream_char *ostream)
3626 {
3627     basic_ostream_char *ret = this->stream;
3628
3629     TRACE("(%p %p)\n", this, ostream);
3630
3631     this->stream = ostream;
3632     return ret;
3633 }
3634
3635 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
3636 /* ?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBAPEAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ */
3637 DEFINE_THISCALL_WRAPPER(basic_ios_char_tie_get, 4)
3638 basic_ostream_char* __thiscall basic_ios_char_tie_get(const basic_ios_char *this)
3639 {
3640     TRACE("(%p)\n", this);
3641     return this->stream;
3642 }
3643
3644 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDD@Z */
3645 /* ?widen@?$basic_ios@DU?$char_traits@D@std@@@std@@QEBADD@Z */
3646 DEFINE_THISCALL_WRAPPER(basic_ios_char_widen, 8)
3647 char __thiscall basic_ios_char_widen(basic_ios_char *this, char ch)
3648 {
3649     TRACE("(%p %c)\n", this, ch);
3650     return ctype_char_widen_ch(ctype_char_use_facet(this->strbuf->loc), ch);
3651 }
3652
3653
3654 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAE@XZ */
3655 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAA@XZ */
3656 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor, 4)
3657 basic_ios_wchar* __thiscall basic_ios_wchar_ctor(basic_ios_wchar *this)
3658 {
3659     TRACE("(%p)\n", this);
3660
3661     ios_base_ctor(&this->base);
3662     this->base.vtable = &MSVCP_basic_ios_wchar_vtable;
3663     return this;
3664 }
3665
3666 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IAE@XZ */
3667 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@IEAA@XZ */
3668 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor, 4)
3669 basic_ios_wchar* __thiscall basic_ios_short_ctor(basic_ios_wchar *this)
3670 {
3671     basic_ios_wchar_ctor(this);
3672     this->base.vtable = &MSVCP_basic_ios_short_vtable;
3673     return this;
3674 }
3675
3676 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IAEXPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
3677 /* ?init@?$basic_ios@_WU?$char_traits@_W@std@@@std@@IEAAXPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_N@Z */
3678 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IAEXPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
3679 /* ?init@?$basic_ios@GU?$char_traits@G@std@@@std@@IEAAXPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@_N@Z */
3680 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_init, 12)
3681 void __thiscall basic_ios_wchar_init(basic_ios_wchar *this, basic_streambuf_wchar *streambuf, MSVCP_bool isstd)
3682 {
3683     TRACE("(%p %p %x)\n", this, streambuf, isstd);
3684     ios_base__Init(&this->base);
3685     this->strbuf = streambuf;
3686     this->stream = NULL;
3687     this->fillch = ' ';
3688
3689     if(!streambuf)
3690         ios_base_setstate(&this->base, IOSTATE_badbit);
3691
3692     if(isstd)
3693         FIXME("standard streams not handled yet\n");
3694 }
3695
3696 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
3697 /* ??0?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
3698 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_ctor_streambuf, 8)
3699 basic_ios_wchar* __thiscall basic_ios_wchar_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
3700 {
3701     TRACE("(%p %p)\n", this, strbuf);
3702
3703     basic_ios_wchar_ctor(this);
3704     basic_ios_wchar_init(this, strbuf, FALSE);
3705     return this;
3706 }
3707
3708 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
3709 /* ??0?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
3710 DEFINE_THISCALL_WRAPPER(basic_ios_short_ctor_streambuf, 8)
3711 basic_ios_wchar* __thiscall basic_ios_short_ctor_streambuf(basic_ios_wchar *this, basic_streambuf_wchar *strbuf)
3712 {
3713     basic_ios_wchar_ctor_streambuf(this, strbuf);
3714     this->base.vtable = &MSVCP_basic_ios_short_vtable;
3715     return this;
3716 }
3717
3718 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
3719 /* ??1?$basic_ios@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
3720 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UAE@XZ */
3721 /* ??1?$basic_ios@GU?$char_traits@G@std@@@std@@UEAA@XZ */
3722 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_dtor, 4)
3723 void __thiscall basic_ios_wchar_dtor(basic_ios_wchar *this)
3724 {
3725     TRACE("(%p)\n", this);
3726     ios_base_dtor(&this->base);
3727 }
3728
3729 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_vector_dtor, 8)
3730 basic_ios_wchar* __thiscall basic_ios_wchar_vector_dtor(basic_ios_wchar *this, unsigned int flags)
3731 {
3732     TRACE("(%p %x)\n", this, flags);
3733     if(flags & 2) {
3734         /* we have an array, with the number of elements stored before the first object */
3735         INT_PTR i, *ptr = (INT_PTR *)this-1;
3736
3737         for(i=*ptr-1; i>=0; i--)
3738             basic_ios_wchar_dtor(this+i);
3739         MSVCRT_operator_delete(ptr);
3740     } else {
3741         basic_ios_wchar_dtor(this);
3742         if(flags & 1)
3743             MSVCRT_operator_delete(this);
3744     }
3745
3746     return this;
3747 }
3748
3749 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
3750 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
3751 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
3752 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
3753 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear_reraise, 12)
3754 void __thiscall basic_ios_wchar_clear_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
3755 {
3756     TRACE("(%p %x %x)\n", this, state, reraise);
3757     ios_base_clear_reraise(&this->base, state | (this->strbuf ? IOSTATE_goodbit : IOSTATE_badbit), reraise);
3758 }
3759
3760 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
3761 /* ?clear@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
3762 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
3763 /* ?clear@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
3764 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_clear, 8)
3765 void __thiscall basic_ios_wchar_clear(basic_ios_wchar *this, unsigned int state)
3766 {
3767     basic_ios_wchar_clear_reraise(this, (IOSB_iostate)state, FALSE);
3768 }
3769
3770 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEAAV12@ABV12@@Z */
3771 /* ?copyfmt@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEBV12@@Z */
3772 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEAAV12@ABV12@@Z */
3773 /* ?copyfmt@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEBV12@@Z */
3774 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_copyfmt, 8)
3775 basic_ios_wchar* __thiscall basic_ios_wchar_copyfmt(basic_ios_wchar *this, basic_ios_wchar *copy)
3776 {
3777     TRACE("(%p %p)\n", this, copy);
3778     if(this == copy)
3779         return this;
3780
3781     this->stream = copy->stream;
3782     this->fillch = copy->fillch;
3783     ios_base_copyfmt(&this->base, &copy->base);
3784     return this;
3785 }
3786
3787 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE_W_W@Z */
3788 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA_W_W@Z */
3789 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEGG@Z */
3790 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAGG@Z */
3791 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_set, 8)
3792 wchar_t __thiscall basic_ios_wchar_fill_set(basic_ios_wchar *this, wchar_t fill)
3793 {
3794     wchar_t ret = this->fillch;
3795
3796     TRACE("(%p %c)\n", this, fill);
3797
3798     this->fillch = fill;
3799     return ret;
3800 }
3801
3802 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WXZ */
3803 /* ?fill@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WXZ */
3804 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGXZ */
3805 /* ?fill@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGXZ */
3806 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_fill_get, 4)
3807 wchar_t __thiscall basic_ios_wchar_fill_get(basic_ios_wchar *this)
3808 {
3809     TRACE("(%p)\n", this);
3810     return this->fillch;
3811 }
3812
3813 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
3814 /* ?imbue@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
3815 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QAE?AVlocale@2@ABV32@@Z */
3816 /* ?imbue@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAA?AVlocale@2@AEBV32@@Z */
3817 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_imbue, 12)
3818 locale *__thiscall basic_ios_wchar_imbue(basic_ios_wchar *this, locale *ret, const locale *loc)
3819 {
3820     TRACE("(%p %p %p)\n", this, ret, loc);
3821
3822     if(this->strbuf) {
3823         basic_streambuf_wchar_pubimbue(this->strbuf, ret, loc);
3824         locale_dtor(ret);
3825     }
3826
3827     return ios_base_imbue(&this->base, ret, loc);
3828 }
3829
3830 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBED_WD@Z */
3831 /* ?narrow@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAD_WD@Z */
3832 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEDGD@Z */
3833 /* ?narrow@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBADGD@Z */
3834 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_narrow, 12)
3835 char __thiscall basic_ios_wchar_narrow(basic_ios_wchar *this, wchar_t ch, char def)
3836 {
3837     TRACE("(%p %c %c)\n", this, ch, def);
3838     return ctype_wchar_narrow_ch(ctype_wchar_use_facet(this->strbuf->loc), ch, def);
3839 }
3840
3841 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
3842 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
3843 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PAV32@@Z */
3844 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@PEAV32@@Z */
3845 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_set, 8)
3846 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_set(basic_ios_wchar *this, basic_streambuf_wchar *streambuf)
3847 {
3848     basic_streambuf_wchar *ret = this->strbuf;
3849
3850     TRACE("(%p %p)\n", this, streambuf);
3851
3852     this->strbuf = streambuf;
3853     basic_ios_wchar_clear(this, IOSTATE_goodbit);
3854     return ret;
3855 }
3856
3857 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
3858 /* ?rdbuf@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@XZ */
3859 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
3860 /* ?rdbuf@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@XZ */
3861 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_rdbuf_get, 4)
3862 basic_streambuf_wchar* __thiscall basic_ios_wchar_rdbuf_get(const basic_ios_wchar *this)
3863 {
3864     TRACE("(%p)\n", this);
3865     return this->strbuf;
3866 }
3867
3868 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXH_N@Z */
3869 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXH_N@Z */
3870 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXH_N@Z */
3871 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXH_N@Z */
3872 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate_reraise, 12)
3873 void __thiscall basic_ios_wchar_setstate_reraise(basic_ios_wchar *this, IOSB_iostate state, MSVCP_bool reraise)
3874 {
3875     TRACE("(%p %x %x)\n", this, state, reraise);
3876
3877     if(state != IOSTATE_goodbit)
3878         basic_ios_wchar_clear_reraise(this, this->base.state | state, reraise);
3879 }
3880
3881 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEXI@Z */
3882 /* ?setstate@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAXI@Z */
3883 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEXI@Z */
3884 /* ?setstate@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAXI@Z */
3885 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_setstate, 8)
3886 void __thiscall basic_ios_wchar_setstate(basic_ios_wchar *this, IOSB_iostate state)
3887 {
3888     basic_ios_wchar_setstate_reraise(this, state, FALSE);
3889 }
3890
3891 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QAEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PAV32@@Z */
3892 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEAAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@PEAV32@@Z */
3893 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QAEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@PAV32@@Z */
3894 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEAAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@PEAV32@@Z */
3895 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_set, 8)
3896 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_set(basic_ios_wchar *this, basic_ostream_wchar *ostream)
3897 {
3898     basic_ostream_wchar *ret = this->stream;
3899
3900     TRACE("(%p %p)\n", this, ostream);
3901
3902     this->stream = ostream;
3903     return ret;
3904 }
3905
3906 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBEPAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
3907 /* ?tie@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBAPEAV?$basic_ostream@_WU?$char_traits@_W@std@@@2@XZ */
3908 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEPAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
3909 /* ?tie@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAPEAV?$basic_ostream@GU?$char_traits@G@std@@@2@XZ */
3910 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_tie_get, 4)
3911 basic_ostream_wchar* __thiscall basic_ios_wchar_tie_get(const basic_ios_wchar *this)
3912 {
3913     TRACE("(%p)\n", this);
3914     return this->stream;
3915 }
3916
3917 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QBE_WD@Z */
3918 /* ?widen@?$basic_ios@_WU?$char_traits@_W@std@@@std@@QEBA_WD@Z */
3919 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QBEGD@Z */
3920 /* ?widen@?$basic_ios@GU?$char_traits@G@std@@@std@@QEBAGD@Z */
3921 DEFINE_THISCALL_WRAPPER(basic_ios_wchar_widen, 8)
3922 wchar_t __thiscall basic_ios_wchar_widen(basic_ios_wchar *this, char ch)
3923 {
3924     TRACE("(%p %c)\n", this, ch);
3925     return ctype_wchar_widen_ch(ctype_wchar_use_facet(this->strbuf->loc), ch);
3926 }
3927
3928 /* Caution: basic_ostream uses virtual inheritance.
3929  * All constructors have additional parameter that says if base class should be initialized.
3930  * Base class needs to be accessed using vbtable.
3931  */
3932 static inline basic_ios_char* basic_ostream_char_get_basic_ios(basic_ostream_char *this)
3933 {
3934     return (basic_ios_char*)((char*)this+this->vbtable[1]);
3935 }
3936
3937 static inline basic_ios_char* basic_ostream_char_to_basic_ios(basic_ostream_char *ptr)
3938 {
3939     return (basic_ios_char*)((char*)ptr+basic_ostream_char_vbtable[1]);
3940 }
3941
3942 static inline basic_ostream_char* basic_ostream_char_from_basic_ios(basic_ios_char *ptr)
3943 {
3944     return (basic_ostream_char*)((char*)ptr-basic_ostream_char_vbtable[1]);
3945 }
3946
3947 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
3948 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
3949 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor, 16)
3950 basic_ostream_char* __thiscall basic_ostream_char_ctor(basic_ostream_char *this,
3951         basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
3952 {
3953     basic_ios_char *base;
3954
3955     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
3956
3957     if(virt_init) {
3958         this->vbtable = basic_ostream_char_vbtable;
3959         base = basic_ostream_char_get_basic_ios(this);
3960         basic_ios_char_ctor(base);
3961     }else {
3962         base = basic_ostream_char_get_basic_ios(this);
3963     }
3964
3965     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
3966     basic_ios_char_init(base, strbuf, isstd);
3967     return this;
3968 }
3969
3970 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
3971 /* ??0?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
3972 DEFINE_THISCALL_WRAPPER(basic_ostream_char_ctor_uninitialized, 16)
3973 basic_ostream_char* __thiscall basic_ostream_char_ctor_uninitialized(basic_ostream_char *this,
3974         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
3975 {
3976     basic_ios_char *base;
3977
3978     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
3979
3980     if(virt_init) {
3981         this->vbtable = basic_ostream_char_vbtable;
3982         base = basic_ostream_char_get_basic_ios(this);
3983         basic_ios_char_ctor(base);
3984     }else {
3985         base = basic_ostream_char_get_basic_ios(this);
3986     }
3987
3988     base->base.vtable = &MSVCP_basic_ostream_char_vtable;
3989     if(addstd)
3990         ios_base_Addstd(&base->base);
3991     return this;
3992 }
3993
3994 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
3995 /* ??1?$basic_ostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
3996 DEFINE_THISCALL_WRAPPER(basic_ostream_char_dtor, 4)
3997 void __thiscall basic_ostream_char_dtor(basic_ios_char *base)
3998 {
3999     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
4000
4001     /* don't destroy virtual base here */
4002     TRACE("(%p)\n", this);
4003 }
4004
4005 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4006 /* ??_D?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4007 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vbase_dtor, 4)
4008 void __thiscall basic_ostream_char_vbase_dtor(basic_ostream_char *this)
4009 {
4010     TRACE("(%p)\n", this);
4011     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(this));
4012     basic_ios_char_dtor(basic_ostream_char_get_basic_ios(this));
4013 }
4014
4015 DEFINE_THISCALL_WRAPPER(basic_ostream_char_vector_dtor, 8)
4016 basic_ostream_char* __thiscall basic_ostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
4017 {
4018     basic_ostream_char *this = basic_ostream_char_from_basic_ios(base);
4019
4020     TRACE("(%p %x)\n", this, flags);
4021
4022     if(flags & 2) {
4023         /* we have an array, with the number of elements stored before the first object */
4024         INT_PTR i, *ptr = (INT_PTR *)this-1;
4025
4026         for(i=*ptr-1; i>=0; i--)
4027             basic_ostream_char_vbase_dtor(this+i);
4028         MSVCRT_operator_delete(ptr);
4029     } else {
4030         basic_ostream_char_vbase_dtor(this);
4031         if(flags & 1)
4032             MSVCRT_operator_delete(this);
4033     }
4034
4035     return this;
4036 }
4037
4038 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
4039 /* ?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
4040 DEFINE_THISCALL_WRAPPER(basic_ostream_char_flush, 4)
4041 basic_ostream_char* __thiscall basic_ostream_char_flush(basic_ostream_char *this)
4042 {
4043     /* this function is not matching C++ specification */
4044     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4045
4046     TRACE("(%p)\n", this);
4047
4048     if(basic_ios_char_rdbuf_get(base) && ios_base_good(&base->base)
4049             && basic_streambuf_char_pubsync(basic_ios_char_rdbuf_get(base))==-1)
4050         basic_ios_char_setstate(base, IOSTATE_badbit);
4051     return this;
4052 }
4053
4054 /* ?flush@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
4055 /* ?flush@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
4056 basic_ostream_char* __cdecl flush_ostream_char(basic_ostream_char *ostream)
4057 {
4058     return basic_ostream_char_flush(ostream);
4059 }
4060
4061 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4062 /* ?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4063 DEFINE_THISCALL_WRAPPER(basic_ostream_char__Osfx, 4)
4064 void __thiscall basic_ostream_char__Osfx(basic_ostream_char *this)
4065 {
4066     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4067
4068     TRACE("(%p)\n", this);
4069
4070     if(base->base.fmtfl & FMTFLAG_unitbuf)
4071         basic_ostream_char_flush(this);
4072 }
4073
4074 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
4075 /* ?osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
4076 DEFINE_THISCALL_WRAPPER(basic_ostream_char_osfx, 4)
4077 void __thiscall basic_ostream_char_osfx(basic_ostream_char *this)
4078 {
4079     TRACE("(%p)\n", this);
4080     basic_ostream_char__Osfx(this);
4081 }
4082
4083 static BOOL basic_ostream_char_sentry_create(basic_ostream_char *ostr)
4084 {
4085     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
4086
4087     if(basic_ios_char_rdbuf_get(base))
4088         call_basic_streambuf_char__Lock(base->strbuf);
4089
4090     if(ios_base_good(&base->base) && base->stream)
4091         basic_ostream_char_flush(base->stream);
4092
4093     return ios_base_good(&base->base);
4094 }
4095
4096 static void basic_ostream_char_sentry_destroy(basic_ostream_char *ostr)
4097 {
4098     basic_ios_char *base = basic_ostream_char_get_basic_ios(ostr);
4099
4100     if(ios_base_good(&base->base) && !__uncaught_exception())
4101         basic_ostream_char_osfx(ostr);
4102
4103     if(basic_ios_char_rdbuf_get(base))
4104         call_basic_streambuf_char__Unlock(base->strbuf);
4105 }
4106
4107 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE_NXZ */
4108 /* ?opfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA_NXZ */
4109 DEFINE_THISCALL_WRAPPER(basic_ostream_char_opfx, 4)
4110 MSVCP_bool __thiscall basic_ostream_char_opfx(basic_ostream_char *this)
4111 {
4112     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4113
4114     TRACE("(%p)\n", this);
4115
4116     if(ios_base_good(&base->base) && base->stream)
4117         basic_ostream_char_flush(base->stream);
4118     return ios_base_good(&base->base);
4119 }
4120
4121 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
4122 /* ?put@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
4123 DEFINE_THISCALL_WRAPPER(basic_ostream_char_put, 8)
4124 basic_ostream_char* __thiscall basic_ostream_char_put(basic_ostream_char *this, char ch)
4125 {
4126     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4127
4128     TRACE("(%p %c)\n", this, ch);
4129
4130     if(!basic_ostream_char_sentry_create(this)
4131             || basic_streambuf_char_sputc(base->strbuf, ch)==EOF) {
4132         basic_ostream_char_sentry_destroy(this);
4133         basic_ios_char_setstate(base, IOSTATE_badbit);
4134         return this;
4135     }
4136
4137     basic_ostream_char_sentry_destroy(this);
4138     return this;
4139 }
4140
4141 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
4142 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
4143 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp, 16)
4144 basic_ostream_char* __thiscall basic_ostream_char_seekp(basic_ostream_char *this, streamoff off, int way)
4145 {
4146     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4147
4148     TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(off), way);
4149
4150     if(!ios_base_fail(&base->base)) {
4151         fpos_int seek;
4152
4153         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
4154                 &seek, off, way, OPENMODE_out);
4155         if(seek.off==-1 && seek.pos==0 && seek.state==0)
4156             basic_ios_char_setstate(base, IOSTATE_failbit);
4157     }
4158     return this;
4159 }
4160
4161 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
4162 /* ?seekp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
4163 DEFINE_THISCALL_WRAPPER(basic_ostream_char_seekp_fpos, 28)
4164 basic_ostream_char* __thiscall basic_ostream_char_seekp_fpos(basic_ostream_char *this, fpos_int pos)
4165 {
4166     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4167
4168     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
4169
4170     if(!ios_base_fail(&base->base)) {
4171         fpos_int seek;
4172
4173         basic_streambuf_char_pubseekpos(basic_ios_char_rdbuf_get(base),
4174                 &seek, pos, OPENMODE_out);
4175         if(seek.off==-1 && seek.pos==0 && seek.state==0)
4176             basic_ios_char_setstate(base, IOSTATE_failbit);
4177     }
4178     return this;
4179 }
4180
4181 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
4182 /* ?tellp@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
4183 DEFINE_THISCALL_WRAPPER(basic_ostream_char_tellp, 8)
4184 fpos_int* __thiscall basic_ostream_char_tellp(basic_ostream_char *this, fpos_int *ret)
4185 {
4186     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4187
4188     TRACE("(%p)\n", this);
4189
4190     if(!ios_base_fail(&base->base)) {
4191         basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
4192                 ret, 0, SEEKDIR_cur, OPENMODE_out);
4193     }else {
4194         ret->off = -1;
4195         ret->pos = 0;
4196         ret->state = 0;
4197     }
4198     return ret;
4199 }
4200
4201 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@PBDH@Z */
4202 /* ?write@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEBD_J@Z */
4203 DEFINE_THISCALL_WRAPPER(basic_ostream_char_write, 16)
4204 basic_ostream_char* __thiscall basic_ostream_char_write(basic_ostream_char *this, const char *str, streamsize count)
4205 {
4206     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4207
4208     TRACE("(%p %s %s)\n", this, debugstr_a(str), wine_dbgstr_longlong(count));
4209
4210     if(!basic_ostream_char_sentry_create(this)
4211             || basic_streambuf_char_sputn(base->strbuf, str, count)!=count) {
4212         basic_ostream_char_sentry_destroy(this);
4213         basic_ios_char_setstate(base, IOSTATE_badbit);
4214         return this;
4215     }
4216
4217     basic_ostream_char_sentry_destroy(this);
4218     return this;
4219 }
4220
4221 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@F@Z */
4222 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@F@Z */
4223 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_short, 8)
4224 basic_ostream_char* __thiscall basic_ostream_char_print_short(basic_ostream_char *this, short val)
4225 {
4226     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4227     int state = IOSTATE_goodbit;
4228
4229     TRACE("(%p %d)\n", this, val);
4230
4231     if(basic_ostream_char_sentry_create(this)) {
4232         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4233         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4234         ostreambuf_iterator_char dest = {0, strbuf};
4235
4236         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base),
4237                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
4238                 ? (LONG)((unsigned short)val) : (LONG)val);
4239     }
4240     basic_ostream_char_sentry_destroy(this);
4241
4242     basic_ios_char_setstate(base, state);
4243     return this;
4244 }
4245
4246 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@G@Z */
4247 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@G@Z */
4248 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ushort, 8)
4249 basic_ostream_char* __thiscall basic_ostream_char_print_ushort(basic_ostream_char *this, unsigned short val)
4250 {
4251     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4252     int state = IOSTATE_goodbit;
4253
4254     TRACE("(%p %u)\n", this, val);
4255
4256     if(basic_ostream_char_sentry_create(this)) {
4257         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4258         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4259         ostreambuf_iterator_char dest = {0, strbuf};
4260
4261         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4262     }
4263     basic_ostream_char_sentry_destroy(this);
4264
4265     basic_ios_char_setstate(base, state);
4266     return this;
4267 }
4268
4269 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z */
4270 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@H@Z */
4271 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@J@Z */
4272 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@J@Z */
4273 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int, 8)
4274 basic_ostream_char* __thiscall basic_ostream_char_print_int(basic_ostream_char *this, int val)
4275 {
4276     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4277     int state = IOSTATE_goodbit;
4278
4279     TRACE("(%p %d)\n", this, val);
4280
4281     if(basic_ostream_char_sentry_create(this)) {
4282         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4283         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4284         ostreambuf_iterator_char dest = {0, strbuf};
4285
4286         num_put_char_put_long(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4287     }
4288     basic_ostream_char_sentry_destroy(this);
4289
4290     basic_ios_char_setstate(base, state);
4291     return this;
4292 }
4293
4294 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@I@Z */
4295 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@I@Z */
4296 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@K@Z */
4297 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@K@Z */
4298 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint, 8)
4299 basic_ostream_char* __thiscall basic_ostream_char_print_uint(basic_ostream_char *this, unsigned int val)
4300 {
4301     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4302     int state = IOSTATE_goodbit;
4303
4304     TRACE("(%p %u)\n", this, val);
4305
4306     if(basic_ostream_char_sentry_create(this)) {
4307         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4308         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4309         ostreambuf_iterator_char dest = {0, strbuf};
4310
4311         num_put_char_put_ulong(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4312     }
4313     basic_ostream_char_sentry_destroy(this);
4314
4315     basic_ios_char_setstate(base, state);
4316     return this;
4317 }
4318
4319 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z */
4320 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@M@Z */
4321 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_float, 8)
4322 basic_ostream_char* __thiscall basic_ostream_char_print_float(basic_ostream_char *this, float val)
4323 {
4324     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4325     int state = IOSTATE_goodbit;
4326
4327     TRACE("(%p %f)\n", this, val);
4328
4329     if(basic_ostream_char_sentry_create(this)) {
4330         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4331         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4332         ostreambuf_iterator_char dest = {0, strbuf};
4333
4334         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4335     }
4336     basic_ostream_char_sentry_destroy(this);
4337
4338     basic_ios_char_setstate(base, state);
4339     return this;
4340 }
4341
4342 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@N@Z */
4343 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@N@Z */
4344 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_double, 12)
4345 basic_ostream_char* __thiscall basic_ostream_char_print_double(basic_ostream_char *this, double val)
4346 {
4347     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4348     int state = IOSTATE_goodbit;
4349
4350     TRACE("(%p %lf)\n", this, val);
4351
4352     if(basic_ostream_char_sentry_create(this)) {
4353         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4354         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4355         ostreambuf_iterator_char dest = {0, strbuf};
4356
4357         num_put_char_put_double(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4358     }
4359     basic_ostream_char_sentry_destroy(this);
4360
4361     basic_ios_char_setstate(base, state);
4362     return this;
4363 }
4364
4365 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@O@Z */
4366 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@O@Z */
4367 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ldouble, 12)
4368 basic_ostream_char* __thiscall basic_ostream_char_print_ldouble(basic_ostream_char *this, double val)
4369 {
4370     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4371     int state = IOSTATE_goodbit;
4372
4373     TRACE("(%p %lf)\n", this, val);
4374
4375     if(basic_ostream_char_sentry_create(this)) {
4376         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4377         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4378         ostreambuf_iterator_char dest = {0, strbuf};
4379
4380         num_put_char_put_ldouble(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4381     }
4382     basic_ostream_char_sentry_destroy(this);
4383
4384     basic_ios_char_setstate(base, state);
4385     return this;
4386 }
4387
4388 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4389 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
4390 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_streambuf, 8)
4391 basic_ostream_char* __thiscall basic_ostream_char_print_streambuf(basic_ostream_char *this, basic_streambuf_char *val)
4392 {
4393     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4394     IOSB_iostate state = IOSTATE_badbit;
4395     int c = '\n';
4396
4397     TRACE("(%p %p)\n", this, val);
4398
4399     if(basic_ostream_char_sentry_create(this)) {
4400         for(c = basic_streambuf_char_sgetc(val); c!=EOF;
4401                 c = basic_streambuf_char_snextc(val)) {
4402             state = IOSTATE_goodbit;
4403
4404             if(basic_streambuf_char_sputc(base->strbuf, c) == EOF) {
4405                 state = IOSTATE_badbit;
4406                 break;
4407             }
4408         }
4409     }else {
4410         state = IOSTATE_badbit;
4411     }
4412     basic_ostream_char_sentry_destroy(this);
4413
4414     ios_base_width_set(&base->base, 0);
4415     basic_ios_char_setstate(base, state);
4416     return this;
4417 }
4418
4419 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@PBX@Z */
4420 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEBX@Z */
4421 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_ptr, 8)
4422 basic_ostream_char* __thiscall basic_ostream_char_print_ptr(basic_ostream_char *this, const void *val)
4423 {
4424     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4425     int state = IOSTATE_goodbit;
4426
4427     TRACE("(%p %p)\n", this, val);
4428
4429     if(basic_ostream_char_sentry_create(this)) {
4430         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4431         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4432         ostreambuf_iterator_char dest = {0, strbuf};
4433
4434         num_put_char_put_ptr(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4435     }
4436     basic_ostream_char_sentry_destroy(this);
4437
4438     basic_ios_char_setstate(base, state);
4439     return this;
4440 }
4441
4442 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z */
4443 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_J@Z */
4444 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_int64, 12)
4445 basic_ostream_char* __thiscall basic_ostream_char_print_int64(basic_ostream_char *this, __int64 val)
4446 {
4447     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4448     int state = IOSTATE_goodbit;
4449
4450     TRACE("(%p)\n", this);
4451
4452     if(basic_ostream_char_sentry_create(this)) {
4453         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4454         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4455         ostreambuf_iterator_char dest = {0, strbuf};
4456
4457         num_put_char_put_int64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4458     }
4459     basic_ostream_char_sentry_destroy(this);
4460
4461     basic_ios_char_setstate(base, state);
4462     return this;
4463 }
4464
4465 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_K@Z */
4466 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_K@Z */
4467 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_uint64, 12)
4468 basic_ostream_char* __thiscall basic_ostream_char_print_uint64(basic_ostream_char *this, unsigned __int64 val)
4469 {
4470     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4471     int state = IOSTATE_goodbit;
4472
4473     TRACE("(%p)\n", this);
4474
4475     if(basic_ostream_char_sentry_create(this)) {
4476         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4477         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4478         ostreambuf_iterator_char dest = {0, strbuf};
4479
4480         num_put_char_put_uint64(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4481     }
4482     basic_ostream_char_sentry_destroy(this);
4483
4484     basic_ios_char_setstate(base, state);
4485     return this;
4486 }
4487
4488 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_N@Z */
4489 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@_N@Z */
4490 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_bool, 8)
4491 basic_ostream_char* __thiscall basic_ostream_char_print_bool(basic_ostream_char *this, MSVCP_bool val)
4492 {
4493     basic_ios_char *base = basic_ostream_char_get_basic_ios(this);
4494     int state = IOSTATE_goodbit;
4495
4496     TRACE("(%p %x)\n", this, val);
4497
4498     if(basic_ostream_char_sentry_create(this)) {
4499         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
4500         const num_put *numput = num_put_char_use_facet(strbuf->loc);
4501         ostreambuf_iterator_char dest = {0, strbuf};
4502
4503         num_put_char_put_bool(numput, &dest, dest, &base->base, basic_ios_char_fill_get(base), val);
4504     }
4505     basic_ostream_char_sentry_destroy(this);
4506
4507     basic_ios_char_setstate(base, state);
4508     return this;
4509 }
4510
4511 /* ?ends@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
4512 /* ?ends@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
4513 basic_ostream_char* __cdecl basic_ostream_char_ends(basic_ostream_char *ostr)
4514 {
4515     TRACE("(%p)\n", ostr);
4516
4517     basic_ostream_char_put(ostr, 0);
4518     return ostr;
4519 }
4520
4521 /* ?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z */
4522 /* ?endl@std@@YAAEAV?$basic_ostream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
4523 basic_ostream_char* __cdecl basic_ostream_char_endl(basic_ostream_char *ostr)
4524 {
4525     TRACE("(%p)\n", ostr);
4526
4527     basic_ostream_char_put(ostr, '\n');
4528     basic_ostream_char_flush(ostr);
4529     return ostr;
4530 }
4531
4532 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
4533 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
4534 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func, 8)
4535 basic_ostream_char* __thiscall basic_ostream_char_print_func(basic_ostream_char *this,
4536         basic_ostream_char* (__cdecl *pfunc)(basic_ostream_char*))
4537 {
4538     TRACE("(%p %p)\n", this, pfunc);
4539     pfunc(this);
4540     return this;
4541 }
4542
4543 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
4544 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
4545 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_basic_ios, 8)
4546 basic_ostream_char* __thiscall basic_ostream_char_print_func_basic_ios(basic_ostream_char *this,
4547         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
4548 {
4549     TRACE("(%p %p)\n", this, pfunc);
4550     pfunc(basic_ostream_char_get_basic_ios(this));
4551     return this;
4552 }
4553
4554 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
4555 /* ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
4556 DEFINE_THISCALL_WRAPPER(basic_ostream_char_print_func_ios_base, 8)
4557 basic_ostream_char* __thiscall basic_ostream_char_print_func_ios_base(
4558         basic_ostream_char *this, ios_base* (__cdecl *pfunc)(ios_base*))
4559 {
4560     TRACE("(%p %p)\n", this, pfunc);
4561     pfunc(&basic_ostream_char_get_basic_ios(this)->base);
4562     return this;
4563 }
4564
4565 /* Caution: basic_ostream uses virtual inheritance. */
4566 static inline basic_ios_wchar* basic_ostream_wchar_get_basic_ios(basic_ostream_wchar *this)
4567 {
4568     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
4569 }
4570
4571 static inline basic_ios_wchar* basic_ostream_wchar_to_basic_ios(basic_ostream_wchar *ptr)
4572 {
4573     return (basic_ios_wchar*)((char*)ptr+basic_ostream_wchar_vbtable[1]);
4574 }
4575
4576 static inline basic_ostream_wchar* basic_ostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
4577 {
4578     return (basic_ostream_wchar*)((char*)ptr-basic_ostream_wchar_vbtable[1]);
4579 }
4580
4581 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
4582 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
4583 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_ctor, 16)
4584 basic_ostream_wchar* __thiscall basic_ostream_wchar_ctor(basic_ostream_wchar *this,
4585         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
4586 {
4587     basic_ios_wchar *base;
4588
4589     TRACE("(%p %p %d %d)\n", this, strbuf, isstd, virt_init);
4590
4591     if(virt_init) {
4592         this->vbtable = basic_ostream_wchar_vbtable;
4593         base = basic_ostream_wchar_get_basic_ios(this);
4594         basic_ios_wchar_ctor(base);
4595     }else {
4596         base = basic_ostream_wchar_get_basic_ios(this);
4597     }
4598
4599     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
4600     basic_ios_wchar_init(base, strbuf, isstd);
4601     return this;
4602 }
4603
4604 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
4605 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
4606 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor, 16)
4607 basic_ostream_wchar* __thiscall basic_ostream_short_ctor(basic_ostream_wchar *this,
4608         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
4609 {
4610     basic_ostream_wchar_ctor(this, strbuf, isstd, virt_init);
4611     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
4612     return this;
4613 }
4614
4615 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
4616 /* ??0?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
4617 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_ctor_uninitialized, 16)
4618 basic_ostream_wchar* __thiscall basic_ostream_wchar_ctor_uninitialized(basic_ostream_wchar *this,
4619         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
4620 {
4621     basic_ios_wchar *base;
4622
4623     TRACE("(%p %d %x)\n", this, uninitialized, addstd);
4624
4625     if(virt_init) {
4626         this->vbtable = basic_ostream_wchar_vbtable;
4627         base = basic_ostream_wchar_get_basic_ios(this);
4628         basic_ios_wchar_ctor(base);
4629     }else {
4630         base = basic_ostream_wchar_get_basic_ios(this);
4631     }
4632
4633     base->base.vtable = &MSVCP_basic_ostream_wchar_vtable;
4634     if(addstd)
4635         ios_base_Addstd(&base->base);
4636     return this;
4637 }
4638
4639 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@_N@Z */
4640 /* ??0?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@_N@Z */
4641 DEFINE_THISCALL_WRAPPER(basic_ostream_short_ctor_uninitialized, 16)
4642 basic_ostream_wchar* __thiscall basic_ostream_short_ctor_uninitialized(basic_ostream_wchar *this,
4643         int uninitialized, MSVCP_bool addstd, MSVCP_bool virt_init)
4644 {
4645     basic_ostream_wchar_ctor_uninitialized(this, uninitialized, addstd, virt_init);
4646     basic_ostream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_ostream_short_vtable;
4647     return this;
4648 }
4649
4650 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
4651 /* ??1?$basic_ostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
4652 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
4653 /* ??1?$basic_ostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
4654 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_dtor, 4)
4655 void __thiscall basic_ostream_wchar_dtor(basic_ios_wchar *base)
4656 {
4657     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
4658
4659     /* don't destroy virtual base here */
4660     TRACE("(%p)\n", this);
4661 }
4662
4663 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
4664 /* ??_D?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
4665 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
4666 /* ??_D?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
4667 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vbase_dtor, 4)
4668 void __thiscall basic_ostream_wchar_vbase_dtor(basic_ostream_wchar *this)
4669 {
4670     TRACE("(%p)\n", this);
4671     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(this));
4672     basic_ios_wchar_dtor(basic_ostream_wchar_get_basic_ios(this));
4673 }
4674
4675 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_vector_dtor, 8)
4676 basic_ostream_wchar* __thiscall basic_ostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
4677 {
4678     basic_ostream_wchar *this = basic_ostream_wchar_from_basic_ios(base);
4679
4680     TRACE("(%p %x)\n", this, flags);
4681
4682     if(flags & 2) {
4683         /* we have an array, with the number of elements stored before the first object */
4684         INT_PTR i, *ptr = (INT_PTR *)this-1;
4685
4686         for(i=*ptr-1; i>=0; i--)
4687             basic_ostream_wchar_vbase_dtor(this+i);
4688         MSVCRT_operator_delete(ptr);
4689     } else {
4690         basic_ostream_wchar_vbase_dtor(this);
4691         if(flags & 1)
4692             MSVCRT_operator_delete(this);
4693     }
4694
4695     return this;
4696 }
4697
4698 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
4699 /* ?flush@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
4700 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
4701 /* ?flush@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
4702 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_flush, 4)
4703 basic_ostream_wchar* __thiscall basic_ostream_wchar_flush(basic_ostream_wchar *this)
4704 {
4705     /* this function is not matching C++ specification */
4706     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4707
4708     TRACE("(%p)\n", this);
4709
4710     if(basic_ios_wchar_rdbuf_get(base) && ios_base_good(&base->base)
4711             && basic_streambuf_wchar_pubsync(basic_ios_wchar_rdbuf_get(base))==-1)
4712         basic_ios_wchar_setstate(base, IOSTATE_badbit);
4713     return this;
4714 }
4715
4716 /* ?flush@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
4717 /* ?flush@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
4718 /* ?flush@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
4719 /* ?flush@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
4720 basic_ostream_wchar* __cdecl flush_ostream_wchar(basic_ostream_wchar *ostream)
4721 {
4722     return basic_ostream_wchar_flush(ostream);
4723 }
4724
4725 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
4726 /* ?_Osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
4727 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
4728 /* ?_Osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
4729 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar__Osfx, 4)
4730 void __thiscall basic_ostream_wchar__Osfx(basic_ostream_wchar *this)
4731 {
4732     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4733
4734     TRACE("(%p)\n", this);
4735
4736     if(base->base.fmtfl & FMTFLAG_unitbuf)
4737         basic_ostream_wchar_flush(this);
4738 }
4739
4740 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
4741 /* ?osfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
4742 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
4743 /* ?osfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
4744 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_osfx, 4)
4745 void __thiscall basic_ostream_wchar_osfx(basic_ostream_wchar *this)
4746 {
4747     TRACE("(%p)\n", this);
4748     basic_ostream_wchar__Osfx(this);
4749 }
4750
4751 static BOOL basic_ostream_wchar_sentry_create(basic_ostream_wchar *ostr)
4752 {
4753     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
4754
4755     if(basic_ios_wchar_rdbuf_get(base))
4756         basic_streambuf_wchar__Lock(base->strbuf);
4757
4758     if(ios_base_good(&base->base) && base->stream)
4759         basic_ostream_wchar_flush(base->stream);
4760
4761     return ios_base_good(&base->base);
4762 }
4763
4764 static void basic_ostream_wchar_sentry_destroy(basic_ostream_wchar *ostr)
4765 {
4766     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(ostr);
4767
4768     if(ios_base_good(&base->base) && !__uncaught_exception())
4769         basic_ostream_wchar_osfx(ostr);
4770
4771     if(basic_ios_wchar_rdbuf_get(base))
4772         basic_streambuf_wchar__Unlock(base->strbuf);
4773 }
4774
4775 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE_NXZ */
4776 /* ?opfx@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA_NXZ */
4777 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE_NXZ */
4778 /* ?opfx@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA_NXZ */
4779 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_opfx, 4)
4780 MSVCP_bool __thiscall basic_ostream_wchar_opfx(basic_ostream_wchar *this)
4781 {
4782     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4783
4784     TRACE("(%p)\n", this);
4785
4786     if(ios_base_good(&base->base) && base->stream)
4787         basic_ostream_wchar_flush(base->stream);
4788     return ios_base_good(&base->base);
4789 }
4790
4791 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
4792 /* ?put@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
4793 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
4794 /* ?put@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
4795 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_put, 8)
4796 basic_ostream_wchar* __thiscall basic_ostream_wchar_put(basic_ostream_wchar *this, wchar_t ch)
4797 {
4798     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4799
4800     TRACE("(%p %c)\n", this, ch);
4801
4802     if(!basic_ostream_wchar_sentry_create(this)
4803             || basic_streambuf_wchar_sputc(base->strbuf, ch)==WEOF) {
4804         basic_ostream_wchar_sentry_destroy(this);
4805         basic_ios_wchar_setstate(base, IOSTATE_badbit);
4806         return this;
4807     }
4808
4809     basic_ostream_wchar_sentry_destroy(this);
4810     return this;
4811 }
4812
4813 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
4814 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
4815 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
4816 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
4817 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp, 16)
4818 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp(basic_ostream_wchar *this, streamoff off, int way)
4819 {
4820     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4821
4822     TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(off), way);
4823
4824     if(!ios_base_fail(&base->base)) {
4825         fpos_int seek;
4826
4827         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
4828                 &seek, off, way, OPENMODE_out);
4829         if(seek.off==-1 && seek.pos==0 && seek.state==0)
4830             basic_ios_wchar_setstate(base, IOSTATE_failbit);
4831     }
4832     return this;
4833 }
4834
4835 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
4836 /* ?seekp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
4837 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
4838 /* ?seekp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
4839 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_seekp_fpos, 28)
4840 basic_ostream_wchar* __thiscall basic_ostream_wchar_seekp_fpos(basic_ostream_wchar *this, fpos_int pos)
4841 {
4842     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4843
4844     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
4845
4846     if(!ios_base_fail(&base->base)) {
4847         fpos_int seek;
4848
4849         basic_streambuf_wchar_pubseekpos(basic_ios_wchar_rdbuf_get(base),
4850                 &seek, pos, OPENMODE_out);
4851         if(seek.off==-1 && seek.pos==0 && seek.state==0)
4852             basic_ios_wchar_setstate(base, IOSTATE_failbit);
4853     }
4854     return this;
4855 }
4856
4857 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
4858 /* ?tellp@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
4859 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
4860 /* ?tellp@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
4861 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_tellp, 8)
4862 fpos_int* __thiscall basic_ostream_wchar_tellp(basic_ostream_wchar *this, fpos_int *ret)
4863 {
4864     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4865
4866     TRACE("(%p)\n", this);
4867
4868     if(!ios_base_fail(&base->base)) {
4869         basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
4870                 ret, 0, SEEKDIR_cur, OPENMODE_out);
4871     }else {
4872         ret->off = -1;
4873         ret->pos = 0;
4874         ret->state = 0;
4875     }
4876     return ret;
4877 }
4878
4879 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PB_WH@Z */
4880 /* ?write@?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEB_W_J@Z */
4881 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV12@PBGH@Z */
4882 /* ?write@?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEBG_J@Z */
4883 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_write, 16)
4884 basic_ostream_wchar* __thiscall basic_ostream_wchar_write(basic_ostream_wchar *this, const wchar_t *str, streamsize count)
4885 {
4886     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4887
4888     TRACE("(%p %s %s)\n", this, debugstr_w(str), wine_dbgstr_longlong(count));
4889
4890     if(!basic_ostream_wchar_sentry_create(this)
4891             || basic_streambuf_wchar_sputn(base->strbuf, str, count)!=count) {
4892         basic_ostream_wchar_sentry_destroy(this);
4893         basic_ios_wchar_setstate(base, IOSTATE_badbit);
4894         return this;
4895     }
4896
4897     basic_ostream_wchar_sentry_destroy(this);
4898     return this;
4899 }
4900
4901 static basic_ostream_wchar* basic_ostream_print_short(basic_ostream_wchar *this, short val, const num_put *numput)
4902 {
4903     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4904     int state = IOSTATE_goodbit;
4905
4906     TRACE("(%p %d)\n", this, val);
4907
4908     if(basic_ostream_wchar_sentry_create(this)) {
4909         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
4910         ostreambuf_iterator_wchar dest = {0, strbuf};
4911
4912         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base),
4913                 (ios_base_flags_get(&base->base) & FMTFLAG_basefield & (FMTFLAG_oct | FMTFLAG_hex))
4914                 ? (LONG)((unsigned short)val) : (LONG)val);
4915     }
4916     basic_ostream_wchar_sentry_destroy(this);
4917
4918     basic_ios_wchar_setstate(base, state);
4919     return this;
4920 }
4921
4922 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@F@Z */
4923 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@F@Z */
4924 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_short, 8)
4925 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_short(basic_ostream_wchar *this, short val)
4926 {
4927     return basic_ostream_print_short(this, val, num_put_wchar_use_facet(
4928                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
4929 }
4930
4931 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@F@Z */
4932 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@F@Z */
4933 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_short, 8)
4934 basic_ostream_wchar* __thiscall basic_ostream_short_print_short(basic_ostream_wchar *this, short val)
4935 {
4936     return basic_ostream_print_short(this, val, num_put_short_use_facet(
4937                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
4938 }
4939
4940 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@G@Z */
4941 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@G@Z */
4942 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ushort, 8)
4943 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ushort(basic_ostream_wchar *this, unsigned short val)
4944 {
4945     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4946     int state = IOSTATE_goodbit;
4947
4948     TRACE("(%p %u)\n", this, val);
4949
4950     if(basic_ostream_wchar_sentry_create(this)) {
4951         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
4952         const num_put *numput = num_put_wchar_use_facet(strbuf->loc);
4953         ostreambuf_iterator_wchar dest = {0, strbuf};
4954
4955         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
4956     }
4957     basic_ostream_wchar_sentry_destroy(this);
4958
4959     basic_ios_wchar_setstate(base, state);
4960     return this;
4961 }
4962
4963 static basic_ostream_wchar* basic_ostream_print_int(basic_ostream_wchar *this, int val, const num_put *numput)
4964 {
4965     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
4966     int state = IOSTATE_goodbit;
4967
4968     TRACE("(%p %d)\n", this, val);
4969
4970     if(basic_ostream_wchar_sentry_create(this)) {
4971         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
4972         ostreambuf_iterator_wchar dest = {0, strbuf};
4973
4974         num_put_wchar_put_long(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
4975     }
4976     basic_ostream_wchar_sentry_destroy(this);
4977
4978     basic_ios_wchar_setstate(base, state);
4979     return this;
4980 }
4981
4982 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@H@Z */
4983 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@H@Z */
4984 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@J@Z */
4985 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@J@Z */
4986 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int, 8)
4987 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int(basic_ostream_wchar *this, int val)
4988 {
4989     return basic_ostream_print_int(this, val, num_put_wchar_use_facet(
4990                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
4991 }
4992
4993 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@H@Z */
4994 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@H@Z */
4995 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@J@Z */
4996 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@J@Z */
4997 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int, 8)
4998 basic_ostream_wchar* __thiscall basic_ostream_short_print_int(basic_ostream_wchar *this, int val)
4999 {
5000     return basic_ostream_print_int(this, val, num_put_short_use_facet(
5001                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5002 }
5003
5004 static basic_ostream_wchar* basic_ostream_print_uint(basic_ostream_wchar *this, unsigned int val, const num_put *numput)
5005 {
5006     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5007     int state = IOSTATE_goodbit;
5008
5009     TRACE("(%p %u)\n", this, val);
5010
5011     if(basic_ostream_wchar_sentry_create(this)) {
5012         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
5013         ostreambuf_iterator_wchar dest = {0, strbuf};
5014
5015         num_put_wchar_put_ulong(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
5016     }
5017     basic_ostream_wchar_sentry_destroy(this);
5018
5019     basic_ios_wchar_setstate(base, state);
5020     return this;
5021 }
5022
5023 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@I@Z */
5024 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@I@Z */
5025 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@K@Z */
5026 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@K@Z */
5027 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint, 8)
5028 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint(basic_ostream_wchar *this, unsigned int val)
5029 {
5030     return basic_ostream_print_uint(this, val, num_put_wchar_use_facet(
5031                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5032 }
5033
5034 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@I@Z */
5035 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@I@Z */
5036 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@K@Z */
5037 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@K@Z */
5038 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint, 8)
5039 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint(basic_ostream_wchar *this, unsigned int val)
5040 {
5041     return basic_ostream_print_uint(this, val, num_put_short_use_facet(
5042                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5043 }
5044
5045 static basic_ostream_wchar* basic_ostream_print_float(basic_ostream_wchar *this, float val, const num_put *numput)
5046 {
5047     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5048     int state = IOSTATE_goodbit;
5049
5050     TRACE("(%p %f)\n", this, val);
5051
5052     if(basic_ostream_wchar_sentry_create(this)) {
5053         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
5054         ostreambuf_iterator_wchar dest = {0, strbuf};
5055
5056         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
5057     }
5058     basic_ostream_wchar_sentry_destroy(this);
5059
5060     basic_ios_wchar_setstate(base, state);
5061     return this;
5062 }
5063
5064 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@M@Z */
5065 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@M@Z */
5066 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_float, 8)
5067 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_float(basic_ostream_wchar *this, float val)
5068 {
5069     return basic_ostream_print_float(this, val, num_put_wchar_use_facet(
5070                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5071 }
5072
5073 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@M@Z */
5074 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@M@Z */
5075 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_float, 8)
5076 basic_ostream_wchar* __thiscall basic_ostream_short_print_float(basic_ostream_wchar *this, float val)
5077 {
5078     return basic_ostream_print_float(this, val, num_put_short_use_facet(
5079                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5080 }
5081
5082 static basic_ostream_wchar* basic_ostream_print_double(basic_ostream_wchar *this, double val, const num_put *numput)
5083 {
5084     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5085     int state = IOSTATE_goodbit;
5086
5087     TRACE("(%p %lf)\n", this, val);
5088
5089     if(basic_ostream_wchar_sentry_create(this)) {
5090         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
5091         ostreambuf_iterator_wchar dest = {0, strbuf};
5092
5093         num_put_wchar_put_double(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
5094     }
5095     basic_ostream_wchar_sentry_destroy(this);
5096
5097     basic_ios_wchar_setstate(base, state);
5098     return this;
5099 }
5100
5101 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@N@Z */
5102 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@N@Z */
5103 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_double, 12)
5104 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_double(basic_ostream_wchar *this, double val)
5105 {
5106     return basic_ostream_print_double(this, val, num_put_wchar_use_facet(
5107                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5108 }
5109
5110 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@N@Z */
5111 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@N@Z */
5112 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_double, 12)
5113 basic_ostream_wchar* __thiscall basic_ostream_short_print_double(basic_ostream_wchar *this, double val)
5114 {
5115     return basic_ostream_print_double(this, val, num_put_short_use_facet(
5116                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5117 }
5118
5119 static basic_ostream_wchar* basic_ostream_print_ldouble(basic_ostream_wchar *this, double val, const num_put *numput)
5120 {
5121     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5122     int state = IOSTATE_goodbit;
5123
5124     TRACE("(%p %lf)\n", this, val);
5125
5126     if(basic_ostream_wchar_sentry_create(this)) {
5127         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
5128         ostreambuf_iterator_wchar dest = {0, strbuf};
5129
5130         num_put_wchar_put_ldouble(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
5131     }
5132     basic_ostream_wchar_sentry_destroy(this);
5133
5134     basic_ios_wchar_setstate(base, state);
5135     return this;
5136 }
5137
5138 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@O@Z */
5139 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@O@Z */
5140 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ldouble, 12)
5141 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ldouble(basic_ostream_wchar *this, double val)
5142 {
5143     return basic_ostream_print_ldouble(this, val, num_put_wchar_use_facet(
5144                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5145 }
5146
5147 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@O@Z */
5148 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@O@Z */
5149 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ldouble, 12)
5150 basic_ostream_wchar* __thiscall basic_ostream_short_print_ldouble(basic_ostream_wchar *this, double val)
5151 {
5152     return basic_ostream_print_ldouble(this, val, num_put_short_use_facet(
5153                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5154 }
5155
5156 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5157 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
5158 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5159 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
5160 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_streambuf, 8)
5161 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_streambuf(basic_ostream_wchar *this, basic_streambuf_wchar *val)
5162 {
5163     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5164     IOSB_iostate state = IOSTATE_badbit;
5165     unsigned short c = '\n';
5166
5167     TRACE("(%p %p)\n", this, val);
5168
5169     if(basic_ostream_wchar_sentry_create(this)) {
5170         for(c = basic_streambuf_wchar_sgetc(val); c!=WEOF;
5171                 c = basic_streambuf_wchar_snextc(val)) {
5172             state = IOSTATE_goodbit;
5173
5174             if(basic_streambuf_wchar_sputc(base->strbuf, c) == WEOF) {
5175                 state = IOSTATE_badbit;
5176                 break;
5177             }
5178         }
5179     }else {
5180         state = IOSTATE_badbit;
5181     }
5182     basic_ostream_wchar_sentry_destroy(this);
5183
5184     ios_base_width_set(&base->base, 0);
5185     basic_ios_wchar_setstate(base, state);
5186     return this;
5187 }
5188
5189 static basic_ostream_wchar* basic_ostream_print_ptr(basic_ostream_wchar *this, const void *val, const num_put *numput)
5190 {
5191     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5192     int state = IOSTATE_goodbit;
5193
5194     TRACE("(%p %p)\n", this, val);
5195
5196     if(basic_ostream_wchar_sentry_create(this)) {
5197         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
5198         ostreambuf_iterator_wchar dest = {0, strbuf};
5199
5200         num_put_wchar_put_ptr(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
5201     }
5202     basic_ostream_wchar_sentry_destroy(this);
5203
5204     basic_ios_wchar_setstate(base, state);
5205     return this;
5206 }
5207
5208 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PBX@Z */
5209 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEBX@Z */
5210 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_ptr, 8)
5211 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_ptr(basic_ostream_wchar *this, const void *val)
5212 {
5213     return basic_ostream_print_ptr(this, val, num_put_wchar_use_facet(
5214                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5215 }
5216
5217 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@PBX@Z */
5218 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEBX@Z */
5219 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_ptr, 8)
5220 basic_ostream_wchar* __thiscall basic_ostream_short_print_ptr(basic_ostream_wchar *this, const void *val)
5221 {
5222     return basic_ostream_print_ptr(this, val, num_put_short_use_facet(
5223                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5224 }
5225
5226 static basic_ostream_wchar* basic_ostream_print_int64(basic_ostream_wchar *this, __int64 val, const num_put *numput)
5227 {
5228     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5229     int state = IOSTATE_goodbit;
5230
5231     TRACE("(%p)\n", this);
5232
5233     if(basic_ostream_wchar_sentry_create(this)) {
5234         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
5235         ostreambuf_iterator_wchar dest = {0, strbuf};
5236
5237         num_put_wchar_put_int64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
5238     }
5239     basic_ostream_wchar_sentry_destroy(this);
5240
5241     basic_ios_wchar_setstate(base, state);
5242     return this;
5243 }
5244
5245 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_J@Z */
5246 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_J@Z */
5247 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_int64, 12)
5248 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_int64(basic_ostream_wchar *this, __int64 val)
5249 {
5250     return basic_ostream_print_int64(this, val, num_put_wchar_use_facet(
5251                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5252 }
5253
5254 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_J@Z */
5255 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_J@Z */
5256 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_int64, 12)
5257 basic_ostream_wchar* __thiscall basic_ostream_short_print_int64(basic_ostream_wchar *this, __int64 val)
5258 {
5259     return basic_ostream_print_int64(this, val, num_put_short_use_facet(
5260                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5261 }
5262
5263 static basic_ostream_wchar* basic_ostream_print_uint64(basic_ostream_wchar *this, unsigned __int64 val, const num_put *numput)
5264 {
5265     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5266     int state = IOSTATE_goodbit;
5267
5268     TRACE("(%p)\n", this);
5269
5270     if(basic_ostream_wchar_sentry_create(this)) {
5271         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
5272         ostreambuf_iterator_wchar dest = {0, strbuf};
5273
5274         num_put_wchar_put_uint64(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
5275     }
5276     basic_ostream_wchar_sentry_destroy(this);
5277
5278     basic_ios_wchar_setstate(base, state);
5279     return this;
5280 }
5281
5282 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_K@Z */
5283 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_K@Z */
5284 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_uint64, 12)
5285 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
5286 {
5287     return basic_ostream_print_uint64(this, val, num_put_wchar_use_facet(
5288                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5289 }
5290
5291 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_K@Z */
5292 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_K@Z */
5293 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_uint64, 12)
5294 basic_ostream_wchar* __thiscall basic_ostream_short_print_uint64(basic_ostream_wchar *this, unsigned __int64 val)
5295 {
5296     return basic_ostream_print_uint64(this, val, num_put_short_use_facet(
5297                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5298 }
5299
5300 static basic_ostream_wchar* basic_ostream_print_bool(basic_ostream_wchar *this, MSVCP_bool val, const num_put *numput)
5301 {
5302     basic_ios_wchar *base = basic_ostream_wchar_get_basic_ios(this);
5303     int state = IOSTATE_goodbit;
5304
5305     TRACE("(%p %x)\n", this, val);
5306
5307     if(basic_ostream_wchar_sentry_create(this)) {
5308         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
5309         ostreambuf_iterator_wchar dest = {0, strbuf};
5310
5311         num_put_wchar_put_bool(numput, &dest, dest, &base->base, basic_ios_wchar_fill_get(base), val);
5312     }
5313     basic_ostream_wchar_sentry_destroy(this);
5314
5315     basic_ios_wchar_setstate(base, state);
5316     return this;
5317 }
5318
5319 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@_N@Z */
5320 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@_N@Z */
5321 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_bool, 8)
5322 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
5323 {
5324     return basic_ostream_print_bool(this, val, num_put_wchar_use_facet(
5325                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5326 }
5327
5328 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@_N@Z */
5329 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@_N@Z */
5330 DEFINE_THISCALL_WRAPPER(basic_ostream_short_print_bool, 8)
5331 basic_ostream_wchar* __thiscall basic_ostream_short_print_bool(basic_ostream_wchar *this, MSVCP_bool val)
5332 {
5333     return basic_ostream_print_bool(this, val, num_put_short_use_facet(
5334                 basic_ios_wchar_rdbuf_get(basic_ostream_wchar_get_basic_ios(this))->loc));
5335 }
5336
5337 /* ?ends@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
5338 /* ?ends@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
5339 /* ?ends@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
5340 /* ?ends@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
5341 basic_ostream_wchar* __cdecl basic_ostream_wchar_ends(basic_ostream_wchar *ostr)
5342 {
5343     TRACE("(%p)\n", ostr);
5344
5345     basic_ostream_wchar_put(ostr, 0);
5346     return ostr;
5347 }
5348
5349 /* ?endl@std@@YAAAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
5350 /* ?endl@std@@YAAEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
5351 /* ?endl@std@@YAAAV?$basic_ostream@GU?$char_traits@G@std@@@1@AAV21@@Z */
5352 /* ?endl@std@@YAAEAV?$basic_ostream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
5353 basic_ostream_wchar* __cdecl basic_ostream_wchar_endl(basic_ostream_wchar *ostr)
5354 {
5355     TRACE("(%p)\n", ostr);
5356
5357     basic_ostream_wchar_put(ostr, '\n');
5358     basic_ostream_wchar_flush(ostr);
5359     return ostr;
5360 }
5361
5362 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
5363 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
5364 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
5365 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
5366 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func, 8)
5367 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func(basic_ostream_wchar *this,
5368         basic_ostream_wchar* (__cdecl *pfunc)(basic_ostream_wchar*))
5369 {
5370     TRACE("(%p %p)\n", this, pfunc);
5371     pfunc(this);
5372     return this;
5373 }
5374
5375 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
5376 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
5377 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
5378 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
5379 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_basic_ios, 8)
5380 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_basic_ios(basic_ostream_wchar *this,
5381         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
5382 {
5383     TRACE("(%p %p)\n", this, pfunc);
5384     pfunc(basic_ostream_wchar_get_basic_ios(this));
5385     return this;
5386 }
5387
5388 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
5389 /* ??6?$basic_ostream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
5390 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
5391 /* ??6?$basic_ostream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
5392 DEFINE_THISCALL_WRAPPER(basic_ostream_wchar_print_func_ios_base, 8)
5393 basic_ostream_wchar* __thiscall basic_ostream_wchar_print_func_ios_base(
5394         basic_ostream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
5395 {
5396     TRACE("(%p %p)\n", this, pfunc);
5397     pfunc(&basic_ostream_wchar_get_basic_ios(this)->base);
5398     return this;
5399 }
5400
5401 /* Caution: basic_istream uses virtual inheritance. */
5402 static inline basic_ios_char* basic_istream_char_get_basic_ios(basic_istream_char *this)
5403 {
5404     return (basic_ios_char*)((char*)this+this->vbtable[1]);
5405 }
5406
5407 static inline basic_ios_char* basic_istream_char_to_basic_ios(basic_istream_char *ptr)
5408 {
5409     return (basic_ios_char*)((char*)ptr+basic_istream_char_vbtable[1]);
5410 }
5411
5412 static inline basic_istream_char* basic_istream_char_from_basic_ios(basic_ios_char *ptr)
5413 {
5414     return (basic_istream_char*)((char*)ptr-basic_istream_char_vbtable[1]);
5415 }
5416
5417 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
5418 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N1@Z */
5419 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_init, 20)
5420 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)
5421 {
5422     basic_ios_char *base;
5423
5424     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
5425
5426     if(virt_init) {
5427         this->vbtable = basic_istream_char_vbtable;
5428         base = basic_istream_char_get_basic_ios(this);
5429         basic_ios_char_ctor(base);
5430     }else {
5431         base = basic_istream_char_get_basic_ios(this);
5432     }
5433
5434     base->base.vtable = &MSVCP_basic_istream_char_vtable;
5435     this->count = 0;
5436     if(!noinit)
5437         basic_ios_char_init(base, strbuf, isstd);
5438     return this;
5439 }
5440
5441 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5442 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@_N@Z */
5443 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor, 16)
5444 basic_istream_char* __thiscall basic_istream_char_ctor(basic_istream_char *this, basic_streambuf_char *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
5445 {
5446     return basic_istream_char_ctor_init(this, strbuf, isstd, FALSE, virt_init);
5447 }
5448
5449 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QAE@W4_Uninitialized@1@@Z */
5450 /* ??0?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
5451 DEFINE_THISCALL_WRAPPER(basic_istream_char_ctor_uninitialized, 12)
5452 basic_istream_char* __thiscall basic_istream_char_ctor_uninitialized(basic_istream_char *this, int uninitialized, MSVCP_bool virt_init)
5453 {
5454     basic_ios_char *base;
5455
5456     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
5457
5458     if(virt_init) {
5459         this->vbtable = basic_istream_char_vbtable;
5460         base = basic_istream_char_get_basic_ios(this);
5461         basic_ios_char_ctor(base);
5462     }else {
5463         base = basic_istream_char_get_basic_ios(this);
5464     }
5465
5466     base->base.vtable = &MSVCP_basic_istream_char_vtable;
5467     ios_base_Addstd(&base->base);
5468     return this;
5469 }
5470
5471 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UAE@XZ */
5472 /* ??1?$basic_istream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
5473 DEFINE_THISCALL_WRAPPER(basic_istream_char_dtor, 4)
5474 void __thiscall basic_istream_char_dtor(basic_ios_char *base)
5475 {
5476     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
5477
5478     /* don't destroy virtual base here */
5479     TRACE("(%p)\n", this);
5480 }
5481
5482 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5483 /* ??_D?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5484 DEFINE_THISCALL_WRAPPER(basic_istream_char_vbase_dtor, 4)
5485 void __thiscall basic_istream_char_vbase_dtor(basic_istream_char *this)
5486 {
5487     TRACE("(%p)\n", this);
5488     basic_istream_char_dtor(basic_istream_char_to_basic_ios(this));
5489     basic_ios_char_dtor(basic_istream_char_get_basic_ios(this));
5490 }
5491
5492 DEFINE_THISCALL_WRAPPER(basic_istream_char_vector_dtor, 8)
5493 basic_istream_char* __thiscall basic_istream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
5494 {
5495     basic_istream_char *this = basic_istream_char_from_basic_ios(base);
5496
5497     TRACE("(%p %x)\n", this, flags);
5498
5499     if(flags & 2) {
5500         /* we have an array, with the number of elements stored before the first object */
5501         INT_PTR i, *ptr = (INT_PTR *)this-1;
5502
5503         for(i=*ptr-1; i>=0; i--)
5504             basic_istream_char_vbase_dtor(this+i);
5505         MSVCRT_operator_delete(ptr);
5506     } else {
5507         basic_istream_char_vbase_dtor(this);
5508         if(flags & 1)
5509             MSVCRT_operator_delete(this);
5510     }
5511
5512     return this;
5513 }
5514
5515 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
5516 /* ?_Ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
5517 DEFINE_THISCALL_WRAPPER(basic_istream_char__Ipfx, 8)
5518 MSVCP_bool __thiscall basic_istream_char__Ipfx(basic_istream_char *this, MSVCP_bool noskip)
5519 {
5520     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5521
5522     TRACE("(%p %d)\n", this, noskip);
5523
5524     if(ios_base_good(&base->base)) {
5525         if(basic_ios_char_tie_get(base))
5526             basic_ostream_char_flush(basic_ios_char_tie_get(base));
5527
5528         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
5529             basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5530             const ctype_char *ctype = ctype_char_use_facet(base->strbuf->loc);
5531             int ch;
5532
5533             for(ch = basic_streambuf_char_sgetc(strbuf); ;
5534                     ch = basic_streambuf_char_snextc(strbuf)) {
5535                 if(ch == EOF) {
5536                     basic_ios_char_setstate(base, IOSTATE_eofbit);
5537                     break;
5538                 }
5539
5540                 if(!ctype_char_is_ch(ctype, _SPACE|_BLANK, ch))
5541                     break;
5542             }
5543         }
5544     }
5545
5546     if(!ios_base_good(&base->base)) {
5547         basic_ios_char_setstate(base, IOSTATE_failbit);
5548         return FALSE;
5549     }
5550
5551     return TRUE;
5552 }
5553
5554 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE_N_N@Z */
5555 /* ?ipfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_N_N@Z */
5556 DEFINE_THISCALL_WRAPPER(basic_istream_char_ipfx, 8)
5557 MSVCP_bool __thiscall basic_istream_char_ipfx(basic_istream_char *this, MSVCP_bool noskip)
5558 {
5559     return basic_istream_char__Ipfx(this, noskip);
5560 }
5561
5562 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEXXZ */
5563 /* ?isfx@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
5564 DEFINE_THISCALL_WRAPPER(basic_istream_char_isfx, 4)
5565 void __thiscall basic_istream_char_isfx(basic_istream_char *this)
5566 {
5567     TRACE("(%p)\n", this);
5568 }
5569
5570 static BOOL basic_istream_char_sentry_create(basic_istream_char *istr, MSVCP_bool noskip)
5571 {
5572     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
5573
5574     if(basic_ios_char_rdbuf_get(base))
5575         call_basic_streambuf_char__Lock(base->strbuf);
5576
5577     return basic_istream_char_ipfx(istr, noskip);
5578 }
5579
5580 static void basic_istream_char_sentry_destroy(basic_istream_char *istr)
5581 {
5582     basic_ios_char *base = basic_istream_char_get_basic_ios(istr);
5583
5584     if(basic_ios_char_rdbuf_get(base))
5585         call_basic_streambuf_char__Unlock(base->strbuf);
5586 }
5587
5588 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QBEHXZ */
5589 /* ?gcount@?$basic_istream@DU?$char_traits@D@std@@@std@@QEBA_JXZ */
5590 DEFINE_THISCALL_WRAPPER(basic_istream_char_gcount, 4)
5591 int __thiscall basic_istream_char_gcount(const basic_istream_char *this)
5592 {
5593     TRACE("(%p)\n", this);
5594     return this->count;
5595 }
5596
5597 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
5598 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
5599 DEFINE_THISCALL_WRAPPER(basic_istream_char_get, 4)
5600 int __thiscall basic_istream_char_get(basic_istream_char *this)
5601 {
5602     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5603     int ret;
5604
5605     TRACE("(%p)\n", this);
5606
5607     this->count = 0;
5608
5609     if(!basic_istream_char_sentry_create(this, TRUE)) {
5610         basic_istream_char_sentry_destroy(this);
5611         return EOF;
5612     }
5613
5614     ret = basic_streambuf_char_sbumpc(basic_ios_char_rdbuf_get(base));
5615     basic_istream_char_sentry_destroy(this);
5616     if(ret == EOF)
5617         basic_ios_char_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
5618     else
5619         this->count++;
5620
5621     return ret;
5622 }
5623
5624 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAD@Z */
5625 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAD@Z */
5626 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_ch, 8)
5627 basic_istream_char* __thiscall basic_istream_char_get_ch(basic_istream_char *this, char *ch)
5628 {
5629     int ret;
5630
5631     TRACE("(%p %p)\n", this, ch);
5632
5633     ret = basic_istream_char_get(this);
5634     if(ret != EOF)
5635         *ch = (char)ret;
5636     return this;
5637 }
5638
5639 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
5640 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
5641 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str_delim, 20)
5642 basic_istream_char* __thiscall basic_istream_char_get_str_delim(basic_istream_char *this, char *str, streamsize count, char delim)
5643 {
5644     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5645     int ch = delim;
5646
5647     TRACE("(%p %p %s %c)\n", this, str, wine_dbgstr_longlong(count), delim);
5648
5649     this->count = 0;
5650
5651     if(basic_istream_char_sentry_create(this, TRUE)) {
5652         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5653
5654         for(ch = basic_streambuf_char_sgetc(strbuf); count>1;
5655                 ch = basic_streambuf_char_snextc(strbuf)) {
5656             if(ch==EOF || ch==delim)
5657                 break;
5658
5659             *str++ = ch;
5660             this->count++;
5661             count--;
5662         }
5663     }
5664     basic_istream_char_sentry_destroy(this);
5665
5666     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
5667             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
5668     if(count > 0)
5669         *str = 0;
5670     return this;
5671 }
5672
5673 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
5674 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
5675 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_str, 16)
5676 basic_istream_char* __thiscall basic_istream_char_get_str(basic_istream_char *this, char *str, streamsize count)
5677 {
5678     return basic_istream_char_get_str_delim(this, str, count, '\n');
5679 }
5680
5681 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
5682 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@D@Z */
5683 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf_delim, 12)
5684 basic_istream_char* __thiscall basic_istream_char_get_streambuf_delim(basic_istream_char *this, basic_streambuf_char *strbuf, char delim)
5685 {
5686     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5687     int ch = delim;
5688
5689     TRACE("(%p %p %c)\n", this, strbuf, delim);
5690
5691     this->count = 0;
5692
5693     if(basic_istream_char_sentry_create(this, TRUE)) {
5694         basic_streambuf_char *strbuf_read = basic_ios_char_rdbuf_get(base);
5695
5696         for(ch = basic_streambuf_char_sgetc(strbuf_read); ;
5697                 ch = basic_streambuf_char_snextc(strbuf_read)) {
5698             if(ch==EOF || ch==delim)
5699                 break;
5700
5701             if(basic_streambuf_char_sputc(strbuf, ch) == EOF)
5702                 break;
5703             this->count++;
5704         }
5705     }
5706     basic_istream_char_sentry_destroy(this);
5707
5708     basic_ios_char_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
5709             (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
5710     return this;
5711 }
5712
5713 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@AAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
5714 /* ?get@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@@Z */
5715 DEFINE_THISCALL_WRAPPER(basic_istream_char_get_streambuf, 8)
5716 basic_istream_char* __thiscall basic_istream_char_get_streambuf(basic_istream_char *this, basic_streambuf_char *strbuf)
5717 {
5718     return basic_istream_char_get_streambuf_delim(this, strbuf, '\n');
5719 }
5720
5721 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADHD@Z */
5722 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_JD@Z */
5723 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline_delim, 20)
5724 basic_istream_char* __thiscall basic_istream_char_getline_delim(basic_istream_char *this, char *str, streamsize count, char delim)
5725 {
5726     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5727     int ch = (unsigned char)delim;
5728
5729     TRACE("(%p %p %s %c)\n", this, str, wine_dbgstr_longlong(count), delim);
5730
5731     this->count = 0;
5732
5733     if(basic_istream_char_sentry_create(this, TRUE) && count>0) {
5734         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5735
5736         while(count > 1) {
5737             ch = basic_streambuf_char_sbumpc(strbuf);
5738
5739             if(ch==EOF || ch==(unsigned char)delim)
5740                 break;
5741
5742             *str++ = ch;
5743             this->count++;
5744             count--;
5745         }
5746
5747         if(ch == (unsigned char)delim)
5748             this->count++;
5749         else if(ch != EOF) {
5750             ch = basic_streambuf_char_sgetc(strbuf);
5751
5752             if(ch == (unsigned char)delim) {
5753                 basic_streambuf_char__Gninc(strbuf);
5754                 this->count++;
5755             }
5756         }
5757     }
5758     basic_istream_char_sentry_destroy(this);
5759
5760     basic_ios_char_setstate(base, (ch==EOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
5761             (!this->count || (ch!=(unsigned char)delim && ch!=EOF) ? IOSTATE_failbit : IOSTATE_goodbit));
5762     if(count > 0)
5763         *str = 0;
5764     return this;
5765 }
5766
5767 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
5768 /* ?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
5769 DEFINE_THISCALL_WRAPPER(basic_istream_char_getline, 16)
5770 basic_istream_char* __thiscall basic_istream_char_getline(basic_istream_char *this, char *str, streamsize count)
5771 {
5772     return basic_istream_char_getline_delim(this, str, count, '\n');
5773 }
5774
5775 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@HH@Z */
5776 /* ?ignore@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
5777 DEFINE_THISCALL_WRAPPER(basic_istream_char_ignore, 16)
5778 basic_istream_char* __thiscall basic_istream_char_ignore(basic_istream_char *this, streamsize count, int delim)
5779 {
5780     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5781     int ch = (unsigned char)delim;
5782     unsigned int state;
5783
5784     TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(count), delim);
5785
5786     this->count = 0;
5787
5788     if(basic_istream_char_sentry_create(this, TRUE)) {
5789         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5790         state = IOSTATE_goodbit;
5791
5792         while(count > 0) {
5793             ch = basic_streambuf_char_sbumpc(strbuf);
5794
5795             if(ch==EOF) {
5796                 state = IOSTATE_eofbit;
5797                 break;
5798             }
5799
5800             if(ch==(unsigned char)delim)
5801                 break;
5802
5803             this->count++;
5804             if(count != INT_MAX)
5805                 count--;
5806         }
5807     }else
5808         state = IOSTATE_failbit;
5809     basic_istream_char_sentry_destroy(this);
5810
5811     basic_ios_char_setstate(base, state);
5812     return this;
5813 }
5814
5815 /* ?ws@std@@YAAAV?$basic_istream@DU?$char_traits@D@std@@@1@AAV21@@Z */
5816 /* ?ws@std@@YAAEAV?$basic_istream@DU?$char_traits@D@std@@@1@AEAV21@@Z */
5817 basic_istream_char* __cdecl ws_basic_istream_char(basic_istream_char *istream)
5818 {
5819     basic_ios_char *base = basic_istream_char_get_basic_ios(istream);
5820     int ch = '\n';
5821
5822     TRACE("(%p)\n", istream);
5823
5824     if(basic_istream_char_sentry_create(istream, TRUE)) {
5825         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5826         const ctype_char *ctype = ctype_char_use_facet(strbuf->loc);
5827
5828         for(ch = basic_streambuf_char_sgetc(strbuf); ctype_char_is_ch(ctype, _SPACE, ch);
5829                 ch = basic_streambuf_char_snextc(strbuf)) {
5830             if(ch == EOF)
5831                 break;
5832         }
5833     }
5834     basic_istream_char_sentry_destroy(istream);
5835
5836     if(ch == EOF)
5837         basic_ios_char_setstate(base, IOSTATE_eofbit);
5838     return istream;
5839 }
5840
5841 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
5842 /* ?peek@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
5843 DEFINE_THISCALL_WRAPPER(basic_istream_char_peek, 4)
5844 int __thiscall basic_istream_char_peek(basic_istream_char *this)
5845 {
5846     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5847     int ret = EOF;
5848
5849     TRACE("(%p)\n", this);
5850
5851     this->count = 0;
5852
5853     if(basic_istream_char_sentry_create(this, TRUE))
5854         ret = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base));
5855     basic_istream_char_sentry_destroy(this);
5856
5857     if (ret == EOF)
5858         basic_ios_char_setstate(base, IOSTATE_eofbit);
5859
5860     return ret;
5861 }
5862
5863 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADIH@Z */
5864 /* ?_Read_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_K_J@Z */
5865 static basic_istream_char* basic_istream_char__Read_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
5866 {
5867     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5868     IOSB_iostate state = IOSTATE_goodbit;
5869
5870     TRACE("(%p %p %lu %s)\n", this, str, size, wine_dbgstr_longlong(count));
5871
5872     if(basic_istream_char_sentry_create(this, TRUE)) {
5873         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5874
5875         this->count = basic_streambuf_char__Sgetn_s(strbuf, str, size, count);
5876         if(this->count != count)
5877             state |= IOSTATE_failbit | IOSTATE_eofbit;
5878     }else {
5879         this->count = 0;
5880     }
5881     basic_istream_char_sentry_destroy(this);
5882
5883     basic_ios_char_setstate(base, state);
5884     return this;
5885 }
5886
5887 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z */
5888 /* ?read@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@PEAD_J@Z */
5889 DEFINE_THISCALL_WRAPPER(basic_istream_char_read, 16)
5890 basic_istream_char* __thiscall basic_istream_char_read(basic_istream_char *this, char *str, streamsize count)
5891 {
5892     return basic_istream_char__Read_s(this, str, count, count);
5893 }
5894
5895 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADIH@Z */
5896 /* ?_Readsome_s@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_K_J@Z */
5897 static streamsize basic_istream_char__Readsome_s(basic_istream_char *this, char *str, MSVCP_size_t size, streamsize count)
5898 {
5899     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5900     IOSB_iostate state = IOSTATE_goodbit;
5901
5902     TRACE("(%p %p %lu %s)\n", this, str, size, wine_dbgstr_longlong(count));
5903
5904     this->count = 0;
5905
5906     if(basic_istream_char_sentry_create(this, TRUE)) {
5907         streamsize avail = basic_streambuf_char_in_avail(basic_ios_char_rdbuf_get(base));
5908         if(avail > count)
5909             avail = count;
5910
5911         if(avail == -1)
5912             state |= IOSTATE_eofbit;
5913         else if(avail > 0)
5914             basic_istream_char__Read_s(this, str, size, avail);
5915     }else {
5916         state |= IOSTATE_failbit;
5917     }
5918     basic_istream_char_sentry_destroy(this);
5919
5920     basic_ios_char_setstate(base, state);
5921     return this->count;
5922 }
5923
5924 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHPADH@Z */
5925 /* ?readsome@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA_JPEAD_J@Z */
5926 DEFINE_THISCALL_WRAPPER(basic_istream_char_readsome, 16)
5927 streamsize __thiscall basic_istream_char_readsome(basic_istream_char *this, char *str, streamsize count)
5928 {
5929     return basic_istream_char__Readsome_s(this, str, count, count);
5930 }
5931
5932 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@D@Z */
5933 /* ?putback@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@D@Z */
5934 DEFINE_THISCALL_WRAPPER(basic_istream_char_putback, 8)
5935 basic_istream_char* __thiscall basic_istream_char_putback(basic_istream_char *this, char ch)
5936 {
5937     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5938     IOSB_iostate state = IOSTATE_goodbit;
5939
5940     TRACE("(%p %c)\n", this, ch);
5941
5942     this->count = 0;
5943
5944     if(basic_istream_char_sentry_create(this, TRUE)) {
5945         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5946
5947         if(!ios_base_good(&base->base))
5948             state |= IOSTATE_failbit;
5949         else if(!strbuf || basic_streambuf_char_sputbackc(strbuf, ch)==EOF)
5950             state |= IOSTATE_badbit;
5951     }
5952     basic_istream_char_sentry_destroy(this);
5953
5954     basic_ios_char_setstate(base, state);
5955     return this;
5956 }
5957
5958 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ */
5959 /* ?unget@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@XZ */
5960 DEFINE_THISCALL_WRAPPER(basic_istream_char_unget, 4)
5961 basic_istream_char* __thiscall basic_istream_char_unget(basic_istream_char *this)
5962 {
5963     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5964     IOSB_iostate state = IOSTATE_goodbit;
5965
5966     TRACE("(%p)\n", this);
5967
5968     this->count = 0;
5969
5970     if(basic_istream_char_sentry_create(this, TRUE)) {
5971         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5972
5973         if(!ios_base_good(&base->base))
5974             state |= IOSTATE_failbit;
5975         else if(!strbuf || basic_streambuf_char_sungetc(strbuf)==EOF)
5976             state |= IOSTATE_badbit;
5977     }
5978     basic_istream_char_sentry_destroy(this);
5979
5980     basic_ios_char_setstate(base, state);
5981     return this;
5982 }
5983
5984 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEHXZ */
5985 /* ?sync@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAHXZ */
5986 DEFINE_THISCALL_WRAPPER(basic_istream_char_sync, 4)
5987 int __thiscall basic_istream_char_sync(basic_istream_char *this)
5988 {
5989     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
5990     basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
5991
5992     TRACE("(%p)\n", this);
5993
5994     if(!strbuf)
5995         return -1;
5996
5997     if(basic_istream_char_sentry_create(this, TRUE)) {
5998         if(basic_streambuf_char_pubsync(strbuf) != -1) {
5999             basic_istream_char_sentry_destroy(this);
6000             return 0;
6001         }
6002     }
6003     basic_istream_char_sentry_destroy(this);
6004
6005     basic_ios_char_setstate(base, IOSTATE_badbit);
6006     return -1;
6007 }
6008
6009 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAE?AV?$fpos@H@2@XZ */
6010 /* ?tellg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
6011 DEFINE_THISCALL_WRAPPER(basic_istream_char_tellg, 8)
6012 fpos_int* __thiscall basic_istream_char_tellg(basic_istream_char *this, fpos_int *ret)
6013 {
6014     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6015
6016     TRACE("(%p %p)\n", this, ret);
6017
6018     if(ios_base_fail(&base->base)) {
6019         ret->off = -1;
6020         ret->pos = 0;
6021         ret->state = 0;
6022         return ret;
6023     }
6024
6025     basic_streambuf_char_pubseekoff(basic_ios_char_rdbuf_get(base),
6026             ret, 0, SEEKDIR_cur, OPENMODE_in);
6027
6028     if(ret->off==-1 && ret->pos==0 && ret->state==0)
6029         basic_ios_char_setstate(base, IOSTATE_failbit);
6030
6031     return ret;
6032 }
6033
6034 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@JH@Z */
6035 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@_JH@Z */
6036 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg, 16)
6037 basic_istream_char* __thiscall basic_istream_char_seekg(basic_istream_char *this, streamoff off, int dir)
6038 {
6039     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6040
6041     TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(off), dir);
6042
6043     if(!ios_base_fail(&base->base)) {
6044         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6045         fpos_int ret;
6046
6047         basic_streambuf_char_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
6048
6049         if(ret.off==-1 && ret.pos==0 && ret.state==0)
6050             basic_ios_char_setstate(base, IOSTATE_failbit);
6051         else
6052             basic_ios_char_clear(base, IOSTATE_goodbit);
6053         return this;
6054     }else
6055         basic_ios_char_clear(base, IOSTATE_goodbit);
6056
6057     return this;
6058 }
6059
6060 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
6061 /* ?seekg@?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
6062 DEFINE_THISCALL_WRAPPER(basic_istream_char_seekg_fpos, 28)
6063 basic_istream_char* __thiscall basic_istream_char_seekg_fpos(basic_istream_char *this, fpos_int pos)
6064 {
6065     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6066
6067     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
6068
6069     if(!ios_base_fail(&base->base)) {
6070         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6071         fpos_int ret;
6072
6073         basic_streambuf_char_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
6074
6075         if(ret.off==-1 && ret.pos==0 && ret.state==0)
6076             basic_ios_char_setstate(base, IOSTATE_failbit);
6077         else
6078             basic_ios_char_clear(base, IOSTATE_goodbit);
6079         return this;
6080     }else
6081         basic_ios_char_clear(base, IOSTATE_goodbit);
6082
6083     return this;
6084 }
6085
6086 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAF@Z */
6087 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAF@Z */
6088 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_short, 8)
6089 basic_istream_char* __thiscall basic_istream_char_read_short(basic_istream_char *this, short *v)
6090 {
6091     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6092     int state = IOSTATE_goodbit;
6093
6094     TRACE("(%p %p)\n", this, v);
6095
6096     if(basic_istream_char_sentry_create(this, FALSE)) {
6097         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6098         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6099         istreambuf_iterator_char first={0}, last={0};
6100         LONG tmp;
6101
6102         first.strbuf = strbuf;
6103         num_get_char_get_long(numget, &last, first, last, &base->base, &state, &tmp);
6104
6105         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
6106             *v = tmp;
6107         else
6108             state |= IOSTATE_failbit;
6109     }
6110     basic_istream_char_sentry_destroy(this);
6111
6112     basic_ios_char_setstate(base, state);
6113     return this;
6114 }
6115
6116 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAG@Z */
6117 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAG@Z */
6118 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ushort, 8)
6119 basic_istream_char* __thiscall basic_istream_char_read_ushort(basic_istream_char *this, unsigned short *v)
6120 {
6121     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6122     int state = IOSTATE_goodbit;
6123
6124     TRACE("(%p %p)\n", this, v);
6125
6126     if(basic_istream_char_sentry_create(this, FALSE)) {
6127         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6128         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6129         istreambuf_iterator_char first={0}, last={0};
6130
6131         first.strbuf = strbuf;
6132         num_get_char_get_ushort(numget, &last, first, last, &base->base, &state, v);
6133     }
6134     basic_istream_char_sentry_destroy(this);
6135
6136     basic_ios_char_setstate(base, state);
6137     return this;
6138 }
6139
6140 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z */
6141 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAH@Z */
6142 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int, 8)
6143 basic_istream_char* __thiscall basic_istream_char_read_int(basic_istream_char *this, int *v)
6144 {
6145     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6146     int state = IOSTATE_goodbit;
6147
6148     TRACE("(%p %p)\n", this, v);
6149
6150     if(basic_istream_char_sentry_create(this, FALSE)) {
6151         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6152         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6153         istreambuf_iterator_char first={0}, last={0};
6154
6155         first.strbuf = strbuf;
6156         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
6157     }
6158     basic_istream_char_sentry_destroy(this);
6159
6160     basic_ios_char_setstate(base, state);
6161     return this;
6162 }
6163
6164 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAI@Z */
6165 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAI@Z */
6166 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint, 8)
6167 basic_istream_char* __thiscall basic_istream_char_read_uint(basic_istream_char *this, unsigned int *v)
6168 {
6169     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6170     int state = IOSTATE_goodbit;
6171
6172     TRACE("(%p %p)\n", this, v);
6173
6174     if(basic_istream_char_sentry_create(this, FALSE)) {
6175         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6176         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6177         istreambuf_iterator_char first={0}, last={0};
6178
6179         first.strbuf = strbuf;
6180         num_get_char_get_uint(numget, &last, first, last, &base->base, &state, v);
6181     }
6182     basic_istream_char_sentry_destroy(this);
6183
6184     basic_ios_char_setstate(base, state);
6185     return this;
6186 }
6187
6188 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAJ@Z */
6189 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAJ@Z */
6190 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_long, 8)
6191 basic_istream_char* __thiscall basic_istream_char_read_long(basic_istream_char *this, LONG *v)
6192 {
6193     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6194     int state = IOSTATE_goodbit;
6195
6196     TRACE("(%p %p)\n", this, v);
6197
6198     if(basic_istream_char_sentry_create(this, FALSE)) {
6199         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6200         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6201         istreambuf_iterator_char first={0}, last={0};
6202
6203         first.strbuf = strbuf;
6204         num_get_char_get_long(numget, &last, first, last, &base->base, &state, v);
6205     }
6206     basic_istream_char_sentry_destroy(this);
6207
6208     basic_ios_char_setstate(base, state);
6209     return this;
6210 }
6211
6212 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAK@Z */
6213 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAK@Z */
6214 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ulong, 8)
6215 basic_istream_char* __thiscall basic_istream_char_read_ulong(basic_istream_char *this, ULONG *v)
6216 {
6217     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6218     int state = IOSTATE_goodbit;
6219
6220     TRACE("(%p %p)\n", this, v);
6221
6222     if(basic_istream_char_sentry_create(this, FALSE)) {
6223         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6224         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6225         istreambuf_iterator_char first={0}, last={0};
6226
6227         first.strbuf = strbuf;
6228         num_get_char_get_ulong(numget, &last, first, last, &base->base, &state, v);
6229     }
6230     basic_istream_char_sentry_destroy(this);
6231
6232     basic_ios_char_setstate(base, state);
6233     return this;
6234 }
6235
6236 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z */
6237 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAM@Z */
6238 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_float, 8)
6239 basic_istream_char* __thiscall basic_istream_char_read_float(basic_istream_char *this, float *v)
6240 {
6241     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6242     int state = IOSTATE_goodbit;
6243
6244     TRACE("(%p %p)\n", this, v);
6245
6246     if(basic_istream_char_sentry_create(this, FALSE)) {
6247         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6248         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6249         istreambuf_iterator_char first={0}, last={0};
6250
6251         first.strbuf = strbuf;
6252         num_get_char_get_float(numget, &last, first, last, &base->base, &state, v);
6253     }
6254     basic_istream_char_sentry_destroy(this);
6255
6256     basic_ios_char_setstate(base, state);
6257     return this;
6258 }
6259
6260 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAN@Z */
6261 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAN@Z */
6262 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_double, 8)
6263 basic_istream_char* __thiscall basic_istream_char_read_double(basic_istream_char *this, double *v)
6264 {
6265     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6266     int state = IOSTATE_goodbit;
6267
6268     TRACE("(%p %p)\n", this, v);
6269
6270     if(basic_istream_char_sentry_create(this, FALSE)) {
6271         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6272         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6273         istreambuf_iterator_char first={0}, last={0};
6274
6275         first.strbuf = strbuf;
6276         num_get_char_get_double(numget, &last, first, last, &base->base, &state, v);
6277     }
6278     basic_istream_char_sentry_destroy(this);
6279
6280     basic_ios_char_setstate(base, state);
6281     return this;
6282 }
6283
6284 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAO@Z */
6285 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAO@Z */
6286 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ldouble, 8)
6287 basic_istream_char* __thiscall basic_istream_char_read_ldouble(basic_istream_char *this, double *v)
6288 {
6289     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6290     int state = IOSTATE_goodbit;
6291
6292     TRACE("(%p %p)\n", this, v);
6293
6294     if(basic_istream_char_sentry_create(this, FALSE)) {
6295         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6296         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6297         istreambuf_iterator_char first={0}, last={0};
6298
6299         first.strbuf = strbuf;
6300         num_get_char_get_ldouble(numget, &last, first, last, &base->base, &state, v);
6301     }
6302     basic_istream_char_sentry_destroy(this);
6303
6304     basic_ios_char_setstate(base, state);
6305     return this;
6306 }
6307
6308 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAPAX@Z */
6309 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
6310 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_ptr, 8)
6311 basic_istream_char* __thiscall basic_istream_char_read_ptr(basic_istream_char *this, void **v)
6312 {
6313     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6314     int state = IOSTATE_goodbit;
6315
6316     TRACE("(%p %p)\n", this, v);
6317
6318     if(basic_istream_char_sentry_create(this, FALSE)) {
6319         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6320         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6321         istreambuf_iterator_char first={0}, last={0};
6322
6323         first.strbuf = strbuf;
6324         num_get_char_get_void(numget, &last, first, last, &base->base, &state, v);
6325     }
6326     basic_istream_char_sentry_destroy(this);
6327
6328     basic_ios_char_setstate(base, state);
6329     return this;
6330 }
6331
6332 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_J@Z */
6333 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_J@Z */
6334 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_int64, 8)
6335 basic_istream_char* __thiscall basic_istream_char_read_int64(basic_istream_char *this, __int64 *v)
6336 {
6337     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6338     int state = IOSTATE_goodbit;
6339
6340     TRACE("(%p %p)\n", this, v);
6341
6342     if(basic_istream_char_sentry_create(this, FALSE)) {
6343         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6344         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6345         istreambuf_iterator_char first={0}, last={0};
6346
6347         first.strbuf = strbuf;
6348         num_get_char_get_int64(numget, &last, first, last, &base->base, &state, v);
6349     }
6350     basic_istream_char_sentry_destroy(this);
6351
6352     basic_ios_char_setstate(base, state);
6353     return this;
6354 }
6355
6356 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_K@Z */
6357 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_K@Z */
6358 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_uint64, 8)
6359 basic_istream_char* __thiscall basic_istream_char_read_uint64(basic_istream_char *this, unsigned __int64 *v)
6360 {
6361     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6362     int state = IOSTATE_goodbit;
6363
6364     TRACE("(%p %p)\n", this, v);
6365
6366     if(basic_istream_char_sentry_create(this, FALSE)) {
6367         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6368         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6369         istreambuf_iterator_char first={0}, last={0};
6370
6371         first.strbuf = strbuf;
6372         num_get_char_get_uint64(numget, &last, first, last, &base->base, &state, v);
6373     }
6374     basic_istream_char_sentry_destroy(this);
6375
6376     basic_ios_char_setstate(base, state);
6377     return this;
6378 }
6379
6380 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AA_N@Z */
6381 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@AEA_N@Z */
6382 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_bool, 8)
6383 basic_istream_char* __thiscall basic_istream_char_read_bool(basic_istream_char *this, MSVCP_bool *v)
6384 {
6385     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6386     int state = IOSTATE_goodbit;
6387
6388     TRACE("(%p %p)\n", this, v);
6389
6390     if(basic_istream_char_sentry_create(this, FALSE)) {
6391         basic_streambuf_char *strbuf = basic_ios_char_rdbuf_get(base);
6392         const num_get *numget = num_get_char_use_facet(strbuf->loc);
6393         istreambuf_iterator_char first={0}, last={0};
6394
6395         first.strbuf = strbuf;
6396         num_get_char_get_bool(numget, &last, first, last, &base->base, &state, v);
6397     }
6398     basic_istream_char_sentry_destroy(this);
6399
6400     basic_ios_char_setstate(base, state);
6401     return this;
6402 }
6403
6404 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
6405 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
6406 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_streambuf, 8)
6407 basic_istream_char* __thiscall basic_istream_char_read_streambuf(
6408         basic_istream_char *this, basic_streambuf_char *streambuf)
6409 {
6410     basic_ios_char *base = basic_istream_char_get_basic_ios(this);
6411     IOSB_iostate state = IOSTATE_failbit;
6412     int c = '\n';
6413
6414     TRACE("(%p %p)\n", this, streambuf);
6415
6416     if(basic_istream_char_sentry_create(this, FALSE)) {
6417         for(c = basic_streambuf_char_sgetc(basic_ios_char_rdbuf_get(base)); c!=EOF;
6418                 c = basic_streambuf_char_snextc(basic_ios_char_rdbuf_get(base))) {
6419             state = IOSTATE_goodbit;
6420             if(basic_streambuf_char_sputc(streambuf, c) == EOF)
6421                 break;
6422         }
6423     }
6424     basic_istream_char_sentry_destroy(this);
6425
6426     basic_ios_char_setstate(base, state | (c==EOF ? IOSTATE_eofbit : IOSTATE_goodbit));
6427     return this;
6428 }
6429
6430 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
6431 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
6432 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func, 8)
6433 basic_istream_char* __thiscall basic_istream_char_read_func(basic_istream_char *this,
6434         basic_istream_char* (__cdecl *pfunc)(basic_istream_char*))
6435 {
6436     TRACE("(%p %p)\n", this, pfunc);
6437     pfunc(this);
6438     return this;
6439 }
6440
6441 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@DU?$char_traits@D@std@@@1@AAV21@@Z@Z */
6442 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@DU?$char_traits@D@std@@@1@AEAV21@@Z@Z */
6443 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_basic_ios, 8)
6444 basic_istream_char* __thiscall basic_istream_char_read_func_basic_ios(basic_istream_char *this,
6445         basic_ios_char* (__cdecl *pfunc)(basic_ios_char*))
6446 {
6447     TRACE("(%p %p)\n", this, pfunc);
6448     pfunc(basic_istream_char_get_basic_ios(this));
6449     return this;
6450 }
6451
6452 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
6453 /* ??5?$basic_istream@DU?$char_traits@D@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
6454 DEFINE_THISCALL_WRAPPER(basic_istream_char_read_func_ios_base, 8)
6455 basic_istream_char* __thiscall basic_istream_char_read_func_ios_base(basic_istream_char *this,
6456         ios_base* (__cdecl *pfunc)(ios_base*))
6457 {
6458     TRACE("(%p %p)\n", this, pfunc);
6459     pfunc(&basic_istream_char_get_basic_ios(this)->base);
6460     return this;
6461 }
6462
6463 /* Caution: basic_istream uses virtual inheritance. */
6464 static inline basic_ios_wchar* basic_istream_wchar_get_basic_ios(basic_istream_wchar *this)
6465 {
6466     return (basic_ios_wchar*)((char*)this+this->vbtable[1]);
6467 }
6468
6469 static inline basic_ios_wchar* basic_istream_wchar_to_basic_ios(basic_istream_wchar *ptr)
6470 {
6471     return (basic_ios_wchar*)((char*)ptr+basic_istream_wchar_vbtable[1]);
6472 }
6473
6474 static inline basic_istream_wchar* basic_istream_wchar_from_basic_ios(basic_ios_wchar *ptr)
6475 {
6476     return (basic_istream_wchar*)((char*)ptr-basic_istream_wchar_vbtable[1]);
6477 }
6478
6479 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
6480 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N1@Z */
6481 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_init, 20)
6482 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_init(basic_istream_wchar *this,
6483         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
6484 {
6485     basic_ios_wchar *base;
6486
6487     TRACE("(%p %p %d %d %d)\n", this, strbuf, isstd, noinit, virt_init);
6488
6489     if(virt_init) {
6490         this->vbtable = basic_istream_wchar_vbtable;
6491         base = basic_istream_wchar_get_basic_ios(this);
6492         basic_ios_wchar_ctor(base);
6493     }else {
6494         base = basic_istream_wchar_get_basic_ios(this);
6495     }
6496
6497     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
6498     this->count = 0;
6499     if(!noinit)
6500         basic_ios_wchar_init(base, strbuf, isstd);
6501     return this;
6502 }
6503
6504 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
6505 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N1@Z */
6506 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_init, 20)
6507 basic_istream_wchar* __thiscall basic_istream_short_ctor_init(basic_istream_wchar *this,
6508         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool noinit, MSVCP_bool virt_init)
6509 {
6510     basic_istream_wchar_ctor_init(this, strbuf, isstd, noinit, virt_init);
6511     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
6512     return this;
6513 }
6514
6515 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6516 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@_N@Z */
6517 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor, 16)
6518 basic_istream_wchar* __thiscall basic_istream_wchar_ctor(basic_istream_wchar *this,
6519         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6520 {
6521     return basic_istream_wchar_ctor_init(this, strbuf, isstd, FALSE, virt_init);
6522 }
6523
6524 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6525 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@_N@Z */
6526 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor, 16)
6527 basic_istream_wchar* __thiscall basic_istream_short_ctor(basic_istream_wchar *this,
6528         basic_streambuf_wchar *strbuf, MSVCP_bool isstd, MSVCP_bool virt_init)
6529 {
6530     return basic_istream_short_ctor_init(this, strbuf, isstd, FALSE, virt_init);
6531 }
6532
6533 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE@W4_Uninitialized@1@@Z */
6534 /* ??0?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
6535 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ctor_uninitialized, 12)
6536 basic_istream_wchar* __thiscall basic_istream_wchar_ctor_uninitialized(
6537         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
6538 {
6539     basic_ios_wchar *base;
6540
6541     TRACE("(%p %d %d)\n", this, uninitialized, virt_init);
6542
6543     if(virt_init) {
6544         this->vbtable = basic_istream_wchar_vbtable;
6545         base = basic_istream_wchar_get_basic_ios(this);
6546         basic_ios_wchar_ctor(base);
6547     }else {
6548         base = basic_istream_wchar_get_basic_ios(this);
6549     }
6550
6551     base->base.vtable = &MSVCP_basic_istream_wchar_vtable;
6552     ios_base_Addstd(&base->base);
6553     return this;
6554 }
6555
6556 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QAE@W4_Uninitialized@1@@Z */
6557 /* ??0?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA@W4_Uninitialized@1@@Z */
6558 DEFINE_THISCALL_WRAPPER(basic_istream_short_ctor_uninitialized, 12)
6559 basic_istream_wchar* __thiscall basic_istream_short_ctor_uninitialized(
6560         basic_istream_wchar *this, int uninitialized, MSVCP_bool virt_init)
6561 {
6562     basic_istream_wchar_ctor_uninitialized(this, uninitialized, virt_init);
6563     basic_istream_wchar_get_basic_ios(this)->base.vtable = &MSVCP_basic_istream_short_vtable;
6564     return this;
6565 }
6566
6567 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
6568 /* ??1?$basic_istream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
6569 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UAE@XZ */
6570 /* ??1?$basic_istream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
6571 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_dtor, 4)
6572 void __thiscall basic_istream_wchar_dtor(basic_ios_wchar *base)
6573 {
6574     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
6575
6576     /* don't destroy virtual base here */
6577     TRACE("(%p)\n", this);
6578 }
6579
6580 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6581 /* ??_D?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6582 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6583 /* ??_D?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6584 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vbase_dtor, 4)
6585 void __thiscall basic_istream_wchar_vbase_dtor(basic_istream_wchar *this)
6586 {
6587     TRACE("(%p)\n", this);
6588     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(this));
6589     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(this));
6590 }
6591
6592 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_vector_dtor, 8)
6593 basic_istream_wchar* __thiscall basic_istream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
6594 {
6595     basic_istream_wchar *this = basic_istream_wchar_from_basic_ios(base);
6596
6597     TRACE("(%p %x)\n", this, flags);
6598
6599     if(flags & 2) {
6600         /* we have an array, with the number of elements stored before the first object */
6601         INT_PTR i, *ptr = (INT_PTR *)this-1;
6602
6603         for(i=*ptr-1; i>=0; i--)
6604             basic_istream_wchar_vbase_dtor(this+i);
6605         MSVCRT_operator_delete(ptr);
6606     } else {
6607         basic_istream_wchar_vbase_dtor(this);
6608         if(flags & 1)
6609             MSVCRT_operator_delete(this);
6610     }
6611
6612     return this;
6613 }
6614
6615 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
6616 /* ?_Ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
6617 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
6618 /* ?_Ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
6619 DEFINE_THISCALL_WRAPPER(basic_istream_wchar__Ipfx, 8)
6620 MSVCP_bool __thiscall basic_istream_wchar__Ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
6621 {
6622     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
6623
6624     TRACE("(%p %d)\n", this, noskip);
6625
6626     if(ios_base_good(&base->base)) {
6627         if(basic_ios_wchar_tie_get(base))
6628             basic_ostream_wchar_flush(basic_ios_wchar_tie_get(base));
6629
6630         if(!noskip && (ios_base_flags_get(&base->base) & FMTFLAG_skipws)) {
6631             basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6632             const ctype_wchar *ctype = ctype_wchar_use_facet(base->strbuf->loc);
6633             int ch;
6634
6635             for(ch = basic_streambuf_wchar_sgetc(strbuf); ;
6636                     ch = basic_streambuf_wchar_snextc(strbuf)) {
6637                 if(ch == WEOF) {
6638                     basic_ios_wchar_setstate(base, IOSTATE_eofbit);
6639                     break;
6640                 }
6641
6642                 if(!ctype_wchar_is_ch(ctype, _SPACE|_BLANK, ch))
6643                     break;
6644             }
6645         }
6646     }
6647
6648     if(!ios_base_good(&base->base)) {
6649         basic_ios_wchar_setstate(base, IOSTATE_failbit);
6650         return FALSE;
6651     }
6652     return TRUE;
6653 }
6654
6655 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE_N_N@Z */
6656 /* ?ipfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_N_N@Z */
6657 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE_N_N@Z */
6658 /* ?ipfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_N_N@Z */
6659 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ipfx, 8)
6660 MSVCP_bool __thiscall basic_istream_wchar_ipfx(basic_istream_wchar *this, MSVCP_bool noskip)
6661 {
6662     return basic_istream_wchar__Ipfx(this, noskip);
6663 }
6664
6665 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
6666 /* ?isfx@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
6667 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEXXZ */
6668 /* ?isfx@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
6669 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_isfx, 4)
6670 void __thiscall basic_istream_wchar_isfx(basic_istream_wchar *this)
6671 {
6672     TRACE("(%p)\n", this);
6673 }
6674
6675 static BOOL basic_istream_wchar_sentry_create(basic_istream_wchar *istr, MSVCP_bool noskip)
6676 {
6677     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
6678
6679     if(basic_ios_wchar_rdbuf_get(base))
6680         basic_streambuf_wchar__Lock(base->strbuf);
6681
6682     return basic_istream_wchar_ipfx(istr, noskip);
6683 }
6684
6685 static void basic_istream_wchar_sentry_destroy(basic_istream_wchar *istr)
6686 {
6687     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istr);
6688
6689     if(basic_ios_wchar_rdbuf_get(base))
6690         basic_streambuf_wchar__Unlock(base->strbuf);
6691 }
6692
6693 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QBEHXZ */
6694 /* ?gcount@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEBA_JXZ */
6695 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QBEHXZ */
6696 /* ?gcount@?$basic_istream@GU?$char_traits@G@std@@@std@@QEBA_JXZ */
6697 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_gcount, 4)
6698 int __thiscall basic_istream_wchar_gcount(const basic_istream_wchar *this)
6699 {
6700     TRACE("(%p)\n", this);
6701     return this->count;
6702 }
6703
6704 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
6705 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
6706 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
6707 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
6708 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get, 4)
6709 unsigned short __thiscall basic_istream_wchar_get(basic_istream_wchar *this)
6710 {
6711     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
6712     int ret;
6713
6714     TRACE("(%p)\n", this);
6715
6716     this->count = 0;
6717
6718     if(!basic_istream_wchar_sentry_create(this, TRUE)) {
6719         basic_istream_wchar_sentry_destroy(this);
6720         return WEOF;
6721     }
6722
6723     ret = basic_streambuf_wchar_sbumpc(basic_ios_wchar_rdbuf_get(base));
6724     basic_istream_wchar_sentry_destroy(this);
6725     if(ret == WEOF)
6726         basic_ios_wchar_setstate(base, IOSTATE_eofbit|IOSTATE_failbit);
6727     else
6728         this->count++;
6729
6730     return ret;
6731 }
6732
6733 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AA_W@Z */
6734 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEA_W@Z */
6735 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAG@Z */
6736 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAG@Z */
6737 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_ch, 8)
6738 basic_istream_wchar* __thiscall basic_istream_wchar_get_ch(basic_istream_wchar *this, wchar_t *ch)
6739 {
6740     unsigned short ret;
6741
6742     TRACE("(%p %p)\n", this, ch);
6743
6744     ret = basic_istream_wchar_get(this);
6745     if(ret != WEOF)
6746         *ch = (wchar_t)ret;
6747     return this;
6748 }
6749
6750 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
6751 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
6752 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
6753 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
6754 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str_delim, 20)
6755 basic_istream_wchar* __thiscall basic_istream_wchar_get_str_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
6756 {
6757     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
6758     unsigned short ch = delim;
6759
6760     TRACE("(%p %p %s %c)\n", this, str, wine_dbgstr_longlong(count), delim);
6761
6762     this->count = 0;
6763
6764     if(basic_istream_wchar_sentry_create(this, TRUE)) {
6765         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6766
6767         for(ch = basic_streambuf_wchar_sgetc(strbuf); count>1;
6768                 ch = basic_streambuf_wchar_snextc(strbuf)) {
6769             if(ch==WEOF || ch==delim)
6770                 break;
6771
6772             *str++ = ch;
6773             this->count++;
6774             count--;
6775         }
6776     }
6777     basic_istream_wchar_sentry_destroy(this);
6778
6779     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
6780             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
6781     if(count > 0)
6782         *str = 0;
6783     return this;
6784 }
6785
6786 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
6787 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
6788 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
6789 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
6790 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_str, 16)
6791 basic_istream_wchar* __thiscall basic_istream_wchar_get_str(basic_istream_wchar *this, wchar_t *str, streamsize count)
6792 {
6793     return basic_istream_wchar_get_str_delim(this, str, count, '\n');
6794 }
6795
6796 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
6797 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@_W@Z */
6798 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
6799 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@G@Z */
6800 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf_delim, 12)
6801 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf_delim(basic_istream_wchar *this, basic_streambuf_wchar *strbuf, wchar_t delim)
6802 {
6803     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
6804     unsigned short ch = delim;
6805
6806     TRACE("(%p %p %c)\n", this, strbuf, delim);
6807
6808     this->count = 0;
6809
6810     if(basic_istream_wchar_sentry_create(this, TRUE)) {
6811         basic_streambuf_wchar *strbuf_read = basic_ios_wchar_rdbuf_get(base);
6812
6813         for(ch = basic_streambuf_wchar_sgetc(strbuf_read); ;
6814                 ch = basic_streambuf_wchar_snextc(strbuf_read)) {
6815             if(ch==WEOF || ch==delim)
6816                 break;
6817
6818             if(basic_streambuf_wchar_sputc(strbuf, ch) == WEOF)
6819                 break;
6820             this->count++;
6821         }
6822     }
6823     basic_istream_wchar_sentry_destroy(this);
6824
6825     basic_ios_wchar_setstate(base, (!this->count ? IOSTATE_failbit : IOSTATE_goodbit) |
6826             (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
6827     return this;
6828 }
6829
6830 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@AAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
6831 /* ?get@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@2@@Z */
6832 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@AAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
6833 /* ?get@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@AEAV?$basic_streambuf@GU?$char_traits@G@std@@@2@@Z */
6834 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_get_streambuf, 8)
6835 basic_istream_wchar* __thiscall basic_istream_wchar_get_streambuf(basic_istream_wchar *this, basic_streambuf_wchar *strbuf)
6836 {
6837     return basic_istream_wchar_get_streambuf_delim(this, strbuf, '\n');
6838 }
6839
6840 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH_W@Z */
6841 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J_W@Z */
6842 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGHG@Z */
6843 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_JG@Z */
6844 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline_delim, 20)
6845 basic_istream_wchar* __thiscall basic_istream_wchar_getline_delim(basic_istream_wchar *this, wchar_t *str, streamsize count, wchar_t delim)
6846 {
6847     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
6848     unsigned short ch = delim;
6849
6850     TRACE("(%p %p %s %c)\n", this, str, wine_dbgstr_longlong(count), delim);
6851
6852     this->count = 0;
6853
6854     if(basic_istream_wchar_sentry_create(this, TRUE) && count>0) {
6855         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6856
6857         while(count > 1) {
6858             ch = basic_streambuf_wchar_sbumpc(strbuf);
6859
6860             if(ch==WEOF || ch==delim)
6861                 break;
6862
6863             *str++ = ch;
6864             this->count++;
6865             count--;
6866         }
6867
6868         if(ch == delim)
6869             this->count++;
6870         else if(ch != WEOF) {
6871             ch = basic_streambuf_wchar_sgetc(strbuf);
6872
6873             if(ch == delim) {
6874                 basic_streambuf_wchar__Gninc(strbuf);
6875                 this->count++;
6876             }
6877         }
6878     }
6879     basic_istream_wchar_sentry_destroy(this);
6880
6881     basic_ios_wchar_setstate(base, (ch==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit) |
6882             (!this->count || (ch!=delim && ch!=WEOF) ? IOSTATE_failbit : IOSTATE_goodbit));
6883     if(count > 0)
6884         *str = 0;
6885     return this;
6886 }
6887
6888 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
6889 /* ?getline@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
6890 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
6891 /* ?getline@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
6892 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_getline, 16)
6893 basic_istream_wchar* __thiscall basic_istream_wchar_getline(basic_istream_wchar *this, wchar_t *str, streamsize count)
6894 {
6895     return basic_istream_wchar_getline_delim(this, str, count, '\n');
6896 }
6897
6898 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@HG@Z */
6899 /* ?ignore@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JG@Z */
6900 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@HG@Z */
6901 /* ?ignore@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JG@Z */
6902 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_ignore, 16)
6903 basic_istream_wchar* __thiscall basic_istream_wchar_ignore(basic_istream_wchar *this, streamsize count, unsigned short delim)
6904 {
6905     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
6906     unsigned short ch = delim;
6907     unsigned int state;
6908
6909     TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(count), delim);
6910
6911     this->count = 0;
6912
6913     if(basic_istream_wchar_sentry_create(this, TRUE)) {
6914         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6915         state = IOSTATE_goodbit;
6916
6917         while(count > 0) {
6918             ch = basic_streambuf_wchar_sbumpc(strbuf);
6919
6920             if(ch==WEOF) {
6921                 state = IOSTATE_eofbit;
6922                 break;
6923             }
6924
6925             if(ch==delim)
6926                 break;
6927
6928             this->count++;
6929             if(count != INT_MAX)
6930                 count--;
6931         }
6932     }else
6933         state = IOSTATE_failbit;
6934     basic_istream_wchar_sentry_destroy(this);
6935
6936     basic_ios_wchar_setstate(base, state);
6937     return this;
6938 }
6939
6940 /* ?ws@std@@YAAAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AAV21@@Z */
6941 /* ?ws@std@@YAAEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@AEAV21@@Z */
6942 /* ?ws@std@@YAAAV?$basic_istream@GU?$char_traits@G@std@@@1@AAV21@@Z */
6943 /* ?ws@std@@YAAEAV?$basic_istream@GU?$char_traits@G@std@@@1@AEAV21@@Z */
6944 basic_istream_wchar* __cdecl ws_basic_istream_wchar(basic_istream_wchar *istream)
6945 {
6946     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(istream);
6947     unsigned short ch = '\n';
6948
6949     TRACE("(%p)\n", istream);
6950
6951     if(basic_istream_wchar_sentry_create(istream, TRUE)) {
6952         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
6953         const ctype_wchar *ctype = ctype_wchar_use_facet(strbuf->loc);
6954
6955         for(ch = basic_streambuf_wchar_sgetc(strbuf); ctype_wchar_is_ch(ctype, _SPACE, ch);
6956                 ch = basic_streambuf_wchar_snextc(strbuf)) {
6957             if(ch == WEOF)
6958                 break;
6959         }
6960     }
6961     basic_istream_wchar_sentry_destroy(istream);
6962
6963     if(ch == WEOF)
6964         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
6965     return istream;
6966 }
6967
6968 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEGXZ */
6969 /* ?peek@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAGXZ */
6970 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEGXZ */
6971 /* ?peek@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAGXZ */
6972 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_peek, 4)
6973 unsigned short __thiscall basic_istream_wchar_peek(basic_istream_wchar *this)
6974 {
6975     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
6976     unsigned short ret = WEOF;
6977
6978     TRACE("(%p)\n", this);
6979
6980     this->count = 0;
6981
6982     if(basic_istream_wchar_sentry_create(this, TRUE))
6983         ret = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base));
6984     basic_istream_wchar_sentry_destroy(this);
6985
6986     if (ret == WEOF)
6987         basic_ios_wchar_setstate(base, IOSTATE_eofbit);
6988
6989     return ret;
6990 }
6991
6992 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WIH@Z */
6993 /* ?_Read_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_K_J@Z */
6994 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGIH@Z */
6995 /* ?_Read_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_K_J@Z */
6996 static basic_istream_wchar* basic_istream_wchar__Read_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
6997 {
6998     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
6999     IOSB_iostate state = IOSTATE_goodbit;
7000
7001     TRACE("(%p %p %lu %s)\n", this, str, size, wine_dbgstr_longlong(count));
7002
7003     if(basic_istream_wchar_sentry_create(this, TRUE)) {
7004         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7005
7006         this->count = basic_streambuf_wchar__Sgetn_s(strbuf, str, size, count);
7007         if(this->count != count)
7008             state |= IOSTATE_failbit | IOSTATE_eofbit;
7009     }else {
7010         this->count = 0;
7011     }
7012     basic_istream_wchar_sentry_destroy(this);
7013
7014     basic_ios_wchar_setstate(base, state);
7015     return this;
7016 }
7017
7018 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@PA_WH@Z */
7019 /* ?read@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@PEA_W_J@Z */
7020 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@PAGH@Z */
7021 /* ?read@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@PEAG_J@Z */
7022 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read, 16)
7023 basic_istream_wchar* __thiscall basic_istream_wchar_read(basic_istream_wchar *this, wchar_t *str, streamsize count)
7024 {
7025     return basic_istream_wchar__Read_s(this, str, count, count);
7026 }
7027
7028 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WIH@Z */
7029 /* ?_Readsome_s@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_K_J@Z */
7030 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGIH@Z */
7031 /* ?_Readsome_s@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_K_J@Z */
7032 static streamsize basic_istream_wchar__Readsome_s(basic_istream_wchar *this, wchar_t *str, MSVCP_size_t size, streamsize count)
7033 {
7034     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7035     IOSB_iostate state = IOSTATE_goodbit;
7036
7037     TRACE("(%p %p %lu %s)\n", this, str, size, wine_dbgstr_longlong(count));
7038
7039     this->count = 0;
7040
7041     if(basic_istream_wchar_sentry_create(this, TRUE)) {
7042         streamsize avail = basic_streambuf_wchar_in_avail(basic_ios_wchar_rdbuf_get(base));
7043         if(avail > count)
7044             avail = count;
7045
7046         if(avail == -1)
7047             state |= IOSTATE_eofbit;
7048         else if(avail > 0)
7049             basic_istream_wchar__Read_s(this, str, size, avail);
7050     }else {
7051         state |= IOSTATE_failbit;
7052     }
7053     basic_istream_wchar_sentry_destroy(this);
7054
7055     basic_ios_wchar_setstate(base, state);
7056     return this->count;
7057 }
7058
7059 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHPA_WH@Z */
7060 /* ?readsome@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA_JPEA_W_J@Z */
7061 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHPAGH@Z */
7062 /* ?readsome@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA_JPEAG_J@Z */
7063 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_readsome, 16)
7064 streamsize __thiscall basic_istream_wchar_readsome(basic_istream_wchar *this, wchar_t *str, streamsize count)
7065 {
7066     return basic_istream_wchar__Readsome_s(this, str, count, count);
7067 }
7068
7069 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@_W@Z */
7070 /* ?putback@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_W@Z */
7071 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@G@Z */
7072 /* ?putback@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@G@Z */
7073 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_putback, 8)
7074 basic_istream_wchar* __thiscall basic_istream_wchar_putback(basic_istream_wchar *this, wchar_t ch)
7075 {
7076     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7077     IOSB_iostate state = IOSTATE_goodbit;
7078
7079     TRACE("(%p %c)\n", this, ch);
7080
7081     this->count = 0;
7082
7083     if(basic_istream_wchar_sentry_create(this, TRUE)) {
7084         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7085
7086         if(!ios_base_good(&base->base))
7087             state |= IOSTATE_failbit;
7088         else if(!strbuf || basic_streambuf_wchar_sputbackc(strbuf, ch)==WEOF)
7089             state |= IOSTATE_badbit;
7090     }
7091     basic_istream_wchar_sentry_destroy(this);
7092
7093     basic_ios_wchar_setstate(base, state);
7094     return this;
7095 }
7096
7097 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@XZ */
7098 /* ?unget@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@XZ */
7099 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@XZ */
7100 /* ?unget@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@XZ */
7101 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_unget, 4)
7102 basic_istream_wchar* __thiscall basic_istream_wchar_unget(basic_istream_wchar *this)
7103 {
7104     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7105     IOSB_iostate state = IOSTATE_goodbit;
7106
7107     TRACE("(%p)\n", this);
7108
7109     this->count = 0;
7110
7111     if(basic_istream_wchar_sentry_create(this, TRUE)) {
7112         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7113
7114         if(!ios_base_good(&base->base))
7115             state |= IOSTATE_failbit;
7116         else if(!strbuf || basic_streambuf_wchar_sungetc(strbuf)==WEOF)
7117             state |= IOSTATE_badbit;
7118     }
7119     basic_istream_wchar_sentry_destroy(this);
7120
7121     basic_ios_wchar_setstate(base, state);
7122     return this;
7123 }
7124
7125 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEHXZ */
7126 /* ?sync@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAHXZ */
7127 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEHXZ */
7128 /* ?sync@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAHXZ */
7129 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_sync, 4)
7130 int __thiscall basic_istream_wchar_sync(basic_istream_wchar *this)
7131 {
7132     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7133     basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7134
7135     TRACE("(%p)\n", this);
7136
7137     if(!strbuf)
7138         return -1;
7139
7140     if(basic_istream_wchar_sentry_create(this, TRUE)) {
7141         if(basic_streambuf_wchar_pubsync(strbuf) != -1) {
7142             basic_istream_wchar_sentry_destroy(this);
7143             return 0;
7144         }
7145     }
7146     basic_istream_wchar_sentry_destroy(this);
7147
7148     basic_ios_wchar_setstate(base, IOSTATE_badbit);
7149     return -1;
7150 }
7151
7152 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7153 /* ?tellg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7154 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAE?AV?$fpos@H@2@XZ */
7155 /* ?tellg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAA?AV?$fpos@H@2@XZ */
7156 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_tellg, 8)
7157 fpos_int* __thiscall basic_istream_wchar_tellg(basic_istream_wchar *this, fpos_int *ret)
7158 {
7159     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7160
7161     TRACE("(%p %p)\n", this, ret);
7162
7163     if(ios_base_fail(&base->base)) {
7164         ret->off = -1;
7165         ret->pos = 0;
7166         ret->state = 0;
7167         return ret;
7168     }
7169
7170     basic_streambuf_wchar_pubseekoff(basic_ios_wchar_rdbuf_get(base),
7171             ret, 0, SEEKDIR_cur, OPENMODE_in);
7172     if(ret->off==-1 && ret->pos==0 && ret->state==0)
7173         basic_ios_wchar_setstate(base, IOSTATE_failbit);
7174
7175     return ret;
7176 }
7177
7178 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@JH@Z */
7179 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@_JH@Z */
7180 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@JH@Z */
7181 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@_JH@Z */
7182 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg, 16)
7183 basic_istream_wchar* __thiscall basic_istream_wchar_seekg(basic_istream_wchar *this, streamoff off, int dir)
7184 {
7185     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7186
7187     TRACE("(%p %s %d)\n", this, wine_dbgstr_longlong(off), dir);
7188
7189     if(!ios_base_fail(&base->base)) {
7190         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7191         fpos_int ret;
7192
7193         basic_streambuf_wchar_pubseekoff(strbuf, &ret, off, dir, OPENMODE_in);
7194
7195         if(ret.off==-1 && ret.pos==0 && ret.state==0)
7196             basic_ios_wchar_setstate(base, IOSTATE_failbit);
7197         else
7198             basic_ios_wchar_clear(base, IOSTATE_goodbit);
7199         return this;
7200     }else
7201         basic_ios_wchar_clear(base, IOSTATE_goodbit);
7202
7203     return this;
7204 }
7205
7206 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7207 /* ?seekg@?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7208 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV12@V?$fpos@H@2@@Z */
7209 /* ?seekg@?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV12@V?$fpos@H@2@@Z */
7210 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_seekg_fpos, 28)
7211 basic_istream_wchar* __thiscall basic_istream_wchar_seekg_fpos(basic_istream_wchar *this, fpos_int pos)
7212 {
7213     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7214
7215     TRACE("(%p %s)\n", this, debugstr_fpos_int(&pos));
7216
7217     if(!ios_base_fail(&base->base)) {
7218         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7219         fpos_int ret;
7220
7221         basic_streambuf_wchar_pubseekpos(strbuf, &ret, pos, OPENMODE_in);
7222
7223         if(ret.off==-1 && ret.pos==0 && ret.state==0)
7224             basic_ios_wchar_setstate(base, IOSTATE_failbit);
7225         else
7226             basic_ios_wchar_clear(base, IOSTATE_goodbit);
7227         return this;
7228     }else
7229         basic_ios_wchar_clear(base, IOSTATE_goodbit);
7230
7231     return this;
7232 }
7233
7234 static basic_istream_wchar* basic_istream_read_short(basic_istream_wchar *this, short *v, const num_get *numget)
7235 {
7236     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7237     int state = IOSTATE_goodbit;
7238
7239     TRACE("(%p %p)\n", this, v);
7240
7241     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7242         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7243         istreambuf_iterator_wchar first={0}, last={0};
7244         LONG tmp;
7245
7246         first.strbuf = strbuf;
7247         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, &tmp);
7248
7249         if(!(state&IOSTATE_failbit) && tmp==(LONG)((short)tmp))
7250             *v = tmp;
7251         else
7252             state |= IOSTATE_failbit;
7253     }
7254     basic_istream_wchar_sentry_destroy(this);
7255
7256     basic_ios_wchar_setstate(base, state);
7257     return this;
7258 }
7259
7260 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAF@Z */
7261 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAF@Z */
7262 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_short, 8)
7263 basic_istream_wchar* __thiscall basic_istream_wchar_read_short(basic_istream_wchar *this, short *v)
7264 {
7265     return basic_istream_read_short(this, v, num_get_wchar_use_facet(
7266                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7267 }
7268
7269 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAF@Z */
7270 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAF@Z */
7271 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_short, 8)
7272 basic_istream_wchar* __thiscall basic_istream_short_read_short(basic_istream_wchar *this, short *v)
7273 {
7274     return basic_istream_read_short(this, v, num_get_short_use_facet(
7275                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7276 }
7277
7278 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAG@Z */
7279 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAG@Z */
7280 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ushort, 8)
7281 basic_istream_wchar* __thiscall basic_istream_wchar_read_ushort(basic_istream_wchar *this, unsigned short *v)
7282 {
7283     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7284     int state = IOSTATE_goodbit;
7285
7286     TRACE("(%p %p)\n", this, v);
7287
7288     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7289         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7290         const num_get *numget = num_get_wchar_use_facet(strbuf->loc);
7291         istreambuf_iterator_wchar first={0}, last={0};
7292
7293         first.strbuf = strbuf;
7294         num_get_wchar_get_ushort(numget, &last, first, last, &base->base, &state, v);
7295     }
7296     basic_istream_wchar_sentry_destroy(this);
7297
7298     basic_ios_wchar_setstate(base, state);
7299     return this;
7300 }
7301
7302 static basic_istream_wchar* basic_istream_read_int(basic_istream_wchar *this, int *v, const num_get *numget)
7303 {
7304     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7305     int state = IOSTATE_goodbit;
7306
7307     TRACE("(%p %p)\n", this, v);
7308
7309     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7310         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7311         istreambuf_iterator_wchar first={0}, last={0};
7312
7313         first.strbuf = strbuf;
7314         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
7315     }
7316     basic_istream_wchar_sentry_destroy(this);
7317
7318     basic_ios_wchar_setstate(base, state);
7319     return this;
7320 }
7321
7322 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAH@Z */
7323 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAH@Z */
7324 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int, 8)
7325 basic_istream_wchar* __thiscall basic_istream_wchar_read_int(basic_istream_wchar *this, int *v)
7326 {
7327     return basic_istream_read_int(this, v, num_get_wchar_use_facet(
7328                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7329 }
7330
7331 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAH@Z */
7332 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAH@Z */
7333 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int, 8)
7334 basic_istream_wchar* __thiscall basic_istream_short_read_int(basic_istream_wchar *this, int *v)
7335 {
7336     return basic_istream_read_int(this, v, num_get_short_use_facet(
7337                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7338 }
7339
7340 static basic_istream_wchar* basic_istream_read_uint(basic_istream_wchar *this, unsigned int *v, const num_get *numget)
7341 {
7342     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7343     int state = IOSTATE_goodbit;
7344
7345     TRACE("(%p %p)\n", this, v);
7346
7347     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7348         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7349         istreambuf_iterator_wchar first={0}, last={0};
7350
7351         first.strbuf = strbuf;
7352         num_get_wchar_get_uint(numget, &last, first, last, &base->base, &state, v);
7353     }
7354     basic_istream_wchar_sentry_destroy(this);
7355
7356     basic_ios_wchar_setstate(base, state);
7357     return this;
7358 }
7359
7360 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAI@Z */
7361 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAI@Z */
7362 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint, 8)
7363 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint(basic_istream_wchar *this, unsigned int *v)
7364 {
7365     return basic_istream_read_uint(this, v, num_get_wchar_use_facet(
7366                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7367 }
7368
7369 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAI@Z */
7370 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAI@Z */
7371 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint, 8)
7372 basic_istream_wchar* __thiscall basic_istream_short_read_uint(basic_istream_wchar *this, unsigned int *v)
7373 {
7374     return basic_istream_read_uint(this, v, num_get_short_use_facet(
7375                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7376 }
7377
7378 static basic_istream_wchar* basic_istream_read_long(basic_istream_wchar *this, LONG *v, const num_get *numget)
7379 {
7380     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7381     int state = IOSTATE_goodbit;
7382
7383     TRACE("(%p %p)\n", this, v);
7384
7385     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7386         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7387         istreambuf_iterator_wchar first={0}, last={0};
7388
7389         first.strbuf = strbuf;
7390         num_get_wchar_get_long(numget, &last, first, last, &base->base, &state, v);
7391     }
7392     basic_istream_wchar_sentry_destroy(this);
7393
7394     basic_ios_wchar_setstate(base, state);
7395     return this;
7396 }
7397
7398 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
7399 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
7400 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_long, 8)
7401 basic_istream_wchar* __thiscall basic_istream_wchar_read_long(basic_istream_wchar *this, LONG *v)
7402 {
7403     return basic_istream_read_long(this, v, num_get_wchar_use_facet(
7404                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7405 }
7406
7407 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAJ@Z */
7408 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAJ@Z */
7409 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_long, 8)
7410 basic_istream_wchar* __thiscall basic_istream_short_read_long(basic_istream_wchar *this, LONG *v)
7411 {
7412     return basic_istream_read_long(this, v, num_get_short_use_facet(
7413                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7414 }
7415
7416 static basic_istream_wchar* basic_istream_read_ulong(basic_istream_wchar *this, ULONG *v, const num_get *numget)
7417 {
7418     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7419     int state = IOSTATE_goodbit;
7420
7421     TRACE("(%p %p)\n", this, v);
7422
7423     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7424         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7425         istreambuf_iterator_wchar first={0}, last={0};
7426
7427         first.strbuf = strbuf;
7428         num_get_wchar_get_ulong(numget, &last, first, last, &base->base, &state, v);
7429     }
7430     basic_istream_wchar_sentry_destroy(this);
7431
7432     basic_ios_wchar_setstate(base, state);
7433     return this;
7434 }
7435
7436 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAK@Z */
7437 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAK@Z */
7438 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ulong, 8)
7439 basic_istream_wchar* __thiscall basic_istream_wchar_read_ulong(basic_istream_wchar *this, ULONG *v)
7440 {
7441     return basic_istream_read_ulong(this, v, num_get_wchar_use_facet(
7442                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7443 }
7444
7445 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAK@Z */
7446 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAK@Z */
7447 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ulong, 8)
7448 basic_istream_wchar* __thiscall basic_istream_short_read_ulong(basic_istream_wchar *this, ULONG *v)
7449 {
7450     return basic_istream_read_ulong(this, v, num_get_short_use_facet(
7451                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7452 }
7453
7454 static basic_istream_wchar* basic_istream_read_float(basic_istream_wchar *this, float *v, const num_get *numget)
7455 {
7456     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7457     int state = IOSTATE_goodbit;
7458
7459     TRACE("(%p %p)\n", this, v);
7460
7461     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7462         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7463         istreambuf_iterator_wchar first={0}, last={0};
7464
7465         first.strbuf = strbuf;
7466         num_get_wchar_get_float(numget, &last, first, last, &base->base, &state, v);
7467     }
7468     basic_istream_wchar_sentry_destroy(this);
7469
7470     basic_ios_wchar_setstate(base, state);
7471     return this;
7472 }
7473
7474 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAM@Z */
7475 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAM@Z */
7476 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_float, 8)
7477 basic_istream_wchar* __thiscall basic_istream_wchar_read_float(basic_istream_wchar *this, float *v)
7478 {
7479     return basic_istream_read_float(this, v, num_get_wchar_use_facet(
7480                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7481 }
7482
7483 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAM@Z */
7484 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAM@Z */
7485 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_float, 8)
7486 basic_istream_wchar* __thiscall basic_istream_short_read_float(basic_istream_wchar *this, float *v)
7487 {
7488     return basic_istream_read_float(this, v, num_get_short_use_facet(
7489                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7490 }
7491
7492 static basic_istream_wchar* basic_istream_read_double(basic_istream_wchar *this, double *v, const num_get *numget)
7493 {
7494     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7495     int state = IOSTATE_goodbit;
7496
7497     TRACE("(%p %p)\n", this, v);
7498
7499     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7500         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7501         istreambuf_iterator_wchar first={0}, last={0};
7502
7503         first.strbuf = strbuf;
7504         num_get_wchar_get_double(numget, &last, first, last, &base->base, &state, v);
7505     }
7506     basic_istream_wchar_sentry_destroy(this);
7507
7508     basic_ios_wchar_setstate(base, state);
7509     return this;
7510 }
7511
7512 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAN@Z */
7513 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAN@Z */
7514 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_double, 8)
7515 basic_istream_wchar* __thiscall basic_istream_wchar_read_double(basic_istream_wchar *this, double *v)
7516 {
7517     return basic_istream_read_double(this, v, num_get_wchar_use_facet(
7518                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7519 }
7520
7521 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAN@Z */
7522 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAN@Z */
7523 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_double, 8)
7524 basic_istream_wchar* __thiscall basic_istream_short_read_double(basic_istream_wchar *this, double *v)
7525 {
7526     return basic_istream_read_double(this, v, num_get_short_use_facet(
7527                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7528 }
7529
7530 static basic_istream_wchar* basic_istream_read_ldouble(basic_istream_wchar *this, double *v, const num_get *numget)
7531 {
7532     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7533     int state = IOSTATE_goodbit;
7534
7535     TRACE("(%p %p)\n", this, v);
7536
7537     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7538         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7539         istreambuf_iterator_wchar first={0}, last={0};
7540
7541         first.strbuf = strbuf;
7542         num_get_wchar_get_ldouble(numget, &last, first, last, &base->base, &state, v);
7543     }
7544     basic_istream_wchar_sentry_destroy(this);
7545
7546     basic_ios_wchar_setstate(base, state);
7547     return this;
7548 }
7549
7550 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAO@Z */
7551 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAO@Z */
7552 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ldouble, 8)
7553 basic_istream_wchar* __thiscall basic_istream_wchar_read_ldouble(basic_istream_wchar *this, double *v)
7554 {
7555     return basic_istream_read_ldouble(this, v, num_get_wchar_use_facet(
7556                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7557 }
7558
7559 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAO@Z */
7560 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAO@Z */
7561 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ldouble, 8)
7562 basic_istream_wchar* __thiscall basic_istream_short_read_ldouble(basic_istream_wchar *this, double *v)
7563 {
7564     return basic_istream_read_ldouble(this, v, num_get_short_use_facet(
7565                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7566 }
7567
7568 static basic_istream_wchar* basic_istream_read_ptr(basic_istream_wchar *this, void **v, const num_get *numget)
7569 {
7570     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7571     int state = IOSTATE_goodbit;
7572
7573     TRACE("(%p %p)\n", this, v);
7574
7575     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7576         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7577         istreambuf_iterator_wchar first={0}, last={0};
7578
7579         first.strbuf = strbuf;
7580         num_get_wchar_get_void(numget, &last, first, last, &base->base, &state, v);
7581     }
7582     basic_istream_wchar_sentry_destroy(this);
7583
7584     basic_ios_wchar_setstate(base, state);
7585     return this;
7586 }
7587
7588 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AAPAX@Z */
7589 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
7590 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_ptr, 8)
7591 basic_istream_wchar* __thiscall basic_istream_wchar_read_ptr(basic_istream_wchar *this, void **v)
7592 {
7593     return basic_istream_read_ptr(this, v, num_get_wchar_use_facet(
7594                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7595 }
7596
7597 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AAPAX@Z */
7598 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEAPEAX@Z */
7599 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_ptr, 8)
7600 basic_istream_wchar* __thiscall basic_istream_short_read_ptr(basic_istream_wchar *this, void **v)
7601 {
7602     return basic_istream_read_ptr(this, v, num_get_short_use_facet(
7603                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7604 }
7605
7606 static basic_istream_wchar* basic_istream_read_int64(basic_istream_wchar *this, __int64 *v, const num_get *numget)
7607 {
7608     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7609     int state = IOSTATE_goodbit;
7610
7611     TRACE("(%p %p)\n", this, v);
7612
7613     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7614         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7615         istreambuf_iterator_wchar first={0}, last={0};
7616
7617         first.strbuf = strbuf;
7618         num_get_wchar_get_int64(numget, &last, first, last, &base->base, &state, v);
7619     }
7620     basic_istream_wchar_sentry_destroy(this);
7621
7622     basic_ios_wchar_setstate(base, state);
7623     return this;
7624 }
7625
7626 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_J@Z */
7627 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_J@Z */
7628 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_int64, 8)
7629 basic_istream_wchar* __thiscall basic_istream_wchar_read_int64(basic_istream_wchar *this, __int64 *v)
7630 {
7631     return basic_istream_read_int64(this, v, num_get_wchar_use_facet(
7632                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7633 }
7634
7635 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_J@Z */
7636 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_J@Z */
7637 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_int64, 8)
7638 basic_istream_wchar* __thiscall basic_istream_short_read_int64(basic_istream_wchar *this, __int64 *v)
7639 {
7640     return basic_istream_read_int64(this, v, num_get_short_use_facet(
7641                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7642 }
7643
7644 static basic_istream_wchar* basic_istream_read_uint64(basic_istream_wchar *this, unsigned __int64 *v, const num_get *numget)
7645 {
7646     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7647     int state = IOSTATE_goodbit;
7648
7649     TRACE("(%p %p)\n", this, v);
7650
7651     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7652         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7653         istreambuf_iterator_wchar first={0}, last={0};
7654
7655         first.strbuf = strbuf;
7656         num_get_wchar_get_uint64(numget, &last, first, last, &base->base, &state, v);
7657     }
7658     basic_istream_wchar_sentry_destroy(this);
7659
7660     basic_ios_wchar_setstate(base, state);
7661     return this;
7662 }
7663
7664 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_K@Z */
7665 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_K@Z */
7666 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_uint64, 8)
7667 basic_istream_wchar* __thiscall basic_istream_wchar_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
7668 {
7669     return basic_istream_read_uint64(this, v, num_get_wchar_use_facet(
7670                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7671 }
7672
7673 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_K@Z */
7674 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_K@Z */
7675 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_uint64, 8)
7676 basic_istream_wchar* __thiscall basic_istream_short_read_uint64(basic_istream_wchar *this, unsigned __int64 *v)
7677 {
7678     return basic_istream_read_uint64(this, v, num_get_short_use_facet(
7679                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7680 }
7681
7682 static basic_istream_wchar* basic_istream_read_bool(basic_istream_wchar *this, MSVCP_bool *v, const num_get *numget)
7683 {
7684     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7685     int state = IOSTATE_goodbit;
7686
7687     TRACE("(%p %p)\n", this, v);
7688
7689     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7690         basic_streambuf_wchar *strbuf = basic_ios_wchar_rdbuf_get(base);
7691         istreambuf_iterator_wchar first={0}, last={0};
7692
7693         first.strbuf = strbuf;
7694         num_get_wchar_get_bool(numget, &last, first, last, &base->base, &state, v);
7695     }
7696     basic_istream_wchar_sentry_destroy(this);
7697
7698     basic_ios_wchar_setstate(base, state);
7699     return this;
7700 }
7701
7702 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@AA_N@Z */
7703 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@AEA_N@Z */
7704 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_bool, 8)
7705 basic_istream_wchar* __thiscall basic_istream_wchar_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
7706 {
7707     return basic_istream_read_bool(this, v, num_get_wchar_use_facet(
7708                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7709 }
7710
7711 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@AA_N@Z */
7712 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@AEA_N@Z */
7713 DEFINE_THISCALL_WRAPPER(basic_istream_short_read_bool, 8)
7714 basic_istream_wchar* __thiscall basic_istream_short_read_bool(basic_istream_wchar *this, MSVCP_bool *v)
7715 {
7716     return basic_istream_read_bool(this, v, num_get_short_use_facet(
7717                 basic_istream_wchar_get_basic_ios(this)->strbuf->loc));
7718 }
7719
7720 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
7721 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
7722 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
7723 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
7724 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_streambuf, 8)
7725 basic_istream_wchar* __thiscall basic_istream_wchar_read_streambuf(
7726         basic_istream_wchar *this, basic_streambuf_wchar *streambuf)
7727 {
7728     basic_ios_wchar *base = basic_istream_wchar_get_basic_ios(this);
7729     IOSB_iostate state = IOSTATE_failbit;
7730     unsigned short c = '\n';
7731
7732     TRACE("(%p %p)\n", this, streambuf);
7733
7734     if(basic_istream_wchar_sentry_create(this, FALSE)) {
7735         for(c = basic_streambuf_wchar_sgetc(basic_ios_wchar_rdbuf_get(base)); c!=WEOF;
7736                 c = basic_streambuf_wchar_snextc(basic_ios_wchar_rdbuf_get(base))) {
7737             state = IOSTATE_goodbit;
7738             if(basic_streambuf_wchar_sputc(streambuf, c) == WEOF)
7739                 break;
7740         }
7741     }
7742     basic_istream_wchar_sentry_destroy(this);
7743
7744     basic_ios_wchar_setstate(base, state | (c==WEOF ? IOSTATE_eofbit : IOSTATE_goodbit));
7745     return this;
7746 }
7747
7748 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7749 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7750 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z */
7751 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV01@AEAV01@@Z@Z */
7752 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func, 8)
7753 basic_istream_wchar* __thiscall basic_istream_wchar_read_func(basic_istream_wchar *this,
7754         basic_istream_wchar* (__cdecl *pfunc)(basic_istream_wchar*))
7755 {
7756     TRACE("(%p %p)\n", this, pfunc);
7757     pfunc(this);
7758     return this;
7759 }
7760
7761 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AAV21@@Z@Z */
7762 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@_WU?$char_traits@_W@std@@@1@AEAV21@@Z@Z */
7763 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAV?$basic_ios@GU?$char_traits@G@std@@@1@AAV21@@Z@Z */
7764 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAV?$basic_ios@GU?$char_traits@G@std@@@1@AEAV21@@Z@Z */
7765 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_basic_ios, 8)
7766 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_basic_ios(basic_istream_wchar *this,
7767         basic_ios_wchar* (__cdecl *pfunc)(basic_ios_wchar*))
7768 {
7769     TRACE("(%p %p)\n", this, pfunc);
7770     pfunc(basic_istream_wchar_get_basic_ios(this));
7771     return this;
7772 }
7773
7774 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7775 /* ??5?$basic_istream@_WU?$char_traits@_W@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7776 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QAEAAV01@P6AAAVios_base@1@AAV21@@Z@Z */
7777 /* ??5?$basic_istream@GU?$char_traits@G@std@@@std@@QEAAAEAV01@P6AAEAVios_base@1@AEAV21@@Z@Z */
7778 DEFINE_THISCALL_WRAPPER(basic_istream_wchar_read_func_ios_base, 8)
7779 basic_istream_wchar* __thiscall basic_istream_wchar_read_func_ios_base(
7780         basic_istream_wchar *this, ios_base* (__cdecl *pfunc)(ios_base*))
7781 {
7782     TRACE("(%p %p)\n", this, pfunc);
7783     pfunc(&basic_istream_wchar_get_basic_ios(this)->base);
7784     return this;
7785 }
7786
7787 static inline basic_ios_char* basic_iostream_char_to_basic_ios(basic_iostream_char *ptr)
7788 {
7789     return (basic_ios_char*)((char*)ptr+basic_iostream_char_vbtable1[1]);
7790 }
7791
7792 static inline basic_iostream_char* basic_iostream_char_from_basic_ios(basic_ios_char *ptr)
7793 {
7794     return (basic_iostream_char*)((char*)ptr-basic_iostream_char_vbtable1[1]);
7795 }
7796
7797 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QAE@PAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7798 /* ??0?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAA@PEAV?$basic_streambuf@DU?$char_traits@D@std@@@1@@Z */
7799 DEFINE_THISCALL_WRAPPER(basic_iostream_char_ctor, 12)
7800 basic_iostream_char* __thiscall basic_iostream_char_ctor(basic_iostream_char *this, basic_streambuf_char *strbuf, MSVCP_bool virt_init)
7801 {
7802     basic_ios_char *basic_ios;
7803
7804     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
7805
7806     if(virt_init) {
7807         this->base1.vbtable = basic_iostream_char_vbtable1;
7808         this->base2.vbtable = basic_iostream_char_vbtable2;
7809         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
7810         basic_ios_char_ctor(basic_ios);
7811     }else {
7812         basic_ios = basic_istream_char_get_basic_ios(&this->base1);
7813     }
7814
7815     basic_ios->base.vtable = &MSVCP_basic_iostream_char_vtable;
7816
7817     basic_istream_char_ctor(&this->base1, strbuf, FALSE, FALSE);
7818     basic_ostream_char_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
7819     return this;
7820 }
7821
7822 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UAE@XZ */
7823 /* ??1?$basic_iostream@DU?$char_traits@D@std@@@std@@UEAA@XZ */
7824 DEFINE_THISCALL_WRAPPER(basic_iostream_char_dtor, 4)
7825 void __thiscall basic_iostream_char_dtor(basic_ios_char *base)
7826 {
7827     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
7828
7829     TRACE("(%p)\n", this);
7830     basic_ostream_char_dtor(basic_ostream_char_to_basic_ios(&this->base2));
7831     basic_istream_char_dtor(basic_istream_char_to_basic_ios(&this->base1));
7832 }
7833
7834 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QAEXXZ */
7835 /* ??_D?$basic_iostream@DU?$char_traits@D@std@@@std@@QEAAXXZ */
7836 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vbase_dtor, 4)
7837 void __thiscall basic_iostream_char_vbase_dtor(basic_iostream_char *this)
7838 {
7839     TRACE("(%p)\n", this);
7840     basic_iostream_char_dtor(basic_iostream_char_to_basic_ios(this));
7841     basic_ios_char_dtor(basic_istream_char_get_basic_ios(&this->base1));
7842 }
7843
7844 DEFINE_THISCALL_WRAPPER(basic_iostream_char_vector_dtor, 8)
7845 basic_iostream_char* __thiscall basic_iostream_char_vector_dtor(basic_ios_char *base, unsigned int flags)
7846 {
7847     basic_iostream_char *this = basic_iostream_char_from_basic_ios(base);
7848
7849     TRACE("(%p %x)\n", this, flags);
7850
7851     if(flags & 2) {
7852         /* we have an array, with the number of elements stored before the first object */
7853         INT_PTR i, *ptr = (INT_PTR *)this-1;
7854
7855         for(i=*ptr-1; i>=0; i--)
7856             basic_iostream_char_vbase_dtor(this+i);
7857         MSVCRT_operator_delete(ptr);
7858     } else {
7859         basic_iostream_char_vbase_dtor(this);
7860         if(flags & 1)
7861             MSVCRT_operator_delete(this);
7862     }
7863
7864     return this;
7865 }
7866
7867 static inline basic_ios_wchar* basic_iostream_wchar_to_basic_ios(basic_iostream_wchar *ptr)
7868 {
7869     return (basic_ios_wchar*)((char*)ptr+basic_iostream_wchar_vbtable1[1]);
7870 }
7871
7872 static inline basic_iostream_wchar* basic_iostream_wchar_from_basic_ios(basic_ios_wchar *ptr)
7873 {
7874     return (basic_iostream_wchar*)((char*)ptr-basic_iostream_wchar_vbtable1[1]);
7875 }
7876
7877 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAE@PAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
7878 /* ??0?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAA@PEAV?$basic_streambuf@_WU?$char_traits@_W@std@@@1@@Z */
7879 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_ctor, 12)
7880 basic_iostream_wchar* __thiscall basic_iostream_wchar_ctor(basic_iostream_wchar *this,
7881         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
7882 {
7883     basic_ios_wchar *basic_ios;
7884
7885     TRACE("(%p %p %d)\n", this, strbuf, virt_init);
7886
7887     if(virt_init) {
7888         this->base1.vbtable = basic_iostream_wchar_vbtable1;
7889         this->base2.vbtable = basic_iostream_wchar_vbtable2;
7890         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
7891         basic_ios_wchar_ctor(basic_ios);
7892     }else {
7893         basic_ios = basic_istream_wchar_get_basic_ios(&this->base1);
7894     }
7895
7896     basic_istream_wchar_ctor(&this->base1, strbuf, FALSE, FALSE);
7897     basic_ostream_wchar_ctor_uninitialized(&this->base2, 0, FALSE, FALSE);
7898
7899     basic_ios->base.vtable = &MSVCP_basic_iostream_wchar_vtable;
7900     return this;
7901 }
7902
7903 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QAE@PAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
7904 /* ??0?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAA@PEAV?$basic_streambuf@GU?$char_traits@G@std@@@1@@Z */
7905 DEFINE_THISCALL_WRAPPER(basic_iostream_short_ctor, 12)
7906 basic_iostream_wchar* __thiscall basic_iostream_short_ctor(basic_iostream_wchar *this,
7907         basic_streambuf_wchar *strbuf, MSVCP_bool virt_init)
7908 {
7909     basic_iostream_wchar_ctor(this, strbuf, virt_init);
7910     basic_istream_wchar_get_basic_ios(&this->base1)->base.vtable = &MSVCP_basic_iostream_short_vtable;
7911     return this;
7912 }
7913
7914 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UAE@XZ */
7915 /* ??1?$basic_iostream@_WU?$char_traits@_W@std@@@std@@UEAA@XZ */
7916 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UAE@XZ */
7917 /* ??1?$basic_iostream@GU?$char_traits@G@std@@@std@@UEAA@XZ */
7918 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_dtor, 4)
7919 void __thiscall basic_iostream_wchar_dtor(basic_ios_wchar *base)
7920 {
7921     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
7922
7923     TRACE("(%p)\n", this);
7924     basic_ostream_wchar_dtor(basic_ostream_wchar_to_basic_ios(&this->base2));
7925     basic_istream_wchar_dtor(basic_istream_wchar_to_basic_ios(&this->base1));
7926 }
7927
7928 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QAEXXZ */
7929 /* ??_D?$basic_iostream@_WU?$char_traits@_W@std@@@std@@QEAAXXZ */
7930 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QAEXXZ */
7931 /* ??_D?$basic_iostream@GU?$char_traits@G@std@@@std@@QEAAXXZ */
7932 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vbase_dtor, 4)
7933 void __thiscall basic_iostream_wchar_vbase_dtor(basic_iostream_wchar *this)
7934 {
7935     TRACE("(%p)\n", this);
7936     basic_iostream_wchar_dtor(basic_iostream_wchar_to_basic_ios(this));
7937     basic_ios_wchar_dtor(basic_istream_wchar_get_basic_ios(&this->base1));
7938 }
7939
7940 DEFINE_THISCALL_WRAPPER(basic_iostream_wchar_vector_dtor, 8)
7941 basic_iostream_wchar* __thiscall basic_iostream_wchar_vector_dtor(basic_ios_wchar *base, unsigned int flags)
7942 {
7943     basic_iostream_wchar *this = basic_iostream_wchar_from_basic_ios(base);
7944
7945     TRACE("(%p %x)\n", this, flags);
7946
7947     if(flags & 2) {
7948         /* we have an array, with the number of elements stored before the first object */
7949         INT_PTR i, *ptr = (INT_PTR *)this-1;
7950
7951         for(i=*ptr-1; i>=0; i--)
7952             basic_iostream_wchar_vbase_dtor(this+i);
7953         MSVCRT_operator_delete(ptr);
7954     } else {
7955         basic_iostream_wchar_vbase_dtor(this);
7956         if(flags & 1)
7957             MSVCRT_operator_delete(this);
7958     }
7959
7960     return this;
7961 }
7962
7963 static void __cdecl setprecision_func(ios_base *base, streamsize prec)
7964 {
7965     ios_base_precision_set(base, prec);
7966 }
7967
7968 /* ?setprecision@std@@YA?AU?$_Smanip@H@1@H@Z */
7969 /* ?setprecision@std@@YA?AU?$_Smanip@_J@1@_J@Z */
7970 manip_streamsize* __cdecl setprecision(manip_streamsize *ret, streamsize prec)
7971 {
7972     TRACE("(%p %s)\n", ret, wine_dbgstr_longlong(prec));
7973
7974     ret->pfunc = setprecision_func;
7975     ret->arg = prec;
7976     return ret;
7977 }
7978
7979 static void __cdecl setw_func(ios_base *base, streamsize width)
7980 {
7981     ios_base_width_set(base, width);
7982 }
7983
7984 /* ?setw@std@@YA?AU?$_Smanip@H@1@H@Z */
7985 /* ?setw@std@@YA?AU?$_Smanip@_J@1@_J@Z */
7986 manip_streamsize* __cdecl setw(manip_streamsize *ret, streamsize width)
7987 {
7988     TRACE("(%p %s)\n", ret, wine_dbgstr_longlong(width));
7989
7990     ret->pfunc = setw_func;
7991     ret->arg = width;
7992     return ret;
7993 }
7994
7995 static void __cdecl resetioflags_func(ios_base *base, int mask)
7996 {
7997     ios_base_setf_mask(base, 0, mask);
7998 }
7999
8000 /* ?resetiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
8001 manip_int* __cdecl resetiosflags(manip_int *ret, int mask)
8002 {
8003     TRACE("(%p %d)\n", ret, mask);
8004
8005     ret->pfunc = resetioflags_func;
8006     ret->arg = mask;
8007     return ret;
8008 }
8009
8010 static void __cdecl setiosflags_func(ios_base *base, int mask)
8011 {
8012     ios_base_setf_mask(base, FMTFLAG_mask, mask);
8013 }
8014
8015 /* ?setiosflags@std@@YA?AU?$_Smanip@H@1@H@Z */
8016 manip_int* __cdecl setiosflags(manip_int *ret, int mask)
8017 {
8018     TRACE("(%p %d)\n", ret, mask);
8019
8020     ret->pfunc = setiosflags_func;
8021     ret->arg = mask;
8022     return ret;
8023 }
8024
8025 static void __cdecl setbase_func(ios_base *base, int set_base)
8026 {
8027     if(set_base == 10)
8028         set_base = FMTFLAG_dec;
8029     else if(set_base == 8)
8030         set_base = FMTFLAG_oct;
8031     else if(set_base == 16)
8032         set_base = FMTFLAG_hex;
8033     else
8034         set_base = 0;
8035
8036     ios_base_setf_mask(base, set_base, FMTFLAG_basefield);
8037 }
8038
8039 /* ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z */
8040 manip_int* __cdecl setbase(manip_int *ret, int base)
8041 {
8042     TRACE("(%p %d)\n", ret, base);
8043
8044     ret->pfunc = setbase_func;
8045     ret->arg = base;
8046     return ret;
8047 }
8048
8049 static basic_filebuf_char filebuf_char_stdin;
8050 /* ?cin@std@@3V?$basic_istream@DU?$char_traits@D@std@@@1@A */
8051 struct {
8052     basic_istream_char obj;
8053     basic_ios_char vbase;
8054 } cin = { { 0 } };
8055 /* ?_Ptr_cin@std@@3PAV?$basic_istream@DU?$char_traits@D@std@@@1@A */
8056 /* ?_Ptr_cin@std@@3PEAV?$basic_istream@DU?$char_traits@D@std@@@1@EA */
8057 basic_istream_char *_Ptr_cin = &cin.obj;
8058
8059 static basic_filebuf_wchar filebuf_short_stdin;
8060 /* ?wcin@std@@3V?$basic_istream@GU?$char_traits@G@std@@@1@A */
8061 struct {
8062     basic_istream_wchar obj;
8063     basic_ios_wchar vbase;
8064 } ucin = { { 0 } };
8065 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@GU?$char_traits@G@std@@@1@A */
8066 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@GU?$char_traits@G@std@@@1@EA */
8067 basic_istream_wchar *_Ptr_ucin = &ucin.obj;
8068
8069 static basic_filebuf_wchar filebuf_wchar_stdin;
8070 /* ?wcin@std@@3V?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
8071 struct {
8072     basic_istream_wchar obj;
8073     basic_ios_wchar vbase;
8074 } wcin = { { 0 } };
8075 /* ?_Ptr_wcin@std@@3PAV?$basic_istream@_WU?$char_traits@_W@std@@@1@A */
8076 /* ?_Ptr_wcin@std@@3PEAV?$basic_istream@_WU?$char_traits@_W@std@@@1@EA */
8077 basic_istream_wchar *_Ptr_wcin = &wcin.obj;
8078
8079 static basic_filebuf_char filebuf_char_stdout;
8080 /* ?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
8081 struct {
8082     basic_ostream_char obj;
8083     basic_ios_char vbase;
8084 } cout = { { 0 } };
8085 /* ?_Ptr_cout@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
8086 /* ?_Ptr_cout@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
8087 basic_ostream_char *_Ptr_cout = &cout.obj;
8088
8089 static basic_filebuf_wchar filebuf_short_stdout;
8090 /* ?wcout@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
8091 struct {
8092     basic_ostream_wchar obj;
8093     basic_ios_wchar vbase;
8094 } ucout = { { 0 } };
8095 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
8096 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
8097 basic_ostream_wchar *_Ptr_ucout = &ucout.obj;
8098
8099 static basic_filebuf_wchar filebuf_wchar_stdout;
8100 /* ?wcout@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
8101 struct {
8102     basic_ostream_wchar obj;
8103     basic_ios_wchar vbase;
8104 } wcout = { { 0 } };
8105 /* ?_Ptr_wcout@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
8106 /* ?_Ptr_wcout@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
8107 basic_ostream_wchar *_Ptr_wcout = &wcout.obj;
8108
8109 static basic_filebuf_char filebuf_char_stderr;
8110 /* ?cerr@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
8111 struct {
8112     basic_ostream_char obj;
8113     basic_ios_char vbase;
8114 } cerr = { { 0 } };
8115 /* ?_Ptr_cerr@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
8116 /* ?_Ptr_cerr@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
8117 basic_ostream_char *_Ptr_cerr = &cerr.obj;
8118
8119 static basic_filebuf_wchar filebuf_short_stderr;
8120 /* ?wcerr@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
8121 struct {
8122     basic_ostream_wchar obj;
8123     basic_ios_wchar vbase;
8124 } ucerr = { { 0 } };
8125 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
8126 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
8127 basic_ostream_wchar *_Ptr_ucerr = &ucerr.obj;
8128
8129 static basic_filebuf_wchar filebuf_wchar_stderr;
8130 /* ?wcerr@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
8131 struct {
8132     basic_ostream_wchar obj;
8133     basic_ios_wchar vbase;
8134 } wcerr = { { 0 } };
8135 /* ?_Ptr_wcerr@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
8136 /* ?_Ptr_wcerr@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
8137 basic_ostream_wchar *_Ptr_wcerr = &wcerr.obj;
8138
8139 static basic_filebuf_char filebuf_char_log;
8140 /* ?clog@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A */
8141 struct {
8142     basic_ostream_char obj;
8143     basic_ios_char vbase;
8144 } clog = { { 0 } };
8145 /* ?_Ptr_clog@std@@3PAV?$basic_ostream@DU?$char_traits@D@std@@@1@A */
8146 /* ?_Ptr_clog@std@@3PEAV?$basic_ostream@DU?$char_traits@D@std@@@1@EA */
8147 basic_ostream_char *_Ptr_clog = &clog.obj;
8148
8149 static basic_filebuf_wchar filebuf_short_log;
8150 /* ?wclog@std@@3V?$basic_ostream@GU?$char_traits@G@std@@@1@A */
8151 struct {
8152     basic_ostream_wchar obj;
8153     basic_ios_wchar vbase;
8154 } uclog = { { 0 } };
8155 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@GU?$char_traits@G@std@@@1@A */
8156 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@GU?$char_traits@G@std@@@1@EA */
8157 basic_ostream_wchar *_Ptr_uclog = &uclog.obj;
8158
8159 static basic_filebuf_wchar filebuf_wchar_log;
8160 /* ?wclog@std@@3V?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
8161 struct {
8162     basic_ostream_wchar obj;
8163     basic_ios_wchar vbase;
8164 } wclog = { { 0 } };
8165 /* ?_Ptr_wclog@std@@3PAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@A */
8166 /* ?_Ptr_wclog@std@@3PEAV?$basic_ostream@_WU?$char_traits@_W@std@@@1@EA */
8167 basic_ostream_wchar *_Ptr_wclog = &wclog.obj;
8168
8169 /* ?_Init_cnt@Init@ios_base@std@@0HA */
8170 int ios_base_Init__Init_cnt = -1;
8171
8172 /* ?_Init_cnt_func@Init@ios_base@std@@CAAAHXZ */
8173 /* ?_Init_cnt_func@Init@ios_base@std@@CAAEAHXZ */
8174 int* __cdecl ios_base_Init__Init_cnt_func(void)
8175 {
8176     return &ios_base_Init__Init_cnt;
8177 }
8178
8179 /* ?_Init_ctor@Init@ios_base@std@@CAXPAV123@@Z */
8180 /* ?_Init_ctor@Init@ios_base@std@@CAXPEAV123@@Z */
8181 void __cdecl ios_base_Init__Init_ctor(void *this)
8182 {
8183     TRACE("(%p)\n", this);
8184
8185     if(ios_base_Init__Init_cnt < 0)
8186         ios_base_Init__Init_cnt = 1;
8187     else
8188         ios_base_Init__Init_cnt++;
8189 }
8190
8191 /* ??0Init@ios_base@std@@QAE@XZ */
8192 /* ??0Init@ios_base@std@@QEAA@XZ */
8193 DEFINE_THISCALL_WRAPPER(ios_base_Init_ctor, 4)
8194 void* __thiscall ios_base_Init_ctor(void *this)
8195 {
8196     ios_base_Init__Init_ctor(this);
8197     return this;
8198 }
8199
8200 /* ?_Init_dtor@Init@ios_base@std@@CAXPAV123@@Z */
8201 /* ?_Init_dtor@Init@ios_base@std@@CAXPEAV123@@Z */
8202 void __cdecl ios_base_Init__Init_dtor(void *this)
8203 {
8204     TRACE("(%p)\n", this);
8205
8206     ios_base_Init__Init_cnt--;
8207     if(!ios_base_Init__Init_cnt) {
8208         basic_ostream_char_flush(&cout.obj);
8209         basic_ostream_char_flush(&cerr.obj);
8210         basic_ostream_char_flush(&clog.obj);
8211     }
8212 }
8213
8214 /* ??1Init@ios_base@std@@QAE@XZ */
8215 /* ??1Init@ios_base@std@@QEAA@XZ */
8216 DEFINE_THISCALL_WRAPPER(ios_base_Init_dtor, 4)
8217 void __thiscall ios_base_Init_dtor(void *this)
8218 {
8219     ios_base_Init__Init_dtor(this);
8220 }
8221
8222 /* ??4Init@ios_base@std@@QAEAAV012@ABV012@@Z */
8223 /* ??4Init@ios_base@std@@QEAAAEAV012@AEBV012@@Z */
8224 DEFINE_THISCALL_WRAPPER(ios_base_Init_op_assign, 8)
8225 void* __thiscall ios_base_Init_op_assign(void *this, void *rhs)
8226 {
8227     TRACE("(%p %p)\n", this, rhs);
8228     return this;
8229 }
8230
8231 /* ?_Init_cnt@_Winit@std@@0HA */
8232 int _Winit__Init_cnt = -1;
8233
8234 /* ??0_Winit@std@@QAE@XZ */
8235 /* ??0_Winit@std@@QEAA@XZ */
8236 DEFINE_THISCALL_WRAPPER(_Winit_ctor, 4)
8237 void* __thiscall _Winit_ctor(void *this)
8238 {
8239     TRACE("(%p)\n", this);
8240
8241     if(_Winit__Init_cnt < 0)
8242         _Winit__Init_cnt = 1;
8243     else
8244         _Winit__Init_cnt++;
8245
8246     return this;
8247 }
8248
8249 /* ??1_Winit@std@@QAE@XZ */
8250 /* ??1_Winit@std@@QAE@XZ */
8251 DEFINE_THISCALL_WRAPPER(_Winit_dtor, 4)
8252 void __thiscall _Winit_dtor(void *this)
8253 {
8254     TRACE("(%p)\n", this);
8255
8256     _Winit__Init_cnt--;
8257     if(!_Winit__Init_cnt) {
8258         basic_ostream_wchar_flush(&wcout.obj);
8259         basic_ostream_wchar_flush(&wcerr.obj);
8260         basic_ostream_wchar_flush(&wclog.obj);
8261     }
8262 }
8263
8264 /* ??4_Winit@std@@QAEAAV01@ABV01@@Z */
8265 /* ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z */
8266 DEFINE_THISCALL_WRAPPER(_Winit_op_assign, 8)
8267 void* __thiscall _Winit_op_assign(void *this, void *rhs)
8268 {
8269     TRACE("(%p %p)\n", this, rhs);
8270     return this;
8271 }
8272
8273 void init_io(void *base)
8274 {
8275 #ifdef __x86_64__
8276     init_iosb_rtti(base);
8277     init_ios_base_rtti(base);
8278     init_basic_ios_char_rtti(base);
8279     init_basic_ios_wchar_rtti(base);
8280     init_basic_ios_short_rtti(base);
8281     init_basic_streambuf_char_rtti(base);
8282     init_basic_streambuf_wchar_rtti(base);
8283     init_basic_streambuf_short_rtti(base);
8284     init_basic_filebuf_char_rtti(base);
8285     init_basic_filebuf_wchar_rtti(base);
8286     init_basic_filebuf_short_rtti(base);
8287     init_basic_ostream_char_rtti(base);
8288     init_basic_ostream_wchar_rtti(base);
8289     init_basic_ostream_short_rtti(base);
8290     init_basic_istream_char_rtti(base);
8291     init_basic_istream_wchar_rtti(base);
8292     init_basic_istream_short_rtti(base);
8293     init_basic_iostream_char_rtti(base);
8294     init_basic_iostream_wchar_rtti(base);
8295     init_basic_iostream_short_rtti(base);
8296 #endif
8297
8298     basic_filebuf_char_ctor_file(&filebuf_char_stdin, stdin);
8299     basic_istream_char_ctor(&cin.obj, &filebuf_char_stdin.base, FALSE/*FIXME*/, TRUE);
8300
8301     basic_filebuf_short_ctor_file(&filebuf_short_stdin, stdin);
8302     basic_istream_short_ctor(&ucin.obj, &filebuf_short_stdin.base, FALSE/*FIXME*/, TRUE);
8303
8304     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdin, stdin);
8305     basic_istream_wchar_ctor(&wcin.obj, &filebuf_wchar_stdin.base, FALSE/*FIXME*/, TRUE);
8306
8307     basic_filebuf_char_ctor_file(&filebuf_char_stdout, stdout);
8308     basic_ostream_char_ctor(&cout.obj, &filebuf_char_stdout.base, FALSE/*FIXME*/, TRUE);
8309
8310     basic_filebuf_short_ctor_file(&filebuf_short_stdout, stdout);
8311     basic_ostream_short_ctor(&ucout.obj, &filebuf_short_stdout.base, FALSE/*FIXME*/, TRUE);
8312
8313     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stdout, stdout);
8314     basic_ostream_wchar_ctor(&wcout.obj, &filebuf_wchar_stdout.base, FALSE/*FIXME*/, TRUE);
8315
8316     basic_filebuf_char_ctor_file(&filebuf_char_stderr, stderr);
8317     basic_ostream_char_ctor(&cerr.obj, &filebuf_char_stderr.base, FALSE/*FIXME*/, TRUE);
8318
8319     basic_filebuf_short_ctor_file(&filebuf_short_stderr, stderr);
8320     basic_ostream_short_ctor(&ucerr.obj, &filebuf_short_stderr.base, FALSE/*FIXME*/, TRUE);
8321
8322     basic_filebuf_wchar_ctor_file(&filebuf_wchar_stderr, stderr);
8323     basic_ostream_wchar_ctor(&wcerr.obj, &filebuf_wchar_stderr.base, FALSE/*FIXME*/, TRUE);
8324
8325     basic_filebuf_char_ctor_file(&filebuf_char_log, stderr);
8326     basic_ostream_char_ctor(&clog.obj, &filebuf_char_log.base, FALSE/*FIXME*/, TRUE);
8327
8328     basic_filebuf_short_ctor_file(&filebuf_short_log, stderr);
8329     basic_ostream_short_ctor(&uclog.obj, &filebuf_short_log.base, FALSE/*FIXME*/, TRUE);
8330
8331     basic_filebuf_wchar_ctor_file(&filebuf_wchar_log, stderr);
8332     basic_ostream_wchar_ctor(&wclog.obj, &filebuf_wchar_log.base, FALSE/*FIXME*/, TRUE);
8333 }
8334
8335 void free_io(void)
8336 {
8337     basic_istream_char_vbase_dtor(&cin.obj);
8338     basic_filebuf_char_dtor(&filebuf_char_stdin);
8339
8340     basic_istream_wchar_vbase_dtor(&ucin.obj);
8341     basic_filebuf_wchar_dtor(&filebuf_short_stdin);
8342
8343     basic_istream_wchar_vbase_dtor(&wcin.obj);
8344     basic_filebuf_wchar_dtor(&filebuf_wchar_stdin);
8345
8346     basic_ostream_char_vbase_dtor(&cout.obj);
8347     basic_filebuf_char_dtor(&filebuf_char_stdout);
8348
8349     basic_ostream_wchar_vbase_dtor(&ucout.obj);
8350     basic_filebuf_wchar_dtor(&filebuf_short_stdout);
8351
8352     basic_ostream_wchar_vbase_dtor(&wcout.obj);
8353     basic_filebuf_wchar_dtor(&filebuf_wchar_stdout);
8354
8355     basic_ostream_char_vbase_dtor(&cerr.obj);
8356     basic_filebuf_char_dtor(&filebuf_char_stderr);
8357
8358     basic_ostream_wchar_vbase_dtor(&ucerr.obj);
8359     basic_filebuf_wchar_dtor(&filebuf_short_stderr);
8360
8361     basic_ostream_wchar_vbase_dtor(&wcerr.obj);
8362     basic_filebuf_wchar_dtor(&filebuf_wchar_stderr);
8363
8364     basic_ostream_char_vbase_dtor(&clog.obj);
8365     basic_filebuf_char_dtor(&filebuf_char_log);
8366
8367     basic_ostream_wchar_vbase_dtor(&uclog.obj);
8368     basic_filebuf_wchar_dtor(&filebuf_short_log);
8369
8370     basic_ostream_wchar_vbase_dtor(&wclog.obj);
8371     basic_filebuf_wchar_dtor(&filebuf_wchar_log);
8372 }