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