Classes | Functions
zorba::transcode Namespace Reference

Classes

class  auto_attach
 A transcode::auto_attach is a class that attaches a transcode::streambuf to a stream and automatically detaches it when the auto_attach object is destroyed. More...
class  stream
 A transcode::stream is used to wrap a C++ standard I/O stream with a transcode::streambuf so that transcoding and the management of the streambuf happens automatically. More...
class  streambuf
 A transcode::streambuf is-a std::streambuf for transcoding character encodings from/to UTF-8 on-the-fly. More...

Functions

template<typename charT , typename Traits >
void attach (std::basic_ios< charT, Traits > &ios, char const *charset)
 Attaches a transcode::streambuf to a stream.
template<typename charT , typename Traits >
void detach (std::basic_ios< charT, Traits > &ios)
 Detaches a previously attached transcode::streambuf from a stream.
template<typename charT , typename Traits >
bool is_attached (std::basic_ios< charT, Traits > &ios)
 Checks whether the given stream has a transcode::streambuf attached.
ZORBA_DLL_PUBLIC bool is_necessary (char const *charset)
 Checks whether it would be necessary to transcode from the given character encoding to UTF-8.
ZORBA_DLL_PUBLIC bool is_supported (char const *charset)
 Checks whether the given character set is supported for transcoding.
template<typename charT , typename Traits >
std::streambuf * orig_streambuf (std::basic_ios< charT, Traits > &ios)
 Gets the original streambuf of the given iostream.

Function Documentation

template<typename charT , typename Traits >
void zorba::transcode::attach ( std::basic_ios< charT, Traits > &  ios,
char const *  charset 
)
inline

Attaches a transcode::streambuf to a stream.

Unlike using a transcode::streambuf directly, this function will create the streambuf, attach it to the stream, and manage it for the lifetime of the stream automatically.

Parameters
iosThe stream to attach the transcode::streambuf to. If the stream already has a transcode::streambuf attached to it, this function does nothing.
charsetThe name of the character encoding to convert from/to.

Definition at line 150 of file transcode_stream.h.

References zorba::internal::base64::alloc_streambuf(), zorba::internal::base64::get_streambuf_index(), and zorba::internal::stream_callback().

Referenced by zorba::transcode::auto_attach< StreamType >::auto_attach().

template<typename charT , typename Traits >
void zorba::transcode::detach ( std::basic_ios< charT, Traits > &  ios)
inline

Detaches a previously attached transcode::streambuf from a stream.

The streambuf is destroyed and the stream's original streambuf is restored.

Parameters
iosThe stream to detach the transcode::streambuf from. If the stream doesn't have a transcode::streambuf attached to it, this function does nothing.

Definition at line 171 of file transcode_stream.h.

References zorba::internal::dealloc_streambuf(), and zorba::internal::base64::get_streambuf_index().

Referenced by zorba::transcode::auto_attach< StreamType >::~auto_attach().

template<typename charT , typename Traits >
bool zorba::transcode::is_attached ( std::basic_ios< charT, Traits > &  ios)
inline

Checks whether the given stream has a transcode::streambuf attached.

Parameters
iosThe stream to check.
Returns
true only if a transcode::streambuf is attached.

Definition at line 187 of file transcode_stream.h.

References zorba::internal::transcode::get_streambuf_index().

ZORBA_DLL_PUBLIC bool zorba::transcode::is_necessary ( char const *  charset)

Checks whether it would be necessary to transcode from the given character encoding to UTF-8.

Parameters
charsetThe name of the character encoding to check.
Returns
true only if it would be necessary to transcode from the given character encoding to UTF-8.
ZORBA_DLL_PUBLIC bool zorba::transcode::is_supported ( char const *  charset)

Checks whether the given character set is supported for transcoding.

Parameters
charsetThe name of the character encoding to check.
Returns
true only if the character encoding is supported.
template<typename charT , typename Traits >
std::streambuf* zorba::transcode::orig_streambuf ( std::basic_ios< charT, Traits > &  ios)
inline

Gets the original streambuf of the given iostream.

Parameters
iosThe stream to get the original streambuf of.
Returns
the original streambuf.

Definition at line 198 of file transcode_stream.h.

blog comments powered by Disqus