CYAML Internals
Data Structures | Typedefs | Enumerations | Functions
save.c File Reference

Save client's data structure to YAML, using schema. More...

#include <inttypes.h>
#include <stdbool.h>
#include <assert.h>
#include <limits.h>
#include <yaml.h>
#include "mem.h"
#include "data.h"
#include "util.h"
Include dependency graph for save.c:

Data Structures

struct  cyaml_state
 
struct  cyaml_ctx
 
struct  cyaml_buffer_ctx
 

Typedefs

typedef struct cyaml_state cyaml_state_t
 
typedef struct cyaml_ctx cyaml_ctx_t
 
typedef struct cyaml_buffer_ctx cyaml_buffer_ctx_t
 

Enumerations

enum  cyaml_emit_style { CYAML_EMIT_STYLE_DEFAULT , CYAML_EMIT_STYLE_BLOCK , CYAML_EMIT_STYLE_FLOW }
 

Functions

static cyaml_err_t cyaml__stack_ensure (cyaml_ctx_t *ctx)
 
static cyaml_err_t cyaml__emit_event_helper (const cyaml_ctx_t *ctx, int valid, yaml_event_t *event)
 
static enum cyaml_emit_style cyaml__get_emit_style (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema)
 
static yaml_sequence_style_t cyaml__get_emit_style_seq (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema)
 
static yaml_mapping_style_t cyaml__get_emit_style_map (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema)
 
static yaml_scalar_style_t cyaml__get_emit_style_scalar (const cyaml_schema_value_t *schema)
 
static bool cyaml__emit_doc_delim (const cyaml_ctx_t *ctx)
 
static cyaml_err_t cyaml__stack_push_write_event (const cyaml_ctx_t *ctx, enum cyaml_state_e state, 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, const cyaml_data_t *data)
 
static cyaml_err_t cyaml__stack_pop_write_event (const cyaml_ctx_t *ctx, enum cyaml_state_e state)
 
static cyaml_err_t cyaml__stack_pop (cyaml_ctx_t *ctx, bool emit)
 
static const uint8_t * cyaml__data_handle_pointer (const cyaml_config_t *config, const cyaml_schema_value_t *schema, const uint8_t *data_in)
 
static void cyaml__backtrace (const cyaml_ctx_t *ctx)
 
static cyaml_err_t cyaml__emit_scalar (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const char *value, const char *tag)
 
static const char * cyaml__get_int (int64_t value)
 
static const char * cyaml__get_uint (uint64_t value, bool hex)
 
static const char * cyaml__get_float (double value)
 
static const char * cyaml__get_double (double value)
 
static int64_t cyaml_sign_pad (uint64_t raw, size_t size)
 
static cyaml_err_t cyaml__write_int (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const uint8_t *data)
 
static cyaml_err_t cyaml__write_uint (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const uint8_t *data)
 
static cyaml_err_t cyaml__write_bool (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const uint8_t *data)
 
static cyaml_err_t cyaml__write_enum (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const uint8_t *data)
 
static cyaml_err_t cyaml__write_float (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const uint8_t *data)
 
static cyaml_err_t cyaml__write_string (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const uint8_t *data)
 
static cyaml_err_t cyaml__write_scalar_value (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const cyaml_data_t *data)
 
static cyaml_err_t cyaml__emit_flags_sequence (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, uint64_t number)
 
static cyaml_err_t cyaml__write_flags_value (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const cyaml_data_t *data)
 
static cyaml_err_t cyaml__emit_bitfield_mapping (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, uint64_t number)
 
static cyaml_err_t cyaml__write_bitfield_value (const cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const cyaml_data_t *data)
 
static cyaml_err_t cyaml__write_value (cyaml_ctx_t *ctx, const cyaml_schema_value_t *schema, const uint8_t *data, uint64_t seq_count)
 
static cyaml_err_t cyaml__write_start (cyaml_ctx_t *ctx)
 
static cyaml_err_t cyaml__write_stream (cyaml_ctx_t *ctx)
 
static cyaml_err_t cyaml__write_doc (cyaml_ctx_t *ctx)
 
