0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-28 19:58:53 +02:00

ircd: Add has() stringop because find() != npos is an annoying construct.

This commit is contained in:
Jason Volk 2017-10-25 09:31:52 -07:00
parent 70326ed471
commit a22e4917c8

View file

@ -41,6 +41,9 @@ namespace ircd
size_t strlcpy(char *const &dest, const string_view &src, const size_t &bufmax);
size_t strlcat(char *const &dest, const string_view &src, const size_t &bufmax);
// wrapper to find(T) != npos
template<class T> bool has(const string_view &, const T &);
// return view without trailing c
string_view rstrip(const string_view &str, const char &c = ' ');
string_view rstrip(const string_view &str, const string_view &c);
@ -448,6 +451,14 @@ ircd::lstrip(const string_view &str,
return pos != string_view::npos? string_view{str.substr(pos)} : string_view{};
}
template<class T>
bool
ircd::has(const string_view &s,
const T &t)
{
return s.find(t) != s.npos;
}
inline size_t
ircd::strlcpy(const mutable_buffer &dst,
const string_view &src)