1 : //========================================================================
2 : //
3 : // Dict.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) 2005 Kristian Høgsberg <krh@redhat.com>
17 : // Copyright (C) 2006 Krzysztof Kowalczyk <kkowalczyk@gmail.com>
18 : // Copyright (C) 2007-2008 Julien Rebetez <julienr@svn.gnome.org>
19 : // Copyright (C) 2010 Albert Astals Cid <aacid@kde.org>
20 : // Copyright (C) 2010 Paweł Wiejacha <pawel.wiejacha@gmail.com>
21 : // Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
22 : //
23 : // To see a description of the changes please see the Changelog file that
24 : // came with your tarball or type make ChangeLog if you are building from git
25 : //
26 : //========================================================================
27 :
28 : #ifndef DICT_H
29 : #define DICT_H
30 :
31 : #ifdef USE_GCC_PRAGMAS
32 : #pragma interface
33 : #endif
34 :
35 : #include "poppler-config.h"
36 : #include "Object.h"
37 : #include "goo/GooMutex.h"
38 :
39 : //------------------------------------------------------------------------
40 : // Dict
41 : //------------------------------------------------------------------------
42 :
43 : struct DictEntry {
44 : char *key;
45 : Object val;
46 : };
47 :
48 : class Dict {
49 : public:
50 :
51 : // Constructor.
52 : Dict(XRef *xrefA);
53 : Dict(Dict* dictA);
54 : Dict *copy(XRef *xrefA);
55 :
56 : // Destructor.
57 : ~Dict();
58 :
59 : // Reference counting.
60 : int incRef();
61 : int decRef();
62 :
63 : // Get number of entries.
64 55 : int getLength() { return length; }
65 :
66 : // Add an entry. NB: does not copy key.
67 : void add(char *key, Object *val);
68 :
69 : // Update the value of an existing entry, otherwise create it
70 : void set(const char *key, Object *val);
71 : // Remove an entry. This invalidate indexes
72 : void remove(const char *key);
73 :
74 : // Check if dictionary is of specified type.
75 : GBool is(const char *type);
76 :
77 : // Look up an entry and return the value. Returns a null object
78 : // if <key> is not in the dictionary.
79 : Object *lookup(const char *key, Object *obj, int recursion = 0);
80 : Object *lookupNF(const char *key, Object *obj);
81 : GBool lookupInt(const char *key, const char *alt_key, int *value);
82 :
83 : // Iterative accessors.
84 : char *getKey(int i);
85 : Object *getVal(int i, Object *obj);
86 : Object *getValNF(int i, Object *obj);
87 :
88 : // Set the xref pointer. This is only used in one special case: the
89 : // trailer dictionary, which is read before the xref table is
90 : // parsed.
91 : void setXRef(XRef *xrefA) { xref = xrefA; }
92 :
93 : XRef *getXRef() { return xref; }
94 :
95 : GBool hasKey(const char *key);
96 :
97 : private:
98 :
99 : GBool sorted;
100 : XRef *xref; // the xref table for this PDF file
101 : DictEntry *entries; // array of entries
102 : int size; // size of <entries> array
103 : int length; // number of entries in dictionary
104 : int ref; // reference count
105 : #if MULTITHREADED
106 : GooMutex mutex;
107 : #endif
108 :
109 : DictEntry *find(const char *key);
110 : };
111 :
112 : #endif
|