Warning, /include/c++/v1/__cxx03/ios is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP___CXX03_IOS
0011 #define _LIBCPP___CXX03_IOS
0012
0013 /*
0014 ios synopsis
0015
0016 #include <__cxx03/iosfwd>
0017
0018 namespace std
0019 {
0020
0021 typedef OFF_T streamoff;
0022 typedef SZ_T streamsize;
0023 template <class stateT> class fpos;
0024
0025 class ios_base
0026 {
0027 public:
0028 class failure;
0029
0030 typedef T1 fmtflags;
0031 static constexpr fmtflags boolalpha;
0032 static constexpr fmtflags dec;
0033 static constexpr fmtflags fixed;
0034 static constexpr fmtflags hex;
0035 static constexpr fmtflags internal;
0036 static constexpr fmtflags left;
0037 static constexpr fmtflags oct;
0038 static constexpr fmtflags right;
0039 static constexpr fmtflags scientific;
0040 static constexpr fmtflags showbase;
0041 static constexpr fmtflags showpoint;
0042 static constexpr fmtflags showpos;
0043 static constexpr fmtflags skipws;
0044 static constexpr fmtflags unitbuf;
0045 static constexpr fmtflags uppercase;
0046 static constexpr fmtflags adjustfield;
0047 static constexpr fmtflags basefield;
0048 static constexpr fmtflags floatfield;
0049
0050 typedef T2 iostate;
0051 static constexpr iostate badbit;
0052 static constexpr iostate eofbit;
0053 static constexpr iostate failbit;
0054 static constexpr iostate goodbit;
0055
0056 typedef T3 openmode;
0057 static constexpr openmode app;
0058 static constexpr openmode ate;
0059 static constexpr openmode binary;
0060 static constexpr openmode in;
0061 static constexpr openmode noreplace; // since C++23
0062 static constexpr openmode out;
0063 static constexpr openmode trunc;
0064
0065 typedef T4 seekdir;
0066 static constexpr seekdir beg;
0067 static constexpr seekdir cur;
0068 static constexpr seekdir end;
0069
0070 class Init;
0071
0072 // 27.5.2.2 fmtflags state:
0073 fmtflags flags() const;
0074 fmtflags flags(fmtflags fmtfl);
0075 fmtflags setf(fmtflags fmtfl);
0076 fmtflags setf(fmtflags fmtfl, fmtflags mask);
0077 void unsetf(fmtflags mask);
0078
0079 streamsize precision() const;
0080 streamsize precision(streamsize prec);
0081 streamsize width() const;
0082 streamsize width(streamsize wide);
0083
0084 // 27.5.2.3 locales:
0085 locale imbue(const locale& loc);
0086 locale getloc() const;
0087
0088 // 27.5.2.5 storage:
0089 static int xalloc();
0090 long& iword(int index);
0091 void*& pword(int index);
0092
0093 // destructor
0094 virtual ~ios_base();
0095
0096 // 27.5.2.6 callbacks;
0097 enum event { erase_event, imbue_event, copyfmt_event };
0098 typedef void (*event_callback)(event, ios_base&, int index);
0099 void register_callback(event_callback fn, int index);
0100
0101 ios_base(const ios_base&) = delete;
0102 ios_base& operator=(const ios_base&) = delete;
0103
0104 static bool sync_with_stdio(bool sync = true);
0105
0106 protected:
0107 ios_base();
0108 };
0109
0110 template <class charT, class traits = char_traits<charT> >
0111 class basic_ios
0112 : public ios_base
0113 {
0114 public:
0115 // types:
0116 typedef charT char_type;
0117 typedef typename traits::int_type int_type; // removed in C++17
0118 typedef typename traits::pos_type pos_type; // removed in C++17
0119 typedef typename traits::off_type off_type; // removed in C++17
0120 typedef traits traits_type;
0121
0122 operator unspecified-bool-type() const;
0123 bool operator!() const;
0124 iostate rdstate() const;
0125 void clear(iostate state = goodbit);
0126 void setstate(iostate state);
0127 bool good() const;
0128 bool eof() const;
0129 bool fail() const;
0130 bool bad() const;
0131
0132 iostate exceptions() const;
0133 void exceptions(iostate except);
0134
0135 // 27.5.4.1 Constructor/destructor:
0136 explicit basic_ios(basic_streambuf<charT,traits>* sb);
0137 virtual ~basic_ios();
0138
0139 // 27.5.4.2 Members:
0140 basic_ostream<charT,traits>* tie() const;
0141 basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr);
0142
0143 basic_streambuf<charT,traits>* rdbuf() const;
0144 basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb);
0145
0146 basic_ios& copyfmt(const basic_ios& rhs);
0147
0148 char_type fill() const;
0149 char_type fill(char_type ch);
0150
0151 locale imbue(const locale& loc);
0152
0153 char narrow(char_type c, char dfault) const;
0154 char_type widen(char c) const;
0155
0156 basic_ios(const basic_ios& ) = delete;
0157 basic_ios& operator=(const basic_ios&) = delete;
0158
0159 protected:
0160 basic_ios();
0161 void init(basic_streambuf<charT,traits>* sb);
0162 void move(basic_ios& rhs);
0163 void swap(basic_ios& rhs) noexcept;
0164 void set_rdbuf(basic_streambuf<charT, traits>* sb);
0165 };
0166
0167 // 27.5.5, manipulators:
0168 ios_base& boolalpha (ios_base& str);
0169 ios_base& noboolalpha(ios_base& str);
0170 ios_base& showbase (ios_base& str);
0171 ios_base& noshowbase (ios_base& str);
0172 ios_base& showpoint (ios_base& str);
0173 ios_base& noshowpoint(ios_base& str);
0174 ios_base& showpos (ios_base& str);
0175 ios_base& noshowpos (ios_base& str);
0176 ios_base& skipws (ios_base& str);
0177 ios_base& noskipws (ios_base& str);
0178 ios_base& uppercase (ios_base& str);
0179 ios_base& nouppercase(ios_base& str);
0180 ios_base& unitbuf (ios_base& str);
0181 ios_base& nounitbuf (ios_base& str);
0182
0183 // 27.5.5.2 adjustfield:
0184 ios_base& internal (ios_base& str);
0185 ios_base& left (ios_base& str);
0186 ios_base& right (ios_base& str);
0187
0188 // 27.5.5.3 basefield:
0189 ios_base& dec (ios_base& str);
0190 ios_base& hex (ios_base& str);
0191 ios_base& oct (ios_base& str);
0192
0193 // 27.5.5.4 floatfield:
0194 ios_base& fixed (ios_base& str);
0195 ios_base& scientific (ios_base& str);
0196 ios_base& hexfloat (ios_base& str);
0197 ios_base& defaultfloat(ios_base& str);
0198
0199 // 27.5.5.5 error reporting:
0200 enum class io_errc
0201 {
0202 stream = 1
0203 };
0204
0205 concept_map ErrorCodeEnum<io_errc> { };
0206 error_code make_error_code(io_errc e) noexcept;
0207 error_condition make_error_condition(io_errc e) noexcept;
0208 storage-class-specifier const error_category& iostream_category() noexcept;
0209
0210 } // std
0211
0212 */
0213
0214 #include <__cxx03/__config>
0215
0216 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
0217
0218 # include <__cxx03/__fwd/ios.h>
0219 # include <__cxx03/__ios/fpos.h>
0220 # include <__cxx03/__locale>
0221 # include <__cxx03/__system_error/error_category.h>
0222 # include <__cxx03/__system_error/error_code.h>
0223 # include <__cxx03/__system_error/error_condition.h>
0224 # include <__cxx03/__system_error/system_error.h>
0225 # include <__cxx03/__utility/swap.h>
0226 # include <__cxx03/__verbose_abort>
0227 # include <__cxx03/version>
0228
0229 // standard-mandated includes
0230
0231 // [ios.syn]
0232 # include <__cxx03/iosfwd>
0233
0234 # if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
0235 # include <__cxx03/__atomic/atomic.h> // for __xindex_
0236 # endif
0237
0238 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0239 # pragma GCC system_header
0240 # endif
0241
0242 _LIBCPP_PUSH_MACROS
0243 # include <__cxx03/__undef_macros>
0244
0245 _LIBCPP_BEGIN_NAMESPACE_STD
0246
0247 typedef ptrdiff_t streamsize;
0248
0249 class _LIBCPP_EXPORTED_FROM_ABI ios_base {
0250 public:
0251 class _LIBCPP_EXPORTED_FROM_ABI failure;
0252
0253 typedef unsigned int fmtflags;
0254 static const fmtflags boolalpha = 0x0001;
0255 static const fmtflags dec = 0x0002;
0256 static const fmtflags fixed = 0x0004;
0257 static const fmtflags hex = 0x0008;
0258 static const fmtflags internal = 0x0010;
0259 static const fmtflags left = 0x0020;
0260 static const fmtflags oct = 0x0040;
0261 static const fmtflags right = 0x0080;
0262 static const fmtflags scientific = 0x0100;
0263 static const fmtflags showbase = 0x0200;
0264 static const fmtflags showpoint = 0x0400;
0265 static const fmtflags showpos = 0x0800;
0266 static const fmtflags skipws = 0x1000;
0267 static const fmtflags unitbuf = 0x2000;
0268 static const fmtflags uppercase = 0x4000;
0269 static const fmtflags adjustfield = left | right | internal;
0270 static const fmtflags basefield = dec | oct | hex;
0271 static const fmtflags floatfield = scientific | fixed;
0272
0273 typedef unsigned int iostate;
0274 static const iostate badbit = 0x1;
0275 static const iostate eofbit = 0x2;
0276 static const iostate failbit = 0x4;
0277 static const iostate goodbit = 0x0;
0278
0279 typedef unsigned int openmode;
0280 static const openmode app = 0x01;
0281 static const openmode ate = 0x02;
0282 static const openmode binary = 0x04;
0283 static const openmode in = 0x08;
0284 static const openmode out = 0x10;
0285 static const openmode trunc = 0x20;
0286 # if _LIBCPP_STD_VER >= 23
0287 static const openmode noreplace = 0x40;
0288 # endif
0289
0290 enum seekdir { beg, cur, end };
0291
0292 # if _LIBCPP_STD_VER <= 14
0293 typedef iostate io_state;
0294 typedef openmode open_mode;
0295 typedef seekdir seek_dir;
0296
0297 typedef std::streamoff streamoff;
0298 typedef std::streampos streampos;
0299 # endif
0300
0301 class _LIBCPP_EXPORTED_FROM_ABI Init;
0302
0303 // 27.5.2.2 fmtflags state:
0304 _LIBCPP_HIDE_FROM_ABI fmtflags flags() const;
0305 _LIBCPP_HIDE_FROM_ABI fmtflags flags(fmtflags __fmtfl);
0306 _LIBCPP_HIDE_FROM_ABI fmtflags setf(fmtflags __fmtfl);
0307 _LIBCPP_HIDE_FROM_ABI fmtflags setf(fmtflags __fmtfl, fmtflags __mask);
0308 _LIBCPP_HIDE_FROM_ABI void unsetf(fmtflags __mask);
0309
0310 _LIBCPP_HIDE_FROM_ABI streamsize precision() const;
0311 _LIBCPP_HIDE_FROM_ABI streamsize precision(streamsize __prec);
0312 _LIBCPP_HIDE_FROM_ABI streamsize width() const;
0313 _LIBCPP_HIDE_FROM_ABI streamsize width(streamsize __wide);
0314
0315 // 27.5.2.3 locales:
0316 locale imbue(const locale& __loc);
0317 locale getloc() const;
0318
0319 // 27.5.2.5 storage:
0320 static int xalloc();
0321 long& iword(int __index);
0322 void*& pword(int __index);
0323
0324 // destructor
0325 virtual ~ios_base();
0326
0327 // 27.5.2.6 callbacks;
0328 enum event { erase_event, imbue_event, copyfmt_event };
0329 typedef void (*event_callback)(event, ios_base&, int __index);
0330 void register_callback(event_callback __fn, int __index);
0331
0332 ios_base(const ios_base&) = delete;
0333 ios_base& operator=(const ios_base&) = delete;
0334
0335 static bool sync_with_stdio(bool __sync = true);
0336
0337 _LIBCPP_HIDE_FROM_ABI iostate rdstate() const;
0338 void clear(iostate __state = goodbit);
0339 _LIBCPP_HIDE_FROM_ABI void setstate(iostate __state);
0340
0341 _LIBCPP_HIDE_FROM_ABI bool good() const;
0342 _LIBCPP_HIDE_FROM_ABI bool eof() const;
0343 _LIBCPP_HIDE_FROM_ABI bool fail() const;
0344 _LIBCPP_HIDE_FROM_ABI bool bad() const;
0345
0346 _LIBCPP_HIDE_FROM_ABI iostate exceptions() const;
0347 _LIBCPP_HIDE_FROM_ABI void exceptions(iostate __iostate);
0348
0349 void __set_badbit_and_consider_rethrow();
0350 void __set_failbit_and_consider_rethrow();
0351
0352 _LIBCPP_HIDE_FROM_ABI void __setstate_nothrow(iostate __state) {
0353 if (__rdbuf_)
0354 __rdstate_ |= __state;
0355 else
0356 __rdstate_ |= __state | ios_base::badbit;
0357 }
0358
0359 protected:
0360 _LIBCPP_HIDE_FROM_ABI ios_base() : __loc_(nullptr) {
0361 // Purposefully does no initialization
0362 //
0363 // Except for the locale, this is a sentinel to avoid destroying
0364 // an uninitialized object. See
0365 // test/libcxx/input.output/iostreams.base/ios.base/ios.base.cons/dtor.uninitialized.pass.cpp
0366 // for the details.
0367 }
0368
0369 void init(void* __sb);
0370 _LIBCPP_HIDE_FROM_ABI void* rdbuf() const { return __rdbuf_; }
0371
0372 _LIBCPP_HIDE_FROM_ABI void rdbuf(void* __sb) {
0373 __rdbuf_ = __sb;
0374 clear();
0375 }
0376
0377 void __call_callbacks(event);
0378 void copyfmt(const ios_base&);
0379 void move(ios_base&);
0380 void swap(ios_base&) _NOEXCEPT;
0381
0382 _LIBCPP_HIDE_FROM_ABI void set_rdbuf(void* __sb) { __rdbuf_ = __sb; }
0383
0384 private:
0385 // All data members must be scalars
0386 fmtflags __fmtflags_;
0387 streamsize __precision_;
0388 streamsize __width_;
0389 iostate __rdstate_;
0390 iostate __exceptions_;
0391 void* __rdbuf_;
0392 void* __loc_;
0393 event_callback* __fn_;
0394 int* __index_;
0395 size_t __event_size_;
0396 size_t __event_cap_;
0397 // TODO(EricWF): Enable this for both Clang and GCC. Currently it is only
0398 // enabled with clang.
0399 # if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
0400 static atomic<int> __xindex_;
0401 # else
0402 static int __xindex_;
0403 # endif
0404 long* __iarray_;
0405 size_t __iarray_size_;
0406 size_t __iarray_cap_;
0407 void** __parray_;
0408 size_t __parray_size_;
0409 size_t __parray_cap_;
0410 };
0411
0412 // enum class io_errc
0413 _LIBCPP_DECLARE_STRONG_ENUM(io_errc){stream = 1};
0414 _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc)
0415
0416 template <>
0417 struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type {};
0418
0419 # ifdef _LIBCPP_CXX03_LANG
0420 template <>
0421 struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type {};
0422 # endif
0423
0424 _LIBCPP_EXPORTED_FROM_ABI const error_category& iostream_category() _NOEXCEPT;
0425
0426 inline _LIBCPP_HIDE_FROM_ABI error_code make_error_code(io_errc __e) _NOEXCEPT {
0427 return error_code(static_cast<int>(__e), iostream_category());
0428 }
0429
0430 inline _LIBCPP_HIDE_FROM_ABI error_condition make_error_condition(io_errc __e) _NOEXCEPT {
0431 return error_condition(static_cast<int>(__e), iostream_category());
0432 }
0433
0434 class _LIBCPP_EXPORTED_FROM_ABI ios_base::failure : public system_error {
0435 public:
0436 explicit failure(const string& __msg, const error_code& __ec = io_errc::stream);
0437 explicit failure(const char* __msg, const error_code& __ec = io_errc::stream);
0438 _LIBCPP_HIDE_FROM_ABI failure(const failure&) _NOEXCEPT = default;
0439 ~failure() _NOEXCEPT override;
0440 };
0441
0442 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) {
0443 # ifndef _LIBCPP_HAS_NO_EXCEPTIONS
0444 throw ios_base::failure(__msg);
0445 # else
0446 _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg);
0447 # endif
0448 }
0449
0450 class _LIBCPP_EXPORTED_FROM_ABI ios_base::Init {
0451 public:
0452 Init();
0453 ~Init();
0454 };
0455
0456 // fmtflags
0457
0458 inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::flags() const { return __fmtflags_; }
0459
0460 inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::flags(fmtflags __fmtfl) {
0461 fmtflags __r = __fmtflags_;
0462 __fmtflags_ = __fmtfl;
0463 return __r;
0464 }
0465
0466 inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::setf(fmtflags __fmtfl) {
0467 fmtflags __r = __fmtflags_;
0468 __fmtflags_ |= __fmtfl;
0469 return __r;
0470 }
0471
0472 inline _LIBCPP_HIDE_FROM_ABI void ios_base::unsetf(fmtflags __mask) { __fmtflags_ &= ~__mask; }
0473
0474 inline _LIBCPP_HIDE_FROM_ABI ios_base::fmtflags ios_base::setf(fmtflags __fmtfl, fmtflags __mask) {
0475 fmtflags __r = __fmtflags_;
0476 unsetf(__mask);
0477 __fmtflags_ |= __fmtfl & __mask;
0478 return __r;
0479 }
0480
0481 // precision
0482
0483 inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::precision() const { return __precision_; }
0484
0485 inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::precision(streamsize __prec) {
0486 streamsize __r = __precision_;
0487 __precision_ = __prec;
0488 return __r;
0489 }
0490
0491 // width
0492
0493 inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::width() const { return __width_; }
0494
0495 inline _LIBCPP_HIDE_FROM_ABI streamsize ios_base::width(streamsize __wide) {
0496 streamsize __r = __width_;
0497 __width_ = __wide;
0498 return __r;
0499 }
0500
0501 // iostate
0502
0503 inline _LIBCPP_HIDE_FROM_ABI ios_base::iostate ios_base::rdstate() const { return __rdstate_; }
0504
0505 inline _LIBCPP_HIDE_FROM_ABI void ios_base::setstate(iostate __state) { clear(__rdstate_ | __state); }
0506
0507 inline _LIBCPP_HIDE_FROM_ABI bool ios_base::good() const { return __rdstate_ == 0; }
0508
0509 inline _LIBCPP_HIDE_FROM_ABI bool ios_base::eof() const { return (__rdstate_ & eofbit) != 0; }
0510
0511 inline _LIBCPP_HIDE_FROM_ABI bool ios_base::fail() const { return (__rdstate_ & (failbit | badbit)) != 0; }
0512
0513 inline _LIBCPP_HIDE_FROM_ABI bool ios_base::bad() const { return (__rdstate_ & badbit) != 0; }
0514
0515 inline _LIBCPP_HIDE_FROM_ABI ios_base::iostate ios_base::exceptions() const { return __exceptions_; }
0516
0517 inline _LIBCPP_HIDE_FROM_ABI void ios_base::exceptions(iostate __iostate) {
0518 __exceptions_ = __iostate;
0519 clear(__rdstate_);
0520 }
0521
0522 template <class _Traits>
0523 // Attribute 'packed' is used to keep the layout compatible with the previous
0524 // definition of the '__fill_' and '_set_' pair in basic_ios on AIX & z/OS.
0525 struct _LIBCPP_PACKED _FillHelper {
0526 _LIBCPP_HIDE_FROM_ABI void __init() { __set_ = false; }
0527 _LIBCPP_HIDE_FROM_ABI _FillHelper& operator=(typename _Traits::int_type __x) {
0528 __set_ = true;
0529 __fill_val_ = __x;
0530 return *this;
0531 }
0532 _LIBCPP_HIDE_FROM_ABI bool __is_set() const { return __set_; }
0533 _LIBCPP_HIDE_FROM_ABI typename _Traits::int_type __get() const { return __fill_val_; }
0534
0535 private:
0536 typename _Traits::int_type __fill_val_;
0537 bool __set_;
0538 };
0539
0540 template <class _Traits>
0541 struct _LIBCPP_PACKED _SentinelValueFill {
0542 _LIBCPP_HIDE_FROM_ABI void __init() { __fill_val_ = _Traits::eof(); }
0543 _LIBCPP_HIDE_FROM_ABI _SentinelValueFill& operator=(typename _Traits::int_type __x) {
0544 __fill_val_ = __x;
0545 return *this;
0546 }
0547 _LIBCPP_HIDE_FROM_ABI bool __is_set() const { return __fill_val_ != _Traits::eof(); }
0548 _LIBCPP_HIDE_FROM_ABI typename _Traits::int_type __get() const { return __fill_val_; }
0549
0550 private:
0551 typename _Traits::int_type __fill_val_;
0552 };
0553
0554 template <class _CharT, class _Traits>
0555 class _LIBCPP_TEMPLATE_VIS basic_ios : public ios_base {
0556 public:
0557 // types:
0558 typedef _CharT char_type;
0559 typedef _Traits traits_type;
0560
0561 typedef typename traits_type::int_type int_type;
0562 typedef typename traits_type::pos_type pos_type;
0563 typedef typename traits_type::off_type off_type;
0564
0565 static_assert(is_same<_CharT, typename traits_type::char_type>::value,
0566 "traits_type::char_type must be the same type as CharT");
0567
0568 # ifdef _LIBCPP_CXX03_LANG
0569 // Preserve the ability to compare with literal 0,
0570 // and implicitly convert to bool, but not implicitly convert to int.
0571 _LIBCPP_HIDE_FROM_ABI operator void*() const { return fail() ? nullptr : (void*)this; }
0572 # else
0573 _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return !fail(); }
0574 # endif
0575
0576 _LIBCPP_HIDE_FROM_ABI bool operator!() const { return fail(); }
0577 _LIBCPP_HIDE_FROM_ABI iostate rdstate() const { return ios_base::rdstate(); }
0578 _LIBCPP_HIDE_FROM_ABI void clear(iostate __state = goodbit) { ios_base::clear(__state); }
0579 _LIBCPP_HIDE_FROM_ABI void setstate(iostate __state) { ios_base::setstate(__state); }
0580 _LIBCPP_HIDE_FROM_ABI bool good() const { return ios_base::good(); }
0581 _LIBCPP_HIDE_FROM_ABI bool eof() const { return ios_base::eof(); }
0582 _LIBCPP_HIDE_FROM_ABI bool fail() const { return ios_base::fail(); }
0583 _LIBCPP_HIDE_FROM_ABI bool bad() const { return ios_base::bad(); }
0584
0585 _LIBCPP_HIDE_FROM_ABI iostate exceptions() const { return ios_base::exceptions(); }
0586 _LIBCPP_HIDE_FROM_ABI void exceptions(iostate __iostate) { ios_base::exceptions(__iostate); }
0587
0588 // 27.5.4.1 Constructor/destructor:
0589 _LIBCPP_HIDE_FROM_ABI explicit basic_ios(basic_streambuf<char_type, traits_type>* __sb);
0590 ~basic_ios() override;
0591
0592 // 27.5.4.2 Members:
0593 _LIBCPP_HIDE_FROM_ABI basic_ostream<char_type, traits_type>* tie() const;
0594 _LIBCPP_HIDE_FROM_ABI basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
0595
0596 _LIBCPP_HIDE_FROM_ABI basic_streambuf<char_type, traits_type>* rdbuf() const;
0597 _LIBCPP_HIDE_FROM_ABI basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
0598
0599 basic_ios& copyfmt(const basic_ios& __rhs);
0600
0601 _LIBCPP_HIDE_FROM_ABI char_type fill() const;
0602 _LIBCPP_HIDE_FROM_ABI char_type fill(char_type __ch);
0603
0604 _LIBCPP_HIDE_FROM_ABI locale imbue(const locale& __loc);
0605
0606 _LIBCPP_HIDE_FROM_ABI char narrow(char_type __c, char __dfault) const;
0607 _LIBCPP_HIDE_FROM_ABI char_type widen(char __c) const;
0608
0609 protected:
0610 _LIBCPP_HIDE_FROM_ABI basic_ios() {
0611 // purposefully does no initialization
0612 // since the destructor does nothing this does not have ios_base issues.
0613 }
0614 _LIBCPP_HIDE_FROM_ABI void init(basic_streambuf<char_type, traits_type>* __sb);
0615
0616 _LIBCPP_HIDE_FROM_ABI void move(basic_ios& __rhs);
0617 _LIBCPP_HIDE_FROM_ABI void move(basic_ios&& __rhs) { move(__rhs); }
0618 _LIBCPP_HIDE_FROM_ABI void swap(basic_ios& __rhs) _NOEXCEPT;
0619 _LIBCPP_HIDE_FROM_ABI void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
0620
0621 private:
0622 basic_ostream<char_type, traits_type>* __tie_;
0623
0624 # if defined(_LIBCPP_ABI_IOS_ALLOW_ARBITRARY_FILL_VALUE)
0625 using _FillType = _FillHelper<traits_type>;
0626 # else
0627 using _FillType = _SentinelValueFill<traits_type>;
0628 # endif
0629 mutable _FillType __fill_;
0630 };
0631
0632 template <class _CharT, class _Traits>
0633 inline _LIBCPP_HIDE_FROM_ABI basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type, traits_type>* __sb) {
0634 init(__sb);
0635 }
0636
0637 template <class _CharT, class _Traits>
0638 basic_ios<_CharT, _Traits>::~basic_ios() {}
0639
0640 template <class _CharT, class _Traits>
0641 inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) {
0642 ios_base::init(__sb);
0643 __tie_ = nullptr;
0644 __fill_.__init();
0645 }
0646
0647 template <class _CharT, class _Traits>
0648 inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>* basic_ios<_CharT, _Traits>::tie() const {
0649 return __tie_;
0650 }
0651
0652 template <class _CharT, class _Traits>
0653 inline _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>*
0654 basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) {
0655 basic_ostream<char_type, traits_type>* __r = __tie_;
0656 __tie_ = __tiestr;
0657 return __r;
0658 }
0659
0660 template <class _CharT, class _Traits>
0661 inline _LIBCPP_HIDE_FROM_ABI basic_streambuf<_CharT, _Traits>* basic_ios<_CharT, _Traits>::rdbuf() const {
0662 return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf());
0663 }
0664
0665 template <class _CharT, class _Traits>
0666 inline _LIBCPP_HIDE_FROM_ABI basic_streambuf<_CharT, _Traits>*
0667 basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) {
0668 basic_streambuf<char_type, traits_type>* __r = rdbuf();
0669 ios_base::rdbuf(__sb);
0670 return __r;
0671 }
0672
0673 template <class _CharT, class _Traits>
0674 inline _LIBCPP_HIDE_FROM_ABI locale basic_ios<_CharT, _Traits>::imbue(const locale& __loc) {
0675 locale __r = getloc();
0676 ios_base::imbue(__loc);
0677 if (rdbuf())
0678 rdbuf()->pubimbue(__loc);
0679 return __r;
0680 }
0681
0682 template <class _CharT, class _Traits>
0683 inline _LIBCPP_HIDE_FROM_ABI char basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const {
0684 return std::use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault);
0685 }
0686
0687 template <class _CharT, class _Traits>
0688 inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::widen(char __c) const {
0689 return std::use_facet<ctype<char_type> >(getloc()).widen(__c);
0690 }
0691
0692 template <class _CharT, class _Traits>
0693 inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill() const {
0694 if (!__fill_.__is_set())
0695 __fill_ = widen(' ');
0696 return __fill_.__get();
0697 }
0698
0699 template <class _CharT, class _Traits>
0700 inline _LIBCPP_HIDE_FROM_ABI _CharT basic_ios<_CharT, _Traits>::fill(char_type __ch) {
0701 if (!__fill_.__is_set())
0702 __fill_ = widen(' ');
0703 char_type __r = __fill_.__get();
0704 __fill_ = __ch;
0705 return __r;
0706 }
0707
0708 template <class _CharT, class _Traits>
0709 basic_ios<_CharT, _Traits>& basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) {
0710 if (this != &__rhs) {
0711 __call_callbacks(erase_event);
0712 ios_base::copyfmt(__rhs);
0713 __tie_ = __rhs.__tie_;
0714 __fill_ = __rhs.__fill_;
0715 __call_callbacks(copyfmt_event);
0716 exceptions(__rhs.exceptions());
0717 }
0718 return *this;
0719 }
0720
0721 template <class _CharT, class _Traits>
0722 inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::move(basic_ios& __rhs) {
0723 ios_base::move(__rhs);
0724 __tie_ = __rhs.__tie_;
0725 __rhs.__tie_ = nullptr;
0726 __fill_ = __rhs.__fill_;
0727 }
0728
0729 template <class _CharT, class _Traits>
0730 inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT {
0731 ios_base::swap(__rhs);
0732 std::swap(__tie_, __rhs.__tie_);
0733 std::swap(__fill_, __rhs.__fill_);
0734 }
0735
0736 template <class _CharT, class _Traits>
0737 inline _LIBCPP_HIDE_FROM_ABI void basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) {
0738 ios_base::set_rdbuf(__sb);
0739 }
0740
0741 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
0742
0743 # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
0744 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
0745 # endif
0746
0747 _LIBCPP_HIDE_FROM_ABI inline ios_base& boolalpha(ios_base& __str) {
0748 __str.setf(ios_base::boolalpha);
0749 return __str;
0750 }
0751
0752 _LIBCPP_HIDE_FROM_ABI inline ios_base& noboolalpha(ios_base& __str) {
0753 __str.unsetf(ios_base::boolalpha);
0754 return __str;
0755 }
0756
0757 _LIBCPP_HIDE_FROM_ABI inline ios_base& showbase(ios_base& __str) {
0758 __str.setf(ios_base::showbase);
0759 return __str;
0760 }
0761
0762 _LIBCPP_HIDE_FROM_ABI inline ios_base& noshowbase(ios_base& __str) {
0763 __str.unsetf(ios_base::showbase);
0764 return __str;
0765 }
0766
0767 _LIBCPP_HIDE_FROM_ABI inline ios_base& showpoint(ios_base& __str) {
0768 __str.setf(ios_base::showpoint);
0769 return __str;
0770 }
0771
0772 _LIBCPP_HIDE_FROM_ABI inline ios_base& noshowpoint(ios_base& __str) {
0773 __str.unsetf(ios_base::showpoint);
0774 return __str;
0775 }
0776
0777 _LIBCPP_HIDE_FROM_ABI inline ios_base& showpos(ios_base& __str) {
0778 __str.setf(ios_base::showpos);
0779 return __str;
0780 }
0781
0782 _LIBCPP_HIDE_FROM_ABI inline ios_base& noshowpos(ios_base& __str) {
0783 __str.unsetf(ios_base::showpos);
0784 return __str;
0785 }
0786
0787 _LIBCPP_HIDE_FROM_ABI inline ios_base& skipws(ios_base& __str) {
0788 __str.setf(ios_base::skipws);
0789 return __str;
0790 }
0791
0792 _LIBCPP_HIDE_FROM_ABI inline ios_base& noskipws(ios_base& __str) {
0793 __str.unsetf(ios_base::skipws);
0794 return __str;
0795 }
0796
0797 _LIBCPP_HIDE_FROM_ABI inline ios_base& uppercase(ios_base& __str) {
0798 __str.setf(ios_base::uppercase);
0799 return __str;
0800 }
0801
0802 _LIBCPP_HIDE_FROM_ABI inline ios_base& nouppercase(ios_base& __str) {
0803 __str.unsetf(ios_base::uppercase);
0804 return __str;
0805 }
0806
0807 _LIBCPP_HIDE_FROM_ABI inline ios_base& unitbuf(ios_base& __str) {
0808 __str.setf(ios_base::unitbuf);
0809 return __str;
0810 }
0811
0812 _LIBCPP_HIDE_FROM_ABI inline ios_base& nounitbuf(ios_base& __str) {
0813 __str.unsetf(ios_base::unitbuf);
0814 return __str;
0815 }
0816
0817 _LIBCPP_HIDE_FROM_ABI inline ios_base& internal(ios_base& __str) {
0818 __str.setf(ios_base::internal, ios_base::adjustfield);
0819 return __str;
0820 }
0821
0822 _LIBCPP_HIDE_FROM_ABI inline ios_base& left(ios_base& __str) {
0823 __str.setf(ios_base::left, ios_base::adjustfield);
0824 return __str;
0825 }
0826
0827 _LIBCPP_HIDE_FROM_ABI inline ios_base& right(ios_base& __str) {
0828 __str.setf(ios_base::right, ios_base::adjustfield);
0829 return __str;
0830 }
0831
0832 _LIBCPP_HIDE_FROM_ABI inline ios_base& dec(ios_base& __str) {
0833 __str.setf(ios_base::dec, ios_base::basefield);
0834 return __str;
0835 }
0836
0837 _LIBCPP_HIDE_FROM_ABI inline ios_base& hex(ios_base& __str) {
0838 __str.setf(ios_base::hex, ios_base::basefield);
0839 return __str;
0840 }
0841
0842 _LIBCPP_HIDE_FROM_ABI inline ios_base& oct(ios_base& __str) {
0843 __str.setf(ios_base::oct, ios_base::basefield);
0844 return __str;
0845 }
0846
0847 _LIBCPP_HIDE_FROM_ABI inline ios_base& fixed(ios_base& __str) {
0848 __str.setf(ios_base::fixed, ios_base::floatfield);
0849 return __str;
0850 }
0851
0852 _LIBCPP_HIDE_FROM_ABI inline ios_base& scientific(ios_base& __str) {
0853 __str.setf(ios_base::scientific, ios_base::floatfield);
0854 return __str;
0855 }
0856
0857 _LIBCPP_HIDE_FROM_ABI inline ios_base& hexfloat(ios_base& __str) {
0858 __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield);
0859 return __str;
0860 }
0861
0862 _LIBCPP_HIDE_FROM_ABI inline ios_base& defaultfloat(ios_base& __str) {
0863 __str.unsetf(ios_base::floatfield);
0864 return __str;
0865 }
0866
0867 _LIBCPP_END_NAMESPACE_STD
0868
0869 _LIBCPP_POP_MACROS
0870
0871 #endif // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
0872
0873 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0874 # include <__cxx03/atomic>
0875 # include <__cxx03/concepts>
0876 # include <__cxx03/cstddef>
0877 # include <__cxx03/cstdlib>
0878 # include <__cxx03/cstring>
0879 # include <__cxx03/initializer_list>
0880 # include <__cxx03/limits>
0881 # include <__cxx03/mutex>
0882 # include <__cxx03/new>
0883 # include <__cxx03/stdexcept>
0884 # include <__cxx03/system_error>
0885 # include <__cxx03/type_traits>
0886 # include <__cxx03/typeinfo>
0887 #endif
0888
0889 #endif // _LIBCPP___CXX03_IOS