static cyaml_err_t cyaml__write_mapping (cyaml_ctx_t *ctx)
 
static cyaml_err_t cyaml__write_sequence (cyaml_ctx_t *ctx)
 
static cyaml_err_t cyaml__validate_save_params (const cyaml_config_t *config, const cyaml_schema_value_t *schema, const cyaml_data_t *data, unsigned seq_count)
 
static cyaml_err_t cyaml__save (const cyaml_config_t *config, const cyaml_schema_value_t *schema, const cyaml_data_t *data, unsigned seq_count, yaml_emitter_t *emitter)
 
cyaml_err_t cyaml_save_file (const char *path, const cyaml_config_t *config, const cyaml_schema_value_t *schema, const cyaml_data_t *data, unsigned seq_count)
 
static int cyaml__buffer_handler (void *data, unsigned char *buffer, size_t size)
 
cyaml_err_t cyaml_save_data (char **output, size_t *len, const cyaml_config_t *config, const cyaml_schema_value_t *schema, const cyaml_data_t *data, unsigned seq_count)
 

Detailed Description

Save client's data structure to YAML, using schema.

This uses libyaml to emit YAML documents, it uses the client-provided schema to access the client data, and validates it before emitting the YAML.

Typedef Documentation

◆ cyaml_buffer_ctx_t

CYAML save buffer context.

◆ cyaml_ctx_t

typedef struct cyaml_ctx cyaml_ctx_t

Internal YAML saving context.

◆ cyaml_state_t

typedef struct cyaml_state cyaml_state_t

A CYAML save state machine stack entry.

Enumeration Type Documentation

◆ cyaml_emit_style

The style to use when emitting mappings and sequences.

Function Documentation

◆ cyaml__backtrace()

static void cyaml__backtrace ( const cyaml_ctx_t ctx)
static

Dump a backtrace to the log.

Parameters
[in]ctxThe CYAML saving context.
Todo:
CYAML_STATE_IN_DOC handling for multi document streams.

◆ cyaml__buffer_handler()

static int cyaml__buffer_handler ( void *  data,
unsigned char *  buffer,
size_t  size 
)
static

Write handler for libyaml.

The write handler is called when the emitter needs to flush the accumulated characters to the output. The handler should write size bytes of the buffer to the output.

Todo:
Could be more efficient about this, but for now, this is fine.
Parameters
[in]dataA pointer to cyaml buffer context struture.
[in]bufferThe buffer with bytes to be written.
[in]sizeThe number of bytes to be written.
Returns
1 on sucess, 0 otherwise.

◆ cyaml__data_handle_pointer()

static const uint8_t* cyaml__data_handle_pointer ( const cyaml_config_t config,
const cyaml_schema_value_t schema,
const uint8_t *  data_in 
)
static

Find address of actual value.

If the value has the pointer flag, the pointer is read, otherwise the address is returned unchanged.

Parameters
[in]configThe CYAML client configuration object.
[in]schemaCYAML schema for the expected value.
[in]data_inThe address to read from.
Returns
New address or for CYAML_FLAG_POINTER, or data_in.

◆ cyaml__emit_bitfield_mapping()

static cyaml_err_t cyaml__emit_bitfield_mapping ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
uint64_t  number 
)
static

Emit a mapping of bitfield values.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]numberThe value of the bitfield data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__emit_doc_delim()

static bool cyaml__emit_doc_delim ( const cyaml_ctx_t ctx)
inlinestatic

Helper to discern whether to emit document delimiting marks.

These are "---" for document start, and "..." for document end.

Parameters
[in]ctxThe CYAML saving context.
Returns
true if delimiters should be emitted, false otherwise.

◆ cyaml__emit_event_helper()

static cyaml_err_t cyaml__emit_event_helper ( const cyaml_ctx_t ctx,
int  valid,
yaml_event_t *  event 
)
static

Helper to simplify emitting libyaml events.

This is a slightly peculiar function, but it is intended to reduce the boilerplate required to emit events.

Intended usage is something like:

