Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | 9bd9388 | 2021-11-17 16:25:01 -0500 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 3 | // |
Chandler Carruth | d201210 | 2019-01-19 10:56:40 +0000 | [diff] [blame] | 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_IOS |
| 11 | #define _LIBCPP_IOS |
| 12 | |
| 13 | /* |
| 14 | ios synopsis |
| 15 | |
| 16 | #include <iosfwd> |
| 17 | |
| 18 | namespace std |
| 19 | { |
| 20 | |
| 21 | typedef OFF_T streamoff; |
| 22 | typedef SZ_T streamsize; |
| 23 | template <class stateT> class fpos; |
| 24 | |
| 25 | class ios_base |
| 26 | { |
| 27 | public: |
| 28 | class failure; |
| 29 | |
| 30 | typedef T1 fmtflags; |
Howard Hinnant | 770a366 | 2012-07-21 01:03:40 +0000 | [diff] [blame] | 31 | static constexpr fmtflags boolalpha; |
| 32 | static constexpr fmtflags dec; |
| 33 | static constexpr fmtflags fixed; |
| 34 | static constexpr fmtflags hex; |
| 35 | static constexpr fmtflags internal; |
| 36 | static constexpr fmtflags left; |
| 37 | static constexpr fmtflags oct; |
| 38 | static constexpr fmtflags right; |
| 39 | static constexpr fmtflags scientific; |
| 40 | static constexpr fmtflags showbase; |
| 41 | static constexpr fmtflags showpoint; |
| 42 | static constexpr fmtflags showpos; |
| 43 | static constexpr fmtflags skipws; |
| 44 | static constexpr fmtflags unitbuf; |
| 45 | static constexpr fmtflags uppercase; |
| 46 | static constexpr fmtflags adjustfield; |
| 47 | static constexpr fmtflags basefield; |
| 48 | static constexpr fmtflags floatfield; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 49 | |
| 50 | typedef T2 iostate; |
Howard Hinnant | 770a366 | 2012-07-21 01:03:40 +0000 | [diff] [blame] | 51 | static constexpr iostate badbit; |
| 52 | static constexpr iostate eofbit; |
| 53 | static constexpr iostate failbit; |
| 54 | static constexpr iostate goodbit; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 55 | |
| 56 | typedef T3 openmode; |
Howard Hinnant | 770a366 | 2012-07-21 01:03:40 +0000 | [diff] [blame] | 57 | static constexpr openmode app; |
| 58 | static constexpr openmode ate; |
| 59 | static constexpr openmode binary; |
| 60 | static constexpr openmode in; |
| 61 | static constexpr openmode out; |
| 62 | static constexpr openmode trunc; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 63 | |
| 64 | typedef T4 seekdir; |
Howard Hinnant | 770a366 | 2012-07-21 01:03:40 +0000 | [diff] [blame] | 65 | static constexpr seekdir beg; |
| 66 | static constexpr seekdir cur; |
| 67 | static constexpr seekdir end; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 68 | |
| 69 | class Init; |
| 70 | |
| 71 | // 27.5.2.2 fmtflags state: |
| 72 | fmtflags flags() const; |
| 73 | fmtflags flags(fmtflags fmtfl); |
| 74 | fmtflags setf(fmtflags fmtfl); |
| 75 | fmtflags setf(fmtflags fmtfl, fmtflags mask); |
| 76 | void unsetf(fmtflags mask); |
| 77 | |
| 78 | streamsize precision() const; |
| 79 | streamsize precision(streamsize prec); |
| 80 | streamsize width() const; |
| 81 | streamsize width(streamsize wide); |
| 82 | |
| 83 | // 27.5.2.3 locales: |
| 84 | locale imbue(const locale& loc); |
| 85 | locale getloc() const; |
| 86 | |
| 87 | // 27.5.2.5 storage: |
| 88 | static int xalloc(); |
| 89 | long& iword(int index); |
| 90 | void*& pword(int index); |
| 91 | |
| 92 | // destructor |
| 93 | virtual ~ios_base(); |
| 94 | |
| 95 | // 27.5.2.6 callbacks; |
| 96 | enum event { erase_event, imbue_event, copyfmt_event }; |
| 97 | typedef void (*event_callback)(event, ios_base&, int index); |
| 98 | void register_callback(event_callback fn, int index); |
| 99 | |
| 100 | ios_base(const ios_base&) = delete; |
| 101 | ios_base& operator=(const ios_base&) = delete; |
| 102 | |
| 103 | static bool sync_with_stdio(bool sync = true); |
| 104 | |
| 105 | protected: |
| 106 | ios_base(); |
| 107 | }; |
| 108 | |
| 109 | template <class charT, class traits = char_traits<charT> > |
| 110 | class basic_ios |
| 111 | : public ios_base |
| 112 | { |
| 113 | public: |
| 114 | // types: |
| 115 | typedef charT char_type; |
Marshall Clow | 57dbb06 | 2015-10-29 05:43:30 +0000 | [diff] [blame] | 116 | typedef typename traits::int_type int_type; // removed in C++17 |
| 117 | typedef typename traits::pos_type pos_type; // removed in C++17 |
| 118 | typedef typename traits::off_type off_type; // removed in C++17 |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 119 | typedef traits traits_type; |
| 120 | |
| 121 | operator unspecified-bool-type() const; |
| 122 | bool operator!() const; |
| 123 | iostate rdstate() const; |
| 124 | void clear(iostate state = goodbit); |
| 125 | void setstate(iostate state); |
| 126 | bool good() const; |
| 127 | bool eof() const; |
| 128 | bool fail() const; |
| 129 | bool bad() const; |
| 130 | |
| 131 | iostate exceptions() const; |
| 132 | void exceptions(iostate except); |
| 133 | |
| 134 | // 27.5.4.1 Constructor/destructor: |
| 135 | explicit basic_ios(basic_streambuf<charT,traits>* sb); |
| 136 | virtual ~basic_ios(); |
| 137 | |
| 138 | // 27.5.4.2 Members: |
| 139 | basic_ostream<charT,traits>* tie() const; |
| 140 | basic_ostream<charT,traits>* tie(basic_ostream<charT,traits>* tiestr); |
| 141 | |
| 142 | basic_streambuf<charT,traits>* rdbuf() const; |
| 143 | basic_streambuf<charT,traits>* rdbuf(basic_streambuf<charT,traits>* sb); |
| 144 | |
| 145 | basic_ios& copyfmt(const basic_ios& rhs); |
| 146 | |
| 147 | char_type fill() const; |
| 148 | char_type fill(char_type ch); |
| 149 | |
| 150 | locale imbue(const locale& loc); |
| 151 | |
| 152 | char narrow(char_type c, char dfault) const; |
| 153 | char_type widen(char c) const; |
| 154 | |
| 155 | basic_ios(const basic_ios& ) = delete; |
| 156 | basic_ios& operator=(const basic_ios&) = delete; |
| 157 | |
| 158 | protected: |
| 159 | basic_ios(); |
| 160 | void init(basic_streambuf<charT,traits>* sb); |
| 161 | void move(basic_ios& rhs); |
Howard Hinnant | 770a366 | 2012-07-21 01:03:40 +0000 | [diff] [blame] | 162 | void swap(basic_ios& rhs) noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 163 | void set_rdbuf(basic_streambuf<charT, traits>* sb); |
| 164 | }; |
| 165 | |
| 166 | // 27.5.5, manipulators: |
| 167 | ios_base& boolalpha (ios_base& str); |
| 168 | ios_base& noboolalpha(ios_base& str); |
| 169 | ios_base& showbase (ios_base& str); |
| 170 | ios_base& noshowbase (ios_base& str); |
| 171 | ios_base& showpoint (ios_base& str); |
| 172 | ios_base& noshowpoint(ios_base& str); |
| 173 | ios_base& showpos (ios_base& str); |
| 174 | ios_base& noshowpos (ios_base& str); |
| 175 | ios_base& skipws (ios_base& str); |
| 176 | ios_base& noskipws (ios_base& str); |
| 177 | ios_base& uppercase (ios_base& str); |
| 178 | ios_base& nouppercase(ios_base& str); |
| 179 | ios_base& unitbuf (ios_base& str); |
| 180 | ios_base& nounitbuf (ios_base& str); |
| 181 | |
| 182 | // 27.5.5.2 adjustfield: |
| 183 | ios_base& internal (ios_base& str); |
| 184 | ios_base& left (ios_base& str); |
| 185 | ios_base& right (ios_base& str); |
| 186 | |
| 187 | // 27.5.5.3 basefield: |
| 188 | ios_base& dec (ios_base& str); |
| 189 | ios_base& hex (ios_base& str); |
| 190 | ios_base& oct (ios_base& str); |
| 191 | |
| 192 | // 27.5.5.4 floatfield: |
| 193 | ios_base& fixed (ios_base& str); |
| 194 | ios_base& scientific (ios_base& str); |
| 195 | ios_base& hexfloat (ios_base& str); |
| 196 | ios_base& defaultfloat(ios_base& str); |
| 197 | |
| 198 | // 27.5.5.5 error reporting: |
| 199 | enum class io_errc |
| 200 | { |
| 201 | stream = 1 |
| 202 | }; |
| 203 | |
| 204 | concept_map ErrorCodeEnum<io_errc> { }; |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 205 | error_code make_error_code(io_errc e) noexcept; |
| 206 | error_condition make_error_condition(io_errc e) noexcept; |
Marshall Clow | 3f138dc | 2013-10-12 22:49:56 +0000 | [diff] [blame] | 207 | storage-class-specifier const error_category& iostream_category() noexcept; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 208 | |
| 209 | } // std |
| 210 | |
| 211 | */ |
| 212 | |
| 213 | #include <__config> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 214 | #include <__locale> |
Arthur O'Dwyer | ef18160 | 2021-05-19 11:57:04 -0400 | [diff] [blame] | 215 | #include <iosfwd> |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 216 | #include <system_error> |
| 217 | |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 218 | #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) |
Marshall Clow | f9698ab | 2013-10-12 19:13:52 +0000 | [diff] [blame] | 219 | #include <atomic> // for __xindex_ |
| 220 | #endif |
| 221 | |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 222 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 223 | #pragma GCC system_header |
Howard Hinnant | aaaa52b | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 224 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 225 | |
| 226 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 227 | |
| 228 | typedef ptrdiff_t streamsize; |
| 229 | |
Howard Hinnant | 8331b76 | 2013-03-06 23:30:19 +0000 | [diff] [blame] | 230 | class _LIBCPP_TYPE_VIS ios_base |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 231 | { |
| 232 | public: |
Eric Fiselier | fb7fc95 | 2016-04-21 23:00:33 +0000 | [diff] [blame] | 233 | class _LIBCPP_EXCEPTION_ABI failure; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 234 | |
| 235 | typedef unsigned int fmtflags; |
| 236 | static const fmtflags boolalpha = 0x0001; |
| 237 | static const fmtflags dec = 0x0002; |
| 238 | static const fmtflags fixed = 0x0004; |
| 239 | static const fmtflags hex = 0x0008; |
| 240 | static const fmtflags internal = 0x0010; |
| 241 | static const fmtflags left = 0x0020; |
| 242 | static const fmtflags oct = 0x0040; |
| 243 | static const fmtflags right = 0x0080; |
| 244 | static const fmtflags scientific = 0x0100; |
| 245 | static const fmtflags showbase = 0x0200; |
| 246 | static const fmtflags showpoint = 0x0400; |
| 247 | static const fmtflags showpos = 0x0800; |
| 248 | static const fmtflags skipws = 0x1000; |
| 249 | static const fmtflags unitbuf = 0x2000; |
| 250 | static const fmtflags uppercase = 0x4000; |
| 251 | static const fmtflags adjustfield = left | right | internal; |
| 252 | static const fmtflags basefield = dec | oct | hex; |
| 253 | static const fmtflags floatfield = scientific | fixed; |
| 254 | |
| 255 | typedef unsigned int iostate; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 256 | static const iostate badbit = 0x1; |
| 257 | static const iostate eofbit = 0x2; |
| 258 | static const iostate failbit = 0x4; |
| 259 | static const iostate goodbit = 0x0; |
| 260 | |
| 261 | typedef unsigned int openmode; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 262 | static const openmode app = 0x01; |
| 263 | static const openmode ate = 0x02; |
| 264 | static const openmode binary = 0x04; |
| 265 | static const openmode in = 0x08; |
| 266 | static const openmode out = 0x10; |
| 267 | static const openmode trunc = 0x20; |
| 268 | |
| 269 | enum seekdir {beg, cur, end}; |
Marshall Clow | 57dbb06 | 2015-10-29 05:43:30 +0000 | [diff] [blame] | 270 | |
| 271 | #if _LIBCPP_STD_VER <= 14 |
| 272 | typedef iostate io_state; |
| 273 | typedef openmode open_mode; |
| 274 | typedef seekdir seek_dir; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 275 | |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 276 | typedef _VSTD::streamoff streamoff; |
| 277 | typedef _VSTD::streampos streampos; |
Marshall Clow | 57dbb06 | 2015-10-29 05:43:30 +0000 | [diff] [blame] | 278 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 279 | |
Howard Hinnant | 8331b76 | 2013-03-06 23:30:19 +0000 | [diff] [blame] | 280 | class _LIBCPP_TYPE_VIS Init; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 281 | |
| 282 | // 27.5.2.2 fmtflags state: |
Howard Hinnant | cf82332 | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 283 | _LIBCPP_INLINE_VISIBILITY fmtflags flags() const; |
| 284 | _LIBCPP_INLINE_VISIBILITY fmtflags flags(fmtflags __fmtfl); |
| 285 | _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl); |
| 286 | _LIBCPP_INLINE_VISIBILITY fmtflags setf(fmtflags __fmtfl, fmtflags __mask); |
| 287 | _LIBCPP_INLINE_VISIBILITY void unsetf(fmtflags __mask); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 288 | |
Howard Hinnant | cf82332 | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 289 | _LIBCPP_INLINE_VISIBILITY streamsize precision() const; |
| 290 | _LIBCPP_INLINE_VISIBILITY streamsize precision(streamsize __prec); |
| 291 | _LIBCPP_INLINE_VISIBILITY streamsize width() const; |
| 292 | _LIBCPP_INLINE_VISIBILITY streamsize width(streamsize __wide); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 293 | |
| 294 | // 27.5.2.3 locales: |
| 295 | locale imbue(const locale& __loc); |
| 296 | locale getloc() const; |
| 297 | |
| 298 | // 27.5.2.5 storage: |
| 299 | static int xalloc(); |
| 300 | long& iword(int __index); |
| 301 | void*& pword(int __index); |
| 302 | |
| 303 | // destructor |
| 304 | virtual ~ios_base(); |
| 305 | |
| 306 | // 27.5.2.6 callbacks; |
| 307 | enum event { erase_event, imbue_event, copyfmt_event }; |
| 308 | typedef void (*event_callback)(event, ios_base&, int __index); |
| 309 | void register_callback(event_callback __fn, int __index); |
| 310 | |
Nikolas Klauser | 0708864 | 2021-12-08 10:57:12 +0100 | [diff] [blame] | 311 | ios_base(const ios_base&) = delete; |
| 312 | ios_base& operator=(const ios_base&) = delete; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 313 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 314 | static bool sync_with_stdio(bool __sync = true); |
| 315 | |
Howard Hinnant | cf82332 | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 316 | _LIBCPP_INLINE_VISIBILITY iostate rdstate() const; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 317 | void clear(iostate __state = goodbit); |
Howard Hinnant | cf82332 | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 318 | _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 319 | |
Howard Hinnant | cf82332 | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 320 | _LIBCPP_INLINE_VISIBILITY bool good() const; |
| 321 | _LIBCPP_INLINE_VISIBILITY bool eof() const; |
| 322 | _LIBCPP_INLINE_VISIBILITY bool fail() const; |
| 323 | _LIBCPP_INLINE_VISIBILITY bool bad() const; |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 324 | |
Howard Hinnant | cf82332 | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 325 | _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; |
Howard Hinnant | f885080 | 2013-10-06 21:00:29 +0000 | [diff] [blame] | 326 | _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 327 | |
| 328 | void __set_badbit_and_consider_rethrow(); |
| 329 | void __set_failbit_and_consider_rethrow(); |
| 330 | |
Louis Dionne | 94ee3a0 | 2019-04-05 16:33:37 +0000 | [diff] [blame] | 331 | _LIBCPP_INLINE_VISIBILITY |
| 332 | void __setstate_nothrow(iostate __state) |
| 333 | { |
| 334 | if (__rdbuf_) |
| 335 | __rdstate_ |= __state; |
| 336 | else |
| 337 | __rdstate_ |= __state | ios_base::badbit; |
| 338 | } |
| 339 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 340 | protected: |
Howard Hinnant | 64da260 | 2010-09-22 15:29:08 +0000 | [diff] [blame] | 341 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 342 | ios_base() {// purposefully does no initialization |
| 343 | } |
| 344 | |
| 345 | void init(void* __sb); |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 346 | _LIBCPP_INLINE_VISIBILITY void* rdbuf() const {return __rdbuf_;} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 347 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 348 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 349 | void rdbuf(void* __sb) |
| 350 | { |
| 351 | __rdbuf_ = __sb; |
| 352 | clear(); |
| 353 | } |
| 354 | |
| 355 | void __call_callbacks(event); |
| 356 | void copyfmt(const ios_base&); |
| 357 | void move(ios_base&); |
Howard Hinnant | 770a366 | 2012-07-21 01:03:40 +0000 | [diff] [blame] | 358 | void swap(ios_base&) _NOEXCEPT; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 359 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 360 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 361 | void set_rdbuf(void* __sb) |
| 362 | { |
| 363 | __rdbuf_ = __sb; |
| 364 | } |
| 365 | |
| 366 | private: |
| 367 | // All data members must be scalars |
| 368 | fmtflags __fmtflags_; |
| 369 | streamsize __precision_; |
| 370 | streamsize __width_; |
| 371 | iostate __rdstate_; |
| 372 | iostate __exceptions_; |
| 373 | void* __rdbuf_; |
| 374 | void* __loc_; |
| 375 | event_callback* __fn_; |
| 376 | int* __index_; |
| 377 | size_t __event_size_; |
| 378 | size_t __event_cap_; |
Eric Fiselier | 8020b6c | 2015-08-19 17:21:46 +0000 | [diff] [blame] | 379 | // TODO(EricWF): Enable this for both Clang and GCC. Currently it is only |
| 380 | // enabled with clang. |
| 381 | #if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) |
Marshall Clow | f9698ab | 2013-10-12 19:13:52 +0000 | [diff] [blame] | 382 | static atomic<int> __xindex_; |
| 383 | #else |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 384 | static int __xindex_; |
Marshall Clow | f9698ab | 2013-10-12 19:13:52 +0000 | [diff] [blame] | 385 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 386 | long* __iarray_; |
| 387 | size_t __iarray_size_; |
| 388 | size_t __iarray_cap_; |
| 389 | void** __parray_; |
| 390 | size_t __parray_size_; |
| 391 | size_t __parray_cap_; |
| 392 | }; |
| 393 | |
| 394 | //enum class io_errc |
Howard Hinnant | 09bc0c9 | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 395 | _LIBCPP_DECLARE_STRONG_ENUM(io_errc) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 396 | { |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 397 | stream = 1 |
| 398 | }; |
Howard Hinnant | 09bc0c9 | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 399 | _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 400 | |
Howard Hinnant | 64da260 | 2010-09-22 15:29:08 +0000 | [diff] [blame] | 401 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 402 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc> : public true_type { }; |
Howard Hinnant | 09bc0c9 | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 403 | |
| 404 | #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS |
Howard Hinnant | 64da260 | 2010-09-22 15:29:08 +0000 | [diff] [blame] | 405 | template <> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 406 | struct _LIBCPP_TEMPLATE_VIS is_error_code_enum<io_errc::__lx> : public true_type { }; |
Howard Hinnant | 09bc0c9 | 2011-12-02 19:36:40 +0000 | [diff] [blame] | 407 | #endif |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 408 | |
Howard Hinnant | 8331b76 | 2013-03-06 23:30:19 +0000 | [diff] [blame] | 409 | _LIBCPP_FUNC_VIS |
Marshall Clow | 3f138dc | 2013-10-12 22:49:56 +0000 | [diff] [blame] | 410 | const error_category& iostream_category() _NOEXCEPT; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 411 | |
| 412 | inline _LIBCPP_INLINE_VISIBILITY |
| 413 | error_code |
Marshall Clow | 3f138dc | 2013-10-12 22:49:56 +0000 | [diff] [blame] | 414 | make_error_code(io_errc __e) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 415 | { |
| 416 | return error_code(static_cast<int>(__e), iostream_category()); |
| 417 | } |
| 418 | |
| 419 | inline _LIBCPP_INLINE_VISIBILITY |
| 420 | error_condition |
Marshall Clow | 3f138dc | 2013-10-12 22:49:56 +0000 | [diff] [blame] | 421 | make_error_condition(io_errc __e) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 422 | { |
| 423 | return error_condition(static_cast<int>(__e), iostream_category()); |
| 424 | } |
| 425 | |
Howard Hinnant | 64da260 | 2010-09-22 15:29:08 +0000 | [diff] [blame] | 426 | class _LIBCPP_EXCEPTION_ABI ios_base::failure |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 427 | : public system_error |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 428 | { |
| 429 | public: |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 430 | explicit failure(const string& __msg, const error_code& __ec = io_errc::stream); |
Howard Hinnant | 3b6579a | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 431 | explicit failure(const char* __msg, const error_code& __ec = io_errc::stream); |
Dimitry Andric | 47269ce | 2020-03-13 19:36:26 +0100 | [diff] [blame] | 432 | failure(const failure&) _NOEXCEPT = default; |
| 433 | virtual ~failure() _NOEXCEPT; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 434 | }; |
| 435 | |
Louis Dionne | 2b23916 | 2019-02-12 16:06:02 +0000 | [diff] [blame] | 436 | _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY |
| 437 | void __throw_failure(char const* __msg) { |
| 438 | #ifndef _LIBCPP_NO_EXCEPTIONS |
| 439 | throw ios_base::failure(__msg); |
| 440 | #else |
| 441 | ((void)__msg); |
| 442 | _VSTD::abort(); |
| 443 | #endif |
| 444 | } |
| 445 | |
Howard Hinnant | 8331b76 | 2013-03-06 23:30:19 +0000 | [diff] [blame] | 446 | class _LIBCPP_TYPE_VIS ios_base::Init |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 447 | { |
| 448 | public: |
| 449 | Init(); |
| 450 | ~Init(); |
| 451 | }; |
| 452 | |
| 453 | // fmtflags |
| 454 | |
| 455 | inline _LIBCPP_INLINE_VISIBILITY |
| 456 | ios_base::fmtflags |
| 457 | ios_base::flags() const |
| 458 | { |
| 459 | return __fmtflags_; |
| 460 | } |
| 461 | |
| 462 | inline _LIBCPP_INLINE_VISIBILITY |
| 463 | ios_base::fmtflags |
| 464 | ios_base::flags(fmtflags __fmtfl) |
| 465 | { |
| 466 | fmtflags __r = __fmtflags_; |
| 467 | __fmtflags_ = __fmtfl; |
| 468 | return __r; |
| 469 | } |
| 470 | |
| 471 | inline _LIBCPP_INLINE_VISIBILITY |
| 472 | ios_base::fmtflags |
| 473 | ios_base::setf(fmtflags __fmtfl) |
| 474 | { |
| 475 | fmtflags __r = __fmtflags_; |
| 476 | __fmtflags_ |= __fmtfl; |
| 477 | return __r; |
| 478 | } |
| 479 | |
| 480 | inline _LIBCPP_INLINE_VISIBILITY |
| 481 | void |
| 482 | ios_base::unsetf(fmtflags __mask) |
| 483 | { |
| 484 | __fmtflags_ &= ~__mask; |
| 485 | } |
| 486 | |
| 487 | inline _LIBCPP_INLINE_VISIBILITY |
| 488 | ios_base::fmtflags |
| 489 | ios_base::setf(fmtflags __fmtfl, fmtflags __mask) |
| 490 | { |
| 491 | fmtflags __r = __fmtflags_; |
| 492 | unsetf(__mask); |
| 493 | __fmtflags_ |= __fmtfl & __mask; |
| 494 | return __r; |
| 495 | } |
| 496 | |
| 497 | // precision |
| 498 | |
| 499 | inline _LIBCPP_INLINE_VISIBILITY |
| 500 | streamsize |
| 501 | ios_base::precision() const |
| 502 | { |
| 503 | return __precision_; |
| 504 | } |
| 505 | |
| 506 | inline _LIBCPP_INLINE_VISIBILITY |
| 507 | streamsize |
| 508 | ios_base::precision(streamsize __prec) |
| 509 | { |
| 510 | streamsize __r = __precision_; |
| 511 | __precision_ = __prec; |
| 512 | return __r; |
| 513 | } |
| 514 | |
| 515 | // width |
| 516 | |
| 517 | inline _LIBCPP_INLINE_VISIBILITY |
| 518 | streamsize |
| 519 | ios_base::width() const |
| 520 | { |
| 521 | return __width_; |
| 522 | } |
| 523 | |
| 524 | inline _LIBCPP_INLINE_VISIBILITY |
| 525 | streamsize |
| 526 | ios_base::width(streamsize __wide) |
| 527 | { |
| 528 | streamsize __r = __width_; |
| 529 | __width_ = __wide; |
| 530 | return __r; |
| 531 | } |
| 532 | |
| 533 | // iostate |
| 534 | |
| 535 | inline _LIBCPP_INLINE_VISIBILITY |
| 536 | ios_base::iostate |
| 537 | ios_base::rdstate() const |
| 538 | { |
| 539 | return __rdstate_; |
| 540 | } |
| 541 | |
| 542 | inline _LIBCPP_INLINE_VISIBILITY |
| 543 | void |
| 544 | ios_base::setstate(iostate __state) |
| 545 | { |
| 546 | clear(__rdstate_ | __state); |
| 547 | } |
| 548 | |
| 549 | inline _LIBCPP_INLINE_VISIBILITY |
| 550 | bool |
| 551 | ios_base::good() const |
| 552 | { |
| 553 | return __rdstate_ == 0; |
| 554 | } |
| 555 | |
| 556 | inline _LIBCPP_INLINE_VISIBILITY |
| 557 | bool |
| 558 | ios_base::eof() const |
| 559 | { |
Marshall Clow | 11de487 | 2013-10-21 14:41:05 +0000 | [diff] [blame] | 560 | return (__rdstate_ & eofbit) != 0; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | inline _LIBCPP_INLINE_VISIBILITY |
| 564 | bool |
| 565 | ios_base::fail() const |
| 566 | { |
Marshall Clow | 11de487 | 2013-10-21 14:41:05 +0000 | [diff] [blame] | 567 | return (__rdstate_ & (failbit | badbit)) != 0; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | inline _LIBCPP_INLINE_VISIBILITY |
| 571 | bool |
| 572 | ios_base::bad() const |
| 573 | { |
Marshall Clow | 11de487 | 2013-10-21 14:41:05 +0000 | [diff] [blame] | 574 | return (__rdstate_ & badbit) != 0; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 575 | } |
| 576 | |
| 577 | inline _LIBCPP_INLINE_VISIBILITY |
| 578 | ios_base::iostate |
| 579 | ios_base::exceptions() const |
| 580 | { |
| 581 | return __exceptions_; |
| 582 | } |
| 583 | |
| 584 | inline _LIBCPP_INLINE_VISIBILITY |
| 585 | void |
Howard Hinnant | f885080 | 2013-10-06 21:00:29 +0000 | [diff] [blame] | 586 | ios_base::exceptions(iostate __iostate) |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 587 | { |
Howard Hinnant | f885080 | 2013-10-06 21:00:29 +0000 | [diff] [blame] | 588 | __exceptions_ = __iostate; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 589 | clear(__rdstate_); |
| 590 | } |
| 591 | |
| 592 | template <class _CharT, class _Traits> |
Eric Fiselier | b5eb1bf | 2017-01-04 23:56:00 +0000 | [diff] [blame] | 593 | class _LIBCPP_TEMPLATE_VIS basic_ios |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 594 | : public ios_base |
| 595 | { |
| 596 | public: |
| 597 | // types: |
| 598 | typedef _CharT char_type; |
| 599 | typedef _Traits traits_type; |
| 600 | |
| 601 | typedef typename traits_type::int_type int_type; |
| 602 | typedef typename traits_type::pos_type pos_type; |
| 603 | typedef typename traits_type::off_type off_type; |
| 604 | |
Marshall Clow | d151d18 | 2018-02-01 03:55:27 +0000 | [diff] [blame] | 605 | static_assert((is_same<_CharT, typename traits_type::char_type>::value), |
| 606 | "traits_type::char_type must be the same type as CharT"); |
| 607 | |
Arthur O'Dwyer | de7f7b4 | 2021-08-06 14:50:09 -0400 | [diff] [blame] | 608 | #ifdef _LIBCPP_CXX03_LANG |
| 609 | // Preserve the ability to compare with literal 0, |
| 610 | // and implicitly convert to bool, but not implicitly convert to int. |
| 611 | _LIBCPP_INLINE_VISIBILITY |
| 612 | operator void*() const {return fail() ? nullptr : (void*)this;} |
| 613 | #else |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 614 | _LIBCPP_INLINE_VISIBILITY |
Arthur O'Dwyer | 6c9c9a7 | 2021-06-15 12:57:54 -0400 | [diff] [blame] | 615 | explicit operator bool() const {return !fail();} |
Arthur O'Dwyer | de7f7b4 | 2021-08-06 14:50:09 -0400 | [diff] [blame] | 616 | #endif |
Eric Fiselier | 6a5f6f9 | 2016-12-30 14:05:52 +0000 | [diff] [blame] | 617 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 618 | _LIBCPP_INLINE_VISIBILITY bool operator!() const {return fail();} |
| 619 | _LIBCPP_INLINE_VISIBILITY iostate rdstate() const {return ios_base::rdstate();} |
| 620 | _LIBCPP_INLINE_VISIBILITY void clear(iostate __state = goodbit) {ios_base::clear(__state);} |
| 621 | _LIBCPP_INLINE_VISIBILITY void setstate(iostate __state) {ios_base::setstate(__state);} |
| 622 | _LIBCPP_INLINE_VISIBILITY bool good() const {return ios_base::good();} |
| 623 | _LIBCPP_INLINE_VISIBILITY bool eof() const {return ios_base::eof();} |
| 624 | _LIBCPP_INLINE_VISIBILITY bool fail() const {return ios_base::fail();} |
| 625 | _LIBCPP_INLINE_VISIBILITY bool bad() const {return ios_base::bad();} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 626 | |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 627 | _LIBCPP_INLINE_VISIBILITY iostate exceptions() const {return ios_base::exceptions();} |
| 628 | _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);} |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 629 | |
| 630 | // 27.5.4.1 Constructor/destructor: |
Howard Hinnant | cf82332 | 2010-12-17 14:46:43 +0000 | [diff] [blame] | 631 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 632 | explicit basic_ios(basic_streambuf<char_type,traits_type>* __sb); |
| 633 | virtual ~basic_ios(); |
| 634 | |
| 635 | // 27.5.4.2 Members: |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 636 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 637 | basic_ostream<char_type, traits_type>* tie() const; |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 638 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 639 | basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr); |
| 640 | |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 641 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 642 | basic_streambuf<char_type, traits_type>* rdbuf() const; |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 643 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 644 | basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb); |
| 645 | |
| 646 | basic_ios& copyfmt(const basic_ios& __rhs); |
| 647 | |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 648 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 649 | char_type fill() const; |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 650 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 651 | char_type fill(char_type __ch); |
| 652 | |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 653 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 654 | locale imbue(const locale& __loc); |
| 655 | |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 656 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 657 | char narrow(char_type __c, char __dfault) const; |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 658 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 659 | char_type widen(char __c) const; |
| 660 | |
| 661 | protected: |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 662 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 663 | basic_ios() {// purposefully does no initialization |
| 664 | } |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 665 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 666 | void init(basic_streambuf<char_type, traits_type>* __sb); |
| 667 | |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 668 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 669 | void move(basic_ios& __rhs); |
Louis Dionne | 16fe295 | 2018-07-11 23:14:33 +0000 | [diff] [blame] | 670 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 671 | void move(basic_ios&& __rhs) {move(__rhs);} |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 672 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | 770a366 | 2012-07-21 01:03:40 +0000 | [diff] [blame] | 673 | void swap(basic_ios& __rhs) _NOEXCEPT; |
Louis Dionne | 173f29e | 2019-05-29 16:01:36 +0000 | [diff] [blame] | 674 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 675 | void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb); |
| 676 | private: |
| 677 | basic_ostream<char_type, traits_type>* __tie_; |
Bruce Mitchener | ca134c5 | 2018-02-14 00:29:38 +0000 | [diff] [blame] | 678 | mutable int_type __fill_; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 679 | }; |
| 680 | |
| 681 | template <class _CharT, class _Traits> |
| 682 | inline _LIBCPP_INLINE_VISIBILITY |
| 683 | basic_ios<_CharT, _Traits>::basic_ios(basic_streambuf<char_type,traits_type>* __sb) |
| 684 | { |
| 685 | init(__sb); |
| 686 | } |
| 687 | |
| 688 | template <class _CharT, class _Traits> |
| 689 | basic_ios<_CharT, _Traits>::~basic_ios() |
| 690 | { |
| 691 | } |
| 692 | |
| 693 | template <class _CharT, class _Traits> |
| 694 | inline _LIBCPP_INLINE_VISIBILITY |
| 695 | void |
| 696 | basic_ios<_CharT, _Traits>::init(basic_streambuf<char_type, traits_type>* __sb) |
| 697 | { |
| 698 | ios_base::init(__sb); |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 699 | __tie_ = nullptr; |
Howard Hinnant | 2efe10d | 2012-08-26 18:05:35 +0000 | [diff] [blame] | 700 | __fill_ = traits_type::eof(); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | template <class _CharT, class _Traits> |
| 704 | inline _LIBCPP_INLINE_VISIBILITY |
| 705 | basic_ostream<_CharT, _Traits>* |
| 706 | basic_ios<_CharT, _Traits>::tie() const |
| 707 | { |
| 708 | return __tie_; |
| 709 | } |
| 710 | |
| 711 | template <class _CharT, class _Traits> |
| 712 | inline _LIBCPP_INLINE_VISIBILITY |
| 713 | basic_ostream<_CharT, _Traits>* |
| 714 | basic_ios<_CharT, _Traits>::tie(basic_ostream<char_type, traits_type>* __tiestr) |
| 715 | { |
| 716 | basic_ostream<char_type, traits_type>* __r = __tie_; |
| 717 | __tie_ = __tiestr; |
| 718 | return __r; |
| 719 | } |
| 720 | |
| 721 | template <class _CharT, class _Traits> |
| 722 | inline _LIBCPP_INLINE_VISIBILITY |
| 723 | basic_streambuf<_CharT, _Traits>* |
| 724 | basic_ios<_CharT, _Traits>::rdbuf() const |
| 725 | { |
| 726 | return static_cast<basic_streambuf<char_type, traits_type>*>(ios_base::rdbuf()); |
| 727 | } |
| 728 | |
| 729 | template <class _CharT, class _Traits> |
| 730 | inline _LIBCPP_INLINE_VISIBILITY |
| 731 | basic_streambuf<_CharT, _Traits>* |
| 732 | basic_ios<_CharT, _Traits>::rdbuf(basic_streambuf<char_type, traits_type>* __sb) |
| 733 | { |
| 734 | basic_streambuf<char_type, traits_type>* __r = rdbuf(); |
| 735 | ios_base::rdbuf(__sb); |
| 736 | return __r; |
| 737 | } |
| 738 | |
| 739 | template <class _CharT, class _Traits> |
| 740 | inline _LIBCPP_INLINE_VISIBILITY |
| 741 | locale |
| 742 | basic_ios<_CharT, _Traits>::imbue(const locale& __loc) |
| 743 | { |
| 744 | locale __r = getloc(); |
| 745 | ios_base::imbue(__loc); |
| 746 | if (rdbuf()) |
| 747 | rdbuf()->pubimbue(__loc); |
| 748 | return __r; |
| 749 | } |
| 750 | |
| 751 | template <class _CharT, class _Traits> |
| 752 | inline _LIBCPP_INLINE_VISIBILITY |
| 753 | char |
| 754 | basic_ios<_CharT, _Traits>::narrow(char_type __c, char __dfault) const |
| 755 | { |
| 756 | return use_facet<ctype<char_type> >(getloc()).narrow(__c, __dfault); |
| 757 | } |
| 758 | |
| 759 | template <class _CharT, class _Traits> |
| 760 | inline _LIBCPP_INLINE_VISIBILITY |
| 761 | _CharT |
| 762 | basic_ios<_CharT, _Traits>::widen(char __c) const |
| 763 | { |
| 764 | return use_facet<ctype<char_type> >(getloc()).widen(__c); |
| 765 | } |
| 766 | |
| 767 | template <class _CharT, class _Traits> |
| 768 | inline _LIBCPP_INLINE_VISIBILITY |
| 769 | _CharT |
| 770 | basic_ios<_CharT, _Traits>::fill() const |
| 771 | { |
Howard Hinnant | 2efe10d | 2012-08-26 18:05:35 +0000 | [diff] [blame] | 772 | if (traits_type::eq_int_type(traits_type::eof(), __fill_)) |
| 773 | __fill_ = widen(' '); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 774 | return __fill_; |
| 775 | } |
| 776 | |
| 777 | template <class _CharT, class _Traits> |
| 778 | inline _LIBCPP_INLINE_VISIBILITY |
| 779 | _CharT |
| 780 | basic_ios<_CharT, _Traits>::fill(char_type __ch) |
| 781 | { |
| 782 | char_type __r = __fill_; |
| 783 | __fill_ = __ch; |
| 784 | return __r; |
| 785 | } |
| 786 | |
| 787 | template <class _CharT, class _Traits> |
| 788 | basic_ios<_CharT, _Traits>& |
| 789 | basic_ios<_CharT, _Traits>::copyfmt(const basic_ios& __rhs) |
| 790 | { |
| 791 | if (this != &__rhs) |
| 792 | { |
| 793 | __call_callbacks(erase_event); |
| 794 | ios_base::copyfmt(__rhs); |
| 795 | __tie_ = __rhs.__tie_; |
| 796 | __fill_ = __rhs.__fill_; |
| 797 | __call_callbacks(copyfmt_event); |
| 798 | exceptions(__rhs.exceptions()); |
| 799 | } |
| 800 | return *this; |
| 801 | } |
| 802 | |
| 803 | template <class _CharT, class _Traits> |
| 804 | inline _LIBCPP_INLINE_VISIBILITY |
| 805 | void |
| 806 | basic_ios<_CharT, _Traits>::move(basic_ios& __rhs) |
| 807 | { |
| 808 | ios_base::move(__rhs); |
| 809 | __tie_ = __rhs.__tie_; |
Bruce Mitchener | 170d897 | 2020-11-24 12:53:53 -0500 | [diff] [blame] | 810 | __rhs.__tie_ = nullptr; |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 811 | __fill_ = __rhs.__fill_; |
| 812 | } |
| 813 | |
| 814 | template <class _CharT, class _Traits> |
| 815 | inline _LIBCPP_INLINE_VISIBILITY |
| 816 | void |
Howard Hinnant | 770a366 | 2012-07-21 01:03:40 +0000 | [diff] [blame] | 817 | basic_ios<_CharT, _Traits>::swap(basic_ios& __rhs) _NOEXCEPT |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 818 | { |
| 819 | ios_base::swap(__rhs); |
Howard Hinnant | b1ad5a8 | 2011-06-30 21:18:19 +0000 | [diff] [blame] | 820 | _VSTD::swap(__tie_, __rhs.__tie_); |
| 821 | _VSTD::swap(__fill_, __rhs.__fill_); |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 822 | } |
| 823 | |
| 824 | template <class _CharT, class _Traits> |
| 825 | inline _LIBCPP_INLINE_VISIBILITY |
| 826 | void |
| 827 | basic_ios<_CharT, _Traits>::set_rdbuf(basic_streambuf<char_type, traits_type>* __sb) |
| 828 | { |
| 829 | ios_base::set_rdbuf(__sb); |
| 830 | } |
| 831 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 832 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 833 | ios_base& |
| 834 | boolalpha(ios_base& __str) |
| 835 | { |
| 836 | __str.setf(ios_base::boolalpha); |
| 837 | return __str; |
| 838 | } |
| 839 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 840 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 841 | ios_base& |
| 842 | noboolalpha(ios_base& __str) |
| 843 | { |
| 844 | __str.unsetf(ios_base::boolalpha); |
| 845 | return __str; |
| 846 | } |
| 847 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 848 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 849 | ios_base& |
| 850 | showbase(ios_base& __str) |
| 851 | { |
| 852 | __str.setf(ios_base::showbase); |
| 853 | return __str; |
| 854 | } |
| 855 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 856 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 857 | ios_base& |
| 858 | noshowbase(ios_base& __str) |
| 859 | { |
| 860 | __str.unsetf(ios_base::showbase); |
| 861 | return __str; |
| 862 | } |
| 863 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 864 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 865 | ios_base& |
| 866 | showpoint(ios_base& __str) |
| 867 | { |
| 868 | __str.setf(ios_base::showpoint); |
| 869 | return __str; |
| 870 | } |
| 871 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 872 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 873 | ios_base& |
| 874 | noshowpoint(ios_base& __str) |
| 875 | { |
| 876 | __str.unsetf(ios_base::showpoint); |
| 877 | return __str; |
| 878 | } |
| 879 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 880 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 881 | ios_base& |
| 882 | showpos(ios_base& __str) |
| 883 | { |
| 884 | __str.setf(ios_base::showpos); |
| 885 | return __str; |
| 886 | } |
| 887 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 888 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 889 | ios_base& |
| 890 | noshowpos(ios_base& __str) |
| 891 | { |
| 892 | __str.unsetf(ios_base::showpos); |
| 893 | return __str; |
| 894 | } |
| 895 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 896 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 897 | ios_base& |
| 898 | skipws(ios_base& __str) |
| 899 | { |
| 900 | __str.setf(ios_base::skipws); |
| 901 | return __str; |
| 902 | } |
| 903 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 904 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 905 | ios_base& |
| 906 | noskipws(ios_base& __str) |
| 907 | { |
| 908 | __str.unsetf(ios_base::skipws); |
| 909 | return __str; |
| 910 | } |
| 911 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 912 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 913 | ios_base& |
| 914 | uppercase(ios_base& __str) |
| 915 | { |
| 916 | __str.setf(ios_base::uppercase); |
| 917 | return __str; |
| 918 | } |
| 919 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 920 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 921 | ios_base& |
| 922 | nouppercase(ios_base& __str) |
| 923 | { |
| 924 | __str.unsetf(ios_base::uppercase); |
| 925 | return __str; |
| 926 | } |
| 927 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 928 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 929 | ios_base& |
| 930 | unitbuf(ios_base& __str) |
| 931 | { |
| 932 | __str.setf(ios_base::unitbuf); |
| 933 | return __str; |
| 934 | } |
| 935 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 936 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 937 | ios_base& |
| 938 | nounitbuf(ios_base& __str) |
| 939 | { |
| 940 | __str.unsetf(ios_base::unitbuf); |
| 941 | return __str; |
| 942 | } |
| 943 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 944 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 945 | ios_base& |
| 946 | internal(ios_base& __str) |
| 947 | { |
| 948 | __str.setf(ios_base::internal, ios_base::adjustfield); |
| 949 | return __str; |
| 950 | } |
| 951 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 952 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 953 | ios_base& |
| 954 | left(ios_base& __str) |
| 955 | { |
| 956 | __str.setf(ios_base::left, ios_base::adjustfield); |
| 957 | return __str; |
| 958 | } |
| 959 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 960 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 961 | ios_base& |
| 962 | right(ios_base& __str) |
| 963 | { |
| 964 | __str.setf(ios_base::right, ios_base::adjustfield); |
| 965 | return __str; |
| 966 | } |
| 967 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 968 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 969 | ios_base& |
| 970 | dec(ios_base& __str) |
| 971 | { |
| 972 | __str.setf(ios_base::dec, ios_base::basefield); |
| 973 | return __str; |
| 974 | } |
| 975 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 976 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 977 | ios_base& |
| 978 | hex(ios_base& __str) |
| 979 | { |
| 980 | __str.setf(ios_base::hex, ios_base::basefield); |
| 981 | return __str; |
| 982 | } |
| 983 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 984 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 985 | ios_base& |
| 986 | oct(ios_base& __str) |
| 987 | { |
| 988 | __str.setf(ios_base::oct, ios_base::basefield); |
| 989 | return __str; |
| 990 | } |
| 991 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 992 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 993 | ios_base& |
| 994 | fixed(ios_base& __str) |
| 995 | { |
| 996 | __str.setf(ios_base::fixed, ios_base::floatfield); |
| 997 | return __str; |
| 998 | } |
| 999 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 1000 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1001 | ios_base& |
| 1002 | scientific(ios_base& __str) |
| 1003 | { |
| 1004 | __str.setf(ios_base::scientific, ios_base::floatfield); |
| 1005 | return __str; |
| 1006 | } |
| 1007 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 1008 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1009 | ios_base& |
| 1010 | hexfloat(ios_base& __str) |
| 1011 | { |
| 1012 | __str.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); |
| 1013 | return __str; |
| 1014 | } |
| 1015 | |
Louis Dionne | e29136f | 2020-07-13 11:53:48 -0400 | [diff] [blame] | 1016 | inline |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1017 | ios_base& |
| 1018 | defaultfloat(ios_base& __str) |
| 1019 | { |
| 1020 | __str.unsetf(ios_base::floatfield); |
| 1021 | return __str; |
| 1022 | } |
| 1023 | |
Howard Hinnant | c51e102 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1024 | _LIBCPP_END_NAMESPACE_STD |
| 1025 | |
Louis Dionne | 2b1ceaa | 2021-04-20 12:03:32 -0400 | [diff] [blame] | 1026 | #endif // _LIBCPP_IOS |