mirror of
https://github.com/matrix-construct/construct
synced 2025-01-14 00:34:18 +01:00
ircd: Add has() stringop because find() != npos is an annoying construct.
This commit is contained in:
parent
70326ed471
commit
a22e4917c8
1 changed files with 11 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue