ios_base.h revision 117397
1// Iostreams base classes -*- C++ -*- 2 3// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 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.8 File-based streams 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 _CPP_BITS_IOSBASE_H 41#define _CPP_BITS_IOSBASE_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 49namespace 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 { _M_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 { _M_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 { _M_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 { _M_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#ifdef _GLIBCPP_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 enum { _M_bufsize = 256 }; 182 char _M_name[_M_bufsize]; 183#endif 184 }; 185 186 // 27.4.2.1.2 Type ios_base::fmtflags 187 /** 188 * @brief This is a bitmask type. 189 * 190 * @c "_Ios_Fmtflags" is implementation-defined, but it is valid to 191 * perform bitwise operations on these values and expect the Right 192 * Thing to happen. Defined objects of type fmtflags are: 193 * - boolalpha 194 * - dec 195 * - fixed 196 * - hex 197 * - internal 198 * - left 199 * - oct 200 * - right 201 * - scientific 202 * - showbase 203 * - showpoint 204 * - showpos 205 * - skipws 206 * - unitbuf 207 * - uppercase 208 * - adjustfield 209 * - basefield 210 * - floatfield 211 */ 212 typedef _Ios_Fmtflags fmtflags; 213 /// Insert/extract @c bool in alphabetic rather than numeric format. 214 static const fmtflags boolalpha = fmtflags(__ios_flags::_S_boolalpha); 215 /// Converts integer input or generates integer output in decimal base. 216 static const fmtflags dec = fmtflags(__ios_flags::_S_dec); 217 /// Generate floating-point output in fixed-point notation. 218 static const fmtflags fixed = fmtflags(__ios_flags::_S_fixed); 219 /// Converts integer input or generates integer output in hexadecimal base. 220 static const fmtflags hex = fmtflags(__ios_flags::_S_hex); 221 /// Adds fill characters at a designated internal point in certain 222 /// generated output, or identical to @c right if no such point is 223 /// designated. 224 static const fmtflags internal = fmtflags(__ios_flags::_S_internal); 225 /// Adds fill characters on the right (final positions) of certain 226 /// generated output. (I.e., the thing you print is flush left.) 227 static const fmtflags left = fmtflags(__ios_flags::_S_left); 228 /// Converts integer input or generates integer output in octal base. 229 static const fmtflags oct = fmtflags(__ios_flags::_S_oct); 230 /// Adds fill characters on the left (initial positions) of certain 231 /// generated output. (I.e., the thing you print is flush right.) 232 static const fmtflags right = fmtflags(__ios_flags::_S_right); 233 /// Generates floating-point output in scientific notation. 234 static const fmtflags scientific = fmtflags(__ios_flags::_S_scientific); 235 /// Generates a prefix indicating the numeric base of generated integer 236 /// output. 237 static const fmtflags showbase = fmtflags(__ios_flags::_S_showbase); 238 /// Generates a decimal-point character unconditionally in generated 239 /// floating-point output. 240 static const fmtflags showpoint = fmtflags(__ios_flags::_S_showpoint); 241 /// Generates a + sign in non-negative generated numeric output. 242 static const fmtflags showpos = fmtflags(__ios_flags::_S_showpos); 243 /// Skips leading white space before certain input operations. 244 static const fmtflags skipws = fmtflags(__ios_flags::_S_skipws); 245 /// Flushes output after each output operation. 246 static const fmtflags unitbuf = fmtflags(__ios_flags::_S_unitbuf); 247 /// Replaces certain lowercase letters with their uppercase equivalents 248 /// in generated output. 249 static const fmtflags uppercase = fmtflags(__ios_flags::_S_uppercase); 250 /// A mask of left|right|internal. Useful for the 2-arg form of @c setf. 251 static const fmtflags adjustfield = fmtflags(__ios_flags::_S_adjustfield); 252 /// A mask of dec|oct|hex. Useful for the 2-arg form of @c setf. 253 static const fmtflags basefield = fmtflags(__ios_flags::_S_basefield); 254 /// A mask of scientific|fixed. Useful for the 2-arg form of @c setf. 255 static const fmtflags floatfield = fmtflags(__ios_flags::_S_floatfield); 256 257 // 27.4.2.1.3 Type ios_base::iostate 258 /** 259 * @brief This is a bitmask type. 260 * 261 * @c "_Ios_Iostate" is implementation-defined, but it is valid to 262 * perform bitwise operations on these values and expect the Right 263 * Thing to happen. Defined objects of type iostate are: 264 * - badbit 265 * - eofbit 266 * - failbit 267 * - goodbit 268 */ 269 typedef _Ios_Iostate iostate; 270 /// Indicates a loss of integrity in an input or output sequence (such 271 /// as an irrecoverable read error from a file). 272 static const iostate badbit = iostate(__ios_flags::_S_badbit); 273 /// Indicates that an input operation reached the end of an input sequence. 274 static const iostate eofbit = iostate(__ios_flags::_S_eofbit); 275 /// Indicates that an input operation failed to read the expected 276 /// characters, or that an output operation failed to generate the 277 /// desired characters. 278 static const iostate failbit = iostate(__ios_flags::_S_failbit); 279 /// Indicates all is well. 280 static const iostate goodbit = iostate(0); 281 282 // 27.4.2.1.4 Type ios_base::openmode 283 /** 284 * @brief This is a bitmask type. 285 * 286 * @c "_Ios_Openmode" is implementation-defined, but it is valid to 287 * perform bitwise operations on these values and expect the Right 288 * Thing to happen. Defined objects of type openmode are: 289 * - app 290 * - ate 291 * - binary 292 * - in 293 * - out 294 * - trunc 295 */ 296 typedef _Ios_Openmode openmode; 297 /// Seek to end before each write. 298 static const openmode app = openmode(__ios_flags::_S_app); 299 /// Open and seek to end immediately after opening. 300 static const openmode ate = openmode(__ios_flags::_S_ate); 301 /// Perform input and output in binary mode (as opposed to text mode). 302 /// This is probably not what you think it is; see 303 /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#3 and 304 /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#7 for more. 305 static const openmode binary = openmode(__ios_flags::_S_bin); 306 /// Open for input. Default for @c ifstream and fstream. 307 static const openmode in = openmode(__ios_flags::_S_in); 308 /// Open for output. Default for @c ofstream and fstream. 309 static const openmode out = openmode(__ios_flags::_S_out); 310 /// Open for input. Default for @c ofstream. 311 static const openmode trunc = openmode(__ios_flags::_S_trunc); 312 313 // 27.4.2.1.5 Type ios_base::seekdir 314 /** 315 * @brief This is an enumerated type. 316 * 317 * @c "_Ios_Seekdir" is implementation-defined. Defined values 318 * of type seekdir are: 319 * - beg 320 * - cur, equivalent to @c SEEK_CUR in the C standard library. 321 * - end, equivalent to @c SEEK_END in the C standard library. 322 */ 323 typedef _Ios_Seekdir seekdir; 324 /// Request a seek relative to the beginning of the stream. 325 static const seekdir beg = seekdir(0); 326 /// Request a seek relative to the current position within the sequence. 327 static const seekdir cur = seekdir(SEEK_CUR); 328 /// Request a seek relative to the current end of the sequence. 329 static const seekdir end = seekdir(SEEK_END); 330 331#ifdef _GLIBCPP_DEPRECATED 332 // Annex D.6 333 typedef int io_state; 334 typedef int open_mode; 335 typedef int seek_dir; 336 337 typedef std::streampos streampos; 338 typedef std::streamoff streamoff; 339#endif 340 341 // Callbacks; 342 /** 343 * @doctodo 344 */ 345 enum event 346 { 347 erase_event, 348 imbue_event, 349 copyfmt_event 350 }; 351 352 /** 353 * @doctodo 354 */ 355 typedef void (*event_callback) (event, ios_base&, int); 356 357 /** 358 * @doctodo 359 */ 360 void 361 register_callback(event_callback __fn, int __index); 362 363 protected: 364 //@{ 365 /** 366 * @if maint 367 * ios_base data members (doc me) 368 * @endif 369 */ 370 streamsize _M_precision; 371 streamsize _M_width; 372 fmtflags _M_flags; 373 iostate _M_exception; 374 iostate _M_streambuf_state; 375 //@} 376 377 // 27.4.2.6 Members for callbacks 378 // 27.4.2.6 ios_base callbacks 379 struct _Callback_list 380 { 381 // Data Members 382 _Callback_list* _M_next; 383 ios_base::event_callback _M_fn; 384 int _M_index; 385 _Atomic_word _M_refcount; // 0 means one reference. 386 387 _Callback_list(ios_base::event_callback __fn, int __index, 388 _Callback_list* __cb) 389 : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { } 390 391 void 392 _M_add_reference() { __atomic_add(&_M_refcount, 1); } 393 394 // 0 => OK to delete. 395 int 396 _M_remove_reference() { return __exchange_and_add(&_M_refcount, -1); } 397 }; 398 399 _Callback_list* _M_callbacks; 400 401 void 402 _M_call_callbacks(event __ev) throw(); 403 404 void 405 _M_dispose_callbacks(void); 406 407 // 27.4.2.5 Members for iword/pword storage 408 struct _Words 409 { 410 void* _M_pword; 411 long _M_iword; 412 _Words() : _M_pword(0), _M_iword(0) { } 413 }; 414 415 // Only for failed iword/pword calls. 416 _Words _M_word_zero; 417 418 // Guaranteed storage. 419 // The first 5 iword and pword slots are reserved for internal use. 420 static const int _S_local_word_size = 8; 421 _Words _M_local_word[_S_local_word_size]; 422 423 // Allocated storage. 424 int _M_word_size; 425 _Words* _M_word; 426 427 _Words& 428 _M_grow_words(int __index); 429 430 // Members for locale and locale caching. 431 locale _M_ios_locale; 432 433 void 434 _M_init(); 435 436 public: 437 438 // 27.4.2.1.6 Class ios_base::Init 439 // Used to initialize standard streams. In theory, g++ could use 440 // -finit-priority to order this stuff correctly without going 441 // through these machinations. 442 class Init 443 { 444 friend class ios_base; 445 public: 446 Init(); 447 ~Init(); 448 449 static void 450 _S_ios_create(bool __sync); 451 452 static void 453 _S_ios_destroy(); 454 455 // NB: Allows debugger applications use of the standard streams 456 // from operator new. _S_ios_base_init must be incremented in 457 // _S_ios_create _after_ initialization is completed. 458 static bool 459 _S_initialized() { return _S_ios_base_init; } 460 461 private: 462 static int _S_ios_base_init; 463 static bool _S_synced_with_stdio; 464 }; 465 466 // [27.4.2.2] fmtflags state functions 467 /** 468 * @brief Access to format flags. 469 * @return The format control flags for both input and output. 470 */ 471 inline fmtflags 472 flags() const { return _M_flags; } 473 474 /** 475 * @brief Setting new format flags all at once. 476 * @param fmtfl The new flags to set. 477 * @return The previous format control flags. 478 * 479 * This function overwrites all the format flags with @a fmtfl. 480 */ 481 inline fmtflags 482 flags(fmtflags __fmtfl) 483 { 484 fmtflags __old = _M_flags; 485 _M_flags = __fmtfl; 486 return __old; 487 } 488 489 /** 490 * @brief Setting new format flags. 491 * @param fmtfl Additional flags to set. 492 * @return The previous format control flags. 493 * 494 * This function sets additional flags in format control. Flags that 495 * were previously set remain set. 496 */ 497 inline fmtflags 498 setf(fmtflags __fmtfl) 499 { 500 fmtflags __old = _M_flags; 501 _M_flags |= __fmtfl; 502 return __old; 503 } 504 505 /** 506 * @brief Setting new format flags. 507 * @param fmtfl Additional flags to set. 508 * @param mask The flags mask for @a fmtfl. 509 * @return The previous format control flags. 510 * 511 * This function clears @a mask in the format flags, then sets 512 * @a fmtfl @c & @a mask. An example mask is @c ios_base::adjustfield. 513 */ 514 inline fmtflags 515 setf(fmtflags __fmtfl, fmtflags __mask) 516 { 517 fmtflags __old = _M_flags; 518 _M_flags &= ~__mask; 519 _M_flags |= (__fmtfl & __mask); 520 return __old; 521 } 522 523 /** 524 * @brief Clearing format flags. 525 * @param mask The flags to unset. 526 * 527 * This function clears @a mask in the format flags. 528 */ 529 inline void 530 unsetf(fmtflags __mask) { _M_flags &= ~__mask; } 531 532 /** 533 * @brief Flags access. 534 * @return The precision to generate on certain output operations. 535 * 536 * @if maint 537 * Be careful if you try to give a definition of "precision" here; see 538 * DR 189. 539 * @endif 540 */ 541 inline streamsize 542 precision() const { return _M_precision; } 543 544 /** 545 * @brief Changing flags. 546 * @param prec The new precision value. 547 * @return The previous value of precision(). 548 */ 549 inline streamsize 550 precision(streamsize __prec) 551 { 552 streamsize __old = _M_precision; 553 _M_precision = __prec; 554 return __old; 555 } 556 557 /** 558 * @brief Flags access. 559 * @return The minimum field width to generate on output operations. 560 * 561 * "Minimum field width" refers to the number of characters. 562 */ 563 inline streamsize 564 width() const { return _M_width; } 565 566 /** 567 * @brief Changing flags. 568 * @param wide The new width value. 569 * @return The previous value of width(). 570 */ 571 inline streamsize 572 width(streamsize __wide) 573 { 574 streamsize __old = _M_width; 575 _M_width = __wide; 576 return __old; 577 } 578 579 // [27.4.2.4] ios_base static members 580 /** 581 * @brief Interaction with the standard C I/O objects. 582 * @param sync Whether to synchronize or not. 583 * @return True if the standard streams were previously synchronized. 584 * 585 * The synchronization referred to is @e only that between the standard 586 * C facilities (e.g., stdout) and the standard C++ objects (e.g., 587 * cout). User-declared streams are unaffected. See 588 * http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#8 for more. 589 */ 590 static bool 591 sync_with_stdio(bool __sync = true); 592 593 // [27.4.2.3] ios_base locale functions 594 /** 595 * @brief Setting a new locale. 596 * @param loc The new locale. 597 * @return The previous locale. 598 * 599 * Sets the new locale for this stream, and 600 * [XXX does something with callbacks]. 601 */ 602 locale 603 imbue(const locale& __loc); 604 605 /** 606 * @brief Locale access 607 * @return A copy of the current locale. 608 * 609 * If @c imbue(loc) has previously been called, then this function 610 * returns @c loc. Otherwise, it returns a copy of @c std::locale(), 611 * the global C++ locale. 612 */ 613 inline locale 614 getloc() const { return _M_ios_locale; } 615 616 /** 617 * @brief Locale access 618 * @return A reference to the current locale. 619 * 620 * Like getloc above, but returns a reference instead of 621 * generating a copy. 622 */ 623 inline const locale& 624 _M_getloc() const { return _M_ios_locale; } 625 626 // [27.4.2.5] ios_base storage functions 627 /** 628 * @doctodo 629 */ 630 static int 631 xalloc() throw(); 632 633 /** 634 * @doctodo 635 */ 636 inline long& 637 iword(int __ix) 638 { 639 _Words& __word = (__ix < _M_word_size) 640 ? _M_word[__ix] : _M_grow_words(__ix); 641 return __word._M_iword; 642 } 643 644 /** 645 * @doctodo 646 */ 647 inline void*& 648 pword(int __ix) 649 { 650 _Words& __word = (__ix < _M_word_size) 651 ? _M_word[__ix] : _M_grow_words(__ix); 652 return __word._M_pword; 653 } 654 655 // Destructor 656 /** 657 * Destroys local storage and 658 * [XXX does something with callbacks]. 659 */ 660 ~ios_base(); 661 662 protected: 663 ios_base(); 664 665#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS 666 //50. Copy constructor and assignment operator of ios_base 667 private: 668 ios_base(const ios_base&); 669 670 ios_base& 671 operator=(const ios_base&); 672#endif 673 }; 674 675 // [27.4.5.1] fmtflags manipulators 676 /// Calls base.setf(ios_base::boolalpha). 677 inline ios_base& 678 boolalpha(ios_base& __base) 679 { 680 __base.setf(ios_base::boolalpha); 681 return __base; 682 } 683 684 /// Calls base.unsetf(ios_base::boolalpha). 685 inline ios_base& 686 noboolalpha(ios_base& __base) 687 { 688 __base.unsetf(ios_base::boolalpha); 689 return __base; 690 } 691 692 /// Calls base.setf(ios_base::showbase). 693 inline ios_base& 694 showbase(ios_base& __base) 695 { 696 __base.setf(ios_base::showbase); 697 return __base; 698 } 699 700 /// Calls base.unsetf(ios_base::showbase). 701 inline ios_base& 702 noshowbase(ios_base& __base) 703 { 704 __base.unsetf(ios_base::showbase); 705 return __base; 706 } 707 708 /// Calls base.setf(ios_base::showpoint). 709 inline ios_base& 710 showpoint(ios_base& __base) 711 { 712 __base.setf(ios_base::showpoint); 713 return __base; 714 } 715 716 /// Calls base.unsetf(ios_base::showpoint). 717 inline ios_base& 718 noshowpoint(ios_base& __base) 719 { 720 __base.unsetf(ios_base::showpoint); 721 return __base; 722 } 723 724 /// Calls base.setf(ios_base::showpos). 725 inline ios_base& 726 showpos(ios_base& __base) 727 { 728 __base.setf(ios_base::showpos); 729 return __base; 730 } 731 732 /// Calls base.unsetf(ios_base::showpos). 733 inline ios_base& 734 noshowpos(ios_base& __base) 735 { 736 __base.unsetf(ios_base::showpos); 737 return __base; 738 } 739 740 /// Calls base.setf(ios_base::skipws). 741 inline ios_base& 742 skipws(ios_base& __base) 743 { 744 __base.setf(ios_base::skipws); 745 return __base; 746 } 747 748 /// Calls base.unsetf(ios_base::skipws). 749 inline ios_base& 750 noskipws(ios_base& __base) 751 { 752 __base.unsetf(ios_base::skipws); 753 return __base; 754 } 755 756 /// Calls base.setf(ios_base::uppercase). 757 inline ios_base& 758 uppercase(ios_base& __base) 759 { 760 __base.setf(ios_base::uppercase); 761 return __base; 762 } 763 764 /// Calls base.unsetf(ios_base::uppercase). 765 inline ios_base& 766 nouppercase(ios_base& __base) 767 { 768 __base.unsetf(ios_base::uppercase); 769 return __base; 770 } 771 772 /// Calls base.setf(ios_base::unitbuf). 773 inline ios_base& 774 unitbuf(ios_base& __base) 775 { 776 __base.setf(ios_base::unitbuf); 777 return __base; 778 } 779 780 /// Calls base.unsetf(ios_base::unitbuf). 781 inline ios_base& 782 nounitbuf(ios_base& __base) 783 { 784 __base.unsetf(ios_base::unitbuf); 785 return __base; 786 } 787 788 // [27.4.5.2] adjustfield anipulators 789 /// Calls base.setf(ios_base::internal, ios_base::adjustfield). 790 inline ios_base& 791 internal(ios_base& __base) 792 { 793 __base.setf(ios_base::internal, ios_base::adjustfield); 794 return __base; 795 } 796 797 /// Calls base.setf(ios_base::left, ios_base::adjustfield). 798 inline ios_base& 799 left(ios_base& __base) 800 { 801 __base.setf(ios_base::left, ios_base::adjustfield); 802 return __base; 803 } 804 805 /// Calls base.setf(ios_base::right, ios_base::adjustfield). 806 inline ios_base& 807 right(ios_base& __base) 808 { 809 __base.setf(ios_base::right, ios_base::adjustfield); 810 return __base; 811 } 812 813 // [27.4.5.3] basefield anipulators 814 /// Calls base.setf(ios_base::dec, ios_base::basefield). 815 inline ios_base& 816 dec(ios_base& __base) 817 { 818 __base.setf(ios_base::dec, ios_base::basefield); 819 return __base; 820 } 821 822 /// Calls base.setf(ios_base::hex, ios_base::basefield). 823 inline ios_base& 824 hex(ios_base& __base) 825 { 826 __base.setf(ios_base::hex, ios_base::basefield); 827 return __base; 828 } 829 830 /// Calls base.setf(ios_base::oct, ios_base::basefield). 831 inline ios_base& 832 oct(ios_base& __base) 833 { 834 __base.setf(ios_base::oct, ios_base::basefield); 835 return __base; 836 } 837 838 // [27.4.5.4] floatfield anipulators 839 /// Calls base.setf(ios_base::fixed, ios_base::floatfield). 840 inline ios_base& 841 fixed(ios_base& __base) 842 { 843 __base.setf(ios_base::fixed, ios_base::floatfield); 844 return __base; 845 } 846 847 /// Calls base.setf(ios_base::scientific, ios_base::floatfield). 848 inline ios_base& 849 scientific(ios_base& __base) 850 { 851 __base.setf(ios_base::scientific, ios_base::floatfield); 852 return __base; 853 } 854 855} // namespace std 856 857#endif /* _CPP_BITS_IOSBASE_H */ 858 859