yaml_event_t event;
int ret = yaml_mapping_end_event_initialize(&event);
err = cyaml__emit_event_helper(ctx, ret, &event);
enum cyaml_err cyaml_err_t
static cyaml_err_t cyaml__emit_event_helper(const cyaml_ctx_t *ctx, int valid, yaml_event_t *event)
Definition: save.c:119
Parameters
[in]ctxThe CYAML saving context.
[in]validWhether the event pointer is valid. Typically this will be the value returned by the libyaml call that initialised the event. As such, if valid is non-zero, the helper will try to emit the event, otherwise, it will return CYAML_ERR_LIBYAML_EVENT_INIT.
[in]eventThe event to try to emit, if valid.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__emit_flags_sequence()

static cyaml_err_t cyaml__emit_flags_sequence ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
uint64_t  number 
)
static

Emit a sequence of flag values.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]numberThe value of the flag data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__emit_scalar()

static cyaml_err_t cyaml__emit_scalar ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const char *  value,
const char *  tag 
)
static

Helper to emit YAML scalar events, using libyaml.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to emit.
[in]valueThe value to emit as a null-terminated C string.
[in]tagYAML tag to use for output.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__get_double()

static const char* cyaml__get_double ( double  value)
static

Get string representation for double precision floating point values.

Parameters
[in]valueThe value to convert.
Returns
String conversion of the value.

◆ cyaml__get_emit_style()

static enum cyaml_emit_style cyaml__get_emit_style ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema 
)
inlinestatic

Get the style to use for mappings/sequences from value flags and config.

As described in the API, schema flags take priority over config flags, and block has precedence over flow, if both flags are set at the same level.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe CYAML schema for the value expected in state.
Returns
The generic style to emit the value with.

◆ cyaml__get_emit_style_map()

static yaml_mapping_style_t cyaml__get_emit_style_map ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema 
)
inlinestatic

Get the style to use for mappings from value flags and config.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe CYAML schema for the value expected in state.
Returns
The libyaml mapping style to emit the value with.

◆ cyaml__get_emit_style_scalar()

static yaml_scalar_style_t cyaml__get_emit_style_scalar ( const cyaml_schema_value_t schema)
inlinestatic

Get the style to use for scalar values from value flags.

Parameters
[in]ctxThe CYAML saving context.
Returns
The libyaml scalar style to emit the value with.

◆ cyaml__get_emit_style_seq()

static yaml_sequence_style_t cyaml__get_emit_style_seq ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema 
)
inlinestatic

Get the style to use for sequences from value flags and config.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe CYAML schema for the value expected in state.
Returns
The libyaml sequence style to emit the value with.

◆ cyaml__get_float()

static const char* cyaml__get_float ( double  value)
static

Get string representation for single precision floating point values.

Parameters
[in]valueThe value to convert.
Returns
String conversion of the value.

◆ cyaml__get_int()

static const char* cyaml__get_int ( int64_t  value)
static

Convert signed integer to string.

Parameters
[in]valueThe integer to convert.
Returns
String conversion of the value.

◆ cyaml__get_uint()

static const char* cyaml__get_uint ( uint64_t  value,
bool  hex 
)
static

Convert unsigned integer to string.

Parameters
[in]valueThe integer to convert.
[in]hexWhether to render the number as hexadecimal.
Returns
String conversion of the value.

◆ cyaml__save()

static cyaml_err_t cyaml__save ( const cyaml_config_t config,
const cyaml_schema_value_t schema,
const cyaml_data_t data,
unsigned  seq_count,
yaml_emitter_t *  emitter 
)
static

The main YAML saving function.

The public interfaces are wrappers around this.

Parameters
[in]configClient's CYAML configuration structure.
[in]schemaCYAML schema for the YAML to be saved.
[in]dataThe caller-owned data to be saved.
[in]seq_countIf top level type is sequence, this should be the entry count, otherwise it is ignored.
[in]emitterAn initialised libyaml emitter object with its output set.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__stack_ensure()

static cyaml_err_t cyaml__stack_ensure ( cyaml_ctx_t ctx)
static

Ensure that the CYAML save context has space for a new stack entry.

Parameters
[in]ctxThe CYAML saving context.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__stack_pop()

