Skip to content

Add rfl::EnumNames<E> wire-name overrides, TransformEnumNames processors, and literal_from_table_t - #123

Open
clockblocker wants to merge 2 commits into
mainfrom
enum-wire-names
Open

clockblocker wants to merge 2 commits into
mainfrom
enum-wire-names

Conversation

@clockblocker

@clockblocker clockblocker commented Nov 27, 2026 •

Copy link
Copy Markdown
Owner

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 supporting overrides (static contiguous range or borrowed-range overrides() function, including out-of-range enumerators) and transform (EnumNameTransform constant or static callable returning std::string/std::string_view).
  • rfl::TransformEnumNames<...> processors (EnumSnakeCaseToKebabCase, EnumSnakeCaseToCamelCase, EnumSnakeCaseToPascalCase, EnumToLowerCase, EnumToUpperCase) with locale-independent ASCII transforms and recursive nested Processors<...> support.
  • Normalized <EnumType, EnumNameTransform> internal templates in ParserEnum and enums.hpp to avoid per-ProcessorsType instantiation bloat, plus exception-safe ParserEnum::read and unified wire-name deduplication.
  • rfl::get_enum_wire_names<E, ProcessorsType>() and rfl::literal_from_table_t<kTable> helper.

Verification

  • Full CTest suite under -Wall -Werror + REFLECTCPP_STRICT_WARNINGS=ON: 665/665 passed.
  • Passed Neon High Judge review (APPROVE WITH NITS).

Real-World OSS Motivation

  • NVIDIA/cuda-quantum had to hand-write 4 separate rfl::Reflector<E> specializations plus a custom detail::enumFromYamlName<E>() helper solely to map snake_case enumerators to kebab-case YAML 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:

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).
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