#include <Pt/TextBuffer.h>
Converts character sequences with different encodings.
More...
Inherits BasicStreamBuffer< CharT, TraitsT >.
|
|
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.
|
|
| | BasicTextBuffer (std::basic_ios< extern_type > &target, CodecType *codec=0) |
| | Construct with external device and codec.
|
| | BasicTextBuffer (CodecType *codec=0) |
| | Construct with codec.
|
|
| ~BasicTextBuffer () throw () |
| | Destructor.
|
|
CodecType * | codec () |
| | Returns the used codec or a nullptr.
|
| void | setCodec (CodecType *codec) |
| | Sets the text codec.
|
|
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.
|
| void | reset (std::basic_ios< extern_type > &target) |
| | Resets the buffer and target.
|
|
void | discard () |
| | Discards the buffer.
|
| std::streamsize | import (std::streamsize size=0) |
| | Import data from the external device.
|
| std::streamsize | import (const extern_type *buf, std::streamsize size) |
| | Import data from a buffer.
|
| std::streamsize | speekn (CharT *buffer, std::streamsize size) |
| | Peeks characters in the stream buffer.
|
|
std::streamsize | out_avail () |
| | Returns the number of characters buffered for output.
|
|
|
virtual std::streamsize | showfull () |
| | Returns the number of characters buffered for output.
|
template<typename CharT, typename ByteT>
class Pt::BasicTextBuffer< CharT, ByteT >
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.
◆ BasicTextBuffer() [1/2]
template<typename CharT, typename ByteT>
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.
◆ BasicTextBuffer() [2/2]
template<typename CharT, typename ByteT>
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.
◆ setCodec()
template<typename CharT, typename ByteT>
The codec object which is passed as pointer will be managed by this class and deleted if its reference count reaches 0.
◆ reset() [1/2]
template<typename CharT, typename ByteT>
The target is detached and the buffer content is discarded. The codec is kept, if one was set previously.
◆ reset() [2/2]
template<typename CharT, typename ByteT>
Attaches to the new target and discards the buffer. The codec is kept, if one was set previously.
◆ import() [1/2]
template<typename CharT, typename ByteT>
| std::streamsize import |
( |
std::streamsize | size = 0 | ) |
|
Returns the number of bytes consumed from the underlying stream.
◆ import() [2/2]
template<typename CharT, typename ByteT>
| std::streamsize import |
( |
const extern_type * | buf, |
|
|
std::streamsize | size ) |
Returns the number of bytes consumed from the input string.
◆ speekn()
template<typename CharT, typename TraitsT = std::char_traits<CharT>>
| std::streamsize speekn |
( |
CharT * | buffer, |
|
|
std::streamsize | size ) |
|
inherited |
The number of characters that can be peeked depends on the current get area and may be less than requested, similar to istream::readsome(). The characters are not consumed.