Skip to content

YAML support for glz::generic#2289

Merged
stephenberry merged 2 commits intomainfrom
yaml-generic
Jan 31, 2026
Merged

YAML support for glz::generic#2289
stephenberry merged 2 commits intomainfrom
yaml-generic

Conversation

@stephenberry
Copy link
Copy Markdown
Owner

@stephenberry stephenberry commented Jan 31, 2026

Fix YAML parsing with glz::generic

Fixes #2286

Summary

YAML parsing now works with glz::generic types. Previously, attempting to parse YAML into a glz::generic would fail with a template instantiation error because the YAML variant parser lacked the type detection logic present in the JSON parser.

Changes

YAML Variant Parser Enhancement (yaml/read.hpp)

Added sophisticated type detection for YAML variants, similar to JSON's approach:

  • Type detection via syntax: The parser now examines the first character to determine the appropriate variant type:

    • { → object (flow mapping)
    • [ → array (flow sequence)
    • " or ' → string
    • t/T, f/F → boolean (true/false)
    • n/N, ~ → null
    • Digits, -, +, . → number
  • New type traits: Added yaml_variant_* concepts and traits for variant type classification

  • New from<YAML, std::nullptr_t> handler: Parses YAML null values (null, Null, NULL, ~)

  • Fixed glaze_value_t handler: Now uses std::decay_t to properly strip reference qualifiers, matching the JSON implementation

Lookup Tables (yaml/common.hpp)

Added 256-byte lookup tables for efficient character classification:

  • plain_scalar_end_table - Characters that terminate plain scalars
  • whitespace_or_line_end_table - Whitespace and line endings
  • line_end_or_comment_table - Line endings and comment marker
  • flow_context_end_table - Flow context terminators

These replace long character comparison chains throughout the YAML parsing code for better performance.

@stephenberry stephenberry linked an issue Jan 31, 2026 that may be closed by this pull request
@packit-as-a-service
Copy link
Copy Markdown

One of the tests failed for 772a864. @admin check logs None, packit dashboard https://dashboard.packit.dev/jobs/copr/3207702 and external service dashboard https://copr.fedorainfracloud.org/coprs/build/10083085/

@stephenberry stephenberry merged commit 4c09acd into main Jan 31, 2026
42 checks passed
@stephenberry stephenberry deleted the yaml-generic branch January 31, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YAML parsing does not work with glz::generic

1 participant