ReactOS 0.4.15-dev-7788-g1ad9096
_ios_base.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18#ifndef _STLP_IOS_BASE_H
19#define _STLP_IOS_BASE_H
20
21#ifndef _STLP_INTERNAL_STDEXCEPT_BASE
22# include <stl/_stdexcept_base.h>
23#endif
24
25#ifndef _STLP_INTERNAL_PAIR_H
26# include <stl/_pair.h>
27#endif
28
29#ifndef _STLP_INTERNAL_LOCALE_H
30# include <stl/_locale.h>
31#endif
32
33#ifndef _STLP_INTERNAL_STRING_H
34# include <stl/_string.h>
35#endif
36
38
39// ----------------------------------------------------------------------
40
41// Class ios_base. This is the base class of the ios hierarchy, which
42// includes basic_istream and basic_ostream. Classes in the ios
43// hierarchy are actually quite simple: they are just glorified
44// wrapper classes. They delegate buffering and physical character
45// manipulation to the streambuf classes, and they delegate most
46// formatting tasks to a locale.
47
49public:
50
52 public:
53 explicit failure(const string&);
55 };
56
57 typedef int fmtflags;
58 typedef int iostate;
59 typedef int openmode;
60 typedef int seekdir;
61
62# ifndef _STLP_NO_ANACHRONISMS
64# endif
65
66 // Formatting flags.
70 _STLP_STATIC_CONSTANT(int, dec = 0x0008);
71 _STLP_STATIC_CONSTANT(int, hex = 0x0010);
72 _STLP_STATIC_CONSTANT(int, oct = 0x0020);
82 _STLP_STATIC_CONSTANT(int, adjustfield = left | right | internal);
83 _STLP_STATIC_CONSTANT(int, basefield = dec | hex | oct);
85
86 // State flags.
87 _STLP_STATIC_CONSTANT(int, goodbit = 0x00);
88 _STLP_STATIC_CONSTANT(int, badbit = 0x01);
89 _STLP_STATIC_CONSTANT(int, eofbit = 0x02);
90 _STLP_STATIC_CONSTANT(int, failbit = 0x04);
91
92 // Openmode flags.
93 _STLP_STATIC_CONSTANT(int, __default_mode = 0x0); /* implementation detail */
94 _STLP_STATIC_CONSTANT(int, app = 0x01);
95 _STLP_STATIC_CONSTANT(int, ate = 0x02);
100
101 // Seekdir flags
102 _STLP_STATIC_CONSTANT(int, beg = 0x01);
105
106public: // Flag-manipulation functions.
107 fmtflags flags() const { return _M_fmtflags; }
109 fmtflags __tmp = _M_fmtflags;
110 _M_fmtflags = __flags;
111 return __tmp;
112 }
113
115 fmtflags __tmp = _M_fmtflags;
116 _M_fmtflags |= __flag;
117 return __tmp;
118 }
119 fmtflags setf(fmtflags __flag, fmtflags __mask) {
120 fmtflags __tmp = _M_fmtflags;
121 _M_fmtflags &= ~__mask;
122 _M_fmtflags |= __flag & __mask;
123 return __tmp;
124 }
125 void unsetf(fmtflags __mask) { _M_fmtflags &= ~__mask; }
126
127 streamsize precision() const { return _M_precision; }
129 streamsize __tmp = _M_precision;
130 _M_precision = __newprecision;
131 return __tmp;
132 }
133
134 streamsize width() const { return _M_width; }
136 streamsize __tmp = _M_width;
137 _M_width = __newwidth;
138 return __tmp;
139 }
140
141public: // Locales
142 locale imbue(const locale&);
143 locale getloc() const { return _M_locale; }
144
145public: // Auxiliary storage.
146 static int _STLP_CALL xalloc();
147 long& iword(int __index);
148 void*& pword(int __index);
149
150public: // Destructor.
151 virtual ~ios_base();
152
153public: // Callbacks.
154 enum event { erase_event, imbue_event, copyfmt_event };
155 typedef void (*event_callback)(event, ios_base&, int __index);
156 void register_callback(event_callback __fn, int __index);
157
158public: // This member function affects only
159 // the eight predefined ios objects:
160 // cin, cout, etc.
161 static bool _STLP_CALL sync_with_stdio(bool __sync = true);
162
163public: // The C++ standard requires only that these
164 // member functions be defined in basic_ios.
165 // We define them in the non-template
166 // base class to avoid code duplication.
167 operator void*() const { return !fail() ? (void*) __CONST_CAST(ios_base*,this) : (void*) 0; }
168 bool operator!() const { return fail(); }
169
170 iostate rdstate() const { return _M_iostate; }
171
172 bool good() const { return _M_iostate == 0; }
173 bool eof() const { return (_M_iostate & eofbit) != 0; }
174 bool fail() const { return (_M_iostate & (failbit | badbit)) != 0; }
175 bool bad() const { return (_M_iostate & badbit) != 0; }
176
177protected: // The functional protected interface.
178
179 // Copies the state of __x to *this. This member function makes it
180 // possible to implement basic_ios::copyfmt without having to expose
181 // ios_base's private data members. Does not copy _M_exception_mask
182 // or _M_iostate.
183 void _M_copy_state(const ios_base& __x);
184
185 void _M_setstate_nothrow(iostate __state) { _M_iostate |= __state; }
186 void _M_clear_nothrow(iostate __state) { _M_iostate = __state; }
187 iostate _M_get_exception_mask() const { return _M_exception_mask; }
188 void _M_set_exception_mask(iostate __mask) { _M_exception_mask = __mask; }
190 if (_M_iostate & _M_exception_mask)
191 _M_throw_failure();
192 }
193
194 void _M_invoke_callbacks(event);
195 void _STLP_FUNCTION_THROWS _M_throw_failure();
196
197 ios_base(); // Default constructor.
198
199protected: // Initialization of the I/O system
200 static void _STLP_CALL _S_initialize();
201 static void _STLP_CALL _S_uninitialize();
202 static bool _S_is_synced;
203
204private: // Invalidate the copy constructor and
205 // assignment operator.
207 void operator=(const ios_base&);
208
209private: // Data members.
210
216
219
221
223 size_t _M_num_callbacks; // Size of the callback array.
224 size_t _M_callback_index; // Index of the next available callback;
225 // initially zero.
226
227 long* _M_iwords; // Auxiliary storage. The count is zero
228 size_t _M_num_iwords; // if and only if the pointer is null.
229
230 void** _M_pwords;
232
233public:
234 // ----------------------------------------------------------------------
235 // Nested initializer class. This is an implementation detail, but it's
236 // prescribed by the standard. The static initializer object (on
237 // implementations where such a thing is required) is declared in
238 // <iostream>
240 {
241 public:
242 Init();
243 ~Init();
244 private:
245 static long _S_count;
246 friend class ios_base;
247 };
248
249 friend class Init;
250
251public:
252# ifndef _STLP_NO_ANACHRONISMS
253 // 31.6 Old iostreams members [depr.ios.members]
257 typedef _STLP_STD::streamoff streamoff;
258 typedef _STLP_STD::streampos streampos;
259# endif
260};
261
262// ----------------------------------------------------------------------
263// ios_base manipulator functions, from section 27.4.5 of the C++ standard.
264// All of them are trivial one-line wrapper functions.
265
266// fmtflag manipulators, section 27.4.5.1
268 { __s.setf(ios_base::boolalpha); return __s;}
269
271 { __s.unsetf(ios_base::boolalpha); return __s;}
272
274 { __s.setf(ios_base::showbase); return __s;}
275
277 { __s.unsetf(ios_base::showbase); return __s;}
278
280 { __s.setf(ios_base::showpoint); return __s;}
281
283 { __s.unsetf(ios_base::showpoint); return __s;}
284
286 { __s.setf(ios_base::showpos); return __s;}
287
289 { __s.unsetf(ios_base::showpos); return __s;}
290
292 { __s.setf(ios_base::skipws); return __s;}
293
295 { __s.unsetf(ios_base::skipws); return __s;}
296
298 { __s.setf(ios_base::uppercase); return __s;}
299
301 { __s.unsetf(ios_base::uppercase); return __s;}
302
304 { __s.setf(ios_base::unitbuf); return __s;}
305
307 { __s.unsetf(ios_base::unitbuf); return __s;}
308
309
310// adjustfield manipulators, section 27.4.5.2
312 { __s.setf(ios_base::internal, ios_base::adjustfield); return __s; }
313
315 { __s.setf(ios_base::left, ios_base::adjustfield); return __s; }
316
318 { __s.setf(ios_base::right, ios_base::adjustfield); return __s; }
319
320// basefield manipulators, section 27.4.5.3
322 { __s.setf(ios_base::dec, ios_base::basefield); return __s; }
323
325 { __s.setf(ios_base::hex, ios_base::basefield); return __s; }
326
328 { __s.setf(ios_base::oct, ios_base::basefield); return __s; }
329
330
331// floatfield manipulators, section 27.4.5.3
333 { __s.setf(ios_base::fixed, ios_base::floatfield); return __s; }
334
336 { __s.setf(ios_base::scientific, ios_base::floatfield); return __s; }
337
339
340#endif /* _STLP_IOS_BASE */
341
342// Local Variables:
343// mode:C++
344// End:
345
#define _STLP_CALL
Definition: _bc.h:131
ios_base &_STLP_CALL showbase(ios_base &__s)
Definition: _ios_base.h:273
ios_base &_STLP_CALL nounitbuf(ios_base &__s)
Definition: _ios_base.h:306
ios_base &_STLP_CALL nouppercase(ios_base &__s)
Definition: _ios_base.h:300
ios_base &_STLP_CALL unitbuf(ios_base &__s)
Definition: _ios_base.h:303
ios_base &_STLP_CALL scientific(ios_base &__s)
Definition: _ios_base.h:335
ios_base &_STLP_CALL boolalpha(ios_base &__s)
Definition: _ios_base.h:267
ios_base &_STLP_CALL noshowpoint(ios_base &__s)
Definition: _ios_base.h:282
ios_base &_STLP_CALL oct(ios_base &__s)
Definition: _ios_base.h:327
ios_base &_STLP_CALL dec(ios_base &__s)
Definition: _ios_base.h:321
ios_base &_STLP_CALL internal(ios_base &__s)
Definition: _ios_base.h:311
ios_base &_STLP_CALL skipws(ios_base &__s)
Definition: _ios_base.h:291
ios_base &_STLP_CALL noshowpos(ios_base &__s)
Definition: _ios_base.h:288
ios_base &_STLP_CALL showpoint(ios_base &__s)
Definition: _ios_base.h:279
ios_base &_STLP_CALL showpos(ios_base &__s)
Definition: _ios_base.h:285
ios_base &_STLP_CALL uppercase(ios_base &__s)
Definition: _ios_base.h:297
ios_base &_STLP_CALL noshowbase(ios_base &__s)
Definition: _ios_base.h:276
ios_base &_STLP_CALL noskipws(ios_base &__s)
Definition: _ios_base.h:294
ios_base &_STLP_CALL noboolalpha(ios_base &__s)
Definition: _ios_base.h:270
ios_base &_STLP_CALL fixed(ios_base &__s)
Definition: _ios_base.h:332
ptrdiff_t streamsize
Definition: char_traits.h:81
static long _S_count
Definition: _ios_base.h:245
_STLP_STD::streampos streampos
Definition: _ios_base.h:258
fmtflags flags(fmtflags __flags)
Definition: _ios_base.h:108
void operator=(const ios_base &)
_STLP_STATIC_CONSTANT(int, boolalpha=0x0100)
iostate rdstate() const
Definition: _ios_base.h:170
iostate io_state
Definition: _ios_base.h:254
_STLP_STATIC_CONSTANT(int, in=0x08)
size_t _M_num_pwords
Definition: _ios_base.h:231
_STLP_STATIC_CONSTANT(int, basefield=dec|hex|oct)
void ** _M_pwords
Definition: _ios_base.h:230
_STLP_STATIC_CONSTANT(int, failbit=0x04)
_STLP_STATIC_CONSTANT(int, showbase=0x0200)
streamsize width(streamsize __newwidth)
Definition: _ios_base.h:135
ios_base(const ios_base &)
fmtflags setf(fmtflags __flag)
Definition: _ios_base.h:114
iostate _M_iostate
Definition: _ios_base.h:212
void unsetf(fmtflags __mask)
Definition: _ios_base.h:125
void _M_clear_nothrow(iostate __state)
Definition: _ios_base.h:186
_STLP_STATIC_CONSTANT(int, out=0x10)
_STLP_STATIC_CONSTANT(int, ate=0x02)
fmtflags flags() const
Definition: _ios_base.h:107
_STLP_STATIC_CONSTANT(int, internal=0x0004)
size_t _M_num_callbacks
Definition: _ios_base.h:223
_STLP_STATIC_CONSTANT(int, showpos=0x0800)
_STLP_STATIC_CONSTANT(int, uppercase=0x4000)
_STLP_STATIC_CONSTANT(int, unitbuf=0x2000)
fmtflags setf(fmtflags __flag, fmtflags __mask)
Definition: _ios_base.h:119
locale _M_locale
Definition: _ios_base.h:220
pair< event_callback, int > * _M_callbacks
Definition: _ios_base.h:222
void _M_setstate_nothrow(iostate __state)
Definition: _ios_base.h:185
_STLP_STATIC_CONSTANT(int, binary=0x04)
bool fail() const
Definition: _ios_base.h:174
_STLP_STATIC_CONSTANT(int, eofbit=0x02)
_STLP_STATIC_CONSTANT(int, adjustfield=left|right|internal)
_STLP_STATIC_CONSTANT(int, showpoint=0x0400)
streamsize width() const
Definition: _ios_base.h:134
_STLP_STATIC_CONSTANT(int, fixed=0x0040)
int openmode
Definition: _ios_base.h:59
seekdir seek_dir
Definition: _ios_base.h:256
_STLP_STATIC_CONSTANT(int, beg=0x01)
size_t _M_callback_index
Definition: _ios_base.h:224
streamsize _M_precision
Definition: _ios_base.h:217
static bool _S_is_synced
Definition: _ios_base.h:202
void _M_check_exception_mask()
Definition: _ios_base.h:189
_STLP_STATIC_CONSTANT(int, __default_mode=0x0)
int iostate
Definition: _ios_base.h:58
int fmtflags
Definition: _ios_base.h:57
_STLP_STATIC_CONSTANT(int, app=0x01)
streamsize _M_width
Definition: _ios_base.h:218
locale getloc() const
Definition: _ios_base.h:143
size_t _M_num_iwords
Definition: _ios_base.h:228
fmtflags _M_fmtflags
Definition: _ios_base.h:211
streamsize precision() const
Definition: _ios_base.h:127
int seekdir
Definition: _ios_base.h:60
fmtflags fmt_flags
Definition: _ios_base.h:63
_STLP_STATIC_CONSTANT(int, left=0x0001)
_STLP_STATIC_CONSTANT(int, floatfield=scientific|fixed)
streamsize precision(streamsize __newprecision)
Definition: _ios_base.h:128
bool eof() const
Definition: _ios_base.h:173
_STLP_STATIC_CONSTANT(int, cur=0x02)
_STLP_STATIC_CONSTANT(int, end=0x04)
_STLP_STATIC_CONSTANT(int, scientific=0x0080)
_STLP_STATIC_CONSTANT(int, trunc=0x20)
bool operator!() const
Definition: _ios_base.h:168
openmode _M_openmode
Definition: _ios_base.h:213
bool bad() const
Definition: _ios_base.h:175
_STLP_STATIC_CONSTANT(int, goodbit=0x00)
_STLP_STATIC_CONSTANT(int, oct=0x0020)
bool good() const
Definition: _ios_base.h:172
_STLP_STATIC_CONSTANT(int, hex=0x0010)
iostate _M_exception_mask
Definition: _ios_base.h:215
_STLP_STATIC_CONSTANT(int, dec=0x0008)
_STLP_STATIC_CONSTANT(int, right=0x0002)
long * _M_iwords
Definition: _ios_base.h:227
_STLP_STATIC_CONSTANT(int, skipws=0x1000)
void _M_set_exception_mask(iostate __mask)
Definition: _ios_base.h:188
_STLP_STATIC_CONSTANT(int, badbit=0x01)
seekdir _M_seekdir
Definition: _ios_base.h:214
iostate _M_get_exception_mask() const
Definition: _ios_base.h:187
openmode open_mode
Definition: _ios_base.h:255
_STLP_STD::streamoff streamoff
Definition: _ios_base.h:257
Definition: _locale.h:75
#define _STLP_FUNCTION_THROWS
Definition: features.h:872
#define _STLP_NOTHROW_INHERENTLY
Definition: features.h:858
#define __CONST_CAST(__x, __y)
Definition: features.h:584
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
FxCollectionEntry * cur
GLuint GLuint end
Definition: gl.h:1545
struct _cl_event * event
Definition: glext.h:7739
GLdouble GLdouble right
Definition: glext.h:10859
GLuint in
Definition: glext.h:9616
GLint left
Definition: glext.h:7726
const GLuint GLenum const GLvoid * binary
Definition: glext.h:7538
int hex(char ch)
double __cdecl trunc(double)
static FILE * out
Definition: regtests2xml.c:44
Definition: _pair.h:47