diff options
Diffstat (limited to 'Source/cmStringAlgorithms.h')
-rw-r--r-- | Source/cmStringAlgorithms.h | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 6b458ec..531678a 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -14,25 +14,12 @@ #include <cm/string_view> +#include "cmProperty.h" #include "cmRange.h" /** String range type. */ using cmStringRange = cmRange<std::vector<std::string>::const_iterator>; -/** Check for non-empty string. */ -inline bool cmNonempty(const char* str) -{ - return str && *str; -} -inline bool cmNonempty(cm::string_view str) -{ - return !str.empty(); -} -inline bool cmNonempty(std::string const* str) -{ - return str && !str->empty(); -} - /** Returns length of a literal string. */ template <size_t N> constexpr size_t cmStrLen(const char (&/*str*/)[N]) @@ -175,6 +162,10 @@ public: cmAlphaNum(unsigned long long int val); cmAlphaNum(float val); cmAlphaNum(double val); + cmAlphaNum(cmProp value) + : View_(*value) + { + } cm::string_view View() const { return this->View_; } @@ -227,20 +218,44 @@ inline bool cmIsInternallyOn(const char* val) return cmIsInternallyOn(cm::string_view(val)); } +/** Check for non-empty Property/Variable value. */ +inline bool cmNonempty(cm::string_view val) +{ + return !cmProp::IsEmpty(val); +} +inline bool cmNonempty(const char* val) +{ + return !cmProp::IsEmpty(val); +} +inline bool cmNonempty(cmProp val) +{ + return !val.IsEmpty(); +} + /** Return true if value is NOTFOUND or ends in -NOTFOUND. */ -bool cmIsNOTFOUND(cm::string_view val); +inline bool cmIsNOTFOUND(cm::string_view val) +{ + return cmProp::IsNOTFOUND(val); +} +inline bool cmIsNOTFOUND(cmProp val) +{ + return val.IsNOTFOUND(); +} /** * Does a string indicate a true or ON value? This is not the same as ifdef. */ -bool cmIsOn(cm::string_view val); +inline bool cmIsOn(cm::string_view val) +{ + return cmProp::IsOn(val); +} inline bool cmIsOn(const char* val) { - return val && cmIsOn(cm::string_view(val)); + return cmProp::IsOn(val); } -inline bool cmIsOn(std::string const* val) +inline bool cmIsOn(cmProp val) { - return val && cmIsOn(*val); + return val.IsOn(); } /** @@ -250,14 +265,17 @@ inline bool cmIsOn(std::string const* val) * IsON and IsOff both returning false. Note that the special path * NOTFOUND, *-NOTFOUND or IGNORE will cause IsOff to return true. */ -bool cmIsOff(cm::string_view val); +inline bool cmIsOff(cm::string_view val) +{ + return cmProp::IsOff(val); +} inline bool cmIsOff(const char* val) { - return !val || cmIsOff(cm::string_view(val)); + return cmProp::IsOff(val); } -inline bool cmIsOff(std::string const* val) +inline bool cmIsOff(cmProp val) { - return !val || cmIsOff(*val); + return val.IsOff(); } /** Returns true if string @a str starts with the character @a prefix. */ |