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