static cyaml_err_t cyaml__stack_pop ( cyaml_ctx_t ctx,
bool  emit 
)
static

Pop the current entry on the CYAML save context's stack.

This frees any resources owned by the stack entry.

Parameters
[in]ctxThe CYAML saving context.
[in]emitWhether end events should be emitted.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__stack_pop_write_event()

static cyaml_err_t cyaml__stack_pop_write_event ( const cyaml_ctx_t ctx,
enum cyaml_state_e  state 
)
static

Emit a YAML end event for the state being popped from the stack.

This frees any resources owned by the stack entry.

Parameters
[in]ctxThe CYAML saving context.
[in]stateThe CYAML save state we're popping from the stack.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__stack_push()

static cyaml_err_t cyaml__stack_push ( cyaml_ctx_t ctx,
enum cyaml_state_e  state,
const cyaml_schema_value_t schema,
const cyaml_data_t data 
)
static

Push a new entry onto the CYAML save context's stack.

Parameters
[in]ctxThe CYAML saving context.
[in]stateThe CYAML save state we're pushing a stack entry for.
[in]schemaThe CYAML schema for the value expected in state.
[in]dataPointer to where value's data should be read from.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__stack_push_write_event()

static cyaml_err_t cyaml__stack_push_write_event ( const cyaml_ctx_t ctx,
enum cyaml_state_e  state,
const cyaml_schema_value_t schema 
)
static

Emit a YAML start event for the state being pushed to the stack.

Parameters
[in]ctxThe CYAML saving context.
[in]stateThe CYAML save state we're pushing a stack entry for.
[in]schemaThe CYAML schema for the value expected in state.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__validate_save_params()

static cyaml_err_t cyaml__validate_save_params ( const cyaml_config_t config,
const cyaml_schema_value_t schema,
const cyaml_data_t data,
unsigned  seq_count 
)
inlinestatic

Check that common save params from client are valid.

Parameters
[in]configThe client's CYAML library config.
[in]schemaThe schema describing the content of data.
[in]dataPoints to client's data.
[in]seq_countTop level sequence count.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_bitfield_value()

static cyaml_err_t cyaml__write_bitfield_value ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const cyaml_data_t data 
)
static

Write a value of type CYAML_BITFIELD.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]dataThe place to read the value from in the client data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_bool()

static cyaml_err_t cyaml__write_bool ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const uint8_t *  data 
)
static

Write a value of type CYAML_BOOL.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]dataThe place to read the value from in the client data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_doc()

static cyaml_err_t cyaml__write_doc ( cyaml_ctx_t ctx)
static

YAML saving handler for the CYAML_STATE_IN_DOC state.

Parameters
[in]ctxThe CYAML saving context.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_enum()

static cyaml_err_t cyaml__write_enum ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const uint8_t *  data 
)
static

Write a value of type CYAML_ENUM.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]dataThe place to read the value from in the client data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_flags_value()

static cyaml_err_t cyaml__write_flags_value ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const cyaml_data_t data 
)
static

Write a value of type CYAML_FLAGS.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]dataThe place to read the value from in the client data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_float()

static cyaml_err_t cyaml__write_float ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const uint8_t *  data 
)
static

Write a value of type CYAML_FLOAT.

The data_size of the schema entry must be the size of a known floating point C type.

Note
The long double type was causing problems, so it isn't currently supported.
Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]dataThe place to read the value from in the client data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_int()

static cyaml_err_t cyaml__write_int ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const uint8_t *  data 
)
static

Write a value of type CYAML_INT.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]dataThe place to read the value from in the client data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_mapping()

static cyaml_err_t cyaml__write_mapping ( cyaml_ctx_t ctx)
static

YAML saving handler for the CYAML_STATE_IN_MAP_KEY and CYAML_STATE_IN_MAP_VALUE states.

Parameters
[in]ctxThe CYAML saving context.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_scalar_value()

static cyaml_err_t cyaml__write_scalar_value ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const cyaml_data_t data 
)
static

Write a scalar value.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]dataThe place to read the value from in the client data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_sequence()

