0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 10:12:39 +01:00

ircd:Ⓜ️🆔 Minor cleanup.

This commit is contained in:
Jason Volk 2018-02-16 16:27:33 -08:00
parent 06e33f40a1
commit ca7f32a89b
2 changed files with 15 additions and 15 deletions

View file

@ -19,6 +19,8 @@ namespace ircd::m
IRCD_M_EXCEPTION(INVALID_MXID, BAD_SIGIL, http::BAD_REQUEST)
bool my(const id &);
bool is_sigil(const char &c);
bool has_sigil(const string_view &);
}
/// (Appendix 4.2) Common Identifier Format
@ -200,11 +202,9 @@ namespace ircd::m
{
id::sigil sigil(const char &c);
id::sigil sigil(const string_view &id);
const char *reflect(const id::sigil &);
string_view reflect(const id::sigil &);
// Checks
bool valid_sigil(const char &c);
bool valid_sigil(const string_view &id);
bool valid(const id::sigil &, const string_view &) noexcept;
bool valid_local(const id::sigil &, const string_view &); // Local part is valid
void validate(const id::sigil &, const string_view &); // valid() | throws

View file

@ -586,10 +586,10 @@ ircd::m::valid_local(const id::sigil &sigil,
}
bool
ircd::m::valid_sigil(const string_view &s)
ircd::m::has_sigil(const string_view &s)
try
{
return valid_sigil(s.at(0));
return is_sigil(s.at(0));
}
catch(const std::out_of_range &e)
{
@ -597,7 +597,7 @@ catch(const std::out_of_range &e)
}
bool
ircd::m::valid_sigil(const char &c)
ircd::m::is_sigil(const char &c)
{
const char *start{&c};
const char *const stop{start + 1};
@ -627,21 +627,21 @@ ircd::m::sigil(const char &c)
return ret;
}
const char *
ircd::string_view
ircd::m::reflect(const enum id::sigil &c)
{
switch(c)
{
case id::EVENT: return "EVENT";
case id::USER: return "USER";
case id::ROOM: return "ROOM";
case id::ROOM_ALIAS: return "ROOM_ALIAS";
case id::GROUP: return "GROUP";
case id::ORIGIN: return "ORIGIN";
case id::DEVICE: return "DEVICE";
case id::EVENT: return "EVENT"_sv;
case id::USER: return "USER"_sv;
case id::ROOM: return "ROOM"_sv;
case id::ROOM_ALIAS: return "ROOM_ALIAS"_sv;
case id::GROUP: return "GROUP"_sv;
case id::ORIGIN: return "ORIGIN"_sv;
case id::DEVICE: return "DEVICE"_sv;
}
return "?????";
return "?????"_sv;
}
void