aboutsummaryrefslogtreecommitdiff
path: root/Lib/std/std_iostream.i
blob: 38a22963fa59c8e7cc95656415f0e96ac37807d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
/* 
   For wchar support, you need to include the wchar.i file
   before this file, ie:
   
   %include <wchar.i>
   %include <std_iostream.i>

   or equivalently, just include

   %include <std_wiostream.i>
*/

%include <std_ios.i>
%include <std_basic_string.i>
%include <std_string.i>
#if defined(SWIG_WCHAR)
%include <std_wstring.i>
#endif

%{
#include <iostream>
%}


namespace std
{
  // 27.6.2.1 Template class basic_ostream
  template<typename _CharT, typename _Traits = char_traits<_CharT> >
  class basic_ostream : virtual public basic_ios<_CharT, _Traits>
  {
  public:
    // Types (inherited from basic_ios (27.4.4)):
    typedef _CharT                     		char_type;
    typedef typename _Traits::int_type 		int_type;
    typedef typename _Traits::pos_type 		pos_type;
    typedef typename _Traits::off_type 		off_type;
    typedef _Traits                    		traits_type;
      
    // 27.6.2.2 Constructor/destructor:
    explicit 
    basic_ostream(basic_streambuf<_CharT, _Traits>* __sb);

    virtual 
    ~basic_ostream();
    
    // 27.6.2.5 Formatted output:
    // 27.6.2.5.3  basic_ostream::operator<<
    basic_ostream<_CharT, _Traits>&
    operator<<(basic_ostream<_CharT, _Traits>& (*__pf)(basic_ostream<_CharT, _Traits>&));

      
    basic_ostream<_CharT, _Traits>&
    operator<<(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&));


    basic_ostream<_CharT, _Traits>&
    operator<<(ios_base& (*__pf) (ios_base&));
    
    // 27.6.2.5.2 Arithmetic Inserters

    basic_ostream<_CharT, _Traits>& 
    operator<<(long __n);
    
    basic_ostream<_CharT, _Traits>& 
    operator<<(unsigned long __n);
    
    basic_ostream<_CharT, _Traits>& 
    operator<<(bool __n);
    
    basic_ostream<_CharT, _Traits>& 
    operator<<(short __n);

    basic_ostream<_CharT, _Traits>& 
    operator<<(unsigned short __n);

    basic_ostream<_CharT, _Traits>& 
    operator<<(int __n);

    basic_ostream<_CharT, _Traits>& 
    operator<<(unsigned int __n);

    basic_ostream<_CharT, _Traits>& 
    operator<<(long long __n);

    basic_ostream<_CharT, _Traits>& 
    operator<<(unsigned long long __n);

    basic_ostream<_CharT, _Traits>& 
    operator<<(double __f);

    basic_ostream<_CharT, _Traits>& 
    operator<<(float __f);

    basic_ostream<_CharT, _Traits>& 
    operator<<(long double __f);

    basic_ostream<_CharT, _Traits>& 
    operator<<(const void* __p);

    basic_ostream<_CharT, _Traits>& 
    operator<<(basic_streambuf<_CharT, _Traits>* __sb);

    %extend {
      std::basic_ostream<_CharT, _Traits >& 
	operator<<(const std::basic_string<_CharT,_Traits, std::allocator<_CharT> >& s)
	{
	  *self << s;
	  return *self;
	}
    }

    // Unformatted output:
    basic_ostream<_CharT, _Traits>& 
    put(char_type __c);

    basic_ostream<_CharT, _Traits>& 
    write(const char_type* __s, streamsize __n);

    basic_ostream<_CharT, _Traits>& 
    flush();

    // Seeks:
    pos_type 
    tellp();

    basic_ostream<_CharT, _Traits>& 
    seekp(pos_type);

