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