Wt
3.3.8
|
#include <Wt/WStringStream>
Classes | |
struct | iterator |
An implementation of an output generator for appending data. More... | |
Public Member Functions | |
WStringStream () | |
Default constructor. More... | |
WStringStream & | operator= (const WStringStream &other) |
Assignment operator. | |
WStringStream (std::ostream &sink) | |
Constructor with std::ostream sink. More... | |
~WStringStream () | |
Destructor. | |
void | append (const char *s, int length) |
Appends a string. More... | |
WStringStream & | operator<< (char) |
Appends a character. | |
WStringStream & | operator<< (char *s) |
Appends a C string. | |
WStringStream & | operator<< (const std::string &s) |
Appends a C++ string. | |
WStringStream & | operator<< (bool) |
Appends a boolean. More... | |
WStringStream & | operator<< (int) |
Appends an integer number. | |
WStringStream & | operator<< (long long) |
Appends an integer number. | |
WStringStream & | operator<< (double) |
Appends a double. | |
iterator | back_inserter () |
Iterator for appending. | |
const char * | c_str () |
Returns the contents as a null-terminated C string. More... | |
std::string | str () const |
Returns the contents as a C++ string. More... | |
bool | empty () const |
Returns whether the contents is empty. More... | |
std::size_t | length () const |
Returns the total length. More... | |
void | clear () |
Clears the contents. More... | |
This is an efficient std::stringstream replacement. It is in particular more efficient when a relatively short string is being composed from many different pieces (avoiding any memory allocation all-together).
Compared to std::stringstream, it also avoids overhead by not supporting the formatting options of the latter, and by not making use of the std::locale, which apparently hampers std::ostream performance (Wt internally uses UTF-8 encoding throughout).
Wt::WStringStream::WStringStream | ( | ) |
Default constructor.
Creates a string stream.
Wt::WStringStream::WStringStream | ( | std::ostream & | sink | ) |
Constructor with std::ostream sink.
Creates a string stream which flushes contents to an std::ostream, instead of relying on internal buffering. The output may still be internally buffered (for performance reasons), and this buffer is only flushed to the underlying ostream when you delete the string stream.
void Wt::WStringStream::append | ( | const char * | s, |
int | length | ||
) |
Appends a string.
Appends length
bytes from the given string.
const char * Wt::WStringStream::c_str | ( | ) |
Returns the contents as a null-terminated C string.
The behaviour is only defined for a string stream with internal buffering.
void Wt::WStringStream::clear | ( | ) |
Clears the contents.
The behaviour is only defined for a string stream with internal buffering.
bool Wt::WStringStream::empty | ( | ) | const |
Returns whether the contents is empty.
The behaviour is only defined for a string stream with internal buffering.
std::size_t Wt::WStringStream::length | ( | ) | const |
Returns the total length.
The behaviour is only defined for a string stream with internal buffering.
WStringStream & Wt::WStringStream::operator<< | ( | bool | v | ) |
Appends a boolean.
This is written to the stream as true
or false
.
std::string Wt::WStringStream::str | ( | ) | const |
Returns the contents as a C++ string.
The behaviour is only defined for a string stream with internal buffering.