FDL Core Library
ASC Framing Decision List — C/C++ Reference Implementation
Loading...
Searching...
No Matches
Functions
fdl_doc_api.cpp File Reference

C ABI wrappers for document creation, parsing, serialization, and memory management. More...

#include "fdl/fdl_core.h"
#include "fdl_compat.h"
#include "fdl_constants.h"
#include "fdl_doc.h"
#include <cstring>
#include <functional>
#include <new>
#include <string>
#include <unordered_map>
#include "fdl_tl_cache.h"

Functions

fdl_doc_tfdl_doc_create (void)
 Create an empty FDL document.
 
void fdl_doc_free (fdl_doc_t *doc)
 Free an FDL document and all associated handles.
 
fdl_parse_result_t fdl_doc_parse_json (const char *json_str, size_t json_len)
 Parse a JSON string into an FDL document.
 
const char * fdl_doc_get_uuid (const fdl_doc_t *doc)
 Get the UUID from a parsed FDL document.
 
const char * fdl_doc_get_fdl_creator (const fdl_doc_t *doc)
 Get the fdl_creator from a parsed FDL document.
 
const char * fdl_doc_get_default_framing_intent (const fdl_doc_t *doc)
 Get the default_framing_intent from a parsed FDL document.
 
char * fdl_doc_to_json (const fdl_doc_t *doc, int indent)
 Serialize document to canonical JSON string.
 

Detailed Description

C ABI wrappers for document creation, parsing, serialization, and memory management.

Function Documentation

◆ fdl_doc_create()

fdl_doc_t * fdl_doc_create ( void  )

Create an empty FDL document.

Returns
New document handle, or NULL on allocation failure. Caller owns — free with fdl_doc_free().

◆ fdl_doc_free()

void fdl_doc_free ( fdl_doc_t doc)

Free an FDL document and all associated handles.

After this call, all handles (contexts, canvases, framing decisions, etc.) obtained from this document are invalid. Safe to call with NULL.

Parameters
docDocument to free, or NULL (no-op).

◆ fdl_doc_parse_json()

fdl_parse_result_t fdl_doc_parse_json ( const char *  json_str,
size_t  json_len 
)

Parse a JSON string into an FDL document.

Parameters
json_strJSON string to parse (need not be null-terminated).
json_lenLength of json_str in bytes.
Returns
Parse result. On success, result.doc is non-NULL (caller owns, free with fdl_doc_free). On failure, result.error is non-NULL (caller owns, free with fdl_free).

< POSIX strdup.

< POSIX strdup.

< POSIX strdup.

◆ fdl_doc_get_uuid()

const char * fdl_doc_get_uuid ( const fdl_doc_t doc)

Get the UUID from a parsed FDL document.

Parameters
docDocument to query.
Returns
UUID string, or NULL if not present. Pointer valid until doc is freed.

◆ fdl_doc_get_fdl_creator()

const char * fdl_doc_get_fdl_creator ( const fdl_doc_t doc)

Get the fdl_creator from a parsed FDL document.

Parameters
docDocument to query.
Returns
Creator string, or NULL if not present. Pointer valid until doc is freed.

◆ fdl_doc_get_default_framing_intent()

const char * fdl_doc_get_default_framing_intent ( const fdl_doc_t doc)

Get the default_framing_intent from a parsed FDL document.

Parameters
docDocument to query.
Returns
Default framing intent ID, or NULL if not present. Pointer valid until doc is freed.

◆ fdl_doc_to_json()

char * fdl_doc_to_json ( const fdl_doc_t doc,
int  indent 
)

Serialize document to canonical JSON string.

Keys are ordered per the FDL specification; null values are excluded.

Parameters
docDocument to serialize.
indentNumber of spaces per indent level (0 for compact JSON).
Returns
Heap-allocated JSON string. Caller owns — free with fdl_free(). Returns NULL if doc is NULL.

< POSIX strdup.