YATL
Loading...
Searching...
No Matches
Document Lifecycle

Functions for loading, saving, and managing TOML documents. More...

Functions

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_loads (YATL_Doc_t *doc, const char *str, size_t len)
 Load a TOML document from a string.
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_clear_boneyard (YATL_Doc_t *doc)
 Clear the document boneyard.

Detailed Description

Functions for loading, saving, and managing TOML documents.

Function Documentation

◆ YATL_doc_clear_boneyard()

YATL_Result_t YATL_doc_clear_boneyard ( YATL_Doc_t * doc)

Clear the document boneyard.

Frees all lines in the boneyard (lines removed during editing that are kept for potential rollback).

Parameters
docPointer to document
Returns
YATL_OK on success
YATL_ERR_INVALID_ARG if doc is NULL or not initialized
Note
Call this after edits are finalized to free memory.

◆ YATL_doc_create()

YATL_Doc_t YATL_doc_create ( void )

Create an initialized document.

Returns
Initialized document structure
YATL_doc_load(&doc, "config.toml");
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.
struct YATL_Doc YATL_Doc_t
Opaque document structure.

◆ YATL_doc_free()

void YATL_doc_free ( YATL_Doc_t * doc)

Free document resources.

Releases all memory associated with the document, including active lines and boneyard lines.

Parameters
docPointer to document to free
Note
Safe to call with NULL pointer (no-op).
The document structure itself is not freed, only its contents.

◆ YATL_doc_load()

YATL_Result_t YATL_doc_load ( YATL_Doc_t * doc,
const char * path )

Load a TOML document from a file.

Reads and parses a TOML file into the document structure.

Parameters
docPointer to initialized document
pathPath to the TOML file
Returns
YATL_OK on success
YATL_ERR_IO if file cannot be opened or read
YATL_ERR_NOMEM if memory allocation fails
YATL_ERR_INVALID_ARG if doc or path is NULL

◆ YATL_doc_loads()

YATL_Result_t YATL_doc_loads ( YATL_Doc_t * doc,
const char * str,
size_t len )

Load a TOML document from a string.

Parses a TOML string into the document structure. The document must be initialized first.

Parameters
docPointer to initialized document
strTOML content string
lenLength of the string in bytes
Returns
YATL_OK on success
YATL_ERR_NOMEM if memory allocation fails
YATL_ERR_INVALID_ARG if doc or str is NULL

◆ YATL_doc_save()

YATL_Result_t YATL_doc_save ( YATL_Doc_t * doc,
const char * path )

Save a document to a file.

Writes the document content to a file, preserving formatting.

Parameters
docPointer to document
pathPath to output file
Returns
YATL_OK on success
YATL_ERR_IO if file cannot be written
YATL_ERR_INVALID_ARG if doc or path is NULL