diff options
author | Brad King <brad.king@kitware.com> | 2019-02-13 14:22:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-02-13 14:52:20 (GMT) |
commit | 2ad14ef4ea57c19f6cb4ed365e99a30be81eefe7 (patch) | |
tree | 6ccc77c06bb66dd2ce56af4414f69accc7e4e882 /Source/cmAlgorithms.h | |
parent | 557b2d6e65038640d5016413e612e48691cff0d8 (diff) | |
download | CMake-2ad14ef4ea57c19f6cb4ed365e99a30be81eefe7.zip CMake-2ad14ef4ea57c19f6cb4ed365e99a30be81eefe7.tar.gz CMake-2ad14ef4ea57c19f6cb4ed365e99a30be81eefe7.tar.bz2 |
cmAlgorithms: Add cmHasPrefix to match existing cmHasSuffix
Diffstat (limited to 'Source/cmAlgorithms.h')
-rw-r--r-- | Source/cmAlgorithms.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h index 9e3efd3..d38b0d1 100644 --- a/Source/cmAlgorithms.h +++ b/Source/cmAlgorithms.h @@ -336,6 +336,14 @@ std::reverse_iterator<Iter> cmMakeReverseIterator(Iter it) return std::reverse_iterator<Iter>(it); } +inline bool cmHasPrefix(std::string const& str, std::string const& prefix) +{ + if (str.size() < prefix.size()) { + return false; + } + return str.compare(0, prefix.size(), prefix) == 0; +} + inline bool cmHasSuffix(const std::string& str, const std::string& suffix) { if (str.size() < suffix.size()) { |