asdf/yaml.h

YAML-specific types and utilities

This header provides types and accessor functions that relate specifically to the YAML layer of ASDF. It covers node style hints for serialization, the YAML event types surfaced through the event-based API, and functions for extracting YAML-specific fields from asdf_event_t objects.

enum asdf_yaml_node_style_t

YAML node style hint used when serializing mappings and sequences

enumerator ASDF_YAML_NODE_STYLE_AUTO = 0

Let libfyaml choose the style

enumerator ASDF_YAML_NODE_STYLE_FLOW

Emit inline using {...} / [...] notation

enumerator ASDF_YAML_NODE_STYLE_BLOCK

Emit in indented block notation

enum asdf_yaml_event_type_t

YAML event types returned inside an asdf_event_t of type ASDF_YAML_EVENT

These mirror the libfyaml event model and are extracted via asdf_yaml_event_type.

enumerator ASDF_YAML_NONE_EVENT = 0

Sentinel: the enclosing asdf_event_t does not carry a YAML sub-event

enumerator ASDF_YAML_STREAM_START_EVENT

Start of the YAML stream

enumerator ASDF_YAML_STREAM_END_EVENT

End of the YAML stream

enumerator ASDF_YAML_DOCUMENT_START_EVENT

Start of a YAML document (---)

enumerator ASDF_YAML_DOCUMENT_END_EVENT

End of a YAML document (...)

enumerator ASDF_YAML_MAPPING_START_EVENT

Start of a YAML mapping node

enumerator ASDF_YAML_MAPPING_END_EVENT

End of a YAML mapping node

enumerator ASDF_YAML_SEQUENCE_START_EVENT

Start of a YAML sequence node

enumerator ASDF_YAML_SEQUENCE_END_EVENT

End of a YAML sequence node

enumerator ASDF_YAML_SCALAR_EVENT

A YAML scalar node

enumerator ASDF_YAML_ALIAS_EVENT

A YAML alias node (reference to an anchor)

struct asdf_yaml_tag_handle_t

A YAML tag directive associating a handle (e.g. "!!" ) with a prefix (e.g. "tag:yaml.org,2002:" )

const char *asdf_yaml_event_scalar_value(const asdf_event_t *event, size_t *lenp)

Return the raw scalar string from a ASDF_YAML_SCALAR_EVENT

The string is owned by event and must not be freed by the caller. Returns NULL if event does not carry a scalar sub-event.

Parameters:
  • event – The asdf_event_t* to query

  • lenp – If non-NULL, receives the byte length of the returned string

Returns:

Pointer to the scalar value, or NULL

const char *asdf_yaml_event_tag(const asdf_event_t *event, size_t *lenp)

Return the YAML tag string from a YAML event, if any

The string is owned by event and must not be freed by the caller. Returns NULL if the event carries no tag.

Parameters:
  • event – The asdf_event_t* to query

  • lenp – If non-NULL, receives the byte length of the returned string

Returns:

Pointer to the tag string, or NULL

asdf_yaml_event_type_t asdf_yaml_event_type(const asdf_event_t *event)

Return the asdf_yaml_event_type_t of the YAML sub-event carried by event

Returns ASDF_YAML_NONE_EVENT if event is not of type ASDF_YAML_EVENT.

Parameters:
  • event – The asdf_event_t* to query

Returns:

The asdf_yaml_event_type_t of the YAML sub-event

const char *asdf_yaml_event_type_text(const asdf_event_t *event)

Return a human-readable name for the YAML event type of event

Parameters:
  • event – The asdf_event_t* to query

Returns:

A static string such as "ASDF_YAML_SCALAR_EVENT"