replaced TomlString with StringBuilder

This commit is contained in:
2025-11-10 05:42:29 +05:00
parent c83ee4078e
commit a33505ffe4
4 changed files with 182 additions and 311 deletions

View File

@@ -11,6 +11,7 @@ extern "C" {
#include <time.h>
#include "tlibc/std.h"
#include "tlibc/string/str.h"
#include "tlibc/string/StringBuilder.h"
typedef struct tm TomlDateTime;
@@ -28,12 +29,6 @@ typedef struct {
NULLABLE(char*) message;
} TomlErr;
typedef struct {
char* s;
u64 len;
u64 _capacity;
} TomlString;
typedef struct _TomlValue TomlValue;
typedef struct {
@@ -70,17 +65,17 @@ struct _TomlValue {
union {
TomlTable* table;
TomlArray* array;
TomlString* string;
i64 integer;
f64 float_;
TomlDateTime datetime;
bool boolean;
str s;
i64 i;
f64 f;
TomlDateTime dt;
bool b;
} value;
};
struct _TomlKeyValue {
TomlString* key;
TomlValue* value;
str key;
TomlValue* value;
};
typedef struct {
@@ -98,28 +93,19 @@ void toml_free(void* p);
const TomlErr* toml_err(void);
void toml_err_clear(void);
TomlString* toml_string_new(void);
TomlString* toml_string_from_str(str s);
void toml_string_append_char(TomlString* self, char ch);
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);
TomlTable* toml_table_new(void);
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, 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);
str toml_table_get_str(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);
bool toml_table_get_bool(const TomlTable* self, str key);
TomlTableIter toml_table_iter_new(TomlTable* table);
TomlKeyValue* toml_table_iter_get(TomlTableIter* self);
@@ -137,7 +123,7 @@ TomlValue* toml_value_new_array(void);
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_new_bool(bool b);
TomlValue* toml_value_from_str(str s);
void toml_value_free(TomlValue* self);
@@ -146,7 +132,7 @@ TomlTable* toml_load_file(FILE* file);
TomlTable* toml_load_filename(cstr filename);
/* TODO: implement dump functions
TomlString* toml_dump_str(const TomlTable* self, TomlErr *err);
str toml_dump_str(const TomlTable* self, TomlErr *err);
void toml_dump_file(const TomlTable* self, FILE* file, TomlErr *err);
*/