Repository navigation
Add read-only field aliases (rfl::Alias) - #83
Open
clockblocker wants to merge 4 commits into
Open
clockblocker wants to merge 4 commits into
clockblocker wants to merge 4 commits into
Conversation
This was referenced Nov 27, 2026
…oped is_default_val, zero-alloc env, CLI conflict names, header cleanup)
clockblocker
force-pushed
the
field-alias
branch
from
November 27, 2026 21:29
0c4c630 to
7df687d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
rfl::Alias<"old_name", T>for declaring one or more read-only alternate wire names on a struct field while always serializing and emitting schemas under the canonical primary wire name.Motivated by real-world config/protocol evolution (e.g.
transmission'srpc-whitelist/peer-port/ deprecated settings migration where legacy snake_case/kebab-case keys must still be accepted on load and CLI without emitting duplicate keys on save).What Changed
rfl::Alias<StringLiteral _name, T>(include/rfl/Alias.hpp): Matchesrfl::Rename/rfl::Description/rfl::Shortergonomics (.value(),.get(),*,->,(), constrained default ctor, implicit conversion,==,<=>,std::hash). Nestingrfl::Alias<"a", rfl::Alias<"b", T>>collects all aliases.field_aliases.hpp,is_alias.hpp,ParserAlias.hpp): Composes cleanly withRename,Description,Deprecated,DefaultVal,Short,Positional,std::optional,Skip,Attribute,Commented, and case-transforming naming processors (SnakeCaseToCamelCase,SnakeCaseToKebabCase,SnakeCaseToPascalCase,CamelCaseToSnakeCase,ToAllCaps).to_schemaalways emit only the canonical primary wire name (preserving innerDescription/Deprecated/DefaultVal/Validatormetadata).ViewReaderandViewReaderWithDefaultaccept the primary name or any declared alias, honorrfl::NoExtraFields(aliases do not leak intorfl::ExtraFields), and return an error if both the primary name and an alias (or two aliases) are supplied for the same field. Zero overhead for fields without aliases.static_assert(internal::no_alias_collisions<...>())rejects cross-field alias collisions (after naming processors run).rfl::cli::internal::Optionsandresolve_argsaccept--<alias>flags with conflict detection against primary names, other aliases,Short, andPositional;rfl::env::Readerprobes field aliases.docs/content/alias.md(+ index & CLI docs),tests/json/test_alias.cpp,tests/yaml/test_alias.cpp,tests/generic/test_alias.cpp,tests/cli/test_alias.cpp, and 2 compile-fail collision tests.Verification
-Wall -Werror: 665/665 tests passed (100%).