libstdc++: basic_ios.h Source File (original) (raw)
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#ifndef _BASIC_IOS_H
31#define _BASIC_IOS_H 1
32
33#pragma GCC system_header
34
40
41namespace std _GLIBCXX_VISIBILITY(default)
42{
43_GLIBCXX_BEGIN_NAMESPACE_VERSION
44
45 template<typename _Facet>
46 inline const _Facet&
47 __check_facet(const _Facet* __f)
48 {
49 if (!__f)
50 __throw_bad_cast();
51 return *__f;
52 }
53
54
55
56
57
58
59
60
61
62
63
64
65
66 template<typename _CharT, typename _Traits>
68 {
69#if __cplusplus >= 202002L
70 static_assert(is_same_v<_CharT, typename _Traits::char_type>);
71#endif
72
73 public:
74
75
76
77
78
79
81 typedef typename _Traits::int_type int_type;
82 typedef typename _Traits::pos_type pos_type;
83 typedef typename _Traits::off_type off_type;
85
86
87
88
89
90
96
97
98
99 protected:
102 mutable bool _M_fill_init;
104
105
107
109
111
112 public:
113
114
115
116
117
118
119
120#if __cplusplus >= 201103L
121 explicit operator bool() const
122 { return !this->fail(); }
123#else
124 operator void*() const
125 { return this->fail() ? 0 : const_cast<basic_ios*>(this); }
126#endif
127
128 bool
130 { return this->fail(); }
131
132
133
134
135
136
137
138
139
142 { return _M_streambuf_state; }
143
144
145
146
147
148
149
150
151 void
153
154
155
156
157
158
159
160 void
163
164
165
166
167 void
168 _M_setstate(iostate __state)
169 {
170
171
172 _M_streambuf_state |= __state;
174 __throw_exception_again;
175 }
176
177
178
179
180
181
182
183 bool
185 { return this->rdstate() == 0; }
186
187
188
189
190
191
192
193 bool
196
197
198
199
200
201
202
203
204 bool
207
208
209
210
211
212
213
214 bool
217
218
219
220
221
222
223
224
227 { return _M_exception; }
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 void
262 {
263 _M_exception = __except;
264 this->clear(_M_streambuf_state);
265 }
266
267
268
269
270
271
272
273 explicit
275 : ios_base(), _M_tie(0), _M_fill(), _M_fill_init(false), _M_streambuf(0),
276 _M_ctype(0), _M_num_put(0), _M_num_get(0)
277 { this->init(__sb); }
278
279
280
281
282
283
284
285 virtual
287
288
289
290
291
292
293
294
295
296
297
300 { return _M_tie; }
301
302
303
304
305
306
307
308
309
312 {
314 _M_tie = __tiestr;
315 return __old;
316 }
317
318
319
320
321
322
323
326 { return _M_streambuf; }
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
352
353
354
355
356
357
358
359
360
361
362
363
366
367
368
369
370
371
372
375 {
376 if (__builtin_expect(!_M_fill_init, false))
377 return this->widen(' ');
378 return _M_fill;
379 }
380
381
382
383
384
385
386
387
388
389
392 {
394 _M_fill = __ch;
395 _M_fill_init = true;
396 return __old;
397 }
398
399
400
401
402
403
404
405
406
407
408
409
410
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431 char
433 { return __check_facet(_M_ctype).narrow(__c, __dfault); }
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
452 { return __check_facet(_M_ctype).widen(__c); }
453
454 protected:
455
456
457
458
459
460
461
463 : ios_base(), _M_tie(0), _M_fill(char_type()), _M_fill_init(false),
464 _M_streambuf(0), _M_ctype(0), _M_num_put(0), _M_num_get(0)
465 { }
466
467
468
469
470
471
472
473 void
475
476#if __cplusplus >= 201103L
479
480 void
482 {
483 ios_base::_M_move(__rhs);
484 _M_cache_locale(_M_ios_locale);
485 this->tie(__rhs.tie(nullptr));
486 _M_fill = __rhs._M_fill;
487 _M_fill_init = __rhs._M_fill_init;
488 _M_streambuf = nullptr;
489 }
490
491 void
493 { this->move(__rhs); }
494
495 void
497 {
498 ios_base::_M_swap(__rhs);
499 _M_cache_locale(_M_ios_locale);
500 __rhs._M_cache_locale(__rhs._M_ios_locale);
501 std::swap(_M_tie, __rhs._M_tie);
502 std::swap(_M_fill, __rhs._M_fill);
503 std::swap(_M_fill_init, __rhs._M_fill_init);
504 }
505
506 void
507 set_rdbuf(basic_streambuf<_CharT, _Traits>* __sb)
508 { _M_streambuf = __sb; }
509#endif
510
511 void
512 _M_cache_locale(const locale& __loc);
513 };
514
515_GLIBCXX_END_NAMESPACE_VERSION
516}
517
519
520#endif
ISO C++ entities toplevel namespace is std.
Template class basic_ios, virtual base class for all stream classes.
void clear(iostate __state=goodbit)
[Re]sets the error state.
bool eof() const
Fast error checking.
locale imbue(const locale &__loc)
Moves to a new locale.
ctype< _CharT > __ctype_type
_Traits::pos_type pos_type
basic_ostream< _CharT, _Traits > * tie() const
Fetches the current tied stream.
iostate exceptions() const
Throwing exceptions on errors.
void setstate(iostate __state)
Sets additional flags in the error state.
bool operator!() const
The quick-and-easy status check.
basic_ios & copyfmt(const basic_ios &__rhs)
Copies fields of __rhs into this.
char_type fill(char_type __ch)
Sets a new empty character.
iostate rdstate() const
Returns the error state of the stream buffer.
void init(basic_streambuf< _CharT, _Traits > *__sb)
All setup is performed here.
bool good() const
Fast error checking.
char_type widen(char __c) const
Widens characters.
char_type fill() const
Retrieves the empty character.
char narrow(char_type __c, char __dfault) const
Squeezes characters.
virtual ~basic_ios()
Empty.
_Traits::off_type off_type
bool fail() const
Fast error checking.
basic_ostream< _CharT, _Traits > * tie(basic_ostream< _CharT, _Traits > *__tiestr)
Ties this stream to an output stream.
basic_streambuf< _CharT, _Traits > * rdbuf() const
Accessing the underlying buffer.
_Traits::int_type int_type
num_put< _CharT, ostreambuf_iterator< _CharT, _Traits > > __num_put_type
num_get< _CharT, istreambuf_iterator< _CharT, _Traits > > __num_get_type
bool bad() const
Fast error checking.
basic_ios(basic_streambuf< _CharT, _Traits > *__sb)
Constructor performs initialization.
void exceptions(iostate __except)
Throwing exceptions on errors.
The actual work of input and output (interface).
Template class basic_ostream.
The base of the I/O class hierarchy.
_Ios_Iostate iostate
This is a bitmask type.
static const iostate eofbit
Indicates that an input operation reached the end of an input sequence.
static const iostate goodbit
Indicates all is well.
static const iostate badbit
Indicates a loss of integrity in an input or output sequence (such as an irrecoverable read error fro...
static const iostate failbit
Indicates that an input operation failed to read the expected characters, or that an output operation...
Container class for localization functionality.
Primary class template ctype facet.
Primary class template num_get.
Primary class template num_put.