LIBFYAML-CORE(3)

๐Ÿ“ฆ version 0.9.6, in nixpkgs unstable

๐Ÿ’– LIBFYAML-CORE(3) ๐Ÿ’–

okay so this is the libfyaml core API page โ€” like, the main character of the whole manual set. grab a strawberry drink ๐Ÿ“ and let's get into it.


โœจ NAME โœจ

libfyaml-core โ€” the libfyaml core API. that's it, that's the name, she's simple and she knows it ๐Ÿ’…


๐ŸŽ€ CORE ๐ŸŽ€

okay so bestie, listen: this is the single top-level include for the entire libfyaml public API. like, one include and you get everything. including it pulls in all the subsystem headers, no cap:

  • Core YAML parser, document tree, emitter, and diagnostics (libfyaml/libfyaml-core.h)
  • General-purpose utilities and portability macros (libfyaml/libfyaml-util.h)
  • YAML path expression parser and executor (libfyaml/libfyaml-path-exec.h)
  • Document builder: event-stream to tree conversion (libfyaml/libfyaml-docbuild.h)
  • Document iterator: tree traversal and event replay (libfyaml/libfyaml-dociter.h)
  • Composer: callback-driven, path-aware event processing (libfyaml/libfyaml-composer.h)
  • Pluggable memory allocators (libfyaml/libfyaml-allocator.h)
  • Thread pool for parallel work (libfyaml/libfyaml-thread.h)
  • BLAKE3 cryptographic hashing (libfyaml/libfyaml-blake3.h)
  • Alignment macros and helpers (libfyaml/libfyaml-align.h)
  • Portable endian detection (libfyaml/libfyaml-endian.h)
  • Portable atomic operations (libfyaml/libfyaml-atomics.h)
  • Variable-length size encoding (libfyaml/libfyaml-vlsize.h)

but lowkey, for faster compilation you're allowed to include only the subsystem headers you actually need. slay, minimalism ๐Ÿงš

and the naming tea โ˜•: all public symbols are prefixed with fy_ (functions/types) or FY_ (macros and constants). iykyk.


๐ŸŒˆ YAML PARSER, DOCUMENT AND EMITTER ๐ŸŒˆ

this header provides the complete YAML 1.2 / JSON parser, document tree, and emitter API โ€” literally the core of libfyaml. it's the biggest and most-used part of the public interface. main character energy fr fr ๐Ÿ‘‘

three complementary APIs cover the full lifecycle of a YAML document:

Event-based parsing (fy_parser_*) โ€” a streaming interface, similar to libyaml's. the parser produces a sequence of typed events (stream-start, document-start, scalar, sequence-start, โ€ฆ) without building an in-memory tree. ideal for large documents, filters, and transcoding pipelines. so efficient โœจ

Document tree (fy_document_*, fy_node_*) โ€” builds a fully navigable in-memory tree from a YAML or JSON source. nodes can be queried, modified, merged, and serialised. path-expression helpers (fy_document_scanf(), fy_document_insert_at(), โ€ฆ) give you XPath-like access into the tree ๐Ÿฆ‹

Emitter (fy_emitter_*) โ€” serialises documents or raw event streams back to YAML or JSON with full control over formatting style, indentation, and quoting. supports streaming output to files, memory buffers, or user-supplied callbacks ๐Ÿซถ

Diagnostics (fy_diag_*) โ€” a structured error-reporting subsystem that attributes messages to precise source locations and integrates with IDE/compiler toolchains via a standard file:line:col: level: text format ๐Ÿ’€

all types are opaque pointers (struct fy_parser *, struct fy_document *, struct fy_node *, โ€ฆ) so the ABI is stable across minor releases. iconic behaviour honestly ๐Ÿ‘‘


๐ŸŒธ struct fy_version ๐ŸŒธ

struct fy_version

the YAML version โœจ

Definition

struct fy_version {
    int major;
    int minor;
}

