replaced char* function arguments with str

This commit is contained in:
2025-11-10 02:16:02 +05:00
parent 247d291da6
commit c83ee4078e
3 changed files with 63 additions and 175 deletions

View File

@@ -12,8 +12,7 @@ extern "C" {
#include "tlibc/std.h"
#include "tlibc/string/str.h"
#define false 0
#define true 1
typedef struct tm TomlDateTime;
typedef enum {
TOML_OK,
@@ -26,8 +25,7 @@ typedef enum {
typedef struct {
TomlErrCode code;
char* message;
i32 _is_literal;
NULLABLE(char*) message;
} TomlErr;
typedef struct {
@@ -75,7 +73,7 @@ struct _TomlValue {
TomlString* string;
i64 integer;
f64 float_;
struct tm datetime;
TomlDateTime datetime;
bool boolean;
} value;
};
@@ -97,20 +95,13 @@ void* toml_malloc(u64 size);
void* toml_realloc(void* p, u64 size);
void toml_free(void* p);
char* toml_strdup(cstr s);
char* toml_strndup(cstr s, u64 n);
i32 toml_vasprintf(char** s, cstr format, va_list args);
i32 toml_asprintf(char** s, cstr format, ...) ATTRIBUTE_CHECK_FORMAT_PRINTF(2, 3);
const TomlErr* toml_err(void);
void toml_err_clear(void);
TomlString* toml_string_new(void);
TomlString* toml_string_from_str(cstr s);
TomlString* toml_string_from_nstr(cstr s, u64 len);
TomlString* toml_string_from_str(str s);
void toml_string_append_char(TomlString* self, char ch);
void toml_string_append_str(TomlString* self, cstr s);
void toml_string_append_nstr(TomlString* self, cstr s, u64 len);
void toml_string_append_str(TomlString* self, str s);
TomlString* toml_string_clone(const TomlString* self);
void toml_string_free(TomlString* self);
i32 toml_string_equals(const TomlString* self, const TomlString* other);
@@ -120,17 +111,15 @@ void toml_table_free(TomlTable* self);
void toml_table_set_by_string(TomlTable* self, TomlString* key, TomlValue* value);
TomlValue* toml_table_get_by_string(const TomlTable* self, const TomlString* key);
void toml_table_set(TomlTable* self, cstr key, TomlValue* value);
void toml_table_setn(TomlTable* self, cstr key, u64 key_len, TomlValue* value);
TomlValue* toml_table_get(const TomlTable* self, cstr key);
TomlTable* toml_table_get_as_table(const TomlTable* self, cstr key);
TomlArray* toml_table_get_as_array(const TomlTable* self, cstr key);
TomlString* toml_table_get_as_string(const TomlTable* self, cstr key);
i64 toml_table_get_as_integer(const TomlTable* self, cstr key);
f64 toml_table_get_as_float(const TomlTable* self, cstr key);
const struct tm* toml_table_get_as_datetime(const TomlTable* self, cstr key);
i32 toml_table_get_as_boolean(const TomlTable* self, cstr key);
TomlValue* toml_table_getn(const TomlTable* self, cstr key, u64 key_len);
void toml_table_set(TomlTable* self, str key, TomlValue* value);
TomlValue* toml_table_get(const TomlTable* self, str key);
TomlTable* toml_table_get_table(const TomlTable* self, str key);
TomlArray* toml_table_get_array(const TomlTable* self, str key);
TomlString* toml_table_get_string(const TomlTable* self, str key);
i64 toml_table_get_integer(const TomlTable* self, str key);
f64 toml_table_get_float(const TomlTable* self, str key);
const TomlDateTime* toml_table_get_datetime(const TomlTable* self, str key);
i32 toml_table_get_boolean(const TomlTable* self, str key);
TomlTableIter toml_table_iter_new(TomlTable* table);
TomlKeyValue* toml_table_iter_get(TomlTableIter* self);
@@ -149,17 +138,15 @@ TomlValue* toml_value_new_integer(i64 integer);
TomlValue* toml_value_new_float(f64 flt);
TomlValue* toml_value_new_datetime(void);
TomlValue* toml_value_new_boolean(i32 boolean);
TomlValue* toml_value_from_str(cstr s);
TomlValue* toml_value_from_str(str s);
void toml_value_free(TomlValue* self);
TomlTable* toml_load_str(cstr s);
TomlTable* toml_load_nstr(cstr s, u64 len);
TomlTable* toml_load_str(str s);
TomlTable* toml_load_file(FILE* file);
TomlTable* toml_load_filename(cstr filename);
/* TODO: implement dump functions
char* toml_dump_str(const TomlTable* self, TomlErr *err);
TomlString* toml_dump_nstr(const TomlTable* self, TomlErr *err);
TomlString* toml_dump_str(const TomlTable* self, TomlErr *err);
void toml_dump_file(const TomlTable* self, FILE* file, TomlErr *err);
*/