zxsd 0.20.0
Embedded XML Schema validation for C
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
zxsd_bind.h File Reference

Typed data bindings between generated C structures and XML documents. More...

#include "zxsd.h"
#include <stddef.h>
Include dependency graph for zxsd_bind.h:

Go to the source code of this file.

Data Structures

struct  zxsd_bind_field
 Generated descriptor for one member of a bound structure. More...
 
struct  zxsd_bind_type
 Generated descriptor for a bound structure. More...
 
struct  zxsd_bind_namespace_t
 Namespace prefix declared on the root element when writing. More...
 
struct  zxsd_bind_root_t
 Generated descriptor for a bound global element. More...
 
struct  zxsd_bind_arena_t
 Caller-owned bump allocator used when reading a document. More...
 
struct  zxsd_bind_path_step_t
 One generation-time-resolved element step; prefixes are not identities. More...
 
struct  zxsd_bind_selection_t
 Immutable selection emitted by zxsdc --stream-bind. More...
 
struct  zxsd_bind_stream_frame_t
 Internal binding frame, exposed only for static allocation. More...
 
struct  zxsd_bind_stream_t
 Single-pass validating typed reader with caller-owned, reusable storage. More...
 
struct  zxsd_bind_runtime_config_t
 Binding-specific layout stamp; initialize with ZXSD_BIND_RUNTIME_CONFIG_INIT. More...
 

Macros

#define ZXSD_BIND_NO_OFFSET   ((size_t)(-1))
 Offset value marking an absent presence or count member.
 
#define ZXSD_BIND_RUNTIME_CONFIG_INIT
 Initialize a binding stamp using the application's headers and compile definitions.
 

Typedefs

typedef struct zxsd_bind_field zxsd_bind_field_t
 Generated descriptor for one member of a bound structure.
 
typedef struct zxsd_bind_type zxsd_bind_type_t
 Generated descriptor for a bound structure.
 
typedef const zxsd_schema_t *(* zxsd_bind_schema_fn) (void)
 Access a generated schema descriptor.
 
typedef int(* zxsd_bind_sink_fn) (void *context, const char *data, size_t length)
 Output callback used by zxsd_bind_write.
 
typedef zxsd_bind_action_t(* zxsd_bind_item_fn) (void *user_data, const void *object)
 Receive one complete, locally validated selected subtree.
 

Enumerations

enum  zxsd_bind_kind_t {
  ZXSD_BIND_STRING = 0 , ZXSD_BIND_BOOLEAN , ZXSD_BIND_INT8 , ZXSD_BIND_UINT8 ,
  ZXSD_BIND_INT16 , ZXSD_BIND_UINT16 , ZXSD_BIND_INT32 , ZXSD_BIND_UINT32 ,
  ZXSD_BIND_INT64 , ZXSD_BIND_UINT64 , ZXSD_BIND_ENUM , ZXSD_BIND_COMPLEX
}
 C representation of one bound value. More...
 
enum  zxsd_bind_role_t { ZXSD_BIND_ATTRIBUTE = 0 , ZXSD_BIND_ELEMENT , ZXSD_BIND_CONTENT }
 XML item carrying a bound value. More...
 
enum  zxsd_bind_storage_t { ZXSD_BIND_INLINE = 0 , ZXSD_BIND_POINTER , ZXSD_BIND_ARRAY }
 Storage layout of a bound member inside its structure. More...
 
enum  zxsd_bind_action_t { ZXSD_BIND_CONTINUE = 0 , ZXSD_BIND_VALIDATE_ONLY , ZXSD_BIND_CALLBACK_ERROR }
 Next action after one locally validated, typed subtree has been delivered. More...
 

Functions

void zxsd_bind_arena_init (zxsd_bind_arena_t *arena, void *storage, size_t capacity)
 Initialize a reading arena over caller-provided storage.
 
void ZXSD_BINDING_ABI_GUARD (void)
 Link-time binding ABI guard used by generated code; no side effects.
 
zxsd_result_t zxsd_bind_check_runtime (const zxsd_bind_runtime_config_t *expected)
 Check core configuration and binding layout sizes before using bindings.
 
zxsd_result_t zxsd_bind_stream_init (zxsd_bind_stream_t *reader, const zxsd_bind_selection_t *selection, void *object, zxsd_bind_arena_t *arena, zxsd_bind_item_fn callback, void *user_data, const zxsd_allocator_t *allocator)
 Initialize a single-pass selected-subtree binding reader.
 
zxsd_result_t zxsd_bind_stream_feed (zxsd_bind_stream_t *reader, const void *data, size_t length)
 Consume arbitrary raw XML bytes without retaining the fragment.
 
zxsd_result_t zxsd_bind_stream_finish (zxsd_bind_stream_t *reader)
 Finish parsing and validate document-wide constraints.
 
void zxsd_bind_stream_dispose (zxsd_bind_stream_t *reader)
 Release identity scratch, clear output, and restore the borrowed arena.
 
zxsd_result_t zxsd_bind_read (const zxsd_bind_root_t *root, const char *xml, void *object, zxsd_bind_arena_t *arena)
 Validate a document and fill a bound structure from it.
 
zxsd_result_t zxsd_bind_read_with_allocator (const zxsd_bind_root_t *root, const char *xml, void *object, zxsd_bind_arena_t *arena, const zxsd_allocator_t *allocator)
 Read like zxsd_bind_read, validating with a scratch allocator.
 
zxsd_result_t zxsd_bind_write (const zxsd_bind_root_t *root, const void *object, zxsd_bind_sink_fn sink, void *context, zxsd_stream_t *validator)
 Serialize a bound structure as an XML document.
 
zxsd_result_t zxsd_bind_write_buffer (const zxsd_bind_root_t *root, const void *object, char *buffer, size_t capacity, size_t *length)
 Serialize a bound structure into a buffer and validate the result.
 
zxsd_result_t zxsd_bind_write_buffer_with_allocator (const zxsd_bind_root_t *root, const void *object, char *buffer, size_t capacity, size_t *length, const zxsd_allocator_t *allocator)
 Write like zxsd_bind_write_buffer, validating with a scratch allocator.
 

Detailed Description

Typed data bindings between generated C structures and XML documents.

Bindings are generated by zxsdc --bindings. Each binding pairs a generated C structure with immutable descriptor tables interpreted by this runtime. The runtime does not allocate memory:

Definition in file zxsd_bind.h.