]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/GnomeVFSStream.h
new class, just what the name says, uses GnomeVFSStream for loading
[evince.git] / pdf / xpdf / GnomeVFSStream.h
1 //========================================================================
2 //
3 // GnomeVFSStream.cc
4 //
5 // Copyright 1996-2002 Glyph & Cog, LLC
6 // Copyright 2003 Martin Kretzschmar
7 //
8 //========================================================================
9
10 #ifndef GNOME_VFS_STREAM_H
11 #define GNOME_VFS_STREAM_H
12
13 #include "gpdf-g-switch.h"
14 #  include <libgnomevfs/gnome-vfs-handle.h>
15 #include "gpdf-g-switch.h"
16 #include "Object.h"
17 #include "Stream.h"
18
19 #define gnomeVFSStreamBufSize fileStreamBufSize
20
21 class GnomeVFSStream: public BaseStream {
22 public:
23
24   GnomeVFSStream(GnomeVFSHandle *handleA, Guint startA, GBool limitedA,
25                  Guint lengthA, Object *dictA);
26   virtual ~GnomeVFSStream();
27   virtual Stream *makeSubStream(Guint startA, GBool limitedA,
28                                 Guint lengthA, Object *dictA);
29   virtual StreamKind getKind() { return strFile; }
30   virtual void reset();
31   virtual void close();
32   virtual int getChar()
33     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
34   virtual int lookChar()
35     { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
36   virtual int getPos() { return bufPos + (bufPtr - buf); }
37   virtual void setPos(Guint pos, int dir = 0);
38   virtual GBool isBinary(GBool last = gTrue) { return last; }
39   virtual Guint getStart() { return start; }
40   virtual void moveStart(int delta);
41
42 private:
43
44   GBool fillBuf();
45
46   GnomeVFSHandle *handle;
47   Guint start;
48   GBool limited;
49   Guint length;
50   char buf[gnomeVFSStreamBufSize];
51   char *bufPtr;
52   char *bufEnd;
53   Guint bufPos;
54   int savePos;
55   GBool saved;
56 };
57
58 #endif /* GNOME_VFS_STREAM_H */