Personal tools
basic_ostringstream
Click on the banner to return to the class reference home page.
basic_ostringstream
basic_ostringstreambasic_ostreambasic_iosios_base
- Data Type and Member Function Indexes
- Synopsis
- Description
- Interface
- Types
- Constructors
- Destructor
- Member Functions
- Examples
- See Also
- Standards Conformance
Data Type and Member Function Indexes
(exclusive of constructors and destructors)
Data Types | ||
char_type int_type ios_type off_type |
ostringstream pos_type sb_type string_type |
traits_type wostringstream |
Synopsis
#include <sstream> template<class charT, class traits = char_traits<charT>, class Allocator = allocator<void> > class basic_ostringstream : public basic_ostream<charT, traits>
Description
The template class basic_ostringstream<charT,traits,Allocator> provides functionality to write 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.
Interface
template<class charT, class traits = char_traits<charT>, class Allocator = allocator<void> > class basic_ostringstream : public basic_ostream<charT, traits> { public: typedef basic_stringbuf<charT, traits, Allocator> sb_type; typedef basic_ios<charT, traits> ios_type; typedef basic_string<charT, traits, Allocator> string_type; 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; 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); };
Types
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;
Constructors
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).
Destructor
virtual ~basic_ostringstream();
Destroys an object of class basic_ostringstream.
Member Functions
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, initialize the input sequence to point at the first character of the buffer. If the opening mode is out, initialize the output sequence to point at the first character of the buffer. If the opening mode is out | app, initialize the output sequence to point at the last character of the buffer.
Examples
See basic_stringstream, basic_istringstream and basic_stringbuf examples.
See Also
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.2.3
Standards Conformance
ANSI X3J16/ISO WG21 Joint C++ Committee
©Copyright 1996, Rogue Wave Software, Inc.