1 //========================================================================
5 // Copyright 1996-2002 Glyph & Cog, LLC
7 //========================================================================
10 #pragma implementation
21 //------------------------------------------------------------------------
23 //------------------------------------------------------------------------
25 Dict::Dict(XRef *xrefA) {
35 for (i = 0; i < length; ++i) {
36 gfree(entries[i].key);
37 entries[i].val.free();
42 void Dict::add(char *key, Object *val) {
43 if (length + 1 > size) {
45 entries = (DictEntry *)grealloc(entries, size * sizeof(DictEntry));
47 entries[length].key = key;
48 entries[length].val = *val;
52 inline DictEntry *Dict::find(char *key) {
55 for (i = 0; i < length; ++i) {
56 if (!strcmp(key, entries[i].key))
62 GBool Dict::is(char *type) {
65 return (e = find("Type")) && e->val.isName(type);
68 Object *Dict::lookup(char *key, Object *obj) {
71 return (e = find(key)) ? e->val.fetch(xref, obj) : obj->initNull();
74 Object *Dict::lookupNF(char *key, Object *obj) {
77 return (e = find(key)) ? e->val.copy(obj) : obj->initNull();
80 char *Dict::getKey(int i) {
81 return entries[i].key;
84 Object *Dict::getVal(int i, Object *obj) {
85 return entries[i].val.fetch(xref, obj);
88 Object *Dict::getValNF(int i, Object *obj) {
89 return entries[i].val.copy(obj);