mirror of
https://github.com/matrix-construct/construct
synced 2025-02-16 16:50:12 +01:00
ircd: Add single char overloads for startswith()/endswith() stringops.
This commit is contained in:
parent
a018eab293
commit
d4bcf904c3
1 changed files with 16 additions and 0 deletions
|
@ -34,9 +34,11 @@ std::pair<std::string, std::string> split(const std::string &str, const std::str
|
|||
std::string between(const std::string &str, const std::string &a = "("s, const std::string &b = ")"s);
|
||||
bool endswith(const std::string &str, const char *const &val);
|
||||
bool endswith(const std::string &str, const std::string &val);
|
||||
bool endswith(const std::string &str, const char &val);
|
||||
template<class It> bool endswith_any(const std::string &str, const It &begin, const It &end);
|
||||
bool startswith(const std::string &str, const char *const &val);
|
||||
bool startswith(const std::string &str, const std::string &val);
|
||||
bool startswith(const std::string &str, const char &val);
|
||||
|
||||
char *strip_colour(char *string);
|
||||
char *strip_unprintable(char *string);
|
||||
|
@ -44,6 +46,13 @@ char *reconstruct_parv(int parc, const char **parv);
|
|||
|
||||
} // namespace ircd
|
||||
|
||||
inline bool
|
||||
ircd::startswith(const std::string &str,
|
||||
const char &val)
|
||||
{
|
||||
return !str.empty() && str[0] == val;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::startswith(const std::string &str,
|
||||
const std::string &val)
|
||||
|
@ -72,6 +81,13 @@ ircd::endswith_any(const std::string &str,
|
|||
});
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::endswith(const std::string &str,
|
||||
const char &val)
|
||||
{
|
||||
return !str.empty() && str[str.size()-1] == val;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ircd::endswith(const std::string &str,
|
||||
const std::string &val)
|
||||
|
|
Loading…
Add table
Reference in a new issue