Coconut Framework  beta
CNDictionary.h
Go to the documentation of this file.
1 
8 #ifndef CNDICTIONARY_H
9 #define CNDICTIONARY_H
10 
11 #include "CNForwarders.h"
12 #include "CNFixedString.h"
13 #include "CNArray.h"
14 
16 #define CNHashTableSizeOfDictionary 64
17 
19 typedef void (*CNReleaseDictionaryItemFuncRef)(void * item, struct CNResource * resource) ;
21 typedef CNBoolean (*CNVisitElementOfDictionaryFuncRef)(const struct CNFixedString * key, void * src, void * info) ;
22 
23 struct CNDictionaryItem ;
24 
29 {
31  struct CNResource * resource ;
33  size_t itemCount ;
35  struct CNDictionaryItem * dictionaryItems[CNHashTableSizeOfDictionary] ;
38 } ;
39 
46 void
47 CNInitDictionary(struct CNDictionary * dst, CNReleaseDictionaryItemFuncRef func, struct CNResource * resource) ;
48 
53 void
54 CNDestroyDictionary(struct CNDictionary * dst) ;
55 
61 static inline size_t
62 CNCountOfDictionary(const struct CNDictionary * src)
63 {
64  return src->itemCount ;
65 }
66 
72 static inline struct CNResource *
74 {
75  return src->resource ;
76 }
77 
85 void *
86 CNSearchDataInDictionary(const struct CNDictionary * dict,const struct CNFixedString * key) ;
87 
94 void
95 CNSetDataToDictionary(struct CNDictionary * dict, const struct CNFixedString * key, void * value) ;
96 
105 CNBoolean
106 CNVisitElementOfDictionary(const struct CNDictionary * src, CNVisitElementOfDictionaryFuncRef visitfunc, void * info) ;
107 
108 #endif /* CNDICTIONARY_H */
109 
void(* CNReleaseDictionaryItemFuncRef)(void *item, struct CNResource *resource)
Definition: CNDictionary.h:19
size_t itemCount
Number of items.
Definition: CNDictionary.h:33
struct CNDictionaryItem * dictionaryItems[CNHashTableSizeOfDictionary]
Array of data.
Definition: CNDictionary.h:35
Forward declaration of data types.
void * CNSearchDataInDictionary(const struct CNDictionary *dict, const struct CNFixedString *key)
Search data in data dictionary.
Define CNArray data structure.
Persistent string. There are only one object for each context of string.
Definition: CNFixedString.h:21
CNReleaseDictionaryItemFuncRef releaseFunc
Function to release the item of dictionary.
Definition: CNDictionary.h:37
Define CNFixedString class.
void CNInitDictionary(struct CNDictionary *dst, CNReleaseDictionaryItemFuncRef func, struct CNResource *resource)
Initialize CNDictionary.
Dictionary of pointer.
Definition: CNDictionary.h:28
static struct CNResource * CNResourceOfDictionary(struct CNDictionary *src)
Get resource fot the dictionary.
Definition: CNDictionary.h:73
static size_t CNCountOfDictionary(const struct CNDictionary *src)
Number of items in dictionary.
Definition: CNDictionary.h:62
CNBoolean CNVisitElementOfDictionary(const struct CNDictionary *src, CNVisitElementOfDictionaryFuncRef visitfunc, void *info)
Visit all elements in the dictionary.
void CNDestroyDictionary(struct CNDictionary *dst)
Deallocate CNDictionary.
CNBoolean(* CNVisitElementOfDictionaryFuncRef)(const struct CNFixedString *key, void *src, void *info)
Definition: CNDictionary.h:21
#define CNHashTableSizeOfDictionary
Definition: CNDictionary.h:16
void CNSetDataToDictionary(struct CNDictionary *dict, const struct CNFixedString *key, void *value)
Set data for key to CNDictionary.
unsigned int CNBoolean
Boolean type.
Definition: CNType.h:14
struct CNResource * resource
Definition: CNDictionary.h:31