From 2ad14ef4ea57c19f6cb4ed365e99a30be81eefe7 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Feb 2019 09:22:41 -0500 Subject: cmAlgorithms: Add cmHasPrefix to match existing cmHasSuffix --- Source/cmAlgorithms.h | 8 ++++++++ 1 file changed, 8 insertions(+) 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 cmMakeReverseIterator(Iter it) return std::reverse_iterator(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()) { -- cgit v0.12