mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 06:09:52 -06:00
Refactor: cmHasPrefix and cmHasSuffix accept now cmProp
This commit is contained in:
@@ -290,6 +290,16 @@ inline bool cmHasPrefix(cm::string_view str, cm::string_view prefix)
|
||||
return str.compare(0, prefix.size(), prefix) == 0;
|
||||
}
|
||||
|
||||
/** Returns true if string @a str starts with string @a prefix. */
|
||||
inline bool cmHasPrefix(cm::string_view str, cmProp prefix)
|
||||
{
|
||||
if (!prefix) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return str.compare(0, prefix->size(), prefix) == 0;
|
||||
}
|
||||
|
||||
/** Returns true if string @a str starts with string @a prefix. */
|
||||
template <size_t N>
|
||||
inline bool cmHasLiteralPrefix(cm::string_view str, const char (&prefix)[N])
|
||||
@@ -310,6 +320,17 @@ inline bool cmHasSuffix(cm::string_view str, cm::string_view suffix)
|
||||
str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
|
||||
}
|
||||
|
||||
/** Returns true if string @a str ends with string @a suffix. */
|
||||
inline bool cmHasSuffix(cm::string_view str, cmProp suffix)
|
||||
{
|
||||
if (!suffix) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return str.size() >= suffix->size() &&
|
||||
str.compare(str.size() - suffix->size(), suffix->size(), suffix) == 0;
|
||||
}
|
||||
|
||||
/** Returns true if string @a str ends with string @a suffix. */
|
||||
template <size_t N>
|
||||
inline bool cmHasLiteralSuffix(cm::string_view str, const char (&suffix)[N])
|
||||
|
||||
Reference in New Issue
Block a user