std1.0.0-beta-7 SafeC docs

Module serial::yaml

#include <std/serial/yaml.h> source

YAML serialization (block style subset), built on std/serial/value.h the same way json.h/csv.h/xml.h/html.h are.

Supported: block scalars (plain, single-quoted '...' with '' escaping, double-quoted "..." with " \ \n \t \r \t escapes), block sequences ('- item' per line, including the compact '- key: value' list-of-maps shorthand), block mappings ('key: value' per line, indentation-nested), flow collections on one line ('[a, b]', '{k: v, n: [1, 2]}', nested, with quoted or plain items), literal and folded block scalars ('|' / '>', with '-' strip / '+' keep chomping), '#' comments (at the line start or after whitespace, outside quotes — 'a#b' is a plain scalar), and the null/bool/int/float scalar forms YAML 1.1 core schema recognizes (~/null, true/false, plain integers and floats).

NOT supported (out of scope for this module — a full YAML 1.2 processor is a much larger undertaking): flow collections spanning several lines, anchors & aliases ('&name' / '*name'), tags ('!!str'), multi-document streams ('---' separators), and merge keys ('<<:'). A document using any of these either parses as plain scalar text (least-surprise fallback — an unterminated '[...' stays a string) or fails — see yaml_parse's 'ok' contract.

Structs

YamlThe YAML backend as a Format (see value.h): v.encode(Yaml::new()), Value::decode(Yaml::new(), text, &ok) — the same as yaml_write / yaml_parse.

Functions

yaml_writeAppends v's YAML text representation to 'out' (does not clear 'out' first). Only VAL_NULL/VAL_BOOL/VAL_INT/VAL_FLOAT/VAL_STRING/VAL_ARRAY/ VAL_OBJECT are meaningful — same value tree json_write accepts.
value_to_yamlConvenience wrapper: a fresh String holding just v's YAML text.
yaml_parseParses a block-style YAML document (see the file-level comment for the supported subset). On success, '*ok' (if non-NULL) is set to 1; on a structural error (inconsistent indentation, unterminated quoted scalar, a line that's neither a valid sequence/mapping entry nor a bare scalar where one is expected), '*ok' is set to 0 and the return value is whatever was parsed before the error.