TomlTable_get -> TomlTable_tryGet
This commit is contained in:
@@ -134,7 +134,7 @@ static inline void TomlTable_set(TomlTable* self, str key, TomlValue value){
|
|||||||
HashMap_pushOrUpdate(self, key, &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);
|
return HashMap_tryGetPtr(self, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ void TomlTable_free(TomlTable* self)
|
|||||||
Result(TomlTable*) TomlTable_get_table(const TomlTable* self, str key)
|
Result(TomlTable*) TomlTable_get_table(const TomlTable* self, str key)
|
||||||
{
|
{
|
||||||
Deferral(1);
|
Deferral(1);
|
||||||
TomlValue* v = TomlTable_get(self, key);
|
TomlValue* v = TomlTable_tryGet(self, key);
|
||||||
try_assert_value_found(v, key);
|
try_assert_value_found(v, key);
|
||||||
try_assert_value_type(v, key, TLIBTOML_TABLE);
|
try_assert_value_type(v, key, TLIBTOML_TABLE);
|
||||||
Return RESULT_VALUE(p, v->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)
|
Result(TomlArray*) TomlTable_get_array(const TomlTable* self, str key)
|
||||||
{
|
{
|
||||||
Deferral(1);
|
Deferral(1);
|
||||||
TomlValue* v = TomlTable_get(self, key);
|
TomlValue* v = TomlTable_tryGet(self, key);
|
||||||
try_assert_value_found(v, key);
|
try_assert_value_found(v, key);
|
||||||
try_assert_value_type(v, key, TLIBTOML_ARRAY);
|
try_assert_value_type(v, key, TLIBTOML_ARRAY);
|
||||||
Return RESULT_VALUE(p, v->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)
|
Result(str*) TomlTable_get_str(const TomlTable* self, str key)
|
||||||
{
|
{
|
||||||
Deferral(1);
|
Deferral(1);
|
||||||
TomlValue* v = TomlTable_get(self, key);
|
TomlValue* v = TomlTable_tryGet(self, key);
|
||||||
try_assert_value_found(v, key);
|
try_assert_value_found(v, key);
|
||||||
try_assert_value_type(v, key, TLIBTOML_STRING);
|
try_assert_value_type(v, key, TLIBTOML_STRING);
|
||||||
Return RESULT_VALUE(p, v->s);
|
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)
|
Result(i64) TomlTable_get_integer(const TomlTable* self, str key)
|
||||||
{
|
{
|
||||||
Deferral(1);
|
Deferral(1);
|
||||||
TomlValue* v = TomlTable_get(self, key);
|
TomlValue* v = TomlTable_tryGet(self, key);
|
||||||
try_assert_value_found(v, key);
|
try_assert_value_found(v, key);
|
||||||
try_assert_value_type(v, key, TLIBTOML_INTEGER);
|
try_assert_value_type(v, key, TLIBTOML_INTEGER);
|
||||||
Return RESULT_VALUE(i, v->i);
|
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)
|
Result(f64) TomlTable_get_float(const TomlTable* self, str key)
|
||||||
{
|
{
|
||||||
Deferral(1);
|
Deferral(1);
|
||||||
TomlValue* v = TomlTable_get(self, key);
|
TomlValue* v = TomlTable_tryGet(self, key);
|
||||||
try_assert_value_found(v, key);
|
try_assert_value_found(v, key);
|
||||||
try_assert_value_type(v, key, TLIBTOML_FLOAT);
|
try_assert_value_type(v, key, TLIBTOML_FLOAT);
|
||||||
Return RESULT_VALUE(f, v->f);
|
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)
|
Result(TomlDateTime*) TomlTable_get_datetime(const TomlTable* self, str key)
|
||||||
{
|
{
|
||||||
Deferral(1);
|
Deferral(1);
|
||||||
TomlValue* v = TomlTable_get(self, key);
|
TomlValue* v = TomlTable_tryGet(self, key);
|
||||||
try_assert_value_found(v, key);
|
try_assert_value_found(v, key);
|
||||||
try_assert_value_type(v, key, TLIBTOML_DATETIME);
|
try_assert_value_type(v, key, TLIBTOML_DATETIME);
|
||||||
Return RESULT_VALUE(p, v->dt);
|
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)
|
Result(bool) TomlTable_get_bool(const TomlTable* self, str key)
|
||||||
{
|
{
|
||||||
Deferral(1);
|
Deferral(1);
|
||||||
TomlValue* v = TomlTable_get(self, key);
|
TomlValue* v = TomlTable_tryGet(self, key);
|
||||||
try_assert_value_found(v, key);
|
try_assert_value_found(v, key);
|
||||||
try_assert_value_type(v, key, TLIBTOML_BOOLEAN);
|
try_assert_value_type(v, key, TLIBTOML_BOOLEAN);
|
||||||
Return RESULT_VALUE(i, v->b);
|
Return RESULT_VALUE(i, v->b);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Result(Table*) toml_walk_table_path(TomlParser* parser, TomlTable* table,
|
|||||||
u64 i = 0;
|
u64 i = 0;
|
||||||
for (; i < key_path->len - 1; i++) {
|
for (; i < key_path->len - 1; i++) {
|
||||||
str part = *key_path->data[i].s;
|
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 (t == NULL) {
|
||||||
if (create_if_not_exist) {
|
if (create_if_not_exist) {
|
||||||
TomlValue new_table_value = TomlValue_new_table();
|
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;
|
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 (t == NULL) {
|
||||||
if (create_if_not_exist) {
|
if (create_if_not_exist) {
|
||||||
TomlValue array_value = TomlValue_new_array();
|
TomlValue array_value = TomlValue_new_array();
|
||||||
@@ -59,7 +59,7 @@ Result(Table*) toml_walk_table_path(TomlParser* parser, TomlTable* table,
|
|||||||
} else {
|
} else {
|
||||||
for (u64 i = 0; i < key_path->len; i++) {
|
for (u64 i = 0; i < key_path->len; i++) {
|
||||||
str part = *key_path->data[i].s;
|
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 (t == NULL) {
|
||||||
if (create_if_not_exist) {
|
if (create_if_not_exist) {
|
||||||
TomlValue new_table_value = TomlValue_new_table();
|
TomlValue new_table_value = TomlValue_new_table();
|
||||||
|
|||||||
Reference in New Issue
Block a user