zorba::base64::auto_attach

#include <zorba/util/base64_stream.h>

A base64::auto_attach is a class that attaches a base64::streambuf to a stream and automatically detaches it when the auto_attach object is destroyed.
  void f( ostream &os ) {
    base64::auto_attach<ostream> const raii( os );
    // ...
  }
A base64::auto_attach is useful for streams not created by you.

Private Attributes

StreamType *

stream_

Public Functions

bool

attach(StreamType &stream, char const *charset)

Calls base64::attach() on the given stream.

auto_attach()

Default constructor; does nothing.

auto_attach(StreamType &stream)

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

auto_attach(auto_attach &from)

Copy constructor that takes ownership of the stream.

void

detach()

Calls base64::detach().

auto_attach &

operator=(auto_attach &from)

Assignment operator that takes ownership of the stream.

~auto_attach()

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

Private Attributes

stream_

StreamType * stream_

Public Functions

attach

bool attach(StreamType &stream, char const *charset)

Calls base64::attach() on the given stream.

Parameters

stream The stream to attach the base64::streambuf to. If the stream already has a base64::streambuf attached to it, this contructor does nothing.
charset The name of the character encoding to convert from/to.

Returns

true only if a base64::streambuf was attached.

auto_attach

 auto_attach()

Default constructor; does nothing.

auto_attach

 auto_attach(StreamType &stream)

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

Parameters

stream The stream to attach the base64::streambuf to. If the stream already has a base64::streambuf attached to it, this contructor does nothing.

auto_attach

 auto_attach(auto_attach &from)

Copy constructor that takes ownership of the stream.

Parameters

from The auto_attach to take ownership from.

detach

void detach()

operator=

auto_attach & operator=(auto_attach &from)

Assignment operator that takes ownership of the stream.

Parameters

from The auto_attach to take ownership from.

Returns

*this.

~auto_attach

 ~auto_attach()

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