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