1 //========================================================================
5 // Copyright 1996 Derek B. Noonburg
7 //========================================================================
10 #pragma implementation
20 //------------------------------------------------------------------------
22 //------------------------------------------------------------------------
33 for (i = 0; i < length; ++i) {
34 gfree(entries[i].key);
35 entries[i].val.free();
40 void Dict::add(char *key, Object *val) {
41 if (length + 1 > size) {
43 entries = (DictEntry *)grealloc(entries, size * sizeof(DictEntry));
45 entries[length].key = key;
46 entries[length].val = *val;
50 inline DictEntry *Dict::find(char *key) {
53 for (i = 0; i < length; ++i) {
54 if (!strcmp(key, entries[i].key))
60 GBool Dict::is(char *type) {
63 return (e = find("Type")) && e->val.isName(type);
66 Object *Dict::lookup(char *key, Object *obj) {
69 return (e = find(key)) ? e->val.fetch(obj) : obj->initNull();
72 Object *Dict::lookupNF(char *key, Object *obj) {
75 return (e = find(key)) ? e->val.copy(obj) : obj->initNull();
78 char *Dict::getKey(int i) {
79 return entries[i].key;
82 Object *Dict::getVal(int i, Object *obj) {
83 return entries[i].val.fetch(obj);
86 Object *Dict::getValNF(int i, Object *obj) {
87 return entries[i].val.copy(obj);