basic_ostringstream クラス
要素とエンコードされたオブジェクトを basic_stringbuf<Elem, Tr, Alloc> クラスのストリーム バッファーに挿入する操作を制御するオブジェクトを記述します。
構文
template <class Elem, class Tr = char_traits<Elem>, class Alloc = allocator<Elem>>
class basic_ostringstream : public basic_ostream<Elem, Tr>
パラメーター
Alloc
アロケーター クラス。
Elem
文字列の基本要素の型。
Tr
文字列の基本要素に特化した文字の特徴。
注釈
このクラスは、要素とエンコードされたオブジェクトを、ストリーム バッファーに挿入する操作を制御するオブジェクトを記述します。要素は Elem 型で、文字特性は Tr クラスによって決められ、要素は Alloc クラスのアロケーターによって割り当てられます。 このオブジェクトは、クラス basic_stringbuf<Elem, Tr, Alloc> のオブジェクトを格納します。
コンストラクター
| コンストラクター | 説明 |
|---|---|
| basic_ostringstream | basic_ostringstream 型のオブジェクトを構築します。 |
Typedefs
| 型名 | 説明 |
|---|---|
| allocator_type | この型はテンプレート パラメーター Alloc の同意語です。 |
メンバー関数
| メンバー関数 | 説明 |
|---|---|
| rdbuf | 型 pointer の格納されたストリーム バッファーのアドレスを basic_stringbuf<Elem, Tr, Alloc> に返します。 |
| str | 文字列バッファー内のテキストを設定または取得します。書き込み位置は変更しません。 |
要件
ヘッダー:<sstream>
名前空間: std
basic_ostringstream::allocator_type
この型はテンプレート パラメーター Alloc の同意語です。
typedef Alloc allocator_type;
basic_ostringstream::basic_ostringstream
basic_ostringstream 型のオブジェクトを構築します。
explicit basic_ostringstream(ios_base::openmode _Mode = ios_base::out);
explicit basic_ostringstream(const basic_string<Elem, Tr, Alloc>& str, ios_base::openmode _Mode = ios_base::out);
パラメーター
_Mode
ios_base::openmode の列挙値のうちの 1 つ。
str
basic_string 型のオブジェクト。
注釈
最初のコンストラクターは、basic_ostream( sb ) を呼び出すことで基底クラスを初期化します。ここで、sb はクラス basic_stringbuf< Elem, Tr, Alloc> の格納されているオブジェクトです。 また、basic_stringbuf< Elem, Tr, Alloc>( _Mode | ios_base::out ) を呼び出すことで sb の初期化もします。 詳細については、次のトピックを参照してください。 basic_ostream および basic_stringbuf
2 番目のコンストラクターが basic_ostream( sb ) を呼び出して基底クラスを初期化します。 また、basic_stringbuf< Elem, Tr, Alloc >( str, _Mode | ios_base::out ) を呼び出すことで sb の初期化もします。
basic_ostringstream::rdbuf
型 pointer の格納されたストリーム バッファーのアドレスを basic_stringbuf<Elem, Tr, Alloc> に返します。
basic_stringbuf<Elem, Tr, Alloc> *rdbuf() const;
戻り値
型 pointer の格納されたストリーム バッファーの basic_stringbuf<Elem, Tr, Alloc> へのアドレス。
注釈
このメンバー関数は、pointer 型の格納されたストリーム バッファーのアドレスを basic_stringbuf<Elem, Tr, Alloc> に返します。
例
rdbuf の使用例については、「basic_filebuf::close」を参照してください。
basic_ostringstream::str
文字列バッファー内のテキストを設定または取得します。書き込み位置は変更しません。
basic_string<Elem, Tr, Alloc> str() const;
void str(
const basic_string<Elem, Tr, Alloc>& _Newstr);
パラメーター
_Newstr
新しい文字列。
戻り値
制御されたシーケンスが制御されるシーケンスのコピーであるElem, TrAlloc>basic_stringクラス<のオブジェクトを*this返します。
注釈
最初のメンバー関数は rdbuf ->str を返します。 2 番目のメンバー関数は rdbuf ->str( _Newstr) を呼び出します。
例
str の使用例については、「basic_stringbuf::str」を参照してください。