ios revision 242939
10Sduke// -*- C++ -*- 212953Scoleenp//===---------------------------- ios -------------------------------------===// 30Sduke// 40Sduke// The LLVM Compiler Infrastructure 50Sduke// 60Sduke// This file is dual licensed under the MIT and the University of Illinois Open 70Sduke// Source Licenses. See LICENSE.TXT for details. 80Sduke// 90Sduke//===----------------------------------------------------------------------===// 100Sduke 110Sduke#ifndef _LIBCPP_IOS 120Sduke#define _LIBCPP_IOS 130Sduke 140Sduke/* 150Sduke ios synopsis 160Sduke 170Sduke#include <iosfwd> 180Sduke 191472Strimsnamespace std 201472Strims{ 211472Strims 220Sduketypedef OFF_T streamoff; 230Sduketypedef SZ_T streamsize; 240Sduketemplate <class stateT> class fpos; 251879Sstefank 261879Sstefankclass ios_base 271879Sstefank{ 282702Sneverpublic: 291879Sstefank class failure; 301879Sstefank 316760Sgoetz typedef T1 fmtflags; 326760Sgoetz static constexpr fmtflags boolalpha; 333648Sminqi static constexpr fmtflags dec; 340Sduke static constexpr fmtflags fixed; 353602Scoleenp static constexpr fmtflags hex; 360Sduke static constexpr fmtflags internal; 370Sduke static constexpr fmtflags left; 380Sduke static constexpr fmtflags oct; 390Sduke static constexpr fmtflags right; 400Sduke static constexpr fmtflags scientific; 410Sduke static constexpr fmtflags showbase; 420Sduke static constexpr fmtflags showpoint; 4312953Scoleenp static constexpr fmtflags showpos; 4412953Scoleenp static constexpr fmtflags skipws; 450Sduke static constexpr fmtflags unitbuf; 462702Snever static constexpr fmtflags uppercase; 4712953Scoleenp static constexpr fmtflags adjustfield; 482702Snever static constexpr fmtflags basefield; 492708Snever static constexpr fmtflags floatfield; 5012953Scoleenp 512702Snever typedef T2 iostate; 522702Snever static constexpr iostate badbit; 532702Snever static constexpr iostate eofbit; 542702Snever static constexpr iostate failbit; 550Sduke static constexpr iostate goodbit; 5612953Scoleenp 572702Snever typedef T3 openmode; 583602Scoleenp static constexpr openmode app; 597261Saeriksso static constexpr openmode ate; 600Sduke static constexpr openmode binary; 610Sduke static constexpr openmode in; 620Sduke static constexpr openmode out; 630Sduke static constexpr openmode trunc; 640Sduke 650Sduke typedef T4 seekdir; 660Sduke static constexpr seekdir beg; 670Sduke static constexpr seekdir cur; 680Sduke static constexpr seekdir end; 692702Snever 700Sduke class Init; 710Sduke 720Sduke // 27.5.2.2 fmtflags state: 730Sduke fmtflags flags() const; 740Sduke fmtflags flags(fmtflags fmtfl); 750Sduke fmtflags setf(fmtflags fmtfl); 760Sduke fmtflags setf(fmtflags fmtfl, fmtflags mask); 770Sduke void unsetf(fmtflags mask); 780Sduke 790Sduke streamsize precision() const; 800Sduke streamsize precision(streamsize prec); 810Sduke streamsize width() const; 823602Scoleenp streamsize width(streamsize wide); 830Sduke 840Sduke // 27.5.2.3 locales: 857261Saeriksso locale imbue(const locale& loc); 867261Saeriksso locale getloc() const; 877261Saeriksso 880Sduke // 27.5.2.5 storage: 890Sduke static int xalloc(); 900Sduke long& iword(int index); 910Sduke void*& pword(int index); 920Sduke 930Sduke // destructor 940Sduke virtual ~ios_base(); 950Sduke 960Sduke // 27.5.2.6 callbacks; 970Sduke enum event { erase_event, imbue_event, copyfmt_event }; 980Sduke typedef void (*event_callback)(event, ios_base&, int index); 990Sduke void register_callback(event_callback fn, int index); 1000Sduke 1010Sduke ios_base(const ios_base&) = delete; 1023602Scoleenp ios_base& operator=(const ios_base&) = delete; 1030Sduke 1040Sduke static bool sync_with_stdio(bool sync = true); 1057261Saeriksso 1067261Saerikssoprotected: 1077261Saeriksso ios_base(); 1080Sduke}; 1090Sduke 1100Sduketemplate <class charT, class traits = char_traits<charT> > 1110Sdukeclass basic_ios 1120Sduke : public ios_base 1130Sduke{ 1140Sdukepublic: 1150Sduke // types: 1160Sduke typedef charT char_type; 1170Sduke typedef typename traits::int_type int_type; 1180Sduke typedef typename traits::pos_type pos_type; 1190Sduke typedef typename traits::off_type off_type; 1200Sduke typedef traits traits_type; 1210Sduke 1220Sduke operator unspecified-bool-type() const; 1230Sduke bool operator!() const; 1240Sduke iostate rdstate() const; 1250Sduke void clear(iostate state = goodbit); 1260Sduke void setstate(iostate state); 1270Sduke bool good() const; 1289248Scoleenp bool eof() const; 1293602Scoleenp bool fail() const; 1300Sduke bool bad() const; 1310Sduke 1322910Scoleenp iostate exceptions() const; 1333648Sminqi void exceptions(iostate except); 1340Sduke 1352910Scoleenp // 27.5.4.1 Constructor/destructor: 1360Sduke explicit basic_ios(basic_streambuf<charT,traits>* sb); 1370Sduke virtual ~basic_ios(); 1380Sduke 1390Sduke // 27.5.4.2 Members: 1400Sduke basic_ostream<charT,traits>* tie() const; 1410Sduke basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr); 1420Sduke 1430Sduke basic_streambuf<charT,traits>* rdbuf() const; 1440Sduke basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb); 1450Sduke 1460Sduke basic_ios& copyfmt(const basic_ios& rhs); 1470Sduke 1480Sduke char_type fill() const; 1490Sduke char_type fill(char_type ch); 1500Sduke 1510Sduke locale imbue(const locale& loc); 1520Sduke 1530Sduke char narrow(char_type c, char dfault) const; 1540Sduke char_type widen(char c) const; 1550Sduke 1560Sduke basic_ios(const basic_ios& ) = delete; 1570Sduke basic_ios& operator=(const basic_ios&) = delete; 1580Sduke 1590Sdukeprotected: 1600Sduke basic_ios(); 1610Sduke void init(basic_streambuf<charT,traits>* sb); 1620Sduke void move(basic_ios& rhs); 1630Sduke void swap(basic_ios& rhs) noexcept; 1640Sduke void set_rdbuf(basic_streambuf<charT, traits>* sb); 1650Sduke}; 1660Sduke 1670Sduke// 27.5.5, manipulators: 1682910Scoleenpios_base& boolalpha (ios_base& str); 1692910Scoleenpios_base& noboolalpha(ios_base& str); 1702910Scoleenpios_base& showbase (ios_base& str); 1713648Sminqiios_base& noshowbase (ios_base& str); 1722910Scoleenpios_base& showpoint (ios_base& str); 1732910Scoleenpios_base& noshowpoint(ios_base& str); 1742910Scoleenpios_base& showpos (ios_base& str); 1752910Scoleenpios_base& noshowpos (ios_base& str); 1762910Scoleenpios_base& skipws (ios_base& str); 1772910Scoleenpios_base& noskipws (ios_base& str); 1782910Scoleenpios_base& uppercase (ios_base& str); 1792910Scoleenpios_base& nouppercase(ios_base& str); 1802910Scoleenpios_base& unitbuf (ios_base& str); 1812910Scoleenpios_base& nounitbuf (ios_base& str); 1822910Scoleenp 1832910Scoleenp// 27.5.5.2 adjustfield: 1842910Scoleenpios_base& internal (ios_base& str); 1853648Sminqiios_base& left (ios_base& str); 1863648Sminqiios_base& right (ios_base& str); 1873648Sminqi 1883648Sminqi// 27.5.5.3 basefield: 1893648Sminqiios_base& dec (ios_base& str); 1903648Sminqiios_base& hex (ios_base& str); 1913648Sminqiios_base& oct (ios_base& str); 1923648Sminqi 1933648Sminqi// 27.5.5.4 floatfield: 1943648Sminqiios_base& fixed (ios_base& str); 1953648Sminqiios_base& scientific (ios_base& str); 1963648Sminqiios_base& hexfloat (ios_base& str); 1973648Sminqiios_base& defaultfloat(ios_base& str); 1983648Sminqi 1993648Sminqi// 27.5.5.5 error reporting: 2003648Sminqienum class io_errc 2013648Sminqi{ 2023648Sminqi stream = 1 2033648Sminqi}; 2043648Sminqi 2053648Sminqiconcept_map ErrorCodeEnum<io_errc> { }; 2063648Sminqierror_code make_error_code(io_errc e); 2073648Sminqierror_condition make_error_condition(io_errc e); 2083648Sminqistorage-class-specifier const error_category& iostream_category; 2093648Sminqi 2102910Scoleenp} // std 2112910Scoleenp 2120Sduke*/ 2133482Sjiangli 2143482Sjiangli#include <__config> 2150Sduke#include <iosfwd> 2160Sduke#include <__locale> 2170Sduke#include <system_error> 2180Sduke 2190Sduke#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2203482Sjiangli#pragma GCC system_header 2210Sduke#endif 2220Sduke 2230Sduke_LIBCPP_BEGIN_NAMESPACE_STD 2240Sduke 2250Sduketypedef ptrdiff_t streamsize; 2263835Ssspitsyn 2270Sdukeclass _LIBCPP_VISIBLE ios_base 2280Sduke{ 2290Sdukepublic: 2303482Sjiangli class _LIBCPP_VISIBLE failure; 2313482Sjiangli 2323482Sjiangli typedef unsigned int fmtflags; 2333482Sjiangli static const fmtflags boolalpha = 0x0001; 2343482Sjiangli static const fmtflags dec = 0x0002; 2353482Sjiangli static const fmtflags fixed = 0x0004; 2360Sduke static const fmtflags hex = 0x0008; 2370Sduke static const fmtflags internal = 0x0010; 2380Sduke static const fmtflags left = 0x0020; 2390Sduke static const fmtflags oct = 0x0040; 2400Sduke static const fmtflags right = 0x0080; 2410Sduke static const fmtflags scientific = 0x0100; 2420Sduke static const fmtflags showbase = 0x0200; 2430Sduke static const fmtflags showpoint = 0x0400; 2442910Scoleenp static const fmtflags showpos = 0x0800; 2452910Scoleenp static const fmtflags skipws = 0x1000; 2462910Scoleenp static const fmtflags unitbuf = 0x2000; 2473648Sminqi static const fmtflags uppercase = 0x4000; 2483648Sminqi static const fmtflags adjustfield = left | right | internal; 2493648Sminqi static const fmtflags basefield = dec | oct | hex; 2500Sduke static const fmtflags floatfield = scientific | fixed; 2510Sduke 2520Sduke typedef unsigned int iostate; 2530Sduke typedef iostate io_state; 2540Sduke static const iostate badbit = 0x1; 2550Sduke static const iostate eofbit = 0x2; 2560Sduke static const iostate failbit = 0x4; 2570Sduke static const iostate goodbit = 0x0; 2580Sduke 2593602Scoleenp typedef unsigned int openmode; 2600Sduke typedef openmode open_mode; 2610Sduke static const openmode app = 0x01; 2620Sduke static const openmode ate = 0x02; 2630Sduke static const openmode binary = 0x04; 2640Sduke static const openmode in = 0x08; 2650Sduke static const openmode out = 0x10; 2660Sduke static const openmode trunc = 0x20; 2670Sduke 2680Sduke enum seekdir {beg, cur, end}; 2690Sduke typedef seekdir seek_dir; 2700Sduke 2710Sduke typedef _VSTD::streamoff streamoff; 2720Sduke typedef _VSTD::streampos streampos; 2730Sduke 2740Sduke class _LIBCPP_VISIBLE Init; 2750Sduke 2760Sduke // 27.5.2.2 fmtflags state: 2770Sduke _LIBCPP_INLINE_VISIBILITY fmtflags flags() const; 2780Sduke _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl); 2790Sduke _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl); 2800Sduke _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask); 28112953Scoleenp _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask); 2820Sduke 2830Sduke _LIBCPP_INLINE_VISIBILITY streamsize precision() const; 2840Sduke _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec); 28512953Scoleenp _LIBCPP_INLINE_VISIBILITY streamsize width() const; 2860Sduke _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide); 2870Sduke 2880Sduke // 27.5.2.3 locales: 2890Sduke locale imbue(const locale& __loc); 2900Sduke locale getloc() const; 2910Sduke 2923471Sfparain // 27.5.2.5 storage: 2930Sduke static int xalloc(); 2940Sduke long& iword(int __index); 29512953Scoleenp void*& pword(int __index); 2960Sduke 2970Sduke // destructor 29812953Scoleenp virtual ~ios_base(); 2993471Sfparain 30012953Scoleenp // 27.5.2.6 callbacks; 3013471Sfparain enum event { erase_event, imbue_event, copyfmt_event }; 3023471Sfparain typedef void (*event_callback)(event, ios_base&, int __index); 3033471Sfparain void register_callback(event_callback __fn, int __index); 3040Sduke 3050Sdukeprivate: 3060Sduke ios_base(const ios_base&); // = delete; 3070Sduke ios_base& operator=(const ios_base&); // = delete; 3080Sduke 3090Sdukepublic: 3100Sduke static bool sync_with_stdio(bool __sync = true); 3110Sduke 3120Sduke _LIBCPP_INLINE_VISIBILITY iostate rdstate() const; 3130Sduke void clear(iostate __state = goodbit); 3140Sduke _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state); 3150Sduke 3160Sduke _LIBCPP_INLINE_VISIBILITY bool good() const; 3170Sduke _LIBCPP_INLINE_VISIBILITY bool eof() const; 3180Sduke _LIBCPP_INLINE_VISIBILITY bool fail() const; 3190Sduke _LIBCPP_INLINE_VISIBILITY bool bad() const; 32012953Scoleenp 3213235Sjiangli _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; 3220Sduke _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __except); 3230Sduke 3240Sduke void __set_badbit_and_consider_rethrow(); 3250Sduke void __set_failbit_and_consider_rethrow(); 3260Sduke 3270Sdukeprotected: 3280Sduke _LIBCPP_INLINE_VISIBILITY 3290Sduke ios_base() {// purposefully does no initialization 3300Sduke } 3310Sduke 3323602Scoleenp void init(void* __sb); 3330Sduke _LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;} 3340Sduke 3350Sduke _LIBCPP_ALWAYS_INLINE 3363602Scoleenp void rdbuf(void* __sb) 3370Sduke { 3380Sduke __rdbuf_ = __sb; 3394623Ssla clear(); 3404623Ssla } 3414623Ssla 3424623Ssla void __call_callbacks(event); 3434623Ssla void copyfmt(const ios_base&); 3444623Ssla void move(ios_base&); 3454623Ssla void swap(ios_base&) _NOEXCEPT; 3464623Ssla 3474623Ssla _LIBCPP_ALWAYS_INLINE 3484625Ssla void set_rdbuf(void* __sb) 3494623Ssla { 3504623Ssla __rdbuf_ = __sb; 3514623Ssla } 3524623Ssla 3534623Sslaprivate: 3544625Ssla // All data members must be scalars 3554623Ssla fmtflags __fmtflags_; 3564623Ssla streamsize __precision_; 3574623Ssla streamsize __width_; 3584623Ssla iostate __rdstate_; 3594623Ssla iostate __exceptions_; 3604623Ssla void* __rdbuf_; 3614623Ssla void* __loc_; 3624623Ssla event_callback* __fn_; 3634623Ssla int* __index_; 3644623Ssla size_t __event_size_; 3654623Ssla size_t __event_cap_; 3664623Ssla static int __xindex_; 3674623Ssla long* __iarray_; 3684623Ssla size_t __iarray_size_; 3694623Ssla size_t __iarray_cap_; 3704623Ssla void** __parray_; 3714623Ssla size_t __parray_size_; 3724623Ssla size_t __parray_cap_; 3734623Ssla}; 3744623Ssla 3754623Ssla//enum class io_errc 3764623Ssla_LIBCPP_DECLARE_STRONG_ENUM(io_errc) 3770Sduke{ 3780Sduke stream = 1 3790Sduke}; 3800Sduke_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) 3810Sduke 3820Sduketemplate <> 3830Sdukestruct _LIBCPP_VISIBLE is_error_code_enum<io_errc> : public true_type { }; 3840Sduke 3850Sduke#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS 3860Sduketemplate <> 3870Sdukestruct _LIBCPP_VISIBLE is_error_code_enum<io_errc::__lx> : public true_type { }; 3880Sduke#endif 3890Sduke 39012953Scoleenp_LIBCPP_VISIBLE 3913235Sjiangliconst error_category& iostream_category(); 3920Sduke 3933602Scoleenpinline _LIBCPP_INLINE_VISIBILITY 3940Sdukeerror_code 3950Sdukemake_error_code(io_errc __e) 3960Sduke{ 3970Sduke return error_code(static_cast<int>(__e), iostream_category()); 3980Sduke} 3993235Sjiangli 4003235Sjiangliinline _LIBCPP_INLINE_VISIBILITY 4013235Sjianglierror_condition 4023235Sjianglimake_error_condition(io_errc __e) 4033235Sjiangli{ 4040Sduke return error_condition(static_cast<int>(__e), iostream_category()); 4050Sduke} 4060Sduke 4070Sdukeclass _LIBCPP_EXCEPTION_ABI ios_base::failure 4080Sduke : public system_error 4090Sduke{ 4100Sdukepublic: 4110Sduke explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); 4120Sduke explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); 4130Sduke virtual ~failure() throw(); 4140Sduke}; 4150Sduke 4160Sdukeclass _LIBCPP_VISIBLE ios_base::Init 4170Sduke{ 4189248Scoleenppublic: 4190Sduke Init(); 4200Sduke ~Init(); 4210Sduke}; 4220Sduke 4230Sduke// fmtflags 4240Sduke 4250Sdukeinline _LIBCPP_INLINE_VISIBILITY 4260Sdukeios_base::fmtflags 4270Sdukeios_base::flags() const 4280Sduke{ 4290Sduke return __fmtflags_; 4300Sduke} 4310Sduke 4320Sdukeinline _LIBCPP_INLINE_VISIBILITY 4330Sdukeios_base::fmtflags 4340Sdukeios_base::flags(fmtflags __fmtfl) 4350Sduke{ 4360Sduke fmtflags __r = __fmtflags_; 4370Sduke __fmtflags_ = __fmtfl; 4389248Scoleenp return __r; 4390Sduke} 4400Sduke 4410Sdukeinline _LIBCPP_INLINE_VISIBILITY 4420Sdukeios_base::fmtflags 4430Sdukeios_base::setf(fmtflags __fmtfl) 4440Sduke{ 4450Sduke fmtflags __r = __fmtflags_; 4460Sduke __fmtflags_ |= __fmtfl; 4470Sduke return __r; 4480Sduke} 4490Sduke 4500Sdukeinline _LIBCPP_INLINE_VISIBILITY 4510Sdukevoid 4523648Sminqiios_base::unsetf(fmtflags __mask) 4532910Scoleenp{ 4542910Scoleenp __fmtflags_ &= ~__mask; 4552910Scoleenp} 4562910Scoleenp 4572910Scoleenpinline _LIBCPP_INLINE_VISIBILITY 4582910Scoleenpios_base::fmtflags 4592910Scoleenpios_base::setf(fmtflags __fmtfl, fmtflags __mask) 4602910Scoleenp{ 4612910Scoleenp fmtflags __r = __fmtflags_; 4622910Scoleenp unsetf(__mask); 4632910Scoleenp __fmtflags_ |= __fmtfl & __mask; 4649248Scoleenp return __r; 4652910Scoleenp} 4662910Scoleenp 4672910Scoleenp// precision 4682910Scoleenp 4692910Scoleenpinline _LIBCPP_INLINE_VISIBILITY 4702910Scoleenpstreamsize 4712910Scoleenpios_base::precision() const 4722910Scoleenp{ 4732910Scoleenp return __precision_; 4742910Scoleenp} 4752910Scoleenp 4762910Scoleenpinline _LIBCPP_INLINE_VISIBILITY 4772910Scoleenpstreamsize 4782910Scoleenpios_base::precision(streamsize __prec) 4792910Scoleenp{ 4802910Scoleenp streamsize __r = __precision_; 4812910Scoleenp __precision_ = __prec; 4823648Sminqi return __r; 4833648Sminqi} 4843648Sminqi 4853648Sminqi// width 4863648Sminqi 4873648Sminqiinline _LIBCPP_INLINE_VISIBILITY 4883648Sminqistreamsize 4893648Sminqiios_base::width() const 4903648Sminqi{ 4913648Sminqi return __width_; 4923648Sminqi} 4933648Sminqi 4949248Scoleenpinline _LIBCPP_INLINE_VISIBILITY 4953648Sminqistreamsize 4963648Sminqiios_base::width(streamsize __wide) 4973648Sminqi{ 4983648Sminqi streamsize __r = __width_; 4993648Sminqi __width_ = __wide; 5003648Sminqi return __r; 5013648Sminqi} 5023648Sminqi 5033648Sminqi// iostate 5043648Sminqi 5053648Sminqiinline _LIBCPP_INLINE_VISIBILITY 5063648Sminqiios_base::iostate 5073648Sminqiios_base::rdstate() const 5083648Sminqi{ 5093648Sminqi return __rdstate_; 5103648Sminqi} 5113648Sminqi 5123648Sminqiinline _LIBCPP_INLINE_VISIBILITY 5133648Sminqivoid 5143648Sminqiios_base::setstate(iostate __state) 5150Sduke{ 5160Sduke clear(__rdstate_ | __state); 5170Sduke} 5180Sduke 5190Sdukeinline _LIBCPP_INLINE_VISIBILITY 5200Sdukebool 5210Sdukeios_base::good() const 5229248Scoleenp{ 5230Sduke return __rdstate_ == 0; 5240Sduke} 5250Sduke 5260Sdukeinline _LIBCPP_INLINE_VISIBILITY 5270Sdukebool 5280Sdukeios_base::eof() const 5293602Scoleenp{ 5300Sduke return __rdstate_ & eofbit; 5310Sduke} 5320Sduke 5330Sdukeinline _LIBCPP_INLINE_VISIBILITY 5340Sdukebool 5350Sdukeios_base::fail() const 5360Sduke{ 5370Sduke return __rdstate_ & (failbit | badbit); 5380Sduke} 5390Sduke 5400Sdukeinline _LIBCPP_INLINE_VISIBILITY 5419248Scoleenpbool 5420Sdukeios_base::bad() const 5433602Scoleenp{ 5440Sduke return __rdstate_ & badbit; 5453602Scoleenp} 5463602Scoleenp 5473602Scoleenpinline _LIBCPP_INLINE_VISIBILITY 5487261Saerikssoios_base::iostate 5490Sdukeios_base::exceptions() const 5504610Ssla{ 5514610Ssla return __exceptions_; 5524610Ssla} 5534610Ssla 5544610Sslainline _LIBCPP_INLINE_VISIBILITY 5550Sdukevoid 5560Sdukeios_base::exceptions(iostate __except) 5570Sduke{ 5580Sduke __exceptions_ = __except; 5590Sduke clear(__rdstate_); 5600Sduke} 5610Sduke 5620Sduketemplate <class _CharT, class _Traits> 5630Sdukeclass _LIBCPP_VISIBLE basic_ios 5640Sduke : public ios_base 5650Sduke{ 5660Sdukepublic: 5670Sduke // types: 5683602Scoleenp typedef _CharT char_type; 5690Sduke typedef _Traits traits_type; 5700Sduke 5710Sduke typedef typename traits_type::int_type int_type; 5720Sduke typedef typename traits_type::pos_type pos_type; 5730Sduke typedef typename traits_type::off_type off_type; 5740Sduke 5750Sduke _LIBCPP_ALWAYS_INLINE 5760Sduke _LIBCPP_EXPLICIT 5770Sduke operator bool() const {return !fail();} 5783602Scoleenp _LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();} 5790Sduke _LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();} 5800Sduke _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);} 5813602Scoleenp _LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);} 5820Sduke _LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();} 5830Sduke _LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();} 5847261Saeriksso _LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();} 5857261Saeriksso _LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();} 5867261Saeriksso 5870Sduke _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();} 5880Sduke _LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);} 5890Sduke 5900Sduke // 27.5.4.1 Constructor/destructor: 5910Sduke _LIBCPP_INLINE_VISIBILITY 5920Sduke explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb); 5930Sduke virtual ~basic_ios(); 5940Sduke 5953602Scoleenp // 27.5.4.2 Members: 5960Sduke _LIBCPP_INLINE_VISIBILITY 5970Sduke basic_ostream<char_type, traits_type>* tie() const; 5980Sduke _LIBCPP_INLINE_VISIBILITY 5990Sduke basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr); 6000Sduke 6010Sduke _LIBCPP_INLINE_VISIBILITY 6020Sduke basic_streambuf<char_type, traits_type>* rdbuf() const; 6030Sduke _LIBCPP_INLINE_VISIBILITY 6040Sduke basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb); 6053602Scoleenp 6060Sduke basic_ios& copyfmt(const basic_ios& __rhs); 6070Sduke 6083602Scoleenp _LIBCPP_INLINE_VISIBILITY 6090Sduke char_type fill() const; 6100Sduke _LIBCPP_INLINE_VISIBILITY 6117261Saeriksso char_type fill(char_type __ch); 6127261Saeriksso 6137261Saeriksso _LIBCPP_INLINE_VISIBILITY 6140Sduke locale imbue(const locale& __loc); 6150Sduke 6160Sduke _LIBCPP_INLINE_VISIBILITY 6170Sduke char narrow(char_type __c, char __dfault) const; 6180Sduke _LIBCPP_INLINE_VISIBILITY 6190Sduke char_type widen(char __c) const; 6200Sduke 62112953Scoleenpprotected: 62212953Scoleenp _LIBCPP_ALWAYS_INLINE 62312953Scoleenp basic_ios() {// purposefully does no initialization 6240Sduke } 6250Sduke _LIBCPP_INLINE_VISIBILITY 6262062Scoleenp void init(basic_streambuf<char_type, traits_type>* __sb); 6270Sduke 6280Sduke _LIBCPP_INLINE_VISIBILITY 62912953Scoleenp void move(basic_ios& __rhs); 6300Sduke#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 6310Sduke _LIBCPP_ALWAYS_INLINE 63212953Scoleenp void move(basic_ios&& __rhs) {move(__rhs);} 6330Sduke#endif 6340Sduke _LIBCPP_INLINE_VISIBILITY 6350Sduke void swap(basic_ios& __rhs) _NOEXCEPT; 6360Sduke _LIBCPP_INLINE_VISIBILITY 6370Sduke void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb); 6383602Scoleenpprivate: 6390Sduke basic_ostream<char_type, traits_type>* __tie_; 6400Sduke mutable int_type __fill_; 6417261Saeriksso}; 6427261Saeriksso 6437261Saerikssotemplate <class _CharT, class _Traits> 6444623Sslainline _LIBCPP_INLINE_VISIBILITY 6454623Sslabasic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb) 6464623Ssla{ 6470Sduke init(__sb); 6480Sduke} 6490Sduke 6502062Scoleenptemplate <class _CharT, class _Traits> 6512062Scoleenpbasic_ios<_CharT, _Traits>::~basic_ios() 6520Sduke{ 65312953Scoleenp} 6540Sduke 6550Sduketemplate <class _CharT, class _Traits> 65612953Scoleenpinline _LIBCPP_INLINE_VISIBILITY 6570Sdukevoid 6580Sdukebasic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) 6590Sduke{ 6600Sduke ios_base::init(__sb); 6610Sduke __tie_ = 0; 6623602Scoleenp __fill_ = traits_type::eof(); 6630Sduke} 6640Sduke 6657261Saerikssotemplate <class _CharT, class _Traits> 6667261Saerikssoinline _LIBCPP_INLINE_VISIBILITY 6677261Saerikssobasic_ostream<_CharT, _Traits>* 6684623Sslabasic_ios<_CharT, _Traits>::tie() const 6694625Ssla{ 6704623Ssla return __tie_; 6710Sduke} 6720Sduke 6730Sduketemplate <class _CharT, class _Traits> 6740Sdukeinline _LIBCPP_INLINE_VISIBILITY 6750Sdukebasic_ostream<_CharT, _Traits>* 6760Sdukebasic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) 6770Sduke{ 67812953Scoleenp basic_ostream<char_type, traits_type>* __r = __tie_; 6790Sduke __tie_ = __tiestr; 6804610Ssla return __r; 6810Sduke} 6824610Ssla 6834610Sslatemplate <class _CharT, class _Traits> 6844610Sslainline _LIBCPP_INLINE_VISIBILITY 6854610Sslabasic_streambuf<_CharT, _Traits>* 6864610Sslabasic_ios<_CharT, _Traits>::rdbuf() const 6874610Ssla{ 6884610Ssla return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf()); 6894610Ssla} 6904610Ssla 6914610Sslatemplate <class _CharT, class _Traits> 6924610Sslainline _LIBCPP_INLINE_VISIBILITY 6930Sdukebasic_streambuf<_CharT, _Traits>* 6940Sdukebasic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) 6950Sduke{ 69610977Sfzhinkin basic_streambuf<char_type, traits_type>* __r = rdbuf(); 6970Sduke ios_base::rdbuf(__sb); 6980Sduke return __r; 6990Sduke} 70012953Scoleenp 7010Sduketemplate <class _CharT, class _Traits> 7020Sdukeinline _LIBCPP_INLINE_VISIBILITY 7033602Scoleenplocale 7040Sdukebasic_ios<_CharT, _Traits>::imbue(const locale& __loc) 7050Sduke{ 7060Sduke locale __r = getloc(); 7070Sduke ios_base::imbue(__loc); 7083602Scoleenp if (rdbuf()) 7093602Scoleenp rdbuf()->pubimbue(__loc); 7100Sduke return __r; 7110Sduke} 7120Sduke 7130Sduketemplate <class _CharT, class _Traits> 7140Sdukeinline _LIBCPP_INLINE_VISIBILITY 7153602Scoleenpchar 7160Sdukebasic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const 7170Sduke{ 7180Sduke return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault); 7190Sduke} 7200Sduke 7210Sduketemplate <class _CharT, class _Traits> 7220Sdukeinline _LIBCPP_INLINE_VISIBILITY 7230Sduke_CharT 7240Sdukebasic_ios<_CharT, _Traits>::widen(char __c) const 7250Sduke{ 7260Sduke return use_facet<ctype<char_type> >(getloc()).widen(__c); 7270Sduke} 7280Sduke 7290Sduketemplate <class _CharT, class _Traits> 73012953Scoleenpinline _LIBCPP_INLINE_VISIBILITY 73112953Scoleenp_CharT 7320Sdukebasic_ios<_CharT, _Traits>::fill() const 7330Sduke{ 7340Sduke if (traits_type::eq_int_type(traits_type::eof(), __fill_)) 7350Sduke __fill_ = widen(' '); 7360Sduke return __fill_; 7370Sduke} 7380Sduke 7390Sduketemplate <class _CharT, class _Traits> 74012953Scoleenpinline _LIBCPP_INLINE_VISIBILITY 7410Sduke_CharT 7420Sdukebasic_ios<_CharT, _Traits>::fill(char_type __ch) 7430Sduke{ 74412953Scoleenp char_type __r = __fill_; 74512953Scoleenp __fill_ = __ch; 7460Sduke return __r; 7473602Scoleenp} 7480Sduke 7490Sduketemplate <class _CharT, class _Traits> 7500Sdukebasic_ios<_CharT, _Traits>& 75112953Scoleenpbasic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) 7520Sduke{ 7530Sduke if (this != &__rhs) 7540Sduke { 7550Sduke __call_callbacks(erase_event); 75612953Scoleenp ios_base::copyfmt(__rhs); 75712953Scoleenp __tie_ = __rhs.__tie_; 7580Sduke __fill_ = __rhs.__fill_; 7590Sduke __call_callbacks(copyfmt_event); 7600Sduke exceptions(__rhs.exceptions()); 7610Sduke } 7620Sduke return *this; 7630Sduke} 7640Sduke 7650Sduketemplate <class _CharT, class _Traits> 7660Sdukeinline _LIBCPP_INLINE_VISIBILITY 7670Sdukevoid 7680Sdukebasic_ios<_CharT, _Traits>::move(basic_ios& __rhs) 7690Sduke{ 7700Sduke ios_base::move(__rhs); 7710Sduke __tie_ = __rhs.__tie_; 7720Sduke __rhs.__tie_ = 0; 7730Sduke __fill_ = __rhs.__fill_; 7740Sduke} 7750Sduke 7760Sduketemplate <class _CharT, class _Traits> 7770Sdukeinline _LIBCPP_INLINE_VISIBILITY 7780Sdukevoid 7790Sdukebasic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT 7800Sduke{ 7810Sduke ios_base::swap(__rhs); 7820Sduke _VSTD::swap(__tie_, __rhs.__tie_); 7830Sduke _VSTD::swap(__fill_, __rhs.__fill_); 7840Sduke} 7850Sduke 7860Sduketemplate <class _CharT, class _Traits> 7870Sdukeinline _LIBCPP_INLINE_VISIBILITY 7880Sdukevoid 7890Sdukebasic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) 7900Sduke{ 7910Sduke ios_base::set_rdbuf(__sb); 7920Sduke} 7932062Scoleenp 7940Sdukeinline _LIBCPP_INLINE_VISIBILITY 7950Sdukeios_base& 7960Sdukeboolalpha(ios_base& __str) 7970Sduke{ 7980Sduke __str.setf(ios_base::boolalpha); 7990Sduke return __str; 8000Sduke} 8010Sduke 8020Sdukeinline _LIBCPP_INLINE_VISIBILITY 8030Sdukeios_base& 8040Sdukenoboolalpha(ios_base& __str) 8050Sduke{ 8060Sduke __str.unsetf(ios_base::boolalpha); 8070Sduke return __str; 8080Sduke} 8090Sduke 8100Sdukeinline _LIBCPP_INLINE_VISIBILITY 8110Sdukeios_base& 8120Sdukeshowbase(ios_base& __str) 8130Sduke{ 8140Sduke __str.setf(ios_base::showbase); 8150Sduke return __str; 8169248Scoleenp} 8170Sduke 8180Sdukeinline _LIBCPP_INLINE_VISIBILITY 8190Sdukeios_base& 8200Sdukenoshowbase(ios_base& __str) 8210Sduke{ 8220Sduke __str.unsetf(ios_base::showbase); 8230Sduke return __str; 8240Sduke} 8253816Scoleenp 8260Sdukeinline _LIBCPP_INLINE_VISIBILITY 8270Sdukeios_base& 8280Sdukeshowpoint(ios_base& __str) 8290Sduke{ 8300Sduke __str.setf(ios_base::showpoint); 8310Sduke return __str; 8320Sduke} 8331485Sjrose 8340Sdukeinline _LIBCPP_INLINE_VISIBILITY 8350Sdukeios_base& 8360Sdukenoshowpoint(ios_base& __str) 8370Sduke{ 8380Sduke __str.unsetf(ios_base::showpoint); 8390Sduke return __str; 8400Sduke} 8410Sduke 8420Sdukeinline _LIBCPP_INLINE_VISIBILITY 8430Sdukeios_base& 8440Sdukeshowpos(ios_base& __str) 8453602Scoleenp{ 8463602Scoleenp __str.setf(ios_base::showpos); 8470Sduke return __str; 8480Sduke} 8490Sduke 8500Sdukeinline _LIBCPP_INLINE_VISIBILITY 8510Sdukeios_base& 8520Sdukenoshowpos(ios_base& __str) 8530Sduke{ 8540Sduke __str.unsetf(ios_base::showpos); 855726Sjrose return __str; 8563602Scoleenp} 8573191Sdsamersoff 8583191Sdsamersoffinline _LIBCPP_INLINE_VISIBILITY 8593191Sdsamersoffios_base& 8600Sdukeskipws(ios_base& __str) 8613191Sdsamersoff{ 862726Sjrose __str.setf(ios_base::skipws); 8636373Sanoll return __str; 8643602Scoleenp} 8653602Scoleenp 866726Sjroseinline _LIBCPP_INLINE_VISIBILITY 8673602Scoleenpios_base& 8683602Scoleenpnoskipws(ios_base& __str) 8690Sduke{ 8703602Scoleenp __str.unsetf(ios_base::skipws); 8713602Scoleenp return __str; 8720Sduke} 8730Sduke 8740Sdukeinline _LIBCPP_INLINE_VISIBILITY 875726Sjroseios_base& 8760Sdukeuppercase(ios_base& __str) 8770Sduke{ 8783602Scoleenp __str.setf(ios_base::uppercase); 8793602Scoleenp return __str; 8803602Scoleenp} 8813602Scoleenp 8823602Scoleenpinline _LIBCPP_INLINE_VISIBILITY 8833602Scoleenpios_base& 8843602Scoleenpnouppercase(ios_base& __str) 8853602Scoleenp{ 8863602Scoleenp __str.unsetf(ios_base::uppercase); 8873602Scoleenp return __str; 8883602Scoleenp} 8893602Scoleenp 8903602Scoleenpinline _LIBCPP_INLINE_VISIBILITY 8913602Scoleenpios_base& 8923602Scoleenpunitbuf(ios_base& __str) 89313254Sjwilhelm{ 89413254Sjwilhelm __str.setf(ios_base::unitbuf); 8953602Scoleenp return __str; 8960Sduke} 8970Sduke 8980Sdukeinline _LIBCPP_INLINE_VISIBILITY 8990Sdukeios_base& 9000Sdukenounitbuf(ios_base& __str) 901{ 902 __str.unsetf(ios_base::unitbuf); 903 return __str; 904} 905 906inline _LIBCPP_INLINE_VISIBILITY 907ios_base& 908internal(ios_base& __str) 909{ 910 __str.setf(ios_base::internal, ios_base::adjustfield); 911 return __str; 912} 913 914inline _LIBCPP_INLINE_VISIBILITY 915ios_base& 916left(ios_base& __str) 917{ 918 __str.setf(ios_base::left, ios_base::adjustfield); 919 return __str; 920} 921 922inline _LIBCPP_INLINE_VISIBILITY 923ios_base& 924right(ios_base& __str) 925{ 926 __str.setf(ios_base::right, ios_base::adjustfield); 927 return __str; 928} 929 930inline _LIBCPP_INLINE_VISIBILITY 931ios_base& 932dec(ios_base& __str) 933{ 934 __str.setf(ios_base::dec, ios_base::basefield); 935 return __str; 936} 937 938inline _LIBCPP_INLINE_VISIBILITY 939ios_base& 940hex(ios_base& __str) 941{ 942 __str.setf(ios_base::hex, ios_base::basefield); 943 return __str; 944} 945 946inline _LIBCPP_INLINE_VISIBILITY 947ios_base& 948oct(ios_base& __str) 949{ 950 __str.setf(ios_base::oct, ios_base::basefield); 951 return __str; 952} 953 954inline _LIBCPP_INLINE_VISIBILITY 955ios_base& 956fixed(ios_base& __str) 957{ 958 __str.setf(ios_base::fixed, ios_base::floatfield); 959 return __str; 960} 961 962inline _LIBCPP_INLINE_VISIBILITY 963ios_base& 964scientific(ios_base& __str) 965{ 966 __str.setf(ios_base::scientific, ios_base::floatfield); 967 return __str; 968} 969 970inline _LIBCPP_INLINE_VISIBILITY 971ios_base& 972hexfloat(ios_base& __str) 973{ 974 __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); 975 return __str; 976} 977 978inline _LIBCPP_INLINE_VISIBILITY 979ios_base& 980defaultfloat(ios_base& __str) 981{ 982 __str.unsetf(ios_base::floatfield); 983 return __str; 984} 985 986_LIBCPP_END_NAMESPACE_STD 987 988#endif // _LIBCPP_IOS 989