aboutsummaryrefslogtreecommitdiff
path: root/src/string_map.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/string_map.cpp')
-rw-r--r--src/string_map.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/string_map.cpp b/src/string_map.cpp
index 7a446937a..09e125800 100644
--- a/src/string_map.cpp
+++ b/src/string_map.cpp
@@ -54,6 +54,10 @@ template <typename T> T * string_map_get (StringMap<T> *h, char co
template <typename T> T * string_map_get (StringMap<T> *h, String const &key);
template <typename T> T * string_map_get (StringMap<T> *h, StringHashKey const &key);
+template <typename T> T & string_map_must_get (StringMap<T> *h, char const *key);
+template <typename T> T & string_map_must_get (StringMap<T> *h, String const &key);
+template <typename T> T & string_map_must_get (StringMap<T> *h, StringHashKey const &key);
+
template <typename T> void string_map_set (StringMap<T> *h, StringHashKey const &key, T const &value);
template <typename T> void string_map_set (StringMap<T> *h, String const &key, T const &value);
template <typename T> void string_map_set (StringMap<T> *h, char const *key, T const &value);
@@ -188,6 +192,23 @@ gb_inline T *string_map_get(StringMap<T> *h, char const *key) {
}
template <typename T>
+T &string_map_must_get(StringMap<T> *h, StringHashKey const &key) {
+ isize index = string_map__find(h, key).entry_index;
+ GB_ASSERT(index >= 0);
+ return h->entries[index].value;
+}
+
+template <typename T>
+gb_inline T &string_map_must_get(StringMap<T> *h, String const &key) {
+ return string_map_must_get(h, string_hash_string(key));
+}
+
+template <typename T>
+gb_inline T &string_map_must_get(StringMap<T> *h, char const *key) {
+ return string_map_must_get(h, string_hash_string(make_string_c(key)));
+}
+
+template <typename T>
void string_map_set(StringMap<T> *h, StringHashKey const &key, T const &value) {
isize index;
StringMapFindResult fr;