Pajdeg  0.2.2
Pajdeg
Files | Macros | Typedefs | Functions
PDDictionary

A hash map construct. More...

Files

file  PDDictionary.h
 

Macros

#define PDDictionaryGetString(d, k)   PDDictionaryGetTyped(d,k,PDInstanceTypeString)
 
#define PDDictionaryGetArray(d, k)   PDDictionaryGetTyped(d,k,PDInstanceTypeArray)
 
#define PDDictionaryGetDictionary(d, k)   PDDictionaryGetTyped(d,k,PDInstanceTypeDict)
 
#define PDDictionaryGetReference(d, k)   PDDictionaryGetTyped(d,k,PDInstanceTypeRef)
 
#define PDDictionaryGetObject(d, k)   PDDictionaryGetTyped(d,k,PDInstanceTypeObj)
 
#define PDDictionaryGetInteger(d, k)   PDNumberGetInteger(PDDictionaryGet(d,k))
 

Typedefs

typedef struct PDDictionaryPDDictionaryRef
 

Functions

PDDictionaryRef PDDictionaryCreate ()
 
PDDictionaryRef PDDictionaryCreateWithBucketCount (PDSize bucketCount)
 
PDDictionaryRef PDDictionaryCreateWithComplex (pd_stack stack)
 
PDDictionaryRef PDDictionaryCreateWithKeyValueDefinition (const void **defs)
 
void PDDictionaryAddEntriesFromComplex (PDDictionaryRef hm, pd_stack stack)
 
void PDDictionarySet (PDDictionaryRef hm, const char *key, void *value)
 
void * PDDictionaryGet (PDDictionaryRef hm, const char *key)
 
void PDDictionaryDelete (PDDictionaryRef hm, const char *key)
 
PDSize PDDictionaryGetCount (PDDictionaryRef hm)
 
void PDDictionaryIterate (PDDictionaryRef hm, PDHashIterator it, void *ui)
 
void PDDictionaryPopulateKeys (PDDictionaryRef hm, char **keys)
 
void PDDictionaryClear (PDDictionaryRef hm)
 
void PDDictionaryPrint (PDDictionaryRef hm)
 
char * PDDictionaryToString (PDDictionaryRef hm)
 
PDInteger PDDictionaryPrinter (void *inst, char **buf, PDInteger offs, PDInteger *cap)
 
void * PDDictionaryGetTyped (PDDictionaryRef dictionary, const char *key, PDInstanceType type)
 
void PDDictionaryAttachCrypto (PDDictionaryRef hm, pd_crypto crypto, PDInteger objectID, PDInteger genNumber)
 

Detailed Description

A hash map construct.

PDDictionary is a simple hash map implementation, with C string keys and PDType values.

Macro Definition Documentation

#define PDDictionaryGetInteger (   d,
 
)    PDNumberGetInteger(PDDictionaryGet(d,k))

Short cut to getting an integer value from a PDDictionary

Typedef Documentation

typedef struct PDDictionary* PDDictionaryRef

A hash map implementation.

The hash map construct.

Function Documentation

void PDDictionaryAddEntriesFromComplex ( PDDictionaryRef  hm,
pd_stack  stack 
)

Add all entries from the given PDF dictionary stack to this hash map. Entries will replace pre-existing key/value pairs when a key in the pd_stack matches the key in the hash map.

Parameters
hmHash map to add entries to
stackPDF dictionary stack
void PDDictionaryAttachCrypto ( PDDictionaryRef  hm,
pd_crypto  crypto,
PDInteger  objectID,
PDInteger  genNumber 
)

Supply a crypto object to a hash map, and associate the hash map with a specific object.

Parameters
hmThe hash map
cryptoThe pd_crypt object
objectIDThe object ID of the owning object
genNumberGeneration number of the owning object
void PDDictionaryClear ( PDDictionaryRef  hm)

Remove all entries in the dictionary.

Parameters
hmDictionary to clear
PDDictionaryRef PDDictionaryCreate ( )

Create a hash map with C string keys using default number of buckets.

Returns
New hash map
PDDictionaryRef PDDictionaryCreateWithBucketCount ( PDSize  bucketCount)

Create a hash map with the given number of buckets. The hash map uses C string keys.

Parameters
bucketCountNumber of buckets to use in the hash map
Returns
New hash map
PDDictionaryRef PDDictionaryCreateWithComplex ( pd_stack  stack)

Create a hash map with a complex object (a PDF dictionary stack).

Parameters
stackPDF dictionary stack
Returns
PDDictionary containing the PDF dictionary content
PDDictionaryRef PDDictionaryCreateWithKeyValueDefinition ( const void **  defs)

Create a dictionary using the key, value, key2, value2, ... PDDefs() definitions in defs.

Parameters
defsA PDDefs() entry with key, value, key, value pairs
Returns
PDDictionary with the corresponding entries.
void PDDictionaryDelete ( PDDictionaryRef  hm,
const char *  key 
)

Delete the given key from the hash map

Parameters
hmThe hash map
keyThe key to delete
void* PDDictionaryGet ( PDDictionaryRef  hm,
const char *  key 
)

Get the value of the given key.

Parameters
hmThe hash map
keyThe key
PDSize PDDictionaryGetCount ( PDDictionaryRef  hm)

Get the number of items in the hash map currently.

Parameters
hmThe hash amp
Returns
The number of inserted key/value pairs
void PDDictionaryIterate ( PDDictionaryRef  hm,
PDHashIterator  it,
void *  ui 
)

Iterate over the hash map entries using the given iterator.

Parameters
hmThe hash map whose key/value pairs should be iterated
itThe iterating function
uiUser information to pass to iterator, if any
void PDDictionaryPopulateKeys ( PDDictionaryRef  hm,
char **  keys 
)

Fill in the keys array with the keys in the dictionary.

Note
keys must have at minimum PDDictionaryGetCount(hm) number of available slots.
Parameters
hmHash map
keysPre-allocated array to populate
void PDDictionaryPrint ( PDDictionaryRef  hm)

Print the hash map content to stdout.

Parameters
hmThe hash map
void PDDictionarySet ( PDDictionaryRef  hm,
const char *  key,
void *  value 
)

Set key to value. If value is NULL, an assertion is thrown. To delete keys, use PDDictionaryDelete().

Parameters
hmThe hash map
keyThe key
valueThe value
char* PDDictionaryToString ( PDDictionaryRef  hm)

Generate a C string formatted according to the PDF specification for this hash map.

Note
The returned string must be freed.
Parameters
hmThe hash map
Returns
C string representation of hash map, as a PDF dictionary