Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Rubberduckycooly
GitHub Repository: Rubberduckycooly/RSDKv5-Decompilation
Path: blob/master/dependencies/all/iniparser/dictionary.h
774 views
1
/*-------------------------------------------------------------------------*/
2
/**
3
@file dictionary.h
4
@author N. Devillard
5
@brief Implements a dictionary for string variables.
6
7
This module implements a simple dictionary object, i.e. a list
8
of string/string associations. This object is useful to store e.g.
9
informations retrieved from a configuration file (ini files).
10
*/
11
/*--------------------------------------------------------------------------*/
12
13
#ifndef _DICTIONARY_H_
14
#define _DICTIONARY_H_
15
16
/*---------------------------------------------------------------------------
17
Includes
18
---------------------------------------------------------------------------*/
19
20
#include <stdio.h>
21
#include <stdlib.h>
22
#include <string.h>
23
#if !_WIN32
24
#include <unistd.h>
25
#endif
26
27
#ifdef __cplusplus
28
extern "C" {
29
#endif
30
31
/*---------------------------------------------------------------------------
32
New types
33
---------------------------------------------------------------------------*/
34
35
36
/*-------------------------------------------------------------------------*/
37
/**
38
@brief Dictionary object
39
40
This object contains a list of string/string associations. Each
41
association is identified by a unique string key. Looking up values
42
in the dictionary is speeded up by the use of a (hopefully collision-free)
43
hash function.
44
*/
45
/*-------------------------------------------------------------------------*/
46
typedef struct _dictionary_ {
47
int n ; /** Number of entries in dictionary */
48
size_t size ; /** Storage size */
49
char ** val ; /** List of string values */
50
char ** key ; /** List of string keys */
51
unsigned * hash ; /** List of hash values for keys */
52
} dictionary ;
53
54
55
/*---------------------------------------------------------------------------
56
Function prototypes
57
---------------------------------------------------------------------------*/
58
59
60
unsigned dictionary_hash(const char * key);
61
62
63
dictionary * dictionary_new(size_t size);
64
65
66
void dictionary_del(dictionary * vd);
67
68
69
const char * dictionary_get(const dictionary * d, const char * key, const char * def);
70
71
72
73
int dictionary_set(dictionary * vd, const char * key, const char * val);
74
75
76
void dictionary_unset(dictionary * d, const char * key);
77
78
79
void dictionary_dump(const dictionary * d, FILE * out);
80
81
#ifdef __cplusplus
82
}
83
#endif
84
85
#endif
86