vs 2005中ios_base继承自_Iosb<int>,主要提供流状态控制、格式控制、本地化等方面支持。
1、类型和数据定义
class ios_base : public _Iosb<int>
{
public:
// 预定义类型
_BITMASK(_Fmtflags, fmtflags); // 其实是typedef int fmtflags 第一个方便理解
_BITMASK(_Iostate, iostate);
_BITMASK(_Openmode, openmode);
_BITMASK(_Seekdir, seekdir);
typedef std::streamoff streamoff;
typedef std::streampos streampos;
enum event
{ // constants for ios events
erase_event, imbue_event, copyfmt_event};
typedef void (__CLRCALL_OR_CDECL *event_callback)(event, ios_base&, int);
class failure // 用于抛出异常。
: public runtime_error
{
public:
explicit failure(const string &_Message)
: runtime_error(_Message) {}
virtual ~failure() throw () {}
#if !_HAS_EXCEPTIONS
protected:
virtual void _Doraise() const // exception中有相关信息
{ // report the exception
_RAISE(*this);
}
#endif /* _HAS_EXCEPTIONS */
};
class Init // 作用?
{ // controller for standard-stream initialization
public:
Init() { _Init_ctor(this); }
~Init() { _Init_dtor(this); }
private:
static void __cdecl _Init_ctor(Init *); // 位于iostream.cpp中
static void __cdecl _Init_dtor(Init *); // 位于iostream.cpp中
static int& __cdecl _Init_cnt_func(); // 位于iostream.cpp中
static int _Init_cnt; // net constructions - destructions
};
// ...
private:
iostate _Mystate; // stream state
iostate _Except; // exception mask
fmtflags _Fmtfl; // fo