C ABI: MAT

The experimental MAT C ABI evaluates element, substance, and material expressions and returns owned records containing canonical typed JSON. See C bindings for ownership and buffer conventions.

Typedefs

typedef struct snt_mat_result snt_mat_result

Opaque handle for one evaluated MAT record.

Functions

int snt_mat_element_eval(const char *expression, int natural, const char *number_density, const char *mass_density, const char *volume, const char *mass, snt_mat_result **result, snt_mat_error *error)

Evaluate one element expression.

Matter arguments are optional PUQ quantity expressions; pass NULL or an empty string to omit one. natural uses natural isotope abundances when nonzero and the deterministic default isotope otherwise.

int snt_mat_substance_eval(const char *expression, int natural, const char *number_density, const char *mass_density, const char *volume, const char *mass, snt_mat_result **result, snt_mat_error *error)

Evaluate one chemical formula with the same optional matter arguments.

int snt_mat_material_eval(const char *expression, const char *normalization, int natural, const char *number_density, const char *mass_density, const char *volume, const char *mass, snt_mat_result **result, snt_mat_error *error)

Evaluate one material mixture.

normalization is number, number_fraction, or mass_fraction; NULL selects number_fraction.

int snt_mat_result_json(const snt_mat_result *result, char *buffer, size_t capacity, size_t *required, snt_mat_error *error)

Serialize a MAT record as UTF-8 JSON.

Pass a null buffer and zero capacity to query required, including the terminating NUL. Returns nonzero and reports the required size when the supplied buffer is too small.

void snt_mat_result_free(snt_mat_result *result)

Release a MAT record returned by the C ABI. Accepts null.

struct snt_mat_error
#include <mat.h>

Error code and diagnostic message returned by a MAT ABI function.

Public Members

int code
const char *message