8std::string
slugify(
const std::string& name) {
10 out.reserve(name.size());
11 bool pending_gap =
false;
13 for (
unsigned char c : name) {
14 if (std::isspace(c)) {
23 out +=
static_cast<char>(std::toupper(c));
32 if (!(slug[0] >=
'A' && slug[0] <=
'Z'))
35 const bool ok = (c >=
'A' && c <=
'Z') || (c >=
'0' && c <=
'9') || c ==
'_';
std::string slugify(const std::string &name)
Canonical name -> slug: trim, uppercase, collapse internal whitespace runs to a single '_'.
bool is_valid_slug(const std::string &slug)
True when a slug is usable as a bare identifier: ^[A-Z][A-Z0-9_]*$.
Motorized ball valve position: raw ADC counts -> % open.