1 //========================================================================
5 // Copyright 1996-2003 Glyph & Cog, LLC
7 //========================================================================
11 #ifdef USE_GCC_PRAGMAS
12 #pragma implementation
22 //------------------------------------------------------------------------
24 //------------------------------------------------------------------------
26 Dict::Dict(XRef *xrefA) {
36 for (i = 0; i < length; ++i) {
37 gfree(entries[i].key);
38 entries[i].val.free();
43 void Dict::add(char *key, Object *val) {
50 entries = (DictEntry *)greallocn(entries, size, sizeof(DictEntry));
52 entries[length].key = key;
53 entries[length].val = *val;
57 inline DictEntry *Dict::find(char *key) {
60 for (i = 0; i < length; ++i) {
61 if (!strcmp(key, entries[i].key))
67 GBool Dict::is(char *type) {
70 return (e = find("Type")) && e->val.isName(type);
73 Object *Dict::lookup(char *key, Object *obj) {
76 return (e = find(key)) ? e->val.fetch(xref, obj) : obj->initNull();
79 Object *Dict::lookupNF(char *key, Object *obj) {
82 return (e = find(key)) ? e->val.copy(obj) : obj->initNull();
85 char *Dict::getKey(int i) {
86 return entries[i].key;
89 Object *Dict::getVal(int i, Object *obj) {
90 return entries[i].val.fetch(xref, obj);
93 Object *Dict::getValNF(int i, Object *obj) {
94 return entries[i].val.copy(obj);