Expand description
asdf/parser.h, asdf/event.h and asdf/yaml.h: the low-level
event-based parser.
This is libasdf’s streaming interface: rather than building a tree, it walks a file and reports what it finds – the version headers, any comments, the block index, the tree’s extent, optionally the YAML events inside it, then each block, then the end.
§Ownership
The header’s contract is unusual and is reproduced rather than simplified:
asdf_parser_parsehands out an event the caller releases withasdf_event_free.asdf_event_iteratereleases the event it handed out last time before producing the next, so a loop over it frees nothing by hand.- Anything still outstanding is released by
asdf_parser_destroy, so a caller that abandons a parse leaks nothing.
An event’s strings belong to the event and stay valid until it is freed.
Structs§
- Asdf
Event - A parser event. Opaque to C.
- Asdf
Parser - A parser handle. Opaque to C.
Functions§
- asdf_
event_ ⚠block_ info - A block event’s position and header, or null for any other event.
- asdf_
event_ ⚠comment - A comment event’s text, without its leading
#, or null. - asdf_
event_ ⚠free - Release an event from
asdf_parser_parse. - asdf_
event_ ⚠iterate - Produce the next event, releasing the one this call produced last.
- asdf_
event_ ⚠print - Print an event, in the format
asdf info --eventsuses. - asdf_
event_ ⚠tree_ info - A tree event’s extent, or null for any other event.
- asdf_
event_ ⚠type - An event’s type;
ASDF_NONE_EVENTfor a null event. - asdf_
event_ type_ name - The name of an event type, as its enum member is spelled.
- asdf_
parser_ ⚠create - Create a parser.
- asdf_
parser_ ⚠destroy - Release a parser and everything it handed out.
- asdf_
parser_ ⚠error_ code - The recorded error code.
- asdf_
parser_ ⚠error_ errno - The recorded
errno, meaningful only for a system error. - asdf_
parser_ ⚠get_ error - The recorded error message, or null.
- asdf_
parser_ ⚠has_ error - Whether the parser has recorded an error.
- asdf_
parser_ ⚠parse - Produce the next event, or null at the end of the stream.
- asdf_
parser_ ⚠set_ input_ file - Read a file and lay out its event stream. Returns 0 on success.
- asdf_
parser_ ⚠set_ input_ fp - Read an already-open stream. Returns 0 on success.
- asdf_
parser_ ⚠set_ input_ mem - Read a buffer. Returns 0 on success.
- asdf_
yaml_ ⚠event_ scalar_ value - A scalar sub-event’s raw text, or null.
- asdf_
yaml_ ⚠event_ tag - A YAML sub-event’s tag, or null.
- asdf_
yaml_ ⚠event_ type - The YAML sub-event type, or
ASDF_YAML_NONE_EVENT. - asdf_
yaml_ ⚠event_ type_ text - A human-readable name for the YAML sub-event type.