1 | //======================================================================== |
2 | // |
3 | // Parser.h |
4 | // |
5 | // Copyright 1996-2003 Glyph & Cog, LLC |
6 | // |
7 | //======================================================================== |
8 | |
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 | // |
16 | // Copyright (C) 2006, 2010, 2013, 2017, 2018, 2020 Albert Astals Cid <aacid@kde.org> |
17 | // Copyright (C) 2012 Hib Eris <hib@hiberis.nl> |
18 | // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> |
19 | // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de> |
20 | // Copyright (C) 2019 Adam Reichold <adam.reichold@t-online.de> |
21 | // |
22 | // To see a description of the changes please see the Changelog file that |
23 | // came with your tarball or type make ChangeLog if you are building from git |
24 | // |
25 | //======================================================================== |
26 | |
27 | #ifndef PARSER_H |
28 | #define PARSER_H |
29 | |
30 | #include "Lexer.h" |
31 | |
32 | //------------------------------------------------------------------------ |
33 | // Parser |
34 | //------------------------------------------------------------------------ |
35 | |
36 | class POPPLER_PRIVATE_EXPORT Parser |
37 | { |
38 | public: |
39 | // Constructor. |
40 | Parser(XRef *xrefA, Stream *streamA, bool allowStreamsA); |
41 | Parser(XRef *xrefA, Object *objectA, bool allowStreamsA); |
42 | |
43 | // Destructor. |
44 | ~Parser(); |
45 | |
46 | Parser(const Parser &) = delete; |
47 | Parser &operator=(const Parser &) = delete; |
48 | |
49 | // Get the next object from the input stream. If <simpleOnly> is |
50 | // true, do not parse compound objects (arrays, dictionaries, or |
51 | // streams). |
52 | Object getObj(bool simpleOnly = false, const unsigned char *fileKey = nullptr, CryptAlgorithm encAlgorithm = cryptRC4, int keyLength = 0, int objNum = 0, int objGen = 0, int recursion = 0, bool strict = false, |
53 | bool decryptString = true); |
54 | |
55 | Object getObj(int recursion); |
56 | template<typename T> |
57 | Object getObj(T) = delete; |
58 | |
59 | // Get stream. |
60 | Stream *getStream() { return lexer.getStream(); } |
61 | |
62 | // Get current position in file. |
63 | Goffset getPos() { return lexer.getPos(); } |
64 | |
65 | private: |
66 | Lexer lexer; // input stream |
67 | bool allowStreams; // parse stream objects? |
68 | Object buf1, buf2; // next two tokens |
69 | int inlineImg; // set when inline image data is encountered |
70 | |
71 | Stream *makeStream(Object &&dict, const unsigned char *fileKey, CryptAlgorithm encAlgorithm, int keyLength, int objNum, int objGen, int recursion, bool strict); |
72 | void shift(int objNum = -1); |
73 | void shift(const char *cmdA, int objNum); |
74 | }; |
75 | |
76 | #endif |
77 | |