CYAML Internals
|
Load YAML data into client's data structure. More...
#include <inttypes.h>
#include <stdbool.h>
#include <assert.h>
#include <limits.h>
#include <errno.h>
#include <yaml.h>
#include "mem.h"
#include "data.h"
#include "util.h"
Data Structures | |
struct | cyaml_state |
struct | cyaml_anchor |
struct | cyaml_event_record |
struct | cyaml_event_replay |
struct | cyaml_event_ctx |
struct | cyaml_ctx |
Macros | |
#define | CYAML_FIELDS_IDX_NONE 0xffff |
Typedefs | |
typedef enum cyaml_event | cyaml_event_t |
typedef struct cyaml_state | cyaml_state_t |
typedef struct cyaml_anchor | cyaml_anchor_t |
typedef struct cyaml_event_record | cyaml_event_record_t |
typedef struct cyaml_event_replay | cyaml_event_replay_t |
typedef struct cyaml_event_ctx | cyaml_event_ctx_t |
typedef struct cyaml_ctx | cyaml_ctx_t |
Enumerations | |
enum | cyaml_event { CYAML_EVT_NO_EVENT = YAML_NO_EVENT, CYAML_EVT_STRM_START = YAML_STREAM_START_EVENT, CYAML_EVT_STRM_END = YAML_STREAM_END_EVENT, CYAML_EVT_DOC_START = YAML_DOCUMENT_START_EVENT, CYAML_EVT_DOC_END = YAML_DOCUMENT_END_EVENT, CYAML_EVT_ALIAS = YAML_ALIAS_EVENT, CYAML_EVT_SCALAR = YAML_SCALAR_EVENT, CYAML_EVT_SEQ_START = YAML_SEQUENCE_START_EVENT, CYAML_EVT_SEQ_END = YAML_SEQUENCE_END_EVENT, CYAML_EVT_MAP_START = YAML_MAPPING_START_EVENT, CYAML_EVT_MAP_END = YAML_MAPPING_END_EVENT, CYAML_EVT__COUNT } |
Functions | |
static cyaml_event_t | cyaml__get_event_type (const yaml_event_t *event) |
static const char * | cyaml__libyaml_event_type_str (const yaml_event_t *event) |
static const char * | cyaml__get_yaml_event_anchor (const yaml_event_t *event) |
static const char * | cyaml__get_yaml_event_alias (const yaml_event_t *event) |
static cyaml_err_t | cyaml__handle_alias (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__new_anchor (cyaml_ctx_t *ctx, uint32_t *anchors_count, cyaml_anchor_t **anchors) |
static cyaml_err_t | cyaml__handle_anchor (cyaml_ctx_t *ctx, const yaml_event_t *event, bool *is_anchor_out) |
static cyaml_err_t | cyaml__record_stack_push (cyaml_ctx_t *ctx, uint32_t event_index) |
static cyaml_err_t | cyaml__record_stack_pop (cyaml_ctx_t *ctx, uint32_t event_index) |
static cyaml_err_t | cyaml__update_anchor_recordings (cyaml_ctx_t *ctx, uint32_t event_index, const yaml_event_t *event) |
static cyaml_err_t | cyaml__handle_record (cyaml_ctx_t *ctx, const yaml_event_t *event, bool replayed_event, uint32_t replay_event_index) |
static void | cyaml__handle_replay (cyaml_ctx_t *ctx, yaml_event_t *event_out, uint32_t *event_index_out) |
static void | cyaml__delete_yaml_event (cyaml_ctx_t *ctx) |
static void | cyaml__free_recording (cyaml_ctx_t *ctx) |
static cyaml_err_t | cyaml_get_next_event (cyaml_ctx_t *ctx) |
static const yaml_event_t * | cyaml__current_event (const cyaml_ctx_t *ctx) |
static uint16_t | cyaml__get_mapping_field_idx (const cyaml_config_t *cfg, const cyaml_schema_value_t *schema, const char *key) |
static const cyaml_schema_field_t * | cyaml_mapping_schema_field (const cyaml_ctx_t *ctx) |
static cyaml_err_t | cyaml__stack_ensure (cyaml_ctx_t *ctx) |
static uint16_t | cyaml__get_mapping_field_count (const cyaml_schema_field_t *mapping_schema) |
static cyaml_err_t | cyaml__mapping_bitfieid_create (cyaml_ctx_t *ctx, cyaml_state_t *state) |
static void | cyaml__mapping_bitfieid_destroy (const cyaml_ctx_t *ctx, cyaml_state_t *state) |
static void | cyaml__mapping_bitfieid_set (const cyaml_ctx_t *ctx) |
static bool | cyaml__mapping_bitfieid_check (const cyaml_ctx_t *ctx) |
static cyaml_err_t | cyaml__mapping_bitfieid_validate (const cyaml_ctx_t *ctx) |
static bool | cyaml__is_sequence (const cyaml_schema_value_t *schema) |
static cyaml_err_t | cyaml__stack_push (cyaml_ctx_t *ctx, enum cyaml_state_e state, const cyaml_schema_value_t *schema, cyaml_data_t *data) |
static void | cyaml__stack_pop (cyaml_ctx_t *ctx) |
static cyaml_err_t | cyaml__validate_event_type_for_schema (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const yaml_event_t *event) |
static cyaml_err_t | cyaml__data_handle_pointer (cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const yaml_event_t *event, uint8_t **value_data_io) |
static void | cyaml__backtrace (cyaml_ctx_t *ctx) |
static cyaml_err_t | cyaml__read_int (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, uint8_t *data) |
static cyaml_err_t | cyaml__read_uint64_t (const char *value, uint64_t *out) |
static cyaml_err_t | cyaml__read_uint (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, uint8_t *data) |
static cyaml_err_t | cyaml__read_bool (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, uint8_t *data) |
static cyaml_err_t | cyaml__read_enum (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, uint8_t *data) |
static cyaml_err_t | cyaml__read_float_f (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, uint8_t *data) |
static cyaml_err_t | cyaml__read_float_d (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, uint8_t *data) |
static cyaml_err_t | cyaml__read_float (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, uint8_t *data) |
static cyaml_err_t | cyaml__read_string (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, uint8_t *data) |
static cyaml_err_t | cyaml__read_scalar_value (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, cyaml_data_t *data, const yaml_event_t *event) |
static cyaml_err_t | cyaml__set_flag (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, uint64_t *flags_out) |
static cyaml_err_t | cyaml__read_flags_value (cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, cyaml_data_t *data) |
static cyaml_err_t | cyaml__get_bitval_index (cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, uint32_t *index_out) |
static cyaml_err_t | cyaml__set_bitval (cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, uint64_t *bits_out) |
static cyaml_err_t | cyaml__read_bitfield_value (cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, cyaml_data_t *data) |
static cyaml_err_t | cyaml__consume_ignored_value (cyaml_ctx_t *ctx, cyaml_event_t cyaml_event) |
static bool | cyaml__string_is_null_ptr (const cyaml_schema_value_t *schema, const char *value) |
static cyaml_err_t | cyaml__read_value (cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, uint8_t *data, const yaml_event_t *event) |
static cyaml_err_t | cyaml__stream_start (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__doc_start (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__stream_end (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__doc_root_value (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__doc_end (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__map_key_check_field (const cyaml_ctx_t *ctx) |
static cyaml_err_t | cyaml__map_key (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__map_end (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__map_value (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__seq_entry (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__seq_end (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__validate_load_params (const cyaml_config_t *config, const cyaml_schema_value_t *schema, cyaml_data_t *const *data_tgt, const unsigned *seq_count_tgt) |
static cyaml_err_t | cyaml__load_event (cyaml_ctx_t *ctx, const yaml_event_t *event) |
static cyaml_err_t | cyaml__load (const cyaml_config_t *config, const cyaml_schema_value_t *schema, cyaml_data_t **data_out, unsigned *seq_count_out, yaml_parser_t *parser) |
cyaml_err_t | cyaml_load_file (const char *path, const cyaml_config_t *config, const cyaml_schema_value_t *schema, cyaml_data_t **data_out, unsigned *seq_count_out) |
cyaml_err_t | cyaml_load_data (const uint8_t *input, size_t input_len, const cyaml_config_t *config, const cyaml_schema_value_t *schema, cyaml_data_t **data_out, unsigned *seq_count_out) |
Load YAML data into client's data structure.
This uses libyaml
to parse YAML documents, it validates the documents against the client provided schema, and uses the schema to place the data in the client's data structure.
#define CYAML_FIELDS_IDX_NONE 0xffff |
Identifies that no mapping schema entry was found for key.
typedef struct cyaml_anchor cyaml_anchor_t |
Anchor data.
This is used to track the progress of recording the anchor's events, and then the data is referenced during replay.
typedef struct cyaml_ctx cyaml_ctx_t |
Internal YAML loading context.
typedef struct cyaml_event_ctx cyaml_event_ctx_t |
CYAML's LibYAML event context.
Only cyaml_get_next_event and friends should poke around inside here. Everything else should use cyaml__current_event to access the current event data, and call cyaml_get_next_event to pump the event stream.
typedef struct cyaml_event_record cyaml_event_record_t |
Event recording context.
This records anchor details, and any anchored events. A stack of events is maintained to keep track of matching start/end events, in order to end anchor recordings with the correct end event.
typedef struct cyaml_event_replay cyaml_event_replay_t |
Event replay context.
typedef enum cyaml_event cyaml_event_t |
CYAML events. These correspond to libyaml
events.
typedef struct cyaml_state cyaml_state_t |
A CYAML load state machine stack entry.
enum cyaml_event |
CYAML events. These correspond to libyaml
events.
|
static |
Dump a backtrace to the log.
[in] | ctx | The CYAML loading context. |
|
static |
Entirely consume an ignored value.
This ignores all the descendants of the value, e.g. if the ignored
key's value is of type CYAML_IGNORE, all of the following is ignored:
[in] | ctx | The CYAML loading context. |
[in] | cyaml_event | The event for the value to ignore. |
|
inlinestatic |
Get a pointer to the load context's current event.
The outside world should use this to get the address of the event data, which will not change for subsequent events. The event should only be used after cyaml_get_next_event() has returned CYAML_OK.
[in] | ctx | The CYAML loading context. |
|
static |
Helper to make allocations for loaded YAML values.
If the current state is sequence, this extends any existing allocation for the sequence.
The current CYAML loading context's state is updated with new allocation address, where necessary.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for value to get data pointer for. |
[in] | event | The YAML event value to get data pointer for. |
[in,out] | value_data_io | Current address of value's data. Updated to new address if value is allocation requiring an allocation. |
|
static |
Delete any current event from the load context.
This gets the next event from the CYAML load context's libyaml
parser object.
[in] | ctx | The CYAML loading context. |
|
static |
YAML loading handler for finalising the CYAML_STATE_IN_DOC state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
YAML loading handler for the root value in the CYAML_STATE_IN_DOC state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
YAML loading handler for documents in the CYAML_STATE_IN_STREAM state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
Free any recordings from the CYAML loading context.
[in] | ctx | The CYAML loading context. |
|
static |
Get bitfield component index for name in a CYAML_BITFIELD value.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[out] | index_out | Returns bitdefs index on success. |
|
inlinestatic |
Get the CYAML event type from a libyaml
event.
[in] | event | The libyaml event. |
|
static |
Count the entries in a mapping field array schema.
The mapping schema array must be terminated by an entry with a NULL key.
[in] | mapping_schema | Array of mapping schema fields. |
|
inlinestatic |
Get the offset to a mapping field by key in a mapping schema array.
[in] | cfg | The client's CYAML library config. |
[in] | schema | CYAML schema for the mapping value to be loaded. |
[in] | key | Key to search for in mapping schema. |
|
static |
Get the anchor name for an alias event.
[in] | event | The libyaml event. |
|
static |
Get the anchor name for an event, or NULL if the event isn't an anchor.
[in] | event | The libyaml event. |
|
static |
Handle an alias event.
This searches the know anchors for a match. If a matching anchor is found, it sets the replay context up to play back the recorded events associated with the anchor, setting the replay state to active.
[in] | ctx | The CYAML loading context. |
[in] | event | The libyaml event. |
|
static |
Handle an event that establishes an anchor.
This should not be called while replaying recorded events, or it will try to rebuild anchors we already have.
This is a no-op if the event doesn't establish an anchor. If the event does create an anchor, an anchor entry is added to the recording context.
[in] | ctx | The CYAML loading context. |
[in] | event | The libyaml event to handle any anchor for. |
[out] | is_anchor_out | Returns whether the event creates an anchor. |
|
static |
Handle the recording of the current event.
[in] | ctx | The CYAML loading context. |
[in] | event | The libyaml to record. |
[in] | replayed_event | Whether this event is a replay. |
[in] | replay_event_index | Index in events array of replayed event. |
|
static |
Handle the current event replay.
There must be an active replay before this is called. If this call yields the final event of the anchor, the replay state is disabled.
[in] | ctx | The CYAML loading context. |
[out] | event_out | The libyaml event to fill from the recording. |
[out] | event_index_out | The index in events array of the replayed event. |
|
inlinestatic |
Helper to check if schema is for a CYAML_SEQUENCE type.
[in] | schema | The schema entry for a type. |
|
static |
Convert a libyaml
event to a human readable string.
[in] | event | The libyaml event. |
|
static |
The main YAML loading function.
The public interfaces are wrappers around this.
[in] | config | Client's CYAML configuration structure. |
[in] | schema | CYAML schema for the YAML to be loaded. |
[out] | data_out | Returns the caller-owned loaded data on success. Untouched on failure. |
[out] | seq_count_out | On success, returns the sequence entry count. Untouched on failure. Must be non-NULL if top-level schema type is CYAML_SEQUENCE, otherwise, must be NULL. |
[in] | parser | An initialised libyaml parser object with its input set. |
|
inlinestatic |
YAML loading helper dispatch function.
Dispatches events to the appropriate event handler function for the current combination of load state machine state (from the load context) and event type.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
YAML loading handler for finalising the CYAML_STATE_IN_MAP_KEY state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
YAML loading handler for new mapping fields in the CYAML_STATE_IN_MAP_KEY state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
Check the field against the schema for the current mapping key.
[in] | ctx | The CYAML loading context. |
|
static |
YAML loading handler for the CYAML_STATE_IN_MAP_VALUE state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
Check the bit for current mapping's current field.
Current CYAML load state must be CYAML_STATE_IN_MAP_KEY.
[in] | ctx | The CYAML loading context. |
|
static |
Create CYAML_STATE_IN_MAP_KEY state's bitfield array allocation.
The bitfield is used to record whether the mapping as all the required fields by mapping schema array index.
[in] | ctx | The CYAML loading context. |
[in] | state | CYAML load state for a CYAML_STATE_IN_MAP_KEY state. |
|
static |
Destroy a CYAML_STATE_IN_MAP_KEY state's bitfield array allocation.
[in] | ctx | The CYAML loading context. |
[in] | state | CYAML load state for a CYAML_STATE_IN_MAP_KEY state. |
|
static |
Set the bit for the current mapping's current field, to indicate it exists.
Current CYAML load state must be CYAML_STATE_IN_MAP_KEY.
[in] | ctx | The CYAML loading context. |
|
static |
Check a mapping had all the required fields.
Checks all the bits are set in the bitfield, which correspond to entries in the mapping schema array which are not marked with the CYAML_FLAG_OPTIONAL flag.
Current CYAML load state must be CYAML_STATE_IN_MAP_KEY.
[in] | ctx | The CYAML loading context. |
|
static |
Create new anchor entry at the end of an anchors array.
[in] | ctx | The CYAML loading context. |
[in,out] | anchors_count | Count of anchors in array. Updated on success. |
[in,out] | anchors | Anchors array, updated on success. |
|
static |
Read a value of type CYAML_BITFIELD.
Since CYAML_FLAGS is a composite value (a mapping), rather than a simple scaler, this consumes events from the YAML input stream.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | data | The place to write the value in the output data. |
|
static |
Read a value of type CYAML_BOOL.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | value | String containing scaler value. |
[in] | data | The place to write the value in the output data. |
|
static |
Read a value of type CYAML_ENUM.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | value | String containing scaler value. |
[in] | data | The place to write the value in the output data. |
|
static |
Read a value of type CYAML_FLAGS.
Since CYAML_FLAGS is a composite value (a sequence of scalars), rather than a simple scaler, this consumes events from the YAML input stream.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | data | The place to write the value in the output data. |
|
static |
Read a value of type CYAML_FLOAT.
The data_size
of the schema entry must be the size of a known floating point C type.
long double
type was causing problems, so it isn't currently supported.[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | value | String containing scaler value. |
[in] | data | The place to write the value in the output data. |
|
static |
Helper to read CYAML_FLOAT of size sizeof(double)
.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | value | String containing scaler value. |
[in] | data | The place to write the value in the output data. |
|
static |
Helper to read CYAML_FLOAT of size sizeof(float)
.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | value | String containing scaler value. |
[in] | data | The place to write the value in the output data. |
|
static |
|
static |
Read a scalar value.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | data | The place to write the value in the output data. |
[in] | event | The libyaml event providing the scalar value data. |
|
static |
Read a value of type CYAML_STRING.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | value | String containing scaler value. |
[in] | data | The place to write the value in the output data. |
|
static |
Read a value of type CYAML_UINT.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | value | String containing scaler value. |
[in] | data | The place to write the value in the output data. |
|
inlinestatic |
Helper to read a number into a uint64_t.
[in] | value | String containing scaler value. |
[in] | out | The place to write the value in the output data. |
|
static |
Handle a YAML event corresponding to a YAML data value.
[in] | ctx | The CYAML loading context. |
[in] | schema | CYAML schema for the expected value. |
[in] | data | Pointer to where value's data should be written. |
[in] | event | The YAML event to handle. |
|
static |
Pop a recording stack context entry.
Any actively recording anchors are checked, and if this event ends the anchor, the anchor recording is moved from the progress array to the complete array.
[in] | ctx | The CYAML loading context. |
[in] | event_index | The current event's index in the recording. |
|
static |
Push a recording stack context entry.
[in] | ctx | The CYAML loading context. |
[in] | event_index | The current event's index in the recording. |
|
static |
YAML loading handler for finalising the CYAML_STATE_IN_SEQUENCE state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
YAML loading handler for new sequence entries in the CYAML_STATE_IN_SEQUENCE state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
Set some bits in a CYAML_BITFIELD value.
If the given bit value name is one expected by the schema, then this function consumes an event from the YAML input stream.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in,out] | bits_out | Current bits, updated on success. |
|
static |
Set a flag in a CYAML_FLAGS value.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for the value to be read. |
[in] | value | String containing scaler value. |
[in,out] | flags_out | Current flags, updated on success. |
|
static |
Ensure that the CYAML load context has space for a new stack entry.
[in] | ctx | The CYAML loading context. |
|
static |
Pop the current entry on the CYAML load context's stack.
This frees any resources owned by the stack entry.
[in] | ctx | The CYAML loading context. |
|
static |
Push a new entry onto the CYAML load context's stack.
[in] | ctx | The CYAML loading context. |
[in] | state | The CYAML load state we're pushing a stack entry for. |
[in] | schema | The CYAML schema for the value expected in state. |
[in] | data | Pointer to where value's data should be written. |
|
static |
YAML loading handler for finalising the CYAML_STATE_IN_STREAM state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
YAML loading handler for start of stream in the CYAML_STATE_START state.
[in] | ctx | The CYAML loading context. |
[in] | event | The YAML event to handle. |
|
static |
Check whether a string represents a NULL value.
[in] | schema | CYAML schema for the value to test. |
[in] | value | String value to test. |
|
static |
Update the anchor data in the recording context.
[in] | ctx | The CYAML loading context. |
[in] | event_index | The current event's index in the recording. |
[in] | event | The libyaml event to fill from the recording. |
|
static |
Validate the current event for what's expected by the schema.
[in] | ctx | The CYAML loading context. |
[in] | schema | The schema for value that the event belongs to. |
[in] | event | The event to be checked. |
|
inlinestatic |
Check that common load parameters from client are valid.
[in] | config | The client's CYAML library config. |
[in] | schema | The schema describing the content of data. |
[in] | data_tgt | Points to client's address to write data to. |
[in] | seq_count_tgt | Points to client's address to write sequence count. |
|
static |
Helper function to read the next YAML input event into the context.
This handles recording the events associated with anchors, and replaying them when an alias event references a valid anchor. If we are not replaying anchored events, this gets the next event from the CYAML load context's libyaml
parser object.
Any existing event in the load context is deleted first.
Callers do not always need to delete the previous event from the context before calling this function. However, after the final call, when cleaning up the context, any event must be deleted with a single call to cyaml__delete_yaml_event.
[in] | ctx | The CYAML loading context. |
cyaml_err_t cyaml_load_data | ( | const uint8_t * | input, |
size_t | input_len, | ||
const cyaml_config_t * | config, | ||
const cyaml_schema_value_t * | schema, | ||
cyaml_data_t ** | data_out, | ||
unsigned * | seq_count_out | ||
) |
Load a YAML document from a data buffer.
NULL
in the data_out
parameter.[in] | input | Buffer to load YAML data from. |
[in] | input_len | Length of input in bytes. |
[in] | config | Client's CYAML configuration structure. |
[in] | schema | CYAML schema for the YAML to be loaded. |
[out] | data_out | Returns the caller-owned loaded data on success. Untouched on failure. |
[out] | seq_count_out | On success, returns the sequence entry count. Untouched on failure. Must be non-NULL if top-level schema type is CYAML_SEQUENCE, otherwise, must be NULL. |
cyaml_err_t cyaml_load_file | ( | const char * | path, |
const cyaml_config_t * | config, | ||
const cyaml_schema_value_t * | schema, | ||
cyaml_data_t ** | data_out, | ||
unsigned * | seq_count_out | ||
) |
Load a YAML document from a file at the given path.
NULL
in the data_out
parameter.[in] | path | Path to YAML file to load. |
[in] | config | Client's CYAML configuration structure. |
[in] | schema | CYAML schema for the YAML to be loaded. |
[out] | data_out | Returns the caller-owned loaded data on success. Untouched on failure. |
[out] | seq_count_out | On success, returns the sequence entry count. Untouched on failure. Must be non-NULL if top-level schema type is CYAML_SEQUENCE, otherwise, must be NULL. |
|
inlinestatic |
Helper to get the current mapping field.
[in] | ctx | The CYAML loading context. |