0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-17 23:40:57 +01:00

ircd: Add tokens_after() util.

This commit is contained in:
Jason Volk 2017-03-17 20:25:14 -07:00
parent a0e7002dde
commit 8ef0b50131
2 changed files with 15 additions and 0 deletions

View file

@ -130,6 +130,7 @@ size_t tokens_count(const string_view &str, const char *const &sep);
string_view token(const string_view &str, const char *const &sep, const size_t &at);
string_view token_last(const string_view &str, const char *const &sep);
string_view token_first(const string_view &str, const char *const &sep);
string_view tokens_after(const string_view &str, const char *const &sep, const size_t &at);
class params
{

View file

@ -23,6 +23,20 @@
#include <RB_INC_BOOST_TOKENIZER_HPP
#include <RB_INC_BOOST_LEXICAL_CAST_HPP
ircd::string_view
ircd::tokens_after(const string_view &str,
const char *const &sep,
const size_t &i)
try
{
const auto t(token(str, sep, i + 1));
return { t.data(), str.data() + str.size() };
}
catch(const std::out_of_range &e)
{
return {};
}
ircd::string_view
ircd::token_first(const string_view &str,
const char *const &sep)