beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / Dict.h
blobfba99edc513849cbe6a4d315bbf5bb946a09ed05
1 //========================================================================
2 //
3 // Dict.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
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) 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>
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
26 //========================================================================
28 #ifndef DICT_H
29 #define DICT_H
31 #ifdef USE_GCC_PRAGMAS
32 #pragma interface
33 #endif
35 #include "poppler-config.h"
36 #include "Object.h"
37 #include "goo/GooMutex.h"
39 //------------------------------------------------------------------------
40 // Dict
41 //------------------------------------------------------------------------
43 struct DictEntry {
44 char *key;
45 Object val;
48 class Dict {
49 public:
51 // Constructor.
52 Dict(XRef *xrefA);
53 Dict(Dict* dictA);
54 Dict *copy(XRef *xrefA);
56 // Destructor.
57 ~Dict();
59 // Reference counting.
60 int incRef();
61 int decRef();
63 // Get number of entries.
64 int getLength() { return length; }
66 // Add an entry. NB: does not copy key.
67 void add(char *key, Object *val);
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);
74 // Check if dictionary is of specified type.
75 GBool is(const char *type);
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);
83 // Iterative accessors.
84 char *getKey(int i);
85 Object *getVal(int i, Object *obj);
86 Object *getValNF(int i, Object *obj);
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; }
93 XRef *getXRef() { return xref; }
95 GBool hasKey(const char *key);
97 private:
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
109 DictEntry *find(const char *key);
112 #endif