Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Dict.h

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

Generated on Sat Nov 5 16:18:13 2005 for OPIE by  doxygen 1.4.2