Public Member Functions | List of all members
zorba::transcode::auto_attach< StreamType > Class Template Reference

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...

#include <zorba/transcode_stream.h>

Public Member Functions

 auto_attach (StreamType &stream, char const *charset)
 Constructs an auto_attach object calling attach() on the given stream.
 ~auto_attach ()
 Destroys this auto_attach object calling detach() on the previously attached stream.

Detailed Description

template<class StreamType>
class zorba::transcode::auto_attach< StreamType >

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.

void f( ostream &os ) {
transcode::auto_attach<ostream> const raii( os, "ISO-8859-1" );
// ...
}

A transcode::auto_attach is useful for streams not created by you.

See Also
http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization

Definition at line 220 of file transcode_stream.h.

Constructor & Destructor Documentation

template<class StreamType >
zorba::transcode::auto_attach< StreamType >::auto_attach ( StreamType &  stream,
char const *  charset 
)
inline

Constructs an auto_attach object calling attach() on the given stream.

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

Definition at line 230 of file transcode_stream.h.

References zorba::transcode::attach().

template<class StreamType >
zorba::transcode::auto_attach< StreamType >::~auto_attach ( )
inline

Destroys this auto_attach object calling detach() on the previously attached stream.

Definition at line 238 of file transcode_stream.h.

References zorba::transcode::detach().


The documentation for this class was generated from the following file:
blog comments powered by Disqus