From 3e21766514b1e87c95c94363289f21a022fa4110 Mon Sep 17 00:00:00 2001 From: Timerix Date: Thu, 27 Nov 2025 00:31:47 +0500 Subject: [PATCH] made all toml_load* functions public --- include/tlibtoml.h | 21 ++++++++++++++++++--- src/toml_load.c | 10 ---------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/include/tlibtoml.h b/include/tlibtoml.h index 04258be..bce6280 100644 --- a/include/tlibtoml.h +++ b/include/tlibtoml.h @@ -48,11 +48,26 @@ typedef List(TomlValue) TomlArray; // Parser // // // ////////////////////////////////////////////////////////////////////////////// - -Result(TomlTable*) toml_load_str(str s); -Result(TomlTable*) toml_load_file(FILE* file); + +/// opens file Result(TomlTable*) toml_load_filename(cstr filename); +/// @param filename to use in error messages +Result(TomlTable*) toml_load_str_filename(str s, cstr filename); + +/// loads whole file in memory +/// @param filename to use in error messages +Result(TomlTable*) toml_load_file_filename(FILE* file, cstr filename); + +static inline Result(TomlTable*) toml_load_str(str s){ + return toml_load_str_filename(s, ""); +} + +static inline Result(TomlTable*) toml_load_file(FILE* file){ + return toml_load_file_filename(file, ""); +} + + /* TODO: implement dump functions str toml_dump_str(const TomlTable* self, TomlErr *err); void toml_dump_file(const TomlTable* self, FILE* file, TomlErr *err); diff --git a/src/toml_load.c b/src/toml_load.c index c4f27f2..1951649 100644 --- a/src/toml_load.c +++ b/src/toml_load.c @@ -30,16 +30,6 @@ Result(TomlTable*) toml_load_file_filename(FILE* file, cstr filename) Return RESULT_VALUE(p, table); } -Result(TomlTable*) toml_load_str(str s) -{ - return toml_load_str_filename(s, ""); -} - -Result(TomlTable*) toml_load_file(FILE* file) -{ - return toml_load_file_filename(file, ""); -} - Result(TomlTable*) toml_load_filename(cstr filename) { Deferral(1);