Robot Agent  1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
dictionary.h
Go to the documentation of this file.
1 
2 /*-------------------------------------------------------------------------*/
12 /*--------------------------------------------------------------------------*/
13 
14 #ifndef _DICTIONARY_H_
15 #define _DICTIONARY_H_
16 
17 /*---------------------------------------------------------------------------
18  Includes
19  ---------------------------------------------------------------------------*/
20 
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <unistd.h>
25 
26 /*---------------------------------------------------------------------------
27  New types
28  ---------------------------------------------------------------------------*/
29 
30 
31 /*-------------------------------------------------------------------------*/
40 /*-------------------------------------------------------------------------*/
41 typedef struct _dictionary_ {
42  int n ;
43  int size ;
44  char ** val ;
45  char ** key ;
46  unsigned * hash ;
47 } dictionary ;
48 
49 
50 /*---------------------------------------------------------------------------
51  Function prototypes
52  ---------------------------------------------------------------------------*/
53 
54 /*-------------------------------------------------------------------------*/
65 /*--------------------------------------------------------------------------*/
66 unsigned dictionary_hash(const char * key);
67 
68 /*-------------------------------------------------------------------------*/
78 /*--------------------------------------------------------------------------*/
79 dictionary * dictionary_new(int size);
80 
81 /*-------------------------------------------------------------------------*/
89 /*--------------------------------------------------------------------------*/
90 void dictionary_del(dictionary * vd);
91 
92 /*-------------------------------------------------------------------------*/
105 /*--------------------------------------------------------------------------*/
106 char * dictionary_get(dictionary * d, const char * key, char * def);
107 
108 
109 /*-------------------------------------------------------------------------*/
134 /*--------------------------------------------------------------------------*/
135 int dictionary_set(dictionary * vd, const char * key, const char * val);
136 
137 /*-------------------------------------------------------------------------*/
147 /*--------------------------------------------------------------------------*/
148 void dictionary_unset(dictionary * d, const char * key);
149 
150 
151 /*-------------------------------------------------------------------------*/
162 /*--------------------------------------------------------------------------*/
163 void dictionary_dump(dictionary * d, FILE * out);
164 
165 #endif
char ** val
Definition: dictionary.h:44
char * dictionary_get(dictionary *d, const char *key, char *def)
Get a value from a dictionary.
Definition: dictionary.c:175
void dictionary_unset(dictionary *d, const char *key)
Delete a key in a dictionary.
Definition: dictionary.c:288
unsigned dictionary_hash(const char *key)
Compute the hash key for a string.
Definition: dictionary.c:88
void dictionary_dump(dictionary *d, FILE *out)
Dump a dictionary to an opened file pointer.
Definition: dictionary.c:337
unsigned * hash
Definition: dictionary.h:46
char ** key
Definition: dictionary.h:45
dictionary * dictionary_new(int size)
Create a new dictionary object.
Definition: dictionary.c:117
void dictionary_del(dictionary *d)
Delete a dictionary object.
Definition: dictionary.c:143
int dictionary_set(dictionary *d, const char *key, const char *val)
Set a value in a dictionary.
Definition: dictionary.c:221
Dictionary object.
Definition: dictionary.h:41
struct _dictionary_ dictionary
Dictionary object.