.TH "hyle/registry.h" 3 "libhyle" \" -*- nroff -*- .ad l .nh .SH NAME hyle/registry.h \- Source registry and the CRUD / view operations behind it\&. .SH SYNOPSIS .br .PP \fR#include \fP .br \fR#include \fP .br \fR#include 'ctx\&.h'\fP .br \fR#include 'field\&.h'\fP .br \fR#include 'query\&.h'\fP .br .SS "Data Structures" .in +1c .ti -1c .RI "struct \fBhyle_ffi_row_t\fP" .br .RI "Flat row representation for FFI (Rust bridge) consumers\&. " .in -1c .SS "Macros" .in +1c .ti -1c .RI "#define \fBHYLE_REGISTRY_AUTO_RECORD\fP 0x01 /* Auto\-create corm record from field metadata */" .br .RI "Auto-create the corm record type from the field metadata\&. " .in -1c .SS "Typedefs" .in +1c .ti -1c .RI "typedef int(* \fBhyle_persist_load_fn\fP) (const char *source_id, const char *partition_val, unsigned fields_hd, void *user)" .br .RI "Load callback for ordered sources\&. " .ti -1c .RI "typedef int(* \fBhyle_persist_save_fn\fP) (const char *source_id, const char *partition_val, unsigned fields_hd, void *user)" .br .RI "Save callback for ordered sources\&. " .ti -1c .RI "typedef const char *(* \fBhyle_derive_fn_t\fP) (const void *def, const char *row_id, const char *field_name, void *user)" .br .RI "Provider signature for derived field values\&. " .in -1c .SS "Functions" .in +1c .ti -1c .RI "unsigned \fBhyle_registry_register\fP (const char *source_id, const \fBhyle_field_t\fP *fields, size_t field_count, uint32_t record_id, unsigned flags, void *user)" .br .RI "Register a source with row and field value maps\&. " .ti -1c .RI "int \fBhyle_registry_put\fP (const char *source_id, const char *row_id, const char **names, const char **values, size_t count)" .br .RI "Add or update a row in a registered source\&. " .ti -1c .RI "int \fBhyle_registry_put_tokens\fP (const char *source_id, const char *row_id, const char *field, const uint16_t *tokens, size_t n_tokens)" .br .RI "Put a tokenized field into the registry for (source_id, row_id, field)\&. " .ti -1c .RI "const char * \fBhyle_field_get_str\fP (const char *source_id, const char *row_id, const char *field)" .br .RI "Get a field value as a string for (row_id, field_name)\&. " .ti -1c .RI "void \fBhyle_registry_del\fP (const char *source_id, const char *row_id)" .br .RI "Delete a row and all of its field values from a source\&. " .ti -1c .RI "int \fBhyle_registry_query\fP (const char *source_id, const \fBhyle_query_t\fP *query, \fBhyle_row_set_t\fP *out, size_t *total_out)" .br .RI "Run the filter, sort and paginate pipeline over a source\&. " .ti -1c .RI "void \fBhyle_row_set_free\fP (\fBhyle_row_set_t\fP *rs)" .br .RI "Free the row map handle held by a row set\&. " .ti -1c .RI "unsigned \fBhyle_registry_get_row_hd\fP (const char *source_id)" .br .RI "Look up the row map handle of a registered source\&. " .ti -1c .RI "unsigned \fBhyle_registry_get_fields_hd\fP (const char *source_id)" .br .RI "Look up the fields map handle of a registered source\&. " .ti -1c .RI "void * \fBhyle_registry_get_user\fP (const char *source_id)" .br .RI "Retrieve the opaque user pointer stored for a source\&. " .ti -1c .RI "void \fBhyle_registry_set_user\fP (const char *source_id, void *user)" .br .RI "Replace the opaque user pointer stored for a source\&. " .ti -1c .RI "size_t \fBhyle_registry_count\fP (void)" .br .RI "Number of currently registered sources\&. " .ti -1c .RI "const char * \fBhyle_registry_id_at\fP (size_t i)" .br .RI "Get the id of the source at a registry index\&. " .ti -1c .RI "size_t \fBhyle_registry_get_field_count\fP (const char *source_id)" .br .RI "Get the field count of a registered source\&. " .ti -1c .RI "const char * \fBhyle_registry_get_field_name\fP (const char *source_id, size_t idx)" .br .RI "Get the name of the field at an index of a source\&. " .ti -1c .RI "\fBhyle_field_type_t\fP \fBhyle_registry_get_field_type\fP (const char *source_id, size_t idx)" .br .RI "Get the type of the field at an index of a source\&. " .ti -1c .RI "int \fBhyle_row_set_to_rows\fP (const \fBhyle_row_set_t\fP *rs, \fBhyle_ffi_row_t\fP **rows_out, size_t *count_out)" .br .RI "Convert a row set into a flat array of FFI rows\&. " .ti -1c .RI "void \fBhyle_rows_free\fP (\fBhyle_ffi_row_t\fP *rows, size_t count)" .br .RI "Free an FFI row array returned by \fBhyle_row_set_to_rows()\fP\&. " .ti -1c .RI "unsigned \fBhyle_ordered_register\fP (const char *source_id, const \fBhyle_field_t\fP *fields, size_t field_count, const char *partition_field, uint32_t record_id, unsigned flags, \fBhyle_persist_load_fn\fP load_fn, \fBhyle_persist_save_fn\fP save_fn, void *persist_user)" .br .RI "Register an ordered, partitioned positional-array source\&. " .ti -1c .RI "int \fBhyle_ordered_count\fP (const char *source_id, const char *partition_val)" .br .RI "Count the items in an ordered partition\&. " .ti -1c .RI "const char * \fBhyle_ordered_key_at\fP (const char *source_id, const char *partition_val, int pos)" .br .RI "Get the storage key of the item at a partition position\&. " .ti -1c .RI "int \fBhyle_ordered_append\fP (const char *source_id, const char *partition_val, const char **names, const char **values, size_t count)" .br .RI "Append an item to the end of a partition and trigger save\&. " .ti -1c .RI "int \fBhyle_ordered_insert_at\fP (const char *source_id, const char *partition_val, int pos, const char **names, const char **values, size_t count)" .br .RI "Insert an item at a partition position, shifting later items up\&. " .ti -1c .RI "void \fBhyle_ordered_remove_at\fP (const char *source_id, const char *partition_val, int pos)" .br .RI "Remove the item at a partition position and trigger save\&. " .ti -1c .RI "void \fBhyle_ordered_clear\fP (const char *source_id, const char *partition_val)" .br .RI "Remove every item in a partition and trigger save\&. " .ti -1c .RI "void \fBhyle_ordered_save\fP (const char *source_id, const char *partition_val)" .br .RI "Explicitly trigger the save callback for a partition\&. " .ti -1c .RI "int \fBhyle_derive_register\fP (const char *derive_key, \fBhyle_derive_fn_t\fP fn, void *user)" .br .RI "Register a derive provider under a derive key\&. " .ti -1c .RI "const char * \fBhyle_derive_call\fP (const void *def, const char *derive_key, const char *row_id, const char *field_name, void *user)" .br .RI "Look up and invoke the provider for a derive key\&. " .in -1c .SH "Detailed Description" .PP Source registry and the CRUD / view operations behind it\&. Registers sources (plain or ordered), writes rows into their corms, and runs filter → sort → paginate queries against them; also the derive-function registry used during index rebuild\&. .SH "Typedef Documentation" .PP .SS "typedef const char *(* hyle_derive_fn_t) (const void *def, const char *row_id, const char *field_name, void *user)" .PP Provider signature for derived field values\&. .PP \fBParameters\fP .RS 4 \fIdef\fP Opaque source definition (user pointer)\&. .br \fIrow_id\fP Row identifier\&. .br \fIfield_name\fP Name of the derived field being queried\&. .br \fIuser\fP Opaque user data (unused)\&. .RE .PP \fBReturns\fP .RS 4 Pointer to a static/thread-local value buffer (caller must not free), or NULL when there is no value\&. .RE .PP .SS "typedef int(* hyle_persist_load_fn) (const char *source_id, const char *partition_val, unsigned fields_hd, void *user)" .PP Load callback for ordered sources\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .br \fIpartition_val\fP Partition whose items must be loaded\&. .br \fIfields_hd\fP Fields map handle to populate\&. .br \fIuser\fP Opaque pointer passed at registration\&. .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure\&. .RE .PP .SS "typedef int(* hyle_persist_save_fn) (const char *source_id, const char *partition_val, unsigned fields_hd, void *user)" .PP Save callback for ordered sources\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .br \fIpartition_val\fP Partition whose items must be persisted\&. .br \fIfields_hd\fP Fields map handle holding the items\&. .br \fIuser\fP Opaque pointer passed at registration\&. .RE .PP \fBReturns\fP .RS 4 0 on success, non-zero on failure\&. .RE .PP .SH "Function Documentation" .PP .SS "const char * hyle_derive_call (const void * def, const char * derive_key, const char * row_id, const char * field_name, void * user)" .PP Look up and invoke the provider for a derive key\&. .PP \fBParameters\fP .RS 4 \fIdef\fP Opaque source definition passed to the provider\&. .br \fIderive_key\fP Key registering the provider to call\&. .br \fIrow_id\fP Row identifier\&. .br \fIfield_name\fP Name of the derived field being queried\&. .br \fIuser\fP Opaque user data (unused)\&. .RE .PP \fBReturns\fP .RS 4 The provider's value, or NULL when no provider is registered\&. .RE .PP .SS "int hyle_derive_register (const char * derive_key, \fBhyle_derive_fn_t\fP fn, void * user)" .PP Register a derive provider under a derive key\&. .PP \fBParameters\fP .RS 4 \fIderive_key\fP Key matching \fBhyle_field_t\&.derive_key\fP\&. .br \fIfn\fP Provider function\&. .br \fIuser\fP Opaque user data passed to fn\&. .RE .PP \fBReturns\fP .RS 4 0 on success, or -1 when the provider table is full\&. .RE .PP .SS "const char * hyle_field_get_str (const char * source_id, const char * row_id, const char * field)" .PP Get a field value as a string for (row_id, field_name)\&. If the field was stored as a tokenized stream, decodes it on-demand into a thread-local buffer without heap allocation\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Dataset ID\&. .br \fIrow_id\fP Row ID\&. .br \fIfield\fP Field name\&. .RE .PP \fBReturns\fP .RS 4 String pointer (caller does not free), or NULL if not found\&. .RE .PP .SS "int hyle_ordered_append (const char * source_id, const char * partition_val, const char ** names, const char ** values, size_t count)" .PP Append an item to the end of a partition and trigger save\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered ordered source id\&. .br \fIpartition_val\fP Partition to append to\&. .br \fInames\fP Field names\&. .br \fIvalues\fP Parallel field values\&. .br \fIcount\fP Number of name/value pairs\&. .RE .PP \fBReturns\fP .RS 4 0 on success, or -1 when the partition cannot be loaded\&. .RE .PP .SS "void hyle_ordered_clear (const char * source_id, const char * partition_val)" .PP Remove every item in a partition and trigger save\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered ordered source id\&. .br \fIpartition_val\fP Partition to clear\&. .RE .PP .SS "int hyle_ordered_count (const char * source_id, const char * partition_val)" .PP Count the items in an ordered partition\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered ordered source id\&. .br \fIpartition_val\fP Partition to count\&. .RE .PP \fBReturns\fP .RS 4 The item count (zero when the partition is unloaded or absent)\&. .RE .PP .SS "int hyle_ordered_insert_at (const char * source_id, const char * partition_val, int pos, const char ** names, const char ** values, size_t count)" .PP Insert an item at a partition position, shifting later items up\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered ordered source id\&. .br \fIpartition_val\fP Partition holding the item\&. .br \fIpos\fP Zero-based insertion position\&. .br \fInames\fP Field names\&. .br \fIvalues\fP Parallel field values\&. .br \fIcount\fP Number of name/value pairs\&. .RE .PP \fBReturns\fP .RS 4 0 on success, or -1 when the position is out of range\&. .RE .PP .SS "const char * hyle_ordered_key_at (const char * source_id, const char * partition_val, int pos)" .PP Get the storage key of the item at a partition position\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered ordered source id\&. .br \fIpartition_val\fP Partition holding the item\&. .br \fIpos\fP Zero-based item position\&. .RE .PP \fBReturns\fP .RS 4 The "{partition_val}__{NNNN}" key in a static buffer (valid until the next call), or NULL when the item does not exist\&. .RE .PP .SS "unsigned hyle_ordered_register (const char * source_id, const \fBhyle_field_t\fP * fields, size_t field_count, const char * partition_field, uint32_t record_id, unsigned flags, \fBhyle_persist_load_fn\fP load_fn, \fBhyle_persist_save_fn\fP save_fn, void * persist_user)" .PP Register an ordered, partitioned positional-array source\&. Items within a partition are addressed by zero-based position and stored under "{partition_val}__{NNNN}" keys\&. When HYLE_REGISTRY_AUTO_RECORD is set and record_id is 0, the record type is derived from the field metadata\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Unique id identifying the source\&. .br \fIfields\fP Array of field descriptors\&. .br \fIfield_count\fP Number of entries in fields\&. .br \fIpartition_field\fP Field scoping items to a partition\&. .br \fIrecord_id\fP Corm record type id, or 0 for plain maps\&. .br \fIflags\fP Extra flags (e\&.g\&. HYLE_REGISTRY_AUTO_RECORD)\&. .br \fIload_fn\fP Load callback, or NULL\&. .br \fIsave_fn\fP Save callback, or NULL\&. .br \fIpersist_user\fP Opaque pointer passed to the callbacks\&. .RE .PP \fBReturns\fP .RS 4 The fields map handle on success, or 0 on error\&. .RE .PP .SS "void hyle_ordered_remove_at (const char * source_id, const char * partition_val, int pos)" .PP Remove the item at a partition position and trigger save\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered ordered source id\&. .br \fIpartition_val\fP Partition holding the item\&. .br \fIpos\fP Zero-based item position to remove\&. .RE .PP .SS "void hyle_ordered_save (const char * source_id, const char * partition_val)" .PP Explicitly trigger the save callback for a partition\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered ordered source id\&. .br \fIpartition_val\fP Partition to persist\&. .RE .PP .SS "size_t hyle_registry_count (void )" .PP Number of currently registered sources\&. .PP \fBReturns\fP .RS 4 The registry size\&. .RE .PP .SS "void hyle_registry_del (const char * source_id, const char * row_id)" .PP Delete a row and all of its field values from a source\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .br \fIrow_id\fP Row identifier to remove\&. .RE .PP .SS "size_t hyle_registry_get_field_count (const char * source_id)" .PP Get the field count of a registered source\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .RE .PP \fBReturns\fP .RS 4 The field count, or 0 when the source is unknown\&. .RE .PP .SS "const char * hyle_registry_get_field_name (const char * source_id, size_t idx)" .PP Get the name of the field at an index of a source\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .br \fIidx\fP Field index\&. .RE .PP \fBReturns\fP .RS 4 The field name, or NULL when the source or index is invalid\&. .RE .PP .SS "\fBhyle_field_type_t\fP hyle_registry_get_field_type (const char * source_id, size_t idx)" .PP Get the type of the field at an index of a source\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .br \fIidx\fP Field index\&. .RE .PP \fBReturns\fP .RS 4 The field type, or 0 when the source or index is invalid\&. .RE .PP .SS "unsigned hyle_registry_get_fields_hd (const char * source_id)" .PP Look up the fields map handle of a registered source\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .RE .PP \fBReturns\fP .RS 4 The fields map handle, or 0 when the source is unknown\&. .RE .PP .SS "unsigned hyle_registry_get_row_hd (const char * source_id)" .PP Look up the row map handle of a registered source\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .RE .PP \fBReturns\fP .RS 4 The row map handle, or 0 when the source is unknown\&. .RE .PP .SS "void * hyle_registry_get_user (const char * source_id)" .PP Retrieve the opaque user pointer stored for a source\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .RE .PP \fBReturns\fP .RS 4 The stored pointer, or NULL when the source is unknown\&. .RE .PP .SS "const char * hyle_registry_id_at (size_t i)" .PP Get the id of the source at a registry index\&. .PP \fBParameters\fP .RS 4 \fIi\fP Registry index\&. .RE .PP \fBReturns\fP .RS 4 The source id, or NULL when i is out of range\&. .RE .PP .SS "int hyle_registry_put (const char * source_id, const char * row_id, const char ** names, const char ** values, size_t count)" .PP Add or update a row in a registered source\&. Writes the row id into the row map and each name/value pair into the fields map, marking any full-text index dirty\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .br \fIrow_id\fP Row identifier\&. .br \fInames\fP Field names\&. .br \fIvalues\fP Parallel field values\&. .br \fIcount\fP Number of name/value pairs\&. .RE .PP \fBReturns\fP .RS 4 0 on success, or -1 when the source or row id is invalid\&. .RE .PP .SS "int hyle_registry_put_tokens (const char * source_id, const char * row_id, const char * field, const uint16_t * tokens, size_t n_tokens)" .PP Put a tokenized field into the registry for (source_id, row_id, field)\&. Encodes the token stream with compact prefix \\x1bT and stores it in fields_hd\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Dataset ID\&. .br \fIrow_id\fP Row ID\&. .br \fIfield\fP Field name\&. .br \fItokens\fP Array of token IDs\&. .br \fIn_tokens\fP Token count\&. .RE .PP \fBReturns\fP .RS 4 0 on success, -1 on error\&. .RE .PP .SS "int hyle_registry_query (const char * source_id, const \fBhyle_query_t\fP * query, \fBhyle_row_set_t\fP * out, size_t * total_out)" .PP Run the filter, sort and paginate pipeline over a source\&. Performs full-text, multi-reference and reference pre-filtering for typed-record sources before delegating to \fBhyle_apply_view()\fP\&. The caller must call \fBhyle_row_set_free()\fP on *out when done\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .br \fIquery\fP Parsed view state to apply\&. .br \fIout\fP Receives the resulting row set\&. .br \fItotal_out\fP Receives the total matching row count, or NULL\&. .RE .PP \fBReturns\fP .RS 4 0 on success, or -1 when the source is unknown or allocation fails\&. .RE .PP .SS "unsigned hyle_registry_register (const char * source_id, const \fBhyle_field_t\fP * fields, size_t field_count, uint32_t record_id, unsigned flags, void * user)" .PP Register a source with row and field value maps\&. Creates the row map (row_hd) and the fields map (fields_hd) for the source, optionally as a typed record corm when record_id is non-zero, and stores the field schema and opaque user pointer for later queries\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Unique id identifying the source\&. .br \fIfields\fP Array of field descriptors\&. .br \fIfield_count\fP Number of entries in fields\&. .br \fIrecord_id\fP Corm record type id, or 0 for plain maps\&. .br \fIflags\fP Extra corm flags for the row map\&. .br \fIuser\fP Opaque pointer stored by the registry\&. .RE .PP \fBReturns\fP .RS 4 The fields map handle on success, or 0 on error\&. .RE .PP .SS "void hyle_registry_set_user (const char * source_id, void * user)" .PP Replace the opaque user pointer stored for a source\&. .PP \fBParameters\fP .RS 4 \fIsource_id\fP Registered source id\&. .br \fIuser\fP New pointer to store\&. .RE .PP .SS "void hyle_row_set_free (\fBhyle_row_set_t\fP * rs)" .PP Free the row map handle held by a row set\&. .PP \fBParameters\fP .RS 4 \fIrs\fP Row set to release, or NULL\&. .RE .PP .SS "int hyle_row_set_to_rows (const \fBhyle_row_set_t\fP * rs, \fBhyle_ffi_row_t\fP ** rows_out, size_t * count_out)" .PP Convert a row set into a flat array of FFI rows\&. .PP \fBParameters\fP .RS 4 \fIrs\fP Row set to convert\&. .br \fIrows_out\fP Receives the row array (call \fBhyle_rows_free()\fP)\&. .br \fIcount_out\fP Receives the number of rows\&. .RE .PP \fBReturns\fP .RS 4 0 on success, or -1 on invalid arguments or allocation failure\&. .RE .PP .SS "void hyle_rows_free (\fBhyle_ffi_row_t\fP * rows, size_t count)" .PP Free an FFI row array returned by \fBhyle_row_set_to_rows()\fP\&. .PP \fBParameters\fP .RS 4 \fIrows\fP Array of rows, or NULL\&. .br \fIcount\fP Number of entries in rows\&. .RE .PP .SH "Author" .PP Generated automatically by Doxygen for libhyle from the source code\&.