root / lab4 / .minix-src / include / c++ / ios @ 13
History | View | Annotate | Download (24.4 KB)
1 |
// -*- C++ -*- |
---|---|
2 |
//===---------------------------- ios -------------------------------------===// |
3 |
// |
4 |
// The LLVM Compiler Infrastructure |
5 |
// |
6 |
// This file is dual licensed under the MIT and the University of Illinois Open |
7 |
// Source Licenses. See LICENSE.TXT for details. |
8 |
// |
9 |
//===----------------------------------------------------------------------===// |
10 |
|
11 |
#ifndef _LIBCPP_IOS |
12 |
#define _LIBCPP_IOS |
13 |
|
14 |
/* |
15 |
ios synopsis |
16 |
|
17 |
#include <iosfwd> |
18 |
|
19 |
namespace std |
20 |
{ |
21 |
|
22 |
typedef OFF_T streamoff; |
23 |
typedef SZ_T streamsize; |
24 |
template <class stateT> class fpos; |
25 |
|
26 |
class ios_base |
27 |
{ |
28 |
public: |
29 |
class failure; |
30 |
|
31 |
typedef T1 fmtflags; |
32 |
static constexpr fmtflags boolalpha; |
33 |
static constexpr fmtflags dec; |
34 |
static constexpr fmtflags fixed; |
35 |
static constexpr fmtflags hex; |
36 |
static constexpr fmtflags internal; |
37 |
static constexpr fmtflags left; |
38 |
static constexpr fmtflags oct; |
39 |
static constexpr fmtflags right; |
40 |
static constexpr fmtflags scientific; |
41 |
static constexpr fmtflags showbase; |
42 |
static constexpr fmtflags showpoint; |
43 |
static constexpr fmtflags showpos; |
44 |
static constexpr fmtflags skipws; |
45 |
static constexpr fmtflags unitbuf; |
46 |
static constexpr fmtflags uppercase; |
47 |
static constexpr fmtflags adjustfield; |
48 |
static constexpr fmtflags basefield; |
49 |
static constexpr fmtflags floatfield; |
50 |
|
51 |
typedef T2 iostate; |
52 |
static constexpr iostate badbit; |
53 |
static constexpr iostate eofbit; |
54 |
static constexpr iostate failbit; |
55 |
static constexpr iostate goodbit; |
56 |
|
57 |
typedef T3 openmode; |
58 |
static constexpr openmode app; |
59 |
static constexpr openmode ate; |
60 |
static constexpr openmode binary; |
61 |
static constexpr openmode in; |
62 |
static constexpr openmode out; |
63 |
static constexpr openmode trunc; |
64 |
|
65 |
typedef T4 seekdir; |
66 |
static constexpr seekdir beg; |
67 |
static constexpr seekdir cur; |
68 |
static constexpr seekdir end; |
69 |
|
70 |
class Init; |
71 |
|
72 |
// 27.5.2.2 fmtflags state: |
73 |
fmtflags flags() const; |
74 |
fmtflags flags(fmtflags fmtfl); |
75 |
fmtflags setf(fmtflags fmtfl); |
76 |
fmtflags setf(fmtflags fmtfl, fmtflags mask); |
77 |
void unsetf(fmtflags mask); |
78 |
|
79 |
streamsize precision() const; |
80 |
streamsize precision(streamsize prec); |
81 |
streamsize width() const; |
82 |
streamsize width(streamsize wide); |
83 |
|
84 |
// 27.5.2.3 locales: |
85 |
locale imbue(const locale& loc); |
86 |
locale getloc() const; |
87 |
|
88 |
// 27.5.2.5 storage: |
89 |
static int xalloc(); |
90 |
long& iword(int index); |
91 |
void*& pword(int index); |
92 |
|
93 |
// destructor |
94 |
virtual ~ios_base(); |
95 |
|
96 |
// 27.5.2.6 callbacks; |
97 |
enum event { erase_event, imbue_event, copyfmt_event }; |
98 |
typedef void (*event_callback)(event, ios_base&, int index); |
99 |
void register_callback(event_callback fn, int index); |
100 |
|
101 |
ios_base(const ios_base&) = delete; |
102 |
ios_base& operator=(const ios_base&) = delete; |
103 |
|
104 |
static bool sync_with_stdio(bool sync = true); |
105 |
|
106 |
protected: |
107 |
ios_base(); |
108 |
}; |
109 |
|
110 |
template <class charT, class traits = char_traits<charT> > |
111 |
class basic_ios |
112 |
: public ios_base |
113 |
{ |
114 |
public: |
115 |
// types: |
116 |
typedef charT char_type; |
117 |
typedef typename traits::int_type int_type; |
118 |
typedef typename traits::pos_type pos_type; |
119 |
typedef typename traits::off_type off_type; |
120 |
typedef traits traits_type; |
121 |
|
122 |
operator unspecified-bool-type() const; |
123 |
bool operator!() const; |
124 |
iostate rdstate() const; |
125 |
void clear(iostate state = goodbit); |
126 |
void setstate(iostate state); |
127 |
bool good() const; |
128 |
bool eof() const; |
129 |
bool fail() const; |
130 |
bool bad() const; |
131 |
|
132 |
iostate exceptions() const; |
133 |
void exceptions(iostate except); |
134 |
|
135 |
// 27.5.4.1 Constructor/destructor: |
136 |
explicit basic_ios(basic_streambuf<charT,traits>* sb); |
137 |
virtual ~basic_ios(); |
138 |
|
139 |
// 27.5.4.2 Members: |
140 |
basic_ostream<charT,traits>* tie() const; |
141 |
basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr); |
142 |
|
143 |
basic_streambuf<charT,traits>* rdbuf() const; |
144 |
basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb); |
145 |
|
146 |
basic_ios& copyfmt(const basic_ios& rhs); |
147 |
|
148 |
char_type fill() const; |
149 |
char_type fill(char_type ch); |
150 |
|
151 |
locale imbue(const locale& loc); |
152 |
|
153 |
char narrow(char_type c, char dfault) const; |
154 |
char_type widen(char c) const; |
155 |
|
156 |
basic_ios(const basic_ios& ) = delete; |
157 |
basic_ios& operator=(const basic_ios&) = delete; |
158 |
|
159 |
protected: |
160 |
basic_ios(); |
161 |
void init(basic_streambuf<charT,traits>* sb); |
162 |
void move(basic_ios& rhs); |
163 |
void swap(basic_ios& rhs) noexcept; |
164 |
void set_rdbuf(basic_streambuf<charT, traits>* sb); |
165 |
}; |
166 |
|
167 |
// 27.5.5, manipulators: |
168 |
ios_base& boolalpha (ios_base& str); |
169 |
ios_base& noboolalpha(ios_base& str); |
170 |
ios_base& showbase (ios_base& str); |
171 |
ios_base& noshowbase (ios_base& str); |
172 |
ios_base& showpoint (ios_base& str); |
173 |
ios_base& noshowpoint(ios_base& str); |
174 |
ios_base& showpos (ios_base& str); |
175 |
ios_base& noshowpos (ios_base& str); |
176 |
ios_base& skipws (ios_base& str); |
177 |
ios_base& noskipws (ios_base& str); |
178 |
ios_base& uppercase (ios_base& str); |
179 |
ios_base& nouppercase(ios_base& str); |
180 |
ios_base& unitbuf (ios_base& str); |
181 |
ios_base& nounitbuf (ios_base& str); |
182 |
|
183 |
// 27.5.5.2 adjustfield: |
184 |
ios_base& internal (ios_base& str); |
185 |
ios_base& left (ios_base& str); |
186 |
ios_base& right (ios_base& str); |
187 |
|
188 |
// 27.5.5.3 basefield: |
189 |
ios_base& dec (ios_base& str); |
190 |
ios_base& hex (ios_base& str); |
191 |
ios_base& oct (ios_base& str); |
192 |
|
193 |
// 27.5.5.4 floatfield: |
194 |
ios_base& fixed (ios_base& str); |
195 |
ios_base& scientific (ios_base& str); |
196 |
ios_base& hexfloat (ios_base& str); |
197 |
ios_base& defaultfloat(ios_base& str); |
198 |
|
199 |
// 27.5.5.5 error reporting: |
200 |
enum class io_errc |
201 |
{ |
202 |
stream = 1 |
203 |
}; |
204 |
|
205 |
concept_map ErrorCodeEnum<io_errc> { }; |
206 |
error_code make_error_code(io_errc e) noexcept; |
207 |
error_condition make_error_condition(io_errc e) noexcept; |
208 |
storage-class-specifier const error_category& iostream_category() noexcept; |
209 |
|
210 |
} // std |
211 |
|
212 |
*/ |
213 |
|
214 |
#include <__config> |
215 |
#include <iosfwd> |
216 |
#include <__locale> |
217 |
#include <system_error> |
218 |
|
219 |
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) |
220 |
#include <atomic> // for __xindex_ |
221 |
#endif |
222 |
|
223 |
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
224 |
#pragma GCC system_header |
225 |
#endif |
226 |
|
227 |
_LIBCPP_BEGIN_NAMESPACE_STD |
228 |
|
229 |
typedef ptrdiff_t streamsize; |
230 |
|
231 |
class _LIBCPP_TYPE_VIS ios_base |
232 |
{ |
233 |
public: |
234 |
class _LIBCPP_TYPE_VIS failure; |
235 |
|
236 |
typedef unsigned int fmtflags; |
237 |
static const fmtflags boolalpha = 0x0001; |
238 |
static const fmtflags dec = 0x0002; |
239 |
static const fmtflags fixed = 0x0004; |
240 |
static const fmtflags hex = 0x0008; |
241 |
static const fmtflags internal = 0x0010; |
242 |
static const fmtflags left = 0x0020; |
243 |
static const fmtflags oct = 0x0040; |
244 |
static const fmtflags right = 0x0080; |
245 |
static const fmtflags scientific = 0x0100; |
246 |
static const fmtflags showbase = 0x0200; |
247 |
static const fmtflags showpoint = 0x0400; |
248 |
static const fmtflags showpos = 0x0800; |
249 |
static const fmtflags skipws = 0x1000; |
250 |
static const fmtflags unitbuf = 0x2000; |
251 |
static const fmtflags uppercase = 0x4000; |
252 |
static const fmtflags adjustfield = left | right | internal; |
253 |
static const fmtflags basefield = dec | oct | hex; |
254 |
static const fmtflags floatfield = scientific | fixed; |
255 |
|
256 |
typedef unsigned int iostate; |
257 |
typedef iostate io_state; |
258 |
static const iostate badbit = 0x1; |
259 |
static const iostate eofbit = 0x2; |
260 |
static const iostate failbit = 0x4; |
261 |
static const iostate goodbit = 0x0; |
262 |
|
263 |
typedef unsigned int openmode; |
264 |
typedef openmode open_mode; |
265 |
static const openmode app = 0x01; |
266 |
static const openmode ate = 0x02; |
267 |
static const openmode binary = 0x04; |
268 |
static const openmode in = 0x08; |
269 |
static const openmode out = 0x10; |
270 |
static const openmode trunc = 0x20; |
271 |
|
272 |
enum seekdir {beg, cur, end}; |
273 |
typedef seekdir seek_dir; |
274 |
|
275 |
typedef _VSTD::streamoff streamoff; |
276 |
typedef _VSTD::streampos streampos; |
277 |
|
278 |
class _LIBCPP_TYPE_VIS Init; |
279 |
|
280 |
// 27.5.2.2 fmtflags state: |
281 |
_LIBCPP_INLINE_VISIBILITY fmtflags flags() const; |
282 |
_LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl); |
283 |
_LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl); |
284 |
_LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask); |
285 |
_LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask); |
286 |
|
287 |
_LIBCPP_INLINE_VISIBILITY streamsize precision() const; |
288 |
_LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec); |
289 |
_LIBCPP_INLINE_VISIBILITY streamsize width() const; |
290 |
_LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide); |
291 |
|
292 |
// 27.5.2.3 locales: |
293 |
locale imbue(const locale& __loc); |
294 |
locale getloc() const; |
295 |
|
296 |
// 27.5.2.5 storage: |
297 |
static int xalloc(); |
298 |
long& iword(int __index); |
299 |
void*& pword(int __index); |
300 |
|
301 |
// destructor |
302 |
virtual ~ios_base(); |
303 |
|
304 |
// 27.5.2.6 callbacks; |
305 |
enum event { erase_event, imbue_event, copyfmt_event }; |
306 |
typedef void (*event_callback)(event, ios_base&, int __index); |
307 |
void register_callback(event_callback __fn, int __index); |
308 |
|
309 |
private: |
310 |
ios_base(const ios_base&); // = delete; |
311 |
ios_base& operator=(const ios_base&); // = delete; |
312 |
|
313 |
public: |
314 |
static bool sync_with_stdio(bool __sync = true); |
315 |
|
316 |
_LIBCPP_INLINE_VISIBILITY iostate rdstate() const; |
317 |
void clear(iostate __state = goodbit); |
318 |
_LIBCPP_INLINE_VISIBILITY void setstate(iostate __state); |
319 |
|
320 |
_LIBCPP_INLINE_VISIBILITY bool good() const; |
321 |
_LIBCPP_INLINE_VISIBILITY bool eof() const; |
322 |
_LIBCPP_INLINE_VISIBILITY bool fail() const; |
323 |
_LIBCPP_INLINE_VISIBILITY bool bad() const; |
324 |
|
325 |
_LIBCPP_INLINE_VISIBILITY iostate exceptions() const; |
326 |
_LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate); |
327 |
|
328 |
void __set_badbit_and_consider_rethrow(); |
329 |
void __set_failbit_and_consider_rethrow(); |
330 |
|
331 |
protected: |
332 |
_LIBCPP_INLINE_VISIBILITY |
333 |
ios_base() {// purposefully does no initialization |
334 |
} |
335 |
|
336 |
void init(void* __sb); |
337 |
_LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;} |
338 |
|
339 |
_LIBCPP_ALWAYS_INLINE |
340 |
void rdbuf(void* __sb) |
341 |
{ |
342 |
__rdbuf_ = __sb; |
343 |
clear(); |
344 |
} |
345 |
|
346 |
void __call_callbacks(event); |
347 |
void copyfmt(const ios_base&); |
348 |
void move(ios_base&); |
349 |
void swap(ios_base&) _NOEXCEPT; |
350 |
|
351 |
_LIBCPP_ALWAYS_INLINE |
352 |
void set_rdbuf(void* __sb) |
353 |
{ |
354 |
__rdbuf_ = __sb; |
355 |
} |
356 |
|
357 |
private: |
358 |
// All data members must be scalars |
359 |
fmtflags __fmtflags_; |
360 |
streamsize __precision_; |
361 |
streamsize __width_; |
362 |
iostate __rdstate_; |
363 |
iostate __exceptions_; |
364 |
void* __rdbuf_; |
365 |
void* __loc_; |
366 |
event_callback* __fn_; |
367 |
int* __index_; |
368 |
size_t __event_size_; |
369 |
size_t __event_cap_; |
370 |
// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only |
371 |
// enabled with clang. |
372 |
#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) |
373 |
static atomic<int> __xindex_; |
374 |
#else |
375 |
static int __xindex_; |
376 |
#endif |
377 |
long* __iarray_; |
378 |
size_t __iarray_size_; |
379 |
size_t __iarray_cap_; |
380 |
void** __parray_; |
381 |
size_t __parray_size_; |
382 |
size_t __parray_cap_; |
383 |
}; |
384 |
|
385 |
//enum class io_errc |
386 |
_LIBCPP_DECLARE_STRONG_ENUM(io_errc) |
387 |
{ |
388 |
stream = 1 |
389 |
}; |
390 |
_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) |
391 |
|
392 |
template <> |
393 |
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc> : public true_type { }; |
394 |
|
395 |
#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS |
396 |
template <> |
397 |
struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc::__lx> : public true_type { }; |
398 |
#endif |
399 |
|
400 |
_LIBCPP_FUNC_VIS |
401 |
const error_category& iostream_category() _NOEXCEPT; |
402 |
|
403 |
inline _LIBCPP_INLINE_VISIBILITY |
404 |
error_code |
405 |
make_error_code(io_errc __e) _NOEXCEPT |
406 |
{ |
407 |
return error_code(static_cast<int>(__e), iostream_category()); |
408 |
} |
409 |
|
410 |
inline _LIBCPP_INLINE_VISIBILITY |
411 |
error_condition |
412 |
make_error_condition(io_errc __e) _NOEXCEPT |
413 |
{ |
414 |
return error_condition(static_cast<int>(__e), iostream_category()); |
415 |
} |
416 |
|
417 |
class _LIBCPP_EXCEPTION_ABI ios_base::failure |
418 |
: public system_error |
419 |
{ |
420 |
public: |
421 |
explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); |
422 |
explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); |
423 |
virtual ~failure() throw(); |
424 |
}; |
425 |
|
426 |
class _LIBCPP_TYPE_VIS ios_base::Init |
427 |
{ |
428 |
public: |
429 |
Init(); |
430 |
~Init(); |
431 |
}; |
432 |
|
433 |
// fmtflags |
434 |
|
435 |
inline _LIBCPP_INLINE_VISIBILITY |
436 |
ios_base::fmtflags |
437 |
ios_base::flags() const |
438 |
{ |
439 |
return __fmtflags_; |
440 |
} |
441 |
|
442 |
inline _LIBCPP_INLINE_VISIBILITY |
443 |
ios_base::fmtflags |
444 |
ios_base::flags(fmtflags __fmtfl) |
445 |
{ |
446 |
fmtflags __r = __fmtflags_; |
447 |
__fmtflags_ = __fmtfl; |
448 |
return __r; |
449 |
} |
450 |
|
451 |
inline _LIBCPP_INLINE_VISIBILITY |
452 |
ios_base::fmtflags |
453 |
ios_base::setf(fmtflags __fmtfl) |
454 |
{ |
455 |
fmtflags __r = __fmtflags_; |
456 |
__fmtflags_ |= __fmtfl; |
457 |
return __r; |
458 |
} |
459 |
|
460 |
inline _LIBCPP_INLINE_VISIBILITY |
461 |
void |
462 |
ios_base::unsetf(fmtflags __mask) |
463 |
{ |
464 |
__fmtflags_ &= ~__mask; |
465 |
} |
466 |
|
467 |
inline _LIBCPP_INLINE_VISIBILITY |
468 |
ios_base::fmtflags |
469 |
ios_base::setf(fmtflags __fmtfl, fmtflags __mask) |
470 |
{ |
471 |
fmtflags __r = __fmtflags_; |
472 |
unsetf(__mask); |
473 |
__fmtflags_ |= __fmtfl & __mask; |
474 |
return __r; |
475 |
} |
476 |
|
477 |
// precision |
478 |
|
479 |
inline _LIBCPP_INLINE_VISIBILITY |
480 |
streamsize |
481 |
ios_base::precision() const |
482 |
{ |
483 |
return __precision_; |
484 |
} |
485 |
|
486 |
inline _LIBCPP_INLINE_VISIBILITY |
487 |
streamsize |
488 |
ios_base::precision(streamsize __prec) |
489 |
{ |
490 |
streamsize __r = __precision_; |
491 |
__precision_ = __prec; |
492 |
return __r; |
493 |
} |
494 |
|
495 |
// width |
496 |
|
497 |
inline _LIBCPP_INLINE_VISIBILITY |
498 |
streamsize |
499 |
ios_base::width() const |
500 |
{ |
501 |
return __width_; |
502 |
} |
503 |
|
504 |
inline _LIBCPP_INLINE_VISIBILITY |
505 |
streamsize |
506 |
ios_base::width(streamsize __wide) |
507 |
{ |
508 |
streamsize __r = __width_; |
509 |
__width_ = __wide; |
510 |
return __r; |
511 |
} |
512 |
|
513 |
// iostate |
514 |
|
515 |
inline _LIBCPP_INLINE_VISIBILITY |
516 |
ios_base::iostate |
517 |
ios_base::rdstate() const |
518 |
{ |
519 |
return __rdstate_; |
520 |
} |
521 |
|
522 |
inline _LIBCPP_INLINE_VISIBILITY |
523 |
void |
524 |
ios_base::setstate(iostate __state) |
525 |
{ |
526 |
clear(__rdstate_ | __state); |
527 |
} |
528 |
|
529 |
inline _LIBCPP_INLINE_VISIBILITY |
530 |
bool |
531 |
ios_base::good() const |
532 |
{ |
533 |
return __rdstate_ == 0; |
534 |
} |
535 |
|
536 |
inline _LIBCPP_INLINE_VISIBILITY |
537 |
bool |
538 |
ios_base::eof() const |
539 |
{ |
540 |
return (__rdstate_ & eofbit) != 0; |
541 |
} |
542 |
|
543 |
inline _LIBCPP_INLINE_VISIBILITY |
544 |
bool |
545 |
ios_base::fail() const |
546 |
{ |
547 |
return (__rdstate_ & (failbit | badbit)) != 0; |
548 |
} |
549 |
|
550 |
inline _LIBCPP_INLINE_VISIBILITY |
551 |
bool |
552 |
ios_base::bad() const |
553 |
{ |
554 |
return (__rdstate_ & badbit) != 0; |
555 |
} |
556 |
|
557 |
inline _LIBCPP_INLINE_VISIBILITY |
558 |
ios_base::iostate |
559 |
ios_base::exceptions() const |
560 |
{ |
561 |
return __exceptions_; |
562 |
} |
563 |
|
564 |
inline _LIBCPP_INLINE_VISIBILITY |
565 |
void |
566 |
ios_base::exceptions(iostate __iostate) |
567 |
{ |
568 |
__exceptions_ = __iostate; |
569 |
clear(__rdstate_); |
570 |
} |
571 |
|
572 |
template <class _CharT, class _Traits> |
573 |
class _LIBCPP_TYPE_VIS_ONLY basic_ios |
574 |
: public ios_base |
575 |
{ |
576 |
public: |
577 |
// types: |
578 |
typedef _CharT char_type; |
579 |
typedef _Traits traits_type; |
580 |
|
581 |
typedef typename traits_type::int_type int_type; |
582 |
typedef typename traits_type::pos_type pos_type; |
583 |
typedef typename traits_type::off_type off_type; |
584 |
|
585 |
_LIBCPP_ALWAYS_INLINE |
586 |
_LIBCPP_EXPLICIT |
587 |
operator bool() const {return !fail();} |
588 |
_LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();} |
589 |
_LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();} |
590 |
_LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);} |
591 |
_LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);} |
592 |
_LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();} |
593 |
_LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();} |
594 |
_LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();} |
595 |
_LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();} |
596 |
|
597 |
_LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();} |
598 |
_LIBCPP_ALWAYS_INLINE void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);} |
599 |
|
600 |
// 27.5.4.1 Constructor/destructor: |
601 |
_LIBCPP_INLINE_VISIBILITY |
602 |
explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb); |
603 |
virtual ~basic_ios(); |
604 |
|
605 |
// 27.5.4.2 Members: |
606 |
_LIBCPP_INLINE_VISIBILITY |
607 |
basic_ostream<char_type, traits_type>* tie() const; |
608 |
_LIBCPP_INLINE_VISIBILITY |
609 |
basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr); |
610 |
|
611 |
_LIBCPP_INLINE_VISIBILITY |
612 |
basic_streambuf<char_type, traits_type>* rdbuf() const; |
613 |
_LIBCPP_INLINE_VISIBILITY |
614 |
basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb); |
615 |
|
616 |
basic_ios& copyfmt(const basic_ios& __rhs); |
617 |
|
618 |
_LIBCPP_INLINE_VISIBILITY |
619 |
char_type fill() const; |
620 |
_LIBCPP_INLINE_VISIBILITY |
621 |
char_type fill(char_type __ch); |
622 |
|
623 |
_LIBCPP_INLINE_VISIBILITY |
624 |
locale imbue(const locale& __loc); |
625 |
|
626 |
_LIBCPP_INLINE_VISIBILITY |
627 |
char narrow(char_type __c, char __dfault) const; |
628 |
_LIBCPP_INLINE_VISIBILITY |
629 |
char_type widen(char __c) const; |
630 |
|
631 |
protected: |
632 |
_LIBCPP_ALWAYS_INLINE |
633 |
basic_ios() {// purposefully does no initialization |
634 |
} |
635 |
_LIBCPP_INLINE_VISIBILITY |
636 |
void init(basic_streambuf<char_type, traits_type>* __sb); |
637 |
|
638 |
_LIBCPP_INLINE_VISIBILITY |
639 |
void move(basic_ios& __rhs); |
640 |
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
641 |
_LIBCPP_ALWAYS_INLINE |
642 |
void move(basic_ios&& __rhs) {move(__rhs);} |
643 |
#endif |
644 |
_LIBCPP_INLINE_VISIBILITY |
645 |
void swap(basic_ios& __rhs) _NOEXCEPT; |
646 |
_LIBCPP_INLINE_VISIBILITY |
647 |
void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb); |
648 |
private: |
649 |
basic_ostream<char_type, traits_type>* __tie_; |
650 |
mutable int_type __fill_; |
651 |
}; |
652 |
|
653 |
template <class _CharT, class _Traits> |
654 |
inline _LIBCPP_INLINE_VISIBILITY |
655 |
basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb) |
656 |
{ |
657 |
init(__sb); |
658 |
} |
659 |
|
660 |
template <class _CharT, class _Traits> |
661 |
basic_ios<_CharT, _Traits>::~basic_ios() |
662 |
{ |
663 |
} |
664 |
|
665 |
template <class _CharT, class _Traits> |
666 |
inline _LIBCPP_INLINE_VISIBILITY |
667 |
void |
668 |
basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) |
669 |
{ |
670 |
ios_base::init(__sb); |
671 |
__tie_ = 0; |
672 |
__fill_ = traits_type::eof(); |
673 |
} |
674 |
|
675 |
template <class _CharT, class _Traits> |
676 |
inline _LIBCPP_INLINE_VISIBILITY |
677 |
basic_ostream<_CharT, _Traits>* |
678 |
basic_ios<_CharT, _Traits>::tie() const |
679 |
{ |
680 |
return __tie_; |
681 |
} |
682 |
|
683 |
template <class _CharT, class _Traits> |
684 |
inline _LIBCPP_INLINE_VISIBILITY |
685 |
basic_ostream<_CharT, _Traits>* |
686 |
basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) |
687 |
{ |
688 |
basic_ostream<char_type, traits_type>* __r = __tie_; |
689 |
__tie_ = __tiestr; |
690 |
return __r; |
691 |
} |
692 |
|
693 |
template <class _CharT, class _Traits> |
694 |
inline _LIBCPP_INLINE_VISIBILITY |
695 |
basic_streambuf<_CharT, _Traits>* |
696 |
basic_ios<_CharT, _Traits>::rdbuf() const |
697 |
{ |
698 |
return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf()); |
699 |
} |
700 |
|
701 |
template <class _CharT, class _Traits> |
702 |
inline _LIBCPP_INLINE_VISIBILITY |
703 |
basic_streambuf<_CharT, _Traits>* |
704 |
basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) |
705 |
{ |
706 |
basic_streambuf<char_type, traits_type>* __r = rdbuf(); |
707 |
ios_base::rdbuf(__sb); |
708 |
return __r; |
709 |
} |
710 |
|
711 |
template <class _CharT, class _Traits> |
712 |
inline _LIBCPP_INLINE_VISIBILITY |
713 |
locale |
714 |
basic_ios<_CharT, _Traits>::imbue(const locale& __loc) |
715 |
{ |
716 |
locale __r = getloc(); |
717 |
ios_base::imbue(__loc); |
718 |
if (rdbuf()) |
719 |
rdbuf()->pubimbue(__loc); |
720 |
return __r; |
721 |
} |
722 |
|
723 |
template <class _CharT, class _Traits> |
724 |
inline _LIBCPP_INLINE_VISIBILITY |
725 |
char |
726 |
basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const |
727 |
{ |
728 |
return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault); |
729 |
} |
730 |
|
731 |
template <class _CharT, class _Traits> |
732 |
inline _LIBCPP_INLINE_VISIBILITY |
733 |
_CharT |
734 |
basic_ios<_CharT, _Traits>::widen(char __c) const |
735 |
{ |
736 |
return use_facet<ctype<char_type> >(getloc()).widen(__c); |
737 |
} |
738 |
|
739 |
template <class _CharT, class _Traits> |
740 |
inline _LIBCPP_INLINE_VISIBILITY |
741 |
_CharT |
742 |
basic_ios<_CharT, _Traits>::fill() const |
743 |
{ |
744 |
if (traits_type::eq_int_type(traits_type::eof(), __fill_)) |
745 |
__fill_ = widen(' '); |
746 |
return __fill_; |
747 |
} |
748 |
|
749 |
template <class _CharT, class _Traits> |
750 |
inline _LIBCPP_INLINE_VISIBILITY |
751 |
_CharT |
752 |
basic_ios<_CharT, _Traits>::fill(char_type __ch) |
753 |
{ |
754 |
char_type __r = __fill_; |
755 |
__fill_ = __ch; |
756 |
return __r; |
757 |
} |
758 |
|
759 |
template <class _CharT, class _Traits> |
760 |
basic_ios<_CharT, _Traits>& |
761 |
basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) |
762 |
{ |
763 |
if (this != &__rhs) |
764 |
{ |
765 |
__call_callbacks(erase_event); |
766 |
ios_base::copyfmt(__rhs); |
767 |
__tie_ = __rhs.__tie_; |
768 |
__fill_ = __rhs.__fill_; |
769 |
__call_callbacks(copyfmt_event); |
770 |
exceptions(__rhs.exceptions()); |
771 |
} |
772 |
return *this; |
773 |
} |
774 |
|
775 |
template <class _CharT, class _Traits> |
776 |
inline _LIBCPP_INLINE_VISIBILITY |
777 |
void |
778 |
basic_ios<_CharT, _Traits>::move(basic_ios& __rhs) |
779 |
{ |
780 |
ios_base::move(__rhs); |
781 |
__tie_ = __rhs.__tie_; |
782 |
__rhs.__tie_ = 0; |
783 |
__fill_ = __rhs.__fill_; |
784 |
} |
785 |
|
786 |
template <class _CharT, class _Traits> |
787 |
inline _LIBCPP_INLINE_VISIBILITY |
788 |
void |
789 |
basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT |
790 |
{ |
791 |
ios_base::swap(__rhs); |
792 |
_VSTD::swap(__tie_, __rhs.__tie_); |
793 |
_VSTD::swap(__fill_, __rhs.__fill_); |
794 |
} |
795 |
|
796 |
template <class _CharT, class _Traits> |
797 |
inline _LIBCPP_INLINE_VISIBILITY |
798 |
void |
799 |
basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) |
800 |
{ |
801 |
ios_base::set_rdbuf(__sb); |
802 |
} |
803 |
|
804 |
inline _LIBCPP_INLINE_VISIBILITY |
805 |
ios_base& |
806 |
boolalpha(ios_base& __str) |
807 |
{ |
808 |
__str.setf(ios_base::boolalpha); |
809 |
return __str; |
810 |
} |
811 |
|
812 |
inline _LIBCPP_INLINE_VISIBILITY |
813 |
ios_base& |
814 |
noboolalpha(ios_base& __str) |
815 |
{ |
816 |
__str.unsetf(ios_base::boolalpha); |
817 |
return __str; |
818 |
} |
819 |
|
820 |
inline _LIBCPP_INLINE_VISIBILITY |
821 |
ios_base& |
822 |
showbase(ios_base& __str) |
823 |
{ |
824 |
__str.setf(ios_base::showbase); |
825 |
return __str; |
826 |
} |
827 |
|
828 |
inline _LIBCPP_INLINE_VISIBILITY |
829 |
ios_base& |
830 |
noshowbase(ios_base& __str) |
831 |
{ |
832 |
__str.unsetf(ios_base::showbase); |
833 |
return __str; |
834 |
} |
835 |
|
836 |
inline _LIBCPP_INLINE_VISIBILITY |
837 |
ios_base& |
838 |
showpoint(ios_base& __str) |
839 |
{ |
840 |
__str.setf(ios_base::showpoint); |
841 |
return __str; |
842 |
} |
843 |
|
844 |
inline _LIBCPP_INLINE_VISIBILITY |
845 |
ios_base& |
846 |
noshowpoint(ios_base& __str) |
847 |
{ |
848 |
__str.unsetf(ios_base::showpoint); |
849 |
return __str; |
850 |
} |
851 |
|
852 |
inline _LIBCPP_INLINE_VISIBILITY |
853 |
ios_base& |
854 |
showpos(ios_base& __str) |
855 |
{ |
856 |
__str.setf(ios_base::showpos); |
857 |
return __str; |
858 |
} |
859 |
|
860 |
inline _LIBCPP_INLINE_VISIBILITY |
861 |
ios_base& |
862 |
noshowpos(ios_base& __str) |
863 |
{ |
864 |
__str.unsetf(ios_base::showpos); |
865 |
return __str; |
866 |
} |
867 |
|
868 |
inline _LIBCPP_INLINE_VISIBILITY |
869 |
ios_base& |
870 |
skipws(ios_base& __str) |
871 |
{ |
872 |
__str.setf(ios_base::skipws); |
873 |
return __str; |
874 |
} |
875 |
|
876 |
inline _LIBCPP_INLINE_VISIBILITY |
877 |
ios_base& |
878 |
noskipws(ios_base& __str) |
879 |
{ |
880 |
__str.unsetf(ios_base::skipws); |
881 |
return __str; |
882 |
} |
883 |
|
884 |
inline _LIBCPP_INLINE_VISIBILITY |
885 |
ios_base& |
886 |
uppercase(ios_base& __str) |
887 |
{ |
888 |
__str.setf(ios_base::uppercase); |
889 |
return __str; |
890 |
} |
891 |
|
892 |
inline _LIBCPP_INLINE_VISIBILITY |
893 |
ios_base& |
894 |
nouppercase(ios_base& __str) |
895 |
{ |
896 |
__str.unsetf(ios_base::uppercase); |
897 |
return __str; |
898 |
} |
899 |
|
900 |
inline _LIBCPP_INLINE_VISIBILITY |
901 |
ios_base& |
902 |
unitbuf(ios_base& __str) |
903 |
{ |
904 |
__str.setf(ios_base::unitbuf); |
905 |
return __str; |
906 |
} |
907 |
|
908 |
inline _LIBCPP_INLINE_VISIBILITY |
909 |
ios_base& |
910 |
nounitbuf(ios_base& __str) |
911 |
{ |
912 |
__str.unsetf(ios_base::unitbuf); |
913 |
return __str; |
914 |
} |
915 |
|
916 |
inline _LIBCPP_INLINE_VISIBILITY |
917 |
ios_base& |
918 |
internal(ios_base& __str) |
919 |
{ |
920 |
__str.setf(ios_base::internal, ios_base::adjustfield); |
921 |
return __str; |
922 |
} |
923 |
|
924 |
inline _LIBCPP_INLINE_VISIBILITY |
925 |
ios_base& |
926 |
left(ios_base& __str) |
927 |
{ |
928 |
__str.setf(ios_base::left, ios_base::adjustfield); |
929 |
return __str; |
930 |
} |
931 |
|
932 |
inline _LIBCPP_INLINE_VISIBILITY |
933 |
ios_base& |
934 |
right(ios_base& __str) |
935 |
{ |
936 |
__str.setf(ios_base::right, ios_base::adjustfield); |
937 |
return __str; |
938 |
} |
939 |
|
940 |
inline _LIBCPP_INLINE_VISIBILITY |
941 |
ios_base& |
942 |
dec(ios_base& __str) |
943 |
{ |
944 |
__str.setf(ios_base::dec, ios_base::basefield); |
945 |
return __str; |
946 |
} |
947 |
|
948 |
inline _LIBCPP_INLINE_VISIBILITY |
949 |
ios_base& |
950 |
hex(ios_base& __str) |
951 |
{ |
952 |
__str.setf(ios_base::hex, ios_base::basefield); |
953 |
return __str; |
954 |
} |
955 |
|
956 |
inline _LIBCPP_INLINE_VISIBILITY |
957 |
ios_base& |
958 |
oct(ios_base& __str) |
959 |
{ |
960 |
__str.setf(ios_base::oct, ios_base::basefield); |
961 |
return __str; |
962 |
} |
963 |
|
964 |
inline _LIBCPP_INLINE_VISIBILITY |
965 |
ios_base& |
966 |
fixed(ios_base& __str) |
967 |
{ |
968 |
__str.setf(ios_base::fixed, ios_base::floatfield); |
969 |
return __str; |
970 |
} |
971 |
|
972 |
inline _LIBCPP_INLINE_VISIBILITY |
973 |
ios_base& |
974 |
scientific(ios_base& __str) |
975 |
{ |
976 |
__str.setf(ios_base::scientific, ios_base::floatfield); |
977 |
return __str; |
978 |
} |
979 |
|
980 |
inline _LIBCPP_INLINE_VISIBILITY |
981 |
ios_base& |
982 |
hexfloat(ios_base& __str) |
983 |
{ |
984 |
__str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); |
985 |
return __str; |
986 |
} |
987 |
|
988 |
inline _LIBCPP_INLINE_VISIBILITY |
989 |
ios_base& |
990 |
defaultfloat(ios_base& __str) |
991 |
{ |
992 |
__str.unsetf(ios_base::floatfield); |
993 |
return __str; |
994 |
} |
995 |
|
996 |
template <class _CharT, class _Traits> |
997 |
class __save_flags |
998 |
{ |
999 |
typedef basic_ios<_CharT, _Traits> __stream_type; |
1000 |
typedef typename __stream_type::fmtflags fmtflags; |
1001 |
|
1002 |
__stream_type& __stream_; |
1003 |
fmtflags __fmtflags_; |
1004 |
_CharT __fill_; |
1005 |
|
1006 |
__save_flags(const __save_flags&); |
1007 |
__save_flags& operator=(const __save_flags&); |
1008 |
public: |
1009 |
_LIBCPP_INLINE_VISIBILITY |
1010 |
explicit __save_flags(__stream_type& __stream) |
1011 |
: __stream_(__stream), |
1012 |
__fmtflags_(__stream.flags()), |
1013 |
__fill_(__stream.fill()) |
1014 |
{} |
1015 |
_LIBCPP_INLINE_VISIBILITY |
1016 |
~__save_flags() |
1017 |
{ |
1018 |
__stream_.flags(__fmtflags_); |
1019 |
__stream_.fill(__fill_); |
1020 |
} |
1021 |
}; |
1022 |
|
1023 |
_LIBCPP_END_NAMESPACE_STD |
1024 |
|
1025 |
#endif // _LIBCPP_IOS |