ios revision 261272
1227825Stheraven// -*- C++ -*- 2227825Stheraven//===---------------------------- ios -------------------------------------===// 3227825Stheraven// 4227825Stheraven// The LLVM Compiler Infrastructure 5227825Stheraven// 6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open 7227825Stheraven// Source Licenses. See LICENSE.TXT for details. 8227825Stheraven// 9227825Stheraven//===----------------------------------------------------------------------===// 10227825Stheraven 11227825Stheraven#ifndef _LIBCPP_IOS 12227825Stheraven#define _LIBCPP_IOS 13227825Stheraven 14227825Stheraven/* 15227825Stheraven ios synopsis 16227825Stheraven 17227825Stheraven#include <iosfwd> 18227825Stheraven 19227825Stheravennamespace std 20227825Stheraven{ 21227825Stheraven 22227825Stheraventypedef OFF_T streamoff; 23227825Stheraventypedef SZ_T streamsize; 24227825Stheraventemplate <class stateT> class fpos; 25227825Stheraven 26227825Stheravenclass ios_base 27227825Stheraven{ 28227825Stheravenpublic: 29227825Stheraven class failure; 30227825Stheraven 31227825Stheraven typedef T1 fmtflags; 32241900Sdim static constexpr fmtflags boolalpha; 33241900Sdim static constexpr fmtflags dec; 34241900Sdim static constexpr fmtflags fixed; 35241900Sdim static constexpr fmtflags hex; 36241900Sdim static constexpr fmtflags internal; 37241900Sdim static constexpr fmtflags left; 38241900Sdim static constexpr fmtflags oct; 39241900Sdim static constexpr fmtflags right; 40241900Sdim static constexpr fmtflags scientific; 41241900Sdim static constexpr fmtflags showbase; 42241900Sdim static constexpr fmtflags showpoint; 43241900Sdim static constexpr fmtflags showpos; 44241900Sdim static constexpr fmtflags skipws; 45241900Sdim static constexpr fmtflags unitbuf; 46241900Sdim static constexpr fmtflags uppercase; 47241900Sdim static constexpr fmtflags adjustfield; 48241900Sdim static constexpr fmtflags basefield; 49241900Sdim static constexpr fmtflags floatfield; 50227825Stheraven 51227825Stheraven typedef T2 iostate; 52241900Sdim static constexpr iostate badbit; 53241900Sdim static constexpr iostate eofbit; 54241900Sdim static constexpr iostate failbit; 55241900Sdim static constexpr iostate goodbit; 56227825Stheraven 57227825Stheraven typedef T3 openmode; 58241900Sdim static constexpr openmode app; 59241900Sdim static constexpr openmode ate; 60241900Sdim static constexpr openmode binary; 61241900Sdim static constexpr openmode in; 62241900Sdim static constexpr openmode out; 63241900Sdim static constexpr openmode trunc; 64227825Stheraven 65227825Stheraven typedef T4 seekdir; 66241900Sdim static constexpr seekdir beg; 67241900Sdim static constexpr seekdir cur; 68241900Sdim static constexpr seekdir end; 69227825Stheraven 70227825Stheraven class Init; 71227825Stheraven 72227825Stheraven // 27.5.2.2 fmtflags state: 73227825Stheraven fmtflags flags() const; 74227825Stheraven fmtflags flags(fmtflags fmtfl); 75227825Stheraven fmtflags setf(fmtflags fmtfl); 76227825Stheraven fmtflags setf(fmtflags fmtfl, fmtflags mask); 77227825Stheraven void unsetf(fmtflags mask); 78227825Stheraven 79227825Stheraven streamsize precision() const; 80227825Stheraven streamsize precision(streamsize prec); 81227825Stheraven streamsize width() const; 82227825Stheraven streamsize width(streamsize wide); 83227825Stheraven 84227825Stheraven // 27.5.2.3 locales: 85227825Stheraven locale imbue(const locale& loc); 86227825Stheraven locale getloc() const; 87227825Stheraven 88227825Stheraven // 27.5.2.5 storage: 89227825Stheraven static int xalloc(); 90227825Stheraven long& iword(int index); 91227825Stheraven void*& pword(int index); 92227825Stheraven 93227825Stheraven // destructor 94227825Stheraven virtual ~ios_base(); 95227825Stheraven 96227825Stheraven // 27.5.2.6 callbacks; 97227825Stheraven enum event { erase_event, imbue_event, copyfmt_event }; 98227825Stheraven typedef void (*event_callback)(event, ios_base&, int index); 99227825Stheraven void register_callback(event_callback fn, int index); 100227825Stheraven 101227825Stheraven ios_base(const ios_base&) = delete; 102227825Stheraven ios_base& operator=(const ios_base&) = delete; 103227825Stheraven 104227825Stheraven static bool sync_with_stdio(bool sync = true); 105227825Stheraven 106227825Stheravenprotected: 107227825Stheraven ios_base(); 108227825Stheraven}; 109227825Stheraven 110227825Stheraventemplate <class charT, class traits = char_traits<charT> > 111227825Stheravenclass basic_ios 112227825Stheraven : public ios_base 113227825Stheraven{ 114227825Stheravenpublic: 115227825Stheraven // types: 116227825Stheraven typedef charT char_type; 117227825Stheraven typedef typename traits::int_type int_type; 118227825Stheraven typedef typename traits::pos_type pos_type; 119227825Stheraven typedef typename traits::off_type off_type; 120227825Stheraven typedef traits traits_type; 121227825Stheraven 122227825Stheraven operator unspecified-bool-type() const; 123227825Stheraven bool operator!() const; 124227825Stheraven iostate rdstate() const; 125227825Stheraven void clear(iostate state = goodbit); 126227825Stheraven void setstate(iostate state); 127227825Stheraven bool good() const; 128227825Stheraven bool eof() const; 129227825Stheraven bool fail() const; 130227825Stheraven bool bad() const; 131227825Stheraven 132227825Stheraven iostate exceptions() const; 133227825Stheraven void exceptions(iostate except); 134227825Stheraven 135227825Stheraven // 27.5.4.1 Constructor/destructor: 136227825Stheraven explicit basic_ios(basic_streambuf<charT,traits>* sb); 137227825Stheraven virtual ~basic_ios(); 138227825Stheraven 139227825Stheraven // 27.5.4.2 Members: 140227825Stheraven basic_ostream<charT,traits>* tie() const; 141227825Stheraven basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr); 142227825Stheraven 143227825Stheraven basic_streambuf<charT,traits>* rdbuf() const; 144227825Stheraven basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb); 145227825Stheraven 146227825Stheraven basic_ios& copyfmt(const basic_ios& rhs); 147227825Stheraven 148227825Stheraven char_type fill() const; 149227825Stheraven char_type fill(char_type ch); 150227825Stheraven 151227825Stheraven locale imbue(const locale& loc); 152227825Stheraven 153227825Stheraven char narrow(char_type c, char dfault) const; 154227825Stheraven char_type widen(char c) const; 155227825Stheraven 156227825Stheraven basic_ios(const basic_ios& ) = delete; 157227825Stheraven basic_ios& operator=(const basic_ios&) = delete; 158227825Stheraven 159227825Stheravenprotected: 160227825Stheraven basic_ios(); 161227825Stheraven void init(basic_streambuf<charT,traits>* sb); 162227825Stheraven void move(basic_ios& rhs); 163241900Sdim void swap(basic_ios& rhs) noexcept; 164227825Stheraven void set_rdbuf(basic_streambuf<charT, traits>* sb); 165227825Stheraven}; 166227825Stheraven 167227825Stheraven// 27.5.5, manipulators: 168227825Stheravenios_base& boolalpha (ios_base& str); 169227825Stheravenios_base& noboolalpha(ios_base& str); 170227825Stheravenios_base& showbase (ios_base& str); 171227825Stheravenios_base& noshowbase (ios_base& str); 172227825Stheravenios_base& showpoint (ios_base& str); 173227825Stheravenios_base& noshowpoint(ios_base& str); 174227825Stheravenios_base& showpos (ios_base& str); 175227825Stheravenios_base& noshowpos (ios_base& str); 176227825Stheravenios_base& skipws (ios_base& str); 177227825Stheravenios_base& noskipws (ios_base& str); 178227825Stheravenios_base& uppercase (ios_base& str); 179227825Stheravenios_base& nouppercase(ios_base& str); 180227825Stheravenios_base& unitbuf (ios_base& str); 181227825Stheravenios_base& nounitbuf (ios_base& str); 182227825Stheraven 183227825Stheraven// 27.5.5.2 adjustfield: 184227825Stheravenios_base& internal (ios_base& str); 185227825Stheravenios_base& left (ios_base& str); 186227825Stheravenios_base& right (ios_base& str); 187227825Stheraven 188227825Stheraven// 27.5.5.3 basefield: 189227825Stheravenios_base& dec (ios_base& str); 190227825Stheravenios_base& hex (ios_base& str); 191227825Stheravenios_base& oct (ios_base& str); 192227825Stheraven 193227825Stheraven// 27.5.5.4 floatfield: 194227825Stheravenios_base& fixed (ios_base& str); 195227825Stheravenios_base& scientific (ios_base& str); 196227825Stheravenios_base& hexfloat (ios_base& str); 197227825Stheravenios_base& defaultfloat(ios_base& str); 198227825Stheraven 199227825Stheraven// 27.5.5.5 error reporting: 200227825Stheravenenum class io_errc 201227825Stheraven{ 202227825Stheraven stream = 1 203227825Stheraven}; 204227825Stheraven 205227825Stheravenconcept_map ErrorCodeEnum<io_errc> { }; 206261272Sdimerror_code make_error_code(io_errc e) noexcept; 207261272Sdimerror_condition make_error_condition(io_errc e) noexcept; 208261272Sdimstorage-class-specifier const error_category& iostream_category() noexcept; 209227825Stheraven 210227825Stheraven} // std 211227825Stheraven 212227825Stheraven*/ 213227825Stheraven 214227825Stheraven#include <__config> 215227825Stheraven#include <iosfwd> 216227825Stheraven#include <__locale> 217227825Stheraven#include <system_error> 218227825Stheraven 219261272Sdim#if __has_feature(cxx_atomic) 220261272Sdim#include <atomic> // for __xindex_ 221261272Sdim#endif 222261272Sdim 223227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 224227825Stheraven#pragma GCC system_header 225227825Stheraven#endif 226227825Stheraven 227227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 228227825Stheraven 229227825Stheraventypedef ptrdiff_t streamsize; 230227825Stheraven 231249989Sdimclass _LIBCPP_TYPE_VIS ios_base 232227825Stheraven{ 233227825Stheravenpublic: 234249989Sdim class _LIBCPP_TYPE_VIS failure; 235227825Stheraven 236227825Stheraven typedef unsigned int fmtflags; 237227825Stheraven static const fmtflags boolalpha = 0x0001; 238227825Stheraven static const fmtflags dec = 0x0002; 239227825Stheraven static const fmtflags fixed = 0x0004; 240227825Stheraven static const fmtflags hex = 0x0008; 241227825Stheraven static const fmtflags internal = 0x0010; 242227825Stheraven static const fmtflags left = 0x0020; 243227825Stheraven static const fmtflags oct = 0x0040; 244227825Stheraven static const fmtflags right = 0x0080; 245227825Stheraven static const fmtflags scientific = 0x0100; 246227825Stheraven static const fmtflags showbase = 0x0200; 247227825Stheraven static const fmtflags showpoint = 0x0400; 248227825Stheraven static const fmtflags showpos = 0x0800; 249227825Stheraven static const fmtflags skipws = 0x1000; 250227825Stheraven static const fmtflags unitbuf = 0x2000; 251227825Stheraven static const fmtflags uppercase = 0x4000; 252227825Stheraven static const fmtflags adjustfield = left | right | internal; 253227825Stheraven static const fmtflags basefield = dec | oct | hex; 254227825Stheraven static const fmtflags floatfield = scientific | fixed; 255227825Stheraven 256227825Stheraven typedef unsigned int iostate; 257227825Stheraven typedef iostate io_state; 258227825Stheraven static const iostate badbit = 0x1; 259227825Stheraven static const iostate eofbit = 0x2; 260227825Stheraven static const iostate failbit = 0x4; 261227825Stheraven static const iostate goodbit = 0x0; 262227825Stheraven 263227825Stheraven typedef unsigned int openmode; 264227825Stheraven typedef openmode open_mode; 265227825Stheraven static const openmode app = 0x01; 266227825Stheraven static const openmode ate = 0x02; 267227825Stheraven static const openmode binary = 0x04; 268227825Stheraven static const openmode in = 0x08; 269227825Stheraven static const openmode out = 0x10; 270227825Stheraven static const openmode trunc = 0x20; 271227825Stheraven 272227825Stheraven enum seekdir {beg, cur, end}; 273227825Stheraven typedef seekdir seek_dir; 274227825Stheraven 275227825Stheraven typedef _VSTD::streamoff streamoff; 276227825Stheraven typedef _VSTD::streampos streampos; 277227825Stheraven 278249989Sdim class _LIBCPP_TYPE_VIS Init; 279227825Stheraven 280227825Stheraven // 27.5.2.2 fmtflags state: 281227825Stheraven _LIBCPP_INLINE_VISIBILITY fmtflags flags() const; 282227825Stheraven _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl); 283227825Stheraven _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl); 284227825Stheraven _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask); 285227825Stheraven _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask); 286227825Stheraven 287227825Stheraven _LIBCPP_INLINE_VISIBILITY streamsize precision() const; 288227825Stheraven _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec); 289227825Stheraven _LIBCPP_INLINE_VISIBILITY streamsize width() const; 290227825Stheraven _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide); 291227825Stheraven 292227825Stheraven // 27.5.2.3 locales: 293227825Stheraven locale imbue(const locale& __loc); 294227825Stheraven locale getloc() const; 295227825Stheraven 296227825Stheraven // 27.5.2.5 storage: 297227825Stheraven static int xalloc(); 298227825Stheraven long& iword(int __index); 299227825Stheraven void*& pword(int __index); 300227825Stheraven 301227825Stheraven // destructor 302227825Stheraven virtual ~ios_base(); 303227825Stheraven 304227825Stheraven // 27.5.2.6 callbacks; 305227825Stheraven enum event { erase_event, imbue_event, copyfmt_event }; 306227825Stheraven typedef void (*event_callback)(event, ios_base&, int __index); 307227825Stheraven void register_callback(event_callback __fn, int __index); 308227825Stheraven 309227825Stheravenprivate: 310227825Stheraven ios_base(const ios_base&); // = delete; 311227825Stheraven ios_base& operator=(const ios_base&); // = delete; 312227825Stheraven 313227825Stheravenpublic: 314227825Stheraven static bool sync_with_stdio(bool __sync = true); 315227825Stheraven 316227825Stheraven _LIBCPP_INLINE_VISIBILITY iostate rdstate() const; 317227825Stheraven void clear(iostate __state = goodbit); 318227825Stheraven _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state); 319227825Stheraven 320227825Stheraven _LIBCPP_INLINE_VISIBILITY bool good() const; 321227825Stheraven _LIBCPP_INLINE_VISIBILITY bool eof() const; 322227825Stheraven _LIBCPP_INLINE_VISIBILITY bool fail() const; 323227825Stheraven _LIBCPP_INLINE_VISIBILITY bool bad() const; 324227825Stheraven 325227825Stheraven _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; 326261272Sdim _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate); 327227825Stheraven 328227825Stheraven void __set_badbit_and_consider_rethrow(); 329227825Stheraven void __set_failbit_and_consider_rethrow(); 330227825Stheraven 331227825Stheravenprotected: 332227825Stheraven _LIBCPP_INLINE_VISIBILITY 333227825Stheraven ios_base() {// purposefully does no initialization 334227825Stheraven } 335227825Stheraven 336227825Stheraven void init(void* __sb); 337227825Stheraven _LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;} 338227825Stheraven 339227825Stheraven _LIBCPP_ALWAYS_INLINE 340227825Stheraven void rdbuf(void* __sb) 341227825Stheraven { 342227825Stheraven __rdbuf_ = __sb; 343227825Stheraven clear(); 344227825Stheraven } 345227825Stheraven 346227825Stheraven void __call_callbacks(event); 347227825Stheraven void copyfmt(const ios_base&); 348227825Stheraven void move(ios_base&); 349241900Sdim void swap(ios_base&) _NOEXCEPT; 350227825Stheraven 351227825Stheraven _LIBCPP_ALWAYS_INLINE 352227825Stheraven void set_rdbuf(void* __sb) 353227825Stheraven { 354227825Stheraven __rdbuf_ = __sb; 355227825Stheraven } 356227825Stheraven 357227825Stheravenprivate: 358227825Stheraven // All data members must be scalars 359227825Stheraven fmtflags __fmtflags_; 360227825Stheraven streamsize __precision_; 361227825Stheraven streamsize __width_; 362227825Stheraven iostate __rdstate_; 363227825Stheraven iostate __exceptions_; 364227825Stheraven void* __rdbuf_; 365227825Stheraven void* __loc_; 366227825Stheraven event_callback* __fn_; 367227825Stheraven int* __index_; 368227825Stheraven size_t __event_size_; 369227825Stheraven size_t __event_cap_; 370261272Sdim#if __has_feature(cxx_atomic) 371261272Sdim static atomic<int> __xindex_; 372261272Sdim#else 373227825Stheraven static int __xindex_; 374261272Sdim#endif 375227825Stheraven long* __iarray_; 376227825Stheraven size_t __iarray_size_; 377227825Stheraven size_t __iarray_cap_; 378227825Stheraven void** __parray_; 379227825Stheraven size_t __parray_size_; 380227825Stheraven size_t __parray_cap_; 381227825Stheraven}; 382227825Stheraven 383227825Stheraven//enum class io_errc 384232924Stheraven_LIBCPP_DECLARE_STRONG_ENUM(io_errc) 385227825Stheraven{ 386227825Stheraven stream = 1 387227825Stheraven}; 388232924Stheraven_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) 389227825Stheraven 390227825Stheraventemplate <> 391261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc> : public true_type { }; 392232924Stheraven 393232924Stheraven#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS 394227825Stheraventemplate <> 395261272Sdimstruct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc::__lx> : public true_type { }; 396232924Stheraven#endif 397227825Stheraven 398249989Sdim_LIBCPP_FUNC_VIS 399261272Sdimconst error_category& iostream_category() _NOEXCEPT; 400227825Stheraven 401227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 402227825Stheravenerror_code 403261272Sdimmake_error_code(io_errc __e) _NOEXCEPT 404227825Stheraven{ 405227825Stheraven return error_code(static_cast<int>(__e), iostream_category()); 406227825Stheraven} 407227825Stheraven 408227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 409227825Stheravenerror_condition 410261272Sdimmake_error_condition(io_errc __e) _NOEXCEPT 411227825Stheraven{ 412227825Stheraven return error_condition(static_cast<int>(__e), iostream_category()); 413227825Stheraven} 414227825Stheraven 415227825Stheravenclass _LIBCPP_EXCEPTION_ABI ios_base::failure 416227825Stheraven : public system_error 417227825Stheraven{ 418227825Stheravenpublic: 419227825Stheraven explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); 420227825Stheraven explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); 421227825Stheraven virtual ~failure() throw(); 422227825Stheraven}; 423227825Stheraven 424249989Sdimclass _LIBCPP_TYPE_VIS ios_base::Init 425227825Stheraven{ 426227825Stheravenpublic: 427227825Stheraven Init(); 428227825Stheraven ~Init(); 429227825Stheraven}; 430227825Stheraven 431227825Stheraven// fmtflags 432227825Stheraven 433227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 434227825Stheravenios_base::fmtflags 435227825Stheravenios_base::flags() const 436227825Stheraven{ 437227825Stheraven return __fmtflags_; 438227825Stheraven} 439227825Stheraven 440227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 441227825Stheravenios_base::fmtflags 442227825Stheravenios_base::flags(fmtflags __fmtfl) 443227825Stheraven{ 444227825Stheraven fmtflags __r = __fmtflags_; 445227825Stheraven __fmtflags_ = __fmtfl; 446227825Stheraven return __r; 447227825Stheraven} 448227825Stheraven 449227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 450227825Stheravenios_base::fmtflags 451227825Stheravenios_base::setf(fmtflags __fmtfl) 452227825Stheraven{ 453227825Stheraven fmtflags __r = __fmtflags_; 454227825Stheraven __fmtflags_ |= __fmtfl; 455227825Stheraven return __r; 456227825Stheraven} 457227825Stheraven 458227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 459227825Stheravenvoid 460227825Stheravenios_base::unsetf(fmtflags __mask) 461227825Stheraven{ 462227825Stheraven __fmtflags_ &= ~__mask; 463227825Stheraven} 464227825Stheraven 465227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 466227825Stheravenios_base::fmtflags 467227825Stheravenios_base::setf(fmtflags __fmtfl, fmtflags __mask) 468227825Stheraven{ 469227825Stheraven fmtflags __r = __fmtflags_; 470227825Stheraven unsetf(__mask); 471227825Stheraven __fmtflags_ |= __fmtfl & __mask; 472227825Stheraven return __r; 473227825Stheraven} 474227825Stheraven 475227825Stheraven// precision 476227825Stheraven 477227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 478227825Stheravenstreamsize 479227825Stheravenios_base::precision() const 480227825Stheraven{ 481227825Stheraven return __precision_; 482227825Stheraven} 483227825Stheraven 484227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 485227825Stheravenstreamsize 486227825Stheravenios_base::precision(streamsize __prec) 487227825Stheraven{ 488227825Stheraven streamsize __r = __precision_; 489227825Stheraven __precision_ = __prec; 490227825Stheraven return __r; 491227825Stheraven} 492227825Stheraven 493227825Stheraven// width 494227825Stheraven 495227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 496227825Stheravenstreamsize 497227825Stheravenios_base::width() const 498227825Stheraven{ 499227825Stheraven return __width_; 500227825Stheraven} 501227825Stheraven 502227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 503227825Stheravenstreamsize 504227825Stheravenios_base::width(streamsize __wide) 505227825Stheraven{ 506227825Stheraven streamsize __r = __width_; 507227825Stheraven __width_ = __wide; 508227825Stheraven return __r; 509227825Stheraven} 510227825Stheraven 511227825Stheraven// iostate 512227825Stheraven 513227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 514227825Stheravenios_base::iostate 515227825Stheravenios_base::rdstate() const 516227825Stheraven{ 517227825Stheraven return __rdstate_; 518227825Stheraven} 519227825Stheraven 520227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 521227825Stheravenvoid 522227825Stheravenios_base::setstate(iostate __state) 523227825Stheraven{ 524227825Stheraven clear(__rdstate_ | __state); 525227825Stheraven} 526227825Stheraven 527227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 528227825Stheravenbool 529227825Stheravenios_base::good() const 530227825Stheraven{ 531227825Stheraven return __rdstate_ == 0; 532227825Stheraven} 533227825Stheraven 534227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 535227825Stheravenbool 536227825Stheravenios_base::eof() const 537227825Stheraven{ 538261272Sdim return (__rdstate_ & eofbit) != 0; 539227825Stheraven} 540227825Stheraven 541227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 542227825Stheravenbool 543227825Stheravenios_base::fail() const 544227825Stheraven{ 545261272Sdim return (__rdstate_ & (failbit | badbit)) != 0; 546227825Stheraven} 547227825Stheraven 548227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 549227825Stheravenbool 550227825Stheravenios_base::bad() const 551227825Stheraven{ 552261272Sdim return (__rdstate_ & badbit) != 0; 553227825Stheraven} 554227825Stheraven 555227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 556227825Stheravenios_base::iostate 557227825Stheravenios_base::exceptions() const 558227825Stheraven{ 559227825Stheraven return __exceptions_; 560227825Stheraven} 561227825Stheraven 562227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 563227825Stheravenvoid 564261272Sdimios_base::exceptions(iostate __iostate) 565227825Stheraven{ 566261272Sdim __exceptions_ = __iostate; 567227825Stheraven clear(__rdstate_); 568227825Stheraven} 569227825Stheraven 570227825Stheraventemplate <class _CharT, class _Traits> 571261272Sdimclass _LIBCPP_TYPE_VIS_ONLY basic_ios 572227825Stheraven : public ios_base 573227825Stheraven{ 574227825Stheravenpublic: 575227825Stheraven // types: 576227825Stheraven typedef _CharT char_type; 577227825Stheraven typedef _Traits traits_type; 578227825Stheraven 579227825Stheraven typedef typename traits_type::int_type int_type; 580227825Stheraven typedef typename traits_type::pos_type pos_type; 581227825Stheraven typedef typename traits_type::off_type off_type; 582227825Stheraven 583232924Stheraven _LIBCPP_ALWAYS_INLINE 584232924Stheraven _LIBCPP_EXPLICIT 585227825Stheraven operator bool() const {return !fail();} 586227825Stheraven _LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();} 587227825Stheraven _LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();} 588227825Stheraven _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);} 589227825Stheraven _LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);} 590227825Stheraven _LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();} 591227825Stheraven _LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();} 592227825Stheraven _LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();} 593227825Stheraven _LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();} 594227825Stheraven 595227825Stheraven _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();} 596261272Sdim _LIBCPP_ALWAYS_INLINE void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);} 597227825Stheraven 598227825Stheraven // 27.5.4.1 Constructor/destructor: 599227825Stheraven _LIBCPP_INLINE_VISIBILITY 600227825Stheraven explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb); 601227825Stheraven virtual ~basic_ios(); 602227825Stheraven 603227825Stheraven // 27.5.4.2 Members: 604227825Stheraven _LIBCPP_INLINE_VISIBILITY 605227825Stheraven basic_ostream<char_type, traits_type>* tie() const; 606227825Stheraven _LIBCPP_INLINE_VISIBILITY 607227825Stheraven basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr); 608227825Stheraven 609227825Stheraven _LIBCPP_INLINE_VISIBILITY 610227825Stheraven basic_streambuf<char_type, traits_type>* rdbuf() const; 611227825Stheraven _LIBCPP_INLINE_VISIBILITY 612227825Stheraven basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb); 613227825Stheraven 614227825Stheraven basic_ios& copyfmt(const basic_ios& __rhs); 615227825Stheraven 616227825Stheraven _LIBCPP_INLINE_VISIBILITY 617227825Stheraven char_type fill() const; 618227825Stheraven _LIBCPP_INLINE_VISIBILITY 619227825Stheraven char_type fill(char_type __ch); 620227825Stheraven 621227825Stheraven _LIBCPP_INLINE_VISIBILITY 622227825Stheraven locale imbue(const locale& __loc); 623227825Stheraven 624227825Stheraven _LIBCPP_INLINE_VISIBILITY 625227825Stheraven char narrow(char_type __c, char __dfault) const; 626227825Stheraven _LIBCPP_INLINE_VISIBILITY 627227825Stheraven char_type widen(char __c) const; 628227825Stheraven 629227825Stheravenprotected: 630227825Stheraven _LIBCPP_ALWAYS_INLINE 631227825Stheraven basic_ios() {// purposefully does no initialization 632227825Stheraven } 633227825Stheraven _LIBCPP_INLINE_VISIBILITY 634227825Stheraven void init(basic_streambuf<char_type, traits_type>* __sb); 635227825Stheraven 636227825Stheraven _LIBCPP_INLINE_VISIBILITY 637227825Stheraven void move(basic_ios& __rhs); 638227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 639227825Stheraven _LIBCPP_ALWAYS_INLINE 640227825Stheraven void move(basic_ios&& __rhs) {move(__rhs);} 641227825Stheraven#endif 642227825Stheraven _LIBCPP_INLINE_VISIBILITY 643241900Sdim void swap(basic_ios& __rhs) _NOEXCEPT; 644227825Stheraven _LIBCPP_INLINE_VISIBILITY 645227825Stheraven void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb); 646227825Stheravenprivate: 647227825Stheraven basic_ostream<char_type, traits_type>* __tie_; 648241900Sdim mutable int_type __fill_; 649227825Stheraven}; 650227825Stheraven 651227825Stheraventemplate <class _CharT, class _Traits> 652227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 653227825Stheravenbasic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb) 654227825Stheraven{ 655227825Stheraven init(__sb); 656227825Stheraven} 657227825Stheraven 658227825Stheraventemplate <class _CharT, class _Traits> 659227825Stheravenbasic_ios<_CharT, _Traits>::~basic_ios() 660227825Stheraven{ 661227825Stheraven} 662227825Stheraven 663227825Stheraventemplate <class _CharT, class _Traits> 664227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 665227825Stheravenvoid 666227825Stheravenbasic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) 667227825Stheraven{ 668227825Stheraven ios_base::init(__sb); 669227825Stheraven __tie_ = 0; 670241900Sdim __fill_ = traits_type::eof(); 671227825Stheraven} 672227825Stheraven 673227825Stheraventemplate <class _CharT, class _Traits> 674227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 675227825Stheravenbasic_ostream<_CharT, _Traits>* 676227825Stheravenbasic_ios<_CharT, _Traits>::tie() const 677227825Stheraven{ 678227825Stheraven return __tie_; 679227825Stheraven} 680227825Stheraven 681227825Stheraventemplate <class _CharT, class _Traits> 682227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 683227825Stheravenbasic_ostream<_CharT, _Traits>* 684227825Stheravenbasic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) 685227825Stheraven{ 686227825Stheraven basic_ostream<char_type, traits_type>* __r = __tie_; 687227825Stheraven __tie_ = __tiestr; 688227825Stheraven return __r; 689227825Stheraven} 690227825Stheraven 691227825Stheraventemplate <class _CharT, class _Traits> 692227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 693227825Stheravenbasic_streambuf<_CharT, _Traits>* 694227825Stheravenbasic_ios<_CharT, _Traits>::rdbuf() const 695227825Stheraven{ 696227825Stheraven return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf()); 697227825Stheraven} 698227825Stheraven 699227825Stheraventemplate <class _CharT, class _Traits> 700227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 701227825Stheravenbasic_streambuf<_CharT, _Traits>* 702227825Stheravenbasic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) 703227825Stheraven{ 704227825Stheraven basic_streambuf<char_type, traits_type>* __r = rdbuf(); 705227825Stheraven ios_base::rdbuf(__sb); 706227825Stheraven return __r; 707227825Stheraven} 708227825Stheraven 709227825Stheraventemplate <class _CharT, class _Traits> 710227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 711227825Stheravenlocale 712227825Stheravenbasic_ios<_CharT, _Traits>::imbue(const locale& __loc) 713227825Stheraven{ 714227825Stheraven locale __r = getloc(); 715227825Stheraven ios_base::imbue(__loc); 716227825Stheraven if (rdbuf()) 717227825Stheraven rdbuf()->pubimbue(__loc); 718227825Stheraven return __r; 719227825Stheraven} 720227825Stheraven 721227825Stheraventemplate <class _CharT, class _Traits> 722227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 723227825Stheravenchar 724227825Stheravenbasic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const 725227825Stheraven{ 726227825Stheraven return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault); 727227825Stheraven} 728227825Stheraven 729227825Stheraventemplate <class _CharT, class _Traits> 730227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 731227825Stheraven_CharT 732227825Stheravenbasic_ios<_CharT, _Traits>::widen(char __c) const 733227825Stheraven{ 734227825Stheraven return use_facet<ctype<char_type> >(getloc()).widen(__c); 735227825Stheraven} 736227825Stheraven 737227825Stheraventemplate <class _CharT, class _Traits> 738227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 739227825Stheraven_CharT 740227825Stheravenbasic_ios<_CharT, _Traits>::fill() const 741227825Stheraven{ 742241900Sdim if (traits_type::eq_int_type(traits_type::eof(), __fill_)) 743241900Sdim __fill_ = widen(' '); 744227825Stheraven return __fill_; 745227825Stheraven} 746227825Stheraven 747227825Stheraventemplate <class _CharT, class _Traits> 748227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 749227825Stheraven_CharT 750227825Stheravenbasic_ios<_CharT, _Traits>::fill(char_type __ch) 751227825Stheraven{ 752227825Stheraven char_type __r = __fill_; 753227825Stheraven __fill_ = __ch; 754227825Stheraven return __r; 755227825Stheraven} 756227825Stheraven 757227825Stheraventemplate <class _CharT, class _Traits> 758227825Stheravenbasic_ios<_CharT, _Traits>& 759227825Stheravenbasic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) 760227825Stheraven{ 761227825Stheraven if (this != &__rhs) 762227825Stheraven { 763227825Stheraven __call_callbacks(erase_event); 764227825Stheraven ios_base::copyfmt(__rhs); 765227825Stheraven __tie_ = __rhs.__tie_; 766227825Stheraven __fill_ = __rhs.__fill_; 767227825Stheraven __call_callbacks(copyfmt_event); 768227825Stheraven exceptions(__rhs.exceptions()); 769227825Stheraven } 770227825Stheraven return *this; 771227825Stheraven} 772227825Stheraven 773227825Stheraventemplate <class _CharT, class _Traits> 774227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 775227825Stheravenvoid 776227825Stheravenbasic_ios<_CharT, _Traits>::move(basic_ios& __rhs) 777227825Stheraven{ 778227825Stheraven ios_base::move(__rhs); 779227825Stheraven __tie_ = __rhs.__tie_; 780227825Stheraven __rhs.__tie_ = 0; 781227825Stheraven __fill_ = __rhs.__fill_; 782227825Stheraven} 783227825Stheraven 784227825Stheraventemplate <class _CharT, class _Traits> 785227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 786227825Stheravenvoid 787241900Sdimbasic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT 788227825Stheraven{ 789227825Stheraven ios_base::swap(__rhs); 790227825Stheraven _VSTD::swap(__tie_, __rhs.__tie_); 791227825Stheraven _VSTD::swap(__fill_, __rhs.__fill_); 792227825Stheraven} 793227825Stheraven 794227825Stheraventemplate <class _CharT, class _Traits> 795227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 796227825Stheravenvoid 797227825Stheravenbasic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) 798227825Stheraven{ 799227825Stheraven ios_base::set_rdbuf(__sb); 800227825Stheraven} 801227825Stheraven 802227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 803227825Stheravenios_base& 804227825Stheravenboolalpha(ios_base& __str) 805227825Stheraven{ 806227825Stheraven __str.setf(ios_base::boolalpha); 807227825Stheraven return __str; 808227825Stheraven} 809227825Stheraven 810227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 811227825Stheravenios_base& 812227825Stheravennoboolalpha(ios_base& __str) 813227825Stheraven{ 814227825Stheraven __str.unsetf(ios_base::boolalpha); 815227825Stheraven return __str; 816227825Stheraven} 817227825Stheraven 818227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 819227825Stheravenios_base& 820227825Stheravenshowbase(ios_base& __str) 821227825Stheraven{ 822227825Stheraven __str.setf(ios_base::showbase); 823227825Stheraven return __str; 824227825Stheraven} 825227825Stheraven 826227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 827227825Stheravenios_base& 828227825Stheravennoshowbase(ios_base& __str) 829227825Stheraven{ 830227825Stheraven __str.unsetf(ios_base::showbase); 831227825Stheraven return __str; 832227825Stheraven} 833227825Stheraven 834227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 835227825Stheravenios_base& 836227825Stheravenshowpoint(ios_base& __str) 837227825Stheraven{ 838227825Stheraven __str.setf(ios_base::showpoint); 839227825Stheraven return __str; 840227825Stheraven} 841227825Stheraven 842227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 843227825Stheravenios_base& 844227825Stheravennoshowpoint(ios_base& __str) 845227825Stheraven{ 846227825Stheraven __str.unsetf(ios_base::showpoint); 847227825Stheraven return __str; 848227825Stheraven} 849227825Stheraven 850227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 851227825Stheravenios_base& 852227825Stheravenshowpos(ios_base& __str) 853227825Stheraven{ 854227825Stheraven __str.setf(ios_base::showpos); 855227825Stheraven return __str; 856227825Stheraven} 857227825Stheraven 858227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 859227825Stheravenios_base& 860227825Stheravennoshowpos(ios_base& __str) 861227825Stheraven{ 862227825Stheraven __str.unsetf(ios_base::showpos); 863227825Stheraven return __str; 864227825Stheraven} 865227825Stheraven 866227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 867227825Stheravenios_base& 868227825Stheravenskipws(ios_base& __str) 869227825Stheraven{ 870227825Stheraven __str.setf(ios_base::skipws); 871227825Stheraven return __str; 872227825Stheraven} 873227825Stheraven 874227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 875227825Stheravenios_base& 876227825Stheravennoskipws(ios_base& __str) 877227825Stheraven{ 878227825Stheraven __str.unsetf(ios_base::skipws); 879227825Stheraven return __str; 880227825Stheraven} 881227825Stheraven 882227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 883227825Stheravenios_base& 884227825Stheravenuppercase(ios_base& __str) 885227825Stheraven{ 886227825Stheraven __str.setf(ios_base::uppercase); 887227825Stheraven return __str; 888227825Stheraven} 889227825Stheraven 890227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 891227825Stheravenios_base& 892227825Stheravennouppercase(ios_base& __str) 893227825Stheraven{ 894227825Stheraven __str.unsetf(ios_base::uppercase); 895227825Stheraven return __str; 896227825Stheraven} 897227825Stheraven 898227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 899227825Stheravenios_base& 900227825Stheravenunitbuf(ios_base& __str) 901227825Stheraven{ 902227825Stheraven __str.setf(ios_base::unitbuf); 903227825Stheraven return __str; 904227825Stheraven} 905227825Stheraven 906227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 907227825Stheravenios_base& 908227825Stheravennounitbuf(ios_base& __str) 909227825Stheraven{ 910227825Stheraven __str.unsetf(ios_base::unitbuf); 911227825Stheraven return __str; 912227825Stheraven} 913227825Stheraven 914227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 915227825Stheravenios_base& 916227825Stheraveninternal(ios_base& __str) 917227825Stheraven{ 918227825Stheraven __str.setf(ios_base::internal, ios_base::adjustfield); 919227825Stheraven return __str; 920227825Stheraven} 921227825Stheraven 922227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 923227825Stheravenios_base& 924227825Stheravenleft(ios_base& __str) 925227825Stheraven{ 926227825Stheraven __str.setf(ios_base::left, ios_base::adjustfield); 927227825Stheraven return __str; 928227825Stheraven} 929227825Stheraven 930227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 931227825Stheravenios_base& 932227825Stheravenright(ios_base& __str) 933227825Stheraven{ 934227825Stheraven __str.setf(ios_base::right, ios_base::adjustfield); 935227825Stheraven return __str; 936227825Stheraven} 937227825Stheraven 938227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 939227825Stheravenios_base& 940227825Stheravendec(ios_base& __str) 941227825Stheraven{ 942227825Stheraven __str.setf(ios_base::dec, ios_base::basefield); 943227825Stheraven return __str; 944227825Stheraven} 945227825Stheraven 946227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 947227825Stheravenios_base& 948227825Stheravenhex(ios_base& __str) 949227825Stheraven{ 950227825Stheraven __str.setf(ios_base::hex, ios_base::basefield); 951227825Stheraven return __str; 952227825Stheraven} 953227825Stheraven 954227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 955227825Stheravenios_base& 956227825Stheravenoct(ios_base& __str) 957227825Stheraven{ 958227825Stheraven __str.setf(ios_base::oct, ios_base::basefield); 959227825Stheraven return __str; 960227825Stheraven} 961227825Stheraven 962227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 963227825Stheravenios_base& 964227825Stheravenfixed(ios_base& __str) 965227825Stheraven{ 966227825Stheraven __str.setf(ios_base::fixed, ios_base::floatfield); 967227825Stheraven return __str; 968227825Stheraven} 969227825Stheraven 970227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 971227825Stheravenios_base& 972227825Stheravenscientific(ios_base& __str) 973227825Stheraven{ 974227825Stheraven __str.setf(ios_base::scientific, ios_base::floatfield); 975227825Stheraven return __str; 976227825Stheraven} 977227825Stheraven 978227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 979227825Stheravenios_base& 980227825Stheravenhexfloat(ios_base& __str) 981227825Stheraven{ 982227825Stheraven __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); 983227825Stheraven return __str; 984227825Stheraven} 985227825Stheraven 986227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 987227825Stheravenios_base& 988227825Stheravendefaultfloat(ios_base& __str) 989227825Stheraven{ 990227825Stheraven __str.unsetf(ios_base::floatfield); 991227825Stheraven return __str; 992227825Stheraven} 993227825Stheraven 994261272Sdimtemplate <class _CharT, class _Traits> 995261272Sdimclass __save_flags 996261272Sdim{ 997261272Sdim typedef basic_ios<_CharT, _Traits> __stream_type; 998261272Sdim typedef typename __stream_type::fmtflags fmtflags; 999261272Sdim 1000261272Sdim __stream_type& __stream_; 1001261272Sdim fmtflags __fmtflags_; 1002261272Sdim _CharT __fill_; 1003261272Sdim 1004261272Sdim __save_flags(const __save_flags&); 1005261272Sdim __save_flags& operator=(const __save_flags&); 1006261272Sdimpublic: 1007261272Sdim _LIBCPP_INLINE_VISIBILITY 1008261272Sdim explicit __save_flags(__stream_type& __stream) 1009261272Sdim : __stream_(__stream), 1010261272Sdim __fmtflags_(__stream.flags()), 1011261272Sdim __fill_(__stream.fill()) 1012261272Sdim {} 1013261272Sdim _LIBCPP_INLINE_VISIBILITY 1014261272Sdim ~__save_flags() 1015261272Sdim { 1016261272Sdim __stream_.flags(__fmtflags_); 1017261272Sdim __stream_.fill(__fill_); 1018261272Sdim } 1019261272Sdim}; 1020261272Sdim 1021227825Stheraven_LIBCPP_END_NAMESPACE_STD 1022227825Stheraven 1023227825Stheraven#endif // _LIBCPP_IOS 1024