add a startsWith util function

Boost has a starts_with in the string algorithms lib,
but we do not want to pull that in everywhere.
This commit is contained in:
Fischlurch 2015-07-03 02:53:27 +02:00
parent ff0950fd3b
commit 50faff29a9

View file

@ -142,6 +142,20 @@ namespace util {
/** check if string starts with a given prefix */
inline bool
startsWith (string const& str, string const& prefix)
{
return 0 == str.rfind(prefix, 0);
}
inline bool
startsWith (string const& str, const char* prefix)
{
return 0 == str.rfind(prefix, 0);
}
/** shortcut for containment test on a map */ /** shortcut for containment test on a map */
template <typename MAP> template <typename MAP>
inline bool inline bool