4 * @brief Interface of dict_t.
9 * Copyright (C) 2007 Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 typedef struct dict_t dict_t
;
31 * @brief Dictionary type, key value stuff.
36 * @brief Set a value in the dict.
38 * @param key key to set
39 * @param value value, NULL to unset key
42 void (*set
)(dict_t
*this, void *key
, void *value
);
45 * @brief Get a value form the dict.
47 * @param key key to get value of
48 * @return assigned value, NULL if not found
50 void* (*get
)(dict_t
*this, void *key
);
53 * @brief Destroy a dict instance.
55 void (*destroy
)(dict_t
*this);
59 * @brief Key comparator function for strings
61 bool dict_streq(void *a
, void *b
);
64 * @brief Create a dict instance.
66 * @param free_key TRUE to free() keys on destruction
69 dict_t
*dict_create(bool(*key_comparator
)(void*,void*),
70 void(*key_destructor
)(void*),
71 void(*value_destructor
)(void*));