basic_ostringstreambasic_ostreambasic_iosios_base
Supports writing objects of class basic_string<charT,traits,Allocator>
Data Types | ||
char_type int_type ios_type off_type |
ostringstream pos_type sb_type string_type |
traits_type wostringstream |
#include <sstream> template<class charT, class traits = char_traits<charT>, class Allocator = allocator<void> > class basic_ostringstream : public basic_ostream<charT, traits>
The template class basic_ostringstream<charT,traits,Allocator> writes to an array in memory. It supports writing objects of class basic_string<charT,traits,Allocator>. It uses a basic_stringbuf object to control the associated storage. It inherits from basic_ostream and therefore can use all the formatted and unformatted output functions.
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT> > class basic_ostringstream : public basic_ostream<charT, traits> { public: typedef traits traits_type; typedef charT char_type; typedef typename traits::int_type int_type; typedef typename traits::pos_type pos_type; typedef typename traits::off_type off_type; typedef basic_stringbuf<charT, traits, Allocator> sb_type; typedef basic_ios<charT, traits> ios_type; typedef basic_string<charT, traits, Allocator> string_type; explicit basic_ostringstream(ios_base::openmode which = ios_base::out); explicit basic_ostringstream(const string_type& str, ios_base::openmode which = ios_base::out); virtual ~basic_ostringstream(); basic_stringbuf<charT,traits,Allocator> *rdbuf() const; string_type str() const; void str(const string_type& str); };
char_type
The type char_type is a synonym for the template parameter charT.
int_type
The type int_type is a synonym of type traits::in_type.
ios_type
The type ios_type is an instantiation of class basic_ios on type charT.
off_type
The type off_type is a synonym of type traits::off_type.
ostringstream
The type ostringstream is an instantiation of class basic_ostringstream on type char:
typedef basic_ostringstream<char> ostringstream;
pos_type
The type pos_type is a synonym of type traits::pos_type.
sb_type
The type sb_type is an instantiation of class basic_stringbuf on type charT.
string_type
The type string_type is an instantiation of class basic_string on type charT.
traits_type
The type traits_type is a synonym for the template parameter traits.
wostringstream
The type wostringstream is an instantiation of class basic_ostringstream on type wchar_t:
typedef basic_ostringstream<wchar_t> wostringstream;
explicit basic_ostringstream(ios_base::openmode which = ios_base::out);
Constructs an object of class basic_ostringstream, initializing the base class basic_ostream with the associated string buffer. The string buffer is initialized by calling the basic_stringbuf constructor basic_stringbuf<charT,traits,Allocator>(which).
explicit basic_ostringstream(const string_type& str, ios_base::openmode which = ios_base::out);
Constructs an object of class basic_ostringstream, initializing the base class basic_ostream with the associated string buffer. The string buffer is initialized by calling the basic_stringbuf constructor basic_stringbuf<charT,traits,Allocator>(str,which).
virtual ~basic_ostringstream();
Destroys an object of class basic_ostringstream.
basic_stringbuf<charT,traits,Allocator>* rdbuf() const;
Returns a pointer to the basic_stringbuf associated with the stream.
string_type str() const;
Returns a string object of type string_type whose contents is a copy of the underlying buffer contents.
void str(const string_type& str);
Clears the underlying string buffer and copies the string object str into it. If the opening mode is in, initializes the input sequence to point to the first character of the buffer. If the opening mode is out, initializes the output sequence to point to the first character of the buffer. If the opening mode is out | app, initializes the output sequence to point to the last character of the buffer.
See basic_stringstream, basic_istringstream and basic_stringbuf examples.
char_traits(3C++), ios_base(3C++), basic_ios(3C++), basic_stringbuf(3C++), basic_string(3C++), basic_istringstream(3C++), basic_stringstream(3C++)
Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Section 27.7.3
ANSI X3J16/ISO WG21 Joint C++ Committee