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:
parent
ff0950fd3b
commit
50faff29a9
1 changed files with 14 additions and 0 deletions
|
|
@ -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 */
|
||||
template <typename MAP>
|
||||
inline bool
|
||||
|
|
|
|||
Loading…
Reference in a new issue