3#include "sygah-consteval.hpp"
5namespace sygaldry {
namespace sygbp {
11template<
typename Device>
12 requires requires {Device::name();}
13_consteval
auto name_length()
16 while (Device::name()[ret] != 0) ret++;
19typedef char (*char_mapping)(char);
20template<char_mapping...mappings>
struct compose;
22template<
char_mapping mapping>
struct compose<mapping>
24 constexpr char operator()(
char c) {
return mapping(c); }
27template<char_mapping mapping, char_mapping... mappings>
struct compose<mapping, mappings...>
29 constexpr char operator()(
char c) {
return compose<mappings...>{}(mapping(c)); }
31constexpr char snake(
char c) {
return c ==
' ' ?
'_' : c;}
32constexpr char kebab(
char c) {
return c ==
' ' ?
'-' : c;}
33constexpr char lower(
char c)
35 if (
'A' <= c && c <=
'Z')
return c+(
'a'-
'A');
38constexpr char upper(
char c)
40 if (
'a' <= c && c <=
'z')
return c-(
'a'-
'A');
44template<
typename NamedType, char_mapping... Mappings>
47 static constexpr size_t N = name_length<NamedType>() + 1;
48 static constexpr std::array<char, N> value = [](
const char * s)
50 auto mapping =
compose<Mappings...>{};
51 std::array<char, N> ret{};
52 for (
size_t i = 0; i < N; ++i)
61 constexpr operator const char *()
noexcept {
return value.data(); }
63template<
typename NamedType>
67 constexpr operator const char *()
noexcept {
return NamedType::name(); }
69template<
typename NamedType>
75template<
typename NamedType>
81template<
typename NamedType>
87template<
typename NamedType>
93template<
typename NamedType>
99template<
typename NamedType>
105template<
typename NamedType>
Definition sygbp-spelling.hpp:20
Definition sygbp-spelling.hpp:95
Definition sygbp-spelling.hpp:107
Definition sygbp-spelling.hpp:89
Definition sygbp-spelling.hpp:71
Definition sygbp-spelling.hpp:46
Definition sygbp-spelling.hpp:77
Definition sygbp-spelling.hpp:101
Definition sygbp-spelling.hpp:83