#include <Pt/TextBuffer.h>
Converts character sequences with different encodings. More...
Inherits BasicStreamBuffer< CharT >.
Public Types | |
| typedef ByteT | extern_type |
| External character type. | |
| typedef CharT | intern_type |
| Internal character type. | |
| typedef CharT | char_type |
| Internal character type. | |
| typedef std::char_traits< CharT > | traits_type |
| Internal character traits. | |
| typedef traits_type::int_type | int_type |
| Integer type. | |
| typedef traits_type::pos_type | pos_type |
| Stream position type. | |
| typedef traits_type::off_type | off_type |
| Stream offset type. | |
| typedef TextCodec< char_type, extern_type > | CodecType |
| Codec type. | |
Public Member Functions | |
| BasicTextBuffer (std::basic_ios< extern_type > &target, CodecType *codec=0) | |
| Construct with external device and codec. More... | |
| BasicTextBuffer (CodecType *codec=0) | |
| Construct with codec. More... | |
| ~BasicTextBuffer () throw () | |
| Destructor. | |
| CodecType * | codec () |
| Returns the used codec or a nullptr. | |
| void | setCodec (CodecType *codec) |
| Sets the text codec. More... | |
| void | attach (std::basic_ios< extern_type > &target) |
| Attach to external target. | |
| void | detach () |
| Detach from external target. | |
| void | reset () |
| Resets the buffer and target. More... | |
| void | reset (std::basic_ios< extern_type > &target) |
| Resets the buffer and target. More... | |
| void | discard () |
| Discards the buffer. | |
| std::streamsize | import (std::streamsize size=0) |
| Import data from the external device. More... | |
| std::streamsize | import (const extern_type *buf, std::streamsize size) |
| Import data from a buffer. More... | |
| std::streamsize | speekn (CharT *buffer, std::streamsize size) |
| Peek data in stream. | |
| std::streamsize | out_avail () |
| Returns the number of characters buffered for output. | |
Protected Member Functions | |
| virtual std::streamsize | showfull () |
| Returns the number of characters buffered for output. | |
This stream buffer encodes and decodes an external character sequence using a codec. Writing to the stream buffer will convert the written characters to the external character types in the external encoding. Reading from the stream buffer will convert from the the encoding of external characters.
|
explicit |
The given stream buffer target is used as external device. All input from and output to the external device is converted using the codec codec. The codec object which is passed as a pointer will be managed by this class and deleted if its reference count reaches 0.
|
explicit |
All input from and output to the external device is converted using the codec codec.
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 | ( | std::basic_ios< extern_type > & | target | ) |
Attaches to the new target and discards the buffer. The codec is kept, if one was set previously.
| std::streamsize import | ( | std::streamsize | size = 0 | ) |
Returns the number of bytes consumed from the underlying stream.
| std::streamsize import | ( | const extern_type * | buf, |
| std::streamsize | size | ||
| ) |
Returns the number of bytes consumed from the input string.