Public Member Functions | Protected Member Functions | List of all members
zorba::base64::streambuf Class Reference

A base64::streambuf is-a std::streambuf for encoding to and decoding from Base64 on-the-fly. More...

#include <zorba/base64_stream.h>

Inherits streambuf.

Public Member Functions

std::streambuf * orig_streambuf () const
 Gets the original streambuf. More...
 
 streambuf (std::streambuf *orig)
 Constructs a base64::streambuf. More...
 
 ~streambuf ()
 Destructs a base64::streambuf. More...
 

Protected Member Functions

void imbue (std::locale const &)
 
int_type overflow (int_type)
 
int_type pbackfail (int_type)
 
pos_type seekoff (off_type, std::ios_base::seekdir, std::ios_base::openmode)
 
pos_type seekpos (pos_type, std::ios_base::openmode)
 
std::streambuf * setbuf (char_type *, std::streamsize)
 
std::streamsize showmanyc ()
 
int sync ()
 
int_type underflow ()
 
std::streamsize xsgetn (char_type *, std::streamsize)
 
std::streamsize xsputn (char_type const *, std::streamsize)
 

Detailed Description

A base64::streambuf is-a std::streambuf for encoding to and decoding from Base64 on-the-fly.

To use it, replace a stream's streambuf:

istream is;
// ...
base64::streambuf b64buf( is.rdbuf() );
is.ios::rdbuf( &b64buf );

Note that the base64::streambuf must exist for as long as it's being used by the stream. If you are replacing the streabuf for a stream you did not create, you should set it back to the original streambuf:

void f( ostream &os ) {
base64::streambuf b64buf( os.rdbuf() );
try {
os.ios::rdbuf( &b64buf );
// ...
}
catch ( ... ) {
os.ios::rdbuf( b64buf.orig_streambuf() );
throw;
}
os.ios::rdbuf( b64buf.orig_streambuf() );
}

Alternatively, you may wish to use either attach(), auto_attach, or base64::stream instead.

Note: due to the nature of Base64-encoding, when writing, you must ensure that the streambuf is flushed (by calling either pubsync() on the streambuf or flush() on the owning stream) when done.

While base64::streambuf does support seeking, the positions are relative to the original byte stream.

Definition at line 68 of file base64_stream.h.

Constructor & Destructor Documentation

zorba::base64::streambuf::streambuf ( std::streambuf *  orig)

Constructs a base64::streambuf.

Parameters
origThe original streambuf to read/write from/to.
Exceptions
std::invalid_argumentif is not supported or orig is null.
zorba::base64::streambuf::~streambuf ( )

Destructs a base64::streambuf.

Member Function Documentation

void zorba::base64::streambuf::imbue ( std::locale const &  )
protected
std::streambuf* zorba::base64::streambuf::orig_streambuf ( ) const
inline

Gets the original streambuf.

Returns
said streambuf.

Definition at line 88 of file base64_stream.h.

int_type zorba::base64::streambuf::overflow ( int_type  )
protected
int_type zorba::base64::streambuf::pbackfail ( int_type  )
protected
pos_type zorba::base64::streambuf::seekoff ( off_type  ,
std::ios_base::seekdir  ,
std::ios_base::openmode   
)
protected
pos_type zorba::base64::streambuf::seekpos ( pos_type  ,
std::ios_base::openmode   
)
protected
std::streambuf* zorba::base64::streambuf::setbuf ( char_type *  ,
std::streamsize   
)
protected
std::streamsize zorba::base64::streambuf::showmanyc ( )
protected
int zorba::base64::streambuf::sync ( )
protected
int_type zorba::base64::streambuf::underflow ( )
protected
std::streamsize zorba::base64::streambuf::xsgetn ( char_type *  ,
std::streamsize   
)
protected
std::streamsize zorba::base64::streambuf::xsputn ( char_type const *  ,
std::streamsize   
)
protected

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