]>
Commit | Line | Data |
---|---|---|
725dc051 BK |
1 | // Iostreams base classes -*- C++ -*- |
2 | ||
7adcbafe | 3 | // Copyright (C) 1997-2022 Free Software Foundation, Inc. |
725dc051 BK |
4 | // |
5 | // This file is part of the GNU ISO C++ Library. This library is free | |
6 | // software; you can redistribute it and/or modify it under the | |
7 | // terms of the GNU General Public License as published by the | |
748086b7 | 8 | // Free Software Foundation; either version 3, or (at your option) |
725dc051 BK |
9 | // any later version. |
10 | ||
11 | // This library is distributed in the hope that it will be useful, | |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | // GNU General Public License for more details. | |
15 | ||
748086b7 JJ |
16 | // Under Section 7 of GPL version 3, you are granted additional |
17 | // permissions described in the GCC Runtime Library Exception, version | |
18 | // 3.1, as published by the Free Software Foundation. | |
19 | ||
20 | // You should have received a copy of the GNU General Public License and | |
21 | // a copy of the GCC Runtime Library Exception along with this program; | |
22 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
23 | // <http://www.gnu.org/licenses/>. | |
725dc051 | 24 | |
f910786b | 25 | /** @file bits/ios_base.h |
729e3d3f | 26 | * This is an internal header file, included by other library headers. |
f910786b | 27 | * Do not attempt to use it directly. @headername{ios} |
729e3d3f PE |
28 | */ |
29 | ||
143c27b0 BK |
30 | // |
31 | // ISO C++ 14882: 27.4 Iostreams base classes | |
32 | // | |
33 | ||
3d7c150e BK |
34 | #ifndef _IOS_BASE_H |
35 | #define _IOS_BASE_H 1 | |
725dc051 | 36 | |
b0a85b86 GDR |
37 | #pragma GCC system_header |
38 | ||
2e362c74 | 39 | #include <ext/atomicity.h> |
e6686813 BK |
40 | #include <bits/localefwd.h> |
41 | #include <bits/locale_classes.h> | |
1814157e | 42 | |
a5dde6dd JW |
43 | #if __cplusplus < 201103L |
44 | # include <stdexcept> | |
45 | #else | |
46 | # include <system_error> | |
47 | #endif | |
48 | ||
12ffa228 BK |
49 | namespace std _GLIBCXX_VISIBILITY(default) |
50 | { | |
51 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
3cbc7af0 | 52 | |
725dc051 BK |
53 | // The following definitions of bitmask types are enums, not ints, |
54 | // as permitted (but not required) in the standard, in order to provide | |
59c06f4d JW |
55 | // better type safety in iostream calls. A side effect is that in C++98 |
56 | // expressions involving them are not compile-time constants. | |
bd80bd9b BK |
57 | enum _Ios_Fmtflags |
58 | { | |
59 | _S_boolalpha = 1L << 0, | |
60 | _S_dec = 1L << 1, | |
61 | _S_fixed = 1L << 2, | |
62 | _S_hex = 1L << 3, | |
63 | _S_internal = 1L << 4, | |
64 | _S_left = 1L << 5, | |
65 | _S_oct = 1L << 6, | |
66 | _S_right = 1L << 7, | |
67 | _S_scientific = 1L << 8, | |
68 | _S_showbase = 1L << 9, | |
69 | _S_showpoint = 1L << 10, | |
70 | _S_showpos = 1L << 11, | |
71 | _S_skipws = 1L << 12, | |
72 | _S_unitbuf = 1L << 13, | |
73 | _S_uppercase = 1L << 14, | |
74 | _S_adjustfield = _S_left | _S_right | _S_internal, | |
75 | _S_basefield = _S_dec | _S_oct | _S_hex, | |
76 | _S_floatfield = _S_scientific | _S_fixed, | |
fbfae2f0 JW |
77 | _S_ios_fmtflags_end = 1L << 16, |
78 | _S_ios_fmtflags_max = __INT_MAX__, | |
79 | _S_ios_fmtflags_min = ~__INT_MAX__ | |
bd80bd9b | 80 | }; |
725dc051 | 81 | |
94a86be0 | 82 | inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags |
725dc051 BK |
83 | operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b) |
84 | { return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); } | |
85 | ||
94a86be0 | 86 | inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags |
725dc051 BK |
87 | operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b) |
88 | { return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); } | |
89 | ||
94a86be0 | 90 | inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags |
725dc051 BK |
91 | operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) |
92 | { return _Ios_Fmtflags(static_cast<int>(__a) ^ static_cast<int>(__b)); } | |
93 | ||
94a86be0 BK |
94 | inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags |
95 | operator~(_Ios_Fmtflags __a) | |
96 | { return _Ios_Fmtflags(~static_cast<int>(__a)); } | |
97 | ||
98 | inline const _Ios_Fmtflags& | |
725dc051 BK |
99 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) |
100 | { return __a = __a | __b; } | |
101 | ||
94a86be0 | 102 | inline const _Ios_Fmtflags& |
725dc051 BK |
103 | operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) |
104 | { return __a = __a & __b; } | |
105 | ||
94a86be0 | 106 | inline const _Ios_Fmtflags& |
725dc051 BK |
107 | operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) |
108 | { return __a = __a ^ __b; } | |
109 | ||
725dc051 | 110 | |
bd80bd9b BK |
111 | enum _Ios_Openmode |
112 | { | |
113 | _S_app = 1L << 0, | |
114 | _S_ate = 1L << 1, | |
115 | _S_bin = 1L << 2, | |
116 | _S_in = 1L << 3, | |
117 | _S_out = 1L << 4, | |
118 | _S_trunc = 1L << 5, | |
a219139e | 119 | _S_noreplace = 1L << 6, |
fbfae2f0 JW |
120 | _S_ios_openmode_end = 1L << 16, |
121 | _S_ios_openmode_max = __INT_MAX__, | |
122 | _S_ios_openmode_min = ~__INT_MAX__ | |
bd80bd9b | 123 | }; |
725dc051 | 124 | |
94a86be0 | 125 | inline _GLIBCXX_CONSTEXPR _Ios_Openmode |
725dc051 BK |
126 | operator&(_Ios_Openmode __a, _Ios_Openmode __b) |
127 | { return _Ios_Openmode(static_cast<int>(__a) & static_cast<int>(__b)); } | |
128 | ||
94a86be0 | 129 | inline _GLIBCXX_CONSTEXPR _Ios_Openmode |
725dc051 BK |
130 | operator|(_Ios_Openmode __a, _Ios_Openmode __b) |
131 | { return _Ios_Openmode(static_cast<int>(__a) | static_cast<int>(__b)); } | |
132 | ||
94a86be0 | 133 | inline _GLIBCXX_CONSTEXPR _Ios_Openmode |
725dc051 BK |
134 | operator^(_Ios_Openmode __a, _Ios_Openmode __b) |
135 | { return _Ios_Openmode(static_cast<int>(__a) ^ static_cast<int>(__b)); } | |
136 | ||
94a86be0 BK |
137 | inline _GLIBCXX_CONSTEXPR _Ios_Openmode |
138 | operator~(_Ios_Openmode __a) | |
139 | { return _Ios_Openmode(~static_cast<int>(__a)); } | |
140 | ||
141 | inline const _Ios_Openmode& | |
725dc051 BK |
142 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) |
143 | { return __a = __a | __b; } | |
144 | ||
94a86be0 | 145 | inline const _Ios_Openmode& |
725dc051 BK |
146 | operator&=(_Ios_Openmode& __a, _Ios_Openmode __b) |
147 | { return __a = __a & __b; } | |
148 | ||
94a86be0 | 149 | inline const _Ios_Openmode& |
725dc051 BK |
150 | operator^=(_Ios_Openmode& __a, _Ios_Openmode __b) |
151 | { return __a = __a ^ __b; } | |
152 | ||
725dc051 | 153 | |
bd80bd9b BK |
154 | enum _Ios_Iostate |
155 | { | |
156 | _S_goodbit = 0, | |
157 | _S_badbit = 1L << 0, | |
158 | _S_eofbit = 1L << 1, | |
159 | _S_failbit = 1L << 2, | |
fbfae2f0 JW |
160 | _S_ios_iostate_end = 1L << 16, |
161 | _S_ios_iostate_max = __INT_MAX__, | |
162 | _S_ios_iostate_min = ~__INT_MAX__ | |
bd80bd9b | 163 | }; |
725dc051 | 164 | |
94a86be0 | 165 | inline _GLIBCXX_CONSTEXPR _Ios_Iostate |
725dc051 BK |
166 | operator&(_Ios_Iostate __a, _Ios_Iostate __b) |
167 | { return _Ios_Iostate(static_cast<int>(__a) & static_cast<int>(__b)); } | |
168 | ||
94a86be0 | 169 | inline _GLIBCXX_CONSTEXPR _Ios_Iostate |
725dc051 BK |
170 | operator|(_Ios_Iostate __a, _Ios_Iostate __b) |
171 | { return _Ios_Iostate(static_cast<int>(__a) | static_cast<int>(__b)); } | |
172 | ||
94a86be0 | 173 | inline _GLIBCXX_CONSTEXPR _Ios_Iostate |
725dc051 BK |
174 | operator^(_Ios_Iostate __a, _Ios_Iostate __b) |
175 | { return _Ios_Iostate(static_cast<int>(__a) ^ static_cast<int>(__b)); } | |
176 | ||
94a86be0 BK |
177 | inline _GLIBCXX_CONSTEXPR _Ios_Iostate |
178 | operator~(_Ios_Iostate __a) | |
179 | { return _Ios_Iostate(~static_cast<int>(__a)); } | |
180 | ||
181 | inline const _Ios_Iostate& | |
725dc051 BK |
182 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) |
183 | { return __a = __a | __b; } | |
184 | ||
94a86be0 | 185 | inline const _Ios_Iostate& |
725dc051 BK |
186 | operator&=(_Ios_Iostate& __a, _Ios_Iostate __b) |
187 | { return __a = __a & __b; } | |
188 | ||
94a86be0 | 189 | inline const _Ios_Iostate& |
725dc051 BK |
190 | operator^=(_Ios_Iostate& __a, _Ios_Iostate __b) |
191 | { return __a = __a ^ __b; } | |
192 | ||
725dc051 | 193 | |
bd80bd9b BK |
194 | enum _Ios_Seekdir |
195 | { | |
196 | _S_beg = 0, | |
ddc9c40d PC |
197 | _S_cur = _GLIBCXX_STDIO_SEEK_CUR, |
198 | _S_end = _GLIBCXX_STDIO_SEEK_END, | |
bd80bd9b BK |
199 | _S_ios_seekdir_end = 1L << 16 |
200 | }; | |
725dc051 | 201 | |
a5dde6dd JW |
202 | #if __cplusplus >= 201103L |
203 | /// I/O error code | |
204 | enum class io_errc { stream = 1 }; | |
205 | ||
206 | template <> struct is_error_code_enum<io_errc> : public true_type { }; | |
207 | ||
208 | const error_category& iostream_category() noexcept; | |
209 | ||
210 | inline error_code | |
d34d36ef JW |
211 | make_error_code(io_errc __e) noexcept |
212 | { return error_code(static_cast<int>(__e), iostream_category()); } | |
a5dde6dd JW |
213 | |
214 | inline error_condition | |
d34d36ef JW |
215 | make_error_condition(io_errc __e) noexcept |
216 | { return error_condition(static_cast<int>(__e), iostream_category()); } | |
a5dde6dd JW |
217 | #endif |
218 | ||
725dc051 | 219 | // 27.4.2 Class ios_base |
840ceb34 | 220 | /** |
00aca6e8 | 221 | * @brief The base of the I/O class hierarchy. |
5b9daa7e | 222 | * @ingroup io |
840ceb34 PE |
223 | * |
224 | * This class defines everything that can be defined about I/O that does | |
225 | * not depend on the type of characters being input or output. Most | |
226 | * people will only see @c ios_base when they need to specify the full | |
227 | * name of the various I/O flags (e.g., the openmodes). | |
228 | */ | |
725dc051 BK |
229 | class ios_base |
230 | { | |
a5dde6dd JW |
231 | #if _GLIBCXX_USE_CXX11_ABI |
232 | #if __cplusplus < 201103L | |
233 | // Type that is layout-compatible with std::system_error | |
234 | struct system_error : std::runtime_error | |
235 | { | |
236 | // Type that is layout-compatible with std::error_code | |
237 | struct error_code | |
238 | { | |
239 | error_code() { } | |
240 | private: | |
241 | int _M_value; | |
242 | const void* _M_cat; | |
243 | } _M_code; | |
244 | }; | |
245 | #endif | |
246 | #endif | |
725dc051 | 247 | public: |
ed6814f7 | 248 | |
5b9daa7e BK |
249 | /** |
250 | * @brief These are thrown to indicate problems with io. | |
251 | * @ingroup exceptions | |
252 | * | |
253 | * 27.4.2.1.1 Class ios_base::failure | |
254 | */ | |
a5dde6dd JW |
255 | #if _GLIBCXX_USE_CXX11_ABI |
256 | class _GLIBCXX_ABI_TAG_CXX11 failure : public system_error | |
257 | { | |
258 | public: | |
259 | explicit | |
260 | failure(const string& __str); | |
261 | ||
262 | #if __cplusplus >= 201103L | |
263 | explicit | |
264 | failure(const string&, const error_code&); | |
265 | ||
266 | explicit | |
267 | failure(const char*, const error_code& = io_errc::stream); | |
268 | #endif | |
269 | ||
270 | virtual | |
271 | ~failure() throw(); | |
272 | ||
273 | virtual const char* | |
274 | what() const throw(); | |
275 | }; | |
276 | #else | |
725dc051 BK |
277 | class failure : public exception |
278 | { | |
279 | public: | |
f5677b15 PC |
280 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
281 | // 48. Use of non-existent exception constructor | |
ed6814f7 | 282 | explicit |
d34786e3 | 283 | failure(const string& __str) throw(); |
725dc051 | 284 | |
663653eb | 285 | // This declaration is not useless: |
a40fff0e | 286 | // http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Vague-Linkage.html |
ed6814f7 | 287 | virtual |
d34786e3 | 288 | ~failure() throw(); |
725dc051 | 289 | |
23a5b444 GDR |
290 | virtual const char* |
291 | what() const throw(); | |
ed6814f7 | 292 | |
f997b675 JW |
293 | #if __cplusplus >= 201103L |
294 | // Define the new members required by C++11, | |
295 | // even though the error_code cannot be stored. | |
296 | ||
297 | explicit | |
298 | failure(const string& __s, const error_code&) noexcept | |
299 | : failure(__s) | |
300 | { } | |
301 | ||
302 | explicit | |
303 | failure(const char* __s, const error_code& = error_code{}) | |
304 | : failure(string(__s)) | |
305 | { } | |
306 | ||
307 | // Stand-in for system_error::code() but returning by value. | |
308 | error_code code() const noexcept { return error_code{}; } | |
309 | #endif | |
310 | ||
725dc051 | 311 | private: |
93d04686 | 312 | string _M_msg; |
725dc051 | 313 | }; |
a5dde6dd | 314 | #endif |
725dc051 BK |
315 | |
316 | // 27.4.2.1.2 Type ios_base::fmtflags | |
840ceb34 PE |
317 | /** |
318 | * @brief This is a bitmask type. | |
319 | * | |
2a60a9f6 | 320 | * @c @a _Ios_Fmtflags is implementation-defined, but it is valid to |
840ceb34 PE |
321 | * perform bitwise operations on these values and expect the Right |
322 | * Thing to happen. Defined objects of type fmtflags are: | |
323 | * - boolalpha | |
324 | * - dec | |
325 | * - fixed | |
326 | * - hex | |
327 | * - internal | |
328 | * - left | |
329 | * - oct | |
330 | * - right | |
331 | * - scientific | |
332 | * - showbase | |
333 | * - showpoint | |
334 | * - showpos | |
335 | * - skipws | |
336 | * - unitbuf | |
337 | * - uppercase | |
338 | * - adjustfield | |
339 | * - basefield | |
340 | * - floatfield | |
341 | */ | |
725dc051 | 342 | typedef _Ios_Fmtflags fmtflags; |
215f9e28 | 343 | |
840ceb34 | 344 | /// Insert/extract @c bool in alphabetic rather than numeric format. |
e3dfd6d5 | 345 | static const fmtflags boolalpha = _S_boolalpha; |
215f9e28 | 346 | |
840ceb34 | 347 | /// Converts integer input or generates integer output in decimal base. |
e3dfd6d5 | 348 | static const fmtflags dec = _S_dec; |
215f9e28 | 349 | |
840ceb34 | 350 | /// Generate floating-point output in fixed-point notation. |
e3dfd6d5 | 351 | static const fmtflags fixed = _S_fixed; |
215f9e28 | 352 | |
840ceb34 | 353 | /// Converts integer input or generates integer output in hexadecimal base. |
e3dfd6d5 | 354 | static const fmtflags hex = _S_hex; |
215f9e28 | 355 | |
840ceb34 PE |
356 | /// Adds fill characters at a designated internal point in certain |
357 | /// generated output, or identical to @c right if no such point is | |
358 | /// designated. | |
e3dfd6d5 | 359 | static const fmtflags internal = _S_internal; |
215f9e28 | 360 | |
840ceb34 PE |
361 | /// Adds fill characters on the right (final positions) of certain |
362 | /// generated output. (I.e., the thing you print is flush left.) | |
e3dfd6d5 | 363 | static const fmtflags left = _S_left; |
215f9e28 | 364 | |
840ceb34 | 365 | /// Converts integer input or generates integer output in octal base. |
e3dfd6d5 | 366 | static const fmtflags oct = _S_oct; |
215f9e28 | 367 | |
840ceb34 PE |
368 | /// Adds fill characters on the left (initial positions) of certain |
369 | /// generated output. (I.e., the thing you print is flush right.) | |
e3dfd6d5 | 370 | static const fmtflags right = _S_right; |
215f9e28 | 371 | |
840ceb34 | 372 | /// Generates floating-point output in scientific notation. |
e3dfd6d5 | 373 | static const fmtflags scientific = _S_scientific; |
215f9e28 | 374 | |
840ceb34 PE |
375 | /// Generates a prefix indicating the numeric base of generated integer |
376 | /// output. | |
e3dfd6d5 | 377 | static const fmtflags showbase = _S_showbase; |
215f9e28 | 378 | |
840ceb34 PE |
379 | /// Generates a decimal-point character unconditionally in generated |
380 | /// floating-point output. | |
e3dfd6d5 | 381 | static const fmtflags showpoint = _S_showpoint; |
215f9e28 | 382 | |
840ceb34 | 383 | /// Generates a + sign in non-negative generated numeric output. |
e3dfd6d5 | 384 | static const fmtflags showpos = _S_showpos; |
215f9e28 | 385 | |
840ceb34 | 386 | /// Skips leading white space before certain input operations. |
e3dfd6d5 | 387 | static const fmtflags skipws = _S_skipws; |
215f9e28 | 388 | |
840ceb34 | 389 | /// Flushes output after each output operation. |
e3dfd6d5 | 390 | static const fmtflags unitbuf = _S_unitbuf; |
215f9e28 | 391 | |
840ceb34 PE |
392 | /// Replaces certain lowercase letters with their uppercase equivalents |
393 | /// in generated output. | |
e3dfd6d5 | 394 | static const fmtflags uppercase = _S_uppercase; |
215f9e28 | 395 | |
840ceb34 | 396 | /// A mask of left|right|internal. Useful for the 2-arg form of @c setf. |
e3dfd6d5 | 397 | static const fmtflags adjustfield = _S_adjustfield; |
215f9e28 | 398 | |
840ceb34 | 399 | /// A mask of dec|oct|hex. Useful for the 2-arg form of @c setf. |
e3dfd6d5 | 400 | static const fmtflags basefield = _S_basefield; |
215f9e28 | 401 | |
840ceb34 | 402 | /// A mask of scientific|fixed. Useful for the 2-arg form of @c setf. |
e3dfd6d5 | 403 | static const fmtflags floatfield = _S_floatfield; |
725dc051 BK |
404 | |
405 | // 27.4.2.1.3 Type ios_base::iostate | |
840ceb34 PE |
406 | /** |
407 | * @brief This is a bitmask type. | |
408 | * | |
2a60a9f6 | 409 | * @c @a _Ios_Iostate is implementation-defined, but it is valid to |
840ceb34 PE |
410 | * perform bitwise operations on these values and expect the Right |
411 | * Thing to happen. Defined objects of type iostate are: | |
412 | * - badbit | |
413 | * - eofbit | |
414 | * - failbit | |
415 | * - goodbit | |
416 | */ | |
725dc051 | 417 | typedef _Ios_Iostate iostate; |
215f9e28 | 418 | |
840ceb34 PE |
419 | /// Indicates a loss of integrity in an input or output sequence (such |
420 | /// as an irrecoverable read error from a file). | |
e3dfd6d5 | 421 | static const iostate badbit = _S_badbit; |
215f9e28 | 422 | |
840ceb34 | 423 | /// Indicates that an input operation reached the end of an input sequence. |
e3dfd6d5 | 424 | static const iostate eofbit = _S_eofbit; |
215f9e28 | 425 | |
840ceb34 PE |
426 | /// Indicates that an input operation failed to read the expected |
427 | /// characters, or that an output operation failed to generate the | |
428 | /// desired characters. | |
e3dfd6d5 | 429 | static const iostate failbit = _S_failbit; |
215f9e28 | 430 | |
840ceb34 | 431 | /// Indicates all is well. |
e3dfd6d5 | 432 | static const iostate goodbit = _S_goodbit; |
725dc051 | 433 | |
840ceb34 PE |
434 | // 27.4.2.1.4 Type ios_base::openmode |
435 | /** | |
436 | * @brief This is a bitmask type. | |
437 | * | |
2a60a9f6 | 438 | * @c @a _Ios_Openmode is implementation-defined, but it is valid to |
840ceb34 PE |
439 | * perform bitwise operations on these values and expect the Right |
440 | * Thing to happen. Defined objects of type openmode are: | |
441 | * - app | |
442 | * - ate | |
443 | * - binary | |
444 | * - in | |
445 | * - out | |
446 | * - trunc | |
447 | */ | |
725dc051 | 448 | typedef _Ios_Openmode openmode; |
215f9e28 | 449 | |
840ceb34 | 450 | /// Seek to end before each write. |
e3dfd6d5 | 451 | static const openmode app = _S_app; |
215f9e28 | 452 | |
840ceb34 | 453 | /// Open and seek to end immediately after opening. |
e3dfd6d5 | 454 | static const openmode ate = _S_ate; |
215f9e28 | 455 | |
840ceb34 PE |
456 | /// Perform input and output in binary mode (as opposed to text mode). |
457 | /// This is probably not what you think it is; see | |
10d43d2f | 458 | /// https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary |
e3dfd6d5 | 459 | static const openmode binary = _S_bin; |
215f9e28 | 460 | |
840ceb34 | 461 | /// Open for input. Default for @c ifstream and fstream. |
e3dfd6d5 | 462 | static const openmode in = _S_in; |
215f9e28 | 463 | |
840ceb34 | 464 | /// Open for output. Default for @c ofstream and fstream. |
e3dfd6d5 | 465 | static const openmode out = _S_out; |
215f9e28 | 466 | |
91fd16a7 | 467 | /// Truncate an existing stream when opening. Default for @c ofstream. |
e3dfd6d5 | 468 | static const openmode trunc = _S_trunc; |
725dc051 | 469 | |
a219139e JW |
470 | static const openmode __noreplace = _S_noreplace; |
471 | ||
472 | #if __cplusplus >= 202100L | |
473 | #define __cpp_lib_ios_noreplace 202200L | |
474 | /// Open a file in exclusive mode. | |
475 | static const openmode noreplace = _S_noreplace; | |
476 | #endif | |
477 | ||
840ceb34 PE |
478 | // 27.4.2.1.5 Type ios_base::seekdir |
479 | /** | |
480 | * @brief This is an enumerated type. | |
481 | * | |
2a60a9f6 | 482 | * @c @a _Ios_Seekdir is implementation-defined. Defined values |
840ceb34 PE |
483 | * of type seekdir are: |
484 | * - beg | |
485 | * - cur, equivalent to @c SEEK_CUR in the C standard library. | |
486 | * - end, equivalent to @c SEEK_END in the C standard library. | |
487 | */ | |
725dc051 | 488 | typedef _Ios_Seekdir seekdir; |
215f9e28 | 489 | |
840ceb34 | 490 | /// Request a seek relative to the beginning of the stream. |
e3dfd6d5 | 491 | static const seekdir beg = _S_beg; |
215f9e28 | 492 | |
840ceb34 | 493 | /// Request a seek relative to the current position within the sequence. |
e3dfd6d5 | 494 | static const seekdir cur = _S_cur; |
215f9e28 | 495 | |
840ceb34 | 496 | /// Request a seek relative to the current end of the sequence. |
e3dfd6d5 | 497 | static const seekdir end = _S_end; |
725dc051 | 498 | |
a74bc411 JW |
499 | #if __cplusplus <= 201402L |
500 | // Annex D.6 (removed in C++17) | |
eef9bf4c JW |
501 | typedef int io_state |
502 | _GLIBCXX_DEPRECATED_SUGGEST("std::iostate"); | |
503 | typedef int open_mode | |
504 | _GLIBCXX_DEPRECATED_SUGGEST("std::openmode"); | |
505 | typedef int seek_dir | |
506 | _GLIBCXX_DEPRECATED_SUGGEST("std::seekdir"); | |
507 | ||
508 | typedef std::streampos streampos | |
509 | _GLIBCXX_DEPRECATED_SUGGEST("std::streampos"); | |
510 | typedef std::streamoff streamoff | |
511 | _GLIBCXX_DEPRECATED_SUGGEST("std::streamoff"); | |
a74bc411 | 512 | #endif |
725dc051 BK |
513 | |
514 | // Callbacks; | |
840ceb34 | 515 | /** |
e2fcbaa3 JQ |
516 | * @brief The set of events that may be passed to an event callback. |
517 | * | |
518 | * erase_event is used during ~ios() and copyfmt(). imbue_event is used | |
519 | * during imbue(). copyfmt_event is used during copyfmt(). | |
840ceb34 | 520 | */ |
725dc051 BK |
521 | enum event |
522 | { | |
523 | erase_event, | |
524 | imbue_event, | |
525 | copyfmt_event | |
526 | }; | |
527 | ||
840ceb34 | 528 | /** |
e2fcbaa3 | 529 | * @brief The type of an event callback function. |
93c66bc6 BK |
530 | * @param __e One of the members of the event enum. |
531 | * @param __b Reference to the ios_base object. | |
532 | * @param __i The integer provided when the callback was registered. | |
e2fcbaa3 JQ |
533 | * |
534 | * Event callbacks are user defined functions that get called during | |
535 | * several ios_base and basic_ios functions, specifically imbue(), | |
536 | * copyfmt(), and ~ios(). | |
840ceb34 | 537 | */ |
93c66bc6 | 538 | typedef void (*event_callback) (event __e, ios_base& __b, int __i); |
725dc051 | 539 | |
840ceb34 | 540 | /** |
e2fcbaa3 JQ |
541 | * @brief Add the callback __fn with parameter __index. |
542 | * @param __fn The function to add. | |
543 | * @param __index The integer to pass to the function when invoked. | |
544 | * | |
545 | * Registers a function as an event callback with an integer parameter to | |
546 | * be passed to the function when invoked. Multiple copies of the | |
547 | * function are allowed. If there are multiple callbacks, they are | |
548 | * invoked in the order they were registered. | |
840ceb34 | 549 | */ |
ed6814f7 | 550 | void |
725dc051 BK |
551 | register_callback(event_callback __fn, int __index); |
552 | ||
553 | protected: | |
ed6814f7 BI |
554 | streamsize _M_precision; |
555 | streamsize _M_width; | |
556 | fmtflags _M_flags; | |
557 | iostate _M_exception; | |
558 | iostate _M_streambuf_state; | |
725dc051 | 559 | |
d9ab8adb | 560 | // 27.4.2.6 Members for callbacks |
725dc051 | 561 | // 27.4.2.6 ios_base callbacks |
725dc051 BK |
562 | struct _Callback_list |
563 | { | |
564 | // Data Members | |
ed6814f7 BI |
565 | _Callback_list* _M_next; |
566 | ios_base::event_callback _M_fn; | |
567 | int _M_index; | |
17325050 | 568 | _Atomic_word _M_refcount; // 0 means one reference. |
ed6814f7 BI |
569 | |
570 | _Callback_list(ios_base::event_callback __fn, int __index, | |
725dc051 BK |
571 | _Callback_list* __cb) |
572 | : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { } | |
ed6814f7 BI |
573 | |
574 | void | |
b7ee72de | 575 | _M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); } |
17325050 | 576 | |
663653eb | 577 | // 0 => OK to delete. |
ed6814f7 | 578 | int |
2c5d0ae8 | 579 | _M_remove_reference() |
be335b18 KS |
580 | { |
581 | // Be race-detector-friendly. For more info see bits/c++config. | |
8c61f400 | 582 | _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount); |
be335b18 KS |
583 | int __res = __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1); |
584 | if (__res == 0) | |
585 | { | |
8c61f400 | 586 | _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount); |
be335b18 KS |
587 | } |
588 | return __res; | |
589 | } | |
725dc051 BK |
590 | }; |
591 | ||
ed6814f7 | 592 | _Callback_list* _M_callbacks; |
725dc051 | 593 | |
ed6814f7 | 594 | void |
725dc051 BK |
595 | _M_call_callbacks(event __ev) throw(); |
596 | ||
ed6814f7 | 597 | void |
50a681c4 | 598 | _M_dispose_callbacks(void) throw(); |
725dc051 | 599 | |
d9ab8adb | 600 | // 27.4.2.5 Members for iword/pword storage |
ed6814f7 BI |
601 | struct _Words |
602 | { | |
603 | void* _M_pword; | |
604 | long _M_iword; | |
663653eb | 605 | _Words() : _M_pword(0), _M_iword(0) { } |
725dc051 BK |
606 | }; |
607 | ||
663653eb | 608 | // Only for failed iword/pword calls. |
ed6814f7 | 609 | _Words _M_word_zero; |
663653eb BK |
610 | |
611 | // Guaranteed storage. | |
2e2a38cd | 612 | // The first 5 iword and pword slots are reserved for internal use. |
e3dfd6d5 | 613 | enum { _S_local_word_size = 8 }; |
ed6814f7 | 614 | _Words _M_local_word[_S_local_word_size]; |
663653eb BK |
615 | |
616 | // Allocated storage. | |
ed6814f7 BI |
617 | int _M_word_size; |
618 | _Words* _M_word; | |
619 | ||
620 | _Words& | |
2a837cf8 | 621 | _M_grow_words(int __index, bool __iword); |
725dc051 BK |
622 | |
623 | // Members for locale and locale caching. | |
ed6814f7 | 624 | locale _M_ios_locale; |
725dc051 | 625 | |
ed6814f7 | 626 | void |
32ade559 | 627 | _M_init() throw(); |
725dc051 BK |
628 | |
629 | public: | |
d9ab8adb | 630 | |
725dc051 BK |
631 | // 27.4.2.1.6 Class ios_base::Init |
632 | // Used to initialize standard streams. In theory, g++ could use | |
633 | // -finit-priority to order this stuff correctly without going | |
ed6814f7 BI |
634 | // through these machinations. |
635 | class Init | |
725dc051 BK |
636 | { |
637 | friend class ios_base; | |
638 | public: | |
639 | Init(); | |
640 | ~Init(); | |
ed6814f7 | 641 | |
a1417556 JW |
642 | #if __cplusplus >= 201103L |
643 | Init(const Init&) = default; | |
644 | Init& operator=(const Init&) = default; | |
645 | #endif | |
646 | ||
725dc051 | 647 | private: |
fa972243 BK |
648 | static _Atomic_word _S_refcount; |
649 | static bool _S_synced_with_stdio; | |
725dc051 BK |
650 | }; |
651 | ||
840ceb34 PE |
652 | // [27.4.2.2] fmtflags state functions |
653 | /** | |
654 | * @brief Access to format flags. | |
655 | * @return The format control flags for both input and output. | |
656 | */ | |
dd42abcc PC |
657 | fmtflags |
658 | flags() const | |
659 | { return _M_flags; } | |
725dc051 | 660 | |
840ceb34 PE |
661 | /** |
662 | * @brief Setting new format flags all at once. | |
93c66bc6 | 663 | * @param __fmtfl The new flags to set. |
840ceb34 PE |
664 | * @return The previous format control flags. |
665 | * | |
93c66bc6 | 666 | * This function overwrites all the format flags with @a __fmtfl. |
840ceb34 | 667 | */ |
dd42abcc | 668 | fmtflags |
725dc051 | 669 | flags(fmtflags __fmtfl) |
ed6814f7 BI |
670 | { |
671 | fmtflags __old = _M_flags; | |
672 | _M_flags = __fmtfl; | |
673 | return __old; | |
725dc051 BK |
674 | } |
675 | ||
840ceb34 PE |
676 | /** |
677 | * @brief Setting new format flags. | |
93c66bc6 | 678 | * @param __fmtfl Additional flags to set. |
840ceb34 PE |
679 | * @return The previous format control flags. |
680 | * | |
681 | * This function sets additional flags in format control. Flags that | |
682 | * were previously set remain set. | |
683 | */ | |
dd42abcc | 684 | fmtflags |
725dc051 | 685 | setf(fmtflags __fmtfl) |
ed6814f7 BI |
686 | { |
687 | fmtflags __old = _M_flags; | |
688 | _M_flags |= __fmtfl; | |
689 | return __old; | |
725dc051 BK |
690 | } |
691 | ||
840ceb34 PE |
692 | /** |
693 | * @brief Setting new format flags. | |
93c66bc6 BK |
694 | * @param __fmtfl Additional flags to set. |
695 | * @param __mask The flags mask for @a fmtfl. | |
840ceb34 PE |
696 | * @return The previous format control flags. |
697 | * | |
698 | * This function clears @a mask in the format flags, then sets | |
699 | * @a fmtfl @c & @a mask. An example mask is @c ios_base::adjustfield. | |
700 | */ | |
dd42abcc | 701 | fmtflags |
725dc051 BK |
702 | setf(fmtflags __fmtfl, fmtflags __mask) |
703 | { | |
704 | fmtflags __old = _M_flags; | |
705 | _M_flags &= ~__mask; | |
706 | _M_flags |= (__fmtfl & __mask); | |
707 | return __old; | |
708 | } | |
709 | ||
840ceb34 PE |
710 | /** |
711 | * @brief Clearing format flags. | |
93c66bc6 | 712 | * @param __mask The flags to unset. |
840ceb34 | 713 | * |
93c66bc6 | 714 | * This function clears @a __mask in the format flags. |
840ceb34 | 715 | */ |
dd42abcc PC |
716 | void |
717 | unsetf(fmtflags __mask) | |
718 | { _M_flags &= ~__mask; } | |
725dc051 | 719 | |
840ceb34 PE |
720 | /** |
721 | * @brief Flags access. | |
722 | * @return The precision to generate on certain output operations. | |
723 | * | |
2a60a9f6 | 724 | * Be careful if you try to give a definition of @a precision here; see |
840ceb34 | 725 | * DR 189. |
840ceb34 | 726 | */ |
dd42abcc PC |
727 | streamsize |
728 | precision() const | |
729 | { return _M_precision; } | |
725dc051 | 730 | |
840ceb34 PE |
731 | /** |
732 | * @brief Changing flags. | |
93c66bc6 | 733 | * @param __prec The new precision value. |
840ceb34 PE |
734 | * @return The previous value of precision(). |
735 | */ | |
dd42abcc | 736 | streamsize |
725dc051 | 737 | precision(streamsize __prec) |
ed6814f7 BI |
738 | { |
739 | streamsize __old = _M_precision; | |
740 | _M_precision = __prec; | |
741 | return __old; | |
725dc051 BK |
742 | } |
743 | ||
840ceb34 PE |
744 | /** |
745 | * @brief Flags access. | |
746 | * @return The minimum field width to generate on output operations. | |
747 | * | |
2a60a9f6 | 748 | * <em>Minimum field width</em> refers to the number of characters. |
840ceb34 | 749 | */ |
dd42abcc PC |
750 | streamsize |
751 | width() const | |
752 | { return _M_width; } | |
725dc051 | 753 | |
840ceb34 PE |
754 | /** |
755 | * @brief Changing flags. | |
93c66bc6 | 756 | * @param __wide The new width value. |
840ceb34 PE |
757 | * @return The previous value of width(). |
758 | */ | |
dd42abcc | 759 | streamsize |
725dc051 | 760 | width(streamsize __wide) |
ed6814f7 BI |
761 | { |
762 | streamsize __old = _M_width; | |
763 | _M_width = __wide; | |
764 | return __old; | |
725dc051 BK |
765 | } |
766 | ||
840ceb34 PE |
767 | // [27.4.2.4] ios_base static members |
768 | /** | |
769 | * @brief Interaction with the standard C I/O objects. | |
93c66bc6 | 770 | * @param __sync Whether to synchronize or not. |
840ceb34 PE |
771 | * @return True if the standard streams were previously synchronized. |
772 | * | |
773 | * The synchronization referred to is @e only that between the standard | |
774 | * C facilities (e.g., stdout) and the standard C++ objects (e.g., | |
775 | * cout). User-declared streams are unaffected. See | |
10d43d2f | 776 | * https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary |
840ceb34 | 777 | */ |
ed6814f7 | 778 | static bool |
725dc051 BK |
779 | sync_with_stdio(bool __sync = true); |
780 | ||
840ceb34 PE |
781 | // [27.4.2.3] ios_base locale functions |
782 | /** | |
783 | * @brief Setting a new locale. | |
93c66bc6 | 784 | * @param __loc The new locale. |
840ceb34 PE |
785 | * @return The previous locale. |
786 | * | |
e2fcbaa3 JQ |
787 | * Sets the new locale for this stream, and then invokes each callback |
788 | * with imbue_event. | |
840ceb34 | 789 | */ |
ed6814f7 | 790 | locale |
32ade559 | 791 | imbue(const locale& __loc) throw(); |
725dc051 | 792 | |
840ceb34 PE |
793 | /** |
794 | * @brief Locale access | |
215f9e28 | 795 | * @return A copy of the current locale. |
840ceb34 PE |
796 | * |
797 | * If @c imbue(loc) has previously been called, then this function | |
798 | * returns @c loc. Otherwise, it returns a copy of @c std::locale(), | |
799 | * the global C++ locale. | |
800 | */ | |
dd42abcc PC |
801 | locale |
802 | getloc() const | |
803 | { return _M_ios_locale; } | |
725dc051 | 804 | |
215f9e28 BK |
805 | /** |
806 | * @brief Locale access | |
807 | * @return A reference to the current locale. | |
808 | * | |
809 | * Like getloc above, but returns a reference instead of | |
810 | * generating a copy. | |
811 | */ | |
dd42abcc PC |
812 | const locale& |
813 | _M_getloc() const | |
814 | { return _M_ios_locale; } | |
215f9e28 | 815 | |
840ceb34 PE |
816 | // [27.4.2.5] ios_base storage functions |
817 | /** | |
e2fcbaa3 JQ |
818 | * @brief Access to unique indices. |
819 | * @return An integer different from all previous calls. | |
820 | * | |
821 | * This function returns a unique integer every time it is called. It | |
822 | * can be used for any purpose, but is primarily intended to be a unique | |
823 | * index for the iword and pword functions. The expectation is that an | |
824 | * application calls xalloc in order to obtain an index in the iword and | |
825 | * pword arrays that can be used without fear of conflict. | |
826 | * | |
827 | * The implementation maintains a static variable that is incremented and | |
828 | * returned on each invocation. xalloc is guaranteed to return an index | |
829 | * that is safe to use in the iword and pword arrays. | |
840ceb34 | 830 | */ |
ed6814f7 | 831 | static int |
725dc051 BK |
832 | xalloc() throw(); |
833 | ||
840ceb34 | 834 | /** |
e2fcbaa3 JQ |
835 | * @brief Access to integer array. |
836 | * @param __ix Index into the array. | |
837 | * @return A reference to an integer associated with the index. | |
838 | * | |
839 | * The iword function provides access to an array of integers that can be | |
840 | * used for any purpose. The array grows as required to hold the | |
841 | * supplied index. All integers in the array are initialized to 0. | |
842 | * | |
843 | * The implementation reserves several indices. You should use xalloc to | |
844 | * obtain an index that is safe to use. Also note that since the array | |
845 | * can grow dynamically, it is not safe to hold onto the reference. | |
840ceb34 | 846 | */ |
dd42abcc | 847 | long& |
725dc051 BK |
848 | iword(int __ix) |
849 | { | |
85d0fad4 | 850 | _Words& __word = ((unsigned)__ix < (unsigned)_M_word_size) |
2a837cf8 | 851 | ? _M_word[__ix] : _M_grow_words(__ix, true); |
725dc051 BK |
852 | return __word._M_iword; |
853 | } | |
854 | ||
840ceb34 | 855 | /** |
e2fcbaa3 JQ |
856 | * @brief Access to void pointer array. |
857 | * @param __ix Index into the array. | |
858 | * @return A reference to a void* associated with the index. | |
859 | * | |
860 | * The pword function provides access to an array of pointers that can be | |
861 | * used for any purpose. The array grows as required to hold the | |
862 | * supplied index. All pointers in the array are initialized to 0. | |
863 | * | |
864 | * The implementation reserves several indices. You should use xalloc to | |
865 | * obtain an index that is safe to use. Also note that since the array | |
866 | * can grow dynamically, it is not safe to hold onto the reference. | |
840ceb34 | 867 | */ |
dd42abcc | 868 | void*& |
725dc051 BK |
869 | pword(int __ix) |
870 | { | |
85d0fad4 | 871 | _Words& __word = ((unsigned)__ix < (unsigned)_M_word_size) |
2a837cf8 | 872 | ? _M_word[__ix] : _M_grow_words(__ix, false); |
725dc051 BK |
873 | return __word._M_pword; |
874 | } | |
875 | ||
876 | // Destructor | |
840ceb34 | 877 | /** |
e2fcbaa3 JQ |
878 | * Invokes each callback with erase_event. Destroys local storage. |
879 | * | |
880 | * Note that the ios_base object for the standard streams never gets | |
881 | * destroyed. As a result, any callbacks registered with the standard | |
882 | * streams will not get invoked with erase_event (unless copyfmt is | |
883 | * used). | |
840ceb34 | 884 | */ |
cb930542 | 885 | virtual ~ios_base(); |
725dc051 BK |
886 | |
887 | protected: | |
50a681c4 | 888 | ios_base() throw (); |
725dc051 | 889 | |
f0fd118f | 890 | #if __cplusplus < 201103L |
f5677b15 PC |
891 | // _GLIBCXX_RESOLVE_LIB_DEFECTS |
892 | // 50. Copy constructor and assignment operator of ios_base | |
725dc051 BK |
893 | private: |
894 | ios_base(const ios_base&); | |
895 | ||
ed6814f7 | 896 | ios_base& |
725dc051 | 897 | operator=(const ios_base&); |
f0fd118f JW |
898 | #else |
899 | public: | |
900 | ios_base(const ios_base&) = delete; | |
901 | ||
902 | ios_base& | |
903 | operator=(const ios_base&) = delete; | |
9b817548 JW |
904 | |
905 | protected: | |
906 | void | |
907 | _M_move(ios_base&) noexcept; | |
908 | ||
909 | void | |
910 | _M_swap(ios_base& __rhs) noexcept; | |
f0fd118f | 911 | #endif |
725dc051 | 912 | }; |
ed6814f7 | 913 | |
840ceb34 PE |
914 | // [27.4.5.1] fmtflags manipulators |
915 | /// Calls base.setf(ios_base::boolalpha). | |
ed6814f7 | 916 | inline ios_base& |
725dc051 BK |
917 | boolalpha(ios_base& __base) |
918 | { | |
919 | __base.setf(ios_base::boolalpha); | |
920 | return __base; | |
921 | } | |
922 | ||
840ceb34 | 923 | /// Calls base.unsetf(ios_base::boolalpha). |
ed6814f7 | 924 | inline ios_base& |
725dc051 BK |
925 | noboolalpha(ios_base& __base) |
926 | { | |
927 | __base.unsetf(ios_base::boolalpha); | |
928 | return __base; | |
929 | } | |
930 | ||
840ceb34 | 931 | /// Calls base.setf(ios_base::showbase). |
ed6814f7 | 932 | inline ios_base& |
725dc051 BK |
933 | showbase(ios_base& __base) |
934 | { | |
935 | __base.setf(ios_base::showbase); | |
936 | return __base; | |
937 | } | |
938 | ||
840ceb34 | 939 | /// Calls base.unsetf(ios_base::showbase). |
ed6814f7 | 940 | inline ios_base& |
725dc051 BK |
941 | noshowbase(ios_base& __base) |
942 | { | |
943 | __base.unsetf(ios_base::showbase); | |
944 | return __base; | |
945 | } | |
946 | ||
840ceb34 | 947 | /// Calls base.setf(ios_base::showpoint). |
ed6814f7 | 948 | inline ios_base& |
725dc051 BK |
949 | showpoint(ios_base& __base) |
950 | { | |
951 | __base.setf(ios_base::showpoint); | |
952 | return __base; | |
953 | } | |
954 | ||
840ceb34 | 955 | /// Calls base.unsetf(ios_base::showpoint). |
ed6814f7 | 956 | inline ios_base& |
725dc051 BK |
957 | noshowpoint(ios_base& __base) |
958 | { | |
959 | __base.unsetf(ios_base::showpoint); | |
960 | return __base; | |
961 | } | |
962 | ||
840ceb34 | 963 | /// Calls base.setf(ios_base::showpos). |
ed6814f7 | 964 | inline ios_base& |
725dc051 BK |
965 | showpos(ios_base& __base) |
966 | { | |
967 | __base.setf(ios_base::showpos); | |
968 | return __base; | |
969 | } | |
970 | ||
840ceb34 | 971 | /// Calls base.unsetf(ios_base::showpos). |
ed6814f7 | 972 | inline ios_base& |
725dc051 BK |
973 | noshowpos(ios_base& __base) |
974 | { | |
975 | __base.unsetf(ios_base::showpos); | |
976 | return __base; | |
977 | } | |
978 | ||
840ceb34 | 979 | /// Calls base.setf(ios_base::skipws). |
ed6814f7 | 980 | inline ios_base& |
725dc051 BK |
981 | skipws(ios_base& __base) |
982 | { | |
983 | __base.setf(ios_base::skipws); | |
984 | return __base; | |
985 | } | |
ed6814f7 | 986 | |
840ceb34 | 987 | /// Calls base.unsetf(ios_base::skipws). |
ed6814f7 | 988 | inline ios_base& |
725dc051 BK |
989 | noskipws(ios_base& __base) |
990 | { | |
991 | __base.unsetf(ios_base::skipws); | |
992 | return __base; | |
993 | } | |
994 | ||
840ceb34 | 995 | /// Calls base.setf(ios_base::uppercase). |
ed6814f7 | 996 | inline ios_base& |
725dc051 BK |
997 | uppercase(ios_base& __base) |
998 | { | |
999 | __base.setf(ios_base::uppercase); | |
1000 | return __base; | |
1001 | } | |
1002 | ||
840ceb34 | 1003 | /// Calls base.unsetf(ios_base::uppercase). |
ed6814f7 | 1004 | inline ios_base& |
725dc051 BK |
1005 | nouppercase(ios_base& __base) |
1006 | { | |
1007 | __base.unsetf(ios_base::uppercase); | |
1008 | return __base; | |
1009 | } | |
1010 | ||
840ceb34 | 1011 | /// Calls base.setf(ios_base::unitbuf). |
ed6814f7 | 1012 | inline ios_base& |
725dc051 BK |
1013 | unitbuf(ios_base& __base) |
1014 | { | |
ed6814f7 | 1015 | __base.setf(ios_base::unitbuf); |
725dc051 BK |
1016 | return __base; |
1017 | } | |
1018 | ||
840ceb34 | 1019 | /// Calls base.unsetf(ios_base::unitbuf). |
ed6814f7 | 1020 | inline ios_base& |
725dc051 BK |
1021 | nounitbuf(ios_base& __base) |
1022 | { | |
1023 | __base.unsetf(ios_base::unitbuf); | |
ed6814f7 | 1024 | return __base; |
725dc051 BK |
1025 | } |
1026 | ||
28dac70a | 1027 | // [27.4.5.2] adjustfield manipulators |
840ceb34 | 1028 | /// Calls base.setf(ios_base::internal, ios_base::adjustfield). |
ed6814f7 | 1029 | inline ios_base& |
725dc051 BK |
1030 | internal(ios_base& __base) |
1031 | { | |
1032 | __base.setf(ios_base::internal, ios_base::adjustfield); | |
ed6814f7 | 1033 | return __base; |
725dc051 BK |
1034 | } |
1035 | ||
840ceb34 | 1036 | /// Calls base.setf(ios_base::left, ios_base::adjustfield). |
ed6814f7 | 1037 | inline ios_base& |
725dc051 BK |
1038 | left(ios_base& __base) |
1039 | { | |
1040 | __base.setf(ios_base::left, ios_base::adjustfield); | |
1041 | return __base; | |
1042 | } | |
ed6814f7 | 1043 | |
840ceb34 | 1044 | /// Calls base.setf(ios_base::right, ios_base::adjustfield). |
ed6814f7 | 1045 | inline ios_base& |
725dc051 BK |
1046 | right(ios_base& __base) |
1047 | { | |
1048 | __base.setf(ios_base::right, ios_base::adjustfield); | |
1049 | return __base; | |
1050 | } | |
ed6814f7 | 1051 | |
28dac70a | 1052 | // [27.4.5.3] basefield manipulators |
840ceb34 | 1053 | /// Calls base.setf(ios_base::dec, ios_base::basefield). |
ed6814f7 | 1054 | inline ios_base& |
725dc051 BK |
1055 | dec(ios_base& __base) |
1056 | { | |
1057 | __base.setf(ios_base::dec, ios_base::basefield); | |
1058 | return __base; | |
1059 | } | |
ed6814f7 | 1060 | |
840ceb34 | 1061 | /// Calls base.setf(ios_base::hex, ios_base::basefield). |
ed6814f7 | 1062 | inline ios_base& |
725dc051 BK |
1063 | hex(ios_base& __base) |
1064 | { | |
1065 | __base.setf(ios_base::hex, ios_base::basefield); | |
1066 | return __base; | |
1067 | } | |
1068 | ||
840ceb34 | 1069 | /// Calls base.setf(ios_base::oct, ios_base::basefield). |
ed6814f7 | 1070 | inline ios_base& |
725dc051 BK |
1071 | oct(ios_base& __base) |
1072 | { | |
1073 | __base.setf(ios_base::oct, ios_base::basefield); | |
1074 | return __base; | |
1075 | } | |
ed6814f7 | 1076 | |
28dac70a | 1077 | // [27.4.5.4] floatfield manipulators |
840ceb34 | 1078 | /// Calls base.setf(ios_base::fixed, ios_base::floatfield). |
ed6814f7 | 1079 | inline ios_base& |
725dc051 BK |
1080 | fixed(ios_base& __base) |
1081 | { | |
1082 | __base.setf(ios_base::fixed, ios_base::floatfield); | |
1083 | return __base; | |
1084 | } | |
1085 | ||
840ceb34 | 1086 | /// Calls base.setf(ios_base::scientific, ios_base::floatfield). |
ed6814f7 | 1087 | inline ios_base& |
725dc051 BK |
1088 | scientific(ios_base& __base) |
1089 | { | |
1090 | __base.setf(ios_base::scientific, ios_base::floatfield); | |
1091 | return __base; | |
1092 | } | |
3cbc7af0 | 1093 | |
c4b64f5b RS |
1094 | #if __cplusplus >= 201103L |
1095 | // New C++11 floatfield manipulators | |
1096 | ||
1097 | /// Calls | |
1098 | /// base.setf(ios_base::fixed|ios_base::scientific, ios_base::floatfield) | |
1099 | inline ios_base& | |
1100 | hexfloat(ios_base& __base) | |
1101 | { | |
1102 | __base.setf(ios_base::fixed | ios_base::scientific, ios_base::floatfield); | |
1103 | return __base; | |
1104 | } | |
1105 | ||
1106 | /// Calls @c base.unsetf(ios_base::floatfield) | |
1107 | inline ios_base& | |
1108 | defaultfloat(ios_base& __base) | |
1109 | { | |
1110 | __base.unsetf(ios_base::floatfield); | |
1111 | return __base; | |
1112 | } | |
1113 | #endif | |
1114 | ||
12ffa228 BK |
1115 | _GLIBCXX_END_NAMESPACE_VERSION |
1116 | } // namespace | |
725dc051 | 1117 | |
3d7c150e | 1118 | #endif /* _IOS_BASE_H */ |