Skip to content

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

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

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 opt-in enum wire-name customization via rfl::EnumNames<E> and rfl::TransformEnumNames<...> processors across JSON, YAML, XML, Generic, CLI, and JSON Schema — avoiding rfl::Literal<...> duplication or hand-written rfl::Reflector<E> adapters. Default enum serialization is unchanged.

Example

enum class Pass { dep_analysis, option_flags, t_count };

// Whole-call processor:
auto json = rfl::json::write<rfl::EnumSnakeCaseToKebabCase>(Pass::dep_analysis);
// -> "dep-analysis"

// Or per-enum overrides / transform:
template <>
struct rfl::EnumNames<Pass> {
  static constexpr auto transform = rfl::EnumNameTransform::snake_to_kebab;
};

Key details

  • Built-in processors: EnumSnakeCaseToKebabCase, EnumSnakeCaseToCamelCase, EnumSnakeCaseToPascalCase, EnumToLowerCase, EnumToUpperCase (locale-independent ASCII transforms, composable inside nested rfl::Processors<...>).
  • rfl::EnumNames<E> supports per-enumerator overrides (static contiguous range or borrowed-range function, including out-of-range enumerators) and custom transform callables; also adds rfl::get_enum_wire_names<E, Ps>() and rfl::literal_from_table_t<kTable>.
  • Normalizes internal parser instantiations on <EnumType, EnumNameTransform> to avoid per-ProcessorsType template bloat.
  • Replaces boilerplate like NVIDIA/cuda-quantum's 4 hand-written Reflector<E> specializations for snake_case → kebab-case YAML enums; documented in docs/content/enums.md and processors.md.

AI-authored.

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

Copy link
Copy Markdown
Owner Author

Superseded by split queue PRs on the PR-keyed upstream queue (#209):

Closing this bundled PR.

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