TomlTable_get -> TomlTable_tryGet

This commit is contained in:
2026-06-07 21:54:33 +05:00
parent 5cb121d1de
commit b95b6b150d
3 changed files with 11 additions and 11 deletions

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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();