다음을 통해 공유


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해당 요소를 할당하는 개체를 설명합니다. 개체는 Elem, Tr, 클래스 basic_stringbuf<개체를 Alloc>저장합니다.

생성자

생성자 Description
basic_ostringstream basic_ostringstream 형식의 개체를 생성합니다.

Typedef

형식 이름 설명
allocator_type 형식은 템플릿 매개 변수 Alloc의 동의어입니다.

멤버 함수

멤버 함수 설명
rdbuf basic_stringbuf TrAllocElem<>형식 pointer의 저장된 스트림 버퍼 주소를 반환합니다.
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);

매개 변수

_모드
ios_base::openmode의 열거형 중 하나입니다.

str
basic_string 형식의 개체입니다.

설명

첫 번째 생성자는 클래스의 저장된 개체를 sb 호출basic_ostream( sb )하여 기본 클래스basic_stringbuf< Elem, Tr, Alloc>를 초기화합니다. 또한 호출basic_stringbuf< Elem, Tr, Alloc>( _Mode | ios_base::out )하여 초기화합니다sb. 자세한 내용은 basic_ostreambasic_stringbuf를 참조하세요.

두 번째 생성자는 basic_ostream( sb )를 호출하여 기본 개체를 초기화합니다. 또한 호출basic_stringbuf< Elem, Tr, Alloc >( str, _Mode | ios_base::out )하여 초기화합니다sb.

basic_ostringstream::rdbuf

Elem, TrAlloc>, basic_stringbuf<형식의 pointer저장된 스트림 버퍼 주소를 반환합니다.

basic_stringbuf<Elem, Tr, Alloc> *rdbuf() const;

Return Value

Elem, Tr>Alloc을 basic_stringbuf<형식의 pointer 저장된 스트림 버퍼 주소입니다.

설명

멤버 함수는 형식 pointer 의 저장된 스트림 버퍼 주소를 elem, TrAlloc>, basic_stringbuf<반환합니다.

예시

rdbuf의 사용 예제는 basic_filebuf::close를 참조하세요.

basic_ostringstream::str

쓰기 위치를 변경하지 않고 문자열 버퍼에서 텍스트를 설정하거나 가져옵니다.

basic_string<Elem, Tr, Alloc> str() const;

void str(
    const basic_string<Elem, Tr, Alloc>& _Newstr);

매개 변수

_Newstr
새 문자열입니다.

Return Value

제어되는 시퀀스가 제어*this되는 시퀀스의 복사본인 클래스 basic_string<Elem, >AllocTr의 개체를 반환합니다.

설명

첫 번째 멤버 함수는 rdbuf ->str를 반환합니다. 두 번째 멤버 함수는 ->str( _Newstr)를 호출 rdbuf 합니다.

예시

를 사용하는 str예제는 basic_stringbuf::str을 참조하세요.

참고 항목

C++ 표준 라이브러리의 스레드 보안
iostream 프로그래밍
iostreams 규칙