ios_base.h

Go to the documentation of this file.
00001 // Iostreams base classes -*- C++ -*- 00002 00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 00004 // Free Software Foundation, Inc. 00005 // 00006 // This file is part of the GNU ISO C++ Library. This library is free 00007 // software; you can redistribute it and/or modify it under the 00008 // terms of the GNU General Public License as published by the 00009 // Free Software Foundation; either version 2, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 00017 // You should have received a copy of the GNU General Public License along 00018 // with this library; see the file COPYING. If not, write to the Free 00019 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00020 // USA. 00021 00022 // As a special exception, you may use this file as part of a free software 00023 // library without restriction. Specifically, if other files instantiate 00024 // templates or use macros or inline functions from this file, or you compile 00025 // this file and link it with other files to produce an executable, this 00026 // file does not by itself cause the resulting executable to be covered by 00027 // the GNU General Public License. This exception does not however 00028 // invalidate any other reasons why the executable file might be covered by 00029 // the GNU General Public License. 00030 00031 // 00032 // ISO C++ 14882: 27.4 Iostreams base classes 00033 // 00034 00035 /** @file ios_base.h 00036 * This is an internal header file, included by other library headers. 00037 * You should not attempt to use it directly. 00038 */ 00039 00040 #ifndef _IOS_BASE_H 00041 #define _IOS_BASE_H 1 00042 00043 #pragma GCC system_header 00044 00045 #include <bits/atomicity.h> 00046 #include <bits/localefwd.h> 00047 #include <bits/locale_classes.h> 00048 00049 namespace std 00050 { 00051 // The following definitions of bitmask types are enums, not ints, 00052 // as permitted (but not required) in the standard, in order to provide 00053 // better type safety in iostream calls. A side effect is that 00054 // expressions involving them are no longer compile-time constants. 00055 enum _Ios_Fmtflags { _S_ios_fmtflags_end = 1L << 16 }; 00056 00057 inline _Ios_Fmtflags 00058 operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b) 00059 { return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); } 00060 00061 inline _Ios_Fmtflags 00062 operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b) 00063 { return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); } 00064 00065 inline _Ios_Fmtflags 00066 operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b) 00067 { return _Ios_Fmtflags(static_cast<int>(__a) ^ static_cast<int>(__b)); } 00068 00069 inline _Ios_Fmtflags 00070 operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) 00071 { return __a = __a | __b; } 00072 00073 inline _Ios_Fmtflags 00074 operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) 00075 { return __a = __a & __b; } 00076 00077 inline _Ios_Fmtflags 00078 operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) 00079 { return __a = __a ^ __b; } 00080 00081 inline _Ios_Fmtflags 00082 operator~(_Ios_Fmtflags __a) 00083 { return _Ios_Fmtflags(~static_cast<int>(__a)); } 00084 00085 00086 enum _Ios_Openmode { _S_ios_openmode_end = 1L << 16 }; 00087 00088 inline _Ios_Openmode 00089 operator&(_Ios_Openmode __a, _Ios_Openmode __b) 00090 { return _Ios_Openmode(static_cast<int>(__a) & static_cast<int>(__b)); } 00091 00092 inline _Ios_Openmode 00093 operator|(_Ios_Openmode __a, _Ios_Openmode __b) 00094 { return _Ios_Openmode(static_cast<int>(__a) | static_cast<int>(__b)); } 00095 00096 inline _Ios_Openmode 00097 operator^(_Ios_Openmode __a, _Ios_Openmode __b) 00098 { return _Ios_Openmode(static_cast<int>(__a) ^ static_cast<int>(__b)); } 00099 00100 inline _Ios_Openmode 00101 operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) 00102 { return __a = __a | __b; } 00103 00104 inline _Ios_Openmode 00105 operator&=(_Ios_Openmode& __a, _Ios_Openmode __b) 00106 { return __a = __a & __b; } 00107 00108 inline _Ios_Openmode 00109 operator^=(_Ios_Openmode& __a, _Ios_Openmode __b) 00110 { return __a = __a ^ __b; } 00111 00112 inline _Ios_Openmode 00113 operator~(_Ios_Openmode __a) 00114 { return _Ios_Openmode(~static_cast<int>(__a)); } 00115 00116 00117 enum _Ios_Iostate { _S_ios_iostate_end = 1L << 16 }; 00118 00119 inline _Ios_Iostate 00120 operator&(_Ios_Iostate __a, _Ios_Iostate __b) 00121 { return _Ios_Iostate(static_cast<int>(__a) & static_cast<int>(__b)); } 00122 00123 inline _Ios_Iostate 00124 operator|(_Ios_Iostate __a, _Ios_Iostate __b) 00125 { return _Ios_Iostate(static_cast<int>(__a) | static_cast<int>(__b)); } 00126 00127 inline _Ios_Iostate 00128 operator^(_Ios_Iostate __a, _Ios_Iostate __b) 00129 { return _Ios_Iostate(static_cast<int>(__a) ^ static_cast<int>(__b)); } 00130 00131 inline _Ios_Iostate 00132 operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) 00133 { return __a = __a | __b; } 00134 00135 inline _Ios_Iostate 00136 operator&=(_Ios_Iostate& __a, _Ios_Iostate __b) 00137 { return __a = __a & __b; } 00138 00139 inline _Ios_Iostate 00140 operator^=(_Ios_Iostate& __a, _Ios_Iostate __b) 00141 { return __a = __a ^ __b; } 00142 00143 inline _Ios_Iostate 00144 operator~(_Ios_Iostate __a) 00145 { return _Ios_Iostate(~static_cast<int>(__a)); } 00146 00147 enum _Ios_Seekdir { _S_ios_seekdir_end = 1L << 16 }; 00148 00149 // 27.4.2 Class ios_base 00150 /** 00151 * @brief The very top of the I/O class hierarchy. 00152 * 00153 * This class defines everything that can be defined about I/O that does 00154 * not depend on the type of characters being input or output. Most 00155 * people will only see @c ios_base when they need to specify the full 00156 * name of the various I/O flags (e.g., the openmodes). 00157 */ 00158 class ios_base 00159 { 00160 public: 00161 00162 // 27.4.2.1.1 Class ios_base::failure 00163 /// These are thrown to indicate problems. Doc me. 00164 class failure : public exception 00165 { 00166 public: 00167 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00168 // 48. Use of non-existent exception constructor 00169 explicit 00170 failure(const string& __str) throw(); 00171 00172 // This declaration is not useless: 00173 // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118 00174 virtual 00175 ~failure() throw(); 00176 00177 virtual const char* 00178 what() const throw(); 00179 00180 private: 00181 string _M_msg; 00182 }; 00183 00184 // 27.4.2.1.2 Type ios_base::fmtflags 00185 /** 00186 * @brief This is a bitmask type. 00187 * 00188 * @c "_Ios_Fmtflags" is implementation-defined, but it is valid to 00189 * perform bitwise operations on these values and expect the Right 00190 * Thing to happen. Defined objects of type fmtflags are: 00191 * - boolalpha 00192 * - dec 00193 * - fixed 00194 * - hex 00195 * - internal 00196 * - left 00197 * - oct 00198 * - right 00199 * - scientific 00200 * - showbase 00201 * - showpoint 00202 * - showpos 00203 * - skipws 00204 * - unitbuf 00205 * - uppercase 00206 * - adjustfield 00207 * - basefield 00208 * - floatfield 00209 */ 00210 typedef _Ios_Fmtflags fmtflags; 00211 00212 /// Insert/extract @c bool in alphabetic rather than numeric format. 00213 static const fmtflags boolalpha = fmtflags(__ios_flags::_S_boolalpha); 00214 00215 /// Converts integer input or generates integer output in decimal base. 00216 static const fmtflags dec = fmtflags(__ios_flags::_S_dec); 00217 00218 /// Generate floating-point output in fixed-point notation. 00219 static const fmtflags fixed = fmtflags(__ios_flags::_S_fixed); 00220 00221 /// Converts integer input or generates integer output in hexadecimal base. 00222 static const fmtflags hex = fmtflags(__ios_flags::_S_hex); 00223 00224 /// Adds fill characters at a designated internal point in certain 00225 /// generated output, or identical to @c right if no such point is 00226 /// designated. 00227 static const fmtflags internal = fmtflags(__ios_flags::_S_internal); 00228 00229 /// Adds fill characters on the right (final positions) of certain 00230 /// generated output. (I.e., the thing you print is flush left.) 00231 static const fmtflags left = fmtflags(__ios_flags::_S_left); 00232 00233 /// Converts integer input or generates integer output in octal base. 00234 static const fmtflags oct = fmtflags(__ios_flags::_S_oct); 00235 00236 /// Adds fill characters on the left (initial positions) of certain 00237 /// generated output. (I.e., the thing you print is flush right.) 00238 static const fmtflags right = fmtflags(__ios_flags::_S_right); 00239 00240 /// Generates floating-point output in scientific notation. 00241 static const fmtflags scientific = fmtflags(__ios_flags::_S_scientific); 00242 00243 /// Generates a prefix indicating the numeric base of generated integer 00244 /// output. 00245 static const fmtflags showbase = fmtflags(__ios_flags::_S_showbase); 00246 00247 /// Generates a decimal-point character unconditionally in generated 00248 /// floating-point output. 00249 static const fmtflags showpoint = fmtflags(__ios_flags::_S_showpoint); 00250 00251 /// Generates a + sign in non-negative generated numeric output. 00252 static const fmtflags showpos = fmtflags(__ios_flags::_S_showpos); 00253 00254 /// Skips leading white space before certain input operations. 00255 static const fmtflags skipws = fmtflags(__ios_flags::_S_skipws); 00256 00257 /// Flushes output after each output operation. 00258 static const fmtflags unitbuf = fmtflags(__ios_flags::_S_unitbuf); 00259 00260 /// Replaces certain lowercase letters with their uppercase equivalents 00261 /// in generated output. 00262 static const fmtflags uppercase = fmtflags(__ios_flags::_S_uppercase); 00263 00264 /// A mask of left|right|internal. Useful for the 2-arg form of @c setf. 00265 static const fmtflags adjustfield = fmtflags(__ios_flags::_S_adjustfield); 00266 00267 /// A mask of dec|oct|hex. Useful for the 2-arg form of @c setf. 00268 static const fmtflags basefield = fmtflags(__ios_flags::_S_basefield); 00269 00270 /// A mask of scientific|fixed. Useful for the 2-arg form of @c setf. 00271 static const fmtflags floatfield = fmtflags(__ios_flags::_S_floatfield); 00272 00273 // 27.4.2.1.3 Type ios_base::iostate 00274 /** 00275 * @brief This is a bitmask type. 00276 * 00277 * @c "_Ios_Iostate" is implementation-defined, but it is valid to 00278 * perform bitwise operations on these values and expect the Right 00279 * Thing to happen. Defined objects of type iostate are: 00280 * - badbit 00281 * - eofbit 00282 * - failbit 00283 * - goodbit 00284 */ 00285 typedef _Ios_Iostate iostate; 00286 00287 /// Indicates a loss of integrity in an input or output sequence (such 00288 /// as an irrecoverable read error from a file). 00289 static const iostate badbit = iostate(__ios_flags::_S_badbit); 00290 00291 /// Indicates that an input operation reached the end of an input sequence. 00292 static const iostate eofbit = iostate(__ios_flags::_S_eofbit); 00293 00294 /// Indicates that an input operation failed to read the expected 00295 /// characters, or that an output operation failed to generate the 00296 /// desired characters. 00297 static const iostate failbit = iostate(__ios_flags::_S_failbit); 00298 00299 /// Indicates all is well. 00300 static const iostate goodbit = iostate(0); 00301 00302 // 27.4.2.1.4 Type ios_base::openmode 00303 /** 00304 * @brief This is a bitmask type. 00305 * 00306 * @c "_Ios_Openmode" is implementation-defined, but it is valid to 00307 * perform bitwise operations on these values and expect the Right 00308 * Thing to happen. Defined objects of type openmode are: 00309 * - app 00310 * - ate 00311 * - binary 00312 * - in 00313 * - out 00314 * - trunc 00315 */ 00316 typedef _Ios_Openmode openmode; 00317 00318 /// Seek to end before each write. 00319 static const openmode app = openmode(__ios_flags::_S_app); 00320 00321 /// Open and seek to end immediately after opening. 00322 static const openmode ate = openmode(__ios_flags::_S_ate); 00323 00324 /// Perform input and output in binary mode (as opposed to text mode). 00325 /// This is probably not what you think it is; see 00326 /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#3 and 00327 /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#7 for more. 00328 static const openmode binary = openmode(__ios_flags::_S_bin); 00329 00330 /// Open for input. Default for @c ifstream and fstream. 00331 static const openmode in = openmode(__ios_flags::_S_in); 00332 00333 /// Open for output. Default for @c ofstream and fstream. 00334 static const openmode out = openmode(__ios_flags::_S_out); 00335 00336 /// Open for input. Default for @c ofstream. 00337 static const openmode trunc = openmode(__ios_flags::_S_trunc); 00338 00339 // 27.4.2.1.5 Type ios_base::seekdir 00340 /** 00341 * @brief This is an enumerated type. 00342 * 00343 * @c "_Ios_Seekdir" is implementation-defined. Defined values 00344 * of type seekdir are: 00345 * - beg 00346 * - cur, equivalent to @c SEEK_CUR in the C standard library. 00347 * - end, equivalent to @c SEEK_END in the C standard library. 00348 */ 00349 typedef _Ios_Seekdir seekdir; 00350 00351 /// Request a seek relative to the beginning of the stream. 00352 static const seekdir beg = seekdir(0); 00353 00354 /// Request a seek relative to the current position within the sequence. 00355 static const seekdir cur = seekdir(SEEK_CUR); 00356 00357 /// Request a seek relative to the current end of the sequence. 00358 static const seekdir end = seekdir(SEEK_END); 00359 00360 #ifdef _GLIBCXX_DEPRECATED 00361 // Annex D.6 00362 typedef int io_state; 00363 typedef int open_mode; 00364 typedef int seek_dir; 00365 00366 typedef std::streampos streampos; 00367 typedef std::streamoff streamoff; 00368 #endif 00369 00370 // Callbacks; 00371 /** 00372 * @brief The set of events that may be passed to an event callback. 00373 * 00374 * erase_event is used during ~ios() and copyfmt(). imbue_event is used 00375 * during imbue(). copyfmt_event is used during copyfmt(). 00376 */ 00377 enum event 00378 { 00379 erase_event, 00380 imbue_event, 00381 copyfmt_event 00382 }; 00383 00384 /** 00385 * @brief The type of an event callback function. 00386 * @param event One of the members of the event enum. 00387 * @param ios_base Reference to the ios_base object. 00388 * @param int The integer provided when the callback was registered. 00389 * 00390 * Event callbacks are user defined functions that get called during 00391 * several ios_base and basic_ios functions, specifically imbue(), 00392 * copyfmt(), and ~ios(). 00393 */ 00394 typedef void (*event_callback) (event, ios_base&, int); 00395 00396 /** 00397 * @brief Add the callback __fn with parameter __index. 00398 * @param __fn The function to add. 00399 * @param __index The integer to pass to the function when invoked. 00400 * 00401 * Registers a function as an event callback with an integer parameter to 00402 * be passed to the function when invoked. Multiple copies of the 00403 * function are allowed. If there are multiple callbacks, they are 00404 * invoked in the order they were registered. 00405 */ 00406 void 00407 register_callback(event_callback __fn, int __index); 00408 00409 protected: 00410 //@{ 00411 /** 00412 * @if maint 00413 * ios_base data members (doc me) 00414 * @endif 00415 */ 00416 streamsize _M_precision; 00417 streamsize _M_width; 00418 fmtflags _M_flags; 00419 iostate _M_exception; 00420 iostate _M_streambuf_state; 00421 //@} 00422 00423 // 27.4.2.6 Members for callbacks 00424 // 27.4.2.6 ios_base callbacks 00425 struct _Callback_list 00426 { 00427 // Data Members 00428 _Callback_list* _M_next; 00429 ios_base::event_callback _M_fn; 00430 int _M_index; 00431 _Atomic_word _M_refcount; // 0 means one reference. 00432 00433 _Callback_list(ios_base::event_callback __fn, int __index, 00434 _Callback_list* __cb) 00435 : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { } 00436 00437 void 00438 _M_add_reference() { __gnu_cxx::__atomic_add(&_M_refcount, 1); } 00439 00440 // 0 => OK to delete. 00441 int 00442 _M_remove_reference() 00443 { return __gnu_cxx::__exchange_and_add(&_M_refcount, -1); } 00444 }; 00445 00446 _Callback_list* _M_callbacks; 00447 00448 void 00449 _M_call_callbacks(event __ev) throw(); 00450 00451 void 00452 _M_dispose_callbacks(void); 00453 00454 // 27.4.2.5 Members for iword/pword storage 00455 struct _Words 00456 { 00457 void* _M_pword; 00458 long _M_iword; 00459 _Words() : _M_pword(0), _M_iword(0) { } 00460 }; 00461 00462 // Only for failed iword/pword calls. 00463 _Words _M_word_zero; 00464 00465 // Guaranteed storage. 00466 // The first 5 iword and pword slots are reserved for internal use. 00467 static const int _S_local_word_size = 8; 00468 _Words _M_local_word[_S_local_word_size]; 00469 00470 // Allocated storage. 00471 int _M_word_size; 00472 _Words* _M_word; 00473 00474 _Words& 00475 _M_grow_words(int __index, bool __iword); 00476 00477 // Members for locale and locale caching. 00478 locale _M_ios_locale; 00479 00480 void 00481 _M_init(); 00482 00483 public: 00484 00485 // 27.4.2.1.6 Class ios_base::Init 00486 // Used to initialize standard streams. In theory, g++ could use 00487 // -finit-priority to order this stuff correctly without going 00488 // through these machinations. 00489 class Init 00490 { 00491 friend class ios_base; 00492 public: 00493 Init(); 00494 ~Init(); 00495 00496 private: 00497 static _Atomic_word _S_refcount; 00498 static bool _S_synced_with_stdio; 00499 }; 00500 00501 // [27.4.2.2] fmtflags state functions 00502 /** 00503 * @brief Access to format flags. 00504 * @return The format control flags for both input and output. 00505 */ 00506 inline fmtflags 00507 flags() const { return _M_flags; } 00508 00509 /** 00510 * @brief Setting new format flags all at once. 00511 * @param fmtfl The new flags to set. 00512 * @return The previous format control flags. 00513 * 00514 * This function overwrites all the format flags with @a fmtfl. 00515 */ 00516 inline fmtflags 00517 flags(fmtflags __fmtfl) 00518 { 00519 fmtflags __old = _M_flags; 00520 _M_flags = __fmtfl; 00521 return __old; 00522 } 00523 00524 /** 00525 * @brief Setting new format flags. 00526 * @param fmtfl Additional flags to set. 00527 * @return The previous format control flags. 00528 * 00529 * This function sets additional flags in format control. Flags that 00530 * were previously set remain set. 00531 */ 00532 inline fmtflags 00533 setf(fmtflags __fmtfl) 00534 { 00535 fmtflags __old = _M_flags; 00536 _M_flags |= __fmtfl; 00537 return __old; 00538 } 00539 00540 /** 00541 * @brief Setting new format flags. 00542 * @param fmtfl Additional flags to set. 00543 * @param mask The flags mask for @a fmtfl. 00544 * @return The previous format control flags. 00545 * 00546 * This function clears @a mask in the format flags, then sets 00547 * @a fmtfl @c & @a mask. An example mask is @c ios_base::adjustfield. 00548 */ 00549 inline fmtflags 00550 setf(fmtflags __fmtfl, fmtflags __mask) 00551 { 00552 fmtflags __old = _M_flags; 00553 _M_flags &= ~__mask; 00554 _M_flags |= (__fmtfl & __mask); 00555 return __old; 00556 } 00557 00558 /** 00559 * @brief Clearing format flags. 00560 * @param mask The flags to unset. 00561 * 00562 * This function clears @a mask in the format flags. 00563 */ 00564 inline void 00565 unsetf(fmtflags __mask) { _M_flags &= ~__mask; } 00566 00567 /** 00568 * @brief Flags access. 00569 * @return The precision to generate on certain output operations. 00570 * 00571 * @if maint 00572 * Be careful if you try to give a definition of "precision" here; see 00573 * DR 189. 00574 * @endif 00575 */ 00576 inline streamsize 00577 precision() const { return _M_precision; } 00578 00579 /** 00580 * @brief Changing flags. 00581 * @param prec The new precision value. 00582 * @return The previous value of precision(). 00583 */ 00584 inline streamsize 00585 precision(streamsize __prec) 00586 { 00587 streamsize __old = _M_precision; 00588 _M_precision = __prec; 00589 return __old; 00590 } 00591 00592 /** 00593 * @brief Flags access. 00594 * @return The minimum field width to generate on output operations. 00595 * 00596 * "Minimum field width" refers to the number of characters. 00597 */ 00598 inline streamsize 00599 width() const { return _M_width; } 00600 00601 /** 00602 * @brief Changing flags. 00603 * @param wide The new width value. 00604 * @return The previous value of width(). 00605 */ 00606 inline streamsize 00607 width(streamsize __wide) 00608 { 00609 streamsize __old = _M_width; 00610 _M_width = __wide; 00611 return __old; 00612 } 00613 00614 // [27.4.2.4] ios_base static members 00615 /** 00616 * @brief Interaction with the standard C I/O objects. 00617 * @param sync Whether to synchronize or not. 00618 * @return True if the standard streams were previously synchronized. 00619 * 00620 * The synchronization referred to is @e only that between the standard 00621 * C facilities (e.g., stdout) and the standard C++ objects (e.g., 00622 * cout). User-declared streams are unaffected. See 00623 * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#8 for more. 00624 */ 00625 static bool 00626 sync_with_stdio(bool __sync = true); 00627 00628 // [27.4.2.3] ios_base locale functions 00629 /** 00630 * @brief Setting a new locale. 00631 * @param loc The new locale. 00632 * @return The previous locale. 00633 * 00634 * Sets the new locale for this stream, and then invokes each callback 00635 * with imbue_event. 00636 */ 00637 locale 00638 imbue(const locale& __loc); 00639 00640 /** 00641 * @brief Locale access 00642 * @return A copy of the current locale. 00643 * 00644 * If @c imbue(loc) has previously been called, then this function 00645 * returns @c loc. Otherwise, it returns a copy of @c std::locale(), 00646 * the global C++ locale. 00647 */ 00648 inline locale 00649 getloc() const { return _M_ios_locale; } 00650 00651 /** 00652 * @brief Locale access 00653 * @return A reference to the current locale. 00654 * 00655 * Like getloc above, but returns a reference instead of 00656 * generating a copy. 00657 */ 00658 inline const locale& 00659 _M_getloc() const { return _M_ios_locale; } 00660 00661 // [27.4.2.5] ios_base storage functions 00662 /** 00663 * @brief Access to unique indices. 00664 * @return An integer different from all previous calls. 00665 * 00666 * This function returns a unique integer every time it is called. It 00667 * can be used for any purpose, but is primarily intended to be a unique 00668 * index for the iword and pword functions. The expectation is that an 00669 * application calls xalloc in order to obtain an index in the iword and 00670 * pword arrays that can be used without fear of conflict. 00671 * 00672 * The implementation maintains a static variable that is incremented and 00673 * returned on each invocation. xalloc is guaranteed to return an index 00674 * that is safe to use in the iword and pword arrays. 00675 */ 00676 static int 00677 xalloc() throw(); 00678 00679 /** 00680 * @brief Access to integer array. 00681 * @param __ix Index into the array. 00682 * @return A reference to an integer associated with the index. 00683 * 00684 * The iword function provides access to an array of integers that can be 00685 * used for any purpose. The array grows as required to hold the 00686 * supplied index. All integers in the array are initialized to 0. 00687 * 00688 * The implementation reserves several indices. You should use xalloc to 00689 * obtain an index that is safe to use. Also note that since the array 00690 * can grow dynamically, it is not safe to hold onto the reference. 00691 */ 00692 inline long& 00693 iword(int __ix) 00694 { 00695 _Words& __word = (__ix < _M_word_size) 00696 ? _M_word[__ix] : _M_grow_words(__ix, true); 00697 return __word._M_iword; 00698 } 00699 00700 /** 00701 * @brief Access to void pointer array. 00702 * @param __ix Index into the array. 00703 * @return A reference to a void* associated with the index. 00704 * 00705 * The pword function provides access to an array of pointers that can be 00706 * used for any purpose. The array grows as required to hold the 00707 * supplied index. All pointers in the array are initialized to 0. 00708 * 00709 * The implementation reserves several indices. You should use xalloc to 00710 * obtain an index that is safe to use. Also note that since the array 00711 * can grow dynamically, it is not safe to hold onto the reference. 00712 */ 00713 inline void*& 00714 pword(int __ix) 00715 { 00716 _Words& __word = (__ix < _M_word_size) 00717 ? _M_word[__ix] : _M_grow_words(__ix, false); 00718 return __word._M_pword; 00719 } 00720 00721 // Destructor 00722 /** 00723 * Invokes each callback with erase_event. Destroys local storage. 00724 * 00725 * Note that the ios_base object for the standard streams never gets 00726 * destroyed. As a result, any callbacks registered with the standard 00727 * streams will not get invoked with erase_event (unless copyfmt is 00728 * used). 00729 */ 00730 virtual ~ios_base(); 00731 00732 protected: 00733 ios_base(); 00734 00735 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00736 // 50. Copy constructor and assignment operator of ios_base 00737 private: 00738 ios_base(const ios_base&); 00739 00740 ios_base& 00741 operator=(const ios_base&); 00742 }; 00743 00744 // [27.4.5.1] fmtflags manipulators 00745 /// Calls base.setf(ios_base::boolalpha). 00746 inline ios_base& 00747 boolalpha(ios_base& __base) 00748 { 00749 __base.setf(ios_base::boolalpha); 00750 return __base; 00751 } 00752 00753 /// Calls base.unsetf(ios_base::boolalpha). 00754 inline ios_base& 00755 noboolalpha(ios_base& __base) 00756 { 00757 __base.unsetf(ios_base::boolalpha); 00758 return __base; 00759 } 00760 00761 /// Calls base.setf(ios_base::showbase). 00762 inline ios_base& 00763 showbase(ios_base& __base) 00764 { 00765 __base.setf(ios_base::showbase); 00766 return __base; 00767 } 00768 00769 /// Calls base.unsetf(ios_base::showbase). 00770 inline ios_base& 00771 noshowbase(ios_base& __base) 00772 { 00773 __base.unsetf(ios_base::showbase); 00774 return __base; 00775 } 00776 00777 /// Calls base.setf(ios_base::showpoint). 00778 inline ios_base& 00779 showpoint(ios_base& __base) 00780 { 00781 __base.setf(ios_base::showpoint); 00782 return __base; 00783 } 00784 00785 /// Calls base.unsetf(ios_base::showpoint). 00786 inline ios_base& 00787 noshowpoint(ios_base& __base) 00788 { 00789 __base.unsetf(ios_base::showpoint); 00790 return __base; 00791 } 00792 00793 /// Calls base.setf(ios_base::showpos). 00794 inline ios_base& 00795 showpos(ios_base& __base) 00796 { 00797 __base.setf(ios_base::showpos); 00798 return __base; 00799 } 00800 00801 /// Calls base.unsetf(ios_base::showpos). 00802 inline ios_base& 00803 noshowpos(ios_base& __base) 00804 { 00805 __base.unsetf(ios_base::showpos); 00806 return __base; 00807 } 00808 00809 /// Calls base.setf(ios_base::skipws). 00810 inline ios_base& 00811 skipws(ios_base& __base) 00812 { 00813 __base.setf(ios_base::skipws); 00814 return __base; 00815 } 00816 00817 /// Calls base.unsetf(ios_base::skipws). 00818 inline ios_base& 00819 noskipws(ios_base& __base) 00820 { 00821 __base.unsetf(ios_base::skipws); 00822 return __base; 00823 } 00824 00825 /// Calls base.setf(ios_base::uppercase). 00826 inline ios_base& 00827 uppercase(ios_base& __base) 00828 { 00829 __base.setf(ios_base::uppercase); 00830 return __base; 00831 } 00832 00833 /// Calls base.unsetf(ios_base::uppercase). 00834 inline ios_base& 00835 nouppercase(ios_base& __base) 00836 { 00837 __base.unsetf(ios_base::uppercase); 00838 return __base; 00839 } 00840 00841 /// Calls base.setf(ios_base::unitbuf). 00842 inline ios_base& 00843 unitbuf(ios_base& __base) 00844 { 00845 __base.setf(ios_base::unitbuf); 00846 return __base; 00847 } 00848 00849 /// Calls base.unsetf(ios_base::unitbuf). 00850 inline ios_base& 00851 nounitbuf(ios_base& __base) 00852 { 00853 __base.unsetf(ios_base::unitbuf); 00854 return __base; 00855 } 00856 00857 // [27.4.5.2] adjustfield anipulators 00858 /// Calls base.setf(ios_base::internal, ios_base::adjustfield). 00859 inline ios_base& 00860 internal(ios_base& __base) 00861 { 00862 __base.setf(ios_base::internal, ios_base::adjustfield); 00863 return __base; 00864 } 00865 00866 /// Calls base.setf(ios_base::left, ios_base::adjustfield). 00867 inline ios_base& 00868 left(ios_base& __base) 00869 { 00870 __base.setf(ios_base::left, ios_base::adjustfield); 00871 return __base; 00872 } 00873 00874 /// Calls base.setf(ios_base::right, ios_base::adjustfield). 00875 inline ios_base& 00876 right(ios_base& __base) 00877 { 00878 __base.setf(ios_base::right, ios_base::adjustfield); 00879 return __base; 00880 } 00881 00882 // [27.4.5.3] basefield anipulators 00883 /// Calls base.setf(ios_base::dec, ios_base::basefield). 00884 inline ios_base& 00885 dec(ios_base& __base) 00886 { 00887 __base.setf(ios_base::dec, ios_base::basefield); 00888 return __base; 00889 } 00890 00891 /// Calls base.setf(ios_base::hex, ios_base::basefield). 00892 inline ios_base& 00893 hex(ios_base& __base) 00894 { 00895 __base.setf(ios_base::hex, ios_base::basefield); 00896 return __base; 00897 } 00898 00899 /// Calls base.setf(ios_base::oct, ios_base::basefield). 00900 inline ios_base& 00901 oct(ios_base& __base) 00902 { 00903 __base.setf(ios_base::oct, ios_base::basefield); 00904 return __base; 00905 } 00906 00907 // [27.4.5.4] floatfield anipulators 00908 /// Calls base.setf(ios_base::fixed, ios_base::floatfield). 00909 inline ios_base& 00910 fixed(ios_base& __base) 00911 { 00912 __base.setf(ios_base::fixed, ios_base::floatfield); 00913 return __base; 00914 } 00915 00916 /// Calls base.setf(ios_base::scientific, ios_base::floatfield). 00917 inline ios_base& 00918 scientific(ios_base& __base) 00919 { 00920 __base.setf(ios_base::scientific, ios_base::floatfield); 00921 return __base; 00922 } 00923 } // namespace std 00924 00925 #endif /* _IOS_BASE_H */ 00926

Generated on Tue Sep 7 10:05:07 2004 for libstdc++-v3 Source by doxygen 1.3.8