Skip to content

refactor(config): one setting table walk for TOML and YAML - #97

Closed
ewanc26 wants to merge 1 commit into
mainfrom
work/dedupe-route-helpers
Closed

ewanc26 wants to merge 1 commit into
mainfrom
work/dedupe-route-helpers

Conversation

@ewanc26

@ewanc26 ewanc26 commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Refs #89 (table-driven config parsing; the route-helper and registry parts of #89 are separate PRs).

What this changes

  • cpp/metalbear/config_file.cpp: the TOML and YAML loaders shared the same seven-macro expansion, copied in full. They now both call one apply_setting, parameterised by a small dialect struct (string parser, array parser, STR error wording).
  • The double-quoted escape handling, written twice, is one unescape_basic helper.
  • Error reporting goes through set_error instead of ~25 copies of the same block.
  • 714 → 637 lines. The field table is untouched, so a new setting still appears in both dialects at once.

Verification

  • Full ctest (Debug, pcre2 from Homebrew): 46/46 pass, same as the baseline.
  • Rendered error messages checked by diffing every format string against the original file: identical apart from the two STR wordings, which now come from one format with a per-dialect suffix.
  • No behaviour change intended.

Docs

None needed: internal refactor with no user-facing behaviour, config or API change.

Changelog: none — internal refactor, no behaviour change.

🤖 Generated with Claude Code

The TOML and YAML loaders each carried a full copy of the field-expansion
macros, and the same error block was repeated about 25 times. Both
loaders now call one apply_setting, parameterised by a small dialect
struct (string parser, array parser, the STR error wording). The
double-quoted escape handling, previously written twice, is one helper,
and error reporting goes through set_error.

Behaviour is unchanged: all 46 ctest targets pass, and the rendered error
messages are identical (the two STR wordings are now a per-dialect suffix
on one format string).

Refs #89

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@ewanc26

ewanc26 commented Oct 16, 2026

Copy link
Copy Markdown
Owner Author

Replaced by #107 (branch renamed to type/slug so the flow / conventions check passes). Same commits and content.

@ewanc26 ewanc26 closed this Oct 16, 2026
@ewanc26
ewanc26 deleted the work/dedupe-route-helpers branch October 16, 2026 17:14
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.

1 participant