blob: b0e7ab96346e452788476a66d77cae51afda1923 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- ios -------------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_IOS
12#define _LIBCPP_IOS
13
14/*
15 ios synopsis
16
17#include <iosfwd>
18
19namespace std
20{
21
22typedef OFF_T streamoff;
23typedef SZ_T streamsize;
24template <class stateT> class fpos;
25
26class ios_base
27{
28public:
29 class failure;
30
31 typedef T1 fmtflags;
32 static const fmtflags boolalpha;
33 static const fmtflags dec;
34 static const fmtflags fixed;
35 static const fmtflags hex;
36 static const fmtflags internal;
37 static const fmtflags left;
38 static const fmtflags oct;
39 static const fmtflags right;
40 static const fmtflags scientific;
41 static const fmtflags showbase;
42 static const fmtflags showpoint;
43 static const fmtflags showpos;
44 static const fmtflags skipws;
45 static const fmtflags unitbuf;
46 static const fmtflags uppercase;
47 static const fmtflags adjustfield;
48 static const fmtflags basefield;
49 static const fmtflags floatfield;
50
51 typedef T2 iostate;
52 static const iostate badbit;
53 static const iostate eofbit;
54 static const iostate failbit;
55 static const iostate goodbit;
56
57 typedef T3 openmode;
58 static const openmode app;
59 static const openmode ate;
60 static const openmode binary;
61 static const openmode in;
62 static const openmode out;
63 static const openmode trunc;
64
65 typedef T4 seekdir;
66 static const seekdir beg;
67 static const seekdir cur;
68 static const 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
106protected:
107 ios_base();
108};
109
110template <class charT, class traits = char_traits<charT> >
111class basic_ios
112 : public ios_base
113{
114public:
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
159protected:
160 basic_ios();
161 void init(basic_streambuf<charT,traits>* sb);
162 void move(basic_ios& rhs);
163 void swap(basic_ios& rhs);
164 void set_rdbuf(basic_streambuf<charT, traits>* sb);
165};
166
167// 27.5.5, manipulators:
168ios_base& boolalpha (ios_base& str);
169ios_base& noboolalpha(ios_base& str);
170ios_base& showbase (ios_base& str);
171ios_base& noshowbase (ios_base& str);
172ios_base& showpoint (ios_base& str);
173ios_base& noshowpoint(ios_base& str);
174ios_base& showpos (ios_base& str);
175ios_base& noshowpos (ios_base& str);
176ios_base& skipws (ios_base& str);
177ios_base& noskipws (ios_base& str);
178ios_base& uppercase (ios_base& str);
179ios_base& nouppercase(ios_base& str);
180ios_base& unitbuf (ios_base& str);
181ios_base& nounitbuf (ios_base& str);
182
183// 27.5.5.2 adjustfield:
184ios_base& internal (ios_base& str);
185ios_base& left (ios_base& str);
186ios_base& right (ios_base& str);
187
188// 27.5.5.3 basefield:
189ios_base& dec (ios_base& str);
190ios_base& hex (ios_base& str);
191ios_base& oct (ios_base& str);
192
193// 27.5.5.4 floatfield:
194ios_base& fixed (ios_base& str);
195ios_base& scientific (ios_base& str);
196ios_base& hexfloat (ios_base& str);
197ios_base& defaultfloat(ios_base& str);
198
199// 27.5.5.5 error reporting:
200enum class io_errc
201{
202 stream = 1
203};
204
205concept_map ErrorCodeEnum<io_errc> { };
206error_code make_error_code(io_errc e);
207error_condition make_error_condition(io_errc e);
208storage-class-specifier const error_category& iostream_category;
209
210} // std
211
212*/
213
214#include <__config>
215#include <iosfwd>
216#include <__locale>
217#include <system_error>
218
219#pragma GCC system_header
220
221_LIBCPP_BEGIN_NAMESPACE_STD
222
223typedef ptrdiff_t streamsize;
224
Howard Hinnant68a8e902010-09-22 15:29:08 +0000225class _LIBCPP_VISIBLE ios_base
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000226{
227public:
228 class failure;
229
230 typedef unsigned int fmtflags;
231 static const fmtflags boolalpha = 0x0001;
232 static const fmtflags dec = 0x0002;
233 static const fmtflags fixed = 0x0004;
234 static const fmtflags hex = 0x0008;
235 static const fmtflags internal = 0x0010;
236 static const fmtflags left = 0x0020;
237 static const fmtflags oct = 0x0040;
238 static const fmtflags right = 0x0080;
239 static const fmtflags scientific = 0x0100;
240 static const fmtflags showbase = 0x0200;
241 static const fmtflags showpoint = 0x0400;
242 static const fmtflags showpos = 0x0800;
243 static const fmtflags skipws = 0x1000;
244 static const fmtflags unitbuf = 0x2000;
245 static const fmtflags uppercase = 0x4000;
246 static const fmtflags adjustfield = left | right | internal;
247 static const fmtflags basefield = dec | oct | hex;
248 static const fmtflags floatfield = scientific | fixed;
249
250 typedef unsigned int iostate;
251 typedef iostate io_state;
252 static const iostate badbit = 0x1;
253 static const iostate eofbit = 0x2;
254 static const iostate failbit = 0x4;
255 static const iostate goodbit = 0x0;
256
257 typedef unsigned int openmode;
258 typedef openmode open_mode;
259 static const openmode app = 0x01;
260 static const openmode ate = 0x02;
261 static const openmode binary = 0x04;
262 static const openmode in = 0x08;
263 static const openmode out = 0x10;
264 static const openmode trunc = 0x20;
265
266 enum seekdir {beg, cur, end};
267 typedef seekdir seek_dir;
268
269 typedef _STD::streamoff streamoff;
270 typedef _STD::streampos streampos;
271
272 class Init;
273
274 // 27.5.2.2 fmtflags state:
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000275 _LIBCPP_INLINE_VISIBILITY fmtflags flags() const;
276 _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl);
277 _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl);
278 _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
279 _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000280
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000281 _LIBCPP_INLINE_VISIBILITY streamsize precision() const;
282 _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec);
283 _LIBCPP_INLINE_VISIBILITY streamsize width() const;
284 _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000285
286 // 27.5.2.3 locales:
287 locale imbue(const locale& __loc);
288 locale getloc() const;
289
290 // 27.5.2.5 storage:
291 static int xalloc();
292 long& iword(int __index);
293 void*& pword(int __index);
294
295 // destructor
296 virtual ~ios_base();
297
298 // 27.5.2.6 callbacks;
299 enum event { erase_event, imbue_event, copyfmt_event };
300 typedef void (*event_callback)(event, ios_base&, int __index);
301 void register_callback(event_callback __fn, int __index);
302
303private:
304 ios_base(const ios_base&); // = delete;
305 ios_base& operator=(const ios_base&); // = delete;
306
307public:
308 static bool sync_with_stdio(bool __sync = true);
309
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000310 _LIBCPP_INLINE_VISIBILITY iostate rdstate() const;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000311 void clear(iostate __state = goodbit);
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000312 _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000313
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000314 _LIBCPP_INLINE_VISIBILITY bool good() const;
315 _LIBCPP_INLINE_VISIBILITY bool eof() const;
316 _LIBCPP_INLINE_VISIBILITY bool fail() const;
317 _LIBCPP_INLINE_VISIBILITY bool bad() const;
Howard Hinnant324bb032010-08-22 00:02:43 +0000318
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000319 _LIBCPP_INLINE_VISIBILITY iostate exceptions() const;
320 _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __except);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000321
322 void __set_badbit_and_consider_rethrow();
323 void __set_failbit_and_consider_rethrow();
324
325protected:
Howard Hinnant68a8e902010-09-22 15:29:08 +0000326 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000327 ios_base() {// purposefully does no initialization
328 }
329
330 void init(void* __sb);
331 _LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;}
332
333 _LIBCPP_ALWAYS_INLINE
334 void rdbuf(void* __sb)
335 {
336 __rdbuf_ = __sb;
337 clear();
338 }
339
340 void __call_callbacks(event);
341 void copyfmt(const ios_base&);
342 void move(ios_base&);
343 void swap(ios_base&);
344
345 _LIBCPP_ALWAYS_INLINE
346 void set_rdbuf(void* __sb)
347 {
348 __rdbuf_ = __sb;
349 }
350
351private:
352 // All data members must be scalars
353 fmtflags __fmtflags_;
354 streamsize __precision_;
355 streamsize __width_;
356 iostate __rdstate_;
357 iostate __exceptions_;
358 void* __rdbuf_;
359 void* __loc_;
360 event_callback* __fn_;
361 int* __index_;
362 size_t __event_size_;
363 size_t __event_cap_;
364 static int __xindex_;
365 long* __iarray_;
366 size_t __iarray_size_;
367 size_t __iarray_cap_;
368 void** __parray_;
369 size_t __parray_size_;
370 size_t __parray_cap_;
371};
372
373//enum class io_errc
Howard Hinnant68a8e902010-09-22 15:29:08 +0000374struct _LIBCPP_VISIBLE io_errc
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000375{
376enum _ {
377 stream = 1
378};
379 _ __v_;
380
381 _LIBCPP_ALWAYS_INLINE io_errc(_ __v) : __v_(__v) {}
382 _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;}
383};
384
Howard Hinnant68a8e902010-09-22 15:29:08 +0000385template <>
386struct _LIBCPP_VISIBLE is_error_code_enum<io_errc> : public true_type { };
387template <>
388struct _LIBCPP_VISIBLE is_error_code_enum<io_errc::_> : public true_type { };
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000389
Howard Hinnant68a8e902010-09-22 15:29:08 +0000390_LIBCPP_VISIBLE
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000391const error_category& iostream_category();
392
393inline _LIBCPP_INLINE_VISIBILITY
394error_code
395make_error_code(io_errc __e)
396{
397 return error_code(static_cast<int>(__e), iostream_category());
398}
399
400inline _LIBCPP_INLINE_VISIBILITY
401error_condition
402make_error_condition(io_errc __e)
403{
404 return error_condition(static_cast<int>(__e), iostream_category());
405}
406
Howard Hinnant68a8e902010-09-22 15:29:08 +0000407class _LIBCPP_EXCEPTION_ABI ios_base::failure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000408 : public system_error
Howard Hinnant324bb032010-08-22 00:02:43 +0000409{
410public:
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000411 explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
Howard Hinnant324bb032010-08-22 00:02:43 +0000412 explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000413 virtual ~failure() throw();
414};
415
Howard Hinnant68a8e902010-09-22 15:29:08 +0000416class _LIBCPP_VISIBLE ios_base::Init
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000417{
418public:
419 Init();
420 ~Init();
421};
422
423// fmtflags
424
425inline _LIBCPP_INLINE_VISIBILITY
426ios_base::fmtflags
427ios_base::flags() const
428{
429 return __fmtflags_;
430}
431
432inline _LIBCPP_INLINE_VISIBILITY
433ios_base::fmtflags
434ios_base::flags(fmtflags __fmtfl)
435{
436 fmtflags __r = __fmtflags_;
437 __fmtflags_ = __fmtfl;
438 return __r;
439}
440
441inline _LIBCPP_INLINE_VISIBILITY
442ios_base::fmtflags
443ios_base::setf(fmtflags __fmtfl)
444{
445 fmtflags __r = __fmtflags_;
446 __fmtflags_ |= __fmtfl;
447 return __r;
448}
449
450inline _LIBCPP_INLINE_VISIBILITY
451void
452ios_base::unsetf(fmtflags __mask)
453{
454 __fmtflags_ &= ~__mask;
455}
456
457inline _LIBCPP_INLINE_VISIBILITY
458ios_base::fmtflags
459ios_base::setf(fmtflags __fmtfl, fmtflags __mask)
460{
461 fmtflags __r = __fmtflags_;
462 unsetf(__mask);
463 __fmtflags_ |= __fmtfl & __mask;
464 return __r;
465}
466
467// precision
468
469inline _LIBCPP_INLINE_VISIBILITY
470streamsize
471ios_base::precision() const
472{
473 return __precision_;
474}
475
476inline _LIBCPP_INLINE_VISIBILITY
477streamsize
478ios_base::precision(streamsize __prec)
479{
480 streamsize __r = __precision_;
481 __precision_ = __prec;
482 return __r;
483}
484
485// width
486
487inline _LIBCPP_INLINE_VISIBILITY
488streamsize
489ios_base::width() const
490{
491 return __width_;
492}
493
494inline _LIBCPP_INLINE_VISIBILITY
495streamsize
496ios_base::width(streamsize __wide)
497{
498 streamsize __r = __width_;
499 __width_ = __wide;
500 return __r;
501}
502
503// iostate
504
505inline _LIBCPP_INLINE_VISIBILITY
506ios_base::iostate
507ios_base::rdstate() const
508{
509 return __rdstate_;
510}
511
512inline _LIBCPP_INLINE_VISIBILITY
513void
514ios_base::setstate(iostate __state)
515{
516 clear(__rdstate_ | __state);
517}
518
519inline _LIBCPP_INLINE_VISIBILITY
520bool
521ios_base::good() const
522{
523 return __rdstate_ == 0;
524}
525
526inline _LIBCPP_INLINE_VISIBILITY
527bool
528ios_base::eof() const
529{
530 return __rdstate_ & eofbit;
531}
532
533inline _LIBCPP_INLINE_VISIBILITY
534bool
535ios_base::fail() const
536{
537 return __rdstate_ & (failbit | badbit);
538}
539
540inline _LIBCPP_INLINE_VISIBILITY
541bool
542ios_base::bad() const
543{
544 return __rdstate_ & badbit;
545}
546
547inline _LIBCPP_INLINE_VISIBILITY
548ios_base::iostate
549ios_base::exceptions() const
550{
551 return __exceptions_;
552}
553
554inline _LIBCPP_INLINE_VISIBILITY
555void
556ios_base::exceptions(iostate __except)
557{
558 __exceptions_ = __except;
559 clear(__rdstate_);
560}
561
562template <class _CharT, class _Traits>
Howard Hinnant68a8e902010-09-22 15:29:08 +0000563class _LIBCPP_VISIBLE basic_ios
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000564 : public ios_base
565{
566public:
567 // types:
568 typedef _CharT char_type;
569 typedef _Traits traits_type;
570
571 typedef typename traits_type::int_type int_type;
572 typedef typename traits_type::pos_type pos_type;
573 typedef typename traits_type::off_type off_type;
574
575 _LIBCPP_ALWAYS_INLINE // explicit
576 operator bool() const {return !fail();}
577 _LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();}
578 _LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();}
579 _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);}
580 _LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);}
581 _LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();}
582 _LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();}
583 _LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();}
584 _LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();}
585
586 _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();}
587 _LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);}
588
589 // 27.5.4.1 Constructor/destructor:
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000590 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000591 explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb);
592 virtual ~basic_ios();
593
594 // 27.5.4.2 Members:
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000595 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000596 basic_ostream<char_type, traits_type>* tie() const;
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000597 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000598 basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
599
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000600 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000601 basic_streambuf<char_type, traits_type>* rdbuf() const;
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000602 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000603 basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
604
605 basic_ios& copyfmt(const basic_ios& __rhs);
606
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000607 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000608 char_type fill() const;
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000609 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000610 char_type fill(char_type __ch);
611
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000612 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000613 locale imbue(const locale& __loc);
614
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000615 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000616 char narrow(char_type __c, char __dfault) const;
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000617 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000618 char_type widen(char __c) const;
619
620protected:
Howard Hinnant68a8e902010-09-22 15:29:08 +0000621 _LIBCPP_ALWAYS_INLINE
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000622 basic_ios() {// purposefully does no initialization
623 }
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000624 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000625 void init(basic_streambuf<char_type, traits_type>* __sb);
626
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000627 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000628 void move(basic_ios& __rhs);
Howard Hinnant73d21a42010-09-04 23:28:19 +0000629#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnant68a8e902010-09-22 15:29:08 +0000630 _LIBCPP_ALWAYS_INLINE
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000631 void move(basic_ios&& __rhs) {move(__rhs);}
632#endif
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000633 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000634 void swap(basic_ios& __rhs);
Howard Hinnant2d72b1e2010-12-17 14:46:43 +0000635 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000636 void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
637private:
638 basic_ostream<char_type, traits_type>* __tie_;
639 char_type __fill_;
640};
641
642template <class _CharT, class _Traits>
643inline _LIBCPP_INLINE_VISIBILITY
644basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb)
645{
646 init(__sb);
647}
648
649template <class _CharT, class _Traits>
650basic_ios<_CharT, _Traits>::~basic_ios()
651{
652}
653
654template <class _CharT, class _Traits>
655inline _LIBCPP_INLINE_VISIBILITY
656void
657basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb)
658{
659 ios_base::init(__sb);
660 __tie_ = 0;
661 __fill_ = widen(' ');
662}
663
664template <class _CharT, class _Traits>
665inline _LIBCPP_INLINE_VISIBILITY
666basic_ostream<_CharT, _Traits>*
667basic_ios<_CharT, _Traits>::tie() const
668{
669 return __tie_;
670}
671
672template <class _CharT, class _Traits>
673inline _LIBCPP_INLINE_VISIBILITY
674basic_ostream<_CharT, _Traits>*
675basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr)
676{
677 basic_ostream<char_type, traits_type>* __r = __tie_;
678 __tie_ = __tiestr;
679 return __r;
680}
681
682template <class _CharT, class _Traits>
683inline _LIBCPP_INLINE_VISIBILITY
684basic_streambuf<_CharT, _Traits>*
685basic_ios<_CharT, _Traits>::rdbuf() const
686{
687 return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf());
688}
689
690template <class _CharT, class _Traits>
691inline _LIBCPP_INLINE_VISIBILITY
692basic_streambuf<_CharT, _Traits>*
693basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb)
694{
695 basic_streambuf<char_type, traits_type>* __r = rdbuf();
696 ios_base::rdbuf(__sb);
697 return __r;
698}
699
700template <class _CharT, class _Traits>
701inline _LIBCPP_INLINE_VISIBILITY
702locale
703basic_ios<_CharT, _Traits>::imbue(const locale& __loc)
704{
705 locale __r = getloc();
706 ios_base::imbue(__loc);
707 if (rdbuf())
708 rdbuf()->pubimbue(__loc);
709 return __r;
710}
711
712template <class _CharT, class _Traits>
713inline _LIBCPP_INLINE_VISIBILITY
714char
715basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const
716{
717 return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
718}
719
720template <class _CharT, class _Traits>
721inline _LIBCPP_INLINE_VISIBILITY
722_CharT
723basic_ios<_CharT, _Traits>::widen(char __c) const
724{
725 return use_facet<ctype<char_type> >(getloc()).widen(__c);
726}
727
728template <class _CharT, class _Traits>
729inline _LIBCPP_INLINE_VISIBILITY
730_CharT
731basic_ios<_CharT, _Traits>::fill() const
732{
733 return __fill_;
734}
735
736template <class _CharT, class _Traits>
737inline _LIBCPP_INLINE_VISIBILITY
738_CharT
739basic_ios<_CharT, _Traits>::fill(char_type __ch)
740{
741 char_type __r = __fill_;
742 __fill_ = __ch;
743 return __r;
744}
745
746template <class _CharT, class _Traits>
747basic_ios<_CharT, _Traits>&
748basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs)
749{
750 if (this != &__rhs)
751 {
752 __call_callbacks(erase_event);
753 ios_base::copyfmt(__rhs);
754 __tie_ = __rhs.__tie_;
755 __fill_ = __rhs.__fill_;
756 __call_callbacks(copyfmt_event);
757 exceptions(__rhs.exceptions());
758 }
759 return *this;
760}
761
762template <class _CharT, class _Traits>
763inline _LIBCPP_INLINE_VISIBILITY
764void
765basic_ios<_CharT, _Traits>::move(basic_ios& __rhs)
766{
767 ios_base::move(__rhs);
768 __tie_ = __rhs.__tie_;
769 __rhs.__tie_ = 0;
770 __fill_ = __rhs.__fill_;
771}
772
773template <class _CharT, class _Traits>
774inline _LIBCPP_INLINE_VISIBILITY
775void
776basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs)
777{
778 ios_base::swap(__rhs);
779 _STD::swap(__tie_, __rhs.__tie_);
780 _STD::swap(__fill_, __rhs.__fill_);
781}
782
783template <class _CharT, class _Traits>
784inline _LIBCPP_INLINE_VISIBILITY
785void
786basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb)
787{
788 ios_base::set_rdbuf(__sb);
789}
790
791inline _LIBCPP_INLINE_VISIBILITY
792ios_base&
793boolalpha(ios_base& __str)
794{
795 __str.setf(ios_base::boolalpha);
796 return __str;
797}
798
799inline _LIBCPP_INLINE_VISIBILITY
800ios_base&
801noboolalpha(ios_base& __str)
802{
803 __str.unsetf(ios_base::boolalpha);
804 return __str;
805}
806
807inline _LIBCPP_INLINE_VISIBILITY
808ios_base&
809showbase(ios_base& __str)
810{
811 __str.setf(ios_base::showbase);
812 return __str;
813}
814
815inline _LIBCPP_INLINE_VISIBILITY
816ios_base&
817noshowbase(ios_base& __str)
818{
819 __str.unsetf(ios_base::showbase);
820 return __str;
821}
822
823inline _LIBCPP_INLINE_VISIBILITY
824ios_base&
825showpoint(ios_base& __str)
826{
827 __str.setf(ios_base::showpoint);
828 return __str;
829}
830
831inline _LIBCPP_INLINE_VISIBILITY
832ios_base&
833noshowpoint(ios_base& __str)
834{
835 __str.unsetf(ios_base::showpoint);
836 return __str;
837}
838
839inline _LIBCPP_INLINE_VISIBILITY
840ios_base&
841showpos(ios_base& __str)
842{
843 __str.setf(ios_base::showpos);
844 return __str;
845}
846
847inline _LIBCPP_INLINE_VISIBILITY
848ios_base&
849noshowpos(ios_base& __str)
850{
851 __str.unsetf(ios_base::showpos);
852 return __str;
853}
854
855inline _LIBCPP_INLINE_VISIBILITY
856ios_base&
857skipws(ios_base& __str)
858{
859 __str.setf(ios_base::skipws);
860 return __str;
861}
862
863inline _LIBCPP_INLINE_VISIBILITY
864ios_base&
865noskipws(ios_base& __str)
866{
867 __str.unsetf(ios_base::skipws);
868 return __str;
869}
870
871inline _LIBCPP_INLINE_VISIBILITY
872ios_base&
873uppercase(ios_base& __str)
874{
875 __str.setf(ios_base::uppercase);
876 return __str;
877}
878
879inline _LIBCPP_INLINE_VISIBILITY
880ios_base&
881nouppercase(ios_base& __str)
882{
883 __str.unsetf(ios_base::uppercase);
884 return __str;
885}
886
887inline _LIBCPP_INLINE_VISIBILITY
888ios_base&
889unitbuf(ios_base& __str)
890{
891 __str.setf(ios_base::unitbuf);
892 return __str;
893}
894
895inline _LIBCPP_INLINE_VISIBILITY
896ios_base&
897nounitbuf(ios_base& __str)
898{
899 __str.unsetf(ios_base::unitbuf);
900 return __str;
901}
902
903inline _LIBCPP_INLINE_VISIBILITY
904ios_base&
905internal(ios_base& __str)
906{
907 __str.setf(ios_base::internal, ios_base::adjustfield);
908 return __str;
909}
910
911inline _LIBCPP_INLINE_VISIBILITY
912ios_base&
913left(ios_base& __str)
914{
915 __str.setf(ios_base::left, ios_base::adjustfield);
916 return __str;
917}
918
919inline _LIBCPP_INLINE_VISIBILITY
920ios_base&
921right(ios_base& __str)
922{
923 __str.setf(ios_base::right, ios_base::adjustfield);
924 return __str;
925}
926
927inline _LIBCPP_INLINE_VISIBILITY
928ios_base&
929dec(ios_base& __str)
930{
931 __str.setf(ios_base::dec, ios_base::basefield);
932 return __str;
933}
934
935inline _LIBCPP_INLINE_VISIBILITY
936ios_base&
937hex(ios_base& __str)
938{
939 __str.setf(ios_base::hex, ios_base::basefield);
940 return __str;
941}
942
943inline _LIBCPP_INLINE_VISIBILITY
944ios_base&
945oct(ios_base& __str)
946{
947 __str.setf(ios_base::oct, ios_base::basefield);
948 return __str;
949}
950
951inline _LIBCPP_INLINE_VISIBILITY
952ios_base&
953fixed(ios_base& __str)
954{
955 __str.setf(ios_base::fixed, ios_base::floatfield);
956 return __str;
957}
958
959inline _LIBCPP_INLINE_VISIBILITY
960ios_base&
961scientific(ios_base& __str)
962{
963 __str.setf(ios_base::scientific, ios_base::floatfield);
964 return __str;
965}
966
967inline _LIBCPP_INLINE_VISIBILITY
968ios_base&
969hexfloat(ios_base& __str)
970{
971 __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
972 return __str;
973}
974
975inline _LIBCPP_INLINE_VISIBILITY
976ios_base&
977defaultfloat(ios_base& __str)
978{
979 __str.unsetf(ios_base::floatfield);
980 return __str;
981}
982
983_LIBCPP_END_NAMESPACE_STD
984
985#endif // _LIBCPP_IOS