0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-25 23:14:13 +01:00

ircd::tokens: Modernize all remaining interface delims to string_view.

This commit is contained in:
Jason Volk 2020-05-11 16:25:51 -07:00
parent 5e0d5237a9
commit db4e0af8a9
2 changed files with 25 additions and 24 deletions

View file

@ -21,16 +21,17 @@ namespace ircd
// to allocate and copy the token with null termination.
using token_view = std::function<void (const string_view &)>;
using token_view_bool = std::function<bool (const string_view &)>;
void tokens(const string_view &str, const char &sep, const token_view &);
void tokens(const string_view &str, const char *const &sep, const token_view &);
void tokens(const string_view &str, const string_view &sep, const token_view &);
bool tokens(const string_view &str, const char &sep, const token_view_bool &);
bool tokens(const string_view &str, const char *const &sep, const token_view_bool &);
bool tokens(const string_view &str, const string_view &sep, const token_view_bool &);
size_t tokens(const string_view &str, const char &sep, const size_t &limit, const token_view &);
size_t tokens(const string_view &str, const char *const &sep, const size_t &limit, const token_view &);
size_t tokens(const string_view &str, const string_view &sep, const size_t &limit, const token_view &);
// Copies tokens into your buffer and null terminates strtok() style. Returns BYTES of buf consumed.
size_t tokens(const string_view &str, const char &sep, const mutable_buffer &buf, const token_view &);
size_t tokens(const string_view &str, const char *const &sep, const mutable_buffer &buf, const token_view &);
size_t tokens(const string_view &str, const string_view &sep, const mutable_buffer &buf, const token_view &);
// Receive token view into iterator range
template<class it, class sep> it tokens(const string_view &str, const sep &, const it &b, const it &e);
@ -75,21 +76,21 @@ namespace ircd
// Convenience to get individual tokens
size_t token_count(const string_view &str, const char &sep);
size_t token_count(const string_view &str, const char *const &sep);
size_t token_count(const string_view &str, const string_view &sep);
bool token_exists(const string_view &str, const char &sep, const string_view &token);
bool token_exists(const string_view &str, const char *const &, const string_view &token);
bool token_exists(const string_view &str, const string_view &sep, const string_view &token);
string_view token(const string_view &str, const char &sep, const size_t &at);
string_view token(const string_view &str, const char *const &sep, const size_t &at);
string_view token(const string_view &str, const string_view &sep, const size_t &at);
string_view token(const string_view &str, const char &sep, const size_t &at, const string_view &def);
string_view token(const string_view &str, const char *const &sep, const size_t &at, const string_view &def);
string_view token(const string_view &str, const string_view &sep, const size_t &at, const string_view &def);
string_view token_last(const string_view &str, const char &sep);
string_view token_last(const string_view &str, const char *const &sep);
string_view token_last(const string_view &str, const string_view &sep);
string_view token_first(const string_view &str, const char &sep);
string_view token_first(const string_view &str, const char *const &sep);
string_view token_first(const string_view &str, const string_view &sep);
string_view tokens_after(const string_view &str, const char &sep, const size_t &at = 0);
string_view tokens_after(const string_view &str, const char *const &sep, const size_t &at = 0);
string_view tokens_after(const string_view &str, const string_view &sep, const size_t &at = 0);
string_view tokens_before(const string_view &str, const char &sep, const size_t &at = 0);
string_view tokens_before(const string_view &str, const char *const &sep, const size_t &at = 0);
string_view tokens_before(const string_view &str, const string_view &sep, const size_t &at = 0);
}
template<size_t N,

View file

@ -49,7 +49,7 @@ ircd::tokens_before(const string_view &str,
ircd::string_view
ircd::tokens_before(const string_view &str,
const char *const &sep,
const string_view &sep,
const size_t &i)
{
using type = string_view;
@ -89,7 +89,7 @@ ircd::tokens_after(const string_view &str,
ircd::string_view
ircd::tokens_after(const string_view &str,
const char *const &sep,
const string_view &sep,
const size_t &i)
{
using type = string_view;
@ -128,7 +128,7 @@ ircd::token_first(const string_view &str,
ircd::string_view
ircd::token_first(const string_view &str,
const char *const &sep)
const string_view &sep)
{
return token(str, sep, 0);
}
@ -148,7 +148,7 @@ ircd::token_last(const string_view &str,
ircd::string_view
ircd::token_last(const string_view &str,
const char *const &sep)
const string_view &sep)
{
using type = string_view;
using iter = typename type::const_iterator;
@ -187,7 +187,7 @@ catch(const std::out_of_range &)
ircd::string_view
ircd::token(const string_view &str,
const char *const &sep,
const string_view &sep,
const size_t &i,
const string_view &def)
try
@ -225,7 +225,7 @@ ircd::token(const string_view &str,
ircd::string_view
ircd::token(const string_view &str,
const char *const &sep,
const string_view &sep,
const size_t &i)
{
using type = string_view;
@ -267,7 +267,7 @@ ircd::token_exists(const string_view &str,
bool
ircd::token_exists(const string_view &str,
const char *const &sep,
const string_view &sep,
const string_view &tok)
{
using type = string_view;
@ -308,7 +308,7 @@ ircd::token_count(const string_view &str,
size_t
ircd::token_count(const string_view &str,
const char *const &sep)
const string_view &sep)
{
using type = string_view;
using iter = typename type::const_iterator;
@ -340,7 +340,7 @@ ircd::tokens(const string_view &str,
size_t
ircd::tokens(const string_view &str,
const char *const &sep,
const string_view &sep,
const mutable_buffer &buf,
const token_view &closure)
{
@ -393,7 +393,7 @@ ircd::tokens(const string_view &str,
size_t
ircd::tokens(const string_view &str,
const char *const &sep,
const string_view &sep,
const size_t &limit,
const token_view &closure)
{
@ -444,7 +444,7 @@ ircd::tokens(const string_view &str,
bool
ircd::tokens(const string_view &str,
const char *const &sep,
const string_view &sep,
const token_view_bool &closure)
{
using type = string_view;
@ -490,7 +490,7 @@ ircd::tokens(const string_view &str,
void
ircd::tokens(const string_view &str,
const char *const &sep,
const string_view &sep,
const token_view &closure)
{
using type = string_view;