0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-01-13 16:33:53 +01:00

ircd: Add multi-string table index util, naive impl.

This commit is contained in:
Jason Volk 2020-03-13 11:10:43 -07:00
parent 2cefc5e248
commit 32459bd7f1
2 changed files with 16 additions and 0 deletions

View file

@ -21,6 +21,10 @@ namespace ircd
inline bool ihas(const string_view &s, const string_view &t);
inline size_t ifind(const string_view &s, const string_view &t);
// Multi-string table suite; returns index past the end on no-match
using string_table = vector_view<const string_view>;
size_t indexof(const string_view &, const string_table &);
// return view without any trailing characters contained in c
string_view rstripa(const string_view &str, const string_view &c);

View file

@ -10,6 +10,18 @@
#include <ircd/simd.h>
size_t
ircd::indexof(const string_view &s,
const string_table &tab)
{
size_t i(0);
for(; i < tab.size(); ++i)
if(s == tab[i])
break;
return i;
}
ircd::string_view
ircd::toupper(const mutable_buffer &out,
const string_view &in)