upgrade to xpdf 3.00.
[swftools.git] / pdf2swf / xpdf / Lexer.h
blob398d27c355a33df5286cdd64f764754211083664
1 //========================================================================
2 //
3 // Lexer.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
9 #ifndef LEXER_H
10 #define LEXER_H
12 #include <aconf.h>
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
18 #include "Object.h"
19 #include "Stream.h"
21 class XRef;
23 #define tokBufSize 128 // size of token buffer
25 //------------------------------------------------------------------------
26 // Lexer
27 //------------------------------------------------------------------------
29 class Lexer {
30 public:
32 // Construct a lexer for a single stream. Deletes the stream when
33 // lexer is deleted.
34 Lexer(XRef *xref, Stream *str);
36 // Construct a lexer for a stream or array of streams (assumes obj
37 // is either a stream or array of streams).
38 Lexer(XRef *xref, Object *obj);
40 // Destructor.
41 ~Lexer();
43 // Get the next object from the input stream.
44 Object *getObj(Object *obj);
46 // Skip to the beginning of the next line in the input stream.
47 void skipToNextLine();
49 // Skip over one character.
50 void skipChar() { getChar(); }
52 // Get stream.
53 Stream *getStream()
54 { return curStr.isNone() ? (Stream *)NULL : curStr.getStream(); }
56 // Get current position in file. This is only used for error
57 // messages, so it returns an int instead of a Guint.
58 int getPos()
59 { return curStr.isNone() ? -1 : (int)curStr.streamGetPos(); }
61 // Set position in file.
62 void setPos(Guint pos, int dir = 0)
63 { if (!curStr.isNone()) curStr.streamSetPos(pos, dir); }
65 private:
67 int getChar();
68 int lookChar();
70 Array *streams; // array of input streams
71 int strPtr; // index of current stream
72 Object curStr; // current stream
73 GBool freeArray; // should lexer free the streams array?
74 char tokBuf[tokBufSize]; // temporary token buffer
77 #endif