/simpletypesystem/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/simpletypesystem/trunk

« back to all changes in this revision

Viewing changes to src/Map.h

  • Committer: Gustav Hartvigsson
  • Date: 2015-08-31 21:16:20 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20150831211620-sae1cl7ug6rrk2vy
* removed s_dynamic_array_foreach_with_return.
  It was a stupid idea to begin with.

* Doc cleanup.
* Added s_map_foreach () skeleton.
* Added s_map_(de)serialize_json () skeleton.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 * The first pointer is the key, the secold is the value.
47
47
 *
48
48
 * please note that SMaps can be slow and are unordered.
49
 
 *
50
 
 * TODO: Total rewrite.
51
49
 */
52
50
 
53
51
 
162
160
s_map_get (SMap * self, spointer key);
163
161
 
164
162
/**
165
 
 * @todo
 
163
 * This function removes an item from 
166
164
 */
167
165
void
168
166
s_map_remove (SMap * self, spointer key);
169
167
 
 
168
/**
 
169
 * Do a for each on each key/value pair.
 
170
 *
 
171
 * @note This function <em>must not</em> change the key. Changing of the
 
172
 * value is permited.
 
173
 *
 
174
 * The foreach should have the following signature:
 
175
 @code{.c}
 
176
void
 
177
my_foreach_func (SMap * map, SMapItem * item, spointer user_data);
 
178
 @endcode
 
179
 * The <tt>user_data</tt> is passed to the function, and the <tt>item</tt>
 
180
 * is what you operate on inside the function. <tt>map</tt> can be ignored.
 
181
 */
 
182
void
 
183
s_map_foreach (SMap * self, ForEachFunc foreach_func, spointer user_data);
 
184
 
 
185
/**
 
186
 * @TODO
 
187
 * @warning NOT IMPLIED
 
188
 *
 
189
 * Get the map as JSON.
 
190
 * @param self The SMap to get the JSON from.
 
191
 * @param to_json_key Functon to 
 
192
 *
 
193
 * @return a null-terminated JSON string representing the matrix.
 
194
 *
 
195
 * The outputted JSON will have the format:
 
196
 @code{.js}
 
197
{
 
198
  "Cats": "Meew",
 
199
  "Dogs": "Bark",
 
200
  "Cows": "Moo"
 
201
}
 
202
 @endcode
 
203
 */
 
204
char *
 
205
s_map_serialize_json (SMap * self,
 
206
                      FuncPointer to_json_key,
 
207
                      FuncPointer to_json_value);
 
208
 
 
209
/**
 
210
 * @TODO
 
211
 * @warning NOT IMPLIED
 
212
 *
 
213
 * Deselialize JSON into an SMap.
 
214
 *
 
215
 * This will append the key/value pair to the map, with the caviat that 
 
216
 *
 
217
 * @param self The SMap to write to.
 
218
 * @param data the JSON data to be deselialised.
 
219
 */
 
220
void
 
221
s_map_deserialize_json (SMap * self ,const char * data,
 
222
                        FuncPointer from_json_key,
 
223
                        FuncPointer from_json_value);
 
224
 
170
225
/** @} */
171
226
 
172
227
END_DECLS