cppstd > ios_base

ios_base クラス

ヘッダ

#include <ios>

クラスの説明

このクラスは全てのI/Oストリームクラスの基底クラスとなる。
直接インスタンスを構築したり、コピーしたりすることは禁止されている。

このクラスを単独で使用することはなく、派生クラスであるbasic_iosクラスと共に使用することを前提としている。

このクラスの各々のオブジェクトは以下の情報を持つ。
項目 説明
フォーマットフラグ fmtflags 入出力のフォーマット方法を示す
精度 streamsize 出力用の浮動小数点をフォーマットするために使用される精度を示す
最小フィールド幅 streamsize 入出力の最小のフィールド幅を示す
ロケール locale ストリームのロケールを示す
記憶域 union { long, void* }[] オブジェクトのユーザが自由に使用できる領域
コールバック event_callback[] このオブジェクトに対し、あるイベントが発生したときに呼び出される関数群

定義

class ios_base
{
public:
    class failure;
    class Init;

    // フォーマットフラグ
    typedef ... fmtflags;
    static const fmtflags boolalpha;
    static const fmtflags dec;
    static const fmtflags fixed;
    static const fmtflags hex;
    static const fmtflags internal;
    static const fmtflags left;
    static const fmtflags oct;
    static const fmtflags right;
    static const fmtflags scientific;
    static const fmtflags showbase;
    static const fmtflags showpoint;
    static const fmtflags showpos;
    static const fmtflags skipws;
    static const fmtflags unitbuf;
    static const fmtflags uppercase;
    static const fmtflags adjustfield;
    static const fmtflags basefield;
    static const fmtflags floatfield;

    // I/O状態
    typedef ... iostate;
    static const iostate badbit;
    static const iostate eofbit;
    static const iostate failbit;
    static const iostate goodbit = iostate(0);

    // オープンモード
    typedef ... openmode;
    static const openmode app;
    static const openmode ate;
    static const openmode binary;
    static const openmode in;
    static const openmode out;
    static const openmode trunc;

    // シーク方向
    typedef ... seekdir;
    static const seekdir beg;
    static const seekdir cur;
    static const seekdir end;

    // コンストラクタ
protected:
    ios_base();

public:
    // デストラクタ
    virtual ~ios_base();

    // コピー(禁止)
private:
    ios_base(const ios_base&);
    ios_base& operator=(const ios_base&);

public:
    // フォーマット
    fmtflags flags() const;
    fmtflags flags(fmtflags fmtfl);
    fmtflags setf(fmtflags fmtfl);
    fmtflags setf(fmtflags fmtfl, fmtflags mask);
    void unsetf(fmtflags mask);

    streamsize precision() const;
    streamsize precision(streamsize prec);
    streamsize width() const;
    streamsize width(streamsize wide);

    // ロケール
    locale imbue(const locale& loc);
    locale getloc() const;

    // 記憶域
    static int xalloc();
    long& iword(int index);
    void*& pword(int index);

    // コールバック
    enum event { erase_event, imbue_event, copyfmt_event };
    typedef void (*event_callback)(event, ios_base&, int index);
    void register_callback(event_callback fn, int index);

    // その他
    static bool sync_with_stdio(bool sync = true);
};

メンバの説明

ios_base()

このクラスは直接インスタンスを生成できないため、コンストラクタはprotectedで宣言されている。
コンストラクタで構築してもオブジェクトは初期化されない。
オブジェクトの初期化は basic_ios::init 関数が行う。

virtual ~ios_base()

デストラクタ。
オブジェクトが正しく初期化されていれば、register_callback(event_callback,int)で登録したコールバックをerase_eventで呼出す。

ios_base(const ios_base&);

ios_base& operator=(const ios_base&);

このクラスのオブジェクトのコピーは禁止されているため、コピーコンストラクタと代入演算子はprivateで宣言され、未実装になっている。

fmtflags flags() const;

fmtflags flags(fmtflags fmtfl);

フォーマットフラグの getter と setter。

fmtflags setf(fmtflags fmtfl);

フォーマットフラグに対し、 fmtfl で指定したビットをセットする。
flags(flags() | fmtfl) と同じ。

fmtflags setf(fmtflags fmtfl, fmtflags mask);

フォーマットフラグに対し、mask でしたビットをクリアしたのち、(fmtfl & mssk) のビットをセットする。
flags( (flags() & ~mask) | (fmtfl & ~mask) ) と同じ。

void unsetf(fmtflags mask);

フォーマットフラグに対し、 maskで指定したビットをクリアする。
flags(flags() & ~mask) と同じ。

streamsize precision() const;

streamsize precision(streamsize prec);

出力用の浮動小数点をフォーマットするために使用される精度のgetter/setter。

streamsize width() const;

streamsize width(streamsize wide);

最小フィールド幅のgetter/setter。

locale imbue(const locale& loc);

loc を新しいロケールとして保存し、register_callback(event_callback,int)で登録したコールバックをimbue_eventで呼出す。

locale getloc() const;

現在適用されているストリームのロケールを返す。

static int xalloc();

long& iword(int index);

void*& pword(int index);

TBD

enum event { erase_event, imbue_event, copyfmt_event };

typedef void (*event_callback)(event, ios_base&, int index);

void register_callback(event_callback fn, int index);

TBD

static bool sync_with_stdio(bool sync = true);

TBD
最終更新:2008年03月10日 22:16
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。