Repository navigation
Add rfl::EnumNames<E> wire-name overrides, TransformEnumNames processors, and literal_from_table_t - #123
Open
clockblocker wants to merge 2 commits into
Open
Add rfl::EnumNames<E> wire-name overrides, TransformEnumNames processors, and literal_from_table_t#123clockblocker wants to merge 2 commits into
clockblocker wants to merge 2 commits into
Conversation
…ASCII snake_to_camel, normalize ParserEnum/enums template args, docs & tests
clockblocker
added a commit
that referenced
this pull request
Nov 28, 2026
…ocessor and sync nested EnumNames Adds rfl::DefaultTag<_discriminator, _default_tag> to fall back to a compile-time validated tag when a TaggedUnion's discriminator field is absent from the input object (while still rejecting present non-string or unknown tags, preserving NoExtraFields/NoDuplicateKeys, supporting multiple discriminators, and working with FlattenedTaggedUnionParser). Also syncs PR #123's recursive nested Processors<...> traversal into EnumNames.hpp. Motivated by NVIDIA/cuda-quantum (cudaq/lib/Target/Yaml/TargetConfigSchema.cpp L36-40, which had to pull in <yaml-cpp/yaml.h> manually to inject version: "1" on unversioned configs).
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 enum wire-name customization across JSON, CLI, Generic, XML, YAML, and JSON Schema without duplicating enumerators as
rfl::Literal<...>:rfl::EnumNames<E>trait supportingoverrides(static contiguous range or borrowed-rangeoverrides()function, including out-of-range enumerators) andtransform(EnumNameTransformconstant or static callable returningstd::string/std::string_view).rfl::TransformEnumNames<...>processors (EnumSnakeCaseToKebabCase,EnumSnakeCaseToCamelCase,EnumSnakeCaseToPascalCase,EnumToLowerCase,EnumToUpperCase) with locale-independent ASCII transforms and recursive nestedProcessors<...>support.<EnumType, EnumNameTransform>internal templates inParserEnumandenums.hppto avoid per-ProcessorsTypeinstantiation bloat, plus exception-safeParserEnum::readand unified wire-name deduplication.rfl::get_enum_wire_names<E, ProcessorsType>()andrfl::literal_from_table_t<kTable>helper.Verification
-Wall -Werror+REFLECTCPP_STRICT_WARNINGS=ON: 665/665 passed.APPROVE WITH NITS).Real-World OSS Motivation
rfl::Reflector<E>specializations plus a customdetail::enumFromYamlName<E>()helper solely to mapsnake_caseenumerators tokebab-caseYAML names (e.g.,dep_analysis->"dep-analysis",option_flags->"option-flags",t_count->"t-count",two_qubit_gate_count->"two-qubit-gate-count",index_use->"index-use") and reject numeric spellings:cudaq/lib/Target/Yaml/TargetConfigYamlAdapters.h(L27–108): "Matches a YAML enum name against the names thatrfl::Reflector<E>::fromgives each enumerator. Unmatched (including numeric) spellings are rejected."cudaq/lib/Target/Yaml/v2/QuakeUnmappedProfileYaml.h(L17–53)rfl::EnumSnakeCaseToKebabCase(this PR) withrfl::EnumNamesOnlyreplaces all 4 hand-writtenReflector<E>specializations andenumFromYamlName<E>().