/[H9]/trunk/tntnet/dynamic/gd-cpp/gd_io_stream.h
ViewVC logotype

Contents of /trunk/tntnet/dynamic/gd-cpp/gd_io_stream.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 68 - (show annotations) (download)
Tue Nov 27 14:28:59 2007 UTC (16 years, 5 months ago) by torben
File MIME type: text/plain
File size: 1870 byte(s)
Basic structure for web-interface

1 #ifndef streamIOCtx
2 #define streamIOCtx
3
4 #include "gd.h"
5
6 #ifdef __cplusplus
7
8 #include <iostream>
9
10 class BGD_EXPORT_DATA_IMPL istreamIOCtx : public gdIOCtx
11 {
12 public:
13 typedef std::istream stream_type;
14 istreamIOCtx(stream_type & __stream) { init( & __stream); }
15
16 static int Getbuf (struct gdIOCtx * ctx, void * buf, int size);
17 static int Putbuf (struct gdIOCtx * , const void * , int );
18 static void Putchar (struct gdIOCtx * , int );
19 static int Getchar (struct gdIOCtx * ctx);
20 static int Seek (struct gdIOCtx * ctx, const int pos);
21 static long Tell (struct gdIOCtx * ctx);
22 static void FreeCtx (struct gdIOCtx * ctx);
23
24 void init(stream_type * __stream)
25 {
26 getC = Getchar;
27 putC = Putchar;
28 getBuf = Getbuf;
29 putBuf = Putbuf;
30 tell = Tell;
31 seek = Seek;
32 gd_free = FreeCtx;
33 _M_stream = __stream;
34 }
35 private:
36 stream_type * _M_stream;
37 };
38 inline gdIOCtx * gdNewIstreamCtx (std::istream * __stream)
39 {
40 return new istreamIOCtx(* __stream);
41 }
42
43 class BGD_EXPORT_DATA_IMPL ostreamIOCtx : public gdIOCtx
44 {
45 public:
46 typedef std::ostream stream_type;
47 ostreamIOCtx(stream_type & __stream) { init( & __stream); }
48
49 static int Getbuf (struct gdIOCtx * , void * , int );
50 static int Putbuf (struct gdIOCtx * ctx, const void * buf, int size);
51 static int Getchar (struct gdIOCtx * );
52 static void Putchar (struct gdIOCtx * ctx, int a);
53 static int Seek (struct gdIOCtx * ctx, const int pos);
54 static long Tell (struct gdIOCtx * ctx);
55 static void FreeCtx (struct gdIOCtx * ctx);
56
57 void init(stream_type * __stream)
58 {
59 getC = Getchar;
60 putC = Putchar;
61 getBuf = Getbuf;
62 putBuf = Putbuf;
63 tell = Tell;
64 seek = Seek;
65 gd_free = FreeCtx;
66 _M_stream = __stream;
67 }
68 private:
69 stream_type * _M_stream;
70 };
71 inline gdIOCtx * gdNewOstreamCtx (std::ostream * __stream)
72 {
73 return new ostreamIOCtx(* __stream);
74 }
75
76 #endif // __cplusplus
77
78 #endif // streamIOCtx

  ViewVC Help
Powered by ViewVC 1.1.20