summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2018-01-15 13:37:40 +0200
committerTor Lillqvist <tml@collabora.com>2018-01-15 13:39:48 +0200
commit7bf59d8f648680747c3a2c26b7836d1b92f9e63a (patch)
treea6626dbff0b5e2395f9ad951d211eaca5edbc464 /common
parentloleaflet: Delay showing of dialog until we have the content (diff)
downloadonline-7bf59d8f648680747c3a2c26b7836d1b92f9e63a.tar.gz
online-7bf59d8f648680747c3a2c26b7836d1b92f9e63a.zip
Add Util::startsWith() to check whether a std::string starts with another
Odd that we have managed without such a helper for so long, or did I just not find it?
Diffstat (limited to 'common')
-rw-r--r--common/Util.hpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/Util.hpp b/common/Util.hpp
index eef5246437..b4eb350406 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -285,6 +285,11 @@ namespace Util
return trimmed(std::string(s));
}
+ inline bool startsWith(const std::string& s, const std::string& t)
+ {
+ return s.length() >= t.length() && memcmp(s.c_str(), t.c_str(), t.length()) == 0;
+ }
+
/// Given one or more patterns to allow, and one or more to deny,
/// the match member will return true if, and only if, the subject
/// matches the allowed list, but not the deny.