17 #ifndef ZORBA_TRANSCODE_STREAM_API_H
18 #define ZORBA_TRANSCODE_STREAM_API_H
24 #include <zorba/config.h>
70 class ZORBA_DLL_PUBLIC
streambuf :
public std::streambuf {
80 streambuf(
char const *charset, std::streambuf *orig );
93 return proxy_buf_->original();
97 void imbue( std::locale
const& );
98 pos_type seekoff( off_type, std::ios_base::seekdir, std::ios_base::openmode );
99 pos_type seekpos( pos_type, std::ios_base::openmode );
100 std::streambuf* setbuf( char_type*, std::streamsize );
101 std::streamsize showmanyc();
103 int_type overflow( int_type );
104 int_type pbackfail( int_type );
106 int_type underflow();
107 std::streamsize xsgetn( char_type*, std::streamsize );
108 std::streamsize xsputn( char_type
const*, std::streamsize );
135 void stream_callback( std::ios_base::event, std::ios_base&,
int index );
139 namespace transcode {
154 template<
typename charT,
typename Traits>
inline
155 void attach( std::basic_ios<charT,Traits> &ios,
char const *charset ) {
157 void *&pword = ios.pword( index );
174 template<
typename charT,
typename Traits>
inline
175 void detach( std::basic_ios<charT,Traits> &ios ) {
177 if (
streambuf *
const buf = static_cast<streambuf*>( ios.pword( index ) ) ) {
178 ios.pword( index ) = 0;
179 ios.rdbuf( buf->orig_streambuf() );
190 template<
typename charT,
typename Traits>
inline
209 template<
class StreamType>
221 attach( stream, charset );
248 template<
class StreamType>
259 # pragma warning( push )
260 # pragma warning( disable : 4355 )
262 tbuf_( charset, this->rdbuf() )
264 # pragma warning( pop )
280 template<
typename StreamArgType>
281 stream(
char const *charset, StreamArgType stream_arg ) :
282 StreamType( stream_arg ),
284 # pragma warning( push )
285 # pragma warning( disable : 4355 )
287 tbuf_( charset, this->rdbuf() )
289 # pragma warning( pop )
306 template<
typename StreamArgType>
307 stream(
char const *charset, StreamArgType stream_arg,
308 std::ios_base::openmode mode ) :
309 StreamType( stream_arg, mode ),
311 # pragma warning( push )
312 # pragma warning( disable : 4355 )
314 tbuf_( charset, this->rdbuf() )
316 # pragma warning( pop )
326 this->std::ios::rdbuf( &tbuf_ );