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