mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::rfc3986: Add valid_literal() to interface.
This commit is contained in:
parent
7f5f07509a
commit
a9cff4f073
2 changed files with 34 additions and 0 deletions
|
@ -28,6 +28,8 @@ namespace ircd::rfc3986
|
|||
|
||||
void valid_hostname(const string_view &); // name part
|
||||
bool valid_hostname(std::nothrow_t, const string_view &);
|
||||
void valid_literal(const string_view &); // ip4 | ip6
|
||||
bool valid_literal(std::nothrow_t, const string_view &);
|
||||
void valid_domain(const string_view &); // dot delimited hostnames
|
||||
bool valid_domain(std::nothrow_t, const string_view &);
|
||||
void valid_host(const string_view &); // domain | ip4 | ip6
|
||||
|
|
|
@ -428,6 +428,38 @@ catch(const qi::expectation_failure<const char *> &e)
|
|||
throw expectation_failure<error>{e};
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::rfc3986::valid_literal(std::nothrow_t,
|
||||
const string_view &str)
|
||||
{
|
||||
static const auto &rule
|
||||
{
|
||||
(parser::ip6_literal >> eoi) |
|
||||
(parser::ip4_literal >> eoi)
|
||||
};
|
||||
|
||||
const char *start(str.data()), *const stop(start + str.size());
|
||||
return qi::parse(start, stop, rule);
|
||||
}
|
||||
|
||||
void
|
||||
ircd::rfc3986::valid_literal(const string_view &str)
|
||||
try
|
||||
{
|
||||
static const auto &rule
|
||||
{
|
||||
(parser::ip6_literal >> eoi) |
|
||||
(parser::ip4_literal >> eoi)
|
||||
};
|
||||
|
||||
const char *start(str.data()), *const stop(start + str.size());
|
||||
qi::parse(start, stop, eps > rule);
|
||||
}
|
||||
catch(const qi::expectation_failure<const char *> &e)
|
||||
{
|
||||
throw expectation_failure<error>{e};
|
||||
}
|
||||
|
||||
bool
|
||||
ircd::rfc3986::valid_hostname(std::nothrow_t,
|
||||
const string_view &str)
|
||||
|
|
Loading…
Reference in a new issue