#include <Pt/TextStream.h>
Converts character sequences using a codec. More...
Inherits BasicOStream< CharT >.
Public Types | |
typedef CharT | char_type |
Internal character type. | |
typedef TextCodec< char_type, extern_type > | CodecType |
Codec type. | |
typedef ByteT | extern_type |
External character type. | |
typedef traits_type::int_type | int_type |
Integer type. | |
typedef CharT | intern_type |
Internal character type. | |
typedef traits_type::off_type | off_type |
Stream offset type. | |
typedef traits_type::pos_type | pos_type |
Stream position type. | |
typedef std::basic_ostream < extern_type > | StreamType |
External stream type. | |
typedef std::char_traits< CharT > | traits_type |
Internal character traits. | |
Public Member Functions | |
BasicTextOStream (StreamType &os, CodecType *codec) | |
Construct with output stream and codec. More... | |
BasicTextOStream (CodecType *codec) | |
Construct with codec. More... | |
~BasicTextOStream () | |
Destructor. | |
void | attach (StreamType &os) |
Attach to external target. | |
BasicStreamBuffer< CharT > * | buffer () |
Returns the buffer. | |
CodecType * | codec () |
Returns the used code or a nullptr. | |
void | detach () |
Detach from external target. | |
void | discard () |
Discards the buffer. | |
void | reset () |
Resets the buffer and target. More... | |
void | reset (StreamType &os) |
Resets the buffer and target. More... | |
void | setBuffer (BasicStreamBuffer< CharT > *sb) |
Sets the buffer. | |
void | setCodec (CodecType *codec) |
Sets the text codec. More... | |
BasicTextBuffer< intern_type, extern_type > & | textBuffer () |
Returns the stream buffer. | |
std::streamsize | writesome (CharT *buffer, std::streamsize n) |
Write as much data as fits in buffer. | |
This stream encodes an external character sequence using a codec. Writing to the stream will convert the written characters to the external character types in the external encoding.
BasicTextOStream | ( | StreamType & | os, |
CodecType * | codec | ||
) |
The character sequence converted by the codec is written to the output stream os. The codec object which is passed as a pointer will be managed by this class and deleted if its reference count reaches 0.
|
explicit |
The codec object which is passed as pointer will be managed by this class and deleted if its reference count reaches 0.
void setCodec | ( | CodecType * | codec | ) |
The codec object which is passed as pointer will be managed by this class and deleted if its reference count reaches 0.
void reset | ( | ) |
The target is detached and the buffer content is discarded. The codec is kept, if one was set previously.
void reset | ( | StreamType & | os | ) |
Attaches to the new target and discards the buffer. The codec is kept, if one was set previously.