fixed windows access violation which occurs if one tries to retrieve
[swftools.git] / pdf2swf / xpdf / Lexer.h
blob8a01ab25e9ae96e80863e6e15d24d15e5e530543
1 //========================================================================
2 //
3 // Lexer.h
4 //
5 // Copyright 1996-2002 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef LEXER_H
10 #define LEXER_H
12 #ifdef __GNUC__
13 #pragma interface
14 #endif
16 #include "Object.h"
17 #include "Stream.h"
19 class XRef;
21 #define tokBufSize 128 // size of token buffer
23 //------------------------------------------------------------------------
24 // Lexer
25 //------------------------------------------------------------------------
27 class Lexer {
28 public:
30 // Construct a lexer for a single stream. Deletes the stream when
31 // lexer is deleted.
32 Lexer(XRef *xref, Stream *str);
34 // Construct a lexer for a stream or array of streams (assumes obj
35 // is either a stream or array of streams).
36 Lexer(XRef *xref, Object *obj);
38 // Destructor.
39 ~Lexer();
41 // Get the next object from the input stream.
42 Object *getObj(Object *obj);
44 // Skip to the beginning of the next line in the input stream.
45 void skipToNextLine();
47 // Skip over one character.
48 void skipChar() { getChar(); }
50 // Get stream.
51 Stream *getStream()
52 { return curStr.isNone() ? (Stream *)NULL : curStr.getStream(); }
54 // Get current position in file. This is only used for error
55 // messages, so it returns an int instead of a Guint.
56 int getPos()
57 { return curStr.isNone() ? -1 : (int)curStr.streamGetPos(); }
59 // Set position in file.
60 void setPos(Guint pos, int dir = 0)
61 { if (!curStr.isNone()) curStr.streamSetPos(pos, dir); }
63 private:
65 int getChar();
66 int lookChar();
68 Array *streams; // array of input streams
69 int strPtr; // index of current stream
70 Object curStr; // current stream
71 GBool freeArray; // should lexer free the streams array?
72 char tokBuf[tokBufSize]; // temporary token buffer
75 #endif