#ifndef streamIOCtx #define streamIOCtx #include "gd.h" #ifdef __cplusplus #include class BGD_EXPORT_DATA_IMPL istreamIOCtx : public gdIOCtx { public: typedef std::istream stream_type; istreamIOCtx(stream_type & __stream) { init( & __stream); } static int Getbuf (struct gdIOCtx * ctx, void * buf, int size); static int Putbuf (struct gdIOCtx * , const void * , int ); static void Putchar (struct gdIOCtx * , int ); static int Getchar (struct gdIOCtx * ctx); static int Seek (struct gdIOCtx * ctx, const int pos); static long Tell (struct gdIOCtx * ctx); static void FreeCtx (struct gdIOCtx * ctx); void init(stream_type * __stream) { getC = Getchar; putC = Putchar; getBuf = Getbuf; putBuf = Putbuf; tell = Tell; seek = Seek; gd_free = FreeCtx; _M_stream = __stream; } private: stream_type * _M_stream; }; inline gdIOCtx * gdNewIstreamCtx (std::istream * __stream) { return new istreamIOCtx(* __stream); } class BGD_EXPORT_DATA_IMPL ostreamIOCtx : public gdIOCtx { public: typedef std::ostream stream_type; ostreamIOCtx(stream_type & __stream) { init( & __stream); } static int Getbuf (struct gdIOCtx * , void * , int ); static int Putbuf (struct gdIOCtx * ctx, const void * buf, int size); static int Getchar (struct gdIOCtx * ); static void Putchar (struct gdIOCtx * ctx, int a); static int Seek (struct gdIOCtx * ctx, const int pos); static long Tell (struct gdIOCtx * ctx); static void FreeCtx (struct gdIOCtx * ctx); void init(stream_type * __stream) { getC = Getchar; putC = Putchar; getBuf = Getbuf; putBuf = Putbuf; tell = Tell; seek = Seek; gd_free = FreeCtx; _M_stream = __stream; } private: stream_type * _M_stream; }; inline gdIOCtx * gdNewOstreamCtx (std::ostream * __stream) { return new ostreamIOCtx(* __stream); } #endif // __cplusplus #endif // streamIOCtx