Add startWith function in stringTools.h

This commit is contained in:
Matthieu Gautier 2019-08-08 14:03:47 +02:00
parent 6234457920
commit e013d38cc6
2 changed files with 10 additions and 0 deletions

View File

@ -70,5 +70,7 @@ T extractFromString(const std::string& str) {
iss >> ret; iss >> ret;
return ret; return ret;
} }
bool startsWith(const std::string& base, const std::string& start);
} //namespace kiwix } //namespace kiwix
#endif #endif

View File

@ -377,3 +377,11 @@ std::string kiwix::normalize(const std::string& word)
{ {
return kiwix::lcAll(word); return kiwix::lcAll(word);
} }
bool kiwix::startsWith(const std::string& base, const std::string& start)
{
return start.length() <= base.length()
&& std::equal(start.begin(), start.end(), base.begin());
}