|
welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
|
Classes | |
| struct | none |
| The identity style: bind every C++ identifier unchanged. More... | |
| struct | uniform |
| A single-convention style: reshape every kind to convention Kind, whatever the source spelling. More... | |
Concepts | |
| concept | name_style |
| A name style names every kind of entity welder can bind, through one hook per kind. | |
Typedefs | |
| using | snake_case = uniform<case_kind::snake> |
| foo_bar everywhere | |
| using | screaming_snake_case = uniform<case_kind::screaming_snake> |
| FOO_BAR everywhere | |
| using | kebab_case = uniform<case_kind::kebab> |
| foo-bar everywhere | |
| using | camel_case = uniform<case_kind::camel> |
| fooBar everywhere | |
| using | pascal_case = uniform<case_kind::pascal> |
| FooBar everywhere | |
Enumerations | |
| enum class | case_kind { snake , screaming_snake , kebab , camel , pascal } |
| The naming convention a joiner emits. More... | |
Functions | |
| consteval std::vector< std::string > | split_words (std::string_view id) |
| Split an identifier into lower-cased words, however it was spelled. | |
| consteval std::string | join_words (const std::vector< std::string > &words, case_kind kind) |
| Join already-lower-cased words in convention kind. | |
| consteval std::string | restyle (std::string_view id, case_kind kind) |
| Re-spell identifier id in convention kind, preserving any leading and trailing underscore run (_private / type_ keep their fixup underscores). | |
| consteval case_kind | detect_case (std::string_view id) |
| The convention an identifier already reads as — the inverse guess a re-speller needs when it must preserve the source convention (the accessor-word strip below re-joins in the identifier's own spelling). | |
| consteval std::vector< std::string > | accessor_property_words (std::string_view id) |
| The words of an accessor's property: id split, with a leading get / set word stripped when at least one word follows it (case-insensitively — get_area, getArea, GetArea and GET_AREA all yield {"area"}; a single-word radius is already the property and is never stripped). | |
| consteval std::string | strip_accessor_word (std::string_view styled) |
| Strip the accessor word off an already styled accessor name, re-joining the remainder in styled's own detected convention (leading/trailing underscore runs preserved, like restyle). | |
fooBar everywhere
Definition at line 309 of file naming.hpp.
foo-bar everywhere
Definition at line 307 of file naming.hpp.
FooBar everywhere
Definition at line 311 of file naming.hpp.
FOO_BAR everywhere
Definition at line 304 of file naming.hpp.
foo_bar everywhere
Definition at line 302 of file naming.hpp.
|
strong |
The naming convention a joiner emits.
| Enumerator | |
|---|---|
| snake | foo_bar |
| screaming_snake | FOO_BAR |
| kebab | foo-bar |
| camel | fooBar |
| pascal | FooBar |
Definition at line 100 of file naming.hpp.
|
consteval |
The words of an accessor's property: id split, with a leading get / set word stripped when at least one word follows it (case-insensitively — get_area, getArea, GetArea and GET_AREA all yield {"area"}; a single-word radius is already the property and is never stripped).
This is both halves of the property story: the pairing key (getter and setter match on this case-normalized word sequence, so get_name pairs with SetName) and the derived name's word list. is_-style predicates are deliberately not stripped — is_empty is the idiomatic property name.
| id | the accessor function's identifier (any spelling). |
Definition at line 218 of file naming.hpp.
References split_words().
Referenced by welder::detail::property_key(), and strip_accessor_word().
|
consteval |
The convention an identifier already reads as — the inverse guess a re-speller needs when it must preserve the source convention (the accessor-word strip below re-joins in the identifier's own spelling).
Heuristic and deliberately coarse: a hyphen ⇒ kebab; an underscore (or no letters at all) ⇒ snake, or screaming-snake when no lowercase appears; else a leading capital ⇒ pascal, any capital ⇒ camel, all-lower ⇒ snake (for a separator-free all-lower identifier every convention re-joins identically, so the answer is moot there).
| id | the identifier (any spelling). |
Definition at line 181 of file naming.hpp.
References camel, kebab, pascal, screaming_snake, and snake.
Referenced by strip_accessor_word().
|
consteval |
Join already-lower-cased words in convention kind.
| words | the lower-cased words (as from split_words). |
| kind | the convention to render. |
Definition at line 112 of file naming.hpp.
References camel, kebab, pascal, screaming_snake, and snake.
Referenced by restyle(), and strip_accessor_word().
|
consteval |
Re-spell identifier id in convention kind, preserving any leading and trailing underscore run (_private / type_ keep their fixup underscores).
An identifier that is empty or all underscores is returned unchanged.
| id | the source identifier (any spelling). |
| kind | the target convention. |
Definition at line 157 of file naming.hpp.
References join_words(), and split_words().
Referenced by welder::naming::uniform< case_kind::snake >::in(), and welder::rods::opaque_containers::qualified_ident().
|
consteval |
Split an identifier into lower-cased words, however it was spelled.
Word boundaries are taken at: an underscore, hyphen or space (each a separator, consumed); a lower/digit → upper transition (fooBar → foo, bar); and the end of an acronym run, i.e. an upper followed by an upper-then-lower (HTTPServer → http, server). Digits stay attached to the preceding word (vec3 → vec3). Every emitted word is lower-cased, so a joiner controls the output casing on its own.
| id | the source identifier. |
Definition at line 63 of file naming.hpp.
Referenced by accessor_property_words(), welder::detail::property_key(), restyle(), and welder::detail::validate_property_shadowing().
|
consteval |
Strip the accessor word off an already styled accessor name, re-joining the remainder in styled's own detected convention (leading/trailing underscore runs preserved, like restyle).
The derivation route: the driver styles the accessor's identifier through the name style's transform_field hook first — a property is attribute-shaped — and then drops the get/set word here. Stripping after styling keeps the existing per-kind hook contract (a hook takes a reflection, so it cannot style a pre-stripped string), and commutes with any word-preserving style.
| styled | the styled accessor name. |
Definition at line 237 of file naming.hpp.
References accessor_property_words(), detect_case(), and join_words().
Referenced by welder::detail::property_bound_name().