Regina 7.0 Calculation Engine
Public Member Functions | List of all members
regina::i18n::IConvStreamBuffer Class Reference

An output stream buffer that translates between character encodings. More...

#include <utilities/i18nutils.h>

Inheritance diagram for regina::i18n::IConvStreamBuffer:

Public Member Functions

 IConvStreamBuffer ()
 Creates a new stream buffer. More...
 
 ~IConvStreamBuffer () override
 Destroys this stream buffer. More...
 
IConvStreamBufferopen (std::ostream &dest, const char *srcCode, const char *destCode)
 Opens a new stream buffer that wraps around the given output stream. More...
 
IConvStreamBufferclose () noexcept
 Closes this stream buffer. More...
 
int_type overflow (int_type c) override
 Sends buffered data to the destination output stream, converting between character sets en route. More...
 
int_type underflow () override
 Simply returns EOF (since this is not an input stream). More...
 
int sync () override
 Flushes all output buffers. More...
 
 IConvStreamBuffer (const IConvStreamBuffer &)=delete
 
IConvStreamBufferoperator= (const IConvStreamBuffer &)=delete
 

Detailed Description

An output stream buffer that translates between character encodings.

The iconv library is used to do the real work.

Users should not normally instantiate this class directly; instead see IConvStream for a higher-level interface to character conversion.

This class will still work if iconv is not supported on the build machine, though in this case it will simply pass data through without performing any translations.

Python
Not included.
Author
Parts of this code are modified from the cxxtools library (http://www.tntnet.org/cxxutils.html), which is copyright (c) 2003 by Tommi Maekitalo, and covered by the GNU Lesser General Public License.

Constructor & Destructor Documentation

◆ IConvStreamBuffer()

regina::i18n::IConvStreamBuffer::IConvStreamBuffer ( )
inline

Creates a new stream buffer.

◆ ~IConvStreamBuffer()

regina::i18n::IConvStreamBuffer::~IConvStreamBuffer ( )
inlineoverride

Destroys this stream buffer.

This stream buffer will be closed, but the destination output stream will not be.

Member Function Documentation

◆ close()

IConvStreamBuffer * regina::i18n::IConvStreamBuffer::close ( )
noexcept

Closes this stream buffer.

Returns
this stream buffer on success, or null on error.

◆ open()

IConvStreamBuffer * regina::i18n::IConvStreamBuffer::open ( std::ostream &  dest,
const char *  srcCode,
const char *  destCode 
)

Opens a new stream buffer that wraps around the given output stream.

If this stream buffer is already open, it will be closed and then reopened with the given parameters.

Any data that is sent to this stream buffer will be translated from srcCode to destCode and passed on to the given output stream.

If the given encodings are invalid, this stream will still forward data to the given output stream but no conversion will take place.

See the iconv documentation for information on what encodings are supported. For the GNU C library implementation, valid encodings can be found by running iconv –list.

Precondition
The destination output stream is already open.
Parameters
destthe destination output stream.
srcCodethe character encoding for data that is to be written into this stream buffer.
destCodethe character encoding for the translated data that will subsequently be written to the destination output stream.
Returns
this stream buffer on success, or null on error.

◆ overflow()

int_type regina::i18n::IConvStreamBuffer::overflow ( int_type  c)
override

Sends buffered data to the destination output stream, converting between character sets en route.

The buffer will be flushed as far as possible, and any invalid characters will be replaced with one or more question marks. If the buffer ends in an incomplete multibyte character, this incomplete character will be held back (since it presumably needs to be combined with later input).

Parameters
can extra character to send that did not fit in the internal buffer, or EOF if we simply wish to flush the buffer.
Returns
0 on success, or EOF on error.

◆ sync()

int regina::i18n::IConvStreamBuffer::sync ( )
override

Flushes all output buffers.

The buffers for both this stream and the destination output stream will be flushed.

Returns
0 on success, or -1 on error.

◆ underflow()

IConvStreamBuffer::int_type regina::i18n::IConvStreamBuffer::underflow ( )
inlineoverride

Simply returns EOF (since this is not an input stream).

Returns
EOF.

The documentation for this class was generated from the following file:

Copyright © 1999-2021, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).