static cyaml_err_t cyaml__write_sequence ( cyaml_ctx_t ctx)
static

YAML saving handler for the CYAML_STATE_IN_SEQUENCE state.

Parameters
[in]ctxThe CYAML saving context.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_start()

static cyaml_err_t cyaml__write_start ( cyaml_ctx_t ctx)
static

YAML saving handler for the CYAML_STATE_START state.

Parameters
[in]ctxThe CYAML saving context.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_stream()

static cyaml_err_t cyaml__write_stream ( cyaml_ctx_t ctx)
static

YAML saving handler for the CYAML_STATE_IN_STREAM state.

Parameters
[in]ctxThe CYAML saving context.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_string()

static cyaml_err_t cyaml__write_string ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const uint8_t *  data 
)
static

Write a value of type CYAML_STRING.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]dataThe place to read the value from in the client data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_uint()

static cyaml_err_t cyaml__write_uint ( const cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const uint8_t *  data 
)
static

Write a value of type CYAML_UINT.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaThe schema for the value to be written.
[in]dataThe place to read the value from in the client data.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml__write_value()

static cyaml_err_t cyaml__write_value ( cyaml_ctx_t ctx,
const cyaml_schema_value_t schema,
const uint8_t *  data,
uint64_t  seq_count 
)
static

Emit the YAML events required for a CYAML value.

Parameters
[in]ctxThe CYAML saving context.
[in]schemaCYAML schema for the expected value.
[in]dataThe place to read the value from in the client data.
[in]seq_countEntry count for sequence values. Unused for non-sequence values.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml_save_data()

cyaml_err_t cyaml_save_data ( char **  output,
size_t *  len,
const cyaml_config_t config,
const cyaml_schema_value_t schema,
const cyaml_data_t data,
unsigned  seq_count 
)

Save a YAML document into a string in memory.

This allocates a buffer containing the serialised YAML data.

To free the returned YAML string, clients should use the cyaml_mem_fn_t function set in the cyaml_config_t passed to this function. For example:

char *yaml;
size_t len;
err = cyaml_save_file(&yaml, &len, &config, &client_schema, client_data, 0);
if (err == CYAML_OK) {
// Use `yaml`:
printf("%*s\n", len, yaml);
// Free `yaml`:
config.mem_fn(config.mem_ctx, yaml, 0);
}
cyaml_err_t cyaml_save_file(const char *path, const cyaml_config_t *config, const cyaml_schema_value_t *schema, const cyaml_data_t *data, unsigned seq_count)
Definition: save.c:1375
@ CYAML_OK
Definition: cyaml.h:576
Note
The returned YAML string does not have a trailing '\0'.
Parameters
[out]outputReturns the caller-owned serialised YAML data on success, untouched on failure. Clients should use the cyaml_mem_fn_t function set in the cyaml_config_t to free the data.
[out]lenReturns the length of the data in output on success, untouched on failure.
[in]configClient's CYAML configuration structure.
[in]schemaCYAML schema for the YAML to be saved.
[in]dataThe caller-owned data to be saved.
[in]seq_countIf top level type is sequence, this should be the entry count, otherwise it is ignored.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml_save_file()

cyaml_err_t cyaml_save_file ( const char *  path,
const cyaml_config_t config,
const cyaml_schema_value_t schema,
const cyaml_data_t data,
unsigned  seq_count 
)

Save a YAML document to a file at the given path.

Parameters
[in]pathPath to YAML file to write.
[in]configClient's CYAML configuration structure.
[in]schemaCYAML schema for the YAML to be saved.
[in]dataThe caller-owned data to be saved.
[in]seq_countIf top level type is sequence, this should be the entry count, otherwise it is ignored.
Returns
CYAML_OK on success, or appropriate error code otherwise.

◆ cyaml_sign_pad()

static int64_t cyaml_sign_pad ( uint64_t  raw,
size_t  size 
)
static

Pad a signed value that's smaller than 64-bit to an int64_t.

This sets all the bits in the padded region.

Parameters
[in]rawContains a signed value of size bytes.
[in]sizeNumber of bytes used in raw.
Returns
Value padded to 64-bit signed.