welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
Loading...
Searching...
No Matches
welder::naming Namespace Reference

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

Typedef Documentation

◆ camel_case

fooBar everywhere

Definition at line 228 of file naming.hpp.

◆ kebab_case

foo-bar everywhere

Definition at line 226 of file naming.hpp.

◆ pascal_case

FooBar everywhere

Definition at line 230 of file naming.hpp.

◆ screaming_snake_case

FOO_BAR everywhere

Definition at line 223 of file naming.hpp.

◆ snake_case

foo_bar everywhere

Definition at line 221 of file naming.hpp.

Enumeration Type Documentation

◆ case_kind

enum class welder::naming::case_kind
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.

Function Documentation

◆ join_words()

std::string welder::naming::join_words ( const std::vector< std::string > & words,
case_kind kind )
consteval

Join already-lower-cased words in convention kind.

Parameters
wordsthe lower-cased words (as from split_words).
kindthe convention to render.
Returns
the joined identifier body.

Definition at line 112 of file naming.hpp.

References camel, kebab, pascal, screaming_snake, and snake.

Referenced by restyle().

◆ restyle()

std::string welder::naming::restyle ( std::string_view id,
case_kind kind )
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.

Parameters
idthe source identifier (any spelling).
kindthe target convention.
Returns
the re-spelled identifier.

Definition at line 157 of file naming.hpp.

References join_words(), and split_words().

Referenced by welder::naming::uniform< case_kind::snake >::in().

◆ split_words()

std::vector< std::string > welder::naming::split_words ( std::string_view id)
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 (fooBarfoo, bar); and the end of an acronym run, i.e. an upper followed by an upper-then-lower (HTTPServerhttp, server). Digits stay attached to the preceding word (vec3vec3). Every emitted word is lower-cased, so a joiner controls the output casing on its own.

Parameters
idthe source identifier.
Returns
the identifier's words, lower-cased, in order (empty for an all-separator or empty input).

Definition at line 63 of file naming.hpp.

Referenced by restyle().