A base64::streambuf is-a std::streambuf for encoding to and decoding from Base64 on-the-fly.
More...
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:
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:
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.