zorba::base64::streambuf

#include <zorba/util/base64_stream.h>

A base64::streambuf is-a std::streambuf for decoding from and encoding to Base64 on-the-fly while reading or writing, respectively. 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 , , or 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.

Private Attributes

char

gbuf_[3]

std::streambuf *

orig_buf_

char

pbuf_[3]

int

plen_

Public Functions

std::streambuf *

orig_streambuf() const

Gets the original streambuf.

streambuf(std::streambuf *orig)

Constructs a base64::streambuf.

~streambuf()

Destructs a base64::streambuf.

Protected 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)

Private Functions

void

clear()

streambuf &

operator=(streambuf const &)

void

resetg()

void

resetp()

streambuf(streambuf const &)

void

writep()

Private Attributes

gbuf_

char gbuf_[3]

orig_buf_

std::streambuf * orig_buf_

pbuf_

char pbuf_[3]

plen_

int plen_

Public Functions

orig_streambuf

std::streambuf * orig_streambuf() const

Gets the original streambuf.

Returns

said streambuf.

streambuf

 streambuf(std::streambuf *orig)

Constructs a base64::streambuf.

Parameters

orig The original streambuf to read/write from/to.

Parameters

std::invalid_argument if is not supported or orig is null.

~streambuf

 ~streambuf()

Destructs a base64::streambuf.

Protected Functions

imbue

void imbue(std::locale const &)

overflow

int_type overflow(int_type)

pbackfail

int_type pbackfail(int_type)

seekoff

pos_type seekoff(off_type, std::ios_base::seekdir, std::ios_base::openmode)

seekpos

pos_type seekpos(pos_type, std::ios_base::openmode)

setbuf

std::streambuf * setbuf(char_type *, std::streamsize)

showmanyc

std::streamsize showmanyc()

sync

int sync()

underflow

int_type underflow()

xsgetn

std::streamsize xsgetn(char_type *, std::streamsize)

xsputn

std::streamsize xsputn(char_type const *, std::streamsize)

Private Functions

clear

void clear()

operator=

streambuf & operator=(streambuf const &)

resetg

void resetg()

resetp

void resetp()

streambuf

 streambuf(streambuf const &)

writep

void writep()