Back to index

tetex-bin  3.0
Dict.h
Go to the documentation of this file.
00001 //========================================================================
00002 //
00003 // Dict.h
00004 //
00005 // Copyright 1996-2003 Glyph & Cog, LLC
00006 //
00007 //========================================================================
00008 
00009 #ifndef DICT_H
00010 #define DICT_H
00011 
00012 #include <aconf.h>
00013 
00014 #ifdef USE_GCC_PRAGMAS
00015 #pragma interface
00016 #endif
00017 
00018 #include "Object.h"
00019 
00020 //------------------------------------------------------------------------
00021 // Dict
00022 //------------------------------------------------------------------------
00023 
00024 struct DictEntry {
00025   char *key;
00026   Object val;
00027 };
00028 
00029 class Dict {
00030 public:
00031 
00032   // Constructor.
00033   Dict(XRef *xrefA);
00034 
00035   // Destructor.
00036   ~Dict();
00037 
00038   // Reference counting.
00039   int incRef() { return ++ref; }
00040   int decRef() { return --ref; }
00041 
00042   // Get number of entries.
00043   int getLength() { return length; }
00044 
00045   // Add an entry.  NB: does not copy key.
00046   void add(char *key, Object *val);
00047 
00048   // Check if dictionary is of specified type.
00049   GBool is(char *type);
00050 
00051   // Look up an entry and return the value.  Returns a null object
00052   // if <key> is not in the dictionary.
00053   Object *lookup(char *key, Object *obj);
00054   Object *lookupNF(char *key, Object *obj);
00055 
00056   // Iterative accessors.
00057   char *getKey(int i);
00058   Object *getVal(int i, Object *obj);
00059   Object *getValNF(int i, Object *obj);
00060 
00061   // Set the xref pointer.  This is only used in one special case: the
00062   // trailer dictionary, which is read before the xref table is
00063   // parsed.
00064   void setXRef(XRef *xrefA) { xref = xrefA; }
00065 
00066 private:
00067 
00068   XRef *xref;               // the xref table for this PDF file
00069   DictEntry *entries;              // array of entries
00070   int size;                 // size of <entries> array
00071   int length;               // number of entries in dictionary
00072   int ref;                  // reference count
00073 
00074   DictEntry *find(char *key);
00075 };
00076 
00077 #endif