17a984708SDavid Chisnall// -*- C++ -*- 27a984708SDavid Chisnall//===---------------------------- ios -------------------------------------===// 37a984708SDavid Chisnall// 47a984708SDavid Chisnall// The LLVM Compiler Infrastructure 57a984708SDavid Chisnall// 67a984708SDavid Chisnall// This file is dual licensed under the MIT and the University of Illinois Open 77a984708SDavid Chisnall// Source Licenses. See LICENSE.TXT for details. 87a984708SDavid Chisnall// 97a984708SDavid Chisnall//===----------------------------------------------------------------------===// 107a984708SDavid Chisnall 117a984708SDavid Chisnall#ifndef _LIBCPP_IOS 127a984708SDavid Chisnall#define _LIBCPP_IOS 137a984708SDavid Chisnall 147a984708SDavid Chisnall/* 157a984708SDavid Chisnall ios synopsis 167a984708SDavid Chisnall 177a984708SDavid Chisnall#include <iosfwd> 187a984708SDavid Chisnall 197a984708SDavid Chisnallnamespace std 207a984708SDavid Chisnall{ 217a984708SDavid Chisnall 227a984708SDavid Chisnalltypedef OFF_T streamoff; 237a984708SDavid Chisnalltypedef SZ_T streamsize; 247a984708SDavid Chisnalltemplate <class stateT> class fpos; 257a984708SDavid Chisnall 267a984708SDavid Chisnallclass ios_base 277a984708SDavid Chisnall{ 287a984708SDavid Chisnallpublic: 297a984708SDavid Chisnall class failure; 307a984708SDavid Chisnall 317a984708SDavid Chisnall typedef T1 fmtflags; 32936e9439SDimitry Andric static constexpr fmtflags boolalpha; 33936e9439SDimitry Andric static constexpr fmtflags dec; 34936e9439SDimitry Andric static constexpr fmtflags fixed; 35936e9439SDimitry Andric static constexpr fmtflags hex; 36936e9439SDimitry Andric static constexpr fmtflags internal; 37936e9439SDimitry Andric static constexpr fmtflags left; 38936e9439SDimitry Andric static constexpr fmtflags oct; 39936e9439SDimitry Andric static constexpr fmtflags right; 40936e9439SDimitry Andric static constexpr fmtflags scientific; 41936e9439SDimitry Andric static constexpr fmtflags showbase; 42936e9439SDimitry Andric static constexpr fmtflags showpoint; 43936e9439SDimitry Andric static constexpr fmtflags showpos; 44936e9439SDimitry Andric static constexpr fmtflags skipws; 45936e9439SDimitry Andric static constexpr fmtflags unitbuf; 46936e9439SDimitry Andric static constexpr fmtflags uppercase; 47936e9439SDimitry Andric static constexpr fmtflags adjustfield; 48936e9439SDimitry Andric static constexpr fmtflags basefield; 49936e9439SDimitry Andric static constexpr fmtflags floatfield; 507a984708SDavid Chisnall 517a984708SDavid Chisnall typedef T2 iostate; 52936e9439SDimitry Andric static constexpr iostate badbit; 53936e9439SDimitry Andric static constexpr iostate eofbit; 54936e9439SDimitry Andric static constexpr iostate failbit; 55936e9439SDimitry Andric static constexpr iostate goodbit; 567a984708SDavid Chisnall 577a984708SDavid Chisnall typedef T3 openmode; 58936e9439SDimitry Andric static constexpr openmode app; 59936e9439SDimitry Andric static constexpr openmode ate; 60936e9439SDimitry Andric static constexpr openmode binary; 61936e9439SDimitry Andric static constexpr openmode in; 62936e9439SDimitry Andric static constexpr openmode out; 63936e9439SDimitry Andric static constexpr openmode trunc; 647a984708SDavid Chisnall 657a984708SDavid Chisnall typedef T4 seekdir; 66936e9439SDimitry Andric static constexpr seekdir beg; 67936e9439SDimitry Andric static constexpr seekdir cur; 68936e9439SDimitry Andric static constexpr seekdir end; 697a984708SDavid Chisnall 707a984708SDavid Chisnall class Init; 717a984708SDavid Chisnall 727a984708SDavid Chisnall // 27.5.2.2 fmtflags state: 737a984708SDavid Chisnall fmtflags flags() const; 747a984708SDavid Chisnall fmtflags flags(fmtflags fmtfl); 757a984708SDavid Chisnall fmtflags setf(fmtflags fmtfl); 767a984708SDavid Chisnall fmtflags setf(fmtflags fmtfl, fmtflags mask); 777a984708SDavid Chisnall void unsetf(fmtflags mask); 787a984708SDavid Chisnall 797a984708SDavid Chisnall streamsize precision() const; 807a984708SDavid Chisnall streamsize precision(streamsize prec); 817a984708SDavid Chisnall streamsize width() const; 827a984708SDavid Chisnall streamsize width(streamsize wide); 837a984708SDavid Chisnall 847a984708SDavid Chisnall // 27.5.2.3 locales: 857a984708SDavid Chisnall locale imbue(const locale& loc); 867a984708SDavid Chisnall locale getloc() const; 877a984708SDavid Chisnall 887a984708SDavid Chisnall // 27.5.2.5 storage: 897a984708SDavid Chisnall static int xalloc(); 907a984708SDavid Chisnall long& iword(int index); 917a984708SDavid Chisnall void*& pword(int index); 927a984708SDavid Chisnall 937a984708SDavid Chisnall // destructor 947a984708SDavid Chisnall virtual ~ios_base(); 957a984708SDavid Chisnall 967a984708SDavid Chisnall // 27.5.2.6 callbacks; 977a984708SDavid Chisnall enum event { erase_event, imbue_event, copyfmt_event }; 987a984708SDavid Chisnall typedef void (*event_callback)(event, ios_base&, int index); 997a984708SDavid Chisnall void register_callback(event_callback fn, int index); 1007a984708SDavid Chisnall 1017a984708SDavid Chisnall ios_base(const ios_base&) = delete; 1027a984708SDavid Chisnall ios_base& operator=(const ios_base&) = delete; 1037a984708SDavid Chisnall 1047a984708SDavid Chisnall static bool sync_with_stdio(bool sync = true); 1057a984708SDavid Chisnall 1067a984708SDavid Chisnallprotected: 1077a984708SDavid Chisnall ios_base(); 1087a984708SDavid Chisnall}; 1097a984708SDavid Chisnall 1107a984708SDavid Chisnalltemplate <class charT, class traits = char_traits<charT> > 1117a984708SDavid Chisnallclass basic_ios 1127a984708SDavid Chisnall : public ios_base 1137a984708SDavid Chisnall{ 1147a984708SDavid Chisnallpublic: 1157a984708SDavid Chisnall // types: 1167a984708SDavid Chisnall typedef charT char_type; 1179729cf09SDimitry Andric typedef typename traits::int_type int_type; // removed in C++17 1189729cf09SDimitry Andric typedef typename traits::pos_type pos_type; // removed in C++17 1199729cf09SDimitry Andric typedef typename traits::off_type off_type; // removed in C++17 1207a984708SDavid Chisnall typedef traits traits_type; 1217a984708SDavid Chisnall 1227a984708SDavid Chisnall operator unspecified-bool-type() const; 1237a984708SDavid Chisnall bool operator!() const; 1247a984708SDavid Chisnall iostate rdstate() const; 1257a984708SDavid Chisnall void clear(iostate state = goodbit); 1267a984708SDavid Chisnall void setstate(iostate state); 1277a984708SDavid Chisnall bool good() const; 1287a984708SDavid Chisnall bool eof() const; 1297a984708SDavid Chisnall bool fail() const; 1307a984708SDavid Chisnall bool bad() const; 1317a984708SDavid Chisnall 1327a984708SDavid Chisnall iostate exceptions() const; 1337a984708SDavid Chisnall void exceptions(iostate except); 1347a984708SDavid Chisnall 1357a984708SDavid Chisnall // 27.5.4.1 Constructor/destructor: 1367a984708SDavid Chisnall explicit basic_ios(basic_streambuf<charT,traits>* sb); 1377a984708SDavid Chisnall virtual ~basic_ios(); 1387a984708SDavid Chisnall 1397a984708SDavid Chisnall // 27.5.4.2 Members: 1407a984708SDavid Chisnall basic_ostream<charT,traits>* tie() const; 1417a984708SDavid Chisnall basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr); 1427a984708SDavid Chisnall 1437a984708SDavid Chisnall basic_streambuf<charT,traits>* rdbuf() const; 1447a984708SDavid Chisnall basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb); 1457a984708SDavid Chisnall 1467a984708SDavid Chisnall basic_ios& copyfmt(const basic_ios& rhs); 1477a984708SDavid Chisnall 1487a984708SDavid Chisnall char_type fill() const; 1497a984708SDavid Chisnall char_type fill(char_type ch); 1507a984708SDavid Chisnall 1517a984708SDavid Chisnall locale imbue(const locale& loc); 1527a984708SDavid Chisnall 1537a984708SDavid Chisnall char narrow(char_type c, char dfault) const; 1547a984708SDavid Chisnall char_type widen(char c) const; 1557a984708SDavid Chisnall 1567a984708SDavid Chisnall basic_ios(const basic_ios& ) = delete; 1577a984708SDavid Chisnall basic_ios& operator=(const basic_ios&) = delete; 1587a984708SDavid Chisnall 1597a984708SDavid Chisnallprotected: 1607a984708SDavid Chisnall basic_ios(); 1617a984708SDavid Chisnall void init(basic_streambuf<charT,traits>* sb); 1627a984708SDavid Chisnall void move(basic_ios& rhs); 163936e9439SDimitry Andric void swap(basic_ios& rhs) noexcept; 1647a984708SDavid Chisnall void set_rdbuf(basic_streambuf<charT, traits>* sb); 1657a984708SDavid Chisnall}; 1667a984708SDavid Chisnall 1677a984708SDavid Chisnall// 27.5.5, manipulators: 1687a984708SDavid Chisnallios_base& boolalpha (ios_base& str); 1697a984708SDavid Chisnallios_base& noboolalpha(ios_base& str); 1707a984708SDavid Chisnallios_base& showbase (ios_base& str); 1717a984708SDavid Chisnallios_base& noshowbase (ios_base& str); 1727a984708SDavid Chisnallios_base& showpoint (ios_base& str); 1737a984708SDavid Chisnallios_base& noshowpoint(ios_base& str); 1747a984708SDavid Chisnallios_base& showpos (ios_base& str); 1757a984708SDavid Chisnallios_base& noshowpos (ios_base& str); 1767a984708SDavid Chisnallios_base& skipws (ios_base& str); 1777a984708SDavid Chisnallios_base& noskipws (ios_base& str); 1787a984708SDavid Chisnallios_base& uppercase (ios_base& str); 1797a984708SDavid Chisnallios_base& nouppercase(ios_base& str); 1807a984708SDavid Chisnallios_base& unitbuf (ios_base& str); 1817a984708SDavid Chisnallios_base& nounitbuf (ios_base& str); 1827a984708SDavid Chisnall 1837a984708SDavid Chisnall// 27.5.5.2 adjustfield: 1847a984708SDavid Chisnallios_base& internal (ios_base& str); 1857a984708SDavid Chisnallios_base& left (ios_base& str); 1867a984708SDavid Chisnallios_base& right (ios_base& str); 1877a984708SDavid Chisnall 1887a984708SDavid Chisnall// 27.5.5.3 basefield: 1897a984708SDavid Chisnallios_base& dec (ios_base& str); 1907a984708SDavid Chisnallios_base& hex (ios_base& str); 1917a984708SDavid Chisnallios_base& oct (ios_base& str); 1927a984708SDavid Chisnall 1937a984708SDavid Chisnall// 27.5.5.4 floatfield: 1947a984708SDavid Chisnallios_base& fixed (ios_base& str); 1957a984708SDavid Chisnallios_base& scientific (ios_base& str); 1967a984708SDavid Chisnallios_base& hexfloat (ios_base& str); 1977a984708SDavid Chisnallios_base& defaultfloat(ios_base& str); 1987a984708SDavid Chisnall 1997a984708SDavid Chisnall// 27.5.5.5 error reporting: 2007a984708SDavid Chisnallenum class io_errc 2017a984708SDavid Chisnall{ 2027a984708SDavid Chisnall stream = 1 2037a984708SDavid Chisnall}; 2047a984708SDavid Chisnall 2057a984708SDavid Chisnallconcept_map ErrorCodeEnum<io_errc> { }; 2064f7ab58eSDimitry Andricerror_code make_error_code(io_errc e) noexcept; 2074f7ab58eSDimitry Andricerror_condition make_error_condition(io_errc e) noexcept; 2084f7ab58eSDimitry Andricstorage-class-specifier const error_category& iostream_category() noexcept; 2097a984708SDavid Chisnall 2107a984708SDavid Chisnall} // std 2117a984708SDavid Chisnall 2127a984708SDavid Chisnall*/ 2137a984708SDavid Chisnall 2147a984708SDavid Chisnall#include <__config> 2157a984708SDavid Chisnall#include <iosfwd> 2167a984708SDavid Chisnall#include <__locale> 2177a984708SDavid Chisnall#include <system_error> 2187a984708SDavid Chisnall 2199729cf09SDimitry Andric#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) 2204f7ab58eSDimitry Andric#include <atomic> // for __xindex_ 2214f7ab58eSDimitry Andric#endif 2224f7ab58eSDimitry Andric 2237a984708SDavid Chisnall#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2247a984708SDavid Chisnall#pragma GCC system_header 2257a984708SDavid Chisnall#endif 2267a984708SDavid Chisnall 2277a984708SDavid Chisnall_LIBCPP_BEGIN_NAMESPACE_STD 2287a984708SDavid Chisnall 2297a984708SDavid Chisnalltypedef ptrdiff_t streamsize; 2307a984708SDavid Chisnall 2311bf9f7c1SDimitry Andricclass _LIBCPP_TYPE_VIS ios_base 2327a984708SDavid Chisnall{ 2337a984708SDavid Chisnallpublic: 2347c82a1ecSDimitry Andric class _LIBCPP_EXCEPTION_ABI failure; 2357a984708SDavid Chisnall 2367a984708SDavid Chisnall typedef unsigned int fmtflags; 2377a984708SDavid Chisnall static const fmtflags boolalpha = 0x0001; 2387a984708SDavid Chisnall static const fmtflags dec = 0x0002; 2397a984708SDavid Chisnall static const fmtflags fixed = 0x0004; 2407a984708SDavid Chisnall static const fmtflags hex = 0x0008; 2417a984708SDavid Chisnall static const fmtflags internal = 0x0010; 2427a984708SDavid Chisnall static const fmtflags left = 0x0020; 2437a984708SDavid Chisnall static const fmtflags oct = 0x0040; 2447a984708SDavid Chisnall static const fmtflags right = 0x0080; 2457a984708SDavid Chisnall static const fmtflags scientific = 0x0100; 2467a984708SDavid Chisnall static const fmtflags showbase = 0x0200; 2477a984708SDavid Chisnall static const fmtflags showpoint = 0x0400; 2487a984708SDavid Chisnall static const fmtflags showpos = 0x0800; 2497a984708SDavid Chisnall static const fmtflags skipws = 0x1000; 2507a984708SDavid Chisnall static const fmtflags unitbuf = 0x2000; 2517a984708SDavid Chisnall static const fmtflags uppercase = 0x4000; 2527a984708SDavid Chisnall static const fmtflags adjustfield = left | right | internal; 2537a984708SDavid Chisnall static const fmtflags basefield = dec | oct | hex; 2547a984708SDavid Chisnall static const fmtflags floatfield = scientific | fixed; 2557a984708SDavid Chisnall 2567a984708SDavid Chisnall typedef unsigned int iostate; 2577a984708SDavid Chisnall static const iostate badbit = 0x1; 2587a984708SDavid Chisnall static const iostate eofbit = 0x2; 2597a984708SDavid Chisnall static const iostate failbit = 0x4; 2607a984708SDavid Chisnall static const iostate goodbit = 0x0; 2617a984708SDavid Chisnall 2627a984708SDavid Chisnall typedef unsigned int openmode; 2637a984708SDavid Chisnall static const openmode app = 0x01; 2647a984708SDavid Chisnall static const openmode ate = 0x02; 2657a984708SDavid Chisnall static const openmode binary = 0x04; 2667a984708SDavid Chisnall static const openmode in = 0x08; 2677a984708SDavid Chisnall static const openmode out = 0x10; 2687a984708SDavid Chisnall static const openmode trunc = 0x20; 2697a984708SDavid Chisnall 2707a984708SDavid Chisnall enum seekdir {beg, cur, end}; 2719729cf09SDimitry Andric 2729729cf09SDimitry Andric#if _LIBCPP_STD_VER <= 14 2739729cf09SDimitry Andric typedef iostate io_state; 2749729cf09SDimitry Andric typedef openmode open_mode; 2757a984708SDavid Chisnall typedef seekdir seek_dir; 2767a984708SDavid Chisnall 2777a984708SDavid Chisnall typedef _VSTD::streamoff streamoff; 2787a984708SDavid Chisnall typedef _VSTD::streampos streampos; 2799729cf09SDimitry Andric#endif 2807a984708SDavid Chisnall 2811bf9f7c1SDimitry Andric class _LIBCPP_TYPE_VIS Init; 2827a984708SDavid Chisnall 2837a984708SDavid Chisnall // 27.5.2.2 fmtflags state: 2847a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY fmtflags flags() const; 2857a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl); 2867a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl); 2877a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask); 2887a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask); 2897a984708SDavid Chisnall 2907a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY streamsize precision() const; 2917a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec); 2927a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY streamsize width() const; 2937a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide); 2947a984708SDavid Chisnall 2957a984708SDavid Chisnall // 27.5.2.3 locales: 2967a984708SDavid Chisnall locale imbue(const locale& __loc); 2977a984708SDavid Chisnall locale getloc() const; 2987a984708SDavid Chisnall 2997a984708SDavid Chisnall // 27.5.2.5 storage: 3007a984708SDavid Chisnall static int xalloc(); 3017a984708SDavid Chisnall long& iword(int __index); 3027a984708SDavid Chisnall void*& pword(int __index); 3037a984708SDavid Chisnall 3047a984708SDavid Chisnall // destructor 3057a984708SDavid Chisnall virtual ~ios_base(); 3067a984708SDavid Chisnall 3077a984708SDavid Chisnall // 27.5.2.6 callbacks; 3087a984708SDavid Chisnall enum event { erase_event, imbue_event, copyfmt_event }; 3097a984708SDavid Chisnall typedef void (*event_callback)(event, ios_base&, int __index); 3107a984708SDavid Chisnall void register_callback(event_callback __fn, int __index); 3117a984708SDavid Chisnall 3127a984708SDavid Chisnallprivate: 3137a984708SDavid Chisnall ios_base(const ios_base&); // = delete; 3147a984708SDavid Chisnall ios_base& operator=(const ios_base&); // = delete; 3157a984708SDavid Chisnall 3167a984708SDavid Chisnallpublic: 3177a984708SDavid Chisnall static bool sync_with_stdio(bool __sync = true); 3187a984708SDavid Chisnall 3197a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY iostate rdstate() const; 3207a984708SDavid Chisnall void clear(iostate __state = goodbit); 3217a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state); 3227a984708SDavid Chisnall 3237a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY bool good() const; 3247a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY bool eof() const; 3257a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY bool fail() const; 3267a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY bool bad() const; 3277a984708SDavid Chisnall 3287a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; 3294f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate); 3307a984708SDavid Chisnall 3317a984708SDavid Chisnall void __set_badbit_and_consider_rethrow(); 3327a984708SDavid Chisnall void __set_failbit_and_consider_rethrow(); 3337a984708SDavid Chisnall 3347a984708SDavid Chisnallprotected: 3357a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 3367a984708SDavid Chisnall ios_base() {// purposefully does no initialization 3377a984708SDavid Chisnall } 3387a984708SDavid Chisnall 3397a984708SDavid Chisnall void init(void* __sb); 340*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY void* rdbuf() const {return __rdbuf_;} 3417a984708SDavid Chisnall 342*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3437a984708SDavid Chisnall void rdbuf(void* __sb) 3447a984708SDavid Chisnall { 3457a984708SDavid Chisnall __rdbuf_ = __sb; 3467a984708SDavid Chisnall clear(); 3477a984708SDavid Chisnall } 3487a984708SDavid Chisnall 3497a984708SDavid Chisnall void __call_callbacks(event); 3507a984708SDavid Chisnall void copyfmt(const ios_base&); 3517a984708SDavid Chisnall void move(ios_base&); 352936e9439SDimitry Andric void swap(ios_base&) _NOEXCEPT; 3537a984708SDavid Chisnall 354*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 3557a984708SDavid Chisnall void set_rdbuf(void* __sb) 3567a984708SDavid Chisnall { 3577a984708SDavid Chisnall __rdbuf_ = __sb; 3587a984708SDavid Chisnall } 3597a984708SDavid Chisnall 3607a984708SDavid Chisnallprivate: 3617a984708SDavid Chisnall // All data members must be scalars 3627a984708SDavid Chisnall fmtflags __fmtflags_; 3637a984708SDavid Chisnall streamsize __precision_; 3647a984708SDavid Chisnall streamsize __width_; 3657a984708SDavid Chisnall iostate __rdstate_; 3667a984708SDavid Chisnall iostate __exceptions_; 3677a984708SDavid Chisnall void* __rdbuf_; 3687a984708SDavid Chisnall void* __loc_; 3697a984708SDavid Chisnall event_callback* __fn_; 3707a984708SDavid Chisnall int* __index_; 3717a984708SDavid Chisnall size_t __event_size_; 3727a984708SDavid Chisnall size_t __event_cap_; 3739729cf09SDimitry Andric// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only 3749729cf09SDimitry Andric// enabled with clang. 3759729cf09SDimitry Andric#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) 3764f7ab58eSDimitry Andric static atomic<int> __xindex_; 3774f7ab58eSDimitry Andric#else 3787a984708SDavid Chisnall static int __xindex_; 3794f7ab58eSDimitry Andric#endif 3807a984708SDavid Chisnall long* __iarray_; 3817a984708SDavid Chisnall size_t __iarray_size_; 3827a984708SDavid Chisnall size_t __iarray_cap_; 3837a984708SDavid Chisnall void** __parray_; 3847a984708SDavid Chisnall size_t __parray_size_; 3857a984708SDavid Chisnall size_t __parray_cap_; 3867a984708SDavid Chisnall}; 3877a984708SDavid Chisnall 3887a984708SDavid Chisnall//enum class io_errc 38994e3ee44SDavid Chisnall_LIBCPP_DECLARE_STRONG_ENUM(io_errc) 3907a984708SDavid Chisnall{ 3917a984708SDavid Chisnall stream = 1 3927a984708SDavid Chisnall}; 39394e3ee44SDavid Chisnall_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) 3947a984708SDavid Chisnall 3957a984708SDavid Chisnalltemplate <> 396aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { }; 39794e3ee44SDavid Chisnall 39894e3ee44SDavid Chisnall#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS 3997a984708SDavid Chisnalltemplate <> 400aed8d94eSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { }; 40194e3ee44SDavid Chisnall#endif 4027a984708SDavid Chisnall 4031bf9f7c1SDimitry Andric_LIBCPP_FUNC_VIS 4044f7ab58eSDimitry Andricconst error_category& iostream_category() _NOEXCEPT; 4057a984708SDavid Chisnall 4067a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4077a984708SDavid Chisnallerror_code 4084f7ab58eSDimitry Andricmake_error_code(io_errc __e) _NOEXCEPT 4097a984708SDavid Chisnall{ 4107a984708SDavid Chisnall return error_code(static_cast<int>(__e), iostream_category()); 4117a984708SDavid Chisnall} 4127a984708SDavid Chisnall 4137a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4147a984708SDavid Chisnallerror_condition 4154f7ab58eSDimitry Andricmake_error_condition(io_errc __e) _NOEXCEPT 4167a984708SDavid Chisnall{ 4177a984708SDavid Chisnall return error_condition(static_cast<int>(__e), iostream_category()); 4187a984708SDavid Chisnall} 4197a984708SDavid Chisnall 4207a984708SDavid Chisnallclass _LIBCPP_EXCEPTION_ABI ios_base::failure 4217a984708SDavid Chisnall : public system_error 4227a984708SDavid Chisnall{ 4237a984708SDavid Chisnallpublic: 4247a984708SDavid Chisnall explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); 4257a984708SDavid Chisnall explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); 4267a984708SDavid Chisnall virtual ~failure() throw(); 4277a984708SDavid Chisnall}; 4287a984708SDavid Chisnall 4291bf9f7c1SDimitry Andricclass _LIBCPP_TYPE_VIS ios_base::Init 4307a984708SDavid Chisnall{ 4317a984708SDavid Chisnallpublic: 4327a984708SDavid Chisnall Init(); 4337a984708SDavid Chisnall ~Init(); 4347a984708SDavid Chisnall}; 4357a984708SDavid Chisnall 4367a984708SDavid Chisnall// fmtflags 4377a984708SDavid Chisnall 4387a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4397a984708SDavid Chisnallios_base::fmtflags 4407a984708SDavid Chisnallios_base::flags() const 4417a984708SDavid Chisnall{ 4427a984708SDavid Chisnall return __fmtflags_; 4437a984708SDavid Chisnall} 4447a984708SDavid Chisnall 4457a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4467a984708SDavid Chisnallios_base::fmtflags 4477a984708SDavid Chisnallios_base::flags(fmtflags __fmtfl) 4487a984708SDavid Chisnall{ 4497a984708SDavid Chisnall fmtflags __r = __fmtflags_; 4507a984708SDavid Chisnall __fmtflags_ = __fmtfl; 4517a984708SDavid Chisnall return __r; 4527a984708SDavid Chisnall} 4537a984708SDavid Chisnall 4547a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4557a984708SDavid Chisnallios_base::fmtflags 4567a984708SDavid Chisnallios_base::setf(fmtflags __fmtfl) 4577a984708SDavid Chisnall{ 4587a984708SDavid Chisnall fmtflags __r = __fmtflags_; 4597a984708SDavid Chisnall __fmtflags_ |= __fmtfl; 4607a984708SDavid Chisnall return __r; 4617a984708SDavid Chisnall} 4627a984708SDavid Chisnall 4637a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4647a984708SDavid Chisnallvoid 4657a984708SDavid Chisnallios_base::unsetf(fmtflags __mask) 4667a984708SDavid Chisnall{ 4677a984708SDavid Chisnall __fmtflags_ &= ~__mask; 4687a984708SDavid Chisnall} 4697a984708SDavid Chisnall 4707a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4717a984708SDavid Chisnallios_base::fmtflags 4727a984708SDavid Chisnallios_base::setf(fmtflags __fmtfl, fmtflags __mask) 4737a984708SDavid Chisnall{ 4747a984708SDavid Chisnall fmtflags __r = __fmtflags_; 4757a984708SDavid Chisnall unsetf(__mask); 4767a984708SDavid Chisnall __fmtflags_ |= __fmtfl & __mask; 4777a984708SDavid Chisnall return __r; 4787a984708SDavid Chisnall} 4797a984708SDavid Chisnall 4807a984708SDavid Chisnall// precision 4817a984708SDavid Chisnall 4827a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4837a984708SDavid Chisnallstreamsize 4847a984708SDavid Chisnallios_base::precision() const 4857a984708SDavid Chisnall{ 4867a984708SDavid Chisnall return __precision_; 4877a984708SDavid Chisnall} 4887a984708SDavid Chisnall 4897a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 4907a984708SDavid Chisnallstreamsize 4917a984708SDavid Chisnallios_base::precision(streamsize __prec) 4927a984708SDavid Chisnall{ 4937a984708SDavid Chisnall streamsize __r = __precision_; 4947a984708SDavid Chisnall __precision_ = __prec; 4957a984708SDavid Chisnall return __r; 4967a984708SDavid Chisnall} 4977a984708SDavid Chisnall 4987a984708SDavid Chisnall// width 4997a984708SDavid Chisnall 5007a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5017a984708SDavid Chisnallstreamsize 5027a984708SDavid Chisnallios_base::width() const 5037a984708SDavid Chisnall{ 5047a984708SDavid Chisnall return __width_; 5057a984708SDavid Chisnall} 5067a984708SDavid Chisnall 5077a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5087a984708SDavid Chisnallstreamsize 5097a984708SDavid Chisnallios_base::width(streamsize __wide) 5107a984708SDavid Chisnall{ 5117a984708SDavid Chisnall streamsize __r = __width_; 5127a984708SDavid Chisnall __width_ = __wide; 5137a984708SDavid Chisnall return __r; 5147a984708SDavid Chisnall} 5157a984708SDavid Chisnall 5167a984708SDavid Chisnall// iostate 5177a984708SDavid Chisnall 5187a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5197a984708SDavid Chisnallios_base::iostate 5207a984708SDavid Chisnallios_base::rdstate() const 5217a984708SDavid Chisnall{ 5227a984708SDavid Chisnall return __rdstate_; 5237a984708SDavid Chisnall} 5247a984708SDavid Chisnall 5257a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5267a984708SDavid Chisnallvoid 5277a984708SDavid Chisnallios_base::setstate(iostate __state) 5287a984708SDavid Chisnall{ 5297a984708SDavid Chisnall clear(__rdstate_ | __state); 5307a984708SDavid Chisnall} 5317a984708SDavid Chisnall 5327a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5337a984708SDavid Chisnallbool 5347a984708SDavid Chisnallios_base::good() const 5357a984708SDavid Chisnall{ 5367a984708SDavid Chisnall return __rdstate_ == 0; 5377a984708SDavid Chisnall} 5387a984708SDavid Chisnall 5397a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5407a984708SDavid Chisnallbool 5417a984708SDavid Chisnallios_base::eof() const 5427a984708SDavid Chisnall{ 5434f7ab58eSDimitry Andric return (__rdstate_ & eofbit) != 0; 5447a984708SDavid Chisnall} 5457a984708SDavid Chisnall 5467a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5477a984708SDavid Chisnallbool 5487a984708SDavid Chisnallios_base::fail() const 5497a984708SDavid Chisnall{ 5504f7ab58eSDimitry Andric return (__rdstate_ & (failbit | badbit)) != 0; 5517a984708SDavid Chisnall} 5527a984708SDavid Chisnall 5537a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5547a984708SDavid Chisnallbool 5557a984708SDavid Chisnallios_base::bad() const 5567a984708SDavid Chisnall{ 5574f7ab58eSDimitry Andric return (__rdstate_ & badbit) != 0; 5587a984708SDavid Chisnall} 5597a984708SDavid Chisnall 5607a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5617a984708SDavid Chisnallios_base::iostate 5627a984708SDavid Chisnallios_base::exceptions() const 5637a984708SDavid Chisnall{ 5647a984708SDavid Chisnall return __exceptions_; 5657a984708SDavid Chisnall} 5667a984708SDavid Chisnall 5677a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 5687a984708SDavid Chisnallvoid 5694f7ab58eSDimitry Andricios_base::exceptions(iostate __iostate) 5707a984708SDavid Chisnall{ 5714f7ab58eSDimitry Andric __exceptions_ = __iostate; 5727a984708SDavid Chisnall clear(__rdstate_); 5737a984708SDavid Chisnall} 5747a984708SDavid Chisnall 5757a848d17SDimitry Andric#if defined(_LIBCPP_CXX03_LANG) 5767a848d17SDimitry Andricstruct _LIBCPP_TYPE_VIS __cxx03_bool { 5777a848d17SDimitry Andric typedef void (__cxx03_bool::*__bool_type)(); 5787a848d17SDimitry Andric void __true_value() {} 5797a848d17SDimitry Andric}; 5807a848d17SDimitry Andric#endif 5817a848d17SDimitry Andric 5827a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 583aed8d94eSDimitry Andricclass _LIBCPP_TEMPLATE_VIS basic_ios 5847a984708SDavid Chisnall : public ios_base 5857a984708SDavid Chisnall{ 5867a984708SDavid Chisnallpublic: 5877a984708SDavid Chisnall // types: 5887a984708SDavid Chisnall typedef _CharT char_type; 5897a984708SDavid Chisnall typedef _Traits traits_type; 5907a984708SDavid Chisnall 5917a984708SDavid Chisnall typedef typename traits_type::int_type int_type; 5927a984708SDavid Chisnall typedef typename traits_type::pos_type pos_type; 5937a984708SDavid Chisnall typedef typename traits_type::off_type off_type; 5947a984708SDavid Chisnall 595*4ba319b5SDimitry Andric static_assert((is_same<_CharT, typename traits_type::char_type>::value), 596*4ba319b5SDimitry Andric "traits_type::char_type must be the same type as CharT"); 597*4ba319b5SDimitry Andric 598540d2a8bSDimitry Andric // __true_value will generate undefined references when linking unless 599540d2a8bSDimitry Andric // we give it internal linkage. 600540d2a8bSDimitry Andric 6017a848d17SDimitry Andric#if defined(_LIBCPP_CXX03_LANG) 602*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6037a848d17SDimitry Andric operator __cxx03_bool::__bool_type() const { 6047a848d17SDimitry Andric return !fail() ? &__cxx03_bool::__true_value : nullptr; 6057a848d17SDimitry Andric } 6067a848d17SDimitry Andric#else 607*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 608aed8d94eSDimitry Andric _LIBCPP_EXPLICIT operator bool() const {return !fail();} 6097a848d17SDimitry Andric#endif 610aed8d94eSDimitry Andric 611*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY bool operator!() const {return fail();} 612*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY iostate rdstate() const {return ios_base::rdstate();} 613*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY void clear(iostate __state = goodbit) {ios_base::clear(__state);} 614*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state) {ios_base::setstate(__state);} 615*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY bool good() const {return ios_base::good();} 616*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY bool eof() const {return ios_base::eof();} 617*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY bool fail() const {return ios_base::fail();} 618*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY bool bad() const {return ios_base::bad();} 6197a984708SDavid Chisnall 620*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY iostate exceptions() const {return ios_base::exceptions();} 621*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);} 6227a984708SDavid Chisnall 6237a984708SDavid Chisnall // 27.5.4.1 Constructor/destructor: 6247a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6257a984708SDavid Chisnall explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb); 6267a984708SDavid Chisnall virtual ~basic_ios(); 6277a984708SDavid Chisnall 6287a984708SDavid Chisnall // 27.5.4.2 Members: 6297a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6307a984708SDavid Chisnall basic_ostream<char_type, traits_type>* tie() const; 6317a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6327a984708SDavid Chisnall basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr); 6337a984708SDavid Chisnall 6347a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6357a984708SDavid Chisnall basic_streambuf<char_type, traits_type>* rdbuf() const; 6367a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6377a984708SDavid Chisnall basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb); 6387a984708SDavid Chisnall 6397a984708SDavid Chisnall basic_ios& copyfmt(const basic_ios& __rhs); 6407a984708SDavid Chisnall 6417a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6427a984708SDavid Chisnall char_type fill() const; 6437a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6447a984708SDavid Chisnall char_type fill(char_type __ch); 6457a984708SDavid Chisnall 6467a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6477a984708SDavid Chisnall locale imbue(const locale& __loc); 6487a984708SDavid Chisnall 6497a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6507a984708SDavid Chisnall char narrow(char_type __c, char __dfault) const; 6517a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6527a984708SDavid Chisnall char_type widen(char __c) const; 6537a984708SDavid Chisnall 6547a984708SDavid Chisnallprotected: 655*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6567a984708SDavid Chisnall basic_ios() {// purposefully does no initialization 6577a984708SDavid Chisnall } 6587a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6597a984708SDavid Chisnall void init(basic_streambuf<char_type, traits_type>* __sb); 6607a984708SDavid Chisnall 6617a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6627a984708SDavid Chisnall void move(basic_ios& __rhs); 663540d2a8bSDimitry Andric#ifndef _LIBCPP_CXX03_LANG 664*4ba319b5SDimitry Andric _LIBCPP_INLINE_VISIBILITY 6657a984708SDavid Chisnall void move(basic_ios&& __rhs) {move(__rhs);} 6667a984708SDavid Chisnall#endif 6677a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 668936e9439SDimitry Andric void swap(basic_ios& __rhs) _NOEXCEPT; 6697a984708SDavid Chisnall _LIBCPP_INLINE_VISIBILITY 6707a984708SDavid Chisnall void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb); 6717a984708SDavid Chisnallprivate: 6727a984708SDavid Chisnall basic_ostream<char_type, traits_type>* __tie_; 673936e9439SDimitry Andric mutable int_type __fill_; 6747a984708SDavid Chisnall}; 6757a984708SDavid Chisnall 6767a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 6777a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 6787a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb) 6797a984708SDavid Chisnall{ 6807a984708SDavid Chisnall init(__sb); 6817a984708SDavid Chisnall} 6827a984708SDavid Chisnall 6837a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 6847a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::~basic_ios() 6857a984708SDavid Chisnall{ 6867a984708SDavid Chisnall} 6877a984708SDavid Chisnall 6887a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 6897a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 6907a984708SDavid Chisnallvoid 6917a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) 6927a984708SDavid Chisnall{ 6937a984708SDavid Chisnall ios_base::init(__sb); 6947a984708SDavid Chisnall __tie_ = 0; 695936e9439SDimitry Andric __fill_ = traits_type::eof(); 6967a984708SDavid Chisnall} 6977a984708SDavid Chisnall 6987a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 6997a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7007a984708SDavid Chisnallbasic_ostream<_CharT, _Traits>* 7017a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::tie() const 7027a984708SDavid Chisnall{ 7037a984708SDavid Chisnall return __tie_; 7047a984708SDavid Chisnall} 7057a984708SDavid Chisnall 7067a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7077a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7087a984708SDavid Chisnallbasic_ostream<_CharT, _Traits>* 7097a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) 7107a984708SDavid Chisnall{ 7117a984708SDavid Chisnall basic_ostream<char_type, traits_type>* __r = __tie_; 7127a984708SDavid Chisnall __tie_ = __tiestr; 7137a984708SDavid Chisnall return __r; 7147a984708SDavid Chisnall} 7157a984708SDavid Chisnall 7167a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7177a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7187a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>* 7197a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::rdbuf() const 7207a984708SDavid Chisnall{ 7217a984708SDavid Chisnall return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf()); 7227a984708SDavid Chisnall} 7237a984708SDavid Chisnall 7247a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7257a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7267a984708SDavid Chisnallbasic_streambuf<_CharT, _Traits>* 7277a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) 7287a984708SDavid Chisnall{ 7297a984708SDavid Chisnall basic_streambuf<char_type, traits_type>* __r = rdbuf(); 7307a984708SDavid Chisnall ios_base::rdbuf(__sb); 7317a984708SDavid Chisnall return __r; 7327a984708SDavid Chisnall} 7337a984708SDavid Chisnall 7347a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7357a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7367a984708SDavid Chisnalllocale 7377a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::imbue(const locale& __loc) 7387a984708SDavid Chisnall{ 7397a984708SDavid Chisnall locale __r = getloc(); 7407a984708SDavid Chisnall ios_base::imbue(__loc); 7417a984708SDavid Chisnall if (rdbuf()) 7427a984708SDavid Chisnall rdbuf()->pubimbue(__loc); 7437a984708SDavid Chisnall return __r; 7447a984708SDavid Chisnall} 7457a984708SDavid Chisnall 7467a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7477a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7487a984708SDavid Chisnallchar 7497a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const 7507a984708SDavid Chisnall{ 7517a984708SDavid Chisnall return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault); 7527a984708SDavid Chisnall} 7537a984708SDavid Chisnall 7547a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7557a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7567a984708SDavid Chisnall_CharT 7577a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::widen(char __c) const 7587a984708SDavid Chisnall{ 7597a984708SDavid Chisnall return use_facet<ctype<char_type> >(getloc()).widen(__c); 7607a984708SDavid Chisnall} 7617a984708SDavid Chisnall 7627a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7637a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7647a984708SDavid Chisnall_CharT 7657a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::fill() const 7667a984708SDavid Chisnall{ 767936e9439SDimitry Andric if (traits_type::eq_int_type(traits_type::eof(), __fill_)) 768936e9439SDimitry Andric __fill_ = widen(' '); 7697a984708SDavid Chisnall return __fill_; 7707a984708SDavid Chisnall} 7717a984708SDavid Chisnall 7727a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7737a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 7747a984708SDavid Chisnall_CharT 7757a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::fill(char_type __ch) 7767a984708SDavid Chisnall{ 7777a984708SDavid Chisnall char_type __r = __fill_; 7787a984708SDavid Chisnall __fill_ = __ch; 7797a984708SDavid Chisnall return __r; 7807a984708SDavid Chisnall} 7817a984708SDavid Chisnall 7827a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7837a984708SDavid Chisnallbasic_ios<_CharT, _Traits>& 7847a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) 7857a984708SDavid Chisnall{ 7867a984708SDavid Chisnall if (this != &__rhs) 7877a984708SDavid Chisnall { 7887a984708SDavid Chisnall __call_callbacks(erase_event); 7897a984708SDavid Chisnall ios_base::copyfmt(__rhs); 7907a984708SDavid Chisnall __tie_ = __rhs.__tie_; 7917a984708SDavid Chisnall __fill_ = __rhs.__fill_; 7927a984708SDavid Chisnall __call_callbacks(copyfmt_event); 7937a984708SDavid Chisnall exceptions(__rhs.exceptions()); 7947a984708SDavid Chisnall } 7957a984708SDavid Chisnall return *this; 7967a984708SDavid Chisnall} 7977a984708SDavid Chisnall 7987a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 7997a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8007a984708SDavid Chisnallvoid 8017a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::move(basic_ios& __rhs) 8027a984708SDavid Chisnall{ 8037a984708SDavid Chisnall ios_base::move(__rhs); 8047a984708SDavid Chisnall __tie_ = __rhs.__tie_; 8057a984708SDavid Chisnall __rhs.__tie_ = 0; 8067a984708SDavid Chisnall __fill_ = __rhs.__fill_; 8077a984708SDavid Chisnall} 8087a984708SDavid Chisnall 8097a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 8107a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8117a984708SDavid Chisnallvoid 812936e9439SDimitry Andricbasic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT 8137a984708SDavid Chisnall{ 8147a984708SDavid Chisnall ios_base::swap(__rhs); 8157a984708SDavid Chisnall _VSTD::swap(__tie_, __rhs.__tie_); 8167a984708SDavid Chisnall _VSTD::swap(__fill_, __rhs.__fill_); 8177a984708SDavid Chisnall} 8187a984708SDavid Chisnall 8197a984708SDavid Chisnalltemplate <class _CharT, class _Traits> 8207a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8217a984708SDavid Chisnallvoid 8227a984708SDavid Chisnallbasic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) 8237a984708SDavid Chisnall{ 8247a984708SDavid Chisnall ios_base::set_rdbuf(__sb); 8257a984708SDavid Chisnall} 8267a984708SDavid Chisnall 8277a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8287a984708SDavid Chisnallios_base& 8297a984708SDavid Chisnallboolalpha(ios_base& __str) 8307a984708SDavid Chisnall{ 8317a984708SDavid Chisnall __str.setf(ios_base::boolalpha); 8327a984708SDavid Chisnall return __str; 8337a984708SDavid Chisnall} 8347a984708SDavid Chisnall 8357a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8367a984708SDavid Chisnallios_base& 8377a984708SDavid Chisnallnoboolalpha(ios_base& __str) 8387a984708SDavid Chisnall{ 8397a984708SDavid Chisnall __str.unsetf(ios_base::boolalpha); 8407a984708SDavid Chisnall return __str; 8417a984708SDavid Chisnall} 8427a984708SDavid Chisnall 8437a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8447a984708SDavid Chisnallios_base& 8457a984708SDavid Chisnallshowbase(ios_base& __str) 8467a984708SDavid Chisnall{ 8477a984708SDavid Chisnall __str.setf(ios_base::showbase); 8487a984708SDavid Chisnall return __str; 8497a984708SDavid Chisnall} 8507a984708SDavid Chisnall 8517a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8527a984708SDavid Chisnallios_base& 8537a984708SDavid Chisnallnoshowbase(ios_base& __str) 8547a984708SDavid Chisnall{ 8557a984708SDavid Chisnall __str.unsetf(ios_base::showbase); 8567a984708SDavid Chisnall return __str; 8577a984708SDavid Chisnall} 8587a984708SDavid Chisnall 8597a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8607a984708SDavid Chisnallios_base& 8617a984708SDavid Chisnallshowpoint(ios_base& __str) 8627a984708SDavid Chisnall{ 8637a984708SDavid Chisnall __str.setf(ios_base::showpoint); 8647a984708SDavid Chisnall return __str; 8657a984708SDavid Chisnall} 8667a984708SDavid Chisnall 8677a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8687a984708SDavid Chisnallios_base& 8697a984708SDavid Chisnallnoshowpoint(ios_base& __str) 8707a984708SDavid Chisnall{ 8717a984708SDavid Chisnall __str.unsetf(ios_base::showpoint); 8727a984708SDavid Chisnall return __str; 8737a984708SDavid Chisnall} 8747a984708SDavid Chisnall 8757a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8767a984708SDavid Chisnallios_base& 8777a984708SDavid Chisnallshowpos(ios_base& __str) 8787a984708SDavid Chisnall{ 8797a984708SDavid Chisnall __str.setf(ios_base::showpos); 8807a984708SDavid Chisnall return __str; 8817a984708SDavid Chisnall} 8827a984708SDavid Chisnall 8837a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8847a984708SDavid Chisnallios_base& 8857a984708SDavid Chisnallnoshowpos(ios_base& __str) 8867a984708SDavid Chisnall{ 8877a984708SDavid Chisnall __str.unsetf(ios_base::showpos); 8887a984708SDavid Chisnall return __str; 8897a984708SDavid Chisnall} 8907a984708SDavid Chisnall 8917a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 8927a984708SDavid Chisnallios_base& 8937a984708SDavid Chisnallskipws(ios_base& __str) 8947a984708SDavid Chisnall{ 8957a984708SDavid Chisnall __str.setf(ios_base::skipws); 8967a984708SDavid Chisnall return __str; 8977a984708SDavid Chisnall} 8987a984708SDavid Chisnall 8997a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9007a984708SDavid Chisnallios_base& 9017a984708SDavid Chisnallnoskipws(ios_base& __str) 9027a984708SDavid Chisnall{ 9037a984708SDavid Chisnall __str.unsetf(ios_base::skipws); 9047a984708SDavid Chisnall return __str; 9057a984708SDavid Chisnall} 9067a984708SDavid Chisnall 9077a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9087a984708SDavid Chisnallios_base& 9097a984708SDavid Chisnalluppercase(ios_base& __str) 9107a984708SDavid Chisnall{ 9117a984708SDavid Chisnall __str.setf(ios_base::uppercase); 9127a984708SDavid Chisnall return __str; 9137a984708SDavid Chisnall} 9147a984708SDavid Chisnall 9157a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9167a984708SDavid Chisnallios_base& 9177a984708SDavid Chisnallnouppercase(ios_base& __str) 9187a984708SDavid Chisnall{ 9197a984708SDavid Chisnall __str.unsetf(ios_base::uppercase); 9207a984708SDavid Chisnall return __str; 9217a984708SDavid Chisnall} 9227a984708SDavid Chisnall 9237a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9247a984708SDavid Chisnallios_base& 9257a984708SDavid Chisnallunitbuf(ios_base& __str) 9267a984708SDavid Chisnall{ 9277a984708SDavid Chisnall __str.setf(ios_base::unitbuf); 9287a984708SDavid Chisnall return __str; 9297a984708SDavid Chisnall} 9307a984708SDavid Chisnall 9317a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9327a984708SDavid Chisnallios_base& 9337a984708SDavid Chisnallnounitbuf(ios_base& __str) 9347a984708SDavid Chisnall{ 9357a984708SDavid Chisnall __str.unsetf(ios_base::unitbuf); 9367a984708SDavid Chisnall return __str; 9377a984708SDavid Chisnall} 9387a984708SDavid Chisnall 9397a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9407a984708SDavid Chisnallios_base& 9417a984708SDavid Chisnallinternal(ios_base& __str) 9427a984708SDavid Chisnall{ 9437a984708SDavid Chisnall __str.setf(ios_base::internal, ios_base::adjustfield); 9447a984708SDavid Chisnall return __str; 9457a984708SDavid Chisnall} 9467a984708SDavid Chisnall 9477a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9487a984708SDavid Chisnallios_base& 9497a984708SDavid Chisnallleft(ios_base& __str) 9507a984708SDavid Chisnall{ 9517a984708SDavid Chisnall __str.setf(ios_base::left, ios_base::adjustfield); 9527a984708SDavid Chisnall return __str; 9537a984708SDavid Chisnall} 9547a984708SDavid Chisnall 9557a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9567a984708SDavid Chisnallios_base& 9577a984708SDavid Chisnallright(ios_base& __str) 9587a984708SDavid Chisnall{ 9597a984708SDavid Chisnall __str.setf(ios_base::right, ios_base::adjustfield); 9607a984708SDavid Chisnall return __str; 9617a984708SDavid Chisnall} 9627a984708SDavid Chisnall 9637a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9647a984708SDavid Chisnallios_base& 9657a984708SDavid Chisnalldec(ios_base& __str) 9667a984708SDavid Chisnall{ 9677a984708SDavid Chisnall __str.setf(ios_base::dec, ios_base::basefield); 9687a984708SDavid Chisnall return __str; 9697a984708SDavid Chisnall} 9707a984708SDavid Chisnall 9717a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9727a984708SDavid Chisnallios_base& 9737a984708SDavid Chisnallhex(ios_base& __str) 9747a984708SDavid Chisnall{ 9757a984708SDavid Chisnall __str.setf(ios_base::hex, ios_base::basefield); 9767a984708SDavid Chisnall return __str; 9777a984708SDavid Chisnall} 9787a984708SDavid Chisnall 9797a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9807a984708SDavid Chisnallios_base& 9817a984708SDavid Chisnalloct(ios_base& __str) 9827a984708SDavid Chisnall{ 9837a984708SDavid Chisnall __str.setf(ios_base::oct, ios_base::basefield); 9847a984708SDavid Chisnall return __str; 9857a984708SDavid Chisnall} 9867a984708SDavid Chisnall 9877a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9887a984708SDavid Chisnallios_base& 9897a984708SDavid Chisnallfixed(ios_base& __str) 9907a984708SDavid Chisnall{ 9917a984708SDavid Chisnall __str.setf(ios_base::fixed, ios_base::floatfield); 9927a984708SDavid Chisnall return __str; 9937a984708SDavid Chisnall} 9947a984708SDavid Chisnall 9957a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 9967a984708SDavid Chisnallios_base& 9977a984708SDavid Chisnallscientific(ios_base& __str) 9987a984708SDavid Chisnall{ 9997a984708SDavid Chisnall __str.setf(ios_base::scientific, ios_base::floatfield); 10007a984708SDavid Chisnall return __str; 10017a984708SDavid Chisnall} 10027a984708SDavid Chisnall 10037a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 10047a984708SDavid Chisnallios_base& 10057a984708SDavid Chisnallhexfloat(ios_base& __str) 10067a984708SDavid Chisnall{ 10077a984708SDavid Chisnall __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); 10087a984708SDavid Chisnall return __str; 10097a984708SDavid Chisnall} 10107a984708SDavid Chisnall 10117a984708SDavid Chisnallinline _LIBCPP_INLINE_VISIBILITY 10127a984708SDavid Chisnallios_base& 10137a984708SDavid Chisnalldefaultfloat(ios_base& __str) 10147a984708SDavid Chisnall{ 10157a984708SDavid Chisnall __str.unsetf(ios_base::floatfield); 10167a984708SDavid Chisnall return __str; 10177a984708SDavid Chisnall} 10187a984708SDavid Chisnall 10194f7ab58eSDimitry Andrictemplate <class _CharT, class _Traits> 10204f7ab58eSDimitry Andricclass __save_flags 10214f7ab58eSDimitry Andric{ 10224f7ab58eSDimitry Andric typedef basic_ios<_CharT, _Traits> __stream_type; 10234f7ab58eSDimitry Andric typedef typename __stream_type::fmtflags fmtflags; 10244f7ab58eSDimitry Andric 10254f7ab58eSDimitry Andric __stream_type& __stream_; 10264f7ab58eSDimitry Andric fmtflags __fmtflags_; 10274f7ab58eSDimitry Andric _CharT __fill_; 10284f7ab58eSDimitry Andric 10294f7ab58eSDimitry Andric __save_flags(const __save_flags&); 10304f7ab58eSDimitry Andric __save_flags& operator=(const __save_flags&); 10314f7ab58eSDimitry Andricpublic: 10324f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10334f7ab58eSDimitry Andric explicit __save_flags(__stream_type& __stream) 10344f7ab58eSDimitry Andric : __stream_(__stream), 10354f7ab58eSDimitry Andric __fmtflags_(__stream.flags()), 10364f7ab58eSDimitry Andric __fill_(__stream.fill()) 10374f7ab58eSDimitry Andric {} 10384f7ab58eSDimitry Andric _LIBCPP_INLINE_VISIBILITY 10394f7ab58eSDimitry Andric ~__save_flags() 10404f7ab58eSDimitry Andric { 10414f7ab58eSDimitry Andric __stream_.flags(__fmtflags_); 10424f7ab58eSDimitry Andric __stream_.fill(__fill_); 10434f7ab58eSDimitry Andric } 10444f7ab58eSDimitry Andric}; 10454f7ab58eSDimitry Andric 10467a984708SDavid Chisnall_LIBCPP_END_NAMESPACE_STD 10477a984708SDavid Chisnall 10487a984708SDavid Chisnall#endif // _LIBCPP_IOS 1049