blob: 514c3ae8d6ea5e6357ff6a99496f2c1d2b7bd7eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
//========================================================================
//
// Dict.h
//
// Copyright 1996-2003 Glyph & Cog, LLC
//
//========================================================================
#ifndef DICT_H
#define DICT_H
#include <aconf.h>
#ifdef USE_GCC_PRAGMAS
#pragma interface
#endif
#if MULTITHREADED
#include "GMutex.h"
#endif
#include "Object.h"
struct DictEntry;
//------------------------------------------------------------------------
// Dict
//------------------------------------------------------------------------
class Dict {
public:
// Constructor.
Dict(XRef *xrefA);
// Destructor.
~Dict();
// Reference counting.
#if MULTITHREADED
int incRef() { return gAtomicIncrement(&ref); }
int decRef() { return gAtomicDecrement(&ref); }
#else
int incRef() { return ++ref; }
int decRef() { return --ref; }
#endif
// Get number of entries.
int getLength() { return length; }
// Add an entry. NB: does not copy key.
void add(char *key, Object *val);
// Check if dictionary is of specified type.
GBool is(const char *type);
// Look up an entry and return the value. Returns a null object
// if <key> is not in the dictionary.
Object *lookup(const char *key, Object *obj, int recursion = 0);
Object *lookupNF(const char *key, Object *obj);
// Iterative accessors.
char *getKey(int i);
Object *getVal(int i, Object *obj);
Object *getValNF(int i, Object *obj);
// Set the xref pointer. This is only used in one special case: the
// trailer dictionary, which is read before the xref table is
// parsed.
void setXRef(XRef *xrefA) { xref = xrefA; }
private:
XRef *xref; // the xref table for this PDF file
DictEntry *entries; // array of entries
DictEntry **hashTab; // hash table pointers
int size; // size of <entries> array
int length; // number of entries in dictionary
#if MULTITHREADED
GAtomicCounter ref; // reference count
#else
int ref; // reference count
#endif
DictEntry *find(const char *key);
void expand();
int hash(const char *key);
};
#endif
|