    basic_ostream<_CharT, _Traits>& 
    seekp(off_type, ios_base::seekdir);

  };

  // 27.6.1.1 Template class basic_istream
  template<typename _CharT, typename _Traits = char_traits<_CharT> >
  class basic_istream : virtual public basic_ios<_CharT, _Traits>
  {
  public:
    // Types (inherited from basic_ios (27.4.4)):
    typedef _CharT                     		char_type;
    typedef typename _Traits::int_type 		int_type;
    typedef typename _Traits::pos_type 		pos_type;
    typedef typename _Traits::off_type 		off_type;
    typedef _Traits                    		traits_type;


  public:
    // 27.6.1.1.1 Constructor/destructor:
    explicit 
    basic_istream(basic_streambuf<_CharT, _Traits>* __sb);

    virtual 
    ~basic_istream();

    // 27.6.1.2.3 basic_istream::operator>>
    basic_istream<_CharT, _Traits>&
    operator>>(basic_istream<_CharT, _Traits>& (*__pf)(basic_istream<_CharT, _Traits>&));
    
    basic_istream<_CharT, _Traits>&
    operator>>(basic_ios<_CharT, _Traits>& (*__pf)(basic_ios<_CharT, _Traits>&));
    
    basic_istream<_CharT, _Traits>&
    operator>>(ios_base& (*__pf)(ios_base&));
      
    // 27.6.1.2.2 Arithmetic Extractors
    basic_istream<_CharT, _Traits>& 
    operator>>(bool& __n);
      
    basic_istream<_CharT, _Traits>& 
    operator>>(short& __n);
      
    basic_istream<_CharT, _Traits>& 
    operator>>(unsigned short& __n);

    basic_istream<_CharT, _Traits>& 
    operator>>(int& __n);
      
    basic_istream<_CharT, _Traits>& 
    operator>>(unsigned int& __n);

    basic_istream<_CharT, _Traits>& 
    operator>>(long& __n);
      
    basic_istream<_CharT, _Traits>& 
    operator>>(unsigned long& __n);

    basic_istream<_CharT, _Traits>& 
    operator>>(long long& __n);

    basic_istream<_CharT, _Traits>& 
    operator>>(unsigned long long& __n);

    basic_istream<_CharT, _Traits>& 
    operator>>(float& __f);

    basic_istream<_CharT, _Traits>& 
    operator>>(double& __f);

    basic_istream<_CharT, _Traits>& 
    operator>>(long double& __f);

    basic_istream<_CharT, _Traits>& 
    operator>>(void*& __p);

    basic_istream<_CharT, _Traits>& 
    operator>>(basic_streambuf<_CharT, _Traits>* __sb);
      
    // 27.6.1.3 Unformatted input:
    inline streamsize 
    gcount(void) const;
      
    int_type 
    get(void);

    basic_istream<_CharT, _Traits>& 
    get(char_type& __c);

    basic_istream<_CharT, _Traits>& 
    get(char_type* __s, streamsize __n, char_type __delim);

    inline basic_istream<_CharT, _Traits>& 
    get(char_type* __s, streamsize __n);

    basic_istream<_CharT, _Traits>&
    get(basic_streambuf<_CharT, _Traits>& __sb, char_type __delim);

    inline basic_istream<_CharT, _Traits>&
    get(basic_streambuf<_CharT, _Traits>& __sb);

    basic_istream<_CharT, _Traits>& 
    getline(char_type* __s, streamsize __n, char_type __delim);

    inline basic_istream<_CharT, _Traits>& 
    getline(char_type* __s, streamsize __n);

    basic_istream<_CharT, _Traits>& 
    ignore(streamsize __n = 1, int_type __delim = _Traits::eof());
      
    int_type 
    peek(void);
      
    basic_istream<_CharT, _Traits>& 
    read(char_type* __s, streamsize __n);

    streamsize 
    readsome(char_type* __s, streamsize __n);
      
    basic_istream<_CharT, _Traits>& 
    putback(char_type __c);

    basic_istream<_CharT, _Traits>& 
    unget(void);

    int 
    sync(void);

    pos_type 
    tellg(void);

    basic_istream<_CharT, _Traits>& 
    seekg(pos_type);

    basic_istream<_CharT, _Traits>& 
    seekg(off_type, ios_base::seekdir);
  };  

  // 27.6.1.5 Template class basic_iostream
  template<typename _CharT, typename _Traits = char_traits<_CharT> >
  class basic_iostream
    : public basic_istream<_CharT, _Traits>, 
      public basic_ostream<_CharT, _Traits>
  {
  public:
    typedef _CharT                     		char_type;
    typedef typename _Traits::int_type 		int_type;
    typedef typename _Traits::pos_type 		pos_type;
    typedef typename _Traits::off_type 		off_type;
    typedef _Traits                    		traits_type;

    explicit 
    basic_iostream(basic_streambuf<_CharT, _Traits>* __sb);

    virtual 
    ~basic_iostream();    
  };

  typedef basic_ostream<char> ostream ;
  typedef basic_istream<char> istream;
  typedef basic_iostream<char> iostream;

  extern istream cin;
  extern ostream cout;
  extern ostream cerr;
  extern ostream clog;

#if defined(SWIG_WCHAR)
  typedef basic_ostream<wchar_t>  wostream;
  typedef basic_istream<wchar_t>  wistream;
  typedef basic_iostream<wchar_t> wiostream;

  extern wistream wcin;
  extern wostream wcout;
  extern wostream wcerr;
  extern wostream wclog;
#endif

  template<typename _CharT, typename _Traits = char_traits<_CharT> >
  std::basic_ostream<_CharT, _Traits>& 
  endl(std::basic_ostream<_CharT, _Traits>& value);

  template<typename _CharT, typename _Traits = char_traits<_CharT> >
  std::basic_ostream<_CharT, _Traits>& 
  ends(std::basic_ostream<_CharT, _Traits>& value);

  template<typename _CharT, typename _Traits = char_traits<_CharT> >
  std::basic_ostream<_CharT, _Traits>& 
  flush(std::basic_ostream<_CharT, _Traits>& value);
}

namespace std {
  %template(ostream) basic_ostream<char>;
  %template(istream) basic_istream<char>;
  %template(iostream) basic_iostream<char>;

  %template(endl) endl<char, std::char_traits<char> >;
  %template(ends) ends<char, std::char_traits<char> >;
  %template(flush) flush<char, std::char_traits<char> >;

#if defined(SWIG_WCHAR)
  %template(wostream) basic_ostream<wchar_t>;
  %template(wistream) basic_istream<wchar_t>;
  %template(wiostream) basic_iostream<wchar_t>;  

  %template(wendl) endl<wchar_t, std::char_traits<wchar_t> >;
  %template(wends) ends<wchar_t, std::char_traits<wchar_t> >;
  %template(wflush) flush<wchar_t, std::char_traits<wchar_t> >;  
#endif
}