ios revision 232950
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 376232950Stheraven_LIBCPP_DECLARE_STRONG_ENUM(io_errc) 377227825Stheraven{ 378227825Stheraven stream = 1 379227825Stheraven}; 380232950Stheraven_LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) 381227825Stheraven 382227825Stheraventemplate <> 383227825Stheravenstruct _LIBCPP_VISIBLE is_error_code_enum<io_errc> : public true_type { }; 384232950Stheraven 385232950Stheraven#ifdef _LIBCPP_HAS_NO_STRONG_ENUMS 386227825Stheraventemplate <> 387227825Stheravenstruct _LIBCPP_VISIBLE is_error_code_enum<io_errc::_> : public true_type { }; 388232950Stheraven#endif 389227825Stheraven 390227825Stheraven_LIBCPP_VISIBLE 391227825Stheravenconst error_category& iostream_category(); 392227825Stheraven 393227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 394227825Stheravenerror_code 395227825Stheravenmake_error_code(io_errc __e) 396227825Stheraven{ 397227825Stheraven return error_code(static_cast<int>(__e), iostream_category()); 398227825Stheraven} 399227825Stheraven 400227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 401227825Stheravenerror_condition 402227825Stheravenmake_error_condition(io_errc __e) 403227825Stheraven{ 404227825Stheraven return error_condition(static_cast<int>(__e), iostream_category()); 405227825Stheraven} 406227825Stheraven 407227825Stheravenclass _LIBCPP_EXCEPTION_ABI ios_base::failure 408227825Stheraven : public system_error 409227825Stheraven{ 410227825Stheravenpublic: 411227825Stheraven explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); 412227825Stheraven explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); 413227825Stheraven virtual ~failure() throw(); 414227825Stheraven}; 415227825Stheraven 416227825Stheravenclass _LIBCPP_VISIBLE ios_base::Init 417227825Stheraven{ 418227825Stheravenpublic: 419227825Stheraven Init(); 420227825Stheraven ~Init(); 421227825Stheraven}; 422227825Stheraven 423227825Stheraven// fmtflags 424227825Stheraven 425227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 426227825Stheravenios_base::fmtflags 427227825Stheravenios_base::flags() const 428227825Stheraven{ 429227825Stheraven return __fmtflags_; 430227825Stheraven} 431227825Stheraven 432227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 433227825Stheravenios_base::fmtflags 434227825Stheravenios_base::flags(fmtflags __fmtfl) 435227825Stheraven{ 436227825Stheraven fmtflags __r = __fmtflags_; 437227825Stheraven __fmtflags_ = __fmtfl; 438227825Stheraven return __r; 439227825Stheraven} 440227825Stheraven 441227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 442227825Stheravenios_base::fmtflags 443227825Stheravenios_base::setf(fmtflags __fmtfl) 444227825Stheraven{ 445227825Stheraven fmtflags __r = __fmtflags_; 446227825Stheraven __fmtflags_ |= __fmtfl; 447227825Stheraven return __r; 448227825Stheraven} 449227825Stheraven 450227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 451227825Stheravenvoid 452227825Stheravenios_base::unsetf(fmtflags __mask) 453227825Stheraven{ 454227825Stheraven __fmtflags_ &= ~__mask; 455227825Stheraven} 456227825Stheraven 457227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 458227825Stheravenios_base::fmtflags 459227825Stheravenios_base::setf(fmtflags __fmtfl, fmtflags __mask) 460227825Stheraven{ 461227825Stheraven fmtflags __r = __fmtflags_; 462227825Stheraven unsetf(__mask); 463227825Stheraven __fmtflags_ |= __fmtfl & __mask; 464227825Stheraven return __r; 465227825Stheraven} 466227825Stheraven 467227825Stheraven// precision 468227825Stheraven 469227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 470227825Stheravenstreamsize 471227825Stheravenios_base::precision() const 472227825Stheraven{ 473227825Stheraven return __precision_; 474227825Stheraven} 475227825Stheraven 476227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 477227825Stheravenstreamsize 478227825Stheravenios_base::precision(streamsize __prec) 479227825Stheraven{ 480227825Stheraven streamsize __r = __precision_; 481227825Stheraven __precision_ = __prec; 482227825Stheraven return __r; 483227825Stheraven} 484227825Stheraven 485227825Stheraven// width 486227825Stheraven 487227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 488227825Stheravenstreamsize 489227825Stheravenios_base::width() const 490227825Stheraven{ 491227825Stheraven return __width_; 492227825Stheraven} 493227825Stheraven 494227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 495227825Stheravenstreamsize 496227825Stheravenios_base::width(streamsize __wide) 497227825Stheraven{ 498227825Stheraven streamsize __r = __width_; 499227825Stheraven __width_ = __wide; 500227825Stheraven return __r; 501227825Stheraven} 502227825Stheraven 503227825Stheraven// iostate 504227825Stheraven 505227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 506227825Stheravenios_base::iostate 507227825Stheravenios_base::rdstate() const 508227825Stheraven{ 509227825Stheraven return __rdstate_; 510227825Stheraven} 511227825Stheraven 512227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 513227825Stheravenvoid 514227825Stheravenios_base::setstate(iostate __state) 515227825Stheraven{ 516227825Stheraven clear(__rdstate_ | __state); 517227825Stheraven} 518227825Stheraven 519227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 520227825Stheravenbool 521227825Stheravenios_base::good() const 522227825Stheraven{ 523227825Stheraven return __rdstate_ == 0; 524227825Stheraven} 525227825Stheraven 526227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 527227825Stheravenbool 528227825Stheravenios_base::eof() const 529227825Stheraven{ 530227825Stheraven return __rdstate_ & eofbit; 531227825Stheraven} 532227825Stheraven 533227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 534227825Stheravenbool 535227825Stheravenios_base::fail() const 536227825Stheraven{ 537227825Stheraven return __rdstate_ & (failbit | badbit); 538227825Stheraven} 539227825Stheraven 540227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 541227825Stheravenbool 542227825Stheravenios_base::bad() const 543227825Stheraven{ 544227825Stheraven return __rdstate_ & badbit; 545227825Stheraven} 546227825Stheraven 547227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 548227825Stheravenios_base::iostate 549227825Stheravenios_base::exceptions() const 550227825Stheraven{ 551227825Stheraven return __exceptions_; 552227825Stheraven} 553227825Stheraven 554227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 555227825Stheravenvoid 556227825Stheravenios_base::exceptions(iostate __except) 557227825Stheraven{ 558227825Stheraven __exceptions_ = __except; 559227825Stheraven clear(__rdstate_); 560227825Stheraven} 561227825Stheraven 562227825Stheraventemplate <class _CharT, class _Traits> 563227825Stheravenclass _LIBCPP_VISIBLE basic_ios 564227825Stheraven : public ios_base 565227825Stheraven{ 566227825Stheravenpublic: 567227825Stheraven // types: 568227825Stheraven typedef _CharT char_type; 569227825Stheraven typedef _Traits traits_type; 570227825Stheraven 571227825Stheraven typedef typename traits_type::int_type int_type; 572227825Stheraven typedef typename traits_type::pos_type pos_type; 573227825Stheraven typedef typename traits_type::off_type off_type; 574227825Stheraven 575232950Stheraven _LIBCPP_ALWAYS_INLINE 576232950Stheraven _LIBCPP_EXPLICIT 577227825Stheraven operator bool() const {return !fail();} 578227825Stheraven _LIBCPP_ALWAYS_INLINE bool operator!() const {return fail();} 579227825Stheraven _LIBCPP_ALWAYS_INLINE iostate rdstate() const {return ios_base::rdstate();} 580227825Stheraven _LIBCPP_ALWAYS_INLINE void clear(iostate __state = goodbit) {ios_base::clear(__state);} 581227825Stheraven _LIBCPP_ALWAYS_INLINE void setstate(iostate __state) {ios_base::setstate(__state);} 582227825Stheraven _LIBCPP_ALWAYS_INLINE bool good() const {return ios_base::good();} 583227825Stheraven _LIBCPP_ALWAYS_INLINE bool eof() const {return ios_base::eof();} 584227825Stheraven _LIBCPP_ALWAYS_INLINE bool fail() const {return ios_base::fail();} 585227825Stheraven _LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();} 586227825Stheraven 587227825Stheraven _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();} 588227825Stheraven _LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);} 589227825Stheraven 590227825Stheraven // 27.5.4.1 Constructor/destructor: 591227825Stheraven _LIBCPP_INLINE_VISIBILITY 592227825Stheraven explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb); 593227825Stheraven virtual ~basic_ios(); 594227825Stheraven 595227825Stheraven // 27.5.4.2 Members: 596227825Stheraven _LIBCPP_INLINE_VISIBILITY 597227825Stheraven basic_ostream<char_type, traits_type>* tie() const; 598227825Stheraven _LIBCPP_INLINE_VISIBILITY 599227825Stheraven basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr); 600227825Stheraven 601227825Stheraven _LIBCPP_INLINE_VISIBILITY 602227825Stheraven basic_streambuf<char_type, traits_type>* rdbuf() const; 603227825Stheraven _LIBCPP_INLINE_VISIBILITY 604227825Stheraven basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb); 605227825Stheraven 606227825Stheraven basic_ios& copyfmt(const basic_ios& __rhs); 607227825Stheraven 608227825Stheraven _LIBCPP_INLINE_VISIBILITY 609227825Stheraven char_type fill() const; 610227825Stheraven _LIBCPP_INLINE_VISIBILITY 611227825Stheraven char_type fill(char_type __ch); 612227825Stheraven 613227825Stheraven _LIBCPP_INLINE_VISIBILITY 614227825Stheraven locale imbue(const locale& __loc); 615227825Stheraven 616227825Stheraven _LIBCPP_INLINE_VISIBILITY 617227825Stheraven char narrow(char_type __c, char __dfault) const; 618227825Stheraven _LIBCPP_INLINE_VISIBILITY 619227825Stheraven char_type widen(char __c) const; 620227825Stheraven 621227825Stheravenprotected: 622227825Stheraven _LIBCPP_ALWAYS_INLINE 623227825Stheraven basic_ios() {// purposefully does no initialization 624227825Stheraven } 625227825Stheraven _LIBCPP_INLINE_VISIBILITY 626227825Stheraven void init(basic_streambuf<char_type, traits_type>* __sb); 627227825Stheraven 628227825Stheraven _LIBCPP_INLINE_VISIBILITY 629227825Stheraven void move(basic_ios& __rhs); 630227825Stheraven#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 631227825Stheraven _LIBCPP_ALWAYS_INLINE 632227825Stheraven void move(basic_ios&& __rhs) {move(__rhs);} 633227825Stheraven#endif 634227825Stheraven _LIBCPP_INLINE_VISIBILITY 635227825Stheraven void swap(basic_ios& __rhs); 636227825Stheraven _LIBCPP_INLINE_VISIBILITY 637227825Stheraven void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb); 638227825Stheravenprivate: 639227825Stheraven basic_ostream<char_type, traits_type>* __tie_; 640227825Stheraven char_type __fill_; 641227825Stheraven}; 642227825Stheraven 643227825Stheraventemplate <class _CharT, class _Traits> 644227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 645227825Stheravenbasic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb) 646227825Stheraven{ 647227825Stheraven init(__sb); 648227825Stheraven} 649227825Stheraven 650227825Stheraventemplate <class _CharT, class _Traits> 651227825Stheravenbasic_ios<_CharT, _Traits>::~basic_ios() 652227825Stheraven{ 653227825Stheraven} 654227825Stheraven 655227825Stheraventemplate <class _CharT, class _Traits> 656227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 657227825Stheravenvoid 658227825Stheravenbasic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) 659227825Stheraven{ 660227825Stheraven ios_base::init(__sb); 661227825Stheraven __tie_ = 0; 662227825Stheraven __fill_ = widen(' '); 663227825Stheraven} 664227825Stheraven 665227825Stheraventemplate <class _CharT, class _Traits> 666227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 667227825Stheravenbasic_ostream<_CharT, _Traits>* 668227825Stheravenbasic_ios<_CharT, _Traits>::tie() const 669227825Stheraven{ 670227825Stheraven return __tie_; 671227825Stheraven} 672227825Stheraven 673227825Stheraventemplate <class _CharT, class _Traits> 674227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 675227825Stheravenbasic_ostream<_CharT, _Traits>* 676227825Stheravenbasic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) 677227825Stheraven{ 678227825Stheraven basic_ostream<char_type, traits_type>* __r = __tie_; 679227825Stheraven __tie_ = __tiestr; 680227825Stheraven return __r; 681227825Stheraven} 682227825Stheraven 683227825Stheraventemplate <class _CharT, class _Traits> 684227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 685227825Stheravenbasic_streambuf<_CharT, _Traits>* 686227825Stheravenbasic_ios<_CharT, _Traits>::rdbuf() const 687227825Stheraven{ 688227825Stheraven return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf()); 689227825Stheraven} 690227825Stheraven 691227825Stheraventemplate <class _CharT, class _Traits> 692227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 693227825Stheravenbasic_streambuf<_CharT, _Traits>* 694227825Stheravenbasic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) 695227825Stheraven{ 696227825Stheraven basic_streambuf<char_type, traits_type>* __r = rdbuf(); 697227825Stheraven ios_base::rdbuf(__sb); 698227825Stheraven return __r; 699227825Stheraven} 700227825Stheraven 701227825Stheraventemplate <class _CharT, class _Traits> 702227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 703227825Stheravenlocale 704227825Stheravenbasic_ios<_CharT, _Traits>::imbue(const locale& __loc) 705227825Stheraven{ 706227825Stheraven locale __r = getloc(); 707227825Stheraven ios_base::imbue(__loc); 708227825Stheraven if (rdbuf()) 709227825Stheraven rdbuf()->pubimbue(__loc); 710227825Stheraven return __r; 711227825Stheraven} 712227825Stheraven 713227825Stheraventemplate <class _CharT, class _Traits> 714227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 715227825Stheravenchar 716227825Stheravenbasic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const 717227825Stheraven{ 718227825Stheraven return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault); 719227825Stheraven} 720227825Stheraven 721227825Stheraventemplate <class _CharT, class _Traits> 722227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 723227825Stheraven_CharT 724227825Stheravenbasic_ios<_CharT, _Traits>::widen(char __c) const 725227825Stheraven{ 726227825Stheraven return use_facet<ctype<char_type> >(getloc()).widen(__c); 727227825Stheraven} 728227825Stheraven 729227825Stheraventemplate <class _CharT, class _Traits> 730227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 731227825Stheraven_CharT 732227825Stheravenbasic_ios<_CharT, _Traits>::fill() const 733227825Stheraven{ 734227825Stheraven return __fill_; 735227825Stheraven} 736227825Stheraven 737227825Stheraventemplate <class _CharT, class _Traits> 738227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 739227825Stheraven_CharT 740227825Stheravenbasic_ios<_CharT, _Traits>::fill(char_type __ch) 741227825Stheraven{ 742227825Stheraven char_type __r = __fill_; 743227825Stheraven __fill_ = __ch; 744227825Stheraven return __r; 745227825Stheraven} 746227825Stheraven 747227825Stheraventemplate <class _CharT, class _Traits> 748227825Stheravenbasic_ios<_CharT, _Traits>& 749227825Stheravenbasic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) 750227825Stheraven{ 751227825Stheraven if (this != &__rhs) 752227825Stheraven { 753227825Stheraven __call_callbacks(erase_event); 754227825Stheraven ios_base::copyfmt(__rhs); 755227825Stheraven __tie_ = __rhs.__tie_; 756227825Stheraven __fill_ = __rhs.__fill_; 757227825Stheraven __call_callbacks(copyfmt_event); 758227825Stheraven exceptions(__rhs.exceptions()); 759227825Stheraven } 760227825Stheraven return *this; 761227825Stheraven} 762227825Stheraven 763227825Stheraventemplate <class _CharT, class _Traits> 764227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 765227825Stheravenvoid 766227825Stheravenbasic_ios<_CharT, _Traits>::move(basic_ios& __rhs) 767227825Stheraven{ 768227825Stheraven ios_base::move(__rhs); 769227825Stheraven __tie_ = __rhs.__tie_; 770227825Stheraven __rhs.__tie_ = 0; 771227825Stheraven __fill_ = __rhs.__fill_; 772227825Stheraven} 773227825Stheraven 774227825Stheraventemplate <class _CharT, class _Traits> 775227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 776227825Stheravenvoid 777227825Stheravenbasic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) 778227825Stheraven{ 779227825Stheraven ios_base::swap(__rhs); 780227825Stheraven _VSTD::swap(__tie_, __rhs.__tie_); 781227825Stheraven _VSTD::swap(__fill_, __rhs.__fill_); 782227825Stheraven} 783227825Stheraven 784227825Stheraventemplate <class _CharT, class _Traits> 785227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 786227825Stheravenvoid 787227825Stheravenbasic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) 788227825Stheraven{ 789227825Stheraven ios_base::set_rdbuf(__sb); 790227825Stheraven} 791227825Stheraven 792227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 793227825Stheravenios_base& 794227825Stheravenboolalpha(ios_base& __str) 795227825Stheraven{ 796227825Stheraven __str.setf(ios_base::boolalpha); 797227825Stheraven return __str; 798227825Stheraven} 799227825Stheraven 800227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 801227825Stheravenios_base& 802227825Stheravennoboolalpha(ios_base& __str) 803227825Stheraven{ 804227825Stheraven __str.unsetf(ios_base::boolalpha); 805227825Stheraven return __str; 806227825Stheraven} 807227825Stheraven 808227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 809227825Stheravenios_base& 810227825Stheravenshowbase(ios_base& __str) 811227825Stheraven{ 812227825Stheraven __str.setf(ios_base::showbase); 813227825Stheraven return __str; 814227825Stheraven} 815227825Stheraven 816227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 817227825Stheravenios_base& 818227825Stheravennoshowbase(ios_base& __str) 819227825Stheraven{ 820227825Stheraven __str.unsetf(ios_base::showbase); 821227825Stheraven return __str; 822227825Stheraven} 823227825Stheraven 824227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 825227825Stheravenios_base& 826227825Stheravenshowpoint(ios_base& __str) 827227825Stheraven{ 828227825Stheraven __str.setf(ios_base::showpoint); 829227825Stheraven return __str; 830227825Stheraven} 831227825Stheraven 832227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 833227825Stheravenios_base& 834227825Stheravennoshowpoint(ios_base& __str) 835227825Stheraven{ 836227825Stheraven __str.unsetf(ios_base::showpoint); 837227825Stheraven return __str; 838227825Stheraven} 839227825Stheraven 840227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 841227825Stheravenios_base& 842227825Stheravenshowpos(ios_base& __str) 843227825Stheraven{ 844227825Stheraven __str.setf(ios_base::showpos); 845227825Stheraven return __str; 846227825Stheraven} 847227825Stheraven 848227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 849227825Stheravenios_base& 850227825Stheravennoshowpos(ios_base& __str) 851227825Stheraven{ 852227825Stheraven __str.unsetf(ios_base::showpos); 853227825Stheraven return __str; 854227825Stheraven} 855227825Stheraven 856227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 857227825Stheravenios_base& 858227825Stheravenskipws(ios_base& __str) 859227825Stheraven{ 860227825Stheraven __str.setf(ios_base::skipws); 861227825Stheraven return __str; 862227825Stheraven} 863227825Stheraven 864227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 865227825Stheravenios_base& 866227825Stheravennoskipws(ios_base& __str) 867227825Stheraven{ 868227825Stheraven __str.unsetf(ios_base::skipws); 869227825Stheraven return __str; 870227825Stheraven} 871227825Stheraven 872227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 873227825Stheravenios_base& 874227825Stheravenuppercase(ios_base& __str) 875227825Stheraven{ 876227825Stheraven __str.setf(ios_base::uppercase); 877227825Stheraven return __str; 878227825Stheraven} 879227825Stheraven 880227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 881227825Stheravenios_base& 882227825Stheravennouppercase(ios_base& __str) 883227825Stheraven{ 884227825Stheraven __str.unsetf(ios_base::uppercase); 885227825Stheraven return __str; 886227825Stheraven} 887227825Stheraven 888227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 889227825Stheravenios_base& 890227825Stheravenunitbuf(ios_base& __str) 891227825Stheraven{ 892227825Stheraven __str.setf(ios_base::unitbuf); 893227825Stheraven return __str; 894227825Stheraven} 895227825Stheraven 896227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 897227825Stheravenios_base& 898227825Stheravennounitbuf(ios_base& __str) 899227825Stheraven{ 900227825Stheraven __str.unsetf(ios_base::unitbuf); 901227825Stheraven return __str; 902227825Stheraven} 903227825Stheraven 904227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 905227825Stheravenios_base& 906227825Stheraveninternal(ios_base& __str) 907227825Stheraven{ 908227825Stheraven __str.setf(ios_base::internal, ios_base::adjustfield); 909227825Stheraven return __str; 910227825Stheraven} 911227825Stheraven 912227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 913227825Stheravenios_base& 914227825Stheravenleft(ios_base& __str) 915227825Stheraven{ 916227825Stheraven __str.setf(ios_base::left, ios_base::adjustfield); 917227825Stheraven return __str; 918227825Stheraven} 919227825Stheraven 920227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 921227825Stheravenios_base& 922227825Stheravenright(ios_base& __str) 923227825Stheraven{ 924227825Stheraven __str.setf(ios_base::right, ios_base::adjustfield); 925227825Stheraven return __str; 926227825Stheraven} 927227825Stheraven 928227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 929227825Stheravenios_base& 930227825Stheravendec(ios_base& __str) 931227825Stheraven{ 932227825Stheraven __str.setf(ios_base::dec, ios_base::basefield); 933227825Stheraven return __str; 934227825Stheraven} 935227825Stheraven 936227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 937227825Stheravenios_base& 938227825Stheravenhex(ios_base& __str) 939227825Stheraven{ 940227825Stheraven __str.setf(ios_base::hex, ios_base::basefield); 941227825Stheraven return __str; 942227825Stheraven} 943227825Stheraven 944227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 945227825Stheravenios_base& 946227825Stheravenoct(ios_base& __str) 947227825Stheraven{ 948227825Stheraven __str.setf(ios_base::oct, ios_base::basefield); 949227825Stheraven return __str; 950227825Stheraven} 951227825Stheraven 952227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 953227825Stheravenios_base& 954227825Stheravenfixed(ios_base& __str) 955227825Stheraven{ 956227825Stheraven __str.setf(ios_base::fixed, ios_base::floatfield); 957227825Stheraven return __str; 958227825Stheraven} 959227825Stheraven 960227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 961227825Stheravenios_base& 962227825Stheravenscientific(ios_base& __str) 963227825Stheraven{ 964227825Stheraven __str.setf(ios_base::scientific, ios_base::floatfield); 965227825Stheraven return __str; 966227825Stheraven} 967227825Stheraven 968227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 969227825Stheravenios_base& 970227825Stheravenhexfloat(ios_base& __str) 971227825Stheraven{ 972227825Stheraven __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); 973227825Stheraven return __str; 974227825Stheraven} 975227825Stheraven 976227825Stheraveninline _LIBCPP_INLINE_VISIBILITY 977227825Stheravenios_base& 978227825Stheravendefaultfloat(ios_base& __str) 979227825Stheraven{ 980227825Stheraven __str.unsetf(ios_base::floatfield); 981227825Stheraven return __str; 982227825Stheraven} 983227825Stheraven 984227825Stheraven_LIBCPP_END_NAMESPACE_STD 985227825Stheraven 986227825Stheraven#endif // _LIBCPP_IOS 987