Members

  • major โ€” Major version number
  • minor โ€” Major version number ๐Ÿ˜ญ (yes bestie, that's what it says โ€” both of them say "Major". not me questioning the docs, periodt)

Description

the parser fills it according to the %YAML directive found in the document.


๐Ÿ’œ fy_version_compare ๐Ÿ’œ

int fy_version_compare(const struct fy_version *va, const struct fy_version *vb)

compare two yaml versions ๐Ÿ’…

Parameters

  • va (const struct fy_version*) โ€“ The first version, if NULL use default version
  • vb (const struct fy_version*) โ€“ The second version, if NULL use default version

Description

compare the versions. that's the whole bit.

Return

0 if versions are equal, > 0 if version va is higher than vb, < 0 if version va is lower than vb.


๐ŸŽ€ fy_version_default ๐ŸŽ€

const struct fy_version *fy_version_default(void)

get the default version of the library ๐ŸŒธ

Parameters

  • void โ€“ no arguments

Description

return the default version of the library, i.e. the highest stable version that is supported.

Return

the default YAML version of this library ๐Ÿซถ


๐Ÿฆ‹ fy_version_is_supported ๐Ÿฆ‹

bool fy_version_is_supported(const struct fy_version *vers)

check if supported version โญ

Parameters

  • vers (const struct fy_version*) โ€“ The version to check, NULL means default version.

Description

check if the given YAML version is supported.

Return

true if version supported, false otherwise.


๐Ÿ”ฅ fy_version_supported_iterate ๐Ÿ”ฅ

const struct fy_version *fy_version_supported_iterate(void **prevp)

iterate over the supported YAML versions ๐Ÿ‘‘

Parameters

  • prevp (void**) โ€“ The previous version iterator

Description

this method iterates over the supported YAML versions of this ibrary (their typo, not mine, i'm obsessed ๐Ÿ˜ญ). the start of the iteration is signalled by a NULL in *prevp.

Return

the next node in sequence or NULL at the end of the sequence.


๐Ÿงš fy_shutdown ๐Ÿงš

void fy_shutdown(void)

final cleanup before exit ๐Ÿ’€

Parameters

  • void โ€“ no arguments

Description

some libraries โ€” cough*libclang*cough โ€” need explicit cleanup calls at the end of program execution, even if you've never called any of their functions. yes, really. rude, but true ๐Ÿ™ˆ

this method will make sure it calls their cleanup functions so that no memory leaks are reported in valgrind etc. doing the emotional labour so you don't have to ๐Ÿ’–


๐Ÿ’… struct fy_tag ๐Ÿ’…

struct fy_tag

the YAML tag structure โœจ

Definition

struct fy_tag {
    const char *handle;
    const char *prefix;
}

Members

  • handle โ€” Handle of the tag (i.e. "!!")
  • prefix โ€” The prefix of the tag (i.e. "tag:yaml.org,2002:"). The parser fills it according to the %TAG directives encountered during parsing.

๐ŸŒˆ struct fy_mark ๐ŸŒˆ

struct fy_mark

marker holding information about a location in a struct fy_input ๐Ÿ“

Definition

struct fy_mark {
    size_t input_pos;
    int line;
    int column;
}

Members

  • input_pos โ€” Position of the mark (from the start of the current input)
  • line โ€” Line position (0 index based)
  • column โ€” Column position (0 index based)

๐Ÿ’œ enum fy_error_type ๐Ÿ’œ

enum fy_error_type

the supported diagnostic/error types ๐Ÿšจ

Definition

enum fy_error_type {
    FYET_DEBUG,
    FYET_INFO,
    FYET_NOTICE,
    FYET_WARNING,
    FYET_ERROR,
    FYET_MAX
};

Constants

  • FYET_DEBUG โ€” Debug level (disabled if library is not compiled in debug mode)
  • FYET_INFO โ€” Informational level
  • FYET_NOTICE โ€” Notice level
  • FYET_WARNING โ€” Warning level
  • FYET_ERROR โ€” Error level - error reporting is using this level
  • FYET_MAX โ€” Non inclusive maximum fy_error_type value

๐ŸŽ€ enum fy_error_module ๐ŸŽ€

enum fy_error_module

module which generated the diagnostic/error ๐Ÿง

Definition

enum fy_error_module {
    FYEM_UNKNOWN,
    FYEM_ATOM,
    FYEM_SCAN,
    FYEM_PARSE,
    FYEM_DOC,
    FYEM_BUILD,
    FYEM_INTERNAL,
    FYEM_SYSTEM,
    FYEM_EMIT,
    FYEM_TYPESET,
    FYEM_DECODE,
    FYEM_ENCODE,
    FYEM_REFLECTION,
    FYEM_MAX
};

Constants

  • FYEM_UNKNOWN โ€” Unknown, default if not specific
  • FYEM_ATOM โ€” Atom module, used by atom chunking
  • FYEM_SCAN โ€” Scanner module
  • FYEM_PARSE โ€” Parser module
  • FYEM_DOC โ€” Document module
  • FYEM_BUILD โ€” Build document module (after tree is constructed)
  • FYEM_INTERNAL โ€” Internal error/diagnostic module
  • FYEM_SYSTEM โ€” System error/diagnostic module
  • FYEM_EMIT โ€” Emitter module
  • FYEM_TYPESET โ€” Prepare types module (C reflection)
  • FYEM_DECODE โ€” Decode, serialization -> internal form module
  • FYEM_ENCODE โ€” Encode, internal form -> serialized form module
  • FYEM_REFLECTION โ€” Generic reflection module messages
  • FYEM_MAX โ€” Non inclusive maximum fy_error_module value

โญ enum fy_parse_cfg_flags โญ

enum fy_parse_cfg_flags

parse configuration flags ๐Ÿšฉ

Definition

enum fy_parse_cfg_flags {
    FYPCF_QUIET,
    FYPCF_COLLECT_DIAG,
    FYPCF_RESOLVE_DOCUMENT,
    FYPCF_DISABLE_MMAP_OPT,
    FYPCF_DISABLE_RECYCLING,
    FYPCF_PARSE_COMMENTS,
    FYPCF_DISABLE_DEPTH_LIMIT,
    FYPCF_DISABLE_ACCELERATORS,
    FYPCF_DISABLE_BUFFERING,
    FYPCF_DEFAULT_VERSION_AUTO,
    FYPCF_DEFAULT_VERSION_1_1,
    FYPCF_DEFAULT_VERSION_1_2,
    FYPCF_DEFAULT_VERSION_1_3,
    FYPCF_SLOPPY_FLOW_INDENTATION,
    FYPCF_PREFER_RECURSIVE,
    FYPCF_JSON_AUTO,
    FYPCF_JSON_NONE,
    FYPCF_JSON_FORCE,
    FYPCF_YPATH_ALIASES,
    FYPCF_ALLOW_DUPLICATE_KEYS
};

Constants

  • FYPCF_QUIET โ€” Quiet, do not output any information messages
  • FYPCF_COLLECT_DIAG โ€” Collect diagnostic/error messages
  • FYPCF_RESOLVE_DOCUMENT โ€” When producing documents, automatically resolve them
  • FYPCF_DISABLE_MMAP_OPT โ€” Disable mmap optimization
  • FYPCF_DISABLE_RECYCLING โ€” Disable recycling optimization
  • FYPCF_PARSE_COMMENTS โ€” Enable parsing of comments (experimental)
  • FYPCF_DISABLE_DEPTH_LIMIT โ€” Disable depth limit check, use with enlarged stack
  • FYPCF_DISABLE_ACCELERATORS โ€” Disable use of access accelerators (saves memory)
  • FYPCF_DISABLE_BUFFERING โ€” Disable use of buffering where possible
  • FYPCF_DEFAULT_VERSION_AUTO โ€” Automatically use the most recent version the library supports
  • FYPCF_DEFAULT_VERSION_1_1 โ€” Default version is YAML 1.1
  • FYPCF_DEFAULT_VERSION_1_2 โ€” Default version is YAML 1.2
  • FYPCF_DEFAULT_VERSION_1_3 โ€” Default version is YAML 1.3 (experimental)
  • FYPCF_SLOPPY_FLOW_INDENTATION โ€” Allow sloppy indentation in flow mode
  • FYPCF_PREFER_RECURSIVE โ€” Prefer recursive algorighms instead of iterative whenever possible (again with the typo, i can't ๐Ÿ˜ญ)
  • FYPCF_JSON_AUTO โ€” Automatically enable JSON mode (when extension is .json)
  • FYPCF_JSON_NONE โ€” Never enable JSON input mode
  • FYPCF_JSON_FORCE โ€” Force JSON mode always
  • FYPCF_YPATH_ALIASES โ€” Enable YPATH aliases mode
  • FYPCF_ALLOW_DUPLICATE_KEYS โ€” Allow duplicate keys on mappings

Description

these flags control the operation of the parse and the debugging output/error reporting via filling in the fy_parse_cfg->flags member ๐Ÿ’–


๐Ÿ“ struct fy_parse_cfg ๐Ÿ“

struct fy_parse_cfg

parser configuration structure. (and we're stopping right here because the page cuts off โ€” more coming bestie, don't go anywhere ๐Ÿซถ)

Definition

struct fy_parse_cfg {
    const char *search_path;
    enum fy_parse_cfg_flags flags;
    void *userdata;
    struct fy_diag *diag;
}

Members ๐Ÿ’…

  • search_path โ€” the search path to use when you're opening files, separated by ':' (yes, like $PATH, bestie, same energy)
  • flags โ€” the configuration flags, your whole vibe-setting situation
  • userdata โ€” an opaque user data pointer, literally does not care what you put in there
  • diag โ€” optional diagnostic interface to use, if you're feeling observant ๐Ÿฉบ

Description

This is the argument you hand over to the fy_parser_create() method, which is the thing that actually does the parsing of YAML files. So like, this struct is the lil' permission slip your parser gets before it goes off and parses. ๐ŸŽ€


๐ŸŒˆ enum fy_event_type

enum fy_event_type

Event types, aka the whole cast of characters that can show up while you're parsing.

Definition

enum fy_event_type {
    FYET_NONE,
    FYET_STREAM_START,
    FYET_STREAM_END,
    FYET_DOCUMENT_START,
    FYET_DOCUMENT_END,
    FYET_MAPPING_START,
    FYET_MAPPING_END,
    FYET_SEQUENCE_START,
    FYET_SEQUENCE_END,
    FYET_SCALAR,
    FYET_ALIAS
};

Constants โœจ

  • FYET_NONE โ€” no event, the void, the nothing, the "leave me alone" state
  • FYET_STREAM_START โ€” stream start event, the opening credits ๐ŸŽฌ
  • FYET_STREAM_END โ€” stream end event, roll credits
  • FYET_DOCUMENT_START โ€” document start event
  • FYET_DOCUMENT_END โ€” document end event
  • FYET_MAPPING_START โ€” YAML mapping start event
  • FYET_MAPPING_END โ€” YAML mapping end event
  • FYET_SEQUENCE_START โ€” YAML sequence start event
  • FYET_SEQUENCE_END โ€” YAML sequence end event
  • FYET_SCALAR โ€” YAML scalar event
  • FYET_ALIAS โ€” YAML alias event

๐Ÿฆ‹ fy_event_type_get_text

const char *fy_event_type_get_text(enum fy_event_type type)

Returns the text of an event type. Give it a type, get a string back, iconic trade.

Parameters

  • type (enum fy_event_type) โ€” the event type you want the text from

Return

A pointer to a text โ€” like, for FYET_SCALAR you get "=VAL". Slay. ๐Ÿ’–


๐Ÿงš enum fy_collection_style

enum fy_collection_style

The collection styles that the parser/emitter supports, i.e. the two aesthetics a collection can serve.

Definition

enum fy_collection_style {
    FYCS_ANY,
    FYCS_BLOCK,
    FYCS_FLOW,
    FYCS_MAX
};

Constants

  • FYCS_ANY โ€” any collection style. Note: the parser never generates this one โ€” it just lets the emitter choose ๐Ÿ‘‘
  • FYCS_BLOCK โ€” block style (not {}[])
  • FYCS_FLOW โ€” flow style {}[]
  • FYCS_MAX โ€” marks end of scalar styles

๐Ÿ“ enum fy_scalar_style

enum fy_scalar_style

The scalar styles supported by the parser/emitter โ€” every way a scalar can dress itself.

Definition

enum fy_scalar_style {
    FYSS_ANY,
    FYSS_PLAIN,
    FYSS_SINGLE_QUOTED,
    FYSS_DOUBLE_QUOTED,
    FYSS_LITERAL,
    FYSS_FOLDED,
    FYSS_MAX
};

Constants

  • FYSS_ANY โ€” any scalar style. Not generated by the parser โ€” it lets the emitter choose ๐Ÿ’…
  • FYSS_PLAIN โ€” plain scalar style
  • FYSS_SINGLE_QUOTED โ€” single quoted style
  • FYSS_DOUBLE_QUOTED โ€” double quoted style
  • FYSS_LITERAL โ€” YAML literal block style
  • FYSS_FOLDED โ€” YAML folded block style
  • FYSS_MAX โ€” marks end of scalar styles

๐ŸŽ€ struct fy_event_stream_start_data

struct fy_event_stream_start_data

Stream start event data, the little payload that rides along with a stream start.

Definition

struct fy_event_stream_start_data {
    struct fy_token *stream_start;
}

Members

  • stream_start โ€” the token that started the stream ๐Ÿซถ

๐ŸŽ€ struct fy_event_stream_end_data

struct fy_event_stream_end_data

Stream end event data.

Definition

struct fy_event_stream_end_data {
    struct fy_token *stream_end;
}

Members

  • stream_end โ€” the token that ended the stream

๐ŸŽ€ struct fy_event_document_start_data

struct fy_event_document_start_data

Document start event data (the manpage says "doument", we love a typo queen ๐Ÿ˜ญ).

Definition

struct fy_event_document_start_data {
    struct fy_token *document_start;
    struct fy_document_state *document_state;
    bool implicit;
}

Members

  • document_start โ€” the token that started the document, or NULL if the document was implicitly started
  • document_state โ€” the state of the document (i.e. info about the YAML version and the configured tags)
  • implicit โ€” true if the document started implicitly

๐ŸŽ€ struct fy_event_document_end_data

struct fy_event_document_end_data

Document end event data (again with the "doument", we stan consistency ๐Ÿ’€).

Definition

struct fy_event_document_end_data {
    struct fy_token *document_end;
    bool implicit;
}

Members

  • document_end โ€” the token that ended the document, or NULL if the document was implicitly ended
  • implicit โ€” true if the document ended implicitly

๐ŸŽ€ struct fy_event_alias_data

struct fy_event_alias_data

Alias event data.

Definition

struct fy_event_alias_data {
    struct fy_token *anchor;
}

Members

  • anchor โ€” the anchor token defining this alias. It's giving "I know a guy" energy.

๐ŸŽ€ struct fy_event_scalar_data

struct fy_event_scalar_data

Scalar event data.

Definition

struct fy_event_scalar_data {
    struct fy_token *anchor;
    struct fy_token *tag;
    struct fy_token *value;
    bool tag_implicit;
}

Members

  • anchor โ€” anchor token, or NULL
  • tag โ€” tag token, or NULL
  • value โ€” scalar value token (this one cannot be NULL, no cap)
  • tag_implicit โ€” true if the tag was implicit or explicit

๐ŸŽ€ struct fy_event_sequence_start_data

struct fy_event_sequence_start_data

Sequence start event data.

Definition

struct fy_event_sequence_start_data {
    struct fy_token *anchor;
    struct fy_token *tag;
    struct fy_token *sequence_start;
}

Members

  • anchor โ€” anchor token, or NULL
  • tag โ€” tag token, or NULL
  • sequence_start โ€” sequence start value token, or NULL if the sequence was started implicitly

๐ŸŽ€ struct fy_event_sequence_end_data

struct fy_event_sequence_end_data

Sequence end event data.

Definition

struct fy_event_sequence_end_data {
    struct fy_token *sequence_end;
}

Members

  • sequence_end โ€” the token that ended the sequence, or NULL if the sequence was implicitly ended

๐ŸŽ€ struct fy_event_mapping_start_data

struct fy_event_mapping_start_data

Mapping start event data.

Definition

struct fy_event_mapping_start_data {
    struct fy_token *anchor;
    struct fy_token *tag;
    struct fy_token *mapping_start;
}

Members

  • anchor โ€” anchor token, or NULL
  • tag โ€” tag token, or NULL
  • mapping_start โ€” mapping start value token, or NULL if the mapping was started implicitly

๐ŸŽ€ struct fy_event_mapping_end_data

struct fy_event_mapping_end_data

Mapping end event data.

Definition

struct fy_event_mapping_end_data {
    struct fy_token *mapping_end;
}

Members

  • mapping_end โ€” the token that ended the mapping, or NULL if the mapping was implicitly ended

๐Ÿ‘‘ struct fy_event

struct fy_event

The event generated by the parser โ€” the main character of this whole section, honestly.

Definition

struct fy_event {
    enum fy_event_type type;
    union {
        struct fy_event_stream_start_data stream_start;
        struct fy_event_stream_end_data stream_end;
        struct fy_event_document_start_data document_start;
        struct fy_event_document_end_data document_end;
        struct fy_event_alias_data alias;
        struct fy_event_scalar_data scalar;
        struct fy_event_sequence_start_data sequence_start;
        struct fy_event_sequence_end_data sequence_end;
        struct fy_event_mapping_start_data mapping_start;
        struct fy_event_mapping_end_data mapping_end;
    } ;
}

Members

  • type โ€” type of the event, see enum fy_event_type
  • {unnamed_union} โ€” anonymous ๐Ÿ‘ป
  • stream_start โ€” stream start information, valid when fy_event->type is enum FYET_STREAM_START
  • stream_end โ€” stream end information, valid when fy_event->type is enum FYET_STREAM_END
  • document_start โ€” document start information, valid when fy_event->type is enum FYET_DOCUMENT_START
  • document_end โ€” document end information, valid when fy_event->type is enum FYET_DOCUMENT_END
  • alias โ€” alias information, valid when fy_event->type is enum FYET_ALIAS
  • scalar โ€” scalar information, valid when fy_event->type is enum FYET_SCALAR
  • sequence_start โ€” sequence start information, valid when fy_event->type is enum FYET_SEQUENCE_START
  • sequence_end โ€” sequence end information, valid when fy_event->type is enum FYET_SEQUENCE_END
  • mapping_start โ€” mapping start information, valid when fy_event->type is enum FYET_MAPPING_START
  • mapping_end โ€” mapping end information, valid when fy_event->type is enum FYET_MAPPING_END

Description

The parser generates one of these bad boys on every single call to fy_parser_parse(), and you release it with fy_parser_event_free(). Yes bestie, every call โ€” that's the whole cycle, don't forget the free or it's a leak situation ๐Ÿ™ˆ


โญ enum fy_event_part

enum fy_event_part

Lets you select a specific part of the event, like picking a track off an album.

Definition

enum fy_event_part {
    FYEP_VALUE,
    FYEP_TAG,
    FYEP_ANCHOR
};

Constants

  • FYEP_VALUE โ€” the value of the event (the main token) ๐ŸŒŸ
  • FYEP_TAG โ€” the tag of the event
  • FYEP_ANCHOR โ€” the anchor of the event

๐Ÿ’œ fy_event_get_type

enum fy_event_type fy_event_get_type(const struct fy_event *fye)

Gets the event's type. Detective behaviour, love that.

Parameters

  • fye (const struct fy_event*) โ€” the event

Description

Returns the type of the event.

Return

The event type, or FYET_NONE when the event is invalid.


๐Ÿ’œ fy_event_data

void *fy_event_data(struct fy_event *fye)

Gets a pointer to the event data.

Parameters

  • fye (struct fy_event*) โ€” the event

Description

So here's the tea: some languages (cough*golang*cough) really don't like unions, and anonymous unions in particular. Like, they'll literally refuse.

You should not have to use this in other language bindings. It's a workaround, not a lifestyle.

Return

A pointer to the event data structure, or NULL if the event is invalid.


๐ŸŒธ fy_library_version

const char *fy_library_version(void)

Returns the library version string. Vibe check on the library itself.

Parameters

  • void โ€” no arguments, she takes nothing ๐Ÿ’…

Return

A pointer to a version string of the form <MAJOR>.<MINOR>[[.<PATCH>][-EXTRA-VERSION-INFO]]


๐Ÿ”ฅ fy_string_to_error_type

enum fy_error_type fy_string_to_error_type(const char *str)

Returns the error type from a string โ€” hand it a string, get the matching error type back.

Parameters

โ€ฆokay the parameter list is literally where this part of the page cuts off, hold on, next bit picks it right back up ๐Ÿซถ

  • str (const char*) โ€” the string you want turned into an error type, bestie

Return

The error type if it's greater than or equal to zero, otherwise FYET_MAX (that's the "nope, didn't work" value, no cap) ๐Ÿ’…


fy_error_type_to_string

const char *fy_error_type_to_string(enum fy_error_type type)

Turn an error type into a string. Like, giving the enum a little name tag โœจ

Parameters

  • type (enum fy_error_type) โ€” the error type you want converted

Return

The string value of the error type, or the empty string "" on error (yes, literally just an empty string, that's the whole mood) ๐Ÿ˜ญ


fy_string_to_error_module

enum fy_error_module fy_string_to_error_module(const char *str)

Give it a string, get back the error module. Reverse uno card ๐Ÿƒ

Parameters

  • str (const char*) โ€” the string to convert to an error module

Return

The error type if it's greater than or equal to zero, FYEM_MAX otherwise


fy_error_module_to_string

const char *fy_error_module_to_string(enum fy_error_module module)

Convert an error module to a string ๐ŸŽ€

Parameters

  • module (enum fy_error_module) โ€” the error module to convert

Return

The string value of the error module, or the empty string "" on error


fy_event_is_implicit

bool fy_event_is_implicit(struct fy_event *fye)

Vibe check on an event: is it an implicit one or not? ๐Ÿ‘€

Parameters

  • fye (struct fy_event*) โ€” a pointer to a struct fy_event to check

Return

true if the event is an implicit one ๐Ÿ’–


fy_document_event_is_implicit

bool fy_document_event_is_implicit(const struct fy_event *fye)

Same vibe check but specifically for a document event ๐Ÿฆ‹

Parameters

  • fye (const struct fy_event*) โ€” a pointer to a struct fy_event to check. It must be either a document start or document end event. Like, that's the assignment, there's no negotiation here ๐Ÿ”ฅ

Return

true if the event is an implicit one


fy_parser_create

struct fy_parser *fy_parser_create(const struct fy_parse_cfg *cfg)

Create a parser. Main character energy, honestly ๐Ÿ‘‘

Parameters

  • cfg (const struct fy_parse_cfg*) โ€” the configuration for the parser

Description

Creates a parser with its configuration cfg. The parser may be destroyed by a corresponding call to fy_parser_destroy(). Slay, and also clean up after yourself ๐Ÿ’…

Return

A pointer to the parser, or NULL in case of an error


fy_parser_destroy

void fy_parser_destroy(struct fy_parser *fyp)

Destroy the given parser. It's not toxic, it's just over โœจ

Parameters

  • fyp (struct fy_parser*) โ€” the parser to destroy

Description

Destroy a parser you created earlier via fy_parser_create(). Closure, but make it C ๐Ÿซถ


fy_parser_get_cfg

const struct fy_parse_cfg *fy_parser_get_cfg(struct fy_parser *fyp)

Get the configuration of a parser. Receipts ๐Ÿ‘€

Parameters

  • fyp (struct fy_parser*) โ€” the parser

Return

The configuration of the parser


fy_parser_get_diag

struct fy_diag *fy_parser_get_diag(struct fy_parser *fyp)

Get the diagnostic object of a parser ๐Ÿฉบ

Parameters

  • fyp (struct fy_parser*) โ€” the parser to get the diagnostic object from

Description

Returns a pointer to the diagnostic object of a parser object. Note that the returned diag object has a reference taken, so you should fy_diag_unref() it when you're done with it. Like, you can't just keep holding it forever, that's rude ๐ŸŒธ

Return

A pointer to a ref'ed diagnostic object, or NULL in case of an error


fy_parser_set_diag

int fy_parser_set_diag(struct fy_parser *fyp, struct fy_diag *diag)

Set the diagnostic object of a parser. Swapping out the whole personality fr fr ๐Ÿ’œ

Parameters

  • fyp (struct fy_parser*) โ€” the parser to replace the diagnostic object of
  • diag (struct fy_diag*) โ€” the parser's new diagnostic object, NULL for default

Description

Replace the parser's current diagnostic object with the one given as an argument. The previous diagnostic object will be unref'ed (and freed if its reference gets to 0). Also note that the diag argument shall take a reference too. Keep track of your refcounts bestie, that's the whole gig ๐ŸŽ€

Return

0 if everything OK, -1 otherwise


fy_parser_reset

int fy_parser_reset(struct fy_parser *fyp)

Reset a parser completely. Fresh start, healed era ๐ŸŒˆ

Parameters

  • fyp (struct fy_parser*) โ€” the parser to reset

Description

Completely reset a parser, including after an error that caused a parser error to be emitted. So even your messiest era is recoverable, iconic honestly.

Return

0 if the reset was successful, -1 otherwise


fy_parser_set_input_file

int fy_parser_set_input_file(struct fy_parser *fyp, const char *file)

Set the parser to process the given file ๐Ÿ“‚

Parameters

  • fyp (struct fy_parser*) โ€” the parser
  • file (const char*) โ€” the file to parse

Description

Point the parser at the given file for processing. The file is located by honoring the search path of the configuration set by the earlier call to fy_parser_create(). While the parser is in use the file must be available โ€” like, don't go moving it mid-parse, that's chaos ๐Ÿ˜ญ (the original literally says "the file will must be available", and honestly? same energy)

Return

Zero on success, -1 on error


fy_parser_set_string

int fy_parser_set_string(struct fy_parser *fyp, const char *str, size_t len)

Set the parser to process the given string โœจ

Parameters

  • fyp (struct fy_parser*) โ€” the parser
  • str (const char*) โ€” the YAML string to parse
  • len (size_t) โ€” the length of the string (or -1 if 0 terminated)

Description

Point the parser at the given (NULL terminated) string. Note that while the parser is active the string must not go out of scope. Do not let it wander off, bestie, that's undefined-behaviour territory ๐Ÿ™ˆ

Return

Zero on success, -1 on error


fy_parser_set_malloc_string

int fy_parser_set_malloc_string(struct fy_parser *fyp, char *str, size_t len)

Set the parser to process the given malloced string. Handing over the keys ๐Ÿ—๏ธ

Parameters

  • fyp (struct fy_parser*) โ€” the parser
  • str (char*) โ€” the YAML string to parse (allocated)
  • len (size_t) โ€” the length of the string (or -1 if 0 terminated)

Description

Point the parser at the given (possible NULL terminated) string. Note that the string is expected to be allocated via malloc(3) and ownership is transferred to the created input. When the input is free'ed the memory will be automatically freed โ€” cute little memory-management situationship ๐Ÿ’–

In case of an error the string is not freed. So if it errors, that malloc is still yours to deal with, no take-backs ๐Ÿซ 

Return

Zero on success, -1 on error


fy_parser_set_input_fp

int fy_parser_set_input_fp(struct fy_parser *fyp, const char *name, FILE *fp)

Set the parser to process the given file ๐ŸŒธ

Parameters

  • fyp (struct fy_parser*) โ€” the parser
  • name (const char*) โ€” the label of the stream
  • fp (FILE*) โ€” the FILE pointer, it must be open in read mode

Description

Point the parser to use fp for processing. Read mode only, we're not out here writing files by accident ๐Ÿ’€

Return

Zero on success, -1 on error


fy_parser_set_input_callback

int fy_parser_set_input_callback(struct fy_parser *fyp, void *user, ssize_t (*callback)(void *user, void *buf, size_t count))

Set the parser to process via a callback. Very "you call me, I call you" of it ๐Ÿ“ž

Parameters

  • fyp (struct fy_parser*) โ€” the parser
  • user (void*) โ€” the user data pointer
  • callback (ssize_t (*)(void *user, void *buf, size_t count)) โ€” the callback method to request data with

Description

Point the parser to use a callback for input.

Return

Zero on success, -1 on error


fy_parser_set_input_fd

int fy_parser_set_input_fd(struct fy_parser *fyp, int fd)

Set the parser to process the given file descriptor ๐Ÿ”ข

Parameters

  • fyp (struct fy_parser*) โ€” the parser
  • fd (int) โ€” the file descriptor to use

Description

Point the parser to use fd for processing.

Return

Zero on success, -1 on error


fy_parser_parse

struct fy_event *fy_parser_parse(struct fy_parser *fyp)

Parse and return the next event. The moment we've all been waiting for โญ

Parameters

  • fyp (struct fy_parser*) โ€” the parser

Description

Each call to fy_parser_parse() returns the next event from the configured input of the parser, or NULL at the end of the stream. The returned event must be released via a matching call to fy_parser_event_free(). Like, every event you take, you give back, that's the rule ๐Ÿค

Return

The next event in the stream, or NULL


fy_parser_parse_peek

const struct fy_event *fy_parser_parse_peek(struct fy_parser *fyp)

Parse and peek at the next event. Looking respectfully ๐Ÿ‘€

Parameters

  • fyp (struct fy_parser*) โ€” the parser

Description

It will return the next event that a call to fy_parser_parse would generate, but as read-only.

You must not free this event. Look, don't touch, don't free ๐Ÿ™…โ€โ™€๏ธ

Return

A peek at the next event in the stream, or NULL


fy_parser_skip

int fy_parser_skip(struct fy_parser *fyp)

Skip the current scalar/collection. Leaving it on read, moving on ๐Ÿ’จ

Parameters

  • fyp (struct fy_parser*) โ€” the parser

Description

Skips the current scalar or collection.

Return

0 on success, -1 on error


fy_parser_count_sequence_items

int fy_parser_count_sequence_items(struct fy_parser *fyp)

Count the sequence items ๐Ÿ”ขโœจ

Parameters

  • fyp (struct fy_parser*) โ€” the parser

Description

Counts the number of sequence items. The parser must already be in a sequence state. Note that this uses backtracking so it might not be very efficient โ€” it's giving "doing the most", honestly ๐Ÿซ 

Return

The number of sequence items on success, -1 on error. Note: if the number of items exceeds INT_MAX, INT_MAX will be returned. (Yes, it just caps out and doesn't tell you, iykyk ๐Ÿ’€)


fy_parser_count_mapping_items

int fy_parser_count_mapping_items(struct fy_parser *fyp)

Count the mapping items ๐Ÿ—บ๏ธ

Parameters

  • fyp (struct fy_parser*) โ€” the parser

Description

Counts the number of mapping items. The parser must already be in a mapping state. Note that this uses backtracking so it might not be very efficient โ€” same energy as the sequence one, it's out here re-walking everything ๐Ÿ˜ฎโ€๐Ÿ’จ

Return

The number of mapping items on success, -1 on error. Note: if the number of items exceeds INT_MAX, INT_MAX will be returned.


fy_parser_event_free

void fy_parser_event_free(struct fy_parser *fyp, struct fy_event *fye)

Free an event. The little cleanup ritual ๐Ÿงน

Parameters

  • fyp (struct fy_parser*) โ€” the parser
  • fye (struct fy_event*) โ€” the event to free (may be NULL)

Description

Free a previously returned event from fy_parser_parse(). Give it back to the universe ๐Ÿ’ซ


fy_parser_get_stream_error

bool fy_parser_get_stream_error(struct fy_parser *fyp)

Check the parser for stream errors ๐Ÿšจ

Parameters

  • fyp (struct fy_parser*) โ€” the parser

Return

true in case of a stream error, false otherwise


fy_parser_get_mode

enum fy_parser_mode fy_parser_get_mode(struct fy_parser *fyp)

Get the parser mode ๐ŸŽ›๏ธ

So like, real quick before we keep going โ€” this stretch is all about the parser's little diary entries (logs and reports) plus the token besties that hold all the text, styles, and comments. Buckle up, we're going in. ๐Ÿ’…


the parser mode getter (yes, this one) โœจ

Parameters

  • fyp (struct fy_parser *) โ€” the parser, obviously.

Description

Grab the parser's current mode, i.e. which YAML version / format it's chewing through rn โ€” YAML 1.1, 1.2, 1.3, or JSON. Iconic little identity check, no cap.

Return

The parser mode. Periodt.


fy_parser_vlog ๐Ÿซถ

void fy_parser_vlog(struct fy_parser *fyp, enum fy_error_type type,
                    const char *fmt, va_list ap)

Log using the parser's diagnostics, printf style, but with the va_arg flavour.

Parameters

  • fyp (struct fy_parser *) โ€” the parser.
  • type (enum fy_error_type) โ€” the error type.
  • fmt (const char *) โ€” the printf format string.
  • ap (va_list) โ€” the argument list.

Description

Drops a log entry onto the parser's diagnostic output. Lowkey the va_list sibling of fy_parser_log, iykyk.


fy_parser_log ๐ŸŒธ

void fy_parser_log(struct fy_parser *fyp, enum fy_error_type type,
                   const char *fmt, ...)

Log using the parser's diagnostics, printf style.

Parameters

  • fyp (struct fy_parser *) โ€” the parser.
  • type (enum fy_error_type) โ€” the error type.
  • fmt (const char *) โ€” the printf format string.
  • ellipsis (ellipsis) โ€” the extra arguments.

Description

Outputs a report on the parser's diagnostics. Same vibe as fy_parser_vlog, just the variadic main-character version ๐Ÿ’…


fy_parser_vreport ๐Ÿ”ฅ

void fy_parser_vreport(struct fy_parser *fyp, enum fy_error_type type,
                       struct fy_token *fyt, const char *fmt, va_list ap)

Report using the parser's diagnostics, printf style, and mark the token โ€” va_arg edition.

Parameters

  • fyp (struct fy_parser *) โ€” the parser.
  • type (enum fy_error_type) โ€” the error type.
  • fyt (struct fy_token *) โ€” the token.
  • fmt (const char *) โ€” the printf format string.
  • ap (va_list) โ€” the argument list.

Description

Outputs a report on the parser and points at the token's position while doing it. It's giving "here's the problem, and here's exactly where ๐Ÿ‘€".


fy_parser_report โญ

void fy_parser_report(struct fy_parser *fyp, enum fy_error_type type,
                      struct fy_token *fyt, const char *fmt, ...)

Report using the parser's diagnostics, printf style, and mark the token.

Parameters

  • fyp (struct fy_parser *) โ€” the parser.
  • type (enum fy_error_type) โ€” the error type.
  • fyt (struct fy_token *) โ€” the token.
  • fmt (const char *) โ€” the printf format string.
  • ellipsis (ellipsis) โ€” the extra arguments.

Description

Outputs a report on the parser and indicates the token's position. Fr the variadic twin of fy_parser_vreport ๐ŸŽ€


fy_token_scalar_style ๐Ÿฆ‹

enum fy_scalar_style fy_token_scalar_style(struct fy_token *fyt)

Get the style of a scalar token.

Parameters

  • fyt (struct fy_token *) โ€” the scalar token whose style we're getting. Note: a NULL token counts as enum FYSS_PLAIN.

Return

The scalar style of the token, or FYSS_PLAIN in every other case. Soft launch, no drama ๐Ÿ’œ


fy_token_collection_style ๐ŸŒˆ

enum fy_collection_style fy_token_collection_style(struct fy_token *fyt)

Get the style of a collection token.

Parameters

  • fyt (struct fy_token *) โ€” the collection token whose style we're getting. Note: a NULL token counts as enum FYCS_ANY.

Return

The collection style of the token, or FYCS_ANY.


fy_token_scalar_is_null ๐Ÿ™ˆ

bool fy_token_scalar_is_null(struct fy_token *fyt)

Test whether the scalar is null (as in, its content).

Parameters

  • fyt (struct fy_token *) โ€” the scalar token to check for NULLity.

Description

Okay important distinction, bestie โ€” this is not the same as null in the YAML type system. It's null as in null content. It's also different from an empty scalar. Three different things, three different vibes. Don't mix them up ๐Ÿ˜ญ

Return

true if it's a null scalar, false otherwise.


fy_token_get_text ๐Ÿ‘‘

const char *fy_token_get_text(struct fy_token *fyt, size_t *lenp)

Get the text (and its length) of a token.

Parameters

  • fyt (struct fy_token *) โ€” the token whose text pointer you want back.
  • lenp (size_t *) โ€” pointer to a variable that will hold the returned length.

Description

Returns a pointer to the token's text along with its length. Heads up: this text is not NULL terminated โ€” if you need a NULL terminated pointer, use fy_token_get_text0() instead.

If the token is "simple" enough (like a plain scalar) or something similar, the returned pointer is a direct pointer into the input space that holds the token. Which means the pointer is not guaranteed to be valid after the parser is destroyed ๐Ÿ’€

If the token is "complex" enough, then space gets allocated, filled, and returned.

And yeah, the concept of "simple" vs "complex" is vague โ€” that's on purpose. We said what we said ๐Ÿซถ

Return

A pointer to the text representation of the token, while lenp gets assigned the character length of said representation. NULL in case of an error.


fy_token_get_text0 ๐ŸŽ€

const char *fy_token_get_text0(struct fy_token *fyt)

Get zero-terminated text of a token.

Parameters

  • fyt (struct fy_token *) โ€” the token whose text pointer you want back.

Description

Returns a pointer to the token's text, and this time it is zero terminated. It allocates memory to hold it inside the token structure โ€” so try to use fy_token_get_text() instead if you can, bestie. Your allocator will thank you ๐Ÿ’–

Return

A pointer to a zero-terminated text representation of the token. NULL in case of an error.


fy_token_get_text_length ๐Ÿ“

size_t fy_token_get_text_length(struct fy_token *fyt)

Get the length of the text of a token.

Parameters

  • fyt (struct fy_token *) โ€” the token.

Description

Returns the length of the token's text representation. That's it, that's the whole job โœจ

Return

The size of the text representation of a token, -1 in case of an error. Note that a NULL token returns a length of zero.


enum fy_comment_placement ๐Ÿ’ฌ

Comment placement relative to the token.

Definition

enum fy_comment_placement {
    fycp_top,
    fycp_right,
    fycp_bottom
};

Constants

  • fycp_top โ€” comment on top of the token.
  • fycp_right โ€” comment to the right of the token.
  • fycp_bottom โ€” comment to the bottom of the token.

Three directions, three moods, all valid ๐ŸŒธ


fy_token_get_comment ๐ŸŒผ

const char *fy_token_get_comment(struct fy_token *fyt,
                                 enum fy_comment_placement which)

Get the zero-terminated comment of a token.

Parameters

  • fyt (struct fy_token *) โ€” the token whose comment text you want back.
  • which (enum fy_comment_placement) โ€” the comment placement.

Description

Grabs the comment attached to a token at the given placement. Very "which one, bestie, top, right, or bottom?" energy.

Return

A pointer to a zero-terminated text representation of the token comment. NULL in case of an error or if the token has no comment.


fy_token_get_comments ๐Ÿงš

const char *fy_token_get_comments(struct fy_token *fyt)

Get all the comments of a token.

Parameters

  • fyt (struct fy_token *) โ€” the token.

Description

Gets every comment attached to a token. All of them. The whole collection โœจ

Return

A pointer to a zero-terminated text representation of all the comments โ€” the comments from all the placements get concatenated and returned as one. NULL in case of an error or if the event has no comments.


fy_token_set_comment ๐Ÿ’…

int fy_token_set_comment(struct fy_token *fyt, enum fy_comment_placement which,
                         const char *text, size_t len)

Attach a comment to a token.

Parameters

  • fyt (struct fy_token *) โ€” the token the comment text gets attached to.
  • which (enum fy_comment_placement) โ€” the placement.
  • text (const char *) โ€” the text of the comment.
  • len (size_t) โ€” the length of the comment (FY_NT means the length of text).

Description

Attaches the given comment onto the token at the specified placement. If another comment is already sitting there, it gets overridden โ€” no warning, no sorry, just replaced. And if text is NULL, the comment is removed entirely ๐Ÿซง

Return

0 on success, -1 on failure.


fy_event_get_comments ๐Ÿ””

const char *fy_event_get_comments(struct fy_event *fye)

Get all the comments of an event.

Parameters

  • fye (struct fy_event *) โ€” the event.

Return

A pointer to a zero-terminated text representation of all the comments โ€” all placements concatenated into one. NULL in case of an error or if the event has no comments.

Careful, bestie: the pointer must be freed if it's not NULL, via a call to free(). Don't leave it hanging ๐Ÿ˜ญ

fy_node_get_comment ๐ŸŒท

const char *fy_node_get_comment(struct fy_node *fyn,
                                enum fy_comment_placement which)

Get a comment of a node.

Parameters

  • fyn (struct fy_node *) โ€” the node.
  • which (enum fy_comment_placement) โ€” the placement of the comment.

Return

A pointer to a zero-terminated text representation of the comment. NULL in case of an error or if the event has no such comments.


fy_node_get_comments ๐ŸŒป

const char *fy_node_get_comments(struct fy_node *fyn)

Get all the comments of a node.

Parameters

  • fyn (struct fy_node *) โ€” the node.

Return

A pointer to a zero-terminated text representation of all the comments โ€” every placement concatenated and returned as one. NULL in case of an error or if the event has no comments.


struct fy_iter_chunk ๐Ÿงฉ

An iteration chunk.

Definition

struct fy_iter_chunk {
    const char *str;
    size_t len;
}

Members

  • str โ€” pointer to the start of the chunk.
  • len โ€” the size of the chunk.

Description

The iterator produces a stream of chunks which cover the whole object. Like little bite-sized pieces of the thing you're walking through ๐Ÿฐ


fy_token_iter_create ๐Ÿฆ‹

struct fy_token_iter *fy_token_iter_create(struct fy_token *fyt)

Create a token iterator.

Parameters

  • fyt (struct fy_token *) โ€” the token to iterate, or NULL.

Description

Creates an iterator for operating on the given token โ€” or, if you hand it NULL, a generic iterator for use with fy_token_iter_start(). The iterator must be destroyed with a matching call to fy_token_iter_destroy(). No ghost iterators, bestie ๐Ÿ‘ป

Return

A pointer to the newly created iterator, or NULL in case of an error.


fy_token_iter_destroy ๐Ÿซง

void fy_token_iter_destroy(struct fy_token_iter *iter)

Destroy the iterator.

Parameters

  • iter (struct fy_token_iter *) โ€” the iterator to destroy.

Description

Destroys the iterator created by fy_token_iter_create(). Clean up after yourself, it's the least you can do ๐Ÿ’œ

fy_token_iter_start

void fy_token_iter_start(struct fy_token *fyt, struct fy_token_iter *iter)

Ok so bestie, this one starts the whole iteration vibe over the contents of a token. ๐ŸŽ€

Parameters

  • fyt (*struct fy_token**) โ€” the token you're gonna iterate over, the main character of this operation
  • iter (*struct fy_token_iter**) โ€” the iterator you're prepping for the journey

Description

It sets up an iterator so it's ready to operate on the given token. Important little detail: the iterator has to have been created by a previous call to fy_token_iter_create() if you want user level API access. No shortcutting that, iykyk. โœจ


fy_token_iter_finish

void fy_token_iter_finish(struct fy_token_iter *iter)

The graceful exit. Stops iterating over the contents of a token โ€” closing time, lights off. ๐Ÿ’…

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator in question

Description

Stops the iteration operation. That's it, that's the whole thing. Periodt.


fy_token_iter_peek_chunk

const struct fy_iter_chunk *fy_token_iter_peek_chunk(struct fy_token_iter *iter)

A little looky-loo ๐Ÿ‘€ at the next iterator chunk โ€” no commitment, just peeking.

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator

Description

Peeks at the next iterator chunk. That's the assignment, and it ate.

Return

A pointer to the next iterator chunk, or NULL in case there's no other. ๐Ÿซถ


fy_token_iter_chunk_next

const struct fy_iter_chunk *fy_token_iter_chunk_next(struct fy_token_iter *iter, const struct fy_iter_chunk *curr, int *errp)

Gets the next chunk in the sequence โ€” like scrolling to the next slide in the deck. ๐Ÿฆ‹

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator
  • curr (*const struct fy_iter_chunk**) โ€” the current chunk, or NULL for the first one
  • errp (*int**) โ€” pointer to an error return value, or NULL

Description

Gets the next iterator chunk in sequence. Lowkey straightforward, highkey essential.

Return

A pointer to the next iterator chunk, or NULL in case there's no other. And heads up: when the return value is NULL, the errp variable gets filled with 0 for a normal end, or -1 in case of an error. Big distinction, don't sleep on it. ๐Ÿ’€


fy_token_iter_advance

void fy_token_iter_advance(struct fy_token_iter *iter, size_t len)

Moves the iterator position forward like you're skipping ahead in a group chat. โญ

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator
  • len (size_t*) โ€” the number of bytes to advance the iterator position

Description

It advances the read pointer of the iterator. But listen: mixing calls of this with any call of fy_token_iter_ungetc() / fy_token_iter_utf8_unget() in a single iterator sequence leads to undefined behavior. Not a cute look, don't do it. ๐Ÿ˜ญ


fy_token_iter_read

ssize_t fy_token_iter_read(struct fy_token_iter *iter, void *buf, size_t count)

Reads a whole block from an iterator โ€” the "give me a handful" option. ๐Ÿ“

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator
  • buf (*void**) โ€” pointer to a block of memory to receive the data; it must be at least count bytes long
  • count (size_t*) โ€” the amount of bytes to read

Description

Reads a block from an iterator. And same warning as before: mixing calls of this with any of the ungetc methods leads to undefined behavior. Fr fr, keep them separate.

Return

The amount of data read, or -1 in case of an error.


fy_token_iter_getc

int fy_token_iter_getc(struct fy_token_iter *iter)

One singular character, please and thank you. ๐Ÿ’–

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator

Description

Reads a single character from an iterator. If the iterator is finished, it will return -1. And if any calls to ungetc have pushed a character into the iterator, it shall return that one instead.

Return

The next character in the iterator, or -1 in case of an error, or end of stream. Very demure, very mindful.


fy_token_iter_ungetc

int fy_token_iter_ungetc(struct fy_token_iter *iter, int c)

The pushback move โ€” putting a character back like you never took it. ๐Ÿ™ˆ

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator
  • c (int*) โ€” the character to push back, or -1 to reset the pushback buffer

Description

Pushes back a single character to an iterator stream, and it will be returned in subsequent calls of fy_token_iter_getc(). Currently only a single character is allowed to be pushed back, and any further calls to ungetc will return an error. One at a time, bestie, we're not made of buffer space. ๐Ÿ’…

Return

The pushed back character given as argument, or -1 in case of an error. And a lil plot twist: if the pushed back character was -1, then 0 will be returned. ๐ŸŒธ


fy_token_iter_peekc

int fy_token_iter_peekc(struct fy_token_iter *iter)

Peeks at a single character like checking who's typing before you reply. ๐Ÿ‘‘

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator

Description

Peeks at the next character to get from an iterator. If the iterator is finished, it will return -1. If any calls to ungetc have pushed a character into the iterator, it shall return that. Key detail: the character is not removed from the iterator stream. It stays. Iconic behavior, honestly.

Return

The next character in the iterator, or -1 in case of an error, or end of stream.


fy_token_iter_utf8_get

int fy_token_iter_utf8_get(struct fy_token_iter *iter)

Same energy as getc but โœจmultibyteโœจ โ€” getting a single utf8 character. ๐ŸŒˆ

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator

Description

Reads a single utf8 character from an iterator. If the iterator is finished, it will return -1. If any calls to ungetc have pushed a character into the iterator, it shall return that.

Return

The next utf8 character in the iterator, or -1 in case of an error, or end of stream.


fy_token_iter_utf8_unget

int fy_token_iter_utf8_unget(struct fy_token_iter *iter, int c)

The utf8 pushback โ€” putting a whole character back into the stream. ๐Ÿงš

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator
  • c (int*) โ€” the character to push back, or -1 to reset the pushback buffer

Description

Pushes back a single utf8 character to an iterator stream. It will be returned in subsequent calls of fy_token_iter_utf8_getc(). Currently only a single character is allowed to be pushed back, and any further calls to ungetc will return an error. Same rule as the byte version, no cap.

Return

The pushed back utf8 character given as argument, or -1 in case of an error. If the pushed back utf8 character was -1, then 0 will be returned. ๐Ÿซถ


fy_token_iter_utf8_peek

int fy_token_iter_utf8_peek(struct fy_token_iter *iter)

Peeking, but make it utf8. ๐Ÿ’œ

Parameters

  • iter (*struct fy_token_iter**) โ€” the iterator

Description

Peeks at the next utf8 character to get from an iterator. If the iterator is finished, it will return -1. If any calls to ungetc have pushed a character into the iterator, it shall return that. And again โ€” the character is not removed from the iterator stream.

Return

The next utf8 character in the iterator, or -1 in case of an error, or end of stream.


fy_parse_load_document

struct fy_document *fy_parse_load_document(struct fy_parser *fyp)

Parses the next document off the parser stream โ€” the actual main event. ๐Ÿ”ฅ

Parameters

  • fyp (*struct fy_parser**) โ€” the parser

Description

This method performs parsing on a parser stream and returns the next document. Which means for a compound document with multiple documents, each call will return the next one. Like flipping to the next page, one at a time. ๐Ÿ“–

Return

The next document from the parser stream.


fy_parse_document_destroy

void fy_parse_document_destroy(struct fy_parser *fyp, struct fy_document *fyd)

Cleans up a document that came from fy_parse_load_document(). Closure, babes. ๐ŸŽ€

Parameters

  • fyp (*struct fy_parser**) โ€” the parser
  • fyd (*struct fy_document**) โ€” the document to destroy

fy_document_resolve

int fy_document_resolve(struct fy_document *fyd)

Resolves anchors and merge keys โ€” tying up all the loose ends. โœจ

Parameters

  • fyd (*struct fy_document**) โ€” the document to resolve

Description

This method performs resolution of the given document by replacing references to anchors with their contents and handling merge keys (<<). Very "make it make sense" of it.

Return

zero on success, -1 on error.


fy_document_has_directives

bool fy_document_has_directives(const struct fy_document *fyd)

A lil vibe check for directives. ๐Ÿ‘€

Parameters

  • fyd (*const struct fy_document**) โ€” the document to check for directives existence

Description

Checks whether the given document has any directives, i.e. TAG or VERSION.

Return

true if directives exist, false if not.


fy_document_has_explicit_document_start

bool fy_document_has_explicit_document_start(const struct fy_document *fyd)

Checking if the document rolled up with an explicit start marker. ๐ŸŒŸ

Parameters

  • fyd (*const struct fy_document**) โ€” the document to check for explicit start marker

Description

Checks whether the given document has an explicit document start marker, i.e. ---

Return

true if the document has an explicit document start marker, false if not.


fy_document_has_explicit_document_end

bool fy_document_has_explicit_document_end(const struct fy_document *fyd)

And now the end-marker equivalent โ€” the "that's a wrap" check. ๐ŸŽฌ

Parameters

  • fyd (*const struct fy_document**) โ€” the document to check for explicit end marker

Description

Checks whether the given document has an explicit document end marker, i.e. ...

Return

true if the document has an explicit document end marker, false if not.


fy_node_document

struct fy_document *fy_node_document(struct fy_node *fyn)

Retrieves the document that the node belongs to โ€” finding the node's home base. ๐Ÿ 

Parameters

  • fyn (*struct fy_node**) โ€” the node to retrieve its document

Description

Returns the document of the node. Note that while the node may not be reachable via a path expression, it may still be a member of a document. So don't count it out just because you can't path your way there. ๐Ÿ’ซ

Return

The document of the node, or NULL in case of an error, or when the node has no document attached.


enum fy_emitter_write_type

enum fy_emitter_write_type

Type of the emitted output โ€” and yes, this is exactly where things keep going, don't go anywhere. ๐Ÿ’…

Definition

okay so this is the enum that tags every little chunk the emitter spits out โ€” like each fragment gets a name badge so you know exactly what it is โœจ

enum fy_emitter_write_type {
    fyewt_document_indicator,
    fyewt_tag_directive,
    fyewt_version_directive,
    fyewt_indent,
    fyewt_indicator,
    fyewt_whitespace,
    fyewt_plain_scalar,
    fyewt_single_quoted_scalar,
    fyewt_double_quoted_scalar,
    fyewt_literal_scalar,
    fyewt_folded_scalar,
    fyewt_anchor,
    fyewt_tag,
    fyewt_linebreak,
    fyewt_alias,
    fyewt_terminating_zero,
    fyewt_plain_scalar_key,
    fyewt_single_quoted_scalar_key,
    fyewt_double_quoted_scalar_key,
    fyewt_comment,
    fyewt_indicator_question_mark,
    fyewt_indicator_colon,
    fyewt_indicator_dash,
    fyewt_indicator_left_bracket,
    fyewt_indicator_right_bracket,
    fyewt_indicator_left_brace,
    fyewt_indicator_right_brace,
    fyewt_indicator_comma,
    fyewt_indicator_bar,
    fyewt_indicator_greater,
    fyewt_indicator_single_quote_start,
    fyewt_indicator_single_quote_end,
    fyewt_indicator_double_quote_start,
    fyewt_indicator_double_quote_end,
    fyewt_indicator_ambersand,
    fyewt_indicator_star,
    fyewt_indicator_chomp,
    fyewt_indicator_explicit_indent
};

๐Ÿงš Constants

so here's the whole cast, one by one ๐Ÿ’…

  • fyewt_document_indicator โ€” this chunk is a document indicator.
  • fyewt_tag_directive โ€” this chunk is a tag directive.
  • fyewt_version_directive โ€” this chunk is a version directive.
  • fyewt_indent โ€” the manpage literally says "Output chunk is a document indicator" here too ๐Ÿ˜ญ yes bestie, same sentence as above, I'm not making the rules, I'm just telling you what it says.
  • fyewt_indicator โ€” this chunk is an indicator.
  • fyewt_whitespace โ€” this chunk is white space.
  • fyewt_plain_scalar โ€” this chunk is a plain scalar.
  • fyewt_single_quoted_scalar โ€” this chunk is a single quoted scalar.
  • fyewt_double_quoted_scalar โ€” this chunk is a double quoted scalar.
  • fyewt_literal_scalar โ€” this chunk is a literal block scalar.
  • fyewt_folded_scalar โ€” this chunk is a folded block scalar.
  • fyewt_anchor โ€” this chunk is an anchor.
  • fyewt_tag โ€” this chunk is a tag.
  • fyewt_linebreak โ€” this chunk is a linebreak.
  • fyewt_alias โ€” this chunk is an alias.
  • fyewt_terminating_zero โ€” this chunk is a terminating zero.
  • fyewt_plain_scalar_key โ€” this chunk is a plain scalar key.
  • fyewt_single_quoted_scalar_key โ€” this chunk is a single quoted scalar key.
  • fyewt_double_quoted_scalar_key โ€” this chunk is a double quoted scalar key.
  • fyewt_comment โ€” this chunk is a comment.
  • fyewt_indicator_question_mark โ€” the ? indicator.
  • fyewt_indicator_colon โ€” the : indicator.
  • fyewt_indicator_dash โ€” the - indicator.
  • fyewt_indicator_left_bracket โ€” the [ indicator.
  • fyewt_indicator_right_bracket โ€” the ] indicator.
  • fyewt_indicator_left_brace โ€” the { indicator.
  • fyewt_indicator_right_brace โ€” the } indicator.
  • fyewt_indicator_comma โ€” the , indicator.
  • fyewt_indicator_bar โ€” the | indicator.
  • fyewt_indicator_greater โ€” the > indicator.
  • fyewt_indicator_single_quote_start โ€” the โ€˜ indicator.
  • fyewt_indicator_single_quote_end โ€” the โ€˜ indicator.
  • fyewt_indicator_double_quote_start โ€” the โ€œ indicator.
  • fyewt_indicator_double_quote_end โ€” the โ€œ indicator.
  • fyewt_indicator_ambersand โ€” the & indicator. (yes, "ambersand", that's how it's spelled here, love that for us ๐Ÿ’€)
  • fyewt_indicator_star โ€” the * indicator.
  • fyewt_indicator_chomp โ€” the chomp indicator (- or +).
  • fyewt_indicator_explicit_indent โ€” the explicit indent indicator (0-9).

Description

it tells you the kind of emitted output, which means you can colorize the output, or do some other content related filtering. so cute, so useful, no cap ๐ŸŽ€


๐Ÿฆ‹ enum fy_emitter_cfg_flags

enum fy_emitter_cfg_flags โ€” the emitter configuration flags, aka the big pile of switches that decides how your YAML comes out the other side.

Definition

enum fy_emitter_cfg_flags {
    FYECF_SORT_KEYS,
    FYECF_OUTPUT_COMMENTS,
    FYECF_STRIP_LABELS,
    FYECF_STRIP_TAGS,
    FYECF_STRIP_DOC,
    FYECF_NO_ENDING_NEWLINE,
    FYECF_STRIP_EMPTY_KV,
    FYECF_EXTENDED_CFG,
    FYECF_INDENT_DEFAULT,
    FYECF_INDENT_1,
    FYECF_INDENT_2,
    FYECF_INDENT_3,
    FYECF_INDENT_4,
    FYECF_INDENT_5,
    FYECF_INDENT_6,
    FYECF_INDENT_7,
    FYECF_INDENT_8,
    FYECF_INDENT_9,
    FYECF_WIDTH_DEFAULT,
    FYECF_WIDTH_80,
    FYECF_WIDTH_132,
    FYECF_WIDTH_INF,
    FYECF_MODE_ORIGINAL,
    FYECF_MODE_BLOCK,
    FYECF_MODE_FLOW,
    FYECF_MODE_FLOW_ONELINE,
    FYECF_MODE_JSON,
    FYECF_MODE_JSON_TP,
    FYECF_MODE_JSON_ONELINE,
    FYECF_MODE_DEJSON,
    FYECF_MODE_PRETTY,
    FYECF_MODE_MANUAL,
    FYECF_MODE_FLOW_COMPACT,
    FYECF_MODE_JSON_COMPACT,
    FYECF_DOC_START_MARK_AUTO,
    FYECF_DOC_START_MARK_OFF,
    FYECF_DOC_START_MARK_ON,
    FYECF_DOC_END_MARK_AUTO,
    FYECF_DOC_END_MARK_OFF,
    FYECF_DOC_END_MARK_ON,
    FYECF_VERSION_DIR_AUTO,
    FYECF_VERSION_DIR_OFF,
    FYECF_VERSION_DIR_ON,
    FYECF_TAG_DIR_AUTO,
    FYECF_TAG_DIR_OFF,
    FYECF_TAG_DIR_ON,
    FYECF_DEFAULT
};

โœจ Constants

  • FYECF_SORT_KEYS โ€” sort keys when emitting.
  • FYECF_OUTPUT_COMMENTS โ€” output comments (experimental, bestie, so don't come for me if it's quirky ๐Ÿ‘€).
  • FYECF_STRIP_LABELS โ€” strip labels when emitting.
  • FYECF_STRIP_TAGS โ€” strip tags when emitting.
  • FYECF_STRIP_DOC โ€” strip document tags and markers when emitting.
  • FYECF_NO_ENDING_NEWLINE โ€” don't output the ending new line (super handy for single line mode).
  • FYECF_STRIP_EMPTY_KV โ€” remove all keys with empty values from the output. heads up: not available in streaming mode ๐Ÿซถ
  • FYECF_EXTENDED_CFG โ€” extend the configuration; this config structure gets embedded in a fy_emitter_xcfg.
  • FYECF_INDENT_DEFAULT โ€” default emit output indent.
  • FYECF_INDENT_1 โ€” output indent is 1.
  • FYECF_INDENT_2 โ€” output indent is 2.
  • FYECF_INDENT_3 โ€” output indent is 3.
  • FYECF_INDENT_4 โ€” output indent is 4.
  • FYECF_INDENT_5 โ€” output indent is 5.
  • FYECF_INDENT_6 โ€” output indent is 6.
  • FYECF_INDENT_7 โ€” output indent is 7.
  • FYECF_INDENT_8 โ€” output indent is 8.
  • FYECF_INDENT_9 โ€” output indent is 9.
  • FYECF_WIDTH_DEFAULT โ€” default emit output width.
  • FYECF_WIDTH_80 โ€” output width is 80.
  • FYECF_WIDTH_132 โ€” output width is 132.
  • FYECF_WIDTH_INF โ€” output width is infinite (no wrapping, live ur truth ๐ŸŒˆ).
  • FYECF_MODE_ORIGINAL โ€” emit using the same flow mode as the original.
  • FYECF_MODE_BLOCK โ€” emit using only the block mode.
  • FYECF_MODE_FLOW โ€” emit using only the flow mode.
  • FYECF_MODE_FLOW_ONELINE โ€” emit using only the flow mode, all in one line.
  • FYECF_MODE_JSON โ€” emit using JSON mode (non type preserving).
  • FYECF_MODE_JSON_TP โ€” emit using JSON mode (type preserving).
  • FYECF_MODE_JSON_ONELINE โ€” emit using JSON mode (non type preserving, one line).
  • FYECF_MODE_DEJSON โ€” emit YAML trying to pretify JSON.
  • FYECF_MODE_PRETTY โ€” emit YAML that tries to look good ๐Ÿ’….
  • FYECF_MODE_MANUAL โ€” emit YAML respecting all manual style hints (reformats if needed).
  • FYECF_MODE_FLOW_COMPACT โ€” emit using only the flow mode, in as much as possible compact form.
  • FYECF_MODE_JSON_COMPACT โ€” emit using JSON compact form.
  • FYECF_DOC_START_MARK_AUTO โ€” automatically generate document start markers if required.
  • FYECF_DOC_START_MARK_OFF โ€” do not generate document start markers.
  • FYECF_DOC_START_MARK_ON โ€” always generate document start markers.
  • FYECF_DOC_END_MARK_AUTO โ€” automatically generate document end markers if required.
  • FYECF_DOC_END_MARK_OFF โ€” do not generate document end markers.
  • FYECF_DOC_END_MARK_ON โ€” always generate document end markers.
  • FYECF_VERSION_DIR_AUTO โ€” automatically generate version directive.
  • FYECF_VERSION_DIR_OFF โ€” never generate version directive.
  • FYECF_VERSION_DIR_ON โ€” always generate version directive.
  • FYECF_TAG_DIR_AUTO โ€” automatically generate tag directives.
  • FYECF_TAG_DIR_OFF โ€” never generate tag directives.
  • FYECF_TAG_DIR_ON โ€” always generate tag directives.
  • FYECF_DEFAULT โ€” the default emitter configuration โญ.

Description

these flags control the operation of the emitter. that's the whole vibe, they're the knobs, you turn them, things change ๐ŸŽ›๏ธ


๐Ÿซถ struct fy_emitter_cfg

struct fy_emitter_cfg โ€” emitter configuration structure.

Definition

struct fy_emitter_cfg {
    enum fy_emitter_cfg_flags flags;
    int (*output)(struct fy_emitter *emit, enum fy_emitter_write_type type, const char *str, int len, void *userdata);
    void *userdata;
    struct fy_diag *diag;
}

Members

  • flags โ€” configuration flags.
  • output โ€” pointer to the method that will perform output.
  • userdata โ€” opaque user data pointer.
  • diag โ€” diagnostic interface.

Description

this is the argument to the fy_emitter_create() method, which is literally the way to convert a runtime document structure back to YAML. icon behavior only ๐Ÿ‘‘โœจ


๐ŸŒธ enum fy_emitter_xcfg_flags

enum fy_emitter_xcfg_flags โ€” emitter extended configuration flags. yes there's a whole extra layer, she's extra like that ๐Ÿ’…

Definition

enum fy_emitter_xcfg_flags {
    FYEXCF_COLOR_AUTO,
    FYEXCF_COLOR_NONE,
    FYEXCF_COLOR_FORCE,
    FYEXCF_OUTPUT_STDOUT,
    FYEXCF_OUTPUT_STDERR,
    FYEXCF_OUTPUT_FILE,
    FYEXCF_OUTPUT_FD,
    FYEXCF_NULL_OUTPUT,
    FYEXCF_OUTPUT_FILENAME,
    FYEXCF_VISIBLE_WS,
    FYEXCF_EXTENDED_INDICATORS,
    FYEXCF_INDENTED_SEQ_IN_MAP,
    FYEXCF_PRESERVE_FLOW_LAYOUT
};

๐ŸŽ€ Constants

  • FYEXCF_COLOR_AUTO โ€” automatically colorize if on a terminal.
  • FYEXCF_COLOR_NONE โ€” do not colorize output.
  • FYEXCF_COLOR_FORCE โ€” force color generation (yes even when you're piping it, she said what she said ๐Ÿ”ฅ).
  • FYEXCF_OUTPUT_STDOUT โ€” output to stdout (this is the default).
  • FYEXCF_OUTPUT_STDERR โ€” output to stderr, instead of stdout.
  • FYEXCF_OUTPUT_FILE โ€” output to the fp FILE pointer.
  • FYEXCF_OUTPUT_FD โ€” output to the fd file descriptor.
  • FYEXCF_NULL_OUTPUT โ€” no output.
  • FYEXCF_OUTPUT_FILENAME โ€” output to the given filename.
  • FYEXCF_VISIBLE_WS โ€” make white space visible ๐Ÿ‘€ (yes, the invisible becomes visible, spooky season)
  • FYEXCF_EXTENDED_INDICATORS โ€” extends the indicators that get generated ๐Ÿ’ซ
  • FYEXCF_INDENTED_SEQ_IN_MAP โ€” indents block sequences that are mapping values (yes bestie, the pretty version) ๐ŸŽ€
  • FYEXCF_PRESERVE_FLOW_LAYOUT โ€” preserves oneline flow collections when you're in streaming mode ๐ŸŒŠ

Description

These flags are literally the remote control for how the emitter behaves. If no extended configuration mode is enabled, all the flags are assumed 0. No mode, no flags, no drama. ๐Ÿ’…


struct fy_emitter_xcfg

struct fy_emitter_xcfg โ€” the emitter's extended configuration structure. It's giving "main character struct" energy fr fr ๐Ÿ‘‘

Definition

struct fy_emitter_xcfg {
    struct fy_emitter_cfg cfg;
    enum fy_emitter_xcfg_flags xflags;
    const char *colors[FYEWT_COUNT];
    union {
        FILE *output_fp;
        int output_fd;
        const char *output_filename;
    } ;
}

Members

  • cfg โ€” the standard emitter configuration, the og setup ๐Ÿซถ
  • xflags โ€” the extra configuration flags, aka the spicy add-ons ๐ŸŒถ๏ธ
  • colors โ€” ANSI color overrides for the default output method ๐ŸŒˆ
  • {unnamed_union} โ€” anonymous (she has no name, mysterious icon behavior ๐Ÿ™ˆ)
  • output_fp โ€” the output FILE *; FYEXCF_FILE_OUTPUT must be set or it's not happening
  • output_fd โ€” the output file descriptor; FYEXCF_FD_OUTPUT must be set
  • output_filename โ€” the output filename; FYEXCF_FILENAME_OUTPUT must be set

Description

This is what you pass as the argument to the emitter create when the FYECF_EXTENDED_CFG bit is set. That's the whole vibe. โœจ


fy_emitter_create

struct fy_emitter *fy_emitter_create(const struct fy_emitter_cfg *cfg)

Create an emitter ๐Ÿ’–

Parameters

  • cfg (*const struct fy_emitter_cfg**) โ€” the emitter configuration

Description

Creates an emitter using the config you handed it. Like, it makes the emitter. That's the tweet. ๐Ÿฆ

Return

The newly created emitter, or NULL on error. If you get NULL, something went wrong, no cap ๐Ÿ˜ญ


fy_emitter_destroy

void fy_emitter_destroy(struct fy_emitter *emit)

Destroy an emitter ๐Ÿ’€

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter to destroy

Description

Destroys an emitter that was previously created by fy_emitter_create(). Cleanup era, we love to see it ๐Ÿงน


fy_emitter_get_cfg

const struct fy_emitter_cfg *fy_emitter_get_cfg(struct fy_emitter *emit)

Get the configuration of an emitter ๐ŸŽ€

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter

Return

The configuration of the emitter. That's it, that's the whole function ๐Ÿซถ


fy_emitter_get_diag

struct fy_diag *fy_emitter_get_diag(struct fy_emitter *emit)

Get the diagnostic object of an emitter ๐Ÿฉบ

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter to get the diagnostic object from

Description

Returns a pointer to the diagnostic object of an emitter object. Note that the returned diag object has a reference taken, so you should fy_diag_unref() it when you're done with it. Like please don't just ghost it, that's a leak bestie ๐Ÿ˜ญ

Return

A pointer to a ref'ed diagnostic object, or NULL in case of an error.


fy_emitter_set_diag

int fy_emitter_set_diag(struct fy_emitter *emit, struct fy_diag *diag)

Set the diagnostic object of an emitter ๐Ÿฉบโœจ

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter to replace the diagnostic object on
  • diag (*struct fy_diag**) โ€” the emitter's new diagnostic object; NULL for default

Description

Swaps out the emitter's current diagnostic object for the one you pass in. The previous diagnostic object will be unref'ed (and freed if its reference gets to 0). Also note that the diag argument shall take a reference too โ€” everybody's holding refs, it's a whole group chat ๐Ÿ’…

Return

0 if everything's OK, -1 otherwise.


fy_emitter_set_finalizer

void fy_emitter_set_finalizer(struct fy_emitter *emit, void (*finalizer)(struct fy_emitter *emit))

Set emitter finalizer ๐ŸŽฌ

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter to replace the diagnostic object on
  • finalizer (void (*)(struct fy_emitter *emit)) โ€” the finalizer callback

Description

Sets a method callback that gets called when the emitter is disposed of. If finalizer is NULL, then the method is removed. Ghosted, gone, no more callback ๐Ÿซฅ


struct fy_emitter_default_output_data

struct fy_emitter_default_output_data โ€” the emitter's default output configuration, the starter pack of output settings ๐Ÿ“

Definition

struct fy_emitter_default_output_data {
    FILE *fp;
    bool colorize;
    bool visible;
}

Members

  • fp โ€” the file where the output is directed to ๐Ÿ“
  • colorize โ€” use ANSI color sequences to colorize the output ๐ŸŒˆ
  • visible โ€” make whitespace visible (requires a UTF8 capable terminal, so check before you commit bestie) ๐Ÿ‘€

Description

This is the argument to the default output method of the emitter. That's its whole job ๐Ÿซก


fy_emitter_default_output

int fy_emitter_default_output(struct fy_emitter *fye, enum fy_emitter_write_type type, const char *str, int len, void *userdata)

The default colorizing output method ๐ŸŒˆ๐Ÿ’–

Parameters

  • fye (*struct fy_emitter**) โ€” the emitter
  • type (enum fy_emitter_write_type) โ€” the type of the emitted output
  • str (*const char**) โ€” pointer to the string to output
  • len (int) โ€” length of the string
  • userdata (*void**) โ€” must point to a fy_emitter_default_output_data structure

Description

This is the default colorizing output method. It will be used when the output field of the emitter configuration is NULL. Default behavior, but make it fashion โœจ

Return

0 on success, -1 on error.


fy_document_default_emit_to_fp

int fy_document_default_emit_to_fp(struct fy_document *fyd, FILE *fp)

Emit a document to a file, using defaults ๐Ÿ“„โžก๏ธ๐Ÿ“

Parameters

  • fyd (*struct fy_document**) โ€” the document to emit
  • fp (*FILE**) โ€” the file where the output is sent

Description

Simple one-shot emitter to a file, using the default emitter output. The output will be colorized if the file points to a tty. Cute AND functional ๐ŸŽ€

Return

0 on success, -1 on error.


fy_emit_event

int fy_emit_event(struct fy_emitter *emit, struct fy_event *fye)

Queue (and possibly emit) an event ๐Ÿ“จ

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter to use
  • fye (*struct fy_event**) โ€” the event to queue for emission

Description

Queues and outputs using the emitter. This is the streaming output method, which does not require creating a document. No document, no problem ๐Ÿ’…

Return

0 on success, -1 on error.


fy_emit_vevent

int fy_emit_vevent(struct fy_emitter *emit, enum fy_event_type type, va_list ap)

Queue (and possibly emit) an event using varargs ๐ŸŽ

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter to use
  • type (enum fy_event_type) โ€” the event type to create
  • ap (va_list) โ€” the variable argument list pointer

Description

Queues and outputs using the emitter. The format is identical to the one used in fy_emit_event_vcreate(). Same format, different entry point, iykyk ๐Ÿซถ

Return

0 on success, -1 on error.


fy_emit_eventf

int fy_emit_eventf(struct fy_emitter *emit, enum fy_event_type type, ...)

Queue (and possibly emit) an event using variable args โœจ

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter to use
  • type (enum fy_event_type) โ€” the event type to create
  • ellipsis (ellipsis) โ€” the optional extra arguments

Description

Queues and outputs using the emitter. The format is identical to the one used in fy_emit_event_create(). Yes it's basically the same description, they're siblings, let them live ๐Ÿ˜Œ

Return

0 on success, -1 on error.


fy_emit_scalar_write

int fy_emit_scalar_write(struct fy_emitter *fye, enum fy_scalar_style style, const char *anchor, const char *tag, const char *buf, size_t count)

Emit a scalar with write semantics โœ๏ธ

Parameters

  • fye (*struct fy_emitter**) โ€” the emitter to use
  • style (enum fy_scalar_style) โ€” the scalar style to use
  • anchor (*const char**) โ€” the anchor, or NULL
  • tag (*const char**) โ€” the tag, or NULL
  • buf (*const char**) โ€” pointer to the buffer
  • count (size_t) โ€” the number of bytes to write

Description

Queues and outputs a scalar using the emitter, via a standard write interface. Bytes go in, YAML comes out ๐ŸŒธ

Return

0 on success, -1 on error.


fy_emit_scalar_vprintf

int fy_emit_scalar_vprintf(struct fy_emitter *fye, enum fy_scalar_style style, const char *anchor, const char *tag, const char *fmt, va_list ap)

Emit a scalar with vprintf semantics ๐Ÿ–จ๏ธ

Parameters

  • fye (*struct fy_emitter**) โ€” the emitter to use
  • style (enum fy_scalar_style) โ€” the scalar style to use
  • anchor (*const char**) โ€” the anchor, or NULL
  • tag (*const char**) โ€” the tag, or NULL
  • fmt (*const char**) โ€” the printf-like format string
  • ap (va_list) โ€” the argument list

Description

Queues and outputs a scalar using the emitter, via a standard vprintf interface. Format strings but make it YAML ๐Ÿ’…

Return

0 on success, -1 on error.


fy_emit_scalar_printf

int fy_emit_scalar_printf(struct fy_emitter *fye, enum fy_scalar_style style, const char *anchor, const char *tag, const char *fmt, ...)

Emit a scalar with printf semantics ๐Ÿ”ฅ

Parameters

  • fye (*struct fy_emitter**) โ€” the emitter to use
  • style (enum fy_scalar_style) โ€” the scalar style to use
  • anchor (*const char**) โ€” the anchor, or NULL
  • tag (*const char**) โ€” the tag, or NULL
  • fmt (*const char**) โ€” the printf-like format string
  • ellipsis (ellipsis) โ€” the extra arguments

Description

Queues and outputs a scalar using the emitter, via a standard printf interface. The people's champion of scalar emission ๐Ÿ‘‘

Return

0 on success, -1 on error.


fy_emit_event_from_parser

int fy_emit_event_from_parser(struct fy_emitter *emit, struct fy_parser *fyp, struct fy_event *fye)

Queue (and possibly emit) an event generated by the parser ๐Ÿ”„

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter to use
  • fyp (*struct fy_parser**) โ€” the parser that generated the event
  • fye (*struct fy_event**) โ€” the event to queue for emission

Description

Queues and outputs using the emitter. This is the streaming output method, which does not require creating a document. Similar to fy_emit_event() but it is more efficient. Same energy, better performance, we stan ๐Ÿ’œ

Return

0 on success, -1 on error.


fy_emit_document

int fy_emit_document(struct fy_emitter *emit, struct fy_document *fyd)

Emit the document using the emitter ๐Ÿ“œโœจ

Parameters

  • emit (*struct fy_emitter**) โ€” the emitter
  • fyd (*struct fy_document**) โ€” the document to emit

Description

Emits a document in YAML format using the emitter. Whole document, one call, slay ๐Ÿ’…

Return

0 on success, -1 on error ๐Ÿ’–


fy_emit_document_start

int fy_emit_document_start(struct fy_emitter *emit, struct fy_document *fyd, struct fy_node *fyn)

Emit a document start using the emitter โœจ

Parameters

  • emit (struct fy_emitter*) โ€” the emitter
  • fyd (struct fy_document*) โ€” the document to pull its start from for emitting
  • fyn (struct fy_node*) โ€” the root, or NULL if you want to just use the document's root

Description

Drops a document start through the emitter. Bestie, this is the one you reach for when you need finer control over the emitting output โ€” like, when you're hand-driving the whole thing instead of letting the library do it. ๐ŸŽ€

Return

0 on success, -1 on error


fy_emit_document_end

int fy_emit_document_end(struct fy_emitter *emit)

Emit document end using the emitter ๐ŸŒธ

Parameters

  • emit (struct fy_emitter*) โ€” the emitter

Description

Drops a document end through the emitter. Same deal as above: this exists so you get finer control over the emitting output. ๐Ÿ’…

Return

0 on success, -1 on error


fy_emit_node

int fy_emit_node(struct fy_emitter *emit, struct fy_node *fyn)

Emit a single node using the emitter ๐Ÿฆ‹

Parameters

  • emit (struct fy_emitter*) โ€” the emitter
  • fyn (struct fy_node*) โ€” the node to emit

Description

Emits one single node through the emitter. Again โ€” finer control over the emitting output is the entire point, iykyk. โœจ

Return

0 on success, -1 on error


fy_emit_root_node

int fy_emit_root_node(struct fy_emitter *emit, struct fy_node *fyn)

Emit a single root node using the emitter ๐Ÿ‘‘

Parameters

  • emit (struct fy_emitter*) โ€” the emitter
  • fyn (struct fy_node*) โ€” the root node to emit

Description

Emits a single root node through the emitter. Main character energy only โ€” and yes, it's for when you need finer control over the emitting output. ๐Ÿ’œ

Return

0 on success, -1 on error


fy_emit_body_node

int fy_emit_body_node(struct fy_emitter *emit, struct fy_node *fyn)

Emit a single body node using the emitter ๐Ÿซถ

Parameters

  • emit (struct fy_emitter*) โ€” the emitter
  • fyn (struct fy_node*) โ€” the body node to emit

Description

Emits a single body node through the emitter, for finer control over the emitting output. Important vibe check though: no stream and document events will be generated at all. Like, none. Zero. Not a single one. ๐Ÿ˜ญ

Return

0 on success, -1 on error


fy_emit_explicit_document_end

int fy_emit_explicit_document_end(struct fy_emitter *emit)

Emit an explicit document end โญ

Parameters

  • emit (struct fy_emitter*) โ€” the emitter

Description

Emits an explicit document end, i.e. ... โ€” yes, literally the three dots, that's the whole flex. Use this if you need finer control over the emitting output. (Also, tiny thing, the original docs say "if you you need" and I'm choosing to believe that was a stylistic choice. Anyway. ๐Ÿ’…)

Return

0 on success, -1 on error


fy_emit_document_to_fp

int fy_emit_document_to_fp(struct fy_document *fyd, enum fy_emitter_cfg_flags flags, FILE *fp)

Emit a document to a file pointer ๐Ÿ“

Parameters

  • fyd (struct fy_document*) โ€” the document to emit
  • flags (enum fy_emitter_cfg_flags) โ€” the emitter flags to use
  • fp (FILE*) โ€” the file pointer to output to

Description

Emits a document, starting from the root, straight out to the file pointer you handed it. ๐Ÿ“ค

Return

0 on success, -1 on error


fy_emit_document_to_file

int fy_emit_document_to_file(struct fy_document *fyd, enum fy_emitter_cfg_flags flags, const char *filename)

Emit a document to a file ๐ŸŽ€

Parameters

  • fyd (struct fy_document*) โ€” the document to emit
  • flags (enum fy_emitter_cfg_flags) โ€” the emitter flags to use
  • filename (const char*) โ€” the filename to output to, or NULL for stdout

Description

Emits a document, from the root, to the file you named. Heads up: the file gets fopen'ed using a "wa" mode. ๐Ÿ—‚๏ธ

Return

0 on success, -1 on error


fy_emit_document_to_fd

int fy_emit_document_to_fd(struct fy_document *fyd, enum fy_emitter_cfg_flags flags, int fd)

Emit a document to a file descriptor ๐ŸŒˆ

Parameters

  • fyd (struct fy_document*) โ€” the document to emit
  • flags (enum fy_emitter_cfg_flags) โ€” the emitter flags to use
  • fd (int) โ€” the file descriptor to output to

Description

Emits a document, from the root, to the file descriptor you gave it. ๐Ÿงš

Return

0 on success, -1 on error


fy_emit_document_to_buffer

int fy_emit_document_to_buffer(struct fy_document *fyd, enum fy_emitter_cfg_flags flags, char *buf, size_t size)

Emit a document to a buffer ๐Ÿ’–

Parameters

  • fyd (struct fy_document*) โ€” the document to emit
  • flags (enum fy_emitter_cfg_flags) โ€” the emitter flags to use
  • buf (char*) โ€” pointer to the buffer area to fill
  • size (size_t) โ€” size of the buffer

Description

Emits a document, from the root, into the buffer you provided. And ngl, if the document doesn't fit? an error will be returned. So size it right, bestie. ๐Ÿ˜ญ

Return

A positive number โ€” the size of the emitted document sitting in the buffer โ€” on success, -1 on error


fy_emit_document_to_string

char *fy_emit_document_to_string(struct fy_document *fyd, enum fy_emitter_cfg_flags flags)

Emit a document to an allocated string โœจ

Parameters

  • fyd (struct fy_document*) โ€” the document to emit
  • flags (enum fy_emitter_cfg_flags) โ€” the emitter flags to use

Description

Emits a document, from the root, into a string which gets dynamically allocated for you. ๐Ÿฆ‹

Return

A pointer to the allocated string, or NULL in case of an error


fy_emit_node_to_buffer

int fy_emit_node_to_buffer(struct fy_node *fyn, enum fy_emitter_cfg_flags flags, char *buf, size_t size)

Emit a node (recursively) to a buffer ๐ŸŽ€

Parameters

  • fyn (struct fy_node*) โ€” the node to emit
  • flags (enum fy_emitter_cfg_flags) โ€” the emitter flags to use
  • buf (char*) โ€” pointer to the buffer area to fill
  • size (size_t) โ€” size of the buffer

Description

Emits a node recursively into the buffer you gave it. And again, if it doesn't fit, an error will be returned โ€” no silent truncation, no drama, just an error. ๐Ÿ™ˆ

Return

A positive number โ€” the size of the emitted node in the buffer โ€” on success, -1 on error


fy_emit_node_to_string

char *fy_emit_node_to_string(struct fy_node *fyn, enum fy_emitter_cfg_flags flags)

Emit a node to an allocated string ๐ŸŒธ

Parameters

  • fyn (struct fy_node*) โ€” the node to emit
  • flags (enum fy_emitter_cfg_flags) โ€” the emitter flags to use

Description

Emits a node recursively into a string which will be dynamically allocated. Obsessed, honestly. ๐Ÿ’œ

Return

A pointer to the allocated string, or NULL in case of an error


fy_emit_to_buffer

struct fy_emitter *fy_emit_to_buffer(enum fy_emitter_cfg_flags flags, char *buf, size_t size)

Create an emitter for buffer output ๐Ÿ”ฅ

Parameters

  • flags (enum fy_emitter_cfg_flags) โ€” the emitter flags to use
  • buf (char*) โ€” pointer to the buffer area to fill
  • size (size_t) โ€” size of the buffer

Description

Creates a special purpose emitter that outputs into a buffer. Your fy_emit_event() calls populate that buffer, and then you go grab the contents with a call to fy_emit_to_buffer_collect(). ๐Ÿซถ

Return

The newly created emitter, or NULL on error


fy_emit_to_buffer_collect

char *fy_emit_to_buffer_collect(struct fy_emitter *emit, size_t *sizep)

Collect the buffer emitter output ๐Ÿงบ

Parameters

  • emit (struct fy_emitter*) โ€” the emitter
  • sizep (size_t*) โ€” pointer to the size to be filled

Description

Collects the output of an emitter that was created by fy_emit_to_buffer() and then populated via fy_emit_event() calls. The returned buffer is NULL terminated, and it's the same one you passed into fy_emit_to_buffer() โ€” no surprise copy, no plot twist. The sizep argument gets filled with the size of the buffer. โœจ

Return

The buffer, or NULL in case of an error


fy_emit_to_string

struct fy_emitter *fy_emit_to_string(enum fy_emitter_cfg_flags flags)

Create an emitter to create a dynamically allocated string ๐Ÿ’ซ

Parameters

  • flags (enum fy_emitter_cfg_flags) โ€” the emitter flags to use

Description

Creates a special purpose emitter that outputs into a dynamically allocated string. Your fy_emit_event() calls populate the buffer, and you retrieve the contents with a call to fy_emit_to_string_collect(). ๐ŸŒŸ

Return

The newly created emitter, or NULL on error


fy_emit_to_string_collect

char *fy_emit_to_string_collect(struct fy_emitter *emit, size_t *sizep)

Collect the string emitter output ๐ŸŽ€

Parameters

  • emit (struct fy_emitter*) โ€” the emitter
  • sizep (size_t*) โ€” pointer to the size to be filled

Description

Collects the output of an emitter created by fy_emit_to_string() and populated using fy_emit_event() calls. The NULL terminated returned buffer is dynamically allocated and must be freed via a call to free(). Ma'am, free your memory. The sizep argument gets filled with the size of the buffer. ๐Ÿ’…

Return

The dynamically allocated string, or NULL in case of an error


fy_node_copy

struct fy_node *fy_node_copy(struct fy_document *fyd, struct fy_node *fyn_from)

Copy a node, associating the new node with the given document ๐Ÿฆ‹

Parameters

  • fyd (struct fy_document*) โ€” the document which the resulting node will be associated with
  • fyn_from (struct fy_node*) โ€” the source node to recursively copy

Description

Makes a deep copy of a node and associates that copy with the document you passed in. And here's the slay part: no content copying takes place because the contents of the nodes are reference counted โ€” so this operation is relatively inexpensive. Literally so cheap. ๐Ÿ’ธ

Also worth flagging: the copy includes all anchors contained in the subtree of the source, so this call will register them with the document. Don't say I didn't warn you. ๐ŸŒธ

Return

The copied node on success, NULL on error


fy_document_clone

struct fy_document *fy_document_clone(struct fy_document *fydsrc)

Clones a document ๐Ÿ‘‘

Parameters

  • fydsrc (struct fy_document*) โ€” the source document to clone

Description

okay so cloning a document is giving deep copy of the source, bestie. ๐Ÿซถ And the cute part? No content copying takes place, because the contents of the nodes are reference counted. That means the operation is relatively inexpensive. Slay. ๐Ÿ’…

Return

The newly created clone document, or NULL in case of an error.

๐Ÿงฉ fy_node_insert

int fy_node_insert(struct fy_node *fyn_to, struct fy_node *fyn_from)

Insert a node to the given node.

Parameters

  • fyn_to (struct fy_node*) โ€” the target node.
  • fyn_from (struct fy_node*) โ€” the source node.

Description

Insert a node to another node. If fyn_from is NULL, then this operation will delete the fyn_to node. ๐Ÿ’€

๐ŸŒธ The operation varies according to the types of the arguments

from: scalar

to: another-scalar -> scalar to: { key: value } -> scalar to: [ seq0,
seq1 ] -> scalar

from: [ seq2 ] to: scalar -> [ seq2 ] to: { key: value } -> [ seq2 ] to:
[ seq0, seq1 ] -> [ seq0, seq1, sec2 ]

from: { another-key: another-value } to: scalar -> { another-key:
another-value } to: { key: value } -> { key: value, another-key:
another-value } to: [ seq0, seq1 ] -> { another-key: another-value }

from: { key: another-value } to: scalar -> { key: another-value } to: {
key: value } -> { key: another-value } to: [ seq0, seq1 ] -> { key:
another-value }

๐Ÿ’… The rules are

  • If target node changes type, source ovewrites target.
  • If source or target node are scalars, source it overwrites target.
  • If target and source are sequences, the items of the source sequence are appended to the target sequence.
  • If target and source are maps, the key, value pairs of the source are appended to the target map. If the target map contains a key-value pair that is present in the source map, it is overwriten by it.

Return

0 on success, -1 on error.

๐Ÿ—‘๏ธ fy_node_delete

int fy_node_delete(struct fy_node *fyn)

Delete a node from a document.

Parameters

  • fyn (struct fy_node*) โ€” the node to delete.

Description

Delete the given node. If itโ€™s part of a sequence, it will be removed from it. If itโ€™s the value of a node key value pair, it will be removed from the mapping.

This is literally an alias for fy_document_insert_at(fyn, NULL). ๐Ÿ‘€

Note that it is expected this node is attached to a document. Do not call this to free a node, because if itโ€™s part of a collection it will not be properly removed. Thatโ€™s a no-no, bestie. ๐Ÿšซ

Return

0 on success, -1 on error.

๐Ÿ“Œ fy_document_insert_at

int fy_document_insert_at(struct fy_document *fyd, const char *path,
    size_t pathlen, struct fy_node *fyn)

Insert a node to the given path in the document.

Parameters

  • fyd (struct fy_document*) โ€” the document.
  • path (const char*) โ€” the path where the insert operation will target.
  • pathlen (size_t) โ€” the length of the path (or -1 if โ€˜0โ€™ terminated).
  • fyn (struct fy_node*) โ€” the source node.

Description

Insert a node to a given point in the document. If fyn is NULL, then this operation will delete the target node.

Please see fy_node_insert for details of operation. ๐Ÿซถ

Note that in any case the fyn node will be unrefโ€™ed. So if the operation fails, and the reference is 0, the node will be freed. If you want it to stick around, take a reference before. fr fr.

Return

0 on success, -1 on error.

๐Ÿ”ข enum fy_node_type

Node type.

Definition

enum fy_node_type {
    FYNT_SCALAR,
    FYNT_SEQUENCE,
    FYNT_MAPPING
};

Constants

  • FYNT_SCALAR โ€” node is a scalar.
  • FYNT_SEQUENCE โ€” node is a sequence.
  • FYNT_MAPPING โ€” node is a mapping.

Description

Each node may be one of the following types. No cap. โœจ

๐ŸŽจ enum fy_node_style

Node style.

Definition

enum fy_node_style {
    FYNS_ANY,
    FYNS_FLOW,
    FYNS_BLOCK,
    FYNS_PLAIN,
    FYNS_SINGLE_QUOTED,
    FYNS_DOUBLE_QUOTED,
    FYNS_LITERAL,
    FYNS_FOLDED,
    FYNS_ALIAS
};

Constants

  • FYNS_ANY โ€” no hint, let the emitter decide.
  • FYNS_FLOW โ€” prefer flow style (for sequence/mappings).
  • FYNS_BLOCK โ€” prefer block style (for sequence/mappings).
  • FYNS_PLAIN โ€” plain style preferred.
  • FYNS_SINGLE_QUOTED โ€” single quoted style preferred.
  • FYNS_DOUBLE_QUOTED โ€” double quoted style preferred.
  • FYNS_LITERAL โ€” literal style preferred (valid in block context).
  • FYNS_FOLDED โ€” folded style preferred (valid in block context).
  • FYNS_ALIAS โ€” itโ€™s an alias.

Description

A node may contain a hint of how it should be rendered, encoded as a style. Obsessed with the aesthetic control here. ๐Ÿ’…

๐Ÿšถ enum fy_node_walk_flags

Node walk flags.

Definition

enum fy_node_walk_flags {
    FYNWF_DONT_FOLLOW,
    FYNWF_FOLLOW,
    FYNWF_PTR_YAML,
    FYNWF_PTR_JSON,
    FYNWF_PTR_RELJSON,
    FYNWF_PTR_YPATH,
    FYNWF_URI_ENCODED,
    FYNWF_MAXDEPTH_DEFAULT,
    FYNWF_MARKER_DEFAULT,
    FYNWF_PTR_DEFAULT
};

Constants

  • FYNWF_DONT_FOLLOW โ€” donโ€™t follow aliases during pathwalk.
  • FYNWF_FOLLOW โ€” follow aliases during pathwalk.
  • FYNWF_PTR_YAML โ€” YAML pointer path walks.
  • FYNWF_PTR_JSON โ€” JSON pointer path walks.
  • FYNWF_PTR_RELJSON โ€” relative JSON pointer path walks.
  • FYNWF_PTR_YPATH โ€” YPATH pointer path walks.
  • FYNWF_URI_ENCODED โ€” the path is URI encoded.
  • FYNWF_MAXDEPTH_DEFAULT โ€” max follow depth is automatically determined.
  • FYNWF_MARKER_DEFAULT โ€” default marker to use when scanning.
  • FYNWF_PTR_DEFAULT โ€” default path type.

๐ŸŽจ fy_node_style_from_scalar_style

enum fy_node_style fy_node_style_from_scalar_style(enum fy_scalar_style
    sstyle)

Convert from scalar to node style.

Parameters

  • sstyle (enum fy_scalar_style) โ€” the input scalar style.

Description

Convert a scalar style to a node style.

Return

The matching node style.

๐Ÿงฎ typedef fy_node_mapping_sort_fn

int fy_node_mapping_sort_fn(const struct fy_node_pair *fynp_a, const
    struct fy_node_pair *fynp_b, void *arg)

Mapping sorting method function.

Parameters

  • fynp_a (const struct fy_node_pair*) โ€” the first node_pair used in the comparison.
  • fynp_b (const struct fy_node_pair*) โ€” the second node_pair used in the comparison.
  • arg (void*) โ€” the opaque user provided pointer to the sort operation.

Return

<0 if fynp_a is less than fynp_b; 0 if fynp_a is equal to fynp_b; >0 if fynp_a is greater than fynp_b.

๐Ÿ” typedef fy_node_scalar_compare_fn

int fy_node_scalar_compare_fn(struct fy_node *fyn_a, struct fy_node
    *fyn_b, void *arg)

Node compare method function for scalars.

Parameters

  • fyn_a (struct fy_node*) โ€” the first scalar node used in the comparison.
  • fyn_b (struct fy_node*) โ€” the second scalar node used in the comparison.
  • arg (void*) โ€” the opaque user provided pointer to the compare operation.

Return

<0 if fyn_a is less than fyn_b; 0 if fyn_a is equal to fyn_b; >0 if fyn_a is greater than fyn_b.

โš–๏ธ fy_node_compare

bool fy_node_compare(struct fy_node *fyn1, struct fy_node *fyn2)

Compare two nodes for equality.

Parameters

  • fyn1 (struct fy_node*) โ€” the first node to use in the comparison.
  • fyn2 (struct fy_node*) โ€” the second node to use in the comparison.

Description

Compare two nodes for equality. The comparison is deep, i.e. it recurses in subnodes, and orders the keys of maps using default libc strcmp ordering. For scalar, the comparison is performed after any escaping, so itโ€™s a true content comparison. periodt. ๐Ÿ’–

Return

true if the nodes contain the same content, false otherwise.

๐Ÿช„ fy_node_compare_user

bool fy_node_compare_user(struct fy_node *fyn1, struct fy_node *fyn2,
    fy_node_mapping_sort_fn sort_fn, void *sort_fn_arg,
    fy_node_scalar_compare_fn cmp_fn, void *cmp_fn_arg)

Compare two nodes for equality using user supplied sort and scalar compare methods.

Parameters

  • fyn1 (struct fy_node*) โ€” the first node to use in the comparison.
  • fyn2 (struct fy_node*) โ€” the second node to use in the comparison.
  • sort_fn (fy_node_mapping_sort_fn) โ€” the method to use for sorting maps, or NULL for the default.
  • sort_fn_arg (void*) โ€” the extra user supplied argument to the sort_fn.
  • cmp_fn (fy_node_scalar_compare_fn) โ€” the method to use for comparing scalars, or NULL for the default.
  • cmp_fn_arg (void*) โ€” the extra user supplied argument to the cmp_fn.

Description

Compare two nodes for equality using user supplied sot and scalar compare methods. Yes, thatโ€™s literally sot, bestie โ€” not me, the page said it. ๐Ÿ’€ The comparison is deep, i.e. it recurses in subnodes, and orders the keys of maps using the supplied mapping sort method for ordering. For scalars, the comparison is performed using the supplied scalar node compare methods.

Return

true if the nodes contain the same content, false otherwise.

๐Ÿงต fy_node_compare_string

bool fy_node_compare_string(struct fy_node *fyn, const char *str, size_t
    len)

Compare a node for equality with a YAML string.

Parameters

  • fyn (struct fy_node*) โ€” the node to use in the comparison.
  • str (const char*) โ€” the YAML string to compare against.
  • len (size_t) โ€” the length of the string (or -1 if โ€˜0โ€™ terminated).

Description

Compare a node for equality with a YAML string. The comparison is performed using fy_node_compare() with the first node supplied as an argument and the second being generated by calling fy_document_build_from_string with the YAML string.

Return

true if the node and the string are equal.

๐Ÿ”‘ fy_node_compare_token

bool fy_node_compare_token(struct fy_node *fyn, struct fy_token *fyt)

Compare a node for equality against a token.

Parameters

  • fyn (struct fy_node*) โ€” the node to use in the comparison.
  • fyt (struct fy_token*) โ€” the scalar token.

So basically this one does an equality check between a node and a token โ€” and listen, both of them have to be scalars, no exceptions, no vibes-based exceptions ๐Ÿ’€

Return โ€” true if the node and the token are equal. That's it, that's the whole reward.


fy_node_compare_text

bool fy_node_compare_text(struct fy_node *fyn, const char *text, size_t len)

Compare a node for equality with a raw C text โœจ

Parameters

  • fyn (struct fy_node *) โ€” the node you're putting in the comparison
  • text (const char *) โ€” the raw C text you're comparing against
  • len (size_t) โ€” how long that text is (or -1 if it's 0 terminated)

Description

Compares a node for equality with a raw C string. Soft requirement, hard requirement: the node must be a scalar. That's non-negotiable bestie ๐ŸŽ€

Return

true if the node and the text are equal. Iconic behaviour, no notes.


fy_document_create

struct fy_document *fy_document_create(const struct fy_parse_cfg *cfg)

Create an empty document ๐Ÿซถ a blank canvas, a fresh start, main character energy

Parameters

  • cfg (const struct fy_parse_cfg *) โ€” the parse configuration to use, or NULL for the default

Description

Makes you an empty document using whatever parser configuration you handed over. If it's NULL, it just uses the default parse configuration. Lowkey the easiest call in the whole library.

Return

The freshly created empty document, or NULL on error ๐Ÿ˜ญ


fy_document_destroy

void fy_document_destroy(struct fy_document *fyd)

Destroy a document previously created via fy_document_create() ๐Ÿ’…

Parameters

  • fyd (struct fy_document *) โ€” the document to destroy

Description

Destroys a document โ€” and yes, along with all children documents. It's giving "take the whole friend group with you." Handle with care, bestie.


fy_document_get_cfg

const struct fy_parse_cfg *fy_document_get_cfg(struct fy_document *fyd)

Get the configuration of a document ๐ŸŒธ

Parameters

  • fyd (struct fy_document *) โ€” the document

Return

The configuration of the document. Slay, now you know what rules it's playing by.


fy_document_get_diag

struct fy_diag *fy_document_get_diag(struct fy_document *fyd)

Get the diagnostic object of a document ๐Ÿ”

Parameters

  • fyd (struct fy_document *) โ€” the document to get the diagnostic object from

Description

Returns a pointer to the diagnostic object of a document object. Important, don't skip this: the returned diag object has a reference taken, so you should fy_diag_unref() it when you're done with it. Not me reminding you to clean up โ€” okay yes, it's literally me reminding you ๐Ÿ’€

Return

A pointer to a ref'ed diagnostic object, or NULL in case of an error.


fy_document_set_diag

int fy_document_set_diag(struct fy_document *fyd, struct fy_diag *diag)

Set the diagnostic object of a document ๐ŸŽ€

Parameters

  • fyd (struct fy_document *) โ€” the document whose diagnostic object gets replaced
  • diag (struct fy_diag *) โ€” the document's new diagnostic object, NULL for default

Description

Swaps the document's current diagnostic object out for the one you passed in. The previous diagnostic object gets unref'ed (and freed if its reference count hits 0). Also note that the diag argument shall take a reference too โ€” yes, it's a whole two-way reference situation, keep up ๐Ÿซถ

Return

0 if everything OK, -1 otherwise.


fy_document_set_parent

int fy_document_set_parent(struct fy_document *fyd, struct fy_document *fyd_child)

Make a document a child of another ๐Ÿ‘‘ found family arc

Parameters

  • fyd (struct fy_document *) โ€” the parent document
  • fyd_child (struct fy_document *) โ€” the child document

Description

Sets the parent of the fyd_child document to be fyd. Simple as that.

Return

0 if all OK, -1 on error.


fy_document_build_from_string

struct fy_document *fy_document_build_from_string(const struct fy_parse_cfg *cfg, const char *str, size_t len)

Create a document using the provided YAML source โœจ

Parameters

  • cfg (const struct fy_parse_cfg *) โ€” the parse configuration to use, or NULL for the default
  • str (const char *) โ€” the YAML source to use
  • len (size_t) โ€” the length of the string (or -1 if 0 terminated)

Description

Creates a document by parsing the string you gave it as a YAML source. Feed it text, get a document. Iconic.

Return

The created document, or NULL on error ๐Ÿ˜ญ


fy_document_build_from_malloc_string

struct fy_document *fy_document_build_from_malloc_string(const struct fy_parse_cfg *cfg, char *str, size_t len)

Create a document using the provided YAML source which was malloced ๐Ÿงš

Parameters

  • cfg (const struct fy_parse_cfg *) โ€” the parse configuration to use, or NULL for the default
  • str (char *) โ€” the YAML source to use
  • len (size_t) โ€” the length of the string (or -1 if 0 terminated)

Description

Creates a document by parsing the provided string as a YAML source. The twist: the string is expected to have been allocated by malloc(3), and when the document is destroyed it will be automatically freed. So like, don't go freeing it yourself afterward, that's not the vibe ๐Ÿซถ

Return

The created document, or NULL on error.


fy_document_build_from_file

struct fy_document *fy_document_build_from_file(const struct fy_parse_cfg *cfg, const char *file)

Create a document parsing the given file ๐Ÿ“

Parameters

  • cfg (const struct fy_parse_cfg *) โ€” the parse configuration to use, or NULL for the default
  • file (const char *) โ€” the name of the file to parse

Description

Creates a document by parsing the provided file as a YAML source. File girlies, this one's for you.

Return

The created document, or NULL on error.


fy_document_build_from_fp

struct fy_document *fy_document_build_from_fp(const struct fy_parse_cfg *cfg, FILE *fp)

Create a document parsing the given file pointer ๐ŸŒˆ

Parameters

  • cfg (const struct fy_parse_cfg *) โ€” the parse configuration to use, or NULL for the default
  • fp (FILE *) โ€” the file pointer

Description

Creates a document by parsing the provided file pointer as a YAML source. Same energy as the file one, except you're already holding the FILE *.

Return

The created document, or NULL on error.


fy_document_vbuildf

struct fy_document *fy_document_vbuildf(const struct fy_parse_cfg *cfg, const char *fmt, va_list ap)

Create a document using the provided YAML via vprintf formatting ๐Ÿ’…

Parameters

  • cfg (const struct fy_parse_cfg *) โ€” the parse configuration to use, or NULL for the default
  • fmt (const char *) โ€” the format string creating the YAML source to use
  • ap (va_list) โ€” the va_list argument pointer

Description

Creates a document by parsing the provided string as a YAML source โ€” except the string is created by applying vprintf formatting. Format string in, YAML document out, no cap.

Return

The created document, or NULL on error.


fy_document_buildf

struct fy_document *fy_document_buildf(const struct fy_parse_cfg *cfg, const char *fmt, ...)

Create a document using the provided YAML source via printf formatting โญ

Parameters

  • cfg (const struct fy_parse_cfg *) โ€” the parse configuration to use, or NULL for the default
  • fmt (const char *) โ€” the format string creating the YAML source to use
  • ellipsis (ellipsis) โ€” the printf arguments

Description

Creates a document by parsing the provided string as a YAML source, where the string is created by applying printf formatting. Yes it's the va_list one's louder sibling.

Return

The created document, or NULL on error.


fy_flow_document_build_from_string

struct fy_document *fy_flow_document_build_from_string(const struct fy_parse_cfg *cfg, const char *str, size_t len, size_t *consumed)

Create a document using the provided YAML source ๐ŸŒธ

Parameters

  • cfg (const struct fy_parse_cfg *) โ€” the parse configuration to use, or NULL for the default
  • str (const char *) โ€” the YAML source to use
  • len (size_t) โ€” the length of the string (or -1 if 0 terminated)
  • consumed (size_t *) โ€” a pointer to the consumed amount

Description

Creates a document by parsing the provided string as a YAML source.

The document is a flow document, i.e. it does not contain any block content and is usually laid out in a single line.

Example of flow documents

plain-scalar โ€œdouble-quoted-scalarโ€ โ€˜single-quoted-scalarโ€™ { foo: bar } [ 0, 1, 2 ]

A flow document matters because parsing stops at the end of it, which means you can drop one inside other non-yaml content. That's the whole point, iykyk ๐Ÿซถ

Return

The created document, or NULL on error.


fy_block_document_build_from_string

struct fy_document *fy_block_document_build_from_string(const struct fy_parse_cfg *cfg, const char *str, size_t len, size_t *consumed)

Create a document using the provided YAML source ๐Ÿฆ‹

Parameters

  • cfg (const struct fy_parse_cfg *) โ€” the parse configuration to use, or NULL for the default
  • str (const char *) โ€” the YAML source to use
  • len (size_t) โ€” the length of the string (or -1 if 0 terminated)
  • consumed (size_t *) โ€” a pointer to the consumed amount

Description

Creates a document by parsing the provided string as a YAML source.

The document is a block document, and it terminates when indentation appears to do so. Indentation is basically the vibe check here ๐Ÿ’€

Example of block documents:

   this-is-yaml
     foo: bar    <- starts here
     baz: [1, 2]
   this-is-yaml-no-more

Return

The created document, or NULL on error.


fy_document_root

struct fy_node *fy_document_root(struct fy_document *fyd)

Return the root node of the document ๐Ÿ‘‘

Parameters

  • fyd (struct fy_document *) โ€” the document

Description

Returns the root of the document. If the document is empty, NULL will be returned instead. Empty document, no root, no main character โ€” tragic but correct.

Return

The root of the document, or NULL if the document is empty.


fy_document_set_root

int fy_document_set_root(struct fy_document *fyd, struct fy_node *fyn)

Set the root of the document ๐ŸŽ€

Parameters

  • fyd (struct fy_document *) โ€” the document
  • fyn (struct fy_node *) โ€” the new root of the document

Description

Sets the root of a document. If the document wasn't empty, the old root will be freed โ€” so don't come crying to me holding a stale pointer, bestie ๐Ÿ˜ญ If fyn is NULL, then the document is set to empty.

Return

0 on success, -1 on error.


fy_node_get_type

enum fy_node_type fy_node_get_type(struct fy_node *fyn)

Get the node type ๐Ÿ”ฅ

Parameters

  • fyn (struct fy_node *) โ€” the node

Description

Retrieves the node type. It is one of FYNT_SCALAR, FYNT_SEQUENCE or FYNT_MAPPING. And a fun little detail: a NULL node argument is a FYNT_SCALAR. Yes really, NULL counts as a scalar. That's the rule ๐Ÿ’…

Return

The node type.

๐Ÿ’… fy_node_get_style

enum fy_node_style fy_node_get_style(struct fy_node *fyn);

Bestie, this one just tells you how a node likes to be rendered โœจ โ€” like, what's its whole aesthetic.

Parameters

  • fyn (struct fy_node *) โ€” the node in question ๐ŸŽ€

Description

Gets the node rendering style. And okay, plot twist: if the node is NULL then the style comes back as FYNS_PLAIN. So even a nothing node has a vibe, iconic.

Return

The node style ๐Ÿ‘‘


๐Ÿฆ‹ fy_node_set_style

enum fy_node_style fy_node_set_style(struct fy_node *fyn, enum fy_node_style style);

Makeover time โ€” you're requesting a new look for a node ๐Ÿ’….

Parameters

  • fyn (struct fy_node *) โ€” the node
  • style (enum fy_node_style) โ€” the requested node rendering style

Description

Tries to set the node rendering style. Notice the "tries" โ€” because if the style is illegal for that node (classic example: you literally can't set an arbitrary scalar that contains zeroes to plain), then whatever style actually got set is what comes back at you. No cap, the function tells you the truth ๐Ÿ™ˆ.

Return

The final node style โ€” as in, the one that actually stuck ๐Ÿ”ฅ


๐Ÿงš fy_node_get_start_token

struct fy_token *fy_node_get_start_token(struct fy_node *fyn);

Grabs the node's start token, like the opening credits of the node's whole era โญ.

Parameters

  • fyn (struct fy_node *) โ€” the node

Description

Retrieves the node start token. And for scalars? This is the exact same thing as the end token. Same token, different nickname, iykyk.

Return

The node start token ๐Ÿ’–


๐ŸŽ€ fy_node_get_end_token

struct fy_token *fy_node_get_end_token(struct fy_node *fyn);

The mirror image bestie โ€” the end token ๐ŸŒธ.

Parameters

  • fyn (struct fy_node *) โ€” the node

Description

Retrieves the node end token. For scalars, this is the same as the start token. (Yeah, we just said that, it's a vibe both ways.)

Return

The node end token ๐Ÿ’œ


โœจ fy_node_is_scalar

bool fy_node_is_scalar(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the node

Description

A little convenience method that checks whether a node is a scalar. That's it, that's the whole thing ๐Ÿซถ.

Return

true if the node is a scalar, false otherwise


๐ŸŒˆ fy_node_is_sequence

bool fy_node_is_sequence(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the node

Description

Convenience method for checking whether a node is a sequence. Short, sweet, slays.

Return

true if the node is a sequence, false otherwise


๐Ÿ’ซ fy_node_is_mapping

bool fy_node_is_mapping(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the node

Description

Convenience method for checking whether a node is a mapping. Okay so it's giving "one job, does it well" ๐Ÿ’….

Return

true if the node is a mapping, false otherwise


๐Ÿ”— fy_node_is_alias

bool fy_node_is_alias(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the node

Description

Convenience method for checking whether a node is an alias. (Aliases are lowkey the main characters of YAML, ngl.)

Return

true if the node is an alias, false otherwise


๐Ÿซง fy_node_is_null

bool fy_node_is_null(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the node

Description

Convenience method for checking whether a node is a NULL scalar. And here's the cute little gotcha: a NULL node argument returns trueโ€ฆ yes, really ๐Ÿ™ˆ.

Return

true if the node is a NULL scalar, false otherwise


๐Ÿงท fy_node_is_attached

bool fy_node_is_attached(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the node

Description

Checks whether a node is attached in a document structure. Real talk: an attached node may not be freed before being detached, so don't even try it ๐Ÿ’€. And yes, there is no method that explicitly detaches a node โ€” that's handled internally by the sequence and mapping removal methods, so it's giving "the library handles it, stay out of it" energy.

Return

true if the node is attached, false otherwise


๐Ÿท๏ธ fy_node_get_tag_token

struct fy_token *fy_node_get_tag_token(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the node which has the tag token to be returned

Description

Gets the tag token of a node, if it exists. If it doesn't exist, no drama, you get nothing back.

Return

The tag token of the given node, or NULL if the tag does not exist ๐Ÿ“


๐ŸŒธ fy_node_get_scalar_token

struct fy_token *fy_node_get_scalar_token(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the node which has the scalar token to be returned

Description

Gets the scalar token of a node, if it exists and the node is a valid scalar node. And heads up bestie: aliases are scalars, so if you call this on an alias node, what you get back shall be an alias token ๐Ÿ‘€. Plot twist handled.

Return

The scalar token of the given node, or NULL if the node is not a scalar ๐Ÿ’œ


๐ŸŒ€ fy_node_resolve_alias

struct fy_node *fy_node_resolve_alias(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the alias node to be resolved

Description

Resolves an alias node, following any subsequent aliases until a non-alias node has been found. Basically chasing the chain until someone's actually real ๐Ÿฆ‹. This call performs cycle detection and excessive redirections checks, so it's totally safe to call in any context. No infinite loop jump scare, we promise.

Return

The resolved alias node, or NULL if either fyn is not an alias, or resolution fails due to a graph cycle ๐Ÿ’€


๐Ÿชž fy_node_dereference

struct fy_node *fy_node_dereference(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the alias node to be dereferenced

Description

Dereferences an alias node. And this is different from resolution, bestie โ€” this one only performs a single alias follow call, and it will fail if the input is not an alias. One hop only, no chain-chasing ๐ŸŒˆ. It also performs cycle detection and excessive redirections checks, so it's safe to call in any context.

Return

The dereferenced alias node, or NULL if either fyn is not an alias, or resolution fails due to a graph cycle


๐Ÿ—‘๏ธ fy_node_free

int fy_node_free(struct fy_node *fyn);

Parameters

  • fyn (struct fy_node *) โ€” the node to free

Description

Recursively frees the given node, releasing the memory it uses, removing any anchors on the document it contains, and releasing references on the tokens it contains. Full cleanup, no crumbs ๐Ÿ’….

But โ€” this method will return an error if the node is attached, or if it's not NULL and it isn't a member of a document. So, like, don't free attached nodes, we literally warned you ๐Ÿ™ˆ.

Return

0 on success, -1 on error


๐ŸŒฑ fy_node_build_from_string

struct fy_node *fy_node_build_from_string(struct fy_document *fyd, const char *str, size_t len);

Create a node using the provided YAML source โœจ.

Parameters

  • fyd (struct fy_document *) โ€” the document
  • str (const char *) โ€” the YAML source to use
  • len (size_t) โ€” the length of the string (or -1 if '0' terminated)

Description

Creates a node by parsing the provided string as a YAML source. The node created will be associated with the provided document ๐ŸŽ€.

Return

The created node, or NULL on error


๐Ÿงต fy_node_build_from_malloc_string

struct fy_node *fy_node_build_from_malloc_string(struct fy_document *fyd, char *str, size_t len);

Same energy as above, except the string came from malloc and the library takes ownership of it ๐Ÿ’….

Parameters

  • fyd (struct fy_document *) โ€” the document
  • str (char *) โ€” the YAML source to use
  • len (size_t) โ€” the length of the string (or -1 if '0' terminated)

Description

Creates a node by parsing the provided string as a YAML source, and the node created will be associated with the provided document. Key detail: the string is expected to have been allocated by malloc(3), and when the document is destroyed it will be automatically freed ๐Ÿซถ. So don't go freeing it yourself afterward, that's double-free territory, bestie.

Return

The created node, or NULL on error


๐Ÿ“ fy_node_build_from_file

struct fy_node *fy_node_build_from_file(struct fy_document *fyd, const char *file);

Parameters

  • fyd (struct fy_document *) โ€” the document
  • file (const char *) โ€” the name of the file to parse

Description

Creates a node by parsing the provided file as a YAML source. The node created will be associated with the provided document ๐ŸŒธ.

Return

The created node, or NULL on error


๐Ÿ–จ๏ธ fy_node_build_from_fp

struct fy_node *fy_node_build_from_fp(struct fy_document *fyd, FILE *fp);

Parameters

  • fyd (struct fy_document *) โ€” the document
  • fp (FILE *) โ€” the file pointer

Description

Creates a node by parsing the provided file pointer as a YAML source. The node created will be associated with the provided document โญ.

Return

The created node, or NULL on error


๐Ÿงช fy_node_vbuildf

struct fy_node *fy_node_vbuildf(struct fy_document *fyd, const char *fmt, va_list ap);

Create a node using the provided YAML source via vprintf formatting ๐Ÿ’œ.

Parameters

  • fyd (struct fy_document *) โ€” the document
  • fmt (const char *) โ€” the format string creating the YAML source to use
  • ap (va_list) โ€” the va_list argument pointer

Description

Creates a node by parsing the resulting string as a YAML source. The string is created by applying vprintf formatting. Format-string girlies, this one's for you ๐ŸŽ€.

Return

The created node, or NULL on error


๐ŸŽจ fy_node_buildf

struct fy_node *fy_node_buildf(struct fy_document *fyd, const char *fmt, ...);

Create a node using the provided YAML source via printf formatting โœจ.

Parameters

  • fyd (struct fy_document *) โ€” the document
  • fmt (const char *) โ€” the format string creating the YAML source to use
  • ellipsis (ellipsis) โ€” the printf arguments

Description

Creates a node by parsing the resulting string as a YAML source. The string is created by applying printf formatting โ€” the comfy varargs version, no va_list required ๐Ÿซถ.

Return

The created node, or NULL on error


๐Ÿ—บ๏ธ fy_node_by_path

struct fy_node *fy_node_by_path(struct fy_node *fyn, const char *path, size_t len, enum fy_node_walk_flags flags);

Retrieve a node using the provided path spec ๐Ÿ”.

Parameters

  • fyn (struct fy_node *) โ€” the node to use as start of the traversal operation
  • path (const char *) โ€” the path spec to use in the traversal operation
  • len (size_t) โ€” the length of the path (or -1 if '0' terminated)
  • flags (enum fy_node_walk_flags) โ€” the extra path walk flags
No return value documented in this part โ€” the page continues from here, so stay tuned bestie ๐ŸŒˆ

Okay so this method pulls up a node relative to the one you hand it, using the path spec you give it. ๐Ÿ’…

Path specs are just keys stitched together with slashes /. Keys are either regular YAML expressions in flow format (for walking mappings) or indexes in brackets (for walking sequences). A path spec can start with /, and that leading slash is silently ignored. โœจ

A few examples make it click:

fyn = { foo: bar } - fy_node_by_path(fyn, "/foo") -> bar
fyn = [ foo, bar ] - fy_node_by_path(fyn, "1") -> bar
fyn = { { foo: bar }: baz } - fy_node_by_path(fyn, "{foo: bar}") -> baz
fyn = [ foo, { bar: baz } } - fy_node_by_path(fyn, "1/bar") -> baz

Heads up: the special characters /{}[] are not escaped in plain style, so you will not be able to use them as path traversal keys. In that case you can easily use either the single or double quoted forms:

fyn = { foo/bar: baz } - fy_node_by_path(fyn, "'foo/bar'") -> baz

Return: The retrieved node, or NULL if itโ€™s not possible to be found. ๐Ÿ˜ญ


โœจ fy_node_get_path โœจ

char *fy_node_get_path(struct fy_node *fyn)

Get the path of this node

Parameters:

  • fyn (*struct fy_node**) โ€” The node

Description: Grab the given nodeโ€™s path address relative to the document root, bestie. This address is dynamically allocated, so free it when youโ€™re done with it. ๐Ÿซถ

Return: The nodeโ€™s address, or NULL if fyn is the root.


โœจ fy_node_get_parent โœจ

struct fy_node *fy_node_get_parent(struct fy_node *fyn)

Get the parent node of a node

Parameters:

  • fyn (*struct fy_node**) โ€” The node

Description: Get the parent node of a node. The parent of a documentโ€™s root is NULL, and so is the parent of the root of a key node in a mapping. This is because the nodes of a key may not be addressed using a path expression. ๐Ÿ’€

Return: The nodeโ€™s parent, or NULL if fyn is the root, or the root of a key mapping.


โœจ fy_node_get_document_parent โœจ

struct fy_node *fy_node_get_document_parent(struct fy_node *fyn)

Get the document parent node of a node

Parameters:

  • fyn (*struct fy_node**) โ€” The node

Description: Get the document parent node of a node. The document parent differs from the regular parent in that a keyโ€™s root node of a mapping is not NULL; instead it points to the actual node parent. ๐ŸŒˆ

Return: The nodeโ€™s document parent, or NULL if fyn is the root.


โœจ fy_node_get_parent_address โœจ

char *fy_node_get_parent_address(struct fy_node *fyn)

Get the path address of this nodeโ€™s parent

Parameters:

  • fyn (*struct fy_node**) โ€” The node

Description: Retrieve the given nodeโ€™s parent path address. The address is dynamically allocated, so free it when youโ€™re done with it. ๐ŸŽ€

Return: The parentโ€™s address, or NULL if fyn is the root.


โœจ fy_node_get_path_relative_to โœจ

char *fy_node_get_path_relative_to(struct fy_node *fyn_parent, struct fy_node *fyn)

Get a path address of a node relative to one of its parents

Parameters:

  • fyn_parent (*struct fy_node**) โ€” The node parent/grandparentโ€ฆ
  • fyn (*struct fy_node**) โ€” The node

Description: Retrieve the given nodeโ€™s path address relative to an arbitrary parent in the tree. The address is dynamically allocated, so free it when youโ€™re done with it. ๐Ÿ’–

Return: The relative address from the parent to the node.


โœจ fy_node_get_short_path โœจ

char *fy_node_get_short_path(struct fy_node *fyn)

Get a path address of a node in the shortest path possible

Parameters:

  • fyn (*struct fy_node**) โ€” The node

Description: Retrieve the given nodeโ€™s short path address relative to the closest anchor โ€” either on this node or its parent. If no such parent is found, it returns the absolute path from the start of the document. ๐Ÿฆ‹

Example:

--- &foo
foo: &bar
    bar
baz
  • The short path of /foo is \*foo
  • The short path of /foo/bar is \*bar
  • The short path of /baz is \*foo/baz

The address is dynamically allocated, so free it when youโ€™re done with it.

Return: The shortest path describing the node.


โœจ fy_node_get_reference โœจ

char *fy_node_get_reference(struct fy_node *fyn)

Get a textual reference to a node

Parameters:

  • fyn (*struct fy_node**) โ€” The node

Description: Retrieve the given nodeโ€™s textual reference. If the node contains an anchor, the expression that references the anchor will be returned; otherwise an absolute path reference relative to the root of the document will be returned. The address is dynamically allocated, so free it when youโ€™re done with it. ๐ŸŒธ

Return: The nodeโ€™s text reference.


โœจ fy_node_create_reference โœจ

struct fy_node *fy_node_create_reference(struct fy_node *fyn)

Create an alias reference node

Parameters:

  • fyn (*struct fy_node**) โ€” The node

Description: Create an alias node reference. If the node contains an anchor, the expression that references the alias will use the anchor; otherwise an absolute path reference relative to the root of the document will be created. ๐Ÿ‘‘

Return: An alias node referencing the argument node.


โœจ fy_node_get_relative_reference โœจ

char *fy_node_get_relative_reference(struct fy_node *fyn_base, struct fy_node *fyn)

Get a textual reference to a node relative to a base node.

Parameters:

  • fyn_base (*struct fy_node**) โ€” The base node
  • fyn (*struct fy_node**) โ€” The node

Description: Retrieve the given nodeโ€™s textual reference as generated using another parent (or grandparent) as a base. If the node contains an anchor, the expression that references the anchor will be returned. If the base node contains an anchor, the reference will be relative to it; otherwise an absolute path reference will be returned. The address is dynamically allocated, so free it when youโ€™re done with it. โญ

Return: The nodeโ€™s text reference.


โœจ fy_node_create_relative_reference โœจ

struct fy_node *fy_node_create_relative_reference(struct fy_node *fyn_base, struct fy_node *fyn)

Create an alias reference node

Parameters:

  • fyn_base (*struct fy_node**) โ€” The base node
  • fyn (*struct fy_node**) โ€” The node

Description: Create a relative alias node reference using another parent (or grandparent) as a base. If the node contains an anchor, the alias will reference the anchor. If the base node contains an anchor, the alias will be relative to it; otherwise an absolute path reference will be created. ๐Ÿ”ฅ

Return: An alias node referencing the argument node relative to the base.


โœจ fy_node_create_scalar โœจ

struct fy_node *fy_node_create_scalar(struct fy_document *fyd, const char *data, size_t size)

Create a scalar node.

Parameters:

  • fyd (*struct fy_document**) โ€” The document which the resulting node will be associated with
  • data (*const char**) โ€” Pointer to the data area
  • size (*size_t**) โ€” Size of the data area, or (size_t)-1 for '0' terminated data.

Description: Create a scalar node using the provided memory area as input. The input is expected to be regular utf8 encoded. It may contain escaped characters, in which case the style of the scalar will be set to double quoted. Note that the data are not copied โ€” merely a reference is taken โ€” so it must be available while the node is in use. ๐Ÿ™ˆ

Return: The created node, or NULL on error.


โœจ fy_node_create_scalar_copy โœจ

struct fy_node *fy_node_create_scalar_copy(struct fy_document *fyd, const char *data, size_t size)

Create a scalar node copying the data.

Parameters:

  • fyd (*struct fy_document**) โ€” The document which the resulting node will be associated with
  • data (*const char**) โ€” Pointer to the data area
  • size (*size_t**) โ€” Size of the data area, or (size_t)-1 for '0' terminated data.

Description: Create a scalar node using the provided memory area as input. The input is expected to be regular utf8 encoded. It may contain escaped characters, in which case the style of the scalar will be set to double quoted. A copy of the data will be made, so it is safe to free the data after the call. ๐Ÿ’œ

Return: The created node, or NULL on error.


โœจ fy_node_create_vscalarf โœจ

struct fy_node *fy_node_create_vscalarf(struct fy_document *fyd, const char *fmt, va_list ap)

vprintf interface for creating scalars

Parameters:

  • fyd (*struct fy_document**) โ€” The document which the resulting node will be associated with
  • fmt (*const char**) โ€” The printf based format string
  • ap (*va_list**) โ€” The va_list containing the arguments

Description: Create a scalar node using a vprintf interface. The input is expected to be regular utf8 encoded. It may contain escaped characters, in which case the style of the scalar will be set to double quoted. ๐Ÿงš

Return: The created node, or NULL on error.


โœจ fy_node_create_scalarf โœจ

struct fy_node *fy_node_create_scalarf(struct fy_document *fyd, const char *fmt, ...)

printf interface for creating scalars

Parameters:

  • fyd (*struct fy_document**) โ€” The document which the resulting node will be associated with
  • fmt (*const char**) โ€” The printf based format string
  • ellipsis (*ellipsis**) โ€” The arguments

Description: Create a scalar node using a printf interface. The input is expected to be regular utf8 encoded. It may contain escaped characters, in which case the style of the scalar will be set to double quoted. ๐Ÿ“

Return: The created node, or NULL on error.


โœจ fy_node_create_sequence โœจ

struct fy_node *fy_node_create_sequence(struct fy_document *fyd)

Create an empty sequence node.

Parameters:

  • fyd (*struct fy_document**) โ€” The document which the resulting node will be associated with

Description: Create an empty sequence node associated with the given document.

Return: The created node, or NULL on error.


โœจ fy_node_create_mapping โœจ

struct fy_node *fy_node_create_mapping(struct fy_document *fyd)

Create an empty mapping node.

Parameters:

  • fyd (*struct fy_document**) โ€” The document which the resulting node will be associated with

Description: Create an empty mapping node associated with the given document.

๐ŸŒธ Return ๐ŸŒธ

The created node, or NULL on error. That's the vibe check for the previous function โ€” success hands you a node, failure hands you NULL, periodt.


๐Ÿ’– fy_node_set_tag ๐Ÿ’–

int fy_node_set_tag(struct fy_node *fyn, const char *data, size_t len)

Okay so bestie, this one manually sets the tag of a node.

Parameters

  • fyn (struct fy_node*) โ€” the node to set itโ€™s tag. Yes, that apostrophe is in the original, weโ€™re keeping the energy.
  • data (const char*) โ€” pointer to the tag data.
  • len (size_t) โ€” size of the tag data, or (size_t)-1 for '0' terminated.

Description

Manually set the tag of a node. The tag must be a valid one for the document the node belongs to.

โš ๏ธ Note that the data are not copied โ€” merely a reference is taken, so it must be available while the node is in use. No cap, that buffer has to stay alive as long as the node does.

If the node already contains a tag it will be overwriten.

Return

0 on success, -1 on error.


๐ŸŽ€ fy_node_remove_tag ๐ŸŽ€

int fy_node_remove_tag(struct fy_node *fyn)

Removes the tag from a node. Poof, gone, no tag era.

Parameters

  • fyn (struct fy_node*) โ€” the node to remove itโ€™s tag.

Description

Remove the tag of a node.

Return

0 on success, -1 on error.


๐Ÿฆ‹ fy_node_get_tag ๐Ÿฆ‹

const char *fy_node_get_tag(struct fy_node *fyn, size_t *lenp)

Gets you a pointer to the tag text, plus the length. Lowkey important: this text is not NULL terminated.

Parameters

  • fyn (struct fy_node*) โ€” the node.
  • lenp (size_t*) โ€” pointer to a variable that will hold the returned length.

Description

This method will return a pointer to the text of a tag along with the length of it. Note that this text is not NULL terminated.

Return

A pointer to the tag of the node, while lenp will be assigned the length of said tag. A NULL will be returned in case of an error.


๐ŸŒธ fy_node_get_tag0 ๐ŸŒธ

const char *fy_node_get_tag0(struct fy_node *fyn)

Same tag-getting mission, but this one is NULL terminated. Very demure, very convenient.

Parameters

  • fyn (struct fy_node*) โ€” the node.

Description

This method will return a pointer to the text of a tag, which will be NULL terminated.

Return

A pointer to the null terminated tag of the node. A NULL will be returned in case of an error.


โœจ fy_node_get_tag_length โœจ

size_t fy_node_get_tag_length(struct fy_node *fyn)

Just the length of the nodeโ€™s tag. If thereโ€™s no tag, itโ€™s giving 0.

Parameters

  • fyn (struct fy_node*) โ€” the tagged node.

Description

This method will return the size of the tag of the node. If the node is not tagged it will return 0.

Return

The size of the tag, or 0 if node is not tagged.


๐Ÿ’œ fy_node_get_scalar ๐Ÿ’œ

const char *fy_node_get_scalar(struct fy_node *fyn, size_t *lenp)

Gets the scalar content of a node, with length. Heads up bestie: this pointer is not NULL terminated.

Parameters

  • fyn (struct fy_node*) โ€” the scalar node.
  • lenp (size_t*) โ€” pointer to a variable that will hold the returned length.

Description

This method will return a pointer to the text of the scalar content of a node along with the length of it. Note that this pointer is not NULL terminated.

Return

A pointer to the scalar content of the node, while lenp will be assigned the length of said content. A NULL will be returned in case of an error, i.e. the node is not a scalar.


๐Ÿ“ fy_node_get_scalar0 ๐Ÿ“

const char *fy_node_get_scalar0(struct fy_node *fyn)

Same scalar energy, but returns a NULL terminated string. Plot twist: it allocates memory to make that happen.

Parameters

  • fyn (struct fy_node*) โ€” the scalar node.

Description

This method will return a pointer to the text of the scalar content of a node as a null terminated string. Note that this call will allocate memory to hold the null terminated string so if possible use fy_node_get_scalar().

Return

A pointer to the scalar content of the node or NULL is returned in case of an error.


๐Ÿงš fy_node_get_scalar_length ๐Ÿงš

size_t fy_node_get_scalar_length(struct fy_node *fyn)

The size of the scalar content. Not a scalar? Then itโ€™s 0, no drama.

Parameters

  • fyn (struct fy_node*) โ€” the scalar node.

Description

This method will return the size of the scalar content of the node. If the node is not a scalar it will return 0.

Return

The size of the scalar content, or 0 if node is not scalar.


๐ŸŒˆ fy_node_get_scalar_utf8_length ๐ŸŒˆ

size_t fy_node_get_scalar_utf8_length(struct fy_node *fyn)

Same size check, but counted in utf8 characters. If itโ€™s not a scalar, you get 0.

Parameters

  • fyn (struct fy_node*) โ€” the scalar node.

Description

This method will return the size of the scalar content of the node in utf8 characters. If the node is not a scalar it will return 0.

Return

The size of the scalar content in utf8 characters, or 0 if node is not scalar.


๐Ÿซถ fy_node_sequence_iterate ๐Ÿซถ

struct fy_node *fy_node_sequence_iterate(struct fy_node *fyn, void **prevp)

Iterates over all the item nodes in a sequence node. Start of the iteration is signalled by a NULL in *prevp.

Parameters

  • fyn (struct fy_node*) โ€” the sequence node.
  • prevp (void**) โ€” the previous sequence iterator.

Description

This method iterates over all the item nodes in the sequence node. The start of the iteration is signalled by a NULL in *prevp.

Return

The next node in sequence or NULL at the end of the sequence.


๐Ÿ”ฅ fy_node_sequence_reverse_iterate ๐Ÿ”ฅ

struct fy_node *fy_node_sequence_reverse_iterate(struct fy_node *fyn, void **prevp)

Same as above but backwards. Main character energy: entering the sequence from the end.

Parameters

  • fyn (struct fy_node*) โ€” the sequence node.
  • prevp (void**) โ€” the previous sequence iterator.

Description

This method iterates in reverse over all the item nodes in the sequence node. The start of the iteration is signalled by a NULL in *prevp.

Return

The next node in reverse sequence or NULL at the end of the sequence.


๐Ÿ‘‘ fy_node_sequence_item_count ๐Ÿ‘‘

int fy_node_sequence_item_count(struct fy_node *fyn)

Gets the item count of the sequence. If somethingโ€™s wrong, you get -1.

Parameters

  • fyn (struct fy_node*) โ€” the sequence node.

Description

Get the item count of the sequence.

Return

The count of items in the sequence or -1 in case of an error.


๐Ÿ’… fy_node_sequence_is_empty ๐Ÿ’…

bool fy_node_sequence_is_empty(struct fy_node *fyn)

Checks whether the sequence contains items. Thatโ€™s what the description says, bestie.

Parameters

  • fyn (struct fy_node*) โ€” the sequence node.

Description

Check whether the sequence contains items.

Return

true if the node is a sequence containing items, false otherwise.


๐ŸŽ€ fy_node_sequence_get_by_index ๐ŸŽ€

struct fy_node *fy_node_sequence_get_by_index(struct fy_node *fyn, int index)

Grabs a sequence item by index. Positive or zero counts from the start, negative counts from the end โ€” so -1 is literally the last item.

Parameters

  • fyn (struct fy_node*) โ€” the sequence node.
  • index (int) โ€” the index of the node to retrieve.
    • >= 0 counting from the start
    • < 0 counting from the end

Description

Retrieve a node in the sequence using itโ€™s index. If index is positive or zero the count is from the start of the sequence, while if negative from the end. I.e. -1 returns the last item in the sequence.

Return

The node at the specified index or NULL if no such item exist.


๐ŸŒŸ fy_node_sequence_append ๐ŸŒŸ

int fy_node_sequence_append(struct fy_node *fyn_seq, struct fy_node *fyn)

Appends a node item to a sequence. Adding to the end, very last-slot-of-the-group-chat energy.

Parameters

  • fyn_seq (struct fy_node*) โ€” the sequence node.
  • fyn (struct fy_node*) โ€” the node item to append.

Description

Append a node item to a sequence.

Return

0 on success, -1 on error.


๐Ÿฆ‹ fy_node_sequence_prepend ๐Ÿฆ‹

int fy_node_sequence_prepend(struct fy_node *fyn_seq, struct fy_node *fyn)

The original one-liner says โ€œAppend a node item to a sequenceโ€ โ€” yes, really โ€” but the description is prepend. Weโ€™re keeping both because fidelity is the moment.

Parameters

  • fyn_seq (struct fy_node*) โ€” the sequence node.
  • fyn (struct fy_node*) โ€” the node item to prepend.

Description

Prepend a node item to a sequence.

Return

0 on success, -1 on error.


๐Ÿ’– fy_node_sequence_insert_before ๐Ÿ’–

int fy_node_sequence_insert_before(struct fy_node *fyn_seq, struct fy_node *fyn_mark, struct fy_node *fyn)

Inserts a node item before another one in the sequence. Itโ€™s giving โ€œexcuse me, Iโ€™m cutting the line.โ€

Parameters

  • fyn_seq (struct fy_node*) โ€” the sequence node.
  • fyn_mark (struct fy_node*) โ€” the node item which the node will be inserted before.
  • fyn (struct fy_node*) โ€” the node item to insert in the sequence.

Description

Insert a node item before another in the sequence.

Return

0 on success, -1 on error.


๐Ÿ’œ fy_node_sequence_insert_after ๐Ÿ’œ

int fy_node_sequence_insert_after(struct fy_node *fyn_seq, struct fy_node *fyn_mark, struct fy_node *fyn)

Same insert situation, but after the mark instead of before.

Parameters

  • fyn_seq (struct fy_node*) โ€” the sequence node.
  • fyn_mark (struct fy_node*) โ€” the node item which the node will be inserted after.
  • fyn (struct fy_node*) โ€” the node item to insert in the sequence.

Description

Insert a node item after another in the sequence.

Return

0 on success, -1 on error.


๐Ÿ“ fy_node_sequence_remove ๐Ÿ“

struct fy_node *fy_node_sequence_remove(struct fy_node *fyn_seq, struct fy_node *fyn)

Removes an item from a sequence and returns it. You get the node back โ€” take it, itโ€™s yours.

Parameters

  • fyn_seq (struct fy_node*) โ€” the sequence node.
  • fyn (struct fy_node*) โ€” the node item to remove from the sequence.

Description

Remove a node item from a sequence and return it.

Return

The removed node item fyn, or NULL in case of an error.


๐ŸŒˆ typedef fy_node_sequence_sort_fn ๐ŸŒˆ

int fy_node_sequence_sort_fn(struct fy_node *fyn_a, struct fy_node *fyn_b, void *arg)

The comparison method used when sorting a sequence. It returns less-than/equal/greater-than vibes.

Parameters

  • fyn_a (struct fy_node*) โ€” the first node used in the comparison.
  • fyn_b (struct fy_node*) โ€” the second node used in the comparison.
  • arg (void*) โ€” the opaque user provided pointer to the sort operation.

Return

  • < 0 if fyn_a is less than fyn_b
  • 0 if fyn_a is equal to fyn_b
  • > 0 if fyn_a is greater than fyn_b

โœจ fy_node_sequence_sort โœจ

int fy_node_sequence_sort(struct fy_node *fyn_seq, fy_node_sequence_sort_fn cmp, void *arg)

Sorts a sequenceโ€™s items using your comparison method. Put it in order, bestie.

Parameters

  • fyn_seq (struct fy_node*) โ€” the sequence node to sort.
  • cmp (fy_node_sequence_sort_fn) โ€” the comparison method.
  • arg (void*) โ€” an opaque user pointer for the comparison method.

Description

Sort the items of a sequence node using the given comparison method.

Return

0 on success, -1 on error.


๐Ÿงš fy_node_mapping_iterate ๐Ÿงš

struct fy_node_pair *fy_node_mapping_iterate(struct fy_node *fyn, void **prevp)

Iterate over a mapping node. Thatโ€™s the brief โ€” this part of the page stops right here, so no params are listed yet.

  • fyn (struct fy_node*) โ€” the mapping node ๐Ÿ’…
  • prevp (void**) โ€” the previous sequence iterator (yeah, it literally says sequence on a mapping function โ€” not me, that's the source ๐Ÿ˜ญ)

Description

okay so this one iterates over, like, all the node pairs in the mapping node. The start of the iteration is signalled by a NULL in *prevp โ€” that's your little green flag to begin โœจ

note that while a mapping is an unordered collection of key/values, the order of which they are created is important for presentation purposes. periodt.

Return

The next node pair in the mapping, or NULL at the end of the mapping. iykyk ๐ŸŽ€

fy_node_mapping_reverse_iterate

struct fy_node_pair *fy_node_mapping_reverse_iterate(struct fy_node *fyn, void **prevp)

Iterate over a mapping node in reverse โ€” walking backwards like it's a comeback era ๐Ÿ’€

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • prevp (void**) โ€” the previous sequence iterator (again with the "sequence", we stay unbothered ๐Ÿซถ)

Description

This method iterates in reverse over all the node pairs in the mapping node. The start of the iteration is signalled by a NULL in *prevp.

same energy as before: while a mapping is an unordered collection of key/values, the order of which they are created is important for presentation purposes. no cap.

Return

The next node pair in reverse sequence in the mapping, or NULL at the end of the mapping. ๐Ÿ’–

fy_node_mapping_item_count

int fy_node_mapping_item_count(struct fy_node *fyn)

Return the node pair count of the mapping โ€” literally just counting, bestie ๐Ÿ”ข

Parameters

  • fyn (struct fy_node*) โ€” the mapping node

Description

Get the count of the node pairs in the mapping.

Return

The count of node pairs in the mapping, or -1 in case of an error. (yes, -1 is the "something went wrong" vibe check ๐Ÿšฉ)

fy_node_mapping_is_empty

bool fy_node_mapping_is_empty(struct fy_node *fyn)

Check whether the mapping is empty โ€” the "is this group chat dead" check ๐Ÿ™ˆ

Parameters

  • fyn (struct fy_node*) โ€” the mapping node

Description

Check whether the mapping contains any node pairs.

Return

true if the node is a mapping containing node pairs, false otherwise.

fy_node_mapping_get_by_index

struct fy_node_pair *fy_node_mapping_get_by_index(struct fy_node *fyn, int index)

Return a node pair by index โ€” pick your fave by number ๐ŸŽฏ

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • index (int) โ€” the index of the node pair to retrieve
    • >= 0 counting from the start
    • < 0 counting from the end

Description

Retrieve a node pair in the mapping using its index. If index is positive or zero the count is from the start of the sequence, while if negative from the end. I.e. -1 returns the last node pair in the mapping. main character behaviour, honestly ๐Ÿ‘‘

Return

The node pair at the specified index, or NULL if no such item exist.

fy_node_mapping_lookup_pair_by_string

struct fy_node_pair *fy_node_mapping_lookup_pair_by_string(struct fy_node *fyn, const char *key, size_t len)

Lookup a node pair in mapping by string ๐Ÿ”

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • key (const char*) โ€” the YAML source to use as key
  • len (size_t) โ€” the length of the key (or -1 if '0' terminated)

Description

This method will return the node pair that contains the same key from the YAML node created from the key argument. The comparison of the node is using fy_node_compare().

Return

The value matching the given key, or NULL if not found. ๐Ÿ’œ

fy_node_mapping_lookup_by_string

struct fy_node *fy_node_mapping_lookup_by_string(struct fy_node *fyn, const char *key, size_t len)

Lookup a node value in mapping by string โ€” yes, the name says "lookup" and the summary says "value", we're just built different ๐Ÿฆ‹

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • key (const char*) โ€” the YAML source to use as key
  • len (size_t) โ€” the length of the key (or -1 if '0' terminated)

Description

This method will return the value of node pair that contains the same key from the YAML node created from the key argument. The comparison of the node is using fy_node_compare().

Return

The value matching the given key, or NULL if not found.

fy_node_mapping_lookup_value_by_string

struct fy_node *fy_node_mapping_lookup_value_by_string(struct fy_node *fyn, const char *key, size_t len)

Lookup a node value in mapping by string โ€” the explicit version, for the girlies who like to be very clear about their intentions ๐Ÿ’…

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • key (const char*) โ€” the YAML source to use as key
  • len (size_t) โ€” the length of the key (or -1 if '0' terminated)

Description

This method will return the value of node pair that contains the same key from the YAML node created from the key argument. The comparison of the node is using fy_node_compare().

It is synonymous with fy_node_mapping_lookup_by_string(). literally the same girl, different name โœจ

Return

The value matching the given key, or NULL if not found.

fy_node_mapping_lookup_key_by_string

struct fy_node *fy_node_mapping_lookup_key_by_string(struct fy_node *fyn, const char *key, size_t len)

Lookup a node key in mapping by string โ€” the flip side, we want the key itself this time ๐Ÿ”‘

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • key (const char*) โ€” the YAML source to use as key
  • len (size_t) โ€” the length of the key (or -1 if '0' terminated)

Description

This method will return the key of node pair that contains the same key from the YAML node created from the key argument. The comparison of the node is using fy_node_compare().

Return

The key matching the given key, or NULL if not found.

fy_node_mapping_lookup_pair_by_simple_key

struct fy_node_pair *fy_node_mapping_lookup_pair_by_simple_key(struct fy_node *fyn, const char *key, size_t len)

Lookup a node pair in mapping by simple string โ€” no YAML parsing arc, we're keeping it simple ๐Ÿงš

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • key (const char*) โ€” the string to use as key
  • len (size_t) โ€” the length of the key (or -1 if '0' terminated)

Description

This method will return the node pair that contains the same key from the YAML node created from the key argument. The comparison of the node is using by comparing the strings for identity.

Return

The node pair matching the given key, or NULL if not found. ๐ŸŒธ

fy_node_mapping_lookup_value_by_simple_key

struct fy_node *fy_node_mapping_lookup_value_by_simple_key(struct fy_node *fyn, const char *key, size_t len)

Lookup a node value in mapping by simple string โ€” same simplicity, but gimme the value ๐ŸŽ€

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • key (const char*) โ€” the string to use as key
  • len (size_t) โ€” the length of the key (or -1 if '0' terminated)

Description

This method will return the value of node pair that contains the same key from the YAML node created from the key argument. The comparison of the node is using by comparing the strings for identity.

Return

The value matching the given key, or NULL if not found.

fy_node_mapping_lookup_pair_by_null_key

struct fy_node_pair *fy_node_mapping_lookup_pair_by_null_key(struct fy_node *fyn)

Lookup a node pair in mapping that has a NULL key โ€” the chaotic one ๐Ÿซ 

Parameters

  • fyn (struct fy_node*) โ€” the mapping node

Description

This method will return the node pair that has a NULL key. Note this method is not using the mapping accelerator and arguably NULL keys should not exist. Alasโ€ฆ

"Alasโ€ฆ" is doing so much emotional labour in that sentence and honestly? felt ๐Ÿ˜ญ

Return

The node pair with a NULL key, NULL otherwise.

fy_node_mapping_lookup_value_by_null_key

struct fy_node *fy_node_mapping_lookup_value_by_null_key(struct fy_node *fyn)

Lookup a node value with a NULL key. bestie we're in the void now ๐Ÿ’€

Parameters

  • fyn (struct fy_node*) โ€” the mapping node

Description

Return the value of a node pair that has a NULL key.

Return

The value matching the null key, NULL otherwise. Note that the value may be NULL too, but for that pathological case use the node pair method instead. ๐Ÿ™ˆ

fy_node_mapping_lookup_scalar_by_simple_key

const char *fy_node_mapping_lookup_scalar_by_simple_key(struct fy_node *fyn, size_t *lenp, const char *key, size_t keylen)

Lookup a scalar in mapping by simple string โ€” we're going straight for the raw scalar contents now โœจ

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • lenp (size_t*) โ€” pointer to a variable that will hold the returned length
  • key (const char*) โ€” the string to use as key
  • keylen (size_t) โ€” the length of the key (or -1 if '0' terminated)

Description

This method will return the scalar contents that contains the same key from the YAML node created from the key argument. The comparison of the node is using by comparing the strings for identity.

Return

The scalar contents matching the given key, or NULL if not found. ๐Ÿ’œ

fy_node_mapping_lookup_scalar0_by_simple_key

const char *fy_node_mapping_lookup_scalar0_by_simple_key(struct fy_node *fyn, const char *key, size_t keylen)

Lookup a scalar in mapping by simple string returning a '0' terminated scalar โ€” the one with the NUL happily attached ๐ŸŒˆ

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • key (const char*) โ€” the string to use as key
  • keylen (size_t) โ€” the length of the key (or -1 if '0' terminated)

Description

This method will return the NUL terminated scalar contents that contains the same key from the YAML node created from the key argument. The comparison of the node is using by comparing the strings for identity.

Return

The NUL terminated scalar contents matching the given key, or NULL if not found. ๐Ÿฆ‹

fy_node_mapping_lookup_pair

struct fy_node_pair *fy_node_mapping_lookup_pair(struct fy_node *fyn, struct fy_node *fyn_key)

Lookup a node pair matching the provided key โ€” you bring your own node as the key, we love a self-sufficient queen ๐Ÿ‘‘

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • fyn_key (struct fy_node*) โ€” the node to use as key

Description

This method will return the node pair that matches the provided fyn_key.

Return

The node pair matching the given key, or NULL if not found.

fy_node_mapping_lookup_value_by_key

struct fy_node *fy_node_mapping_lookup_value_by_key(struct fy_node *fyn, struct fy_node *fyn_key)

Lookup a node pair's value matching the provided key โ€” node-in, value-out, the classic trade ๐Ÿ”ฅ

Parameters

  • fyn (struct fy_node*) โ€” the mapping node
  • fyn_key (struct fy_node*) โ€” the node to use as key

Description

This method will return the node pair that matches the provided fyn_key. The key may be collection and a content match check is performed recursively in order to find the right key. so it goes deep, recursively, until it finds its match โ€” obsessed ๐Ÿ’…

Return: The node value matching the given key, or NULL if not found. ๐Ÿซถ


๐ŸŒธ fy_node_mapping_lookup_key_by_key ๐ŸŒธ

struct fy_node *fy_node_mapping_lookup_key_by_key(struct fy_node *fyn, struct fy_node *fyn_key)

Parameters

  • fyn (struct fy_node*) โ€” The mapping node
  • fyn_key (struct fy_node*) โ€” The node to use as key

Description Okay so this one hunts down the node pair that matches the fyn_key you hand it. The key can be a collection, and a content-match check gets performed recursively to find the right key. Recursive key matching is giving main character energy fr.

Return The node key matching the given key, or NULL if not found.


โญ fy_node_mapping_get_pair_index โญ

int fy_node_mapping_get_pair_index(struct fy_node *fyn, const struct fy_node_pair *fynp)

Parameters

  • fyn (struct fy_node*) โ€” The mapping node
  • fynp (const struct fy_node_pair*) โ€” The node pair

Description Returns the node pair index in the mapping for the node pair you passed in. If it canโ€™t find it, you get -1, no cap. ๐Ÿ’…

Return The index of the node pair in the mapping or -1 in case of an error.


๐ŸŽ€ fy_node_pair_key ๐ŸŽ€

struct fy_node *fy_node_pair_key(struct fy_node_pair *fynp)

Parameters

  • fynp (struct fy_node_pair*) โ€” The node pair

Description Grabs the node pairโ€™s key. Heads up bestie: this can be NULL, and it also returns NULL when the node pair argument itself is NULL, so protect against that case. ๐Ÿซถ

Return The node pair key


๐Ÿฆ‹ fy_node_pair_value ๐Ÿฆ‹

struct fy_node *fy_node_pair_value(struct fy_node_pair *fynp)

Parameters

  • fynp (struct fy_node_pair*) โ€” The node pair

Description Grabs the node pairโ€™s value. Same warning as its key twin: this may be NULL, and itโ€™s also returned when the node pair argument is NULL, so please protect against that case.

Return The node pair value


๐Ÿ”ฅ fy_node_pair_set_key ๐Ÿ”ฅ

int fy_node_pair_set_key(struct fy_node_pair *fynp, struct fy_node *fyn)

Parameters

  • fynp (struct fy_node_pair*) โ€” The node pair
  • fyn (struct fy_node*) โ€” The key node

Description Sets the key part of the node pair. It overwrites any previous key. Note that no checks for duplicate keys are going to be performed โ€” so if youโ€™re out here making dupes, thatโ€™s on you. ๐Ÿ’€

Return 0 on success, -1 on error


๐Ÿ’œ fy_node_pair_set_value ๐Ÿ’œ

int fy_node_pair_set_value(struct fy_node_pair *fynp, struct fy_node *fyn)

Parameters

  • fynp (struct fy_node_pair*) โ€” The node pair
  • fyn (struct fy_node*) โ€” The value node

Description Sets the value part of the node pair. It overwrites any previous value. Simple, clean, iconic.

Return 0 on success, -1 on error


โœจ fy_node_mapping_append โœจ

int fy_node_mapping_append(struct fy_node *fyn_map, struct fy_node *fyn_key, struct fy_node *fyn_value)

Parameters

  • fyn_map (struct fy_node*) โ€” The mapping node
  • fyn_key (struct fy_node*) โ€” The node pairโ€™s key
  • fyn_value (struct fy_node*) โ€” The node pairโ€™s value

Description Appends a node pair to a mapping. Adding to the end of the mapping lineup, periodt.

Return 0 on success, -1 on error


๐ŸŒˆ fy_node_mapping_prepend ๐ŸŒˆ

int fy_node_mapping_prepend(struct fy_node *fyn_map, struct fy_node *fyn_key, struct fy_node *fyn_value)

Parameters

  • fyn_map (struct fy_node*) โ€” The mapping node
  • fyn_key (struct fy_node*) โ€” The node pairโ€™s key
  • fyn_value (struct fy_node*) โ€” The node pairโ€™s value

Description Prepends a node pair to a mapping. Itโ€™s giving โ€œfront of the lineโ€ behavior. ๐Ÿ‘‘

Return 0 on success, -1 on error


๐Ÿงš fy_node_mapping_remove ๐Ÿงš

int fy_node_mapping_remove(struct fy_node *fyn_map, struct fy_node_pair *fynp)

Parameters

  • fyn_map (struct fy_node*) โ€” The mapping node
  • fynp (struct fy_node_pair*) โ€” The node pair to remove

Description Removes the node pair from a mapping. Bye bestie ๐Ÿ‘‹

Return 0 on success, -1 on failure.


๐ŸŒธ fy_node_mapping_sort ๐ŸŒธ

int fy_node_mapping_sort(struct fy_node *fyn_map, fy_node_mapping_sort_fn key_cmp, void *arg)

Parameters

  • fyn_map (struct fy_node*) โ€” The mapping node to sort
  • key_cmp (fy_node_mapping_sort_fn) โ€” The comparison method
  • arg (void*) โ€” An opaque user pointer for the comparison method

Description Sorts the keys of a single mapping node using the comparison method you pass. If key_cmp is NULL, it uses the default one. Unlike fy_node_sort(), this does not recurse into child nodes โ€” it stays in its lane. ๐Ÿ’…

Return 0 on success, -1 on error


๐Ÿ“ fy_node_mapping_remove_by_key ๐Ÿ“

struct fy_node *fy_node_mapping_remove_by_key(struct fy_node *fyn_map, struct fy_node *fyn_key)

Parameters

  • fyn_map (struct fy_node*) โ€” The mapping node
  • fyn_key (struct fy_node*) โ€” The node pairโ€™s key

Description Removes the node pair from the mapping using the supplied key. Itโ€™s a remove-and-return-the-value situation.

Return The value part of the removed node pair, or NULL in case of an error.


๐Ÿฆ‹ fy_node_sort ๐Ÿฆ‹

int fy_node_sort(struct fy_node *fyn, fy_node_mapping_sort_fn key_cmp, void *arg)

Parameters

  • fyn (struct fy_node*) โ€” The node to sort
  • key_cmp (fy_node_mapping_sort_fn) โ€” The comparison method
  • arg (void*) โ€” An opaque user pointer for the comparison method

Description Recursively sorts all mappings of the given node, using the comparison method you pass โ€” and if thatโ€™s NULL, the default one. This one does go down into the child nodes, bestie. Recursive sorting ate. ๐Ÿ”ฅ

Return 0 on success, -1 on error


๐Ÿ’– fy_node_vscanf ๐Ÿ’–

int fy_node_vscanf(struct fy_node *fyn, const char *fmt, va_list ap)

Parameters

  • fyn (struct fy_node*) โ€” The node to use as a pathspec root
  • fmt (const char*) โ€” The scanf based format string
  • ap (va_list) โ€” The va_list containing the arguments

Description This method easily retrieves data using a familiar vscanf interface. The format string is a regular scanf format string with this format:

โ€œpathspec opt pathspec optโ€ฆโ€

Each pathspec is separated with space from the scanf option.

For example

fyn = { foo: 3 } -> fy_node_scanf(fyn, โ€œ/foo dโ€œ, struct var) -> var = 3

Return The number of scanned arguments, or -1 on error.


๐ŸŒŸ fy_node_scanf ๐ŸŒŸ

int fy_node_scanf(struct fy_node *fyn, const char *fmt, ...)

Parameters

  • fyn (struct fy_node*) โ€” The node to use as a pathspec root
  • fmt (const char*) โ€” The scanf based format string
  • ellipsis (ellipsis) โ€” The arguments

Description This method easily retrieves data using a familiar vscanf interface. The format string is a regular scanf format string with this format:

โ€œpathspec opt pathspec optโ€ฆโ€

Each pathspec is separated with space from the scanf option.

For example

fyn = { foo: 3 } -> fy_node_scanf(fyn, โ€œ/foo dโ€œ, struct var) -> var = 3

Return The number of scanned arguments, or -1 on error.


๐ŸŽ€ fy_document_vscanf ๐ŸŽ€

int fy_document_vscanf(struct fy_document *fyd, const char *fmt, va_list ap)

Parameters

  • fyd (struct fy_document*) โ€” The document
  • fmt (const char*) โ€” The scanf based format string
  • ap (va_list) โ€” The va_list containing the arguments

Description This method easily retrieves data using a familiar vscanf interface. The format string is a regular scanf format string with this format:

โ€œpathspec opt pathspec optโ€ฆโ€

Each pathspec is separated with space from the scanf option.

For example

fyd = { foo: 3 } -> fy_document_scanf(fyd, โ€œ/foo dโ€œ, struct var) -> var = 3

Return The number of scanned arguments, or -1 on error.


๐Ÿซถ fy_document_scanf ๐Ÿซถ

int fy_document_scanf(struct fy_document *fyd, const char *fmt, ...)

Parameters

  • fyd (struct fy_document*) โ€” The document
  • fmt (const char*) โ€” The scanf based format string
  • ellipsis (ellipsis) โ€” The arguments

Description This method easily retrieves data using a familiar vscanf interface. The format string is a regular scanf format string with this format:

โ€œpathspec opt pathspec optโ€ฆโ€

Each pathspec is separated with space from the scanf option.

For example

fyn = { foo: 3 } -> fy_node_scanf(fyd, โ€œ/foo dโ€œ, struct var) -> var = 3

Return The number of scanned arguments, or -1 on error.


๐Ÿงš fy_document_tag_directive_iterate ๐Ÿงš

struct fy_token *fy_document_tag_directive_iterate(struct fy_document *fyd, void **prevp)

Parameters

  • fyd (struct fy_document*) โ€” The document
  • prevp (void**) โ€” The previous state of the iterator

Description This method iterates over all the documentโ€™s tag directives. The start of the iteration is signalled by a NULL in *prevp. Itโ€™s a little iterator situation, very demure.

Return The next tag directive token in the document or NULL at the end of them.


๐Ÿ’œ fy_document_tag_directive_lookup ๐Ÿ’œ

struct fy_token *fy_document_tag_directive_lookup(struct fy_document *fyd, const char *handle)

Parameters

  • fyd (struct fy_document*) โ€” The document
  • handle (const char*) โ€” The handle to look for

Description Retrieves the matching tag directive token of the document that matches the handle.

Return The tag directive token with the given handle or NULL if not found


๐ŸŒธ fy_tag_directive_token_handle ๐ŸŒธ

const char *fy_tag_directive_token_handle(struct fy_token *fyt, size_t *lenp)

Parameters

  • fyt (struct fy_token*) โ€” The tag directive token
  • lenp (size_t*) โ€” Pointer to a variable that will hold the returned length

Description

Bestie, this one retrieves the tag directive token's handle value. It's only valid on tag directive tokens, okay? Don't try it on anything else. ๐Ÿ’…

Return

You get a pointer to the tag directive's handle, and lenp gets assigned the length of that handle. If something goes wrong, you get a NULL back. ๐Ÿ˜ญ


fy_tag_directive_token_prefix

const char *fy_tag_directive_token_prefix(struct fy_token *fyt, size_t *lenp)

Get a tag directive prefix โœจ

Parameters

  • fyt (struct fy_token*) โ€“ The tag directive token.
  • lenp (size_t*) โ€“ Pointer to a variable that will hold the returned length.

Description

This one retrieves the tag directive token's prefix value. Again, only valid on tag directive tokens! ๐ŸŽ€

Return

You get a pointer to the tag directive's prefix, and lenp gets assigned the length of that prefix. A NULL comes back if there's an error. ๐Ÿ™ˆ


fy_document_tag_directive_add

int fy_document_tag_directive_add(struct fy_document *fyd, const char *handle, const char *prefix)

Add a tag directive to a document ๐ŸŽ€

Parameters

  • fyd (struct fy_document*) โ€“ The document.
  • handle (const char*) โ€“ The handle of the tag directive.
  • prefix (const char*) โ€“ The prefix of the tag directive.

Description

Adds a tag directive to the document. Slay. โœจ

Return

0 on success, -1 on error.


fy_document_tag_directive_remove

int fy_document_tag_directive_remove(struct fy_document *fyd, const char *handle)

Remove a tag directive ๐Ÿ’€

Parameters

  • fyd (struct fy_document*) โ€“ The document.
  • handle (const char*) โ€“ The handle of the tag directive to remove.

Description

Removes a tag directive from a document. But bestie, removal is prohibited if any node is still using this tag directive. Don't even try it. ๐Ÿšซ

Return

0 on success, -1 on error.


fy_document_lookup_anchor

struct fy_anchor *fy_document_lookup_anchor(struct fy_document *fyd, const char *anchor, size_t len)

Lookup an anchor ๐Ÿ”

Parameters

  • fyd (struct fy_document*) โ€“ The document.
  • anchor (const char*) โ€“ The anchor to look for.
  • len (size_t) โ€“ The length of the anchor (or -1 if '0' terminated).

Description

Looks for an anchor having the name you provided. It's giving detective energy. ๐Ÿ•ต๏ธโ€โ™€๏ธ

Return

The anchor if found, NULL otherwise.


fy_document_lookup_anchor_by_token

struct fy_anchor *fy_document_lookup_anchor_by_token(struct fy_document *fyd, struct fy_token *anchor)

Lookup an anchor by token text ๐Ÿ”

Parameters

  • fyd (struct fy_document*) โ€“ The document.
  • anchor (struct fy_token*) โ€“ The token contains the anchor text to look for.

Description

Looks for an anchor having the name provided from the text of the token. Token vibes. ๐ŸŽŸ๏ธ

Return

The anchor if found, NULL otherwise.


fy_document_lookup_anchor_by_node

struct fy_anchor *fy_document_lookup_anchor_by_node(struct fy_document *fyd, struct fy_node *fyn)

Lookup an anchor by node ๐Ÿ”

Parameters

  • fyd (struct fy_document*) โ€“ The document.
  • fyn (struct fy_node*) โ€“ The node.

Description

Looks for an anchor located in the given node. Node-based search, iykyk. ๐ŸŒณ

Return

The anchor if found, NULL otherwise.


fy_anchor_get_text

const char *fy_anchor_get_text(struct fy_anchor *fya, size_t *lenp)

Get the text of an anchor ๐Ÿ“

Parameters

  • fya (struct fy_anchor*) โ€“ The anchor.
  • lenp (size_t*) โ€“ Pointer to a variable that will hold the returned length.

Description

This method returns a pointer to the text of an anchor along with the length of it. Note: this text is not NULL terminated. So don't treat it like a C string, bestie. ๐Ÿ™…โ€โ™€๏ธ

Return

A pointer to the text of the anchor, while lenp will be assigned the length of said anchor. A NULL will be returned in case of an error.


fy_anchor_node

struct fy_node *fy_anchor_node(struct fy_anchor *fya)

Get the node of an anchor ๐ŸŒณ

Parameters

  • fya (struct fy_anchor*) โ€“ The anchor.

Description

This method returns the node associated with the anchor. Simple. โœจ

Return

The node of the anchor, or NULL in case of an error.


fy_document_anchor_iterate

struct fy_anchor *fy_document_anchor_iterate(struct fy_document *fyd, void **prevp)

Iterate over a document's anchors ๐Ÿ”

Parameters

  • fyd (struct fy_document*) โ€“ The document.
  • prevp (void**) โ€“ The previous state of the iterator.

Description

This method iterates over all the document's anchors. The start of the iteration is signalled by a NULL in *prevp. So set *prevp to NULL to begin. ๐Ÿšฆ

Return

The next anchor in the document or NULL at the end of them.


fy_document_set_anchor

int fy_document_set_anchor(struct fy_document *fyd, struct fy_node *fyn, const char *text, size_t len)

Place an anchor โš“

Parameters

  • fyd (struct fy_document*) โ€“ The document.
  • fyn (struct fy_node*) โ€“ The node to set the anchor to.
  • text (const char*) โ€“ Pointer to the anchor text.
  • len (size_t) โ€“ Size of the anchor text, or (size_t)-1 for '0' terminated.

Description

Places an anchor to the node with the given text name.

Note: the data are not copied, merely a reference is taken, so it must be available while the node is in use. Don't let it go out of scope! ๐Ÿ˜ฌ

Also note that this method is deprecated; use fy_node_set_anchor() instead. Periodt. ๐Ÿ’…

Return

0 on success, -1 on error.


fy_node_set_anchor

int fy_node_set_anchor(struct fy_node *fyn, const char *text, size_t len)

Place an anchor to the node โš“

Parameters

  • fyn (struct fy_node*) โ€“ The node to set the anchor to.
  • text (const char*) โ€“ Pointer to the anchor text.
  • len (size_t) โ€“ Size of the anchor text, or (size_t)-1 for '0' terminated.

Description

Places an anchor to the node with the given text name.

Note: the data are not copied, merely a reference is taken, so it must be available while the node is in use. Same warning as before. โš ๏ธ

This is similar to fy_document_set_anchor() with the document set to the document of the fyn node. So it's the glow-up version. โœจ

Return

0 on success, -1 on error.


fy_node_set_anchor_copy

int fy_node_set_anchor_copy(struct fy_node *fyn, const char *text, size_t len)

Place an anchor to the node copying the text ๐Ÿ“‹

Parameters

  • fyn (struct fy_node*) โ€“ The node to set the anchor to.
  • text (const char*) โ€“ Pointer to the anchor text.
  • len (size_t) โ€“ Size of the anchor text, or (size_t)-1 for '0' terminated.

Description

Places an anchor to the node with the given text name, which will be copied, so it's safe to dispose the text after the call. No take-backs, it's yours now. ๐Ÿซถ

Return

0 on success, -1 on error.


fy_node_set_vanchorf

int fy_node_set_vanchorf(struct fy_node *fyn, const char *fmt, va_list ap)

Place an anchor to the node using a vprintf interface ๐Ÿ–จ๏ธ

Parameters

  • fyn (struct fy_node*) โ€“ The node to set the anchor to.
  • fmt (const char*) โ€“ Pointer to the anchor format string.
  • ap (va_list) โ€“ The argument list.

Description

Places an anchor to the node with the given text name as created via vprintf'ing the arguments. So you can format it all fancy. ๐Ÿ’…

Return

0 on success, -1 on error.


fy_node_set_anchorf

int fy_node_set_anchorf(struct fy_node *fyn, const char *fmt, ...)

Place an anchor to the node using a printf interface ๐Ÿ–จ๏ธ

Parameters

  • fyn (struct fy_node*) โ€“ The node to set the anchor to.
  • fmt (const char*) โ€“ Pointer to the anchor format string.
  • ellipsis (ellipsis) โ€“ The extra arguments.

Description

Places an anchor to the node with the given text name as created via printf'ing the arguments. Variadic vibes. โœจ

Return

0 on success, -1 on error.


fy_node_remove_anchor

int fy_node_remove_anchor(struct fy_node *fyn)

Remove an anchor ๐Ÿ’€

Parameters

  • fyn (struct fy_node*) โ€“ The node to remove anchors from.

Description

Removes an anchor for the given node (if it exists). If it doesn't exist, no biggie. ๐Ÿคทโ€โ™€๏ธ

Return

0 on success, -1 on error.


fy_node_get_anchor

struct fy_anchor *fy_node_get_anchor(struct fy_node *fyn)

Get the anchor of a node ๐Ÿ”

Parameters

  • fyn (struct fy_node*) โ€“ The node.

Description

Retrieves the anchor of the given node (if it exists). It's giving "do you have a moment to talk about our lord and savior, the anchor?" ๐Ÿ˜‡

Return

The anchor if there's one at the node, or NULL otherwise.


fy_node_get_nearest_anchor

struct fy_anchor *fy_node_get_nearest_anchor(struct fy_node *fyn)

Get the nearest anchor of the node ๐Ÿงญ

Parameters

  • fyn (struct fy_node*) โ€“ The node.

Description

Retrieves the anchor of the nearest parent of the given node or the given node if it has one. So it climbs up the tree until it finds an anchor. ๐ŸŒณโฌ†๏ธ

Return

The nearest anchor if there's one, or NULL otherwise.


fy_node_get_nearest_child_of

struct fy_node *fy_node_get_nearest_child_of(struct fy_node *fyn_base, struct fy_node *fyn)

Get the nearest node which is a child of the base ๐Ÿงฌ

Parameters

  • fyn_base (struct fy_node*) โ€“ The base node.
  • fyn (struct fy_node*) โ€“ The node to start from.

Description

Retrieves the nearest node which is a child of fyn_base starting at fyn and working upwards. So you're climbing the tree from fyn up until you find a node that is a child of fyn_base. Family reunion vibes. ๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ

Return

The nearest child of the base if there's one, or NULL otherwise.


fy_node_create_alias

struct fy_node *fy_node_create_alias(struct fy_document *fyd, const char *alias, size_t len)

Create an alias node ๐ŸŽญ

Parameters

  • fyd (struct fy_document*) โ€“ The document.
  • alias (const char*) โ€“ The alias text.
  • len (size_t) โ€“ The length of the alias (or -1 if '0' terminated).

Description

Creates an alias on the given document.

Note: the data are not copied, merely a reference is taken, so it must be available while the node is in use. Same warning again, bestie. ๐Ÿซ 

Return

The created alias node, or NULL in case of an error.


fy_node_create_alias_copy

struct fy_node *fy_node_create_alias_copy(struct fy_document *fyd, const char *alias, size_t len)

Create an alias node copying the data ๐Ÿ“‹

Parameters

  • fyd (struct fy_document*) โ€“ The document.
  • alias (const char*) โ€“ The alias text.
  • len (size_t) โ€“ The length of the alias (or -1 if '0' terminated).

Description

Creates an alias on the given document. (This one copies the data, so you don't have to worry about lifetime.) ๐Ÿซถ

Okay okay, picking up mid-thought because we love a seamless transition: a copy of the data will be made, so it is safe to free the data after the call. The return value? The created alias node, or NULL in case of an error. No cap. ๐Ÿ’…


fy_node_get_meta

void *fy_node_get_meta(struct fy_node *fyn)

Get the meta pointer of a node. Bestie, it literally does what it says on the tin. ๐ŸŽ€

Parameters:

  • fyn (struct fy_node*) โ€” The node to get meta data from

Description:

Return the meta pointer of a node.

Return:

The stored meta data pointer. Slay.


fy_node_set_meta

int fy_node_set_meta(struct fy_node *fyn, void *meta)

Set the meta pointer of a node. Very demure, very mindful pointer assignment. โœจ

Parameters:

  • fyn (struct fy_node*) โ€” The node to set meta data
  • meta (void*) โ€” The meta data pointer

Description:

Set the meta pointer of a node. If meta is NULL then clear the meta data. Thatโ€™s the vibe check: NULL means wipe it. ๐Ÿซถ

Return:

0 on success, -1 on error.


fy_node_clear_meta

void fy_node_clear_meta(struct fy_node *fyn)

Clear the meta data of a node. Poof, gone, iconic. ๐Ÿ’จ

Parameters:

  • fyn (struct fy_node*) โ€” The node to clear meta data

Description:

Clears the meta data of a node.


typedef fy_node_meta_clear_fn

void fy_node_meta_clear_fn(struct fy_node *fyn, void *meta, void *user)

Meta data clear method. This is the callback energy we need. ๐ŸŒธ

Parameters:

  • fyn (struct fy_node*) โ€” The node which the meta data is being cleared
  • meta (void*) โ€” The meta data of the node assigned via fy_node_set_meta()
  • user (void*) โ€” The user pointer of fy_document_register_meta()

Description:

This is the callback called when meta data are cleared. Yep, itโ€™s giving cleanup crew. ๐Ÿงน


fy_document_register_meta

int fy_document_register_meta(struct fy_document *fyd,
                              fy_node_meta_clear_fn clear_fn,
                              void *user)

Register a meta cleanup hook. Very official. Very โ€œIโ€™ve got your back when the node gets freed.โ€ ๐Ÿ‘‘

Parameters:

  • fyd (struct fy_document*) โ€” The document which the hook is registered to
  • clear_fn (fy_node_meta_clear_fn) โ€” The clear hook method
  • user (void*) โ€” Opaque user provided pointer to the clear method

Description:

Register a meta data cleanup hook, to be called when the node is freed via a final call to fy_node_free(). The hook is active for all nodes belonging to the document. So like, every node in the doc gets the same energy. ๐ŸŒˆ

Return:

0 on success, -1 if another hook is already registered. One hook at a time, bestie โ€” weโ€™re not running a circus. ๐ŸŽช


fy_document_unregister_meta

void fy_document_unregister_meta(struct fy_document *fyd)

Unregister a meta cleanup hook. Bye-bye, hook. ๐Ÿ’…

Parameters:

  • fyd (struct fy_document*) โ€” The document to unregister itโ€™s meta cleanup hook.

Description:

Unregister the currently active meta cleanup hook. The previous cleanup hook will be called for every node in the document. That part matters โ€” the old hook still gets its moment. ๐ŸŽฌ


fy_node_set_marker

bool fy_node_set_marker(struct fy_node *fyn, unsigned int marker)

Set a marker of a node. Marking your territory, but make it YAML. ๐Ÿ–๏ธ

Parameters:

  • fyn (struct fy_node*) โ€” The node
  • marker (unsigned int) โ€” The marker to set

Description:

Sets the marker of the given node, while returning the previous state of the marker. Note that the markers use the same space as the node follow markers. Important detail, donโ€™t forget it. โญ

Return:

The previous value of the marker.


fy_node_clear_marker

bool fy_node_clear_marker(struct fy_node *fyn, unsigned int marker)

Clear a marker of a node. Un-marking, but still returning the old state because weโ€™re thorough. ๐Ÿฆ‹

Parameters:

  • fyn (struct fy_node*) โ€” The node
  • marker (unsigned int) โ€” The marker to clear

Description:

Clears the marker of the given node, while returning the previous state of the marker. Note that the markers use the same space as the node follow markers. Same rule, same space. ๐Ÿซถ

Return:

The previous value of the marker.


fy_node_is_marker_set

bool fy_node_is_marker_set(struct fy_node *fyn, unsigned int marker)

Checks whether a marker is set. The vibe check for markers. ๐Ÿ”

Parameters:

  • fyn (struct fy_node*) โ€” The node
  • marker (unsigned int) โ€” The marker index (must be less that FYNWF_MAX_USER_MARKER)

Description:

Check the state of the given marker.

Return:

The value of the marker (invalid markers return false). So if you pass nonsense, itโ€™s a no from the marker. ๐Ÿ’€


fy_node_vreport

void fy_node_vreport(struct fy_node *fyn, enum fy_error_type type,
                     const char *fmt, va_list ap)

Report about a node vprintf style. Diagnostic drama, but make it formatted. ๐Ÿ˜ญ

Parameters:

  • fyn (struct fy_node*) โ€” The node
  • type (enum fy_error_type) โ€” The error type
  • fmt (const char*) โ€” The printf format string
  • ap (va_list) โ€” The argument list

Description:

Output a report about the given node via the specific error type, and using the reporting configuration of the nodeโ€™s document. Itโ€™s giving structured complaints. ๐Ÿ“ข


fy_node_report

void fy_node_report(struct fy_node *fyn, enum fy_error_type type,
                    const char *fmt, ...)

Report about a node printf style. Same energy, but with the ... varargs flex. โœจ

Parameters:

  • fyn (struct fy_node*) โ€” The node
  • type (enum fy_error_type) โ€” The error type
  • fmt (const char*) โ€” The printf format string
  • ellipsis (ellipsis) โ€” The extra arguments.

Description:

Output a report about the given node via the specific error type, and using the reporting configuration of the nodeโ€™s document.


fy_node_override_vreport

void fy_node_override_vreport(struct fy_node *fyn, enum fy_error_type type,
                              const char *file, int line, int column,
                              const char *fmt, va_list ap)

Report about a node vprintf style, overriding file, line and column info. Custom location, custom chaos. ๐Ÿ—บ๏ธ

Parameters:

  • fyn (struct fy_node*) โ€” The node
  • type (enum fy_error_type) โ€” The error type
  • file (const char*) โ€” The file override
  • line (int) โ€” The line override
  • column (int) โ€” The column override
  • fmt (const char*) โ€” The printf format string
  • ap (va_list) โ€” The argument list

Description:

Output a report about the given node via the specific error type, and using the reporting configuration of the nodeโ€™s document. This method will use the overrides provided in order to massage the reporting information. If file is NULL, no file location will be reported. If either line or column is negative no location will be reported. So negative numbers mean โ€œlocation? never heard of her.โ€ ๐Ÿ™ˆ


fy_node_override_report

void fy_node_override_report(struct fy_node *fyn, enum fy_error_type type,
                             const char *file, int line, int column,
                             const char *fmt, ...)

Report about a node printf style, overriding file, line and column info. The varargs version of โ€œmake the location say what I want.โ€ ๐Ÿ’…

Parameters:

  • fyn (struct fy_node*) โ€” The node
  • type (enum fy_error_type) โ€” The error type
  • file (const char*) โ€” The file override
  • line (int) โ€” The line override
  • column (int) โ€” The column override
  • fmt (const char*) โ€” The printf format string
  • ellipsis (ellipsis) โ€” The extra arguments.

Description:

Output a report about the given node via the specific error type, and using the reporting configuration of the nodeโ€™s document. This method will use the overrides provided in order to massage the reporting information. If file is NULL, no file location will be reported. If either line or column is negative no location will be reported. Same rules, same dramatic reporting energy. ๐Ÿ”ฅ


fy_event_vreport

void fy_event_vreport(struct fy_parser *fyp, struct fy_event *fye,
                      enum fy_event_part fyep, enum fy_error_type type,
                      const char *fmt, va_list ap)

Report about an event vprintf style. Event gossip, but official. ๐Ÿ‘€

Parameters:

  • fyp (struct fy_parser*) โ€” The parser of which the event was generated from
  • fye (struct fy_event*) โ€” The event
  • fyep (enum fy_event_part) โ€” The event part which the report is about
  • type (enum fy_error_type) โ€” The error type
  • fmt (const char*) โ€” The printf format string
  • ap (va_list) โ€” The argument list

Description:

Output a report about the given event via the specific error type, focusing at the given event part. Focused. Intentional. Iconic. ๐ŸŽฏ


fy_event_report

void fy_event_report(struct fy_parser *fyp, struct fy_event *fye,
                     enum fy_event_part fyep, enum fy_error_type type,
                     const char *fmt, ...)

Report about an event printf style. Now with extra arguments and main character energy. ๐ŸŒŸ

Parameters:

  • fyp (struct fy_parser*) โ€” The parser of which the event was generated from
  • fye (struct fy_event*) โ€” The event
  • fyep (enum fy_event_part) โ€” The event part which the report is about
  • type (enum fy_error_type) โ€” The error type
  • fmt (const char*) โ€” The printf format string
  • ellipsis (ellipsis) โ€” The extra arguments.

Description:

Output a report about the given event via the specific error type, focusing at the given event part. Same focus, same event, just printf style. ๐Ÿ’–


struct fy_diag_cfg

struct fy_diag_cfg

The diagnostics configuration. This is the control room for how diagnostics look and behave. ๐ŸŽ›๏ธ

Definition:

struct fy_diag_cfg {
    FILE *fp;
    fy_diag_output_fn output_fn;
    void *user;
    enum fy_error_type level;
    unsigned int module_mask;
    bool colorize : 1;
    bool show_source : 1;
    bool show_position : 1;
    bool show_type : 1;
    bool show_module : 1;
    int source_width;
    int position_width;
    int type_width;
    int module_width;
}

Members:

  • fp โ€” File descriptor of the error output
  • output_fn โ€” Callback to use when fp is NULL
  • user โ€” User pointer to pass to the output_fn
  • level โ€” The minimum debugging level
  • module_mask โ€” A bitmask of the enabled modules
  • colorize โ€” true if output should be colorized using ANSI sequences
  • show_source โ€” true if source location should be displayed
  • show_position โ€” true if position should be displayed
  • show_type โ€” true if the type should be displayed
  • show_module โ€” true if the module should be displayed
  • source_width โ€” Width of the source field
  • position_width โ€” Width of the position field
  • type_width โ€” Width of the type field
  • module_width โ€” Width of the module field

Description:

This structure contains the configuration of the diagnostic object. Basically the settings screen for your diagnostics. ๐ŸŽ€


struct fy_diag_error

struct fy_diag_error

A collected diagnostic error. Yes, an error that got collected. We love a documented problem. ๐Ÿ“

Definition

struct fy_diag_error {
    enum fy_error_type type;
    enum fy_error_module module;
    struct fy_token *fyt;
    const char *msg;
    const char *file;
    int line;
    int column;
}

Members

  • type โ€” the error type, bestie โœจ
  • module โ€” which module it came from
  • fyt โ€” the token, and yes it might be NULL so pls check ๐Ÿซถ
  • msg โ€” the message that gets output right alongside it
  • file โ€” the file that held the input
  • line โ€” the line where the error is sitting
  • column โ€” the column where the error is sitting

Description

Okay so this struct is literally just a little info packet about an error that the diagnostic object is collecting. That's it, that's the vibe ๐Ÿ’…


fy_diag_create

struct fy_diag *fy_diag_create(const struct fy_diag_cfg *cfg)

Create a diagnostic object, iconic behaviour honestly ๐Ÿ‘‘

Parameters

  • cfg (const struct fy_diag_cfg*) โ€” the configuration for the diagnostic object (NULL is default)

Description

Makes you a diagnostic object using the config you handed over.

Return

A pointer to the diagnostic object, or NULL if something went wrong ๐Ÿ˜ญ


fy_diag_destroy

void fy_diag_destroy(struct fy_diag *diag)

Destroy a diagnostic object.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object to destroy

Description

Destroys a diagnostic object โ€” but heads up, the actual destruction only happens once there are no more references left to it. However, no output will be generated after this call. So it's giving "I'm leaving the group chat but I'm still lurking" ๐Ÿ’€


fy_diag_get_cfg

const struct fy_diag_cfg *fy_diag_get_cfg(struct fy_diag *diag)

Get a diagnostic object's configuration.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object

Description

Returns the current configuration of a diagnostic object.

Return

A const pointer to the diagnostic object configuration, or NULL in the case where diag is NULL.


fy_diag_set_cfg

void fy_diag_set_cfg(struct fy_diag *diag, const struct fy_diag_cfg *cfg)

Set a diagnostic object's configuration.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object
  • cfg (const struct fy_diag_cfg*) โ€” the diagnostic configuration

Description

Swaps out the current diagnostic config for the one you passed in. Out with the old, in with the new ๐Ÿฆ‹


fy_diag_set_level

void fy_diag_set_level(struct fy_diag *diag, enum fy_error_type level)

Set a diagnostic object's debug error level.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object
  • level (enum fy_error_type) โ€” the debugging level to set

fy_diag_set_colorize

void fy_diag_set_colorize(struct fy_diag *diag, bool colorize)

Set a diagnostic object's colorize option โœจ๐ŸŒˆ

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object
  • colorize (bool) โ€” the colorize option

fy_diag_ref

struct fy_diag *fy_diag_ref(struct fy_diag *diag)

Increment the reference counter of a diagnostic object.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object to reference

Description

Increments the reference. Keeping it alive, holding space for it ๐Ÿซถ

Return

Always returns the diag argument โ€” it literally hands it right back to you.


fy_diag_unref

void fy_diag_unref(struct fy_diag *diag)

Take away a ref from a diagnostic object.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object to unref

Description

Takes away a reference, and if it hits 0, the diagnostic object gets freed. Last one out, turn off the lights ๐Ÿ’…


fy_diag_got_error

bool fy_diag_got_error(struct fy_diag *diag)

Test whether an error level diagnostic has been produced.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object

Description

Tests whether an error diagnostic has been produced. Like a vibe check but for errors.

Return

true if an error has been produced, false otherwise.


fy_diag_set_error

void fy_diag_set_error(struct fy_diag *diag, bool on_error)

Sets the error produced state.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object
  • on_error (bool) โ€” the set error state

Description

Sets the error produced state. Yeah, it says it twice, I'm just relaying the message fr fr.


fy_diag_reset_error

void fy_diag_reset_error(struct fy_diag *diag)

Reset the error flag of the diagnostic object.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object

Description

Clears the error flag that got set by an output of an error level diagnostic. Fresh start energy ๐ŸŒธ


fy_diag_set_collect_errors

void fy_diag_set_collect_errors(struct fy_diag *diag, bool collect_errors)

Collect errors instead of outputting.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object
  • collect_errors (bool) โ€” the collect errors mode

Description

Sets the collect errors mode. When it's true, instead of outputting to the diagnostic interface, the errors get collected so you can come back for them later. Little error scrapbook, iykyk ๐ŸŽ€


fy_diag_get_collect_errors

bool fy_diag_get_collect_errors(struct fy_diag *diag)

Get collect errors state.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object

Description

Gets the collect errors mode.

Return

true if it's collecting errors, false otherwise.


fy_diag_cfg_default

void fy_diag_cfg_default(struct fy_diag_cfg *cfg)

Fill in the configuration structure with defaults โญ

Parameters

  • cfg (struct fy_diag_cfg*) โ€” the diagnostic configuration structure

Description

Fills the configuration structure with defaults. The default always associates the file descriptor to stderr โ€” that's just how it is, no notes.


fy_diag_cfg_from_parser_flags

void fy_diag_cfg_from_parser_flags(struct fy_diag_cfg *cfg, enum fy_parse_cfg_flags pflags)

Fill partial diagnostic config structure from parser config flags.

Parameters

  • cfg (struct fy_diag_cfg*) โ€” the diagnostic configuration structure
  • pflags (enum fy_parse_cfg_flags) โ€” the parser flags

Description

Fills in part of the configuration structure using parser flags. Since the parser flags do not contain debugging flags anymore, this method is deprecated โ€” it's giving legacy era, don't @ me ๐Ÿ™ˆ


fy_diag_vprintf

int fy_diag_vprintf(struct fy_diag *diag, const char *fmt, va_list ap)

vprintf raw interface to diagnostics.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object to use
  • fmt (const char*) โ€” the vprintf format string
  • ap (va_list) โ€” the arguments

Description

Raw output to the diagnostic object using a standard vprintf interface. Note that this is the lowest level interface, and as such is not recommended for use, since no formatting or coloring will take place. You're rawdogging the output, essentially ๐Ÿ’€

Return

The number of characters output, or -1 in case of an error. Note that 0 shall be returned if the diagnostic object has been destroyed but not yet freed.


fy_diag_printf

int fy_diag_printf(struct fy_diag *diag, const char *fmt, ...)

printf raw interface to diagnostics.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object to use
  • fmt (const char*) โ€” the printf format string
  • ellipsis (ellipsis) โ€” the arguments

Description

Raw output to the diagnostic object using a standard printf interface. Same warning as its vprintf sibling: this is the lowest level interface, so it's not recommended, since no formatting or coloring will take place.

Return

The number of characters output, or -1 in case of an error. Note that 0 shall be returned if the diagnostic object has been destroyed but not yet freed.


struct fy_diag_ctx

struct fy_diag_ctx

The diagnostics context. It's giving main character context packet ๐Ÿ‘‘

Definition

struct fy_diag_ctx {
    enum fy_error_type level;
    enum fy_error_module module;
    const char *source_func;
    const char *source_file;
    int source_line;
    const char *file;
    int line;
    int column;
}

Members

  • level โ€” the level of the diagnostic
  • module โ€” the module of the diagnostic
  • source_func โ€” the source function
  • source_file โ€” the source file
  • source_line โ€” the source line
  • file โ€” the file that caused the error
  • line โ€” the line where the diagnostic occured
  • column โ€” the column where the diagnostic occured

Description

This structure contains the diagnostic context. That's the whole lore ๐ŸŒธ


fy_vdiag

int fy_vdiag(struct fy_diag *diag, const struct fy_diag_ctx *fydc, const char *fmt, va_list ap)

Context aware diagnostic output, like vprintf.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object to use
  • fydc (const struct fy_diag_ctx*) โ€” the diagnostic context
  • fmt (const char*) โ€” the vprintf format string
  • ap (va_list) โ€” the arguments

Description

Context aware output to the diagnostic object using a standard vprintf interface. Now with โœจcontextโœจ.

Return

The number of characters output, or -1 in case of an error. Note that 0 shall be returned if the diagnostic object has been destroyed but not yet freed.


fy_diagf

int fy_diagf(struct fy_diag *diag, const struct fy_diag_ctx *fydc, const char *fmt, ...)

Context aware diagnostic output, like printf.

Parameters

  • diag (struct fy_diag*) โ€” the diagnostic object to use
  • fydc (const struct fy_diag_ctx*) โ€” the diagnostic context
  • fmt (const char*) โ€” the vprintf format string
  • ellipsis (ellipsis) โ€” variable arguments

Description

Context aware output to the diagnostic object using a standard printf interface.

Return

The number of characters output, or -1 in case of an error. Note that 0 shall be returned if the diagnostic object has been destroyed but not yet freed.


fy_diag_token_vreport

void fy_diag_token_vreport(struct fy_diag *diag, struct fy_token *fyt, enum fy_error_type type, const char *fmt, va_list ap)

Report about a token, vprintf style, using the given diagnostic object ๐Ÿ”ฅ

Parameters

  • diag (struct fy_diag*) โ€” the diag object
  • fyt (struct fy_token*) โ€” the token
  • type (enum fy_error_type) โ€” the error type
  • fmt (const char*) โ€” the printf format string
  • ap (va_list) โ€” the argument list

Description

Outputs a report about the given token via the specific error type, and using the reporting configuration of the token's document. It's a whole relay situation โ€” the token's document calls the shots ๐ŸŽ€

fy_diag_token_report

void fy_diag_token_report(struct fy_diag *diag, struct fy_token *fye,
       enum fy_error_type type, const char *fmt, ...)

okay so this one is literally just "tell me about this token, printf style" ๐ŸŽ€ it reports about a token using the diag object you hand it.

Parameters

  • diag (struct fy_diag *) โ€” the diag object, your reporter bestie
  • fye (struct fy_token *) โ€” the token in question
  • type (enum fy_error_type) โ€” the error type
  • fmt (const char *) โ€” the printf format string
  • ellipsis (ellipsis) โ€” the extra arguments

Description

Outputs a report about the given token via the specific error type, and uses the reporting configuration of the token's document ๐Ÿ’… so the token's doc decides how it gets dressed up.


fy_diag_token_override_vreport

void fy_diag_token_override_vreport(struct fy_diag *diag, struct
       fy_token *fyt, enum fy_error_type type, const char *file, int line, int
       column, const char *fmt, va_list ap)

the va_list twin of the override-y token reporter โœจ vprintf style, and it lets you override the file, line and column info.

Parameters

  • diag (struct fy_diag *) โ€” the diag object
  • fyt (struct fy_token *) โ€” the token
  • type (enum fy_error_type) โ€” the error type
  • file (const char *) โ€” the file override
  • line (int) โ€” the line override
  • column (int) โ€” the column override
  • fmt (const char *) โ€” the printf format string
  • ap (va_list) โ€” the argument list

Description

Outputs a report about the given token via the specific error type, using the reporting configuration of the token's document. This method uses the overrides you provide in order to massage the reporting information ๐Ÿซถ

fr fr: if file is NULL, no file location will be reported. And if either line or column is negative, no location will be reported either. no cap.

fy_diag_token_override_report

void fy_diag_token_override_report(struct fy_diag *diag, struct fy_token
       *fyt, enum fy_error_type type, const char *file, int line, int column,
       const char *fmt, ...)

same energy as the last one but printf style with an ellipsis instead of a va_list ๐Ÿ’–

Parameters

  • diag (struct fy_diag *) โ€” the diag object
  • fyt (struct fy_token *) โ€” the token
  • type (enum fy_error_type) โ€” the error type
  • file (const char *) โ€” the file override
  • line (int) โ€” the line override
  • column (int) โ€” the column override
  • fmt (const char *) โ€” the printf format string
  • ellipsis (ellipsis) โ€” the extra arguments

Description

Outputs a report about the given token via the specific error type, and uses the reporting configuration of the token's document. This method will use the overrides provided in order to massage the reporting information.

again, because it matters: file being NULL means no file location gets reported, and a negative line or column means no location gets reported. iconic consistency ๐ŸŒธ

fy_diag_node_vreport

void fy_diag_node_vreport(struct fy_diag *diag, struct fy_node *fyn,
       enum fy_error_type type, const char *fmt, va_list ap)

token who? we're on nodes now ๐Ÿฆ‹ report about a node, vprintf style.

Parameters

  • diag (struct fy_diag *) โ€” the diag object
  • fyn (struct fy_node *) โ€” the node
  • type (enum fy_error_type) โ€” the error type
  • fmt (const char *) โ€” the printf format string
  • ap (va_list) โ€” the argument list

Description

Outputs a report about the given node via the specific error type, and uses the reporting configuration of the node's document ๐Ÿ’œ


fy_diag_node_report

void fy_diag_node_report(struct fy_diag *diag, struct fy_node *fyn, enum
       fy_error_type type, const char *fmt, ...)

the printf version for nodes, and yes she ate ๐Ÿ’…

Parameters

  • diag (struct fy_diag *) โ€” the diag object
  • fyn (struct fy_node *) โ€” the node
  • type (enum fy_error_type) โ€” the error type
  • fmt (const char *) โ€” the printf format string
  • ellipsis (ellipsis) โ€” the extra arguments

Description

Outputs a report about the given node via the specific error type, and uses the reporting configuration of the node's document โœจ


fy_diag_node_override_vreport

void fy_diag_node_override_vreport(struct fy_diag *diag, struct fy_node
       *fyn, enum fy_error_type type, const char *file, int line, int column,
       const char *fmt, va_list ap)

node report, vprintf style, but with the file/line/column glow-up overrides ๐ŸŽ€

Parameters

  • diag (struct fy_diag *) โ€” the diag object
  • fyn (struct fy_node *) โ€” the node
  • type (enum fy_error_type) โ€” the error type
  • file (const char *) โ€” the file override
  • line (int) โ€” the line override
  • column (int) โ€” the column override
  • fmt (const char *) โ€” the printf format string
  • ap (va_list) โ€” the argument list

Description

Outputs a report about the given node via the specific error type, and uses the reporting configuration of the node's document. This method will use the overrides provided in order to massage the reporting information.

bestie, remember the rule: file NULL โ†’ no file location reported. line or column negative โ†’ no location reported. periodt ๐Ÿ’€

fy_diag_node_override_report

void fy_diag_node_override_report(struct fy_diag *diag, struct fy_node
       *fyn, enum fy_error_type type, const char *file, int line, int column,
       const char *fmt, ...)

and the printf-style version of the node override reporter, completing the set ๐Ÿ”ฅ

Parameters

  • diag (struct fy_diag *) โ€” the diag object
  • fyn (struct fy_node *) โ€” the node
  • type (enum fy_error_type) โ€” the error type
  • file (const char *) โ€” the file override
  • line (int) โ€” the line override
  • column (int) โ€” the column override
  • fmt (const char *) โ€” the printf format string
  • ellipsis (ellipsis) โ€” the extra arguments

Description

Outputs a report about the given node via the specific error type, and uses the reporting configuration of the node's document. This method will use the overrides provided in order to massage the reporting information.

file is NULL โ†’ no file location reported. Negative line or column โ†’ no location reported. same as her sisters ๐Ÿซถ

fy_diag_event_vreport

void fy_diag_event_vreport(struct fy_diag *diag, struct fy_event *fye,
       enum fy_event_part fyep, enum fy_error_type type, const char *fmt,
       va_list ap)

events have entered the chat ๐Ÿ˜ญ vprintf style, and note the extra fyep โ€” you're reporting about a specific event part not the whole event.

Parameters

  • diag (struct fy_diag *) โ€” the diag object
  • fye (struct fy_event *) โ€” the event
  • fyep (enum fy_event_part) โ€” the event part
  • type (enum fy_error_type) โ€” the error type
  • fmt (const char *) โ€” the printf format string
  • ap (va_list) โ€” the argument list

Description

Outputs a report about the given event part via the specific error type โญ


fy_diag_event_report

void fy_diag_event_report(struct fy_diag *diag, struct fy_event *fye,
       enum fy_event_part fyep, enum fy_error_type type, const char *fmt, ...)

the printf-style event-part reporter, same trio of vibes, different signature ๐Ÿ’–

Parameters

  • diag (struct fy_diag *) โ€” the diag object
  • fye (struct fy_event *) โ€” the event
  • fyep (enum fy_event_part) โ€” the event part
  • type (enum fy_error_type) โ€” the error type
  • fmt (const char *) โ€” the printf format string
  • ellipsis (ellipsis) โ€” the extra arguments

Description

Outputs a report about the given event part via the specific error type ๐ŸŒˆ


fy_diag_errors_iterate

struct fy_diag_error *fy_diag_errors_iterate(struct fy_diag *diag, void
       **prevp)

okay this one's a little iterator icon ๐Ÿ‘‘ it walks over the errors of a diagnostic object.

Parameters

  • diag (struct fy_diag *) โ€” the diagnostic object
  • prevp (void **) โ€” the previous result iterator

Description

This method iterates over all the errors collected on the diagnostic object. The start of the iteration is signalled by a NULL in *prevp โ€” that's your "go" signal, no cap ๐Ÿ’…

Return

The next errors, or NULL when there are not any more ๐ŸŽ€


fy_parser_checkpoint_create

struct fy_parser_checkpoint *fy_parser_checkpoint_create(struct
       fy_parser *fyp)

save point!! ๐ŸŽฎ this creates a checkpoint of the parser's current state, so you can stash where you're at and potentially roll back to it later using fy_parser_rollback(). it's giving "quicksave before the boss fight" energy fr fr.

important: the checkpoint must be destroyed via fy_parser_checkpoint_destroy() when it's no longer needed. don't just leave it lying around ๐Ÿ™ˆ

Parameters

  • fyp (struct fy_parser *) โ€” the parser

Return

A pointer to the checkpoint, or NULL in case of an error ๐Ÿ˜ญ


fy_parser_checkpoint_destroy

void fy_parser_checkpoint_destroy(struct fy_parser_checkpoint *fypchk)

the cleanup crew ๐Ÿงน destroys a checkpoint you created earlier via fy_parser_checkpoint_create().

Parameters

  • fypchk (struct fy_parser_checkpoint *) โ€” the checkpoint to destroy

Description

Destroys a checkpoint created earlier via fy_parser_checkpoint_create() โœจ


fy_parser_rollback

int fy_parser_rollback(struct fy_parser *fyp, struct
       fy_parser_checkpoint *fypc)

the actual rewind button โช rolls the parser state back to a previously created checkpoint, so you can revert to an earlier state and re-parse from that point.

the checkpoint remains valid after rollback ๐Ÿซถ so you can use it again, or destroy it via fy_parser_checkpoint_destroy(). reusable, we love to see it.

Parameters

  • fyp (struct fy_parser *) โ€” the parser
  • fypc (struct fy_parser_checkpoint *) โ€” the checkpoint to roll back to

Return

0 on success, -1 on error ๐Ÿ’€


enum fy_token_type

enum fy_token_type

Token types ๐ŸŽ€ โ€” the roster of what a token can be.

Definition

okay bestie, this is the big enum that holds every token type fyaml knows about โ€” YAML tokens, path-expression (YPATH) tokens, scalar-expression tokens, all of it. yes, it's long. no, we're not skipping any. every single one gets its moment ๐Ÿ’…

enum fy_token_type {
    FYTT_NONE,
    FYTT_STREAM_START,
    FYTT_STREAM_END,
    FYTT_VERSION_DIRECTIVE,
    FYTT_TAG_DIRECTIVE,
    FYTT_DOCUMENT_START,
    FYTT_DOCUMENT_END,
    FYTT_BLOCK_SEQUENCE_START,
    FYTT_BLOCK_MAPPING_START,
    FYTT_BLOCK_END,
    FYTT_FLOW_SEQUENCE_START,
    FYTT_FLOW_SEQUENCE_END,
    FYTT_FLOW_MAPPING_START,
    FYTT_FLOW_MAPPING_END,
    FYTT_BLOCK_ENTRY,
    FYTT_FLOW_ENTRY,
    FYTT_KEY,
    FYTT_VALUE,
    FYTT_ALIAS,
    FYTT_ANCHOR,
    FYTT_TAG,
    FYTT_SCALAR,
    FYTT_INPUT_MARKER,
    FYTT_PE_SLASH,
    FYTT_PE_ROOT,
    FYTT_PE_THIS,
    FYTT_PE_PARENT,
    FYTT_PE_MAP_KEY,
    FYTT_PE_SEQ_INDEX,
    FYTT_PE_SEQ_SLICE,
    FYTT_PE_SCALAR_FILTER,
    FYTT_PE_COLLECTION_FILTER,
    FYTT_PE_SEQ_FILTER,
    FYTT_PE_MAP_FILTER,
    FYTT_PE_UNIQUE_FILTER,
    FYTT_PE_EVERY_CHILD,
    FYTT_PE_EVERY_CHILD_R,
    FYTT_PE_ALIAS,
    FYTT_PE_SIBLING,
    FYTT_PE_COMMA,
    FYTT_PE_BARBAR,
    FYTT_PE_AMPAMP,
    FYTT_PE_LPAREN,
    FYTT_PE_RPAREN,
    FYTT_PE_EQEQ,
    FYTT_PE_NOTEQ,
    FYTT_PE_LT,
    FYTT_PE_GT,
    FYTT_PE_LTE,
    FYTT_PE_GTE,
    FYTT_SE_PLUS,
    FYTT_SE_MINUS,
    FYTT_SE_MULT,
    FYTT_SE_DIV,
    FYTT_PE_METHOD,
    FYTT_SE_METHOD,
    FYTT_PE_BANG,
    FYTT_PE_AT
};

Constants

welcome to the token zoo ๐Ÿฆ‹ โ€” every resident gets a lil intro, no cap:

  • FYTT_NONE โ€” no token. the void. the "there is literally nothing here" token ๐Ÿ’€
  • FYTT_STREAM_START โ€” stream start token โœจ
  • FYTT_STREAM_END โ€” stream end token, the wrap-up ๐ŸŽ€
  • FYTT_VERSION_DIRECTIVE โ€” version directive token
  • FYTT_TAG_DIRECTIVE โ€” tag directive token
  • FYTT_DOCUMENT_START โ€” document start token, main character energy ๐Ÿ‘‘
  • FYTT_DOCUMENT_END โ€” document end token
  • FYTT_BLOCK_SEQUENCE_START โ€” block sequence start token
  • FYTT_BLOCK_MAPPING_START โ€” block mapping start token
  • FYTT_BLOCK_END โ€” block end token
  • FYTT_FLOW_SEQUENCE_START โ€” flow sequence start token
  • FYTT_FLOW_SEQUENCE_END โ€” flow sequence end token
  • FYTT_FLOW_MAPPING_START โ€” flow mapping start token
  • FYTT_FLOW_MAPPING_END โ€” flow mapping end token
  • FYTT_BLOCK_ENTRY โ€” block entry token
  • FYTT_FLOW_ENTRY โ€” flow entry token
  • FYTT_KEY โ€” key token ๐Ÿ”‘
  • FYTT_VALUE โ€” value token
  • FYTT_ALIAS โ€” alias token
  • FYTT_ANCHOR โ€” anchor token โš“
  • FYTT_TAG โ€” tag token
  • FYTT_SCALAR โ€” scalar token
  • FYTT_INPUT_MARKER โ€” input marker token
  • FYTT_PE_SLASH โ€” path expression slash token
  • FYTT_PE_ROOT โ€” path expression root token
  • FYTT_PE_THIS โ€” path expression this token
  • FYTT_PE_PARENT โ€” path expression parent token
  • FYTT_PE_MAP_KEY โ€” path expression map key token
  • FYTT_PE_SEQ_INDEX โ€” path expression sequence index token
  • FYTT_PE_SEQ_SLICE โ€” path expression sequence slice token
  • FYTT_PE_SCALAR_FILTER โ€” path expression scalar filter token
  • FYTT_PE_COLLECTION_FILTER โ€” path expression collection filter token
  • FYTT_PE_SEQ_FILTER โ€” path expression sequence filter token
  • FYTT_PE_MAP_FILTER โ€” path expression map filter token
  • FYTT_PE_UNIQUE_FILTER โ€” path expression unique filter token
  • FYTT_PE_EVERY_CHILD โ€” path expression every child token
  • FYTT_PE_EVERY_CHILD_R โ€” path expression every child recursive token
  • FYTT_PE_ALIAS โ€” path expression alias token
  • FYTT_PE_SIBLING โ€” path expression sibling token
  • FYTT_PE_COMMA โ€” path expression , token
  • FYTT_PE_BARBAR โ€” path expression || token
  • FYTT_PE_AMPAMP โ€” path expression && token
  • FYTT_PE_LPAREN โ€” path expression ( token
  • FYTT_PE_RPAREN โ€” path expression ) token
  • FYTT_PE_EQEQ โ€” path expression == token
  • FYTT_PE_NOTEQ โ€” path expression != token
  • FYTT_PE_LT โ€” path expression < token
  • FYTT_PE_GT โ€” path expression > token
  • FYTT_PE_LTE โ€” path expression <= token
  • FYTT_PE_GTE โ€” path expression >= token
  • FYTT_SE_PLUS โ€” scalar expression + token
  • FYTT_SE_MINUS โ€” scalar expression - token
  • FYTT_SE_MULT โ€” scalar expression * token
  • FYTT_SE_DIV โ€” scalar expression / token
  • FYTT_PE_METHOD โ€” path expression method token
  • FYTT_SE_METHOD โ€” scalar expression method token
  • FYTT_PE_BANG โ€” path expression ! token
  • FYTT_PE_AT โ€” path expression @ token

fy_token_type_is_valid

bool fy_token_type_is_valid(enum fy_token_type type)

so this one does a vibe check on a token type โ€” is it even valid, yes or no? ๐Ÿซถ

Parameters

  • type (enum fy_token_type) โ€” the token type in question

Description

literally just checks whether the token type you handed it is a valid one.

Return

true if the token type is valid, false otherwise.


fy_token_type_is_yaml

bool fy_token_type_is_yaml(enum fy_token_type type)

same energy, but the question is "is this a YAML token type?" ๐ŸŒธ

Parameters

  • type (enum fy_token_type) โ€” the token type

Description

checks if the thing you passed in is a valid YAML token type.

Return

true if the token type is a valid YAML one, false otherwise.


fy_token_type_is_content

bool fy_token_type_is_content(enum fy_token_type type)

and now: is it a content token type? iykyk โœจ

Parameters

  • type (enum fy_token_type) โ€” the token type

Description

checks if the token type is a valid YAML content one.

Return

true if the token type is a valid YAML content one, false otherwise.


fy_token_type_is_path_expr

bool fy_token_type_is_path_expr(enum fy_token_type type)

YPATH check incoming ๐Ÿฆ‹

Parameters

  • type (enum fy_token_type) โ€” the token type

Description

checks if the token type is a valid YPATH parse expression token.

Return

true if the token type is a valid YPATH one, false otherwise.


fy_token_type_is_scalar_expr

bool fy_token_type_is_scalar_expr(enum fy_token_type type)

same but for the scalar-expression side of YPATH ๐Ÿ’œ

Parameters

  • type (enum fy_token_type) โ€” the token type

Description

checks if the token type is a valid YPATH parse scalar expression token.

Return

true if the token type is a valid YPATH scalar one, false otherwise.


fy_token_get_type

enum fy_token_type fy_token_get_type(struct fy_token *fyt)

gimme the type, bestie ๐Ÿ‘€

Parameters

  • fyt (struct fy_token *) โ€” the token

Description

returns the token's type โ€” and if it's NULL, you get FYTT_NONE back. no crash, no drama, just the void token ๐Ÿ’€

Return

the token's type; FYTT_NONE if it's not a valid token (or it's NULL).


fy_token_start_mark

const struct fy_mark *fy_token_start_mark(struct fy_token *fyt)

where does this token start? ๐Ÿ“

Parameters

  • fyt (struct fy_token *) โ€” the token to get its start marker

Description

returns the token's start marker if it exists. and ngl, it is permissible for some token types to have no start marker, because they're without content. so don't come for it if you get NULL ๐ŸŽ€

Return

the token's start marker, NULL if not available.


fy_token_end_mark

const struct fy_mark *fy_token_end_mark(struct fy_token *fyt)

and where does it end? ๐Ÿ“

Parameters

  • fyt (struct fy_token *) โ€” the token to get its end marker

Description

returns the token's end marker if it exists. same deal as before: it is permissible for some token types to have no end marker because they're without content.

Return

the token's end marker, NULL if not available.


fy_token_style_start_mark

const struct fy_mark *fy_token_style_start_mark(struct fy_token *fyt)

this one is the start marker with style โ€” it includes the style indicators ๐Ÿ’…

Parameters

  • fyt (struct fy_token *) โ€” the token to get its style start marker

Description

returns the token's start marker if it exists, including the style indicators. and yeah, again, it's permissible for some token types to have no start marker because they're without content.

Return

the token's style start marker, NULL if not available.


fy_token_style_end_mark

const struct fy_mark *fy_token_style_end_mark(struct fy_token *fyt)

the matching style end marker โ€” the other half of the fit โœจ

Parameters

  • fyt (struct fy_token *) โ€” the token to get its style end marker

Description

returns the token's end marker if it exists, including the style indicators. and once more for the people in the back: it's permissible for some token types to have no end marker because they're without content.

Return

the token's style end marker, NULL if not available.


fy_scan

struct fy_token *fy_scan(struct fy_parser *fyp)

okay this one is low key iconic โ€” it's the raw scanner door ๐Ÿ”ฅ

Parameters

  • fyp (struct fy_parser *) โ€” the parser to get the next token from

Description

returns the next scanner token. heads up though: this is a very low level interface โ€” it's meant for users who want or need to implement their own YAML parser. so if that's not you, bestie, maybe step back ๐Ÿ˜ญ

โš ๏ธ the token you get back is expected to be disposed of using fy_scan_token_free(). do not just leave it lying around.

Return

the next token, or NULL if there are no more tokens available.


fy_scan_token_free

void fy_scan_token_free(struct fy_parser *fyp, struct fy_token *fyt)

clean up your mess ๐Ÿ’– (respectfully)

Parameters

  • fyp (struct fy_parser *) โ€” the parser of which the token was returned by fy_scan()
  • fyt (struct fy_token *) โ€” the token to free

Description

frees the token that came back from fy_scan(). that's it, that's the whole job ๐Ÿซถ


fy_tag_directive_token_prefix0

const char *fy_tag_directive_token_prefix0(struct fy_token *fyt)

grab the tag directive prefix as a nice zero-terminated string ๐ŸŽ€

Parameters

  • fyt (struct fy_token *) โ€” the tag directive token out of which the prefix pointer will be returned

Description

pulls out the tag directive's prefix contents as a zero terminated string. it's similar to fy_tag_directive_token_prefix(), except the string you get back is zero terminated โ€” and memory may be allocated to hold it, associated with the token. so it's the โœจglowed-upโœจ version.

Return

a pointer to the zero terminated text representation of the prefix token. NULL in case of an error. ๐Ÿ™ˆ

fy_tag_directive_token_handle0

const char *fy_tag_directive_token_handle0(struct fy_token *fyt)

Get the handle chillin' inside a tag directive token, but make it a zero terminated string โœจ

Parameters

  • fyt (struct fy_token*) โ€“ the tag directive token you're pulling the handle pointer out of.

Description

Okay so this one grabs the tag directive's handle contents and hands them to you as a zero terminated string ๐Ÿ’…. It's basically fy_tag_directive_token_handle()'s sibling โ€” the difference being that what comes back is zero terminated, and memory may get allocated to hold it, and that memory is associated with the token. So like, it's the same vibe but null-safe at the end, iykyk.

Return

A pointer to the zero terminated text representation of the handle token ๐ŸŽ€. NULL if something went wrong.


fy_tag_token_handle

const char *fy_tag_token_handle(struct fy_token *fyt, size_t *lenp)

Get the handle that's inside a tag token ๐Ÿท๏ธ

Parameters

  • fyt (struct fy_token*) โ€“ the tag token the handle pointer comes out of.
  • lenp (size_t*) โ€“ pointer to a variable that'll hold the returned length.

Description

Retrieves the tag handle contents fr fr. It will fail if the token isn't actually a tag token, or if a memory error happens ๐Ÿ˜ญ. No cap, those are the two ways it goes sideways.

Return

A pointer to the text representation of the handle token, and lenp gets assigned the character length of said representation. NULL if there's an error.


fy_tag_token_suffix

const char *fy_tag_token_suffix(struct fy_token *fyt, size_t *lenp)

Get the suffix out of a tag token ๐Ÿ’–

Parameters

  • fyt (struct fy_token*) โ€“ the tag token you're grabbing the suffix pointer from.
  • lenp (size_t*) โ€“ pointer to a variable that'll hold the returned length.

Description

Retrieves the tag suffix contents โœจ. Fails if the token isn't a tag token, or if a memory error decides to show up ๐Ÿ˜ญ.

Return

A pointer to the text representation of the suffix token, with lenp assigned the character length of that representation. NULL in case of an error.


fy_tag_token_short

const char *fy_tag_token_short(struct fy_token *fyt, size_t *lenp)

Get the short tag of a tag token, bestie ๐ŸŽ€

Parameters

  • fyt (struct fy_token*) โ€“ the tag token the short pointer comes out of.
  • lenp (size_t*) โ€“ pointer to a variable that'll hold the returned length.

Description

Retrieves the short tag contents. And like โ€” the short tag is literally the same one you'll need to emit, so it's giving main character energy ๐Ÿ”ฅ. Fails if the token isn't a tag token, or if a memory error happens.

Return

A pointer to the text representation of the short tag, and lenp gets the character length of that representation. NULL in case of an error.


fy_tag_token_handle0

const char *fy_tag_token_handle0(struct fy_token *fyt)

Get the handle inside a tag token, zero terminated edition ๐ŸŒธ

Parameters

  • fyt (struct fy_token*) โ€“ the tag token from which the handle pointer will be returned.

Description

Retrieves the tag handle contents as a zero terminated string ๐Ÿ’œ. It's similar to fy_tag_token_handle(), except the returned string is zero terminated and memory may be allocated to hold it, associated with the token. Same energy, just null-terminated at the end, slay.

Return

A pointer to the zero terminated text representation of the handle token. NULL in case of an error.


fy_tag_token_short0

const char *fy_tag_token_short0(struct fy_token *fyt)

Get the short tag of a tag token as a zero terminated string ๐Ÿฆ‹

Parameters

  • fyt (struct fy_token*) โ€“ the tag token the short pointer comes out of.

Description

Retrieves the short tag contents โ€” and again, the short tag is the exact same one that needs to be emitted ๐Ÿ‘‘. Will fail if the token isn't a tag token, or if a memory error happens.

Return

A pointer to the null terminated text representation of the short tag. NULL in case of an error.


fy_tag_token_suffix0

const char *fy_tag_token_suffix0(struct fy_token *fyt)

Get the suffix inside a tag token as a zero terminated string ๐Ÿ“

Parameters

  • fyt (struct fy_token*) โ€“ the tag token the suffix pointer comes out of.

Description

Retrieves the tag suffix contents as a zero terminated string โœจ. Just like fy_tag_token_suffix(), except โ€” you guessed it โ€” the returned string is zero terminated and memory may be allocated to hold it, associated with the token. Consistent queen behavior.

Return

A pointer to the zero terminated text representation of the suffix token. NULL in case of an error.


fy_version_directive_token_version

const struct fy_version *fy_version_directive_token_version(struct fy_token *fyt)

Return the version of a version directive token ๐ŸŒˆ

Parameters

  • fyt (struct fy_token*) โ€“ the version directive token.

Description

Retrieves the version stored in a version directive token. Simple as that, no notes ๐Ÿ’….

Return

A pointer to the version stored in the version directive token, or NULL if there's an error, or if the token isn't a version directive token. (Rude, but fair.)


fy_scalar_token_get_style

enum fy_scalar_style fy_scalar_token_get_style(struct fy_token *fyt)

Return the style of a scalar token ๐ŸŽ€

Parameters

  • fyt (struct fy_token*) โ€“ the scalar token.

Description

Retrieves the style of a scalar token. That's the whole assignment โœจ.

Return

The scalar style of the token, or FYSS_ANY if there's an error. So yeah, FYSS_ANY is doing double duty as the error signal here โ€” just so you know ๐Ÿ’€.


fy_tag_token_tag

const struct fy_tag *fy_tag_token_tag(struct fy_token *fyt)

Get the tag of a tag token ๐Ÿท๏ธ

Parameters

  • fyt (struct fy_token*) โ€“ the tag token.

Description

Retrieves the tag of a tag token. Iconic, lowkey self-explanatory.

Return

A pointer to the tag, or NULL in case of an error.


fy_tag_directive_token_tag

const struct fy_tag *fy_tag_directive_token_tag(struct fy_token *fyt)

Get the tag of a tag directive token ๐Ÿ’–

Parameters

  • fyt (struct fy_token*) โ€“ the tag directive token.

Description

Retrieves the tag of a tag directive token. Same vibe, different token type ๐Ÿซถ.

Return

A pointer to the tag, or NULL in case of an error.


fy_event_get_token

struct fy_token *fy_event_get_token(struct fy_event *fye)

Return the main token of an event โญ

Parameters

  • fye (struct fy_event*) โ€“ the event you want the main token of.

Description

Retrieves the main token of an event โ€” and like, to be clear, that's the main token, not the tag or the anchor ๐Ÿ™ˆ. It may be NULL in the case of an implicit event.

Return

The main token if it exists, NULL otherwise or in case of an error.


fy_event_get_anchor_token

struct fy_token *fy_event_get_anchor_token(struct fy_event *fye)

Return the anchor token of an event ๐Ÿฆ‹

Parameters

  • fye (struct fy_event*) โ€“ the event you want the anchor token of.

Description

Retrieves the anchor token if it exists โœจ. Heads up bestie โ€” this is only valid for mapping/sequence start events and scalar events. Don't come for other event types, it's not giving.

Return

The anchor token if it exists, NULL otherwise or in case of an error.


fy_event_get_tag_token

struct fy_token *fy_event_get_tag_token(struct fy_event *fye)

Return the tag token of an event ๐ŸŽ€

Parameters

  • fye (struct fy_event*) โ€“ the event you want the tag token of.

Description

Retrieves the tag token if it exists. Same rule as the anchor one โ€” only valid for mapping/sequence start events and scalar events, got it? ๐Ÿ’…

Return

The tag token if it exists, NULL otherwise or in case of an error.


fy_event_start_mark

const struct fy_mark *fy_event_start_mark(struct fy_event *fye)

Get the event's start marker ๐Ÿ“

Parameters

  • fye (struct fy_event*) โ€“ the event you want the start marker of.

Description

Returns the event's start marker if it exists โœจ. The start marker is the one belonging to the event's main token, fyi.

Return

The event's start marker, NULL if it's not available.


fy_event_end_mark

const struct fy_mark *fy_event_end_mark(struct fy_event *fye)

Get the event's end marker ๐Ÿ“

Parameters

  • fye (struct fy_event*) โ€“ the event you want the end marker of.

Description

Returns the event's end marker if it exists ๐Ÿ’–. The end marker is the one belonging to the event's main token.

Return

The event's end marker, NULL if it's not available.


fy_event_style_start_mark

const struct fy_mark *fy_event_style_start_mark(struct fy_event *fye)

Get the event's start marker โ€” style edition ๐Ÿ’…

Parameters

  • fye (struct fy_event*) โ€“ the event you want the style start marker of.

Description

Returns the event's style start marker if it exists โœจ. The start marker is the one of the event's main token, including the style marks. But โ€” plot twist โ€” if the event contains a tag, then the start mark is the start of the tag token ๐Ÿ‘€. So it's giving slightly different energy depending on what's in the event.

Return

The event's start marker, NULL if it's not available.


fy_event_style_end_mark

const struct fy_mark *fy_event_style_end_mark(struct fy_event *fye)

Get the event's end marker โ€” style edition ๐ŸŽ€

Parameters

  • fye (struct fy_event*) โ€“ the event you want the end marker of.

Description

Returns the event's style end marker if it exists. The end marker is the one belonging to the event's main token ๐ŸŒธ.

Return

The event's end marker, NULL if it's not available.


fy_event_get_node_style

enum fy_node_style fy_event_get_node_style(struct fy_event *fye)

Get the node style of an event ๐Ÿฆ‹

Parameters

  • fye (struct fy_event*) โ€“ the event you want the node style of.

Description

Returns the node style (FYNS_*) of an event โœจ. It may return FYNS_ANY if the event is implicit. And, important detail: for collection start events, the only possible values are FYNS_ANY, FYNS_FLOW, and FYNS_BLOCK ๐Ÿ’…. A scalar event, on the other hand, may return any of them. So like, know your event type, bestie.

Return

Hmm โ€” the docs say this returns "the event's end marker, NULL if not available," which is lowkey a copy-paste glitch on their end ๐Ÿ˜ญ, but we're reporting it faithfully: that's what it says. (Editor's note: the text literally says "The event's end marker, NULL if not available.")


fy_document_start_event_version

const struct fy_version *fy_document_start_event_version(struct fy_event *fye)

Return the version of a document start event ๐Ÿซถ

Parameters

  • fye (struct fy_event*) โ€“ the document start event.

Description

Retrieves the version stored in a document start event โœจ.

Return

A pointer to the version, or NULL if there's an error, or if the event isn't a document start event.


fy_document_state_version

const struct fy_version *fy_document_state_version(struct fy_document_state *fyds)

Return the version of a document state object ๐Ÿ’œ

Parameters

  • fyds (struct fy_document_state*) โ€“ the document state object.

Description

Retrieves the version stored in a document state object. Yeah, that's it โ€” she's straightforward and we respect it ๐ŸŒธ.

Return

A pointer to the version, or NULL if something went sideways ๐Ÿ˜ญ


fy_document_state_start_mark

const struct fy_mark *fy_document_state_start_mark(struct fy_document_state *fyds)

Get the document state's start mark โœจ

Parameters

  • fyds (struct fy_document_state*) โ€” the document state object

Description

Returns the document state's start mark (if it even has one, bestie). Heads up: purely synthetic documents don't contain one, so don't come for me when you get NULL ๐Ÿ’…

Return

The document's start marker, or NULL if it's not available.


fy_document_state_end_mark

const struct fy_mark *fy_document_state_end_mark(struct fy_document_state *fyds)

Get the document state's end mark ๐ŸŽ€

Parameters

  • fyds (struct fy_document_state*) โ€” the document state object

Description

Returns the document state's end mark (if it exists). Same deal as before: purely synthetic documents do not contain one, no cap ๐Ÿซถ

Return

The document's end marker, or NULL if it's not available.


fy_document_state_version_explicit

bool fy_document_state_version_explicit(struct fy_document_state *fyds)

Was the version explicit? ๐Ÿ‘€

Parameters

  • fyds (struct fy_document_state*) โ€” the document state object

Description

Find out if a document state object's version was explicitly set in the document. Note that for synthetic documents this method returns false, periodt.

Return

true if the version was set explicitly, false otherwise


fy_document_state_tags_explicit

bool fy_document_state_tags_explicit(struct fy_document_state *fyds)

Were the tags explicit? ๐Ÿท๏ธ

Parameters

  • fyds (struct fy_document_state*) โ€” the document state object

Description

Find out if a document state object's tags were explicitly set in the document. And yeah, for synthetic documents this method returns false, iykyk.

Return

true if the document had tags set explicitly, false otherwise


fy_document_state_start_implicit

bool fy_document_state_start_implicit(struct fy_document_state *fyds)

Did it start implicitly? ๐ŸŒธ

Parameters

  • fyds (struct fy_document_state*) โ€” the document state object

Description

Find out if a document state object's document was started implicitly. Note that for synthetic documents this method returns false ๐Ÿ’œ

Return

true if the document was started implicitly, false otherwise


fy_document_state_end_implicit

bool fy_document_state_end_implicit(struct fy_document_state *fyds)

Did it end implicitly? ๐Ÿฆ‹

Parameters

  • fyds (struct fy_document_state*) โ€” the document state object

Description

Find out if a document state object's document was ended implicitly. Note that for synthetic documents this method returns false ๐Ÿ˜Œ

Return

true if the document was ended implicitly, false otherwise


fy_document_state_json_mode

bool fy_document_state_json_mode(struct fy_document_state *fyds)

Was the input JSON? ๐Ÿ”ฅ

Parameters

  • fyds (struct fy_document_state*) โ€” the document state object

Description

Find out if a document state object's document was created by a JSON input. Note that for synthetic documents this method returns false โ€” say it with me now ๐Ÿ“ฃ

Return

true if the document was created in JSON mode, false otherwise


fy_document_state_tag_directive_iterate

const struct fy_tag *fy_document_state_tag_directive_iterate(struct fy_document_state *fyds, void **prevp)

Iterate over the tag directives of a document state object ๐Ÿ”

Parameters

  • fyds (struct fy_document_state*) โ€” the document state
  • prevp (void**) โ€” the previous iterator

Description

This method iterates over all the tag directive nodes in the document state object. The start of the iteration is signalled by a NULL in *prevp ๐Ÿ’ซ

Return

The next tag, or NULL at the end of the iteration sequence.


fy_document_state_tag_directives

struct fy_tag **fy_document_state_tag_directives(struct fy_document_state *fyds)

Get all the tag directives in a malloc'ed array ๐Ÿงบ

Parameters

  • fyds (struct fy_document_state*) โ€” the document state

Description

Returns all the tag directives in a dynamically allocated area. Must be free()'d when you're not using it anymore โ€” like, actually free it, bestie, don't just vibe and forget ๐Ÿ™ˆ

Return

An array of fy_tag pointer structures, terminated with a NULL pointer, and NULL on error.


fy_document_state_tag_is_default

bool fy_document_state_tag_is_default(struct fy_document_state *fyds, const struct fy_tag *tag)

Test whether the given tag is a default one ๐ŸŽฏ

Parameters

  • fyds (struct fy_document_state*) โ€” the document state
  • tag (const struct fy_tag*) โ€” the tag to check

Description

Test whether a tag is a default (i.e. implicitly set) one.

Return

true if the tag is a default one, false otherwise


fy_parser_get_document_state

struct fy_document_state *fy_parser_get_document_state(struct fy_parser *fyp)

Get the document state of a parser object ๐Ÿ”

Parameters

  • fyp (struct fy_parser*) โ€” the parser

Description

Retrieves the document state object of a parser. Note that this is only valid during parsing โ€” like, only while the party's happening ๐ŸŽ‰

Return

The active document state object of the parser, NULL otherwise


fy_document_get_document_state

struct fy_document_state *fy_document_get_document_state(struct fy_document *fyd)

Get the document state of a document ๐Ÿ“„

Parameters

  • fyd (struct fy_document*) โ€” the document

Description

Retrieves the document state object of a document. Simple as that ๐Ÿ’…

Return

The document state object of the document, NULL otherwise


fy_document_set_document_state

int fy_document_set_document_state(struct fy_document *fyd, struct fy_document_state *fyds)

Set the document state of a document ๐Ÿ› ๏ธ

Parameters

  • fyd (struct fy_document*) โ€” the document
  • fyds (struct fy_document_state*) โ€” the document state to use, or NULL for default

Description

Sets the document state of a document. That's the whole gig ๐Ÿซก

Return

0 if the set operation was successful, -1 otherwise


fy_document_create_from_event

struct fy_document *fy_document_create_from_event(struct fy_parser *fyp, struct fy_event *fye)

Create an empty document using the event โœจ

Parameters

  • fyp (struct fy_parser*) โ€” the parser
  • fye (struct fy_event*) โ€” the event

Description

Create an empty document using the FYET_DOCUMENT_START event generated by the parser. Literally what it says ๐Ÿ‘‘

Return

The created empty document, or NULL on error.


fy_document_update_from_event

int fy_document_update_from_event(struct fy_document *fyd, struct fy_parser *fyp, struct fy_event *fye)

Update the document with the event ๐Ÿ”„

Parameters

  • fyd (struct fy_document*) โ€” the document
  • fyp (struct fy_parser*) โ€” the parser
  • fye (struct fy_event*) โ€” the event

Description

Update the document using the FYET_DOCUMENT_END event generated by the parser ๐ŸŒˆ

Return

0 on success, -1 on error


fy_node_create_from_event

struct fy_node *fy_node_create_from_event(struct fy_document *fyd, struct fy_parser *fyp, struct fy_event *fye)

Create a node using the event ๐ŸŒฑ

Parameters

  • fyd (struct fy_document*) โ€” the document
  • fyp (struct fy_parser*) โ€” the parser
  • fye (struct fy_event*) โ€” the event

Description

Create a new node using the supplied event. The allowed events are FYET_SCALAR, FYET_ALIAS, FYET_MAPPING_START & FYET_SEQUENCE_START โ€” anything else is a no ๐Ÿ’€

Return

The newly created node, or NULL on error


fy_node_update_from_event

int fy_node_update_from_event(struct fy_node *fyn, struct fy_parser *fyp, struct fy_event *fye)

Update a node using the event ๐Ÿงš

Parameters

  • fyn (struct fy_node*) โ€” the node
  • fyp (struct fy_parser*) โ€” the parser
  • fye (struct fy_event*) โ€” the event

Description

Update information of a node created using fy_node_create_from_event(). The allowed events are FYET_MAPPING_END & FYET_SEQUENCE_END ๐ŸŽ€

Return

0 on success, -1 on error


fy_node_pair_create_with_key

struct fy_node_pair *fy_node_pair_create_with_key(struct fy_document *fyd, struct fy_node *fyn_parent, struct fy_node *fyn)

Create a new node pair and set its key ๐Ÿ”‘

Parameters

  • fyd (struct fy_document*) โ€” the document
  • fyn_parent (struct fy_node*) โ€” the mapping
  • fyn (struct fy_node*) โ€” the node pair key

Description

Create a new node pair using the supplied fyn_parent mapping and fyn node as a key. Note that the nodes _must_ have been created by fy_node_create_from_event and they are not interchangeable with other node pair methods โ€” like, do not mix them, fr fr ๐Ÿ™…โ€โ™€๏ธ

The node pair will be added to the fyn_parent mapping with a subsequent call to fy_node_pair_update_with_value().

Return

The newly created node pair, or NULL on error


fy_node_pair_update_with_value

int fy_node_pair_update_with_value(struct fy_node_pair *fynp, struct fy_node *fyn)

Update a node pair with a value and add it to the parent mapping ๐Ÿ’–

Parameters

  • fynp (struct fy_node_pair*) โ€” the node pair
  • fyn (struct fy_node*) โ€” the node pair value

Description

Update the node pair with the given value and add it to the parent mapping. Note that the fyn node _must_ have been created by fy_node_create_from_event and the node pair created by fy_node_pair_create_with_key(). Do not intermix other node pair manipulation methods, bestie โ€” I'm begging ๐Ÿ˜ญ

Return

0 on success, -1 on error


fy_node_sequence_add_item

int fy_node_sequence_add_item(struct fy_node *fyn_parent, struct fy_node *fyn)

Add an item node to a sequence node ๐Ÿงต

Parameters

  • fyn_parent (struct fy_node*) โ€” the parent sequence node
  • fyn (struct fy_node*) โ€” the node pair item

Description

Add an item to the end of the sequence node fyn_parent. Note that the fyn_parent and fyn nodes _must_ have been created by fy_node_create_from_event. Do not intermix other sequence node manipulation methods โ€” same rule as before, no exceptions ๐Ÿ’…

Return

0 on success, -1 on error


fy_emitter_get_document_state

struct fy_document_state *fy_emitter_get_document_state(struct fy_emitter *emit)

Get the document state of an emitter object ๐Ÿ“ค

Parameters

  • emit (struct fy_emitter*) โ€” the emitter

Description โ€” Retrieve the document state object of an emitter. Note that this is only valid during emitting, bestie.

Return โ€” The active document state object of the emitter, NULL otherwise.

โš ๏ธ Emitting only. Outside that window? Not it. ๐Ÿ’€

fy_emit_event_create

struct fy_event *fy_emit_event_create(struct fy_emitter *emit, enum fy_event_type type, ...)

Create an emit event. โœจ

Parameters

  • emit (struct fy_emitter*) โ€” The emitter.
  • type (enum fy_event_type) โ€” The event type to create.
  • ellipsis (ellipsis) โ€” The optional extra arguments.

Description โ€” Create an emit event to pass to fy_emit_event(). The extra arguments differ according to the event to be created. So yeah, the varargs are giving โ€œchoose your own adventure,โ€ but with YAML event types. ๐ŸŽ€

The extra args go like this, depending on the event:

  • FYET_STREAM_START
    • None.
  • FYET_STREAM_END
    • None.
  • FYET_DOCUMENT_START
    • int implicit โ€” true if document start should be marked implicit, false if document start should not be marked implicit.
    • const struct fy_version *vers โ€” Pointer to version to use for the document, or NULL for default.
    • const struct fy_tag * const *tags โ€” Pointer to a NULL terminated array of tag pointers (like argv), NULL if no extra tags are to be used.
  • FYET_DOCUMENT_END
    • int implicit โ€” true if document end should be marked implicit, false if document end should not be marked implicit.
  • FYET_MAPPING_START
    • enum fy_node_style style โ€” Style of the mapping (one of FYNS_ANY, FYNS_BLOCK or FYNS_FLOW).
    • const char *anchor โ€” Anchor to place at the mapping, or NULL for none.
    • const char *tag โ€” Tag to place at the mapping, or NULL for none.
  • FYET_MAPPING_END
    • None.
  • FYET_SEQUENCE_START
    • enum fy_node_style style โ€” Style of the sequence (one of FYNS_ANY, FYNS_BLOCK or FYNS_FLOW).
    • const char *anchor โ€” Anchor to place at the sequence, or NULL for none.
    • const char *tag โ€” Tag to place at the sequence, or NULL for none.
  • FYET_SEQUENCE_END
    • None.
  • FYET_SCALAR
    • enum fy_scalar_style style โ€” Style of the scalar, any valid FYSS_* value. Note that certain styles may not be used according to the contents of the data.
    • const char *value โ€” Pointer to the scalar contents.
    • size_t len โ€” Length of the scalar contents, or FY_NT (-1) for strlen(value).
    • const char *anchor โ€” Anchor to place at the scalar, or NULL for none.
    • const char *tag โ€” Tag to place at the scalar, or NULL for none.
  • FYET_ALIAS
    • const char *value โ€” Pointer to the alias.

Return โ€” The created event or NULL in case of an error.


fy_emit_event_vcreate

struct fy_event *fy_emit_event_vcreate(struct fy_emitter *emit, enum fy_event_type type, va_list ap)

Create an emit event using varargs. ๐ŸŒธ

Parameters

  • emit (struct fy_emitter*) โ€” The emitter.
  • type (enum fy_event_type) โ€” The event type to create.
  • ap (va_list) โ€” The variable argument list pointer.

Description โ€” Create an emit event to pass to fy_emit_event(). The varargs are analogous to fy_emit_event_create(). Same energy, just handed a va_list. ๐Ÿซถ

Return โ€” The created event or NULL in case of an error.


fy_emit_event_free

void fy_emit_event_free(struct fy_emitter *emit, struct fy_event *fye)

Free an event created via fy_emit_event_create(). ๐Ÿงน

Parameters

  • emit (struct fy_emitter*) โ€” The emitter.
  • fye (struct fy_event*) โ€” The event to free.

Description โ€” Free an event previously created via fy_emit_event_create(). Note that usually you donโ€™t have to call this method since if you pass the event to fy_emit_event() it shall be disposed properly. Its only use is error recovery and cleanup. So like, donโ€™t make freeing your whole personality โ€” itโ€™s an emergency-cleanup kind of function. ๐Ÿ’…


fy_parse_event_create

struct fy_event *fy_parse_event_create(struct fy_parser *fyp, enum fy_event_type type, ...)

Create an emit event. Yes, thatโ€™s literally the one-liner. ๐Ÿ‘‘

Parameters

  • fyp (struct fy_parser*) โ€” The parser.
  • type (enum fy_event_type) โ€” The event type to create.
  • ellipsis (ellipsis) โ€” variable arguments.

Description โ€” See fy_emit_event_create()โ€ฆ ๐Ÿ‘€

Return โ€” The created event or NULL in case of an error.


fy_parse_event_vcreate

struct fy_event *fy_parse_event_vcreate(struct fy_parser *fyp, enum fy_event_type type, va_list ap)

Create an emit event using varargs. โญ

Parameters

  • fyp (struct fy_parser*) โ€” The parser.
  • type (enum fy_event_type) โ€” The event type to create.
  • ap (va_list) โ€” The variable argument list pointer.

Description โ€” Create an emit event to pass to fy_emit_event(). The varargs are analogous to fy_parse_event_create(). ๐Ÿฆ‹

Return โ€” The created event or NULL in case of an error.

๐ŸŒธ PATH EXECUTION ๐ŸŒธ

okay so this header is where it gets fun โ€” it gives you the ypath subsystem, which is basically a JSONPath / XPath-style query language for navigating your YAML document trees ๐Ÿฆ‹. iykyk, it's a whole vibe.

A ypath expression like /servers/0/host gets parsed first into a compiled struct fy_path_expr, and then it's executed against a starting node in any struct fy_document to produce a result set of matching nodes. Filter predicates and wildcards are also supported โ€” slay ๐Ÿ’….

Typical workflow, bestie, follow along:

// 1. Create a path parser
struct fy_path_parser *fypp = fy_path_parser_create(NULL);

// 2. Compile an expression
struct fy_path_expr *expr =
    fy_path_parse_expr_from_string(fypp, "/servers/0/host", -1);

// 3. Create an executor and run the expression
struct fy_path_exec *fypx = fy_path_exec_create(NULL);
fy_path_exec_execute(fypx, expr, fy_document_root(fyd));

// 4. Iterate results
void *iter = NULL;
struct fy_node *fyn;
while ((fyn = fy_path_exec_results_iterate(fypx, &iter)) != NULL)
    process(fyn);

// 5. Cleanup
fy_path_exec_destroy(fypx);
fy_path_expr_free(expr);
fy_path_parser_destroy(fypp);

For one-shot use, fy_path_expr_build_from_string() wraps steps 1 and 2 into a single call โ€” so convenient, honestly ๐Ÿซถ.

The executor can be reset and re-used for multiple executions against the same or different documents. The compiled expression is independent of any document and may be executed repeatedly. no cap, it's reusable like that โœจ.


๐ŸŽ€ enum fy_path_parse_cfg_flags ๐ŸŽ€

enum fy_path_parse_cfg_flags โ€” Path parse configuration flags ๐Ÿ’–

Definition

enum fy_path_parse_cfg_flags {
    FYPPCF_QUIET,
    FYPPCF_DISABLE_RECYCLING,
    FYPPCF_DISABLE_ACCELERATORS
};

Constants

  • FYPPCF_QUIET โ€” Quiet mode, so it doesn't output any information messages ๐Ÿคซ
  • FYPPCF_DISABLE_RECYCLING โ€” Disable the recycling optimization โ™ป๏ธ
  • FYPPCF_DISABLE_ACCELERATORS โ€” Disable use of access accelerators (this one saves memory ๐Ÿ’พ)

Description

These flags control the operation of the path parse. periodt.


๐ŸŒˆ struct fy_path_parse_cfg ๐ŸŒˆ

struct fy_path_parse_cfg โ€” the path parser configuration structure ๐Ÿ‘‘

Definition

struct fy_path_parse_cfg {
    enum fy_path_parse_cfg_flags flags;
    void *userdata;
    struct fy_diag *diag;
}

Members

  • flags โ€” Configuration flags โœจ
  • userdata โ€” Opaque user data pointer ๐Ÿซง
  • diag โ€” Optional diagnostic interface to use ๐Ÿฉบ

Description

This is the argument to the fy_path_parser_create() method, which is what performs parsing of a ypath expression. it's giving config-central ๐Ÿ’….


๐Ÿ’œ fy_path_parser_create ๐Ÿ’œ

struct fy_path_parser *fy_path_parser_create(const struct fy_path_parse_cfg *cfg)

Create a ypath parser ๐ŸŒŸ

Parameters

  • cfg (*const struct fy_path_parse_cfg**) โ€” The configuration for the path parser

Description

Creates a path parser with its configuration cfg. The path parser may be destroyed by a corresponding call to fy_path_parser_destroy(). If cfg is NULL a default yaml parser is created ๐ŸŽ€.

Return

A pointer to the path parser, or NULL in case of an error ๐Ÿ˜ญ.


๐Ÿฆ‹ fy_path_parser_destroy ๐Ÿฆ‹

void fy_path_parser_destroy(struct fy_path_parser *fypp)

Destroy the given path parser ๐Ÿ’€

Parameters

  • fypp (*struct fy_path_parser**) โ€” The path parser to destroy

Description

Destroys a path parser that you created earlier via fy_path_parser_create(). clean up after yourself bestie ๐Ÿงน.


โญ fy_path_parser_reset โญ

int fy_path_parser_reset(struct fy_path_parser *fypp)

Reset a path parser completely ๐Ÿ”„

Parameters

  • fypp (*struct fy_path_parser**) โ€” The path parser to reset

Description

Completely resets a path parser โ€” including after an error that caused a parser error to be emitted. like a fresh start, we love that for you ๐ŸŒธ.

Return

0 if the reset was successful, -1 otherwise.


๐Ÿ“ fy_path_parse_expr_from_string ๐Ÿ“

struct fy_path_expr *fy_path_parse_expr_from_string(struct fy_path_parser *fypp, const char *str, size_t len)

Parse an expression from a given string โœ๏ธ

Parameters

  • fypp (*struct fy_path_parser**) โ€” The path parser to use
  • str (*const char**) โ€” The ypath source to use.
  • len (size_t) โ€” The length of the string (or -1 if '0' terminated)

Description

Creates a path expression from a string, using the path parser you hand it ๐Ÿซถ.

Return

The created path expression, or NULL on error ๐Ÿ˜ญ.


๐Ÿงš fy_path_expr_build_from_string ๐Ÿงš

struct fy_path_expr *fy_path_expr_build_from_string(const struct fy_path_parse_cfg *pcfg, const char *str, size_t len)

Parse an expression from a given string (the one-shot version, icon behavior) โœจ

Parameters

  • pcfg (*const struct fy_path_parse_cfg**) โ€” The path parser configuration to use, or NULL for default
  • str (*const char**) โ€” The ypath source to use.
  • len (size_t) โ€” The length of the string (or -1 if '0' terminated)

Description

Creates a path expression from a string using the provided path parser configuration ๐ŸŽ€.

Return

The created path expression, or NULL on error ๐Ÿ˜ญ.


๐ŸŒธ fy_path_expr_free ๐ŸŒธ

void fy_path_expr_free(struct fy_path_expr *expr)

Free a path expression ๐Ÿ—‘๏ธ

Parameters

  • expr (*struct fy_path_expr**) โ€” The expression to free (may be NULL)

Description

Frees a previously returned expression from any of the path parser methods, like fy_path_expr_build_from_string(). and yes, NULL is fine, it handles it ๐Ÿ’….


๐Ÿ‘‘ fy_path_expr_dump ๐Ÿ‘‘

void fy_path_expr_dump(struct fy_path_expr *expr, struct fy_diag *diag, enum fy_error_type errlevel, int level, const char *banner)

Dump the contents of a path expression to the diagnostic object ๐Ÿ“œ

Parameters

  • expr (*struct fy_path_expr**) โ€” The expression to dump
  • diag (*struct fy_diag**) โ€” The diagnostic object to use
  • errlevel (enum fy_error_type) โ€” The error level which the diagnostic will use
  • level (int) โ€” The nest level; should be set to 0
  • banner (*const char**) โ€” The banner to display on level 0

Description

Dumps the expression using the provided error level. perfect for when you're like "what is this even doing" ๐Ÿ™ˆ.


๐Ÿ”ฅ fy_path_expr_to_document ๐Ÿ”ฅ

struct fy_document *fy_path_expr_to_document(struct fy_path_expr *expr)

Converts the path expression to a YAML document ๐Ÿ“„

Parameters

  • expr (*struct fy_path_expr**) โ€” The expression to convert to a document

Description

Converts the expression to a YAML document, which is genuinely so useful for understanding what the expression evaluates to ๐Ÿ‘€. it's giving debug mode.

Return

The document of the expression, or NULL on error ๐Ÿ˜ญ.


๐ŸŽ€ enum fy_path_exec_cfg_flags ๐ŸŽ€

enum fy_path_exec_cfg_flags โ€” Path executor configuration flags ๐Ÿ’–

Definition

enum fy_path_exec_cfg_flags {
    FYPXCF_QUIET,
    FYPXCF_DISABLE_RECYCLING,
    FYPXCF_DISABLE_ACCELERATORS
};

Constants

  • FYPXCF_QUIET โ€” Quiet, do not output any information messages ๐Ÿคซ
  • FYPXCF_DISABLE_RECYCLING โ€” Disable recycling optimization โ™ป๏ธ
  • FYPXCF_DISABLE_ACCELERATORS โ€” Disable use of access accelerators (saves memory ๐Ÿ’พ)

Description

These flags control the operation of the path expression executor. periodt.


๐ŸŒˆ struct fy_path_exec_cfg ๐ŸŒˆ

struct fy_path_exec_cfg โ€” the path expression executor configuration structure ๐Ÿ‘‘

Definition

struct fy_path_exec_cfg {
    enum fy_path_exec_cfg_flags flags;
    void *userdata;
    struct fy_diag *diag;
}

Members

  • flags โ€” Configuration flags โœจ
  • userdata โ€” Opaque user data pointer ๐Ÿซง
  • diag โ€” Optional diagnostic interface to use ๐Ÿฉบ

Description

This is the argument to the fy_path_exec_create() method, which is what performs execution of a ypath expression ๐Ÿ’….


๐Ÿ’œ fy_path_exec_create ๐Ÿ’œ

struct fy_path_exec *fy_path_exec_create(const struct fy_path_exec_cfg *xcfg)

Create a ypath expression executor ๐ŸŒŸ

Parameters

  • xcfg (*const struct fy_path_exec_cfg**) โ€” The configuration for the executor

Description

Creates a ypath expression parser with its configuration cfg. The executor may be destroyed by a corresponding call to fy_path_exec_destroy(). (yes the manpage says cfg here even though the param is xcfg โ€” we don't make the rules, we just report them ๐Ÿ™ˆ)

Return

A pointer to the executor, or NULL in case of an error ๐Ÿ˜ญ.


๐Ÿฆ‹ fy_path_exec_destroy ๐Ÿฆ‹

void fy_path_exec_destroy(struct fy_path_exec *fypx)

Destroy the given path expression executor ๐Ÿ’€

Parameters

  • fypx (*struct fy_path_exec**) โ€” The path parser to destroy

Description

Destroys an executor created earlier via fy_path_exec_create(). (the manpage literally says "Destroy ane executor" โ€” typo and all, we keep it, that's the lore ๐Ÿซถ)


โญ fy_path_exec_reset โญ

int fy_path_exec_reset(struct fy_path_exec *fypx)

Reset an executor ๐Ÿ”„

Parameters

  • fypx (*struct fy_path_exec**) โ€” The executor to reset

Description

Completely resets an executor, without releasing it. reuse szn ๐Ÿ’….

Return

0 if the reset was successful, -1 otherwise.


๐Ÿ“ fy_path_exec_execute ๐Ÿ“

int fy_path_exec_execute(struct fy_path_exec *fypx, struct fy_path_expr *expr, struct fy_node *fyn_start)

Execute a path expression starting at the given start node ๐Ÿš€

Parameters

  • fypx (*struct fy_path_exec**) โ€” The executor to use
  • expr (*struct fy_path_expr**) โ€” The expression to use
  • fyn_start (*struct fy_node**) โ€” The node on which the expression will begin.

Description

Executes the expression starting at fyn_start. If execution is successful, the results are available via fy_path_exec_results_iterate() โœจ.

โš ๏ธ heads up bestie: it is illegal to modify the state of the document that the results reside in between this call and the results collection. like, do not touch it. seriously. ๐Ÿ’€

Return

0 if the execution was successful, -1 otherwise.

Note that the execution may be successful but no results were produced, in which case the iterator will return NULL ๐Ÿ™ˆ. (successful but empty, we've all been there)


๐Ÿงš fy_path_exec_results_iterate ๐Ÿงš

struct fy_node *fy_path_exec_results_iterate(struct fy_path_exec *fypx, void **prevp)

Iterate over the results of execution ๐Ÿ”

Parameters

  • fypx (*struct fy_path_exec**) โ€” The executor
  • prevp (void**) โ€” The previous result iterator

Description

This method iterates over all the results in the executor. The start of the iteration is signalled by a NULL in *prevp ๐ŸŽ€.

Return

The next node in the result set, or NULL at the end of the results ๐Ÿ.


๐Ÿฆ‹ DOCUMENT ITERATION ๐Ÿฆ‹

okay so this header provides struct fy_document_iterator, which traverses a document tree depth-first without using system stack recursion โ€” no stack overflow era, we love to see it ๐Ÿ™Œ. Two usage modes are supported:

Node iteration โ€” visit every node in a subtree in document order:

struct fy_document_iterator *fydi = fy_document_iterator_create();
fy_document_iterator_node_start(fydi, fy_document_root(fyd));
struct fy_node *fyn;
while ((fyn = fy_document_iterator_node_next(fydi)) != NULL)
    process(fyn);
fy_document_iterator_destroy(fydi);

Event replay โ€” regenerate the YAML event stream that produced the document, suitable for feeding into a parser, emitter, or composer:

struct fy_document_iterator *fydi =
    fy_document_iterator_create_on_document(fyd);
struct fy_event *fye;
while ((fye = fy_document_iterator_generate_next(fydi)) != NULL) {
    process_event(fye);
    fy_document_iterator_event_free(fydi, fye);
}
fy_document_iterator_destroy(fydi);

The iterator can also be attached to a struct fy_parser via fy_parser_set_document_iterator(), making a parser transparently replay the events of an existing document rather than parsing fresh input. obsessed with the convenience, honestly ๐Ÿ’…

Events emitted by the iterator are in the same order as those that originally created the document, so round-trip fidelity is preserved. no cap, the round-trip stays iconic โœจ


๐ŸŽ€ enum fy_document_iterator_cfg_flags

Document iterator configuration flags ๐Ÿซถ

๐Ÿ“Œ Definition

enum fy_document_iterator_cfg_flags {
    FYDICF_WANT_BODY_EVENTS,
    FYDICF_WANT_DOCUMENT_BODY_EVENTS,
    FYDICF_WANT_STREAM_DOCUMENT_BODY_EVENTS
};

๐ŸŒˆ Constants

  • FYDICF_WANT_BODY_EVENTS โ€” Generate body events
  • FYDICF_WANT_DOCUMENT_BODY_EVENTS โ€” Generate document and body events
  • FYDICF_WANT_STREAM_DOCUMENT_BODY_EVENTS โ€” Generate stream, document and body events

๐Ÿ’ฌ Description

These flags control the operation of the document iterator. tiny flags, big main-character energy ๐Ÿ‘‘


๐Ÿงš struct fy_document_iterator_cfg

document iterator configuration structure. ๐Ÿซถ

๐Ÿ“Œ Definition

struct fy_document_iterator_cfg {
    enum fy_document_iterator_cfg_flags flags;
    struct fy_document *fyd;
    struct fy_node *iterate_root;
}

๐Ÿงฉ Members

  • flags โ€” The document iterator flags
  • fyd โ€” The document to iterate on (or NULL if iterate_root is set)
  • iterate_root โ€” The root of iteration (NULL when fyd is not NULL)

๐Ÿ’ฌ Description

Argument to the fy_document_iterator_create_cfg() method. it's giving config struct realness ๐Ÿ’œ


๐Ÿฆ‹ fy_document_iterator_create

struct fy_document_iterator *fy_document_iterator_create(void)

Create a document iterator ๐Ÿ’–

๐ŸŽฏ Parameters

  • void โ€” no arguments

๐Ÿ’ฌ Description

Creates a document iterator, that can trawl through a document without using recursion. no recursion, just vibes โœจ

๐Ÿ” Return

The newly created document iterator or NULL on error


๐ŸŒธ fy_document_iterator_create_cfg

struct fy_document_iterator *fy_document_iterator_create_cfg(const struct fy_document_iterator_cfg *cfg)

Create a document iterator using config ๐ŸŽ€

๐ŸŽฏ Parameters

  • cfg (const struct fy_document_iterator_cfg*) โ€” The document iterator to destroy
not me side-eyeing that parameter description ๐Ÿ’€ but yes, that is genuinely what it says.

๐Ÿ’ฌ Description

Creates a document iterator, that can trawl through a document without using recursion. The iterator will generate all the events that created the given document starting at iterator root. it literally replays the lore of the document ๐Ÿซถ

๐Ÿ” Return

The newly created document iterator or NULL on error


๐Ÿฆ‹ fy_document_iterator_create_on_document

struct fy_document_iterator *fy_document_iterator_create_on_document(struct fy_document *fyd)

Create a document iterator on document โœจ

๐ŸŽฏ Parameters

  • fyd (struct fy_document*) โ€” The document to iterate on

๐Ÿ’ฌ Description

Creates a document iterator, starting at the root of the given document. root node first, obviously ๐Ÿ’…

๐Ÿ” Return

The newly created document iterator or NULL on error


๐ŸŒˆ fy_document_iterator_create_on_node

struct fy_document_iterator *fy_document_iterator_create_on_node(struct fy_node *fyn)

Create a document iterator on node ๐Ÿฆ‹

๐ŸŽฏ Parameters

  • fyn (struct fy_node*) โ€” The node to iterate on

๐Ÿ’ฌ Description

Creates a document iterator, starting at the given node. pick your starting point, bestie ๐ŸŽฏ

๐Ÿ” Return

The newly created document iterator or NULL on error


๐Ÿ’… fy_document_iterator_destroy

void fy_document_iterator_destroy(struct fy_document_iterator *fydi)

Destroy the given document iterator ๐Ÿ’€

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to destroy

๐Ÿ’ฌ Description

Destroy a document iterator created earlier via fy_document_iterator_create(). cleanup era, we love to see it ๐Ÿงน


๐ŸŽ€ fy_document_iterator_event_free

void fy_document_iterator_event_free(struct fy_document_iterator *fydi, struct fy_event *fye)

Free an event that was created by a document iterator ๐Ÿซถ

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator that created the event
  • fye (struct fy_event*) โ€” The event

๐Ÿ’ฌ Description

Free (possibly recycling) an event that was created by a document iterator. recycling? we love sustainability โ™ป๏ธ


โญ fy_document_iterator_stream_start

struct fy_event *fy_document_iterator_stream_start(struct fy_document_iterator *fydi)

Create a stream start event using the iterator ๐ŸŒŸ

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to create the event

๐Ÿ’ฌ Description

Creates a stream start event on the document iterator and advances the internal state of it accordingly. state machine go brrr โš™๏ธ

๐Ÿ” Return

The newly created stream start event, or NULL on error.


๐ŸŒŸ fy_document_iterator_stream_end

struct fy_event *fy_document_iterator_stream_end(struct fy_document_iterator *fydi)

Create a stream end event using the iterator ๐ŸŒˆ

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to create the event

๐Ÿ’ฌ Description

Creates a stream end event on the document iterator and advances the internal state of it accordingly. wrap it up, stream edition ๐ŸŽฌ

๐Ÿ” Return

The newly created stream end event, or NULL on error.


๐Ÿงš fy_document_iterator_document_start

struct fy_event *fy_document_iterator_document_start(struct fy_document_iterator *fydi, struct fy_document *fyd)

Create a document start event using the iterator ๐Ÿ“„

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to create the event
  • fyd (struct fy_document*) โ€” The document containing the document state that is used in the event

๐Ÿ’ฌ Description

Creates a document start event on the document iterator and advances the internal state of it accordingly. The document must not be released until an error, cleanup or a call to fy_document_iterator_document_end(). do not release it early, bestie โ€” that's a whole mess ๐Ÿ˜ญ

๐Ÿ” Return

The newly created document start event, or NULL on error.


๐ŸŽฌ fy_document_iterator_document_end

struct fy_event *fy_document_iterator_document_end(struct fy_document_iterator *fydi)

Create a document end event using the iterator ๐Ÿ

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to create the event

๐Ÿ’ฌ Description

Creates a document end event on the document iterator and advances the internal state of it accordingly. The document that was used earlier in the call of fy_document_iterator_document_start() can now be released. okay NOW you may release it, periodt ๐Ÿ’…

๐Ÿ” Return

The newly created document end event, or NULL on error.


๐Ÿ“ fy_document_iterator_body_next

struct fy_event *fy_document_iterator_body_next(struct fy_document_iterator *fydi)

Create document body events until the end ๐Ÿ“

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to create the event

๐Ÿ’ฌ Description

Creates the next document body, depth first until the end of the document. The events are created depth first and are in same exact sequence that the original events that created the document.

That means that the finite event stream that generated the document is losslesly preserved in such a way that the document tree representation is functionally equivalent. the lore is preserved, fr fr ๐Ÿ“š

Repeated calls to this function will generate a stream of SCALAR, ALIAS, SEQUENCE START, SEQUENCE END, MAPPING START and MAPPING END events, returning NULL at the end of the body event stream.

๐Ÿ” Return

The newly created document body event or NULL at an error, or an end of the event stream. Use fy_document_iterator_get_error() to check if an error occured. vibe check the error state if something smells off ๐Ÿ‘€


๐Ÿฆ‹ fy_document_iterator_node_start

void fy_document_iterator_node_start(struct fy_document_iterator *fydi, struct fy_node *fyn)

Start a document node iteration run using a starting point ๐ŸŽฏ

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to run with
  • fyn (struct fy_node*) โ€” The iterator root for the iteration

๐Ÿ’ฌ Description

Starts an iteration run starting at the given node. set the starting point and let it cook ๐Ÿณ


๐ŸŒˆ fy_document_iterator_node_next

struct fy_node *fy_document_iterator_node_next(struct fy_document_iterator *fydi)

Return the next node in the iteration sequence ๐Ÿงš

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to use for the iteration

๐Ÿ’ฌ Description

Returns a pointer to the next node iterating using as a start the node given at fy_document_iterator_node_start(). The first node returned will be that, followed by all the remaing nodes in the subtree. first the root, then the whole subtree โ€” iconic traversal behavior ๐ŸŒณ

๐Ÿ” Return

The next node in the iteration sequence or NULL at the end, or if an error occured.


โญ fy_document_iterator_generate_next

struct fy_event *fy_document_iterator_generate_next(struct fy_document_iterator *fydi)

Create events from document iterator โœจ

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to create the event

๐Ÿ’ฌ Description

This is a method that will handle the complex state of generating stream, document and body events on the given iterator. the multitasking icon of this API ๐Ÿ‘‘

When generation is complete a NULL event will be generated.

๐Ÿ” Return

The newly created event or NULL at an error, or an end of the event stream. Use fy_document_iterator_get_error() to check if an error occured. again: check the error state, bestie ๐Ÿ”


๐Ÿ’œ fy_document_iterator_get_error

bool fy_document_iterator_get_error(struct fy_document_iterator *fydi)

Get the error state of the document iterator ๐Ÿšจ

๐ŸŽฏ Parameters

  • fydi (struct fy_document_iterator*) โ€” The document iterator to use for checking itโ€™s error state.

๐Ÿ’ฌ Description

Returns the error state of the iterator. If itโ€™s in error state, return true and reset the iterator to the state just after creation. error state detected? reset and pretend it never happened, main character move ๐Ÿ’…

๐Ÿ” Return

true if it was in an error state, false otherwise. ๐Ÿ’–

๐ŸŒŸ enum fy_parser_event_generator_flags ๐ŸŒŸ

ok so this enum is literally just a vibe check for which events the generator should make. three options, no notes ๐Ÿ’…

enum fy_parser_event_generator_flags {
    FYPEGF_GENERATE_DOCUMENT_EVENTS,
    FYPEGF_GENERATE_STREAM_EVENTS,
    FYPEGF_GENERATE_ALL_EVENTS
};

the constants ๐ŸŽ€

  • FYPEGF_GENERATE_DOCUMENT_EVENTS โ€” generate document events
  • FYPEGF_GENERATE_STREAM_EVENTS โ€” generate stream events
  • FYPEGF_GENERATE_ALL_EVENTS โ€” generate all events

๐Ÿ› ๏ธ fy_parser_set_document_iterator

int fy_parser_set_document_iterator(struct fy_parser *fyp, enum fy_parser_event_generator_flags flags, struct fy_document_iterator *fydi)

Associate a parser with a document iterator

Parameters ๐ŸŒธ

  • fyp (struct fy_parser*) โ€” The parser
  • flags (enum fy_parser_event_generator_flags) โ€” The event generation flags
  • fydi (struct fy_document_iterator*) โ€” The document iterator to associate

Description ๐Ÿ’–

okay so you're basically setting up a situationship between a parser and a document iterator โ€” instead of the parser doing the parsing itself, the events get generated by the document iterator instead. iconic delegation, ngl.

Return โœจ

0 on success, -1 on error


๐Ÿ“ฆ DOCUMENT BUILDER ๐Ÿ“ฆ

This header provides struct fy_document_builder, which accumulates YAML parser events and assembles them into a struct fy_document tree. it's giving arts-and-crafts but for YAML ๐ŸŽจ

The builder supports two operating modes:

Pull mode โ€” the builder drives a parser internally:

struct fy_document_builder *fydb =
    fy_document_builder_create_on_parser(fyp);
struct fy_document *fyd;
while ((fyd = fy_document_builder_load_document(fydb, fyp)) != NULL) {
    process(fyd);
    fy_document_destroy(fyd);
}
fy_document_builder_destroy(fydb);

Push mode โ€” the caller feeds events one at a time and takes ownership when the document is complete:

fy_document_builder_set_in_stream(fydb);
struct fy_event *fye;
while ((fye = get_next_event()) != NULL) {
    fy_document_builder_process_event(fydb, fye);
    if (fy_document_builder_is_document_complete(fydb)) {
        struct fy_document *fyd =
            fy_document_builder_take_document(fydb);
        process(fyd);
        fy_document_destroy(fyd);
    }
}

Push mode is the move when events arrive asynchronously or from a source other than a libfyaml parser โ€” like a document iterator or a network stream. main character energy for sure ๐Ÿฆ‹

fy_parse_load_document_with_builder() provides the simplest interface: literally one single call that returns the next complete document from a parser. ate and left no crumbs ๐Ÿ’…


๐Ÿงฑ struct fy_document_builder_cfg

document builder configuration structure.

Definition

struct fy_document_builder_cfg {
    struct fy_parse_cfg parse_cfg;
    void *userdata;
    struct fy_diag *diag;
}

Members ๐Ÿ‘‘

  • parse_cfg โ€” Parser configuration
  • userdata โ€” Opaque user data pointer
  • diag โ€” Optional diagnostic interface to use

Description ๐Ÿ’œ

Argument to the fy_document_builder_create() method


๐Ÿฃ fy_document_builder_create

struct fy_document_builder *fy_document_builder_create(const struct fy_document_builder_cfg *cfg)

Create a document builder

Parameters ๐ŸŒˆ

  • cfg (const struct fy_document_builder_cfg*) โ€” The configuration for the document builder

Description โœจ

Creates a document builder with its configuration cfg. The document builder may be destroyed by a corresponding call to fy_document_builder_destroy().

Return ๐Ÿซถ

A pointer to the document builder or NULL in case of an error.


๐Ÿงš fy_document_builder_create_on_parser

struct fy_document_builder *fy_document_builder_create_on_parser(struct fy_parser *fyp)

Create a document builder pulling state from the parser

Parameters ๐Ÿ’ซ

  • fyp (struct fy_parser*) โ€” The parser to associate with

Description ๐ŸŒธ

Creates a document builder pulling state from the given parser

Return โญ

A pointer to the document builder or NULL in case of an error.


๐Ÿ”„ fy_document_builder_reset

void fy_document_builder_reset(struct fy_document_builder *fydb)

Reset a document builder

Parameters ๐ŸŽ€

  • fydb (struct fy_document_builder*) โ€” The document builder

Description ๐Ÿ’…

Resets a document builder without destroying it โ€” a little factory reset, but it keeps the builder alive. we love a soft launch.


๐Ÿ’€ fy_document_builder_destroy

void fy_document_builder_destroy(struct fy_document_builder *fydb)

Destroy a document builder

Parameters ๐Ÿ˜ญ

  • fydb (struct fy_document_builder*) โ€” The document builder

Description ๐Ÿ”ฅ

Destroy a document builder. it's over bestie, say bye.


๐Ÿ“„ fy_document_builder_get_document

struct fy_document *fy_document_builder_get_document(struct fy_document_builder *fydb)

Get the document of a builder

Parameters ๐Ÿฆ‹

  • fydb (struct fy_document_builder*) โ€” The document builder

Description ๐ŸŒŸ

Retrieve the document of a document builder. heads up though โ€” this document may be incomplete. If you need to take ownership use fy_document_builder_take_document(). don't be out here acting like it's finished, it's not ๐Ÿ˜ค

Return ๐Ÿ’–

The document that the builder built, or NULL in case of an error


๐ŸŒŠ fy_document_builder_is_in_stream

bool fy_document_builder_is_in_stream(struct fy_document_builder *fydb)

Test document builder in stream

Parameters ๐Ÿงต

  • fydb (struct fy_document_builder*) โ€” The document builder

Description โœจ

Find out if the document builder is in 'stream' state โ€” i.e. after stream start but before stream end events are generated. the in-between era, the liminal space, the "we're so back but also not yet" moment.

Return ๐Ÿซถ

true if in stream, false otherwise


๐Ÿ“‘ fy_document_builder_is_in_document

bool fy_document_builder_is_in_document(struct fy_document_builder *fydb)

Test document builder in document

Parameters ๐Ÿ’œ

  • fydb (struct fy_document_builder*) โ€” The document builder

Description ๐ŸŒธ

Find out if the document builder is in 'document' state โ€” i.e. after document start but before document end events are generated.

Return โญ

true if in document, false otherwise


โœ… fy_document_builder_is_document_complete

bool fy_document_builder_is_document_complete(struct fy_document_builder *fydb)

Test document builder complete

Parameters ๐ŸŽ€

  • fydb (struct fy_document_builder*) โ€” The document builder

Description ๐Ÿ’ซ

Find out if the document of the builder is complete. and if it is complete, then a call to fy_document_builder_take_document() will transfer ownership of the document to the caller. that's the glow-up moment right there.

Return ๐ŸŒˆ

true if document complete, false otherwise


๐Ÿซด fy_document_builder_take_document

struct fy_document *fy_document_builder_take_document(struct fy_document_builder *fydb)

Take ownership the document of a builder

Parameters ๐Ÿ‘‘

  • fydb (struct fy_document_builder*) โ€” The document builder

Description ๐Ÿ’–

Take ownership of the document of a document builder. the document builder's document must be complete โ€” like, non-negotiable, fr fr.

Return โœจ

The document that the builder built, or NULL in case of an error


๐Ÿ‘€ fy_document_builder_peek_document

struct fy_document *fy_document_builder_peek_document(struct fy_document_builder *fydb)

Peek at the document of a builder

Parameters ๐ŸŒธ

  • fydb (struct fy_document_builder*) โ€” The document builder

Description ๐Ÿฆ‹

Peek at the document of a document builder. Ownership still remains with the builder โ€” so like, look, don't touch ๐Ÿ’…

Return ๐ŸŽ€

A peek to the document that the builder built, or NULL in case of an error


๐ŸŒŠ fy_document_builder_set_in_stream

void fy_document_builder_set_in_stream(struct fy_document_builder *fydb)

Set the builders state in 'stream'

Parameters ๐Ÿงš

  • fydb (struct fy_document_builder*) โ€” The document builder

Description ๐Ÿ’ซ

Set the document builders state to in 'stream'


๐Ÿ“‘ fy_document_builder_set_in_document

int fy_document_builder_set_in_document(struct fy_document_builder *fydb, struct fy_document_state *fyds, bool single)

Set the builders state in 'document'

Parameters ๐ŸŒŸ

  • fydb (struct fy_document_builder*) โ€” The document builder
  • fyds (struct fy_document_state*) โ€” The document state
  • single (bool) โ€” Single document mode

Description ๐Ÿ”ฅ

Set the document builders state to in 'document'

Return โญ

0 on success, -1 on error


๐Ÿ“ฅ fy_document_builder_load_document

struct fy_document *fy_document_builder_load_document(struct fy_document_builder *fydb, struct fy_parser *fyp)

Create a document from parser events

Parameters ๐Ÿ’œ

  • fydb (struct fy_document_builder*) โ€” The document builder
  • fyp (struct fy_parser*) โ€” The parser

Description ๐ŸŒˆ

Load a document by pumping the parser for events and then processing them with the builder. pump it, process it, slay it.

Return ๐Ÿซถ

The document that results from the parser, or NULL in case of an error (or EOF)


๐Ÿ—๏ธ fy_parse_load_document_with_builder

struct fy_document *fy_parse_load_document_with_builder(struct fy_parser *fyp)

Parse a document via built-in builder

Parameters โœจ

  • fyp (struct fy_parser*) โ€” The parser

Description ๐ŸŒธ

Load a document by pumping the parser for events and then processing them with the in-parser builder. the builder's already in there, you don't gotta bring your own ๐Ÿ’…

Return ๐ŸŽ€

The document that results from the parser, or NULL in case of an error (or EOF)


โšก fy_document_builder_process_event

int fy_document_builder_process_event(struct fy_document_builder *fydb, struct fy_event *fye)

Process an event with a builder

Parameters ๐Ÿฆ‹

  • fydb (struct fy_document_builder*) โ€” The document builder
  • fye (struct fy_event*) โ€” The event

Description ๐Ÿ’ซ

Pump an event to a document builder for processing.

Return โญ

0 on success, -1 on error


๐ŸŽผ COMPOSER ๐ŸŽผ

This header provides two complementary interfaces for processing YAML event streams with awareness of the current position in the document hierarchy โ€” and the best part? no commitment to building a full in-memory tree required. we're just vibing through the events, not moving in ๐Ÿงš

Simple callback interface โ€” fy_parse_compose() calls a user function for each event, passing both the event and the current struct fy_path so the callback can make intelligent decisions without maintaining its own path stack:

enum fy_composer_return my_cb(struct fy_parser *fyp,
                              struct fy_event *fye,
                              struct fy_path *path,
                              void *userdata)
{
    if (fy_path_depth(path) > 3)
        return FYCR_OK_START_SKIP;
    process(fye);
    return FYCR_OK_CONTINUE;
}
fy_parse_compose(fyp, my_cb, ctx);

Object-based interface โ€” struct fy_composer is literally the same mechanism but wrapped in a reusable object, bestie ๐Ÿ’…. It's got ops callbacks, optional document builder integration, and helpers for navigating the path hierarchy. Same energy, cuter packaging.

Path inspection helpers โ€” functions like fy_path_in_mapping(), fy_path_depth(), fy_path_component_is_sequence(), plus those user-data attach/retrieve pairs, let your callbacks annotate and query the live path stack with zero external bookkeeping. No mental notes app needed, we love to see it ๐Ÿซถ.

Callbacks control event processing by returning one of:

  • FYCR_OK_CONTINUE โ€” consume the event and continue
  • FYCR_OK_STOP โ€” consume the event and stop
  • FYCR_OK_START_SKIP โ€” start skipping the current subtree
  • FYCR_OK_STOP_SKIP โ€” stop an active skip and resume processing
  • FYCR_ERROR โ€” abort with an error

๐ŸŽ€ enum fy_composer_return

enum fy_composer_return โ€” the returns of the composer callback, aka the vibe check for your whole event loop โœจ

Definition

enum fy_composer_return {
    FYCR_OK_CONTINUE,
    FYCR_OK_STOP,
    FYCR_OK_START_SKIP,
    FYCR_OK_STOP_SKIP,
    FYCR_ERROR
};

Constants

  • FYCR_OK_CONTINUE โ€” continue processing, event processed ๐Ÿ’–
  • FYCR_OK_STOP โ€” stop processing, event processed
  • FYCR_OK_START_SKIP โ€” start skip object(s), event processed
  • FYCR_OK_STOP_SKIP โ€” stop skipping of objects, event processed
  • FYCR_ERROR โ€” error, stop processing ๐Ÿ’€

๐ŸŒธ fy_composer_return_is_ok

bool fy_composer_return_is_ok(enum fy_composer_return ret)

Check if the return code is OK. Literally just "is this fine or not" ๐Ÿงš

Parameters

  • ret (enum fy_composer_return) โ€“ the composer return to check

Description

Convenience method for checking if it's OK to continue.

Return

true if non error or skip condition.


๐Ÿฆ‹ typedef fy_parse_composer_cb

enum fy_composer_return fy_parse_composer_cb(struct fy_parser *fyp,
                                             struct fy_event *fye,
                                             struct fy_path *path,
                                             void *userdata)

Composer callback method โ€” the main character of this whole section, no cap ๐Ÿ‘‘

Parameters

  • fyp (struct fy_parser*) โ€“ The parser
  • fye (struct fy_event*) โ€“ The event
  • path (struct fy_path*) โ€“ The path that the parser is processing
  • userdata (void*) โ€“ The user data of the fy_parse_compose() method

Description

This method is called by the fy_parse_compose() method when an event must be processed.

Return

fy_composer_return code telling the parser what to do.


๐ŸŒˆ fy_parse_compose

int fy_parse_compose(struct fy_parser *fyp, fy_parse_composer_cb cb,
                     void *userdata)

Parse using a compose callback. It's giving โœจ alternative timeline โœจ.

Parameters

  • fyp (struct fy_parser*) โ€“ The parser
  • cb (fy_parse_composer_cb) โ€“ The callback that will be called
  • userdata (void*) โ€“ user pointer to pass to the callback

Description

Alternative parsing method using a composer callback.

The parser will construct a path argument that is used by the callback to make intelligent decisions about creating a document and/or DOM. Big brain behavior fr fr ๐Ÿง 

Return

0 if no error occured, -1 on error.


๐Ÿ’œ fy_path_component_is_mapping

bool fy_path_component_is_mapping(struct fy_path_component *fypc)

Check if the component is a mapping ๐Ÿ”

Parameters

  • fypc (struct fy_path_component*) โ€“ The path component to check

Return

true if the path component is a mapping, false otherwise.


โญ fy_path_component_is_sequence

bool fy_path_component_is_sequence(struct fy_path_component *fypc)

Check if the component is a sequence ๐ŸŒŸ

Parameters

  • fypc (struct fy_path_component*) โ€“ The path component to check

Return

true if the path component is a sequence, false otherwise.


๐Ÿ“ fy_path_component_sequence_get_index

int fy_path_component_sequence_get_index(struct fy_path_component *fypc)

Get the index of sequence path component โ€” like, which slot are we in, bestie? ๐Ÿ”ข

Parameters

  • fypc (struct fy_path_component*) โ€“ The sequence path component to return it's index value

Return

>= 0 the sequence index, -1 if the component is either not in the proper mode, or not a sequence.


๐ŸŽ€ fy_path_component_mapping_get_scalar_key

struct fy_token *fy_path_component_mapping_get_scalar_key(struct fy_path_component *fypc)

Get the scalar key of a mapping ๐Ÿ”‘

Parameters

  • fypc (struct fy_path_component*) โ€“ The mapping path component to return it's scalar key

Return

a non NULL scalar or alias token if the mapping contains a scalar key, NULL in case of an error, or if the component has a complex key.


๐ŸŒธ fy_path_component_mapping_get_scalar_key_tag

struct fy_token *fy_path_component_mapping_get_scalar_key_tag(struct fy_path_component *fypc)

Get the scalar key's tag of a mapping ๐Ÿท๏ธ

Parameters

  • fypc (struct fy_path_component*) โ€“ The mapping path component to return it's scalar key's tag

Return

a non NULL tag token if the mapping contains a scalar key with a tag or NULL in case of an error, or if the component has a complex key.


๐Ÿฆ‹ fy_path_component_mapping_get_complex_key

struct fy_document *fy_path_component_mapping_get_complex_key(struct fy_path_component *fypc)

Get the complex key of a mapping โ€” this is the fancy one, iykyk ๐Ÿ’…

Parameters

  • fypc (struct fy_path_component*) โ€“ The mapping path component to return it's complex key

Return

a non NULL document if the mapping contains a complex key, NULL in case of an error, or if the component has a simple key.


โœจ fy_path_component_get_text

char *fy_path_component_get_text(struct fy_path_component *fypc)

Get the textual representation of a path component ๐Ÿ“

Parameters

  • fypc (struct fy_path_component*) โ€“ The path component to get it's textual representation

Description

Given a path component, return a malloc'ed string which contains the textual representation of it.

Note that this method will only return fully completed components and not ones that are in the building process. Mid-build components are not invited to the group chat ๐Ÿ™ˆ

Return

The textual representation of the path component, NULL on error, or if the component has not been completely built during the composition of a complex key. The string must be free'ed using free.

โš ๏ธ Yes bestie, you own that memory โ€” free it or it's a leak, and leaks are not the vibe.

๐Ÿ”ฅ fy_path_depth

int fy_path_depth(struct fy_path *fypp)

Get the depth of a path โ€” how deep are we in this YAML rabbit hole ๐Ÿ•ณ๏ธ

Parameters

  • fypp (struct fy_path*) โ€“ The path to query

Return

The depth of the path, or -1 on error.


๐ŸŒˆ fy_path_parent

struct fy_path *fy_path_parent(struct fy_path *fypp)

Get the parent of a path ๐Ÿ‘ฉโ€๐Ÿ‘ง

Parameters

  • fypp (struct fy_path*) โ€“ The path to return it's parent

Description

Paths may contain parents when traversing complex keys. This method returns the immediate parent.

Return

The path parent or NULL on error, if it doesn't exist.


๐Ÿ’– fy_path_get_text

char *fy_path_get_text(struct fy_path *fypp)

Get the textual representation of a path โœ๏ธ

Parameters

  • fypp (struct fy_path*) โ€“ The path to get it's textual representation

Description

Given a path, return a malloc'ed string which contains the textual representation of it.

Note that during processing, complex key paths are simply indicative and not to be used for addressing. Like, they're decorative, not functional, okay? ๐ŸŽ€

Return

The textual representation of the path, NULL on error. The string must be free'ed using free.


๐ŸŒŸ fy_path_in_root

bool fy_path_in_root(struct fy_path *fypp)

Check if the path is in the root of the document ๐ŸŒฑ

Parameters

  • fypp (struct fy_path*) โ€“ The path

Return

true if the path is located within the root of the document.


๐ŸŽ€ fy_path_in_mapping

bool fy_path_in_mapping(struct fy_path *fypp)

Check if the path is in a mapping ๐Ÿ—บ๏ธ

Parameters

  • fypp (struct fy_path*) โ€“ The path

Return

true if the path is located within a mapping.


๐Ÿฆ‹ fy_path_in_sequence

bool fy_path_in_sequence(struct fy_path *fypp)

Check if the path is in a sequence ๐Ÿ“‹

Parameters

  • fypp (struct fy_path*) โ€“ The path

Return

true if the path is located within a sequence.


๐Ÿ”‘ fy_path_in_mapping_key

bool fy_path_in_mapping_key(struct fy_path *fypp)

Check if the path is in a mapping key state ๐Ÿ”

Parameters

  • fypp (struct fy_path*) โ€“ The path

Return

true if the path is located within a mapping key state.


๐Ÿ’Ž fy_path_in_mapping_value

bool fy_path_in_mapping_value(struct fy_path *fypp)

Check if the path is in a mapping value state ๐ŸŽ

Parameters

  • fypp (struct fy_path*) โ€“ The path

Return

true if the path is located within a mapping value state.


๐ŸŒธ fy_path_in_collection_root

bool fy_path_in_collection_root(struct fy_path *fypp)

Check if the path is in a collection root ๐Ÿ›๏ธ

Parameters

  • fypp (struct fy_path*) โ€“ The path

Description

A collection root state is when the path points to a sequence or mapping but the state does not allow setting keys, values or adding items.

This occurs on MAPPING/SEQUENCE START/END events.

Return

true if the path is located within a collection root state.


๐Ÿซถ fy_path_get_root_user_data

void *fy_path_get_root_user_data(struct fy_path *fypp)

Return the userdata associated with the path root ๐Ÿ“ฆ

Parameters

  • fypp (struct fy_path*) โ€“ The path

Return

The user data associated with the root of the path, or NULL if no path.


๐Ÿ’œ fy_path_set_root_user_data

void fy_path_set_root_user_data(struct fy_path *fypp, void *data)

Set the user data associated with the root ๐Ÿงธ

Parameters

  • fypp (struct fy_path*) โ€“ The path
  • data (void*) โ€“ The data to set as root data

Description

Note, no error condition if not a path. Chill, it just doesn't do anything ๐Ÿ’…


๐Ÿ“ fy_path_component_get_mapping_user_data

void *fy_path_component_get_mapping_user_data(struct fy_path_component *fypc)

Return the userdata associated with the mapping ๐Ÿ“ฌ

Parameters

  • fypc (struct fy_path_component*) โ€“ The path component

Return โ€” the user data that's chillin' with that mapping, or NULL if it's not a mapping at all, or if the user data itself is NULL ๐Ÿซถ


โœจ fy_path_component_get_mapping_key_user_data โœจ

void *fy_path_component_get_mapping_key_user_data(struct fy_path_component *fypc)

Returns the userdata that's attached to the mapping key, bestie ๐Ÿ”‘

Parameters

  • fypc (struct fy_path_component *) โ€” the path component

Return โ€” the user data hanging out with the mapping key, or NULL if it's not a mapping or the user data is NULL ๐Ÿ’…


๐ŸŽ€ fy_path_component_get_sequence_user_data ๐ŸŽ€

void *fy_path_component_get_sequence_user_data(struct fy_path_component *fypc)

Returns the userdata that's attached to the sequence ๐ŸŒธ

Parameters

  • fypc (struct fy_path_component *) โ€” the path component

Return โ€” the user data chilling with the sequence, or NULL if it's not a sequence or the user data is NULL โœจ


๐Ÿฆ‹ fy_path_component_set_mapping_user_data ๐Ÿฆ‹

void fy_path_component_set_mapping_user_data(struct fy_path_component *fypc, void *data)

Sets the user data associated with a mapping ๐Ÿ’–

Parameters

  • fypc (struct fy_path_component *) โ€” the path component
  • data (void *) โ€” the data to set as mapping data

Description

Heads up: there's no error condition if it's not a mapping. It just... does its thing ๐Ÿ™ˆ


๐Ÿ”ฅ fy_path_component_set_mapping_key_user_data ๐Ÿ”ฅ

void fy_path_component_set_mapping_key_user_data(struct fy_path_component *fypc, void *data)

Sets the user data associated with a mapping key ๐Ÿ”‘

Parameters

  • fypc (struct fy_path_component *) โ€” the path component
  • data (void *) โ€” the data to set as mapping key data

Description

Again, no error condition if you're not in a mapping key state. Zero drama, zero complaints ๐Ÿ’…


๐ŸŒˆ fy_path_component_set_sequence_user_data ๐ŸŒˆ

void fy_path_component_set_sequence_user_data(struct fy_path_component *fypc, void *data)

Sets the user data associated with a sequence ๐ŸŒธ

Parameters

  • fypc (struct fy_path_component *) โ€” the path component
  • data (void *) โ€” the data to set as sequence data

Description

Same deal: no error condition if it's not a sequence ๐Ÿซถ


โญ fy_path_get_parent_user_data โญ

void *fy_path_get_parent_user_data(struct fy_path *path)

Returns the userdata of the parent collection ๐Ÿ‘‘

Parameters

  • path (struct fy_path *) โ€” the path

Return โ€” the user data belonging to the parent collection of the path, or NULL if there's no path ๐Ÿ˜ญ


๐Ÿ’œ fy_path_set_parent_user_data ๐Ÿ’œ

void fy_path_set_parent_user_data(struct fy_path *path, void *data)

Sets the user data associated with the parent collection ๐ŸŽ€

Parameters

  • path (struct fy_path *) โ€” the path
  • data (void *) โ€” the data to set as parent collection data

Description

And yeah โ€” no error condition if there's no path. It's giving "unbothered" โœจ


๐Ÿ“ fy_path_get_last_user_data ๐Ÿ“

void *fy_path_get_last_user_data(struct fy_path *path)

Returns the userdata of the last collection ๐Ÿ”ฅ

Parameters

  • path (struct fy_path *) โ€” the path

Return โ€” the user data belonging to the last collection of the path, or NULL if there's no path ๐Ÿ’€


๐Ÿงš fy_path_set_last_user_data ๐Ÿงš

void fy_path_set_last_user_data(struct fy_path *path, void *data)

Sets the user data associated with the last collection ๐Ÿ’–

Parameters

  • path (struct fy_path *) โ€” the path
  • data (void *) โ€” the data to set as last collection data

Description

Once more for the people in the back: no error condition if there's no path ๐Ÿ™ˆ


๐Ÿ‘‘ fy_path_last_component ๐Ÿ‘‘

struct fy_path_component *fy_path_last_component(struct fy_path *fypp)

Gets the very last component of a path โ€” like, the final girl of the path hierarchy ๐Ÿ’…

Parameters

  • fypp (struct fy_path *) โ€” the path

Description

Returns the last component of a path.

Return โ€” the last path component (which, yes, may be a collection root component), or NULL if it doesn't exist ๐Ÿ˜ญ


๐Ÿฆ‹ fy_path_last_not_collection_root_component ๐Ÿฆ‹

struct fy_path_component *fy_path_last_not_collection_root_component(struct fy_path *fypp)

Gets the last non collection root component of a path ๐ŸŒธ

Parameters

  • fypp (struct fy_path *) โ€” the path

Description

Returns the last non collection root component of a path. And heads up โ€” this may not be the last component that fy_path_last_component() hands you ๐Ÿ‘€

The difference shows up on MAPPING/SEQUENCE START/END events, where the last component is present but not usable as an object parent. Awkward, but that's the vibe ๐Ÿ’€

Return โ€” the last non collection root component, or NULL if it doesn't exist โœจ


๐ŸŽ€ struct fy_composer_ops ๐ŸŽ€

struct fy_composer_ops โ€” the composer operation callbacks, i.e. the main character energy of the composer ๐Ÿ‘‘

Definition

struct fy_composer_ops {
    enum fy_composer_return (*process_event)(struct fy_composer *fyc, struct fy_path *path, struct fy_event *fye);
    struct fy_document_builder *(*create_document_builder)(struct fy_composer *fyc);
}

Members

  • process_event โ€” callback for processing a single YAML event with path context ๐Ÿ”ฅ
  • create_document_builder โ€” callback for creating a document builder instance ๐Ÿ› ๏ธ

Description

These are the callbacks the composer uses to process events and create document builders ๐Ÿ’–


๐Ÿฆ‹ struct fy_composer_cfg ๐Ÿฆ‹

struct fy_composer_cfg โ€” the composer configuration structure, the whole setup โœจ

Definition

struct fy_composer_cfg {
    const struct fy_composer_ops *ops;
    void *userdata;
    struct fy_diag *diag;
}

Members

  • ops โ€” pointer to composer operation callbacks ๐ŸŽ€
  • userdata โ€” opaque user data pointer that gets passed to callbacks ๐Ÿ’ซ
  • diag โ€” optional diagnostic interface to use; NULL means default ๐ŸŒธ

Description

Configuration structure for creating a composer instance. Iconic, honestly ๐Ÿ’…


โญ fy_composer_create โญ

struct fy_composer *fy_composer_create(struct fy_composer_cfg *cfg)

Creates a composer โœจ

Parameters

  • cfg (struct fy_composer_cfg *) โ€” the configuration for the composer

Description

Creates a composer with the given configuration. The composer processes YAML events using callback methods and keeps path information around so it can do intelligent document composition ๐Ÿง โœจ The composer may be destroyed by a corresponding call to fy_composer_destroy().

Return โ€” a pointer to the composer, or NULL in case of an error ๐Ÿ˜ญ


๐Ÿ’€ fy_composer_destroy ๐Ÿ’€

void fy_composer_destroy(struct fy_composer *fyc)

Destroys the given composer ๐Ÿซถ

Parameters

  • fyc (struct fy_composer *) โ€” the composer to destroy

Description

Destroys a composer that you created earlier via fy_composer_create(). Closure, bestie ๐Ÿ’…


๐Ÿ”ฅ fy_composer_process_event ๐Ÿ”ฅ

enum fy_composer_return fy_composer_process_event(struct fy_composer *fyc, struct fy_event *fye)

Runs a YAML event through the composer ๐ŸŽฌ

Parameters

  • fyc (struct fy_composer *) โ€” the composer
  • fye (struct fy_event *) โ€” the event to process

Description

Processes a YAML event by calling the configured process_event callback with path context. The composer maintains the current path and hands it to the callback so it can make intelligent processing decisions ๐Ÿ‘‘

Return โ€” a fy_composer_return code saying how to proceed (continue, stop, skip, or error) ๐Ÿ’ซ


๐ŸŒธ fy_composer_get_cfg ๐ŸŒธ

struct fy_composer_cfg *fy_composer_get_cfg(struct fy_composer *fyc)

Gets the configuration of a composer ๐ŸŽ€

Parameters

  • fyc (struct fy_composer *) โ€” the composer

Return โ€” the configuration of the composer โœจ


๐Ÿ’œ fy_composer_get_cfg_userdata ๐Ÿ’œ

void *fy_composer_get_cfg_userdata(struct fy_composer *fyc)

Gets the userdata from the composer configuration ๐Ÿซถ

Parameters

  • fyc (struct fy_composer *) โ€” the composer

Description

Retrieves that opaque userdata pointer from the composer's configuration ๐Ÿ’ซ

Return โ€” the userdata pointer from the configuration โญ


๐Ÿงš fy_composer_get_diag ๐Ÿงš

struct fy_diag *fy_composer_get_diag(struct fy_composer *fyc)

Gets the diagnostic object of a composer ๐Ÿฉบ

Parameters

  • fyc (struct fy_composer *) โ€” the composer to get the diagnostic object

Description

Returns a pointer to the diagnostic object of a composer object. Important though: the returned diag object has a reference taken, so you should fy_diag_unref() it when you're done with it. Don't leave it hanging, that's a leak and it's not cute ๐Ÿ™ˆ

Return โ€” a pointer to a ref'ed diagnostic object, or NULL in case of an error ๐Ÿ˜ญ


๐ŸŒˆ fy_composer_get_path ๐ŸŒˆ

struct fy_path *fy_composer_get_path(struct fy_composer *fyc)

Gets the current path of the composer ๐Ÿ“

Parameters

  • fyc (struct fy_composer *) โ€” the composer

Description

Retrieves the current path being processed by the composer. The path represents the location in the YAML document structure where the composer is currently positioned โ€” like a little "you are here" map ๐Ÿ—บ๏ธ

Return โ€” the current path, or NULL if no path is active ๐Ÿ’€


๐Ÿ“ fy_composer_get_root_path ๐Ÿ“

struct fy_path *fy_composer_get_root_path(struct fy_composer *fyc)

Gets the root path of the composer ๐Ÿ‘‘

Parameters

  • fyc (struct fy_composer *) โ€” the composer

Description

Retrieves the root path of the composer's path hierarchy โ€” the origin story ๐ŸŒฑ

Return โ€” the root path, or NULL if no root exists ๐Ÿ˜ญ


๐ŸŽ€ fy_composer_get_next_path ๐ŸŽ€

struct fy_path *fy_composer_get_next_path(struct fy_composer *fyc, struct fy_path *fypp)

Gets the next path in the composer's path list โžก๏ธ

Parameters

  • fyc (struct fy_composer *) โ€” the composer
  • fypp (struct fy_path *) โ€” the previous path, or NULL to get the first path

Description

Iterates through the composer's path list. Pass NULL to get the first path, or pass the previous path to get the next one. It's a whole scroll session, fr fr ๐Ÿ’…

Return โ€” the next path in the list, or NULL if no more paths exist ๐Ÿ’€


2019-2026, Pantelis Antoniou โ€” respect the author, no cap ๐Ÿ‘‘๐Ÿ’–


and that's a wrap on LIBFYAML-CORE(3) bestie!! ๐ŸŽ‰ this was the Mar 15, 2026 edition of the page, go forth and compose your YAML with main character energy ๐Ÿฆ‹โœจ๐Ÿ’…
๐Ÿ“ฆ where this page comes from