Skip to content

Commit 8b1dab5

Browse files
committedMay 3, 2017
map: convert comments to doxygen format
1 parent 7fe9cb9 commit 8b1dab5

File tree

3 files changed

+66
-22
lines changed

3 files changed

+66
-22
lines changed
 

‎doc/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Vis Editor API Documenation
77
text
88
buffer
99
array
10+
map

‎doc/map.rst

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Map
2+
===
3+
4+
.. doxygenfile:: map.h

‎map.h

+61-22
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,83 @@
33

44
#include <stdbool.h>
55

6+
/**
7+
* @file
8+
* Crit-bit tree based map which supports unique prefix queries and
9+
* ordered iteration.
10+
*/
11+
12+
/** Opaque map type. */
613
typedef struct Map Map;
714

8-
/* Allocate a new map. */
15+
/** Allocate a new map. */
916
Map *map_new(void);
10-
/* Retrieves a value, or NULL if it isn't in the map */
17+
/** Lookup a value, returns ``NULL`` if not found. */
1118
void *map_get(const Map*, const char *key);
12-
/* Get first element of the map, or NULL if empty */
19+
/**
20+
* Get first element of the map, or ``NULL`` if empty.
21+
* @param key Updated with the key of the first element.
22+
*/
1323
void *map_first(const Map*, const char **key);
14-
/* Returns the corresponding value if the given prefix is unique.
15-
* Otherwise NULL, if no such prefix exists then errno is set to ENOENT. */
24+
/**
25+
* Lookup element by unique prefix match.
26+
* @param prefix The prefix to search for.
27+
* @return The corresponding value, if the given prefix is unique.
28+
* Otherwise ``NULL``. If no such prefix exists, then ``errno``
29+
* is set to ``ENOENT``.
30+
*/
1631
void *map_closest(const Map*, const char *prefix);
17-
/* check whether the map contains the given prefix, i.e. whether it can
18-
* be extended to match a key of an element stored in the map. */
32+
/**
33+
* Check whether the map contains the given prefix.
34+
* whether it can be extended to match a key of a map element.
35+
*/
1936
bool map_contains(const Map*, const char *prefix);
20-
/* Test whether the given prefix can be extended to exactly one map element
21-
* i.e. true iff the prefix map contains exactly one element. */
37+
/**
38+
* Check whether the given prefix can be extended to exactly one map element.
39+
* True iff the prefix map contains exactly one element.
40+
*/
2241
bool map_leaf(const Map*, const char *prefix);
23-
/* Place a member in the map. This returns false if we run out of memory
24-
* (errno = ENOMEM), or if that key already appears in the map (errno = EEXIST). */
42+
/**
43+
* Store a key value pair in the map.
44+
* @return False if we run out of memory (``errno = ENOMEM``), or if the key
45+
* already appears in the map (``errno = EEXIST``).
46+
*/
2547
bool map_put(Map*, const char *key, const void *value);
26-
/* Remove a member from the map. Returns the removed entry or NULL
27-
* if there was no entry found using the given key*/
48+
/**
49+
* Remove a map element.
50+
* @return The removed entry or ``NULL`` if no such element exists.
51+
*/
2852
void *map_delete(Map*, const char *key);
29-
/* Copy all entries from `src' into `dest', overwrites existing entries in `dest' */
53+
/** Copy all entries from ``src`` into ``dest``, overwrites existing entries in ``dest``. */
3054
bool map_copy(Map *dest, Map *src);
31-
/* Ordered iteration over a map, call handle for every entry. If handle
32-
* returns false, the iteration will stop. */
55+
/**
56+
* Ordered iteration over a map.
57+
* Invokes the passed callback for every map entry.
58+
* If ``handle`` returns false, the iteration will stop.
59+
* @param handle A function invoked for ever map element.
60+
* @param data A context pointer, passed as last argument to ``handle``.
61+
*/
3362
void map_iterate(const Map*, bool (*handle)(const char *key, void *value, void *data), const void *data);
34-
/* Return a submap matching a prefix. This returns a pointer into the
35-
* original map, so don't alter the map while using the return value. */
63+
/**
64+
* Get a sub map matching a prefix.
65+
* @rst
66+
* .. warning:: This returns a pointer into the original map.
67+
* Do not alter the map while using the return value.
68+
* @endrst
69+
*/
3670
const Map *map_prefix(const Map*, const char *prefix);
37-
/* Test whether the map is empty i.e. contains no elements */
71+
/** Test whether the map is empty (contains no elements). */
3872
bool map_empty(const Map*);
39-
/* Remove every member from the map. The map will be empty after this. */
73+
/** Empty the map. */
4074
void map_clear(Map*);
41-
/* Release all memory associated with this map */
75+
/** Release all memory associated with this map. */
4276
void map_free(Map*);
43-
/* Call free(3) for every pointer stored in the map, then free the map itself */
77+
/**
78+
* Call `free(3)` for every map element, then free the map itself.
79+
* @rst
80+
* .. warning:: Assumes map elements to be pointers.
81+
* @endrst
82+
*/
4483
void map_free_full(Map*);
4584

4685
#endif

0 commit comments

Comments
 (0)
Please sign in to comment.