summaryrefslogtreecommitdiffstats
path: root/Source/cmStringAlgorithms.h
diff options
context:
space:
mode:
authorSebastian Holtermann <sebholt@xwmw.org>2019-08-17 08:58:50 (GMT)
committerSebastian Holtermann <sebholt@xwmw.org>2019-08-17 08:58:50 (GMT)
commit5b7650216b92b89e0dd083191ad1178aefbb6a9f (patch)
tree0bd3a0b65bd3464a3c42850ee6c8150f5c15c8db /Source/cmStringAlgorithms.h
parent34301441b963a2d7e02b4a4355a6634b3bbb7977 (diff)
downloadCMake-5b7650216b92b89e0dd083191ad1178aefbb6a9f.zip
CMake-5b7650216b92b89e0dd083191ad1178aefbb6a9f.tar.gz
CMake-5b7650216b92b89e0dd083191ad1178aefbb6a9f.tar.bz2
cmStringAlgorithms: Add cmIsInternallyOn, cmIsNOTFOUND, cmIsOn, cmIsOff
This adds the following functions to cmStringAlgorithms: - `cmIsInternallyOn` - `cmIsNOTFOUND` - `cmIsOn` - `cmIsOff` The implementations were copied from the equivalent functions in cmSystemTools.
Diffstat (limited to 'Source/cmStringAlgorithms.h')
-rw-r--r--Source/cmStringAlgorithms.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h
index 223d712..5b8b878 100644
--- a/Source/cmStringAlgorithms.h
+++ b/Source/cmStringAlgorithms.h
@@ -180,6 +180,51 @@ std::string cmWrap(char prefix, Range const& rng, char suffix,
sep);
}
+/**
+ * Does a string indicates that CMake/CPack/CTest internally
+ * forced this value. This is not the same as On, but this
+ * may be considered as "internally switched on".
+ */
+bool cmIsInternallyOn(cm::string_view val);
+inline bool cmIsInternallyOn(const char* val)
+{
+ if (!val) {
+ return false;
+ }
+ return cmIsInternallyOn(cm::string_view(val));
+}
+
+/** Return true if value is NOTFOUND or ends in -NOTFOUND. */
+bool cmIsNOTFOUND(cm::string_view val);
+
+/**
+ * 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(const char* val)
+{
+ if (!val) {
+ return false;
+ }
+ return cmIsOn(cm::string_view(val));
+}
+
+/**
+ * Does a string indicate a false or off value ? Note that this is
+ * not the same as !IsOn(...) because there are a number of
+ * ambiguous values such as "/usr/local/bin" a path will result in
+ * 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(const char* val)
+{
+ if (!val) {
+ return true;
+ }
+ return cmIsOff(cm::string_view(val));
+}
+
/** Returns true if string @a str starts with the character @a prefix. */
inline bool cmHasPrefix(cm::string_view str, char prefix)
{