gd_io_stream.h (libgd-2.3.2) | : | gd_io_stream.h (libgd-2.3.3) | ||
---|---|---|---|---|
skipping to change at line 52 | skipping to change at line 52 | |||
/** Construct an instance of this input stream specialization, | /** Construct an instance of this input stream specialization, | |||
given an input stream. | given an input stream. | |||
For example: | For example: | |||
std::ifstream in("image.png", std::ios_base::in | std::ios_base:: binary ); | std::ifstream in("image.png", std::ios_base::in | std::ios_base:: binary ); | |||
istreamIOCtx in_ctx(in); | istreamIOCtx in_ctx(in); | |||
*/ | */ | |||
istreamIOCtx(stream_type & __stream) { | istreamIOCtx(stream_type & __stream) { | |||
init( & __stream); | init( & __stream); | |||
} | } | |||
static int Getbuf (struct gdIOCtx * ctx, void * buf, int size); | static int Getbuf(gdIOCtxPtr ctx, void *buf, int size); | |||
static int Putbuf (struct gdIOCtx * , const void * , int ); | static int Putbuf(gdIOCtxPtr, const void *, int); | |||
static void Putchar (struct gdIOCtx * , int ); | static void Putchar(gdIOCtxPtr, int); | |||
static int Getchar (struct gdIOCtx * ctx); | static int Getchar(gdIOCtxPtr ctx); | |||
static int Seek (struct gdIOCtx * ctx, const int pos); | static int Seek(gdIOCtxPtr ctx, const int pos); | |||
static long Tell (struct gdIOCtx * ctx); | static long Tell(gdIOCtxPtr ctx); | |||
static void FreeCtx (struct gdIOCtx * ctx); | static void FreeCtx(gdIOCtxPtr ctx); | |||
void init(stream_type * __stream) { | void init(stream_type * __stream) { | |||
getC = Getchar; | getC = Getchar; | |||
putC = Putchar; | putC = Putchar; | |||
getBuf = Getbuf; | getBuf = Getbuf; | |||
putBuf = Putbuf; | putBuf = Putbuf; | |||
tell = Tell; | tell = Tell; | |||
seek = Seek; | seek = Seek; | |||
gd_free = FreeCtx; | gd_free = FreeCtx; | |||
_M_stream = __stream; | _M_stream = __stream; | |||
} | } | |||
private: | private: | |||
stream_type * _M_stream; | stream_type * _M_stream; | |||
}; | }; | |||
/** Allocate a new instance of the class | /** Allocate a new instance of the class | |||
*/ | */ | |||
inline gdIOCtx * gdNewIstreamCtx (std::istream * __stream) | inline gdIOCtxPtr gdNewIstreamCtx(std::istream *__stream) | |||
{ | { | |||
return new istreamIOCtx(* __stream); | return new istreamIOCtx(* __stream); | |||
} | } | |||
/** Standard library output stream specialization of gdIOCtx | /** Standard library output stream specialization of gdIOCtx | |||
*/ | */ | |||
class BGD_EXPORT_DATA_IMPL ostreamIOCtx : public gdIOCtx | class BGD_EXPORT_DATA_IMPL ostreamIOCtx : public gdIOCtx | |||
{ | { | |||
public: | public: | |||
typedef std::ostream stream_type; | typedef std::ostream stream_type; | |||
/** Construct an instance of this output stream specialization, | /** Construct an instance of this output stream specialization, | |||
given an output stream. | given an output stream. | |||
For example: | For example: | |||
std::ofstream out("image.gif", std::ios_base::out | std::ios_base ::binary ); | std::ofstream out("image.gif", std::ios_base::out | std::ios_base ::binary ); | |||
ostreamIOCtx out_ctx(out); | ostreamIOCtx out_ctx(out); | |||
*/ | */ | |||
ostreamIOCtx(stream_type & __stream) { | ostreamIOCtx(stream_type & __stream) { | |||
init( & __stream); | init( & __stream); | |||
} | } | |||
static int Getbuf (struct gdIOCtx * , void * , int ); | static int Getbuf(gdIOCtxPtr, void *, int); | |||
static int Putbuf (struct gdIOCtx * ctx, const void * buf, int size) | static int Putbuf(gdIOCtxPtr ctx, const void *buf, int size); | |||
; | static int Getchar(gdIOCtxPtr); | |||
static int Getchar (struct gdIOCtx * ); | static void Putchar(gdIOCtxPtr ctx, int a); | |||
static void Putchar (struct gdIOCtx * ctx, int a); | static int Seek(gdIOCtxPtr ctx, const int pos); | |||
static int Seek (struct gdIOCtx * ctx, const int pos); | static long Tell(gdIOCtxPtr ctx); | |||
static long Tell (struct gdIOCtx * ctx); | static void FreeCtx(gdIOCtxPtr ctx); | |||
static void FreeCtx (struct gdIOCtx * ctx); | ||||
void init(stream_type * __stream) { | void init(stream_type * __stream) { | |||
getC = Getchar; | getC = Getchar; | |||
putC = Putchar; | putC = Putchar; | |||
getBuf = Getbuf; | getBuf = Getbuf; | |||
putBuf = Putbuf; | putBuf = Putbuf; | |||
tell = Tell; | tell = Tell; | |||
seek = Seek; | seek = Seek; | |||
gd_free = FreeCtx; | gd_free = FreeCtx; | |||
_M_stream = __stream; | _M_stream = __stream; | |||
} | } | |||
private: | private: | |||
stream_type * _M_stream; | stream_type * _M_stream; | |||
}; | }; | |||
/** Allocate a new instance of the class | /** Allocate a new instance of the class | |||
*/ | */ | |||
inline gdIOCtx * gdNewOstreamCtx (std::ostream * __stream) | inline gdIOCtxPtr gdNewOstreamCtx(std::ostream *__stream) | |||
{ | { | |||
return new ostreamIOCtx(* __stream); | return new ostreamIOCtx(* __stream); | |||
} | } | |||
#endif /* __cplusplus */ | #endif /* __cplusplus */ | |||
#endif /* _gd_io_stream_h */ | #endif /* _gd_io_stream_h */ | |||
End of changes. 4 change blocks. | ||||
17 lines changed or deleted | 16 lines changed or added |