17 #ifndef ZORBA_BASE64_STREAM_API_H
18 #define ZORBA_BASE64_STREAM_API_H
22 #include <zorba/config.h>
68 class ZORBA_DLL_PUBLIC
streambuf :
public std::streambuf {
93 void imbue( std::locale
const& );
94 pos_type seekoff( off_type, std::ios_base::seekdir, std::ios_base::openmode );
95 pos_type seekpos( pos_type, std::ios_base::openmode );
96 std::streambuf* setbuf( char_type*, std::streamsize );
97 std::streamsize showmanyc();
99 int_type overflow( int_type );
100 int_type pbackfail( int_type );
101 int_type underflow();
102 std::streamsize xsgetn( char_type*, std::streamsize );
103 std::streamsize xsputn( char_type
const*, std::streamsize );
106 std::streambuf *orig_buf_;
152 template<
typename charT,
class Traits>
inline
153 void attach( std::basic_ios<charT,Traits> &ios ) {
155 void *&pword = ios.pword( index );
157 std::streambuf *
const buf =
173 template<
typename charT,
class Traits>
inline
174 void detach( std::basic_ios<charT,Traits> &ios ) {
176 if (
streambuf *
const buf = static_cast<streambuf*>( ios.pword( index ) ) ) {
177 ios.pword( index ) = 0;
178 ios.rdbuf( buf->orig_streambuf() );
189 template<
typename charT,
class Traits>
inline
208 template<
class StreamType>
246 template<
class StreamType>
254 # pragma warning( push )
255 # pragma warning( disable : 4355 )
257 b64buf_( this->rdbuf() )
259 # pragma warning( pop )
273 template<
typename StreamArgType>
275 StreamType( stream_arg ),
277 # pragma warning( push )
278 # pragma warning( disable : 4355 )
280 b64buf_( this->rdbuf() )
282 # pragma warning( pop )
297 template<
typename StreamArgType>
298 stream( StreamArgType stream_arg, std::ios_base::openmode mode ) :
299 StreamType( stream_arg, mode ),
301 # pragma warning( push )
302 # pragma warning( disable : 4355 )
304 b64buf_( this->rdbuf() )
306 # pragma warning( pop )
316 this->std::ios::rdbuf( &b64buf_ );
void detach(std::basic_ios< charT, Traits > &ios)
Detaches a previously attached base64::streambuf from a stream.
A base64::streambuf is-a std::streambuf for encoding to and decoding from Base64 on-the-fly.
void attach(std::basic_ios< charT, Traits > &ios)
Attaches a base64::streambuf to a stream.
~auto_attach()
Destroys this auto_attach object calling detach() on the previously attached stream.
A base64::stream is used to wrap a C++ standard I/O stream with a base64::streambuf so that encoding/...
ZORBA_DLL_PUBLIC int get_streambuf_index()
stream()
Constructs a base64::stream.
ZORBA_DLL_PUBLIC std::streambuf * alloc_streambuf(std::streambuf *orig)
stream(StreamArgType stream_arg)
Constructs a stream.
std::streambuf * orig_streambuf() const
Gets the original streambuf.
ZORBA_DLL_PUBLIC void stream_callback(std::ios_base::event, std::ios_base &, int index)
auto_attach(StreamType &stream)
Constructs an auto_attach object calling attach() on the given stream.
stream(StreamArgType stream_arg, std::ios_base::openmode mode)
Constructs a base64::stream.
ZORBA_DLL_PUBLIC void dealloc_streambuf(std::streambuf *)
A base64::auto_attach is a class that attaches a base64::streambuf to a stream and automatically deta...
bool is_attached(std::basic_ios< charT, Traits > &ios)
Checks whether the given stream has a base64::streambuf attached.