1
//========================================================================
5
// Copyright 1996-2003 Glyph & Cog, LLC
7
//========================================================================
9
//========================================================================
11
// Modified under the Poppler project - http://poppler.freedesktop.org
13
// All changes made under the Poppler project to this file are licensed
14
// under GPL version 2 or later
16
// Copyright (C) 2006, 2007 Albert Astals Cid <aacid@kde.org>
17
// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
19
// To see a description of the changes please see the Changelog file that
20
// came with your tarball or type make ChangeLog if you are building from git
22
//========================================================================
27
#ifdef USE_GCC_PRAGMAS
36
#define tokBufSize 128 // size of token buffer
38
//------------------------------------------------------------------------
40
//------------------------------------------------------------------------
45
// Construct a lexer for a single stream. Deletes the stream when
47
Lexer(XRef *xrefA, Stream *str);
49
// Construct a lexer for a stream or array of streams (assumes obj
50
// is either a stream or array of streams).
51
Lexer(XRef *xrefA, Object *obj);
56
// Get the next object from the input stream.
57
Object *getObj(Object *obj, int objNum = -1);
59
// Skip to the beginning of the next line in the input stream.
60
void skipToNextLine();
62
// Skip over one character.
63
void skipChar() { getChar(); }
67
{ return curStr.isNone() ? (Stream *)NULL : curStr.getStream(); }
69
// Get current position in file. This is only used for error
70
// messages, so it returns an int instead of a Guint.
72
{ return curStr.isNone() ? -1 : (int)curStr.streamGetPos(); }
74
// Set position in file.
75
void setPos(Guint pos, int dir = 0)
76
{ if (!curStr.isNone()) curStr.streamSetPos(pos, dir); }
78
// Returns true if <c> is a whitespace character.
79
static GBool isSpace(int c);
82
// often (e.g. ~30% on PDF Refernce 1.6 pdf file from Adobe site) getChar
83
// is called right after lookChar. In order to avoid expensive re-doing
84
// getChar() of underlying stream, we cache the last value found by
85
// lookChar() in lookCharLastValueCached. A special value
86
// LOOK_VALUE_NOT_CACHED that should never be part of stream indicates
87
// that no value was cached
88
static const int LOOK_VALUE_NOT_CACHED = -3;
89
int lookCharLastValueCached;
93
int getChar(GBool comesFromLook = gFalse);
96
Array *streams; // array of input streams
97
int strPtr; // index of current stream
98
Object curStr; // current stream
99
GBool freeArray; // should lexer free the streams array?
100
char tokBuf[tokBufSize]; // temporary token buffer