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:
parent
2cefc5e248
commit
32459bd7f1
2 changed files with 16 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue