From b95b6b150dcde1cd99e216c1448dc8d837d6f089 Mon Sep 17 00:00:00 2001 From: Timerix Date: Sun, 7 Jun 2026 21:54:33 +0500 Subject: [PATCH] TomlTable_get -> TomlTable_tryGet --- include/tlibtoml.h | 2 +- src/TomlTable.c | 14 +++++++------- src/toml_parse/toml_walk_table_path.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/tlibtoml.h b/include/tlibtoml.h index 3e46f7f..0e55ccf 100644 --- a/include/tlibtoml.h +++ b/include/tlibtoml.h @@ -134,7 +134,7 @@ static inline void TomlTable_set(TomlTable* self, str key, TomlValue value){ HashMap_pushOrUpdate(self, key, &value); } -static inline TomlValue* TomlTable_get(const TomlTable* self, const str key){ +static inline NULLABLE(TomlValue*) TomlTable_tryGet(const TomlTable* self, const str key){ return HashMap_tryGetPtr(self, key); } diff --git a/src/TomlTable.c b/src/TomlTable.c index 636222c..f809cb5 100644 --- a/src/TomlTable.c +++ b/src/TomlTable.c @@ -41,7 +41,7 @@ void TomlTable_free(TomlTable* self) Result(TomlTable*) TomlTable_get_table(const TomlTable* self, str key) { Deferral(1); - TomlValue* v = TomlTable_get(self, key); + TomlValue* v = TomlTable_tryGet(self, key); try_assert_value_found(v, key); try_assert_value_type(v, key, TLIBTOML_TABLE); Return RESULT_VALUE(p, v->table); @@ -50,7 +50,7 @@ Result(TomlTable*) TomlTable_get_table(const TomlTable* self, str key) Result(TomlArray*) TomlTable_get_array(const TomlTable* self, str key) { Deferral(1); - TomlValue* v = TomlTable_get(self, key); + TomlValue* v = TomlTable_tryGet(self, key); try_assert_value_found(v, key); try_assert_value_type(v, key, TLIBTOML_ARRAY); Return RESULT_VALUE(p, v->array); @@ -59,7 +59,7 @@ Result(TomlArray*) TomlTable_get_array(const TomlTable* self, str key) Result(str*) TomlTable_get_str(const TomlTable* self, str key) { Deferral(1); - TomlValue* v = TomlTable_get(self, key); + TomlValue* v = TomlTable_tryGet(self, key); try_assert_value_found(v, key); try_assert_value_type(v, key, TLIBTOML_STRING); Return RESULT_VALUE(p, v->s); @@ -68,7 +68,7 @@ Result(str*) TomlTable_get_str(const TomlTable* self, str key) Result(i64) TomlTable_get_integer(const TomlTable* self, str key) { Deferral(1); - TomlValue* v = TomlTable_get(self, key); + TomlValue* v = TomlTable_tryGet(self, key); try_assert_value_found(v, key); try_assert_value_type(v, key, TLIBTOML_INTEGER); Return RESULT_VALUE(i, v->i); @@ -77,7 +77,7 @@ Result(i64) TomlTable_get_integer(const TomlTable* self, str key) Result(f64) TomlTable_get_float(const TomlTable* self, str key) { Deferral(1); - TomlValue* v = TomlTable_get(self, key); + TomlValue* v = TomlTable_tryGet(self, key); try_assert_value_found(v, key); try_assert_value_type(v, key, TLIBTOML_FLOAT); Return RESULT_VALUE(f, v->f); @@ -86,7 +86,7 @@ Result(f64) TomlTable_get_float(const TomlTable* self, str key) Result(TomlDateTime*) TomlTable_get_datetime(const TomlTable* self, str key) { Deferral(1); - TomlValue* v = TomlTable_get(self, key); + TomlValue* v = TomlTable_tryGet(self, key); try_assert_value_found(v, key); try_assert_value_type(v, key, TLIBTOML_DATETIME); Return RESULT_VALUE(p, v->dt); @@ -95,7 +95,7 @@ Result(TomlDateTime*) TomlTable_get_datetime(const TomlTable* self, str key) Result(bool) TomlTable_get_bool(const TomlTable* self, str key) { Deferral(1); - TomlValue* v = TomlTable_get(self, key); + TomlValue* v = TomlTable_tryGet(self, key); try_assert_value_found(v, key); try_assert_value_type(v, key, TLIBTOML_BOOLEAN); Return RESULT_VALUE(i, v->b); diff --git a/src/toml_parse/toml_walk_table_path.c b/src/toml_parse/toml_walk_table_path.c index 5376f7e..3a27b54 100644 --- a/src/toml_parse/toml_walk_table_path.c +++ b/src/toml_parse/toml_walk_table_path.c @@ -15,7 +15,7 @@ Result(Table*) toml_walk_table_path(TomlParser* parser, TomlTable* table, u64 i = 0; for (; i < key_path->len - 1; i++) { str part = *key_path->data[i].s; - TomlValue* t = TomlTable_get(real_table, part); + TomlValue* t = TomlTable_tryGet(real_table, part); if (t == NULL) { if (create_if_not_exist) { TomlValue new_table_value = TomlValue_new_table(); @@ -32,7 +32,7 @@ Result(Table*) toml_walk_table_path(TomlParser* parser, TomlTable* table, } str part = *key_path->data[i].s; - TomlValue* t = TomlTable_get(real_table, part); + TomlValue* t = TomlTable_tryGet(real_table, part); if (t == NULL) { if (create_if_not_exist) { TomlValue array_value = TomlValue_new_array(); @@ -59,7 +59,7 @@ Result(Table*) toml_walk_table_path(TomlParser* parser, TomlTable* table, } else { for (u64 i = 0; i < key_path->len; i++) { str part = *key_path->data[i].s; - TomlValue* t = TomlTable_get(real_table, part); + TomlValue* t = TomlTable_tryGet(real_table, part); if (t == NULL) { if (create_if_not_exist) { TomlValue new_table_value = TomlValue_new_table();