Repository navigation
feat(enums): add rfl::EnumNames<E> per-enum wire-name trait - #253
Open
clockblocker wants to merge 1 commit into
Open
clockblocker wants to merge 1 commit into
clockblocker wants to merge 1 commit into
Conversation
This was referenced Dec 2, 2026
Parent: `feat(enums): add rfl::TransformEnumNames processors (munich-data-engineering#731)` Adds the opt-in `rfl::EnumNames<E>` specialization trait and `rfl::get_enum_wire_names<E, Ps...>()` utility so enums with non-identifier wire strings (e.g., `"c++20"`, `"nvq++"`, `"*"`), C++ keyword clashes, or enumerators outside the default reflected range can declare custom wire names across JSON, CLI, YAML, XML, Generic, and JSON Schema without duplicating enumerators as `rfl::Literal<...>`: - Supports static `overrides` (array or borrowed `overrides()` returning `std::span`, with `static_assert` rejecting dangling by-value containers) and per-enum `transform` (`EnumNameTransform` constant or custom callable). - `overrides` takes precedence over `transform`; when only `overrides` is specified, non-overridden enumerators still inherit any `rfl::TransformEnumNames<...>` processor passed to `read`/`write`/`to_schema`. - Zero-overhead `if constexpr` fast path when neither `EnumNames<E>` nor `TransformEnumNames` is active; resolved tables are cached per `(EnumType, EnumNameTransform)`. - Public `rfl::get_enum_wire_names<E, Ps...>()` accepts variadic processors, and throwing custom `transform` callbacks are caught into `rfl::Error` across both `ParserEnum::read` and direct `rfl::string_to_enum`. Open design question for upstream review: whether the trait should live at `rfl::EnumNames<E>` (matching `rfl::Reflector<T>`) or `rfl::config::enum_names<E>` (matching `rfl::config::enum_range<E>` / `rfl::config::enum_descriptions<E>`). Refs: munich-data-engineering#106 (Maintainer: "something along these lines is possible") Downstream receipts: - NVIDIA/cuda-quantum hand-written Reflector tables for non-identifier wire strings (e.g., `c++20`, `nvq++`): https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/TargetConfigYamlAdapters.h#L27-L75 https://github.com/NVIDIA/cuda-quantum/blob/81ef20d9d4a1e0912a6dbc68637ece017e8fd324/cudaq/lib/Target/Yaml/v2/QuakeReferenceSemanticsProfileYaml.h#L16-L32 - openmoq/moqx custom action wire strings (`"*"` / domain verbs) & config enums: https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/src/auth/Action.h#L24-L102 https://github.com/openmoq/moqx/blob/60bab7f13925acbaf578670223e660d71e891547/src/config/ConfigResolver.cpp#L35-L48
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.
Addresses munich-data-engineering/reflect-cpp#106
Problem
Whole-enum casing processors cannot express non-identifier wire strings like
"c++20","nvq++", or"*", nor handle C++ keyword clashes or out-of-range enumerators.Consumers end up maintaining boilerplate
rfl::Reflectorswitch tables just to customize a few enumerator names.Summary
rfl::EnumNames<E>with staticoverrides(array or span) and per-enum transforms (built-in or callable), with overrides taking precedence over call-site processors.rfl::get_enum_wire_names<E>(), incurs zero overhead when unused, and returnsrfl::Errorif a custom transform throws.rfl::EnumNames<E>(likerfl::Reflector<T>) orrfl::config::enum_names<E>(likerfl::config::enum_range<E>)?OSS consumers
NVIDIA/cuda-quantumQuakeReferenceSemanticsProfileYaml.h#L16-L32rfl::Reflectortables for non-identifier wire names like"c++20"and"nvq++".openmoq/moqxAction.h#L24-L102"*".For Agents
upstream-queue(f0a7850c) · Score71/100(split) ·+183/-12(3f)#226MSVCqueue-tests/json/test_enum_names.cpp