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