aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/map.h
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2014-05-12 02:25:17 +0200
committerEliseo Martínez <eliseomarmol@gmail.com>2014-05-15 20:46:01 +0200
commitda51dc9cf202772f60bd2da975dbef257bd9237c (patch)
tree5c16b93238a153f55634e9323077f30c8133970c /src/nvim/map.h
parentffe61e5ba1721340ca51d56bae3ddaca415fb5bc (diff)
downloadrneovim-da51dc9cf202772f60bd2da975dbef257bd9237c.tar.gz
rneovim-da51dc9cf202772f60bd2da975dbef257bd9237c.tar.bz2
rneovim-da51dc9cf202772f60bd2da975dbef257bd9237c.zip
Introduce nvim namespace: Move files.
Move files from src/ to src/nvim/. - src/nvim/ becomes the new root dir for nvim executable sources. - src/libnvim/ is planned to become root dir of the neovim library.
Diffstat (limited to 'src/nvim/map.h')
-rw-r--r--src/nvim/map.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/nvim/map.h b/src/nvim/map.h
new file mode 100644
index 0000000000..9e61b903d5
--- /dev/null
+++ b/src/nvim/map.h
@@ -0,0 +1,57 @@
+// General-purpose string->pointer associative array with a simple API
+#ifndef NEOVIM_MAP_H
+#define NEOVIM_MAP_H
+
+#include <stdbool.h>
+
+#include "map_defs.h"
+
+/// Creates a new `Map` instance
+///
+/// @return a pointer to the new instance
+Map *map_new(void);
+
+/// Frees memory for a `Map` instance
+///
+/// @param map The `Map` instance
+void map_free(Map *map);
+
+/// Gets the value corresponding to a key in a `Map` instance
+///
+/// @param map The `Map` instance
+/// @param key A key string
+/// @return The value if the key exists in the map, or NULL if it doesn't
+void *map_get(Map *map, const char *key);
+
+/// Checks if a key exists in the map
+///
+/// @param map The `Map` instance
+/// @param key A key string
+/// @return true if the key exists, false otherwise
+bool map_has(Map *map, const char *key);
+
+/// Set the value corresponding to a key in a `Map` instance and returns
+/// the old value.
+///
+/// @param map The `Map` instance
+/// @param key A key string
+/// @param value A value
+/// @return The current value if exists or NULL otherwise
+void *map_put(Map *map, const char *key, void *value);
+
+/// Deletes the value corresponding to a key in a `Map` instance and returns
+/// the old value.
+///
+/// @param map The `Map` instance
+/// @param key A key string
+/// @return The current value if exists or NULL otherwise
+void *map_del(Map *map, const char *key);
+
+/// Iterates through each key/value pair in the map
+///
+/// @param map The `Map` instance
+/// @param cb A function that will be called for each key/value
+void map_foreach(Map *map, key_value_cb cb);
+
+#endif /* NEOVIM_MAP_H */
+