ThingWorx C SDK
twDict.h
1 /***************************************
2  * Copyright 2017, PTC, Inc.
3  ***************************************/
4 #include <stdio.h>
5 
6 #ifndef TW_C_SDK_TWDICT_H
7 #define TW_C_SDK_TWDICT_H
8 
9 #define TW_DICT_MISSING -3 /* No such element */
10 #define TW_DICT_FULL -2 /* Dictionary is full */
11 #define TW_DICT_OMEM -1 /* Out of Memory */
12 #define TW_DICT_OK 0 /* OK */
13 
14 #ifndef TW_FOREACH_CONTINUE
15 #define TW_FOREACH_CONTINUE 0
16 #define TW_FOREACH_EXIT 1
17 #endif
18 
19 #define TW_DICTIONARY_LIST 1
20 #define TW_DICTIONARY_MAP 2
21 typedef int twDictionaryMode;
22 
23 typedef void twDict;
24 typedef void (*dict_del_func) (void * item);
25 typedef const char* (*dict_key_parse_func) (void * item);
26 typedef int (*twDict_foreach_fn)(void *key, size_t key_size, void *data, size_t data_size,void *arg);
27 
33 int twDict_Cleanup ();
34 
51 twDict * twDict_Create(dict_del_func delete_function,dict_key_parse_func parse_func);
52 
62 int twDict_Delete(twDict* in);
63 
73 int twDict_Clear(twDict* in);
74 
85 int twDict_Add(twDict* in, void *value);
86 
103 int twDict_Remove(twDict* in, void * item, char deleteValue);
104 
123 size_t twDict_Foreach(twDict* in, twDict_foreach_fn listHandler, void *userData);
124 
139 int twDict_Find(twDict* in, void* query, void** results);
140 
149 int twDict_GetCount(twDict* in);
150 
151 /*
152 Replaces the value of the specified dictionary entry with the new value supplied.
153 Parameters:
154  int - pointer to the dictionary to operate on
155  value - pointer to the value whose value should be replaced.
156  new_value - the new value
157  dispose - Boolean: delete the old value using the delete function specified when the dictionary was created
158 Return:
159  int - zero if successful, non-zero if an error occurred
160 */
161 int twDict_ReplaceValue(twDict* in, void * value, void * new_value, char dispose);
162 
163 #endif /* TW_C_SDK_TWDICT_H */