source: trunk/poppler/mypoppler/poppler/Lexer.h @ 461

Last change on this file since 461 was 461, checked in by Silvan Scherrer, 11 years ago

poppler update to 0.14.2

File size: 3.0 KB
RevLine 
[2]1//========================================================================
2//
3// Lexer.h
4//
5// Copyright 1996-2003 Glyph & Cog, LLC
6//
7//========================================================================
8
[257]9//========================================================================
10//
11// Modified under the Poppler project - http://poppler.freedesktop.org
12//
13// All changes made under the Poppler project to this file are licensed
14// under GPL version 2 or later
15//
[461]16// Copyright (C) 2006, 2007, 2010 Albert Astals Cid <aacid@kde.org>
[257]17// Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
18//
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
21//
22//========================================================================
23
[2]24#ifndef LEXER_H
25#define LEXER_H
26
27#ifdef USE_GCC_PRAGMAS
28#pragma interface
29#endif
30
31#include "Object.h"
32#include "Stream.h"
33
34class XRef;
35
36#define tokBufSize 128          // size of token buffer
37
38//------------------------------------------------------------------------
39// Lexer
40//------------------------------------------------------------------------
41
42class Lexer {
43public:
44
45  // Construct a lexer for a single stream.  Deletes the stream when
46  // lexer is deleted.
47  Lexer(XRef *xrefA, Stream *str);
48
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);
52
53  // Destructor.
54  ~Lexer();
55
56  // Get the next object from the input stream.
57  Object *getObj(Object *obj, int objNum = -1);
58
59  // Skip to the beginning of the next line in the input stream.
60  void skipToNextLine();
61
62  // Skip over one character.
63  void skipChar() { getChar(); }
64
65  // Get stream.
66  Stream *getStream()
[461]67    { return curStr.isStream() ? curStr.getStream() : (Stream *)NULL; }
[2]68
69  // Get current position in file.  This is only used for error
70  // messages, so it returns an int instead of a Guint.
71  int getPos()
[461]72    { return curStr.isStream() ? (int)curStr.streamGetPos() : -1; }
[2]73
74  // Set position in file.
75  void setPos(Guint pos, int dir = 0)
[461]76    { if (curStr.isStream()) curStr.streamSetPos(pos, dir); }
[2]77
78  // Returns true if <c> is a whitespace character.
79  static GBool isSpace(int c);
80
[250]81
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;
90
[2]91private:
92
[250]93  int getChar(GBool comesFromLook = gFalse);
[2]94  int lookChar();
95
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
101
102  XRef *xref;
103};
104
105#endif
Note: See TracBrowser for help on using the repository browser.