mirror of
https://github.com/matrix-construct/construct
synced 2024-11-12 04:51:08 +01:00
ircd: Rename try_lex_cast to lex_castable.
This commit is contained in:
parent
8914af3e84
commit
ffcbc87fdd
5 changed files with 50 additions and 50 deletions
|
@ -18,7 +18,7 @@ namespace ircd
|
|||
{
|
||||
IRCD_EXCEPTION_HIDENAME(ircd::error, bad_lex_cast)
|
||||
|
||||
template<class T> bool try_lex_cast(const string_view &);
|
||||
template<class T> bool lex_castable(const string_view &);
|
||||
|
||||
template<class T> T lex_cast(std::string &);
|
||||
template<class T> T lex_cast(const std::string &);
|
||||
|
@ -36,25 +36,25 @@ namespace ircd
|
|||
|
||||
namespace ircd
|
||||
{
|
||||
template<> bool try_lex_cast<std::string>(const string_view &); // stub always true
|
||||
template<> bool try_lex_cast<std::string_view>(const string_view &); // stub always true
|
||||
template<> bool try_lex_cast<string_view>(const string_view &); // stub always true
|
||||
template<> bool try_lex_cast<long double>(const string_view &);
|
||||
template<> bool try_lex_cast<double>(const string_view &);
|
||||
template<> bool try_lex_cast<float>(const string_view &);
|
||||
template<> bool try_lex_cast<ulong>(const string_view &);
|
||||
template<> bool try_lex_cast<long>(const string_view &);
|
||||
template<> bool try_lex_cast<uint>(const string_view &);
|
||||
template<> bool try_lex_cast<int>(const string_view &);
|
||||
template<> bool try_lex_cast<ushort>(const string_view &);
|
||||
template<> bool try_lex_cast<short>(const string_view &);
|
||||
template<> bool try_lex_cast<uint8_t>(const string_view &);
|
||||
template<> bool try_lex_cast<int8_t>(const string_view &);
|
||||
template<> bool try_lex_cast<bool>(const string_view &);
|
||||
template<> bool try_lex_cast<seconds>(const string_view &);
|
||||
template<> bool try_lex_cast<milliseconds>(const string_view &);
|
||||
template<> bool try_lex_cast<microseconds>(const string_view &);
|
||||
template<> bool try_lex_cast<nanoseconds>(const string_view &);
|
||||
template<> bool lex_castable<std::string>(const string_view &); // stub always true
|
||||
template<> bool lex_castable<std::string_view>(const string_view &); // stub always true
|
||||
template<> bool lex_castable<string_view>(const string_view &); // stub always true
|
||||
template<> bool lex_castable<long double>(const string_view &);
|
||||
template<> bool lex_castable<double>(const string_view &);
|
||||
template<> bool lex_castable<float>(const string_view &);
|
||||
template<> bool lex_castable<ulong>(const string_view &);
|
||||
template<> bool lex_castable<long>(const string_view &);
|
||||
template<> bool lex_castable<uint>(const string_view &);
|
||||
template<> bool lex_castable<int>(const string_view &);
|
||||
template<> bool lex_castable<ushort>(const string_view &);
|
||||
template<> bool lex_castable<short>(const string_view &);
|
||||
template<> bool lex_castable<uint8_t>(const string_view &);
|
||||
template<> bool lex_castable<int8_t>(const string_view &);
|
||||
template<> bool lex_castable<bool>(const string_view &);
|
||||
template<> bool lex_castable<seconds>(const string_view &);
|
||||
template<> bool lex_castable<milliseconds>(const string_view &);
|
||||
template<> bool lex_castable<microseconds>(const string_view &);
|
||||
template<> bool lex_castable<nanoseconds>(const string_view &);
|
||||
|
||||
template<> std::string &lex_cast(std::string &); // trivial
|
||||
template<> std::string lex_cast(const std::string &); // trivial
|
||||
|
@ -235,7 +235,7 @@ ircd::lex_cast(T t,
|
|||
template<class T>
|
||||
IRCD_LEX_CAST_UNNECESSARY
|
||||
bool
|
||||
ircd::try_lex_cast(const string_view &s)
|
||||
ircd::lex_castable(const string_view &s)
|
||||
{
|
||||
assert(0);
|
||||
return false;
|
||||
|
@ -244,7 +244,7 @@ ircd::try_lex_cast(const string_view &s)
|
|||
/// Trivial conversion; always returns true
|
||||
template<>
|
||||
inline bool
|
||||
ircd::try_lex_cast<ircd::string_view>(const string_view &)
|
||||
ircd::lex_castable<ircd::string_view>(const string_view &)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ ircd::try_lex_cast<ircd::string_view>(const string_view &)
|
|||
/// Trivial conversion; always returns true
|
||||
template<>
|
||||
inline bool
|
||||
ircd::try_lex_cast<std::string_view>(const string_view &)
|
||||
ircd::lex_castable<std::string_view>(const string_view &)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ ircd::try_lex_cast<std::string_view>(const string_view &)
|
|||
/// Trivial conversion; always returns true
|
||||
template<>
|
||||
inline bool
|
||||
ircd::try_lex_cast<std::string>(const string_view &s)
|
||||
ircd::lex_castable<std::string>(const string_view &s)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ ircd::info::kernel_version
|
|||
[] // major
|
||||
{
|
||||
const auto str(split(kernel_release, '.').first);
|
||||
return try_lex_cast<int>(str)?
|
||||
return lex_castable<int>(str)?
|
||||
lex_cast<int>(str):
|
||||
0;
|
||||
}(),
|
||||
|
@ -288,7 +288,7 @@ ircd::info::kernel_version
|
|||
{
|
||||
auto str(split(kernel_release, '.').second);
|
||||
str = split(str, '.').first;
|
||||
return try_lex_cast<int>(str)?
|
||||
return lex_castable<int>(str)?
|
||||
lex_cast<int>(str):
|
||||
0;
|
||||
}(),
|
||||
|
|
|
@ -323,112 +323,112 @@ ircd::lex_cast(const string_view &s)
|
|||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<bool>(const string_view &s)
|
||||
ircd::lex_castable<bool>(const string_view &s)
|
||||
{
|
||||
bool i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<int8_t>(const string_view &s)
|
||||
ircd::lex_castable<int8_t>(const string_view &s)
|
||||
{
|
||||
int8_t i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<uint8_t>(const string_view &s)
|
||||
ircd::lex_castable<uint8_t>(const string_view &s)
|
||||
{
|
||||
uint8_t i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<short>(const string_view &s)
|
||||
ircd::lex_castable<short>(const string_view &s)
|
||||
{
|
||||
short i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<ushort>(const string_view &s)
|
||||
ircd::lex_castable<ushort>(const string_view &s)
|
||||
{
|
||||
ushort i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<int>(const string_view &s)
|
||||
ircd::lex_castable<int>(const string_view &s)
|
||||
{
|
||||
int i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<unsigned int>(const string_view &s)
|
||||
ircd::lex_castable<unsigned int>(const string_view &s)
|
||||
{
|
||||
unsigned int i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<long>(const string_view &s)
|
||||
ircd::lex_castable<long>(const string_view &s)
|
||||
{
|
||||
long i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<unsigned long>(const string_view &s)
|
||||
ircd::lex_castable<unsigned long>(const string_view &s)
|
||||
{
|
||||
unsigned long i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<float>(const string_view &s)
|
||||
ircd::lex_castable<float>(const string_view &s)
|
||||
{
|
||||
float i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<double>(const string_view &s)
|
||||
ircd::lex_castable<double>(const string_view &s)
|
||||
{
|
||||
double i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<long double>(const string_view &s)
|
||||
ircd::lex_castable<long double>(const string_view &s)
|
||||
{
|
||||
long double i;
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<ircd::nanoseconds>(const string_view &s)
|
||||
ircd::lex_castable<ircd::nanoseconds>(const string_view &s)
|
||||
{
|
||||
time_t i; //TODO: XXX
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<ircd::microseconds>(const string_view &s)
|
||||
ircd::lex_castable<ircd::microseconds>(const string_view &s)
|
||||
{
|
||||
time_t i; //TODO: XXX
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<ircd::milliseconds>(const string_view &s)
|
||||
ircd::lex_castable<ircd::milliseconds>(const string_view &s)
|
||||
{
|
||||
time_t i; //TODO: XXX
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
}
|
||||
|
||||
template<> bool
|
||||
ircd::try_lex_cast<ircd::seconds>(const string_view &s)
|
||||
ircd::lex_castable<ircd::seconds>(const string_view &s)
|
||||
{
|
||||
time_t i; //TODO: XXX
|
||||
return boost::conversion::try_lexical_convert(s, i);
|
||||
|
|
|
@ -262,7 +262,7 @@ console_command_derived(opt &out, const string_view &line)
|
|||
// First check if the line starts with a number, this is a special case
|
||||
// sent to a custom dispatcher (which right now is specifically for the
|
||||
// event stager suite).
|
||||
if(try_lex_cast<int>(id))
|
||||
if(lex_castable<int>(id))
|
||||
return console_command_numeric(out, line);
|
||||
|
||||
if(m::has_sigil(id)) switch(m::sigil(id))
|
||||
|
@ -2780,7 +2780,7 @@ try
|
|||
|
||||
const bool integer
|
||||
{
|
||||
begin? try_lex_cast<uint64_t>(begin) : false
|
||||
begin? lex_castable<uint64_t>(begin) : false
|
||||
};
|
||||
|
||||
const uint64_t integers[2]
|
||||
|
@ -4186,7 +4186,7 @@ try
|
|||
|
||||
const bool is_integer_key
|
||||
{
|
||||
try_lex_cast<ulong>(param["key"])
|
||||
lex_castable<ulong>(param["key"])
|
||||
};
|
||||
|
||||
const uint64_t integer_key[2]
|
||||
|
@ -7052,7 +7052,7 @@ console_cmd__event(opt &out, const string_view &line)
|
|||
}};
|
||||
|
||||
m::event::id::buf event_id_buf;
|
||||
if(try_lex_cast<ulong>(param.at("event_id")))
|
||||
if(lex_castable<ulong>(param.at("event_id")))
|
||||
event_id_buf = m::event_id(param.at<ulong>("event_id"));
|
||||
|
||||
const m::event::id event_id
|
||||
|
@ -7554,7 +7554,7 @@ console_cmd__event__cached(opt &out, const string_view &line)
|
|||
|
||||
return true;
|
||||
}
|
||||
else if(try_lex_cast<ulong>(id))
|
||||
else if(lex_castable<ulong>(id))
|
||||
{
|
||||
const m::event::idx event_idx
|
||||
{
|
||||
|
@ -9672,14 +9672,14 @@ console_cmd__room__state__history(opt &out, const string_view &line)
|
|||
|
||||
const m::event::id &event_id
|
||||
{
|
||||
!try_lex_cast<int64_t>(point)?
|
||||
!lex_castable<int64_t>(point)?
|
||||
m::event::id{point}:
|
||||
m::event::id{}
|
||||
};
|
||||
|
||||
const int64_t bound
|
||||
{
|
||||
try_lex_cast<int64_t>(point)?
|
||||
lex_castable<int64_t>(point)?
|
||||
lex_cast<int64_t>(point):
|
||||
-1L
|
||||
};
|
||||
|
|
|
@ -91,7 +91,7 @@ ircd::m::auth_room_power_levels(const m::event &event,
|
|||
continue;
|
||||
}
|
||||
|
||||
if(!try_lex_cast<int64_t>(unquote(value)))
|
||||
if(!lex_castable<int64_t>(unquote(value)))
|
||||
throw FAIL
|
||||
{
|
||||
"m.room.power_levels content.users value is not an integer."
|
||||
|
|
Loading…
Reference in a new issue