00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _CPP_BITS_IOSBASE_H
00035 #define _CPP_BITS_IOSBASE_H 1
00036
00037 #pragma GCC system_header
00038
00039 namespace std
00040 {
00041
00042
00043
00044
00045 enum _Ios_Fmtflags { _M_ios_fmtflags_end = 1L << 16 };
00046
00047 inline _Ios_Fmtflags
00048 operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
00049 { return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); }
00050
00051 inline _Ios_Fmtflags
00052 operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
00053 { return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); }
00054
00055 inline _Ios_Fmtflags
00056 operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
00057 { return _Ios_Fmtflags(static_cast<int>(__a) ^ static_cast<int>(__b)); }
00058
00059 inline _Ios_Fmtflags
00060 operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
00061 { return __a = __a | __b; }
00062
00063 inline _Ios_Fmtflags
00064 operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
00065 { return __a = __a & __b; }
00066
00067 inline _Ios_Fmtflags
00068 operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
00069 { return __a = __a ^ __b; }
00070
00071 inline _Ios_Fmtflags
00072 operator~(_Ios_Fmtflags __a)
00073 { return _Ios_Fmtflags(~static_cast<int>(__a)); }
00074
00075
00076 enum _Ios_Openmode { _M_ios_openmode_end = 1L << 16 };
00077
00078 inline _Ios_Openmode
00079 operator&(_Ios_Openmode __a, _Ios_Openmode __b)
00080 { return _Ios_Openmode(static_cast<int>(__a) & static_cast<int>(__b)); }
00081
00082 inline _Ios_Openmode
00083 operator|(_Ios_Openmode __a, _Ios_Openmode __b)
00084 { return _Ios_Openmode(static_cast<int>(__a) | static_cast<int>(__b)); }
00085
00086 inline _Ios_Openmode
00087 operator^(_Ios_Openmode __a, _Ios_Openmode __b)
00088 { return _Ios_Openmode(static_cast<int>(__a) ^ static_cast<int>(__b)); }
00089
00090 inline _Ios_Openmode
00091 operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
00092 { return __a = __a | __b; }
00093
00094 inline _Ios_Openmode
00095 operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
00096 { return __a = __a & __b; }
00097
00098 inline _Ios_Openmode
00099 operator^=(_Ios_Openmode& __a, _Ios_Openmode __b)
00100 { return __a = __a ^ __b; }
00101
00102 inline _Ios_Openmode
00103 operator~(_Ios_Openmode __a)
00104 { return _Ios_Openmode(~static_cast<int>(__a)); }
00105
00106
00107 enum _Ios_Iostate { _M_ios_iostate_end = 1L << 16 };
00108
00109 inline _Ios_Iostate
00110 operator&(_Ios_Iostate __a, _Ios_Iostate __b)
00111 { return _Ios_Iostate(static_cast<int>(__a) & static_cast<int>(__b)); }
00112
00113 inline _Ios_Iostate
00114 operator|(_Ios_Iostate __a, _Ios_Iostate __b)
00115 { return _Ios_Iostate(static_cast<int>(__a) | static_cast<int>(__b)); }
00116
00117 inline _Ios_Iostate
00118 operator^(_Ios_Iostate __a, _Ios_Iostate __b)
00119 { return _Ios_Iostate(static_cast<int>(__a) ^ static_cast<int>(__b)); }
00120
00121 inline _Ios_Iostate
00122 operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
00123 { return __a = __a | __b; }
00124
00125 inline _Ios_Iostate
00126 operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
00127 { return __a = __a & __b; }
00128
00129 inline _Ios_Iostate
00130 operator^=(_Ios_Iostate& __a, _Ios_Iostate __b)
00131 { return __a = __a ^ __b; }
00132
00133 inline _Ios_Iostate
00134 operator~(_Ios_Iostate __a)
00135 { return _Ios_Iostate(~static_cast<int>(__a)); }
00136
00137 enum _Ios_Seekdir { _M_ios_seekdir_end = 1L << 16 };
00138
00139
00140 class ios_base
00141 {
00142 public:
00143
00144
00145 class failure : public exception
00146 {
00147 public:
00148 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00149
00150 explicit
00151 failure(const string& __str) throw();
00152
00153 virtual
00154 ~failure() throw();
00155
00156 virtual const char*
00157 what() const throw();
00158
00159 private:
00160 enum { _M_bufsize = 256 };
00161 char _M_name[_M_bufsize];
00162 #endif
00163 };
00164
00165
00166 typedef _Ios_Fmtflags fmtflags;
00167
00168 static const fmtflags boolalpha = fmtflags(__ios_flags::_S_boolalpha);
00169 static const fmtflags dec = fmtflags(__ios_flags::_S_dec);
00170 static const fmtflags fixed = fmtflags(__ios_flags::_S_fixed);
00171 static const fmtflags hex = fmtflags(__ios_flags::_S_hex);
00172 static const fmtflags internal = fmtflags(__ios_flags::_S_internal);
00173 static const fmtflags left = fmtflags(__ios_flags::_S_left);
00174 static const fmtflags oct = fmtflags(__ios_flags::_S_oct);
00175 static const fmtflags right = fmtflags(__ios_flags::_S_right);
00176 static const fmtflags scientific = fmtflags(__ios_flags::_S_scientific);
00177 static const fmtflags showbase = fmtflags(__ios_flags::_S_showbase);
00178 static const fmtflags showpoint = fmtflags(__ios_flags::_S_showpoint);
00179 static const fmtflags showpos = fmtflags(__ios_flags::_S_showpos);
00180 static const fmtflags skipws = fmtflags(__ios_flags::_S_skipws);
00181 static const fmtflags unitbuf = fmtflags(__ios_flags::_S_unitbuf);
00182 static const fmtflags uppercase = fmtflags(__ios_flags::_S_uppercase);
00183 static const fmtflags adjustfield = fmtflags(__ios_flags::_S_adjustfield);
00184 static const fmtflags basefield = fmtflags(__ios_flags::_S_basefield);
00185 static const fmtflags floatfield = fmtflags(__ios_flags::_S_floatfield);
00186
00187
00188 typedef _Ios_Iostate iostate;
00189 static const iostate badbit = iostate(__ios_flags::_S_badbit);
00190 static const iostate eofbit = iostate(__ios_flags::_S_eofbit);
00191 static const iostate failbit = iostate(__ios_flags::_S_failbit);
00192 static const iostate goodbit = iostate(0);
00193
00194
00195 typedef _Ios_Openmode openmode;
00196 static const openmode app = openmode(__ios_flags::_S_app);
00197 static const openmode ate = openmode(__ios_flags::_S_ate);
00198 static const openmode binary = openmode(__ios_flags::_S_bin);
00199 static const openmode in = openmode(__ios_flags::_S_in);
00200 static const openmode out = openmode(__ios_flags::_S_out);
00201 static const openmode trunc = openmode(__ios_flags::_S_trunc);
00202
00203
00204 typedef _Ios_Seekdir seekdir;
00205 static const seekdir beg = seekdir(0);
00206 static const seekdir cur = seekdir(SEEK_CUR);
00207 static const seekdir end = seekdir(SEEK_END);
00208
00209 #ifdef _GLIBCPP_DEPRECATED
00210 typedef int io_state;
00211 typedef int open_mode;
00212 typedef int seek_dir;
00213 #endif
00214
00215
00216 enum event
00217 {
00218 erase_event,
00219 imbue_event,
00220 copyfmt_event
00221 };
00222
00223 typedef void (*event_callback) (event, ios_base&, int);
00224
00225 void
00226 register_callback(event_callback __fn, int __index);
00227
00228 protected:
00229
00230 streamsize _M_precision;
00231 streamsize _M_width;
00232 fmtflags _M_flags;
00233
00234
00235
00236 struct _Callback_list
00237 {
00238
00239 _Callback_list* _M_next;
00240 ios_base::event_callback _M_fn;
00241 int _M_index;
00242 int _M_refcount;
00243
00244 _Callback_list(ios_base::event_callback __fn, int __index,
00245 _Callback_list* __cb)
00246 : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { }
00247
00248 void
00249 _M_add_reference() { ++_M_refcount; }
00250
00251 int
00252 _M_remove_reference() { return _M_refcount--; }
00253 };
00254
00255 _Callback_list* _M_callbacks;
00256
00257 void
00258 _M_call_callbacks(event __ev) throw();
00259
00260 void
00261 _M_dispose_callbacks(void);
00262
00263
00264 struct _Words
00265 {
00266 void* _M_pword;
00267 long _M_iword;
00268 };
00269
00270 static const int _S_local_words = 8;
00271 _Words _M_word_array[_S_local_words];
00272 _Words _M_dummy;
00273 _Words* _M_words;
00274 int _M_word_limit;
00275
00276 _Words&
00277 _M_grow_words(int __index);
00278
00279
00280 locale _M_ios_locale;
00281
00282 void
00283 _M_init();
00284
00285 public:
00286
00287
00288
00289
00290
00291 class Init
00292 {
00293 friend class ios_base;
00294 public:
00295 Init();
00296 ~Init();
00297
00298 static void
00299 _S_ios_create(bool __sync);
00300
00301 static void
00302 _S_ios_destroy();
00303
00304 private:
00305 static int _S_ios_base_init;
00306 static bool _S_synced_with_stdio;
00307 };
00308
00309
00310 inline fmtflags
00311 flags() const { return _M_flags; }
00312
00313 inline fmtflags
00314 flags(fmtflags __fmtfl)
00315 {
00316 fmtflags __old = _M_flags;
00317 _M_flags = __fmtfl;
00318 return __old;
00319 }
00320
00321 inline fmtflags
00322 setf(fmtflags __fmtfl)
00323 {
00324 fmtflags __old = _M_flags;
00325 _M_flags |= __fmtfl;
00326 return __old;
00327 }
00328
00329 inline fmtflags
00330 setf(fmtflags __fmtfl, fmtflags __mask)
00331 {
00332 fmtflags __old = _M_flags;
00333 _M_flags &= ~__mask;
00334 _M_flags |= (__fmtfl & __mask);
00335 return __old;
00336 }
00337
00338 inline void
00339 unsetf(fmtflags __mask) { _M_flags &= ~__mask; }
00340
00341 inline streamsize
00342 precision() const { return _M_precision; }
00343
00344 inline streamsize
00345 precision(streamsize __prec)
00346 {
00347 streamsize __old = _M_precision;
00348 _M_precision = __prec;
00349 return __old;
00350 }
00351
00352 inline streamsize
00353 width() const { return _M_width; }
00354
00355 inline streamsize
00356 width(streamsize __wide)
00357 {
00358 streamsize __old = _M_width;
00359 _M_width = __wide;
00360 return __old;
00361 }
00362
00363 static bool
00364 sync_with_stdio(bool __sync = true);
00365
00366
00367 locale
00368 imbue(const locale& __loc);
00369
00370 inline locale
00371 getloc() const { return _M_ios_locale; }
00372
00373
00374 static int
00375 xalloc() throw();
00376
00377 inline long&
00378 iword(int __ix)
00379 {
00380 _Words& __word = (__ix < _M_word_limit)
00381 ? _M_words[__ix] : _M_grow_words(__ix);
00382 return __word._M_iword;
00383 }
00384
00385 inline void*&
00386 pword(int __ix)
00387 {
00388 _Words& __word = (__ix < _M_word_limit)
00389 ? _M_words[__ix] : _M_grow_words(__ix);
00390 return __word._M_pword;
00391 }
00392
00393
00394 ~ios_base();
00395
00396 protected:
00397 ios_base();
00398
00399 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00400 private:
00401 ios_base(const ios_base&);
00402
00403 ios_base&
00404 operator=(const ios_base&);
00405 #endif
00406 };
00407
00408
00409 inline ios_base&
00410 boolalpha(ios_base& __base)
00411 {
00412 __base.setf(ios_base::boolalpha);
00413 return __base;
00414 }
00415
00416 inline ios_base&
00417 noboolalpha(ios_base& __base)
00418 {
00419 __base.unsetf(ios_base::boolalpha);
00420 return __base;
00421 }
00422
00423 inline ios_base&
00424 showbase(ios_base& __base)
00425 {
00426 __base.setf(ios_base::showbase);
00427 return __base;
00428 }
00429
00430 inline ios_base&
00431 noshowbase(ios_base& __base)
00432 {
00433 __base.unsetf(ios_base::showbase);
00434 return __base;
00435 }
00436
00437 inline ios_base&
00438 showpoint(ios_base& __base)
00439 {
00440 __base.setf(ios_base::showpoint);
00441 return __base;
00442 }
00443
00444 inline ios_base&
00445 noshowpoint(ios_base& __base)
00446 {
00447 __base.unsetf(ios_base::showpoint);
00448 return __base;
00449 }
00450
00451 inline ios_base&
00452 showpos(ios_base& __base)
00453 {
00454 __base.setf(ios_base::showpos);
00455 return __base;
00456 }
00457
00458 inline ios_base&
00459 noshowpos(ios_base& __base)
00460 {
00461 __base.unsetf(ios_base::showpos);
00462 return __base;
00463 }
00464
00465 inline ios_base&
00466 skipws(ios_base& __base)
00467 {
00468 __base.setf(ios_base::skipws);
00469 return __base;
00470 }
00471
00472 inline ios_base&
00473 noskipws(ios_base& __base)
00474 {
00475 __base.unsetf(ios_base::skipws);
00476 return __base;
00477 }
00478
00479 inline ios_base&
00480 uppercase(ios_base& __base)
00481 {
00482 __base.setf(ios_base::uppercase);
00483 return __base;
00484 }
00485
00486 inline ios_base&
00487 nouppercase(ios_base& __base)
00488 {
00489 __base.unsetf(ios_base::uppercase);
00490 return __base;
00491 }
00492
00493 inline ios_base&
00494 unitbuf(ios_base& __base)
00495 {
00496 __base.setf(ios_base::unitbuf);
00497 return __base;
00498 }
00499
00500 inline ios_base&
00501 nounitbuf(ios_base& __base)
00502 {
00503 __base.unsetf(ios_base::unitbuf);
00504 return __base;
00505 }
00506
00507
00508 inline ios_base&
00509 internal(ios_base& __base)
00510 {
00511 __base.setf(ios_base::internal, ios_base::adjustfield);
00512 return __base;
00513 }
00514
00515 inline ios_base&
00516 left(ios_base& __base)
00517 {
00518 __base.setf(ios_base::left, ios_base::adjustfield);
00519 return __base;
00520 }
00521
00522 inline ios_base&
00523 right(ios_base& __base)
00524 {
00525 __base.setf(ios_base::right, ios_base::adjustfield);
00526 return __base;
00527 }
00528
00529
00530 inline ios_base&
00531 dec(ios_base& __base)
00532 {
00533 __base.setf(ios_base::dec, ios_base::basefield);
00534 return __base;
00535 }
00536
00537 inline ios_base&
00538 hex(ios_base& __base)
00539 {
00540 __base.setf(ios_base::hex, ios_base::basefield);
00541 return __base;
00542 }
00543
00544 inline ios_base&
00545 oct(ios_base& __base)
00546 {
00547 __base.setf(ios_base::oct, ios_base::basefield);
00548 return __base;
00549 }
00550
00551
00552 inline ios_base&
00553 fixed(ios_base& __base)
00554 {
00555 __base.setf(ios_base::fixed, ios_base::floatfield);
00556 return __base;
00557 }
00558
00559 inline ios_base&
00560 scientific(ios_base& __base)
00561 {
00562 __base.setf(ios_base::scientific, ios_base::floatfield);
00563 return __base;
00564 }
00565
00566 }
00567
00568 #endif
00569