54#define YATL_LINE_SIZE 96
60#define YATL_CURSOR_SIZE 96
66#define YATL_SPAN_SIZE 160
72#define YATL_DOC_SIZE 64
141#define YATL_ENABLE_LOGGING
143#ifdef YATL_ENABLE_LOGGING
145#define LOG_LEVEL YATL_LOG_DEBUG
177#ifdef YATL_ENABLE_LOGGING
178#define YATL_LOG(level, fmt, ...) \
180 if ((level) >= LOG_LEVEL) { \
181 fprintf(stderr, "[%s] %s:%d (%s): " fmt "\n", log_level_str(level), \
182 __FILE__, __LINE__, __func__, ##__VA_ARGS__); \
186#define YATL_LOG(level, fmt, ...) \
594 const char **out_text,
size_t *out_len);
628 const size_t *lengths,
size_t line_count);
YATL_Doc_t YATL_doc_create(void)
Create an initialized document.
YATL_Result_t YATL_doc_load(YATL_Doc_t *doc, const char *path)
Load a TOML document from a file.
YATL_Result_t YATL_doc_clear_boneyard(YATL_Doc_t *doc)
Clear the document boneyard.
YATL_Result_t YATL_doc_save(YATL_Doc_t *doc, const char *path)
Save a document to a file.
void YATL_doc_free(YATL_Doc_t *doc)
Free document resources.
YATL_Result_t YATL_doc_loads(YATL_Doc_t *doc, const char *str, size_t len)
Load a TOML document from a string.
YATL_Result_t
Result/error codes returned by YATL functions.
Definition yatl.h:231
YATL_SpanType_t
Span type enumeration.
Definition yatl.h:201
YATL_ValueType_t
Value type enumeration.
Definition yatl.h:219
@ YATL_ERR_NOT_FOUND
Definition yatl.h:236
@ YATL_OK
Definition yatl.h:233
@ YATL_ERR_SYNTAX
Definition yatl.h:235
@ YATL_ERR_NOMEM
Definition yatl.h:239
@ YATL_DONE
Definition yatl.h:232
@ YATL_ERR_IO
Definition yatl.h:234
@ YATL_ERR_TYPE
Definition yatl.h:237
@ YATL_ERR_BUFFERi
Definition yatl.h:238
@ YATL_ERR_INVALID_ARG
Definition yatl.h:240
@ YATL_S_NODE_ARRAY
Definition yatl.h:204
@ YATL_S_NODE_ARRAY_TABLE
Definition yatl.h:205
@ YATL_S_LEAF_COMMENT
Definition yatl.h:208
@ YATL_S_NONE
Definition yatl.h:202
@ YATL_S_SLICE_KEY
Definition yatl.h:209
@ YATL_S_NODE_INLINE_TABLE
Definition yatl.h:206
@ YATL_S_LEAF_KEYVAL
Definition yatl.h:207
@ YATL_S_NODE_TABLE
Definition yatl.h:203
@ YATL_S_SLICE_VALUE
Definition yatl.h:210
@ YATL_TYPE_BAREVALUE
Definition yatl.h:220
@ YATL_TYPE_STRING
Definition yatl.h:222
@ YATL_TYPE_ARRAY
Definition yatl.h:223
@ YATL_TYPE_INLINE_TABLE
Definition yatl.h:224
YATL_Span_t YATL_span_create(void)
Create an initialized span.
YATL_Cursor_t YATL_cursor_create(void)
Create an initialized cursor.
YATL_log_level_t
Log levels for YATL diagnostic messages.
Definition yatl.h:130
@ YATL_LOG_ERROR
Definition yatl.h:134
@ YATL_LOG_DEBUG
Definition yatl.h:131
@ YATL_LOG_WARN
Definition yatl.h:133
@ YATL_LOG_INFO
Definition yatl.h:132
YATL_Result_t YATL_span_ml_set_value(YATL_Span_t *span, const char **lines, const size_t *lengths, size_t line_count)
Set the value of a span, supporting multi-line values.
YATL_Result_t YATL_span_set_value(YATL_Span_t *span, const char *value, size_t length)
Set the value of a span with a single-line value.Replaces the value content of a span with new conten...
YATL_Result_t YATL_span_find_name(const YATL_Span_t *in_span, const char *name, YATL_Span_t *out_span)
Find a table or key-value by name.
YATL_Result_t YATL_span_iter_line(const YATL_Span_t *span, YATL_Cursor_t *cursor, const char **out_text, size_t *out_len)
Iterate over line segments within a span.
YATL_Result_t YATL_doc_span(const YATL_Doc_t *doc, YATL_Span_t *out_span)
Get a span covering the entire document.
YATL_Result_t YATL_cursor_move(YATL_Cursor_t *cursor, long npos)
Move a cursor by a character offset.
YATL_Result_t YATL_span_find_next(const YATL_Span_t *in_span, YATL_Cursor_t *cursor, YATL_Span_t *out_span)
Find the next span within a boundary span.
YATL_Result_t YATL_span_find_next_by_name(const YATL_Span_t *in_span, const char *name, const YATL_Cursor_t *in_cursor, YATL_Cursor_t *out_cursor, YATL_Span_t *out_span)
Find next table or key-value by name with cursor support.
YATL_Result_t YATL_span_keyval_slice(const YATL_Span_t *in_span, YATL_Span_t *key, YATL_Span_t *val)
Slice a key-value span into separate key and value spans.
const char * YATL_span_type_name(YATL_SpanType_t type)
Get the string name of a span type.
YATL_Result_t YATL_span_text(const YATL_Span_t *in_span, const char **out_text, size_t *out_len)
Get text content of a single-line span.
YATL_SpanType_t YATL_span_type(const YATL_Span_t *span)
Get the type of a span.
YATL_Result_t YATL_span_get_string(const YATL_Span_t *in_span, const char *key, const char **out_text, size_t *out_len)
Convenience function to find a key and get its string value.
#define YATL_CURSOR_SIZE
Size of opaque YATL_Cursor_t structure in bytes.
Definition yatl.h:60
struct YATL_Doc YATL_Doc_t
Opaque document structure.
struct YATL_Cursor YATL_Cursor_t
Opaque cursor structure.
struct YATL_Line YATL_Line_t
Opaque line structure.
#define YATL_DOC_SIZE
Size of opaque YATL_Doc_t structure in bytes.
Definition yatl.h:72
#define YATL_SPAN_SIZE
Size of opaque YATL_Span_t structure in bytes.
Definition yatl.h:66
struct YATL_Span YATL_Span_t
Opaque span structure.
#define YATL_LINE_SIZE
Size of opaque YATL_Line_t structure in bytes.
Definition yatl.h:54
Opaque cursor structure.
Definition yatl.h:94
Opaque document structure.
Definition yatl.h:122
Opaque line structure.
Definition yatl.h:81
Opaque span structure.
Definition yatl.h:109