ios revision 227825
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; 32227825Stheraven static const fmtflags boolalpha; 33227825Stheraven static const fmtflags dec; 34227825Stheraven static const fmtflags fixed; 35227825Stheraven static const fmtflags hex; 36227825Stheraven static const fmtflags internal; 37227825Stheraven static const fmtflags left; 38227825Stheraven static const fmtflags oct; 39227825Stheraven static const fmtflags right; 40227825Stheraven static const fmtflags scientific; 41227825Stheraven static const fmtflags showbase; 42227825Stheraven static const fmtflags showpoint; 43227825Stheraven static const fmtflags showpos; 44227825Stheraven static const fmtflags skipws; 45227825Stheraven static const fmtflags unitbuf; 46227825Stheraven static const fmtflags uppercase; 47227825Stheraven static const fmtflags adjustfield; 48227825Stheraven static const fmtflags basefield; 49227825Stheraven static const fmtflags floatfield; 50227825Stheraven 51227825Stheraven typedef T2 iostate; 52227825Stheraven static const iostate badbit; 53227825Stheraven static const iostate eofbit; 54227825Stheraven static const iostate failbit; 55227825Stheraven static const iostate goodbit; 56227825Stheraven 57227825Stheraven typedef T3 openmode; 58227825Stheraven static const openmode app; 59227825Stheraven static const openmode ate; 60227825Stheraven static const openmode binary; 61227825Stheraven static const openmode in; 62227825Stheraven static const openmode out; 63227825Stheraven static const openmode trunc; 64227825Stheraven 65227825Stheraven typedef T4 seekdir; 66227825Stheraven static const seekdir beg; 67227825Stheraven static const seekdir cur; 68227825Stheraven static const 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); 163227825Stheraven void swap(basic_ios& rhs); 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> { }; 206227825Stheravenerror_code make_error_code(io_errc e); 207227825Stheravenerror_condition make_error_condition(io_errc e); 208227825Stheravenstorage-class-specifier const error_category& iostream_category; 209227825Stheraven 210227825Stheraven} // std 211227825Stheraven 212227825Stheraven*/ 213227825Stheraven 214227825Stheraven#include <__config> 215227825Stheraven#include <iosfwd> 216227825Stheraven#include <__locale> 217227825Stheraven#include <system_error> 218227825Stheraven 219227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 220227825Stheraven#pragma GCC system_header 221227825Stheraven#endif 222227825Stheraven 223227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD 224227825Stheraven 225227825Stheraventypedef ptrdiff_t streamsize; 226227825Stheraven 227227825Stheravenclass _LIBCPP_VISIBLE ios_base 228227825Stheraven{ 229227825Stheravenpublic: 230227825Stheraven class failure; 231227825Stheraven 232227825Stheraven typedef unsigned int fmtflags; 233227825Stheraven static const fmtflags boolalpha = 0x0001; 234227825Stheraven static const fmtflags dec = 0x0002; 235227825Stheraven static const fmtflags fixed = 0x0004; 236227825Stheraven static const fmtflags hex = 0x0008; 237227825Stheraven static const fmtflags internal = 0x0010; 238227825Stheraven static const fmtflags left = 0x0020; 239227825Stheraven static const fmtflags oct = 0x0040; 240227825Stheraven static const fmtflags right = 0x0080; 241227825Stheraven static const fmtflags scientific = 0x0100; 242227825Stheraven static const fmtflags showbase = 0x0200; 243227825Stheraven static const fmtflags showpoint = 0x0400; 244227825Stheraven static const fmtflags showpos = 0x0800; 245227825Stheraven static const fmtflags skipws = 0x1000; 246227825Stheraven static const fmtflags unitbuf = 0x2000; 247227825Stheraven static const fmtflags uppercase = 0x4000; 248227825Stheraven static const fmtflags adjustfield = left | right | internal; 249227825Stheraven static const fmtflags basefield = dec | oct | hex; 250227825Stheraven static const fmtflags floatfield = scientific | fixed; 251227825Stheraven 252227825Stheraven typedef unsigned int iostate; 253227825Stheraven typedef iostate io_state; 254227825Stheraven static const iostate badbit = 0x1; 255227825Stheraven static const iostate eofbit = 0x2; 256227825Stheraven static const iostate failbit = 0x4; 257227825Stheraven static const iostate goodbit = 0x0; 258227825Stheraven 259227825Stheraven typedef unsigned int openmode; 260227825Stheraven typedef openmode open_mode; 261227825Stheraven static const openmode app = 0x01; 262227825Stheraven static const openmode ate = 0x02; 263227825Stheraven static const openmode binary = 0x04; 264227825Stheraven static const openmode in = 0x08; 265227825Stheraven static const openmode out = 0x10; 266227825Stheraven static const openmode trunc = 0x20; 267227825Stheraven 268227825Stheraven enum seekdir {beg, cur, end}; 269227825Stheraven typedef seekdir seek_dir; 270227825Stheraven 271227825Stheraven typedef _VSTD::streamoff streamoff; 272227825Stheraven typedef _VSTD::streampos streampos; 273227825Stheraven 274227825Stheraven class Init; 275227825Stheraven 276227825Stheraven // 27.5.2.2 fmtflags state: 277227825Stheraven _LIBCPP_INLINE_VISIBILITY fmtflags flags() const; 278227825Stheraven _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl); 279227825Stheraven _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl); 280227825Stheraven _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask); 281227825Stheraven _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask); 282227825Stheraven 283227825Stheraven _LIBCPP_INLINE_VISIBILITY streamsize precision() const; 284227825Stheraven _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec); 285227825Stheraven _LIBCPP_INLINE_VISIBILITY streamsize width() const; 286227825Stheraven _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide); 287227825Stheraven 288227825Stheraven // 27.5.2.3 locales: 289227825Stheraven locale imbue(const locale& __loc); 290227825Stheraven locale getloc() const; 291227825Stheraven 292227825Stheraven // 27.5.2.5 storage: 293227825Stheraven static int xalloc(); 294227825Stheraven long& iword(int __index); 295227825Stheraven void*& pword(int __index); 296227825Stheraven 297227825Stheraven // destructor 298227825Stheraven virtual ~ios_base(); 299227825Stheraven 300227825Stheraven // 27.5.2.6 callbacks; 301227825Stheraven enum event { erase_event, imbue_event, copyfmt_event }; 302227825Stheraven typedef void (*event_callback)(event, ios_base&, int __index); 303227825Stheraven void register_callback(event_callback __fn, int __index); 304227825Stheraven 305227825Stheravenprivate: 306227825Stheraven ios_base(const ios_base&); // = delete; 307227825Stheraven ios_base& operator=(const ios_base&); // = delete; 308227825Stheraven 309227825Stheravenpublic: 310227825Stheraven static bool sync_with_stdio(bool __sync = true); 311227825Stheraven 312227825Stheraven _LIBCPP_INLINE_VISIBILITY iostate rdstate() const; 313227825Stheraven void clear(iostate __state = goodbit); 314227825Stheraven _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state); 315227825Stheraven 316227825Stheraven _LIBCPP_INLINE_VISIBILITY bool good() const; 317227825Stheraven _LIBCPP_INLINE_VISIBILITY bool eof() const; 318227825Stheraven _LIBCPP_INLINE_VISIBILITY bool fail() const; 319227825Stheraven _LIBCPP_INLINE_VISIBILITY bool bad() const; 320227825Stheraven 321227825Stheraven _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; 322227825Stheraven _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __except); 323227825Stheraven 324227825Stheraven void __set_badbit_and_consider_rethrow(); 325227825Stheraven void __set_failbit_and_consider_rethrow(); 326227825Stheraven 327227825Stheravenprotected: 328227825Stheraven _LIBCPP_INLINE_VISIBILITY 329227825Stheraven ios_base() {// purposefully does no initialization 330227825Stheraven } 331227825Stheraven 332227825Stheraven void init(void* __sb); 333227825Stheraven _LIBCPP_ALWAYS_INLINE void* rdbuf() const {return __rdbuf_;} 334227825Stheraven 335227825Stheraven _LIBCPP_ALWAYS_INLINE 336227825Stheraven void rdbuf(void* __sb) 337227825Stheraven { 338227825Stheraven __rdbuf_ = __sb; 339227825Stheraven clear(); 340227825Stheraven } 341227825Stheraven 342227825Stheraven void __call_callbacks(event); 343227825Stheraven void copyfmt(const ios_base&); 344227825Stheraven void move(ios_base&); 345227825Stheraven void swap(ios_base&); 346227825Stheraven 347227825Stheraven _LIBCPP_ALWAYS_INLINE 348227825Stheraven void set_rdbuf(void* __sb) 349227825Stheraven { 350227825Stheraven __rdbuf_ = __sb; 351227825Stheraven } 352227825Stheraven 353227825Stheravenprivate: 354227825Stheraven // All data members must be scalars 355227825Stheraven fmtflags __fmtflags_; 356227825Stheraven streamsize __precision_; 357227825Stheraven streamsize __width_; 358227825Stheraven iostate __rdstate_; 359227825Stheraven iostate __exceptions_; 360227825Stheraven void* __rdbuf_; 361227825Stheraven void* __loc_; 362227825Stheraven event_callback* __fn_; 363227825Stheraven int* __index_; 364227825Stheraven size_t __event_size_; 365227825Stheraven size_t __event_cap_; 366227825Stheraven static int __xindex_; 367227825Stheraven long* __iarray_; 368227825Stheraven size_t __iarray_size_; 369227825Stheraven size_t __iarray_cap_; 370227825Stheraven void** __parray_; 371227825Stheraven size_t __parray_size_; 372227825Stheraven size_t __parray_cap_; 373227825Stheraven}; 374227825Stheraven 375227825Stheraven//enum class io_errc 376227825Stheravenstruct _LIBCPP_VISIBLE io_errc 377227825Stheraven{ 378227825Stheravenenum _ { 379227825Stheraven stream = 1 380227825Stheraven}; 381227825Stheraven _ __v_; 382227825Stheraven 383227825Stheraven _LIBCPP_ALWAYS_INLINE io_errc(_ __v) : __v_(__v) {} 384227825Stheraven _LIBCPP_ALWAYS_INLINE operator int() const {return __v_;} 385227825Stheraven}; 386227825Stheraven 387227825Stheraventemplate <> 388227825Stheravenstruct _LIBCPP_VISIBLE is_error_code_enum<io_errc> : public true_type { }; 389227825Stheraventemplate <> 390227825Stheravenstruct _LIBCPP_VISIBLE is_error_code_enum<io_errc::_> : public true_type { }; 391227825Stheraven 392227825Stheraven_LIBCPP_VISIBLE 393227825Stheravenconst error_category& iostream_category(); 394227825Stheraven 395227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 396227825Stheravenerror_code 397227825Stheravenmake_error_code(io_errc __e) 398227825Stheraven{ 399227825Stheraven return error_code(static_cast<int>(__e), iostream_category()); 400227825Stheraven} 401227825Stheraven 402227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 403227825Stheravenerror_condition 404227825Stheravenmake_error_condition(io_errc __e) 405227825Stheraven{ 406227825Stheraven return error_condition(static_cast<int>(__e), iostream_category()); 407227825Stheraven} 408227825Stheraven 409227825Stheravenclass _LIBCPP_EXCEPTION_ABI ios_base::failure 410227825Stheraven : public system_error 411227825Stheraven{ 412227825Stheravenpublic: 413227825Stheraven explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); 414227825Stheraven explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); 415227825Stheraven virtual ~failure() throw(); 416227825Stheraven}; 417227825Stheraven 418227825Stheravenclass _LIBCPP_VISIBLE ios_base::Init 419227825Stheraven{ 420227825Stheravenpublic: 421227825Stheraven Init(); 422227825Stheraven ~Init(); 423227825Stheraven}; 424227825Stheraven 425227825Stheraven// fmtflags 426227825Stheraven 427227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 428227825Stheravenios_base::fmtflags 429227825Stheravenios_base::flags() const 430227825Stheraven{ 431227825Stheraven return __fmtflags_; 432227825Stheraven} 433227825Stheraven 434227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 435227825Stheravenios_base::fmtflags 436227825Stheravenios_base::flags(fmtflags __fmtfl) 437227825Stheraven{ 438227825Stheraven fmtflags __r = __fmtflags_; 439227825Stheraven __fmtflags_ = __fmtfl; 440227825Stheraven return __r; 441227825Stheraven} 442227825Stheraven 443227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 444227825Stheravenios_base::fmtflags 445227825Stheravenios_base::setf(fmtflags __fmtfl) 446227825Stheraven{ 447227825Stheraven fmtflags __r = __fmtflags_; 448227825Stheraven __fmtflags_ |= __fmtfl; 449227825Stheraven return __r; 450227825Stheraven} 451227825Stheraven 452227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 453227825Stheravenvoid 454227825Stheravenios_base::unsetf(fmtflags __mask) 455227825Stheraven{ 456227825Stheraven __fmtflags_ &= ~__mask; 457227825Stheraven} 458227825Stheraven 459227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 460227825Stheravenios_base::fmtflags 461227825Stheravenios_base::setf(fmtflags __fmtfl, fmtflags __mask) 462227825Stheraven{ 463227825Stheraven fmtflags __r = __fmtflags_; 464227825Stheraven unsetf(__mask); 465227825Stheraven __fmtflags_ |= __fmtfl & __mask; 466227825Stheraven return __r; 467227825Stheraven} 468227825Stheraven 469227825Stheraven// precision 470227825Stheraven 471227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 472227825Stheravenstreamsize 473227825Stheravenios_base::precision() const 474227825Stheraven{ 475227825Stheraven return __precision_; 476227825Stheraven} 477227825Stheraven 478227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 479227825Stheravenstreamsize 480227825Stheravenios_base::precision(streamsize __prec) 481227825Stheraven{ 482227825Stheraven streamsize __r = __precision_; 483227825Stheraven __precision_ = __prec; 484227825Stheraven return __r; 485227825Stheraven} 486227825Stheraven 487227825Stheraven// width 488227825Stheraven 489227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 490227825Stheravenstreamsize 491227825Stheravenios_base::width() const 492227825Stheraven{ 493227825Stheraven return __width_; 494227825Stheraven} 495227825Stheraven 496227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 497227825Stheravenstreamsize 498227825Stheravenios_base::width(streamsize __wide) 499227825Stheraven{ 500227825Stheraven streamsize __r = __width_; 501227825Stheraven __width_ = __wide; 502227825Stheraven return __r; 503227825Stheraven} 504227825Stheraven 505227825Stheraven// iostate 506227825Stheraven 507227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 508227825Stheravenios_base::iostate 509227825Stheravenios_base::rdstate() const 510227825Stheraven{ 511227825Stheraven return __rdstate_; 512227825Stheraven} 513227825Stheraven 514227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 515227825Stheravenvoid 516227825Stheravenios_base::setstate(iostate __state) 517227825Stheraven{ 518227825Stheraven clear(__rdstate_ | __state); 519227825Stheraven} 520227825Stheraven 521227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 522227825Stheravenbool 523227825Stheravenios_base::good() const 524227825Stheraven{ 525227825Stheraven return __rdstate_ == 0; 526227825Stheraven} 527227825Stheraven 528227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 529227825Stheravenbool 530227825Stheravenios_base::eof() const 531227825Stheraven{ 532227825Stheraven return __rdstate_ & eofbit; 533227825Stheraven} 534227825Stheraven 535227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 536227825Stheravenbool 537227825Stheravenios_base::fail() const 538227825Stheraven{ 539227825Stheraven return __rdstate_ & (failbit | badbit); 540227825Stheraven} 541227825Stheraven 542227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 543227825Stheravenbool 544227825Stheravenios_base::bad() const 545227825Stheraven{ 546227825Stheraven return __rdstate_ & badbit; 547227825Stheraven} 548227825Stheraven 549227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 550227825Stheravenios_base::iostate 551227825Stheravenios_base::exceptions() const 552227825Stheraven{ 553227825Stheraven return __exceptions_; 554227825Stheraven} 555227825Stheraven 556227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 557227825Stheravenvoid 558227825Stheravenios_base::exceptions(iostate __except) 559227825Stheraven{ 560227825Stheraven __exceptions_ = __except; 561227825Stheraven clear(__rdstate_); 562227825Stheraven} 563227825Stheraven 564227825Stheraventemplate <class _CharT, class _Traits> 565227825Stheravenclass _LIBCPP_VISIBLE basic_ios 566227825Stheraven : public ios_base 567227825Stheraven{ 568227825Stheravenpublic: 569227825Stheraven // types: 570227825Stheraven typedef _CharT char_type; 571227825Stheraven typedef _Traits traits_type; 572227825Stheraven 573227825Stheraven typedef typename traits_type::int_type int_type; 574227825Stheraven typedef typename traits_type::pos_type pos_type; 575227825Stheraven typedef typename traits_type::off_type off_type; 576227825Stheraven 577227825Stheraven _LIBCPP_ALWAYS_INLINE // explicit 578227825Stheraven operator bool() const {return !fail();} 579227825Stheraven _LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();} 580227825Stheraven _LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();} 581227825Stheraven _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);} 582227825Stheraven _LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);} 583227825Stheraven _LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();} 584227825Stheraven _LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();} 585227825Stheraven _LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();} 586227825Stheraven _LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();} 587227825Stheraven 588227825Stheraven _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();} 589227825Stheraven _LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);} 590227825Stheraven 591227825Stheraven // 27.5.4.1 Constructor/destructor: 592227825Stheraven _LIBCPP_INLINE_VISIBILITY 593227825Stheraven explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb); 594227825Stheraven virtual ~basic_ios(); 595227825Stheraven 596227825Stheraven // 27.5.4.2 Members: 597227825Stheraven _LIBCPP_INLINE_VISIBILITY 598227825Stheraven basic_ostream<char_type, traits_type>* tie() const; 599227825Stheraven _LIBCPP_INLINE_VISIBILITY 600227825Stheraven basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr); 601227825Stheraven 602227825Stheraven _LIBCPP_INLINE_VISIBILITY 603227825Stheraven basic_streambuf<char_type, traits_type>* rdbuf() const; 604227825Stheraven _LIBCPP_INLINE_VISIBILITY 605227825Stheraven basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb); 606227825Stheraven 607227825Stheraven basic_ios& copyfmt(const basic_ios& __rhs); 608227825Stheraven 609227825Stheraven _LIBCPP_INLINE_VISIBILITY 610227825Stheraven char_type fill() const; 611227825Stheraven _LIBCPP_INLINE_VISIBILITY 612227825Stheraven char_type fill(char_type __ch); 613227825Stheraven 614227825Stheraven _LIBCPP_INLINE_VISIBILITY 615227825Stheraven locale imbue(const locale& __loc); 616227825Stheraven 617227825Stheraven _LIBCPP_INLINE_VISIBILITY 618227825Stheraven char narrow(char_type __c, char __dfault) const; 619227825Stheraven _LIBCPP_INLINE_VISIBILITY 620227825Stheraven char_type widen(char __c) const; 621227825Stheraven 622227825Stheravenprotected: 623227825Stheraven _LIBCPP_ALWAYS_INLINE 624227825Stheraven basic_ios() {// purposefully does no initialization 625227825Stheraven } 626227825Stheraven _LIBCPP_INLINE_VISIBILITY 627227825Stheraven void init(basic_streambuf<char_type, traits_type>* __sb); 628227825Stheraven 629227825Stheraven _LIBCPP_INLINE_VISIBILITY 630227825Stheraven void move(basic_ios& __rhs); 631227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 632227825Stheraven _LIBCPP_ALWAYS_INLINE 633227825Stheraven void move(basic_ios&& __rhs) {move(__rhs);} 634227825Stheraven#endif 635227825Stheraven _LIBCPP_INLINE_VISIBILITY 636227825Stheraven void swap(basic_ios& __rhs); 637227825Stheraven _LIBCPP_INLINE_VISIBILITY 638227825Stheraven void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb); 639227825Stheravenprivate: 640227825Stheraven basic_ostream<char_type, traits_type>* __tie_; 641227825Stheraven char_type __fill_; 642227825Stheraven}; 643227825Stheraven 644227825Stheraventemplate <class _CharT, class _Traits> 645227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 646227825Stheravenbasic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb) 647227825Stheraven{ 648227825Stheraven init(__sb); 649227825Stheraven} 650227825Stheraven 651227825Stheraventemplate <class _CharT, class _Traits> 652227825Stheravenbasic_ios<_CharT, _Traits>::~basic_ios() 653227825Stheraven{ 654227825Stheraven} 655227825Stheraven 656227825Stheraventemplate <class _CharT, class _Traits> 657227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 658227825Stheravenvoid 659227825Stheravenbasic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) 660227825Stheraven{ 661227825Stheraven ios_base::init(__sb); 662227825Stheraven __tie_ = 0; 663227825Stheraven __fill_ = widen(' '); 664227825Stheraven} 665227825Stheraven 666227825Stheraventemplate <class _CharT, class _Traits> 667227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 668227825Stheravenbasic_ostream<_CharT, _Traits>* 669227825Stheravenbasic_ios<_CharT, _Traits>::tie() const 670227825Stheraven{ 671227825Stheraven return __tie_; 672227825Stheraven} 673227825Stheraven 674227825Stheraventemplate <class _CharT, class _Traits> 675227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 676227825Stheravenbasic_ostream<_CharT, _Traits>* 677227825Stheravenbasic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) 678227825Stheraven{ 679227825Stheraven basic_ostream<char_type, traits_type>* __r = __tie_; 680227825Stheraven __tie_ = __tiestr; 681227825Stheraven return __r; 682227825Stheraven} 683227825Stheraven 684227825Stheraventemplate <class _CharT, class _Traits> 685227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 686227825Stheravenbasic_streambuf<_CharT, _Traits>* 687227825Stheravenbasic_ios<_CharT, _Traits>::rdbuf() const 688227825Stheraven{ 689227825Stheraven return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf()); 690227825Stheraven} 691227825Stheraven 692227825Stheraventemplate <class _CharT, class _Traits> 693227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 694227825Stheravenbasic_streambuf<_CharT, _Traits>* 695227825Stheravenbasic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) 696227825Stheraven{ 697227825Stheraven basic_streambuf<char_type, traits_type>* __r = rdbuf(); 698227825Stheraven ios_base::rdbuf(__sb); 699227825Stheraven return __r; 700227825Stheraven} 701227825Stheraven 702227825Stheraventemplate <class _CharT, class _Traits> 703227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 704227825Stheravenlocale 705227825Stheravenbasic_ios<_CharT, _Traits>::imbue(const locale& __loc) 706227825Stheraven{ 707227825Stheraven locale __r = getloc(); 708227825Stheraven ios_base::imbue(__loc); 709227825Stheraven if (rdbuf()) 710227825Stheraven rdbuf()->pubimbue(__loc); 711227825Stheraven return __r; 712227825Stheraven} 713227825Stheraven 714227825Stheraventemplate <class _CharT, class _Traits> 715227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 716227825Stheravenchar 717227825Stheravenbasic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const 718227825Stheraven{ 719227825Stheraven return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault); 720227825Stheraven} 721227825Stheraven 722227825Stheraventemplate <class _CharT, class _Traits> 723227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 724227825Stheraven_CharT 725227825Stheravenbasic_ios<_CharT, _Traits>::widen(char __c) const 726227825Stheraven{ 727227825Stheraven return use_facet<ctype<char_type> >(getloc()).widen(__c); 728227825Stheraven} 729227825Stheraven 730227825Stheraventemplate <class _CharT, class _Traits> 731227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 732227825Stheraven_CharT 733227825Stheravenbasic_ios<_CharT, _Traits>::fill() const 734227825Stheraven{ 735227825Stheraven return __fill_; 736227825Stheraven} 737227825Stheraven 738227825Stheraventemplate <class _CharT, class _Traits> 739227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 740227825Stheraven_CharT 741227825Stheravenbasic_ios<_CharT, _Traits>::fill(char_type __ch) 742227825Stheraven{ 743227825Stheraven char_type __r = __fill_; 744227825Stheraven __fill_ = __ch; 745227825Stheraven return __r; 746227825Stheraven} 747227825Stheraven 748227825Stheraventemplate <class _CharT, class _Traits> 749227825Stheravenbasic_ios<_CharT, _Traits>& 750227825Stheravenbasic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) 751227825Stheraven{ 752227825Stheraven if (this != &__rhs) 753227825Stheraven { 754227825Stheraven __call_callbacks(erase_event); 755227825Stheraven ios_base::copyfmt(__rhs); 756227825Stheraven __tie_ = __rhs.__tie_; 757227825Stheraven __fill_ = __rhs.__fill_; 758227825Stheraven __call_callbacks(copyfmt_event); 759227825Stheraven exceptions(__rhs.exceptions()); 760227825Stheraven } 761227825Stheraven return *this; 762227825Stheraven} 763227825Stheraven 764227825Stheraventemplate <class _CharT, class _Traits> 765227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 766227825Stheravenvoid 767227825Stheravenbasic_ios<_CharT, _Traits>::move(basic_ios& __rhs) 768227825Stheraven{ 769227825Stheraven ios_base::move(__rhs); 770227825Stheraven __tie_ = __rhs.__tie_; 771227825Stheraven __rhs.__tie_ = 0; 772227825Stheraven __fill_ = __rhs.__fill_; 773227825Stheraven} 774227825Stheraven 775227825Stheraventemplate <class _CharT, class _Traits> 776227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 777227825Stheravenvoid 778227825Stheravenbasic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) 779227825Stheraven{ 780227825Stheraven ios_base::swap(__rhs); 781227825Stheraven _VSTD::swap(__tie_, __rhs.__tie_); 782227825Stheraven _VSTD::swap(__fill_, __rhs.__fill_); 783227825Stheraven} 784227825Stheraven 785227825Stheraventemplate <class _CharT, class _Traits> 786227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 787227825Stheravenvoid 788227825Stheravenbasic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) 789227825Stheraven{ 790227825Stheraven ios_base::set_rdbuf(__sb); 791227825Stheraven} 792227825Stheraven 793227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 794227825Stheravenios_base& 795227825Stheravenboolalpha(ios_base& __str) 796227825Stheraven{ 797227825Stheraven __str.setf(ios_base::boolalpha); 798227825Stheraven return __str; 799227825Stheraven} 800227825Stheraven 801227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 802227825Stheravenios_base& 803227825Stheravennoboolalpha(ios_base& __str) 804227825Stheraven{ 805227825Stheraven __str.unsetf(ios_base::boolalpha); 806227825Stheraven return __str; 807227825Stheraven} 808227825Stheraven 809227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 810227825Stheravenios_base& 811227825Stheravenshowbase(ios_base& __str) 812227825Stheraven{ 813227825Stheraven __str.setf(ios_base::showbase); 814227825Stheraven return __str; 815227825Stheraven} 816227825Stheraven 817227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 818227825Stheravenios_base& 819227825Stheravennoshowbase(ios_base& __str) 820227825Stheraven{ 821227825Stheraven __str.unsetf(ios_base::showbase); 822227825Stheraven return __str; 823227825Stheraven} 824227825Stheraven 825227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 826227825Stheravenios_base& 827227825Stheravenshowpoint(ios_base& __str) 828227825Stheraven{ 829227825Stheraven __str.setf(ios_base::showpoint); 830227825Stheraven return __str; 831227825Stheraven} 832227825Stheraven 833227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 834227825Stheravenios_base& 835227825Stheravennoshowpoint(ios_base& __str) 836227825Stheraven{ 837227825Stheraven __str.unsetf(ios_base::showpoint); 838227825Stheraven return __str; 839227825Stheraven} 840227825Stheraven 841227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 842227825Stheravenios_base& 843227825Stheravenshowpos(ios_base& __str) 844227825Stheraven{ 845227825Stheraven __str.setf(ios_base::showpos); 846227825Stheraven return __str; 847227825Stheraven} 848227825Stheraven 849227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 850227825Stheravenios_base& 851227825Stheravennoshowpos(ios_base& __str) 852227825Stheraven{ 853227825Stheraven __str.unsetf(ios_base::showpos); 854227825Stheraven return __str; 855227825Stheraven} 856227825Stheraven 857227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 858227825Stheravenios_base& 859227825Stheravenskipws(ios_base& __str) 860227825Stheraven{ 861227825Stheraven __str.setf(ios_base::skipws); 862227825Stheraven return __str; 863227825Stheraven} 864227825Stheraven 865227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 866227825Stheravenios_base& 867227825Stheravennoskipws(ios_base& __str) 868227825Stheraven{ 869227825Stheraven __str.unsetf(ios_base::skipws); 870227825Stheraven return __str; 871227825Stheraven} 872227825Stheraven 873227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 874227825Stheravenios_base& 875227825Stheravenuppercase(ios_base& __str) 876227825Stheraven{ 877227825Stheraven __str.setf(ios_base::uppercase); 878227825Stheraven return __str; 879227825Stheraven} 880227825Stheraven 881227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 882227825Stheravenios_base& 883227825Stheravennouppercase(ios_base& __str) 884227825Stheraven{ 885227825Stheraven __str.unsetf(ios_base::uppercase); 886227825Stheraven return __str; 887227825Stheraven} 888227825Stheraven 889227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 890227825Stheravenios_base& 891227825Stheravenunitbuf(ios_base& __str) 892227825Stheraven{ 893227825Stheraven __str.setf(ios_base::unitbuf); 894227825Stheraven return __str; 895227825Stheraven} 896227825Stheraven 897227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 898227825Stheravenios_base& 899227825Stheravennounitbuf(ios_base& __str) 900227825Stheraven{ 901227825Stheraven __str.unsetf(ios_base::unitbuf); 902227825Stheraven return __str; 903227825Stheraven} 904227825Stheraven 905227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 906227825Stheravenios_base& 907227825Stheraveninternal(ios_base& __str) 908227825Stheraven{ 909227825Stheraven __str.setf(ios_base::internal, ios_base::adjustfield); 910227825Stheraven return __str; 911227825Stheraven} 912227825Stheraven 913227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 914227825Stheravenios_base& 915227825Stheravenleft(ios_base& __str) 916227825Stheraven{ 917227825Stheraven __str.setf(ios_base::left, ios_base::adjustfield); 918227825Stheraven return __str; 919227825Stheraven} 920227825Stheraven 921227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 922227825Stheravenios_base& 923227825Stheravenright(ios_base& __str) 924227825Stheraven{ 925227825Stheraven __str.setf(ios_base::right, ios_base::adjustfield); 926227825Stheraven return __str; 927227825Stheraven} 928227825Stheraven 929227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 930227825Stheravenios_base& 931227825Stheravendec(ios_base& __str) 932227825Stheraven{ 933227825Stheraven __str.setf(ios_base::dec, ios_base::basefield); 934227825Stheraven return __str; 935227825Stheraven} 936227825Stheraven 937227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 938227825Stheravenios_base& 939227825Stheravenhex(ios_base& __str) 940227825Stheraven{ 941227825Stheraven __str.setf(ios_base::hex, ios_base::basefield); 942227825Stheraven return __str; 943227825Stheraven} 944227825Stheraven 945227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 946227825Stheravenios_base& 947227825Stheravenoct(ios_base& __str) 948227825Stheraven{ 949227825Stheraven __str.setf(ios_base::oct, ios_base::basefield); 950227825Stheraven return __str; 951227825Stheraven} 952227825Stheraven 953227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 954227825Stheravenios_base& 955227825Stheravenfixed(ios_base& __str) 956227825Stheraven{ 957227825Stheraven __str.setf(ios_base::fixed, ios_base::floatfield); 958227825Stheraven return __str; 959227825Stheraven} 960227825Stheraven 961227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 962227825Stheravenios_base& 963227825Stheravenscientific(ios_base& __str) 964227825Stheraven{ 965227825Stheraven __str.setf(ios_base::scientific, ios_base::floatfield); 966227825Stheraven return __str; 967227825Stheraven} 968227825Stheraven 969227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 970227825Stheravenios_base& 971227825Stheravenhexfloat(ios_base& __str) 972227825Stheraven{ 973227825Stheraven __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); 974227825Stheraven return __str; 975227825Stheraven} 976227825Stheraven 977227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 978227825Stheravenios_base& 979227825Stheravendefaultfloat(ios_base& __str) 980227825Stheraven{ 981227825Stheraven __str.unsetf(ios_base::floatfield); 982227825Stheraven return __str; 983227825Stheraven} 984227825Stheraven 985227825Stheraven_LIBCPP_END_NAMESPACE_STD 986227825Stheraven 987227825Stheraven#endif // _LIBCPP_IOS 988