summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2021-09-21 15:13:14 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2021-09-21 15:14:05 (GMT)
commitedf67dd039f40a4222e41cc15a197cb6395bf885 (patch)
tree70e7d2bf0b3d93c4d9a49dd5fe6b60d3b731f830 /Source
parentcc56dc7468bfee49dedbf395d6fca5c372d200fe (diff)
downloadCMake-edf67dd039f40a4222e41cc15a197cb6395bf885.zip
CMake-edf67dd039f40a4222e41cc15a197cb6395bf885.tar.gz
CMake-edf67dd039f40a4222e41cc15a197cb6395bf885.tar.bz2
cmValue: add IsInternallyOn methods
Diffstat (limited to 'Source')
-rw-r--r--Source/cmStringAlgorithms.cxx9
-rw-r--r--Source/cmStringAlgorithms.h15
-rw-r--r--Source/cmValue.cxx10
-rw-r--r--Source/cmValue.h22
4 files changed, 38 insertions, 18 deletions
diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx
index acb5e5b..1bb6808 100644
--- a/Source/cmStringAlgorithms.cxx
+++ b/Source/cmStringAlgorithms.cxx
@@ -218,15 +218,6 @@ std::string cmCatViews(std::initializer_list<cm::string_view> views)
return result;
}
-bool cmIsInternallyOn(cm::string_view val)
-{
- return (val.size() == 4) && //
- (val[0] == 'I' || val[0] == 'i') && //
- (val[1] == '_') && //
- (val[2] == 'O' || val[2] == 'o') && //
- (val[3] == 'N' || val[3] == 'n');
-}
-
bool cmStrToLong(const char* str, long* value)
{
errno = 0;
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h
index a9edcdf..fd5febf 100644
--- a/Source/cmStringAlgorithms.h
+++ b/Source/cmStringAlgorithms.h
@@ -224,20 +224,17 @@ std::string cmWrap(char prefix, Range const& rng, char suffix,
* 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(cm::string_view val)
+{
+ return cmValue::IsInternallyOn(val);
+}
inline bool cmIsInternallyOn(const char* val)
{
- if (!val) {
- return false;
- }
- return cmIsInternallyOn(cm::string_view(val));
+ return cmValue::IsInternallyOn(val);
}
inline bool cmIsInternallyOn(cmValue val)
{
- if (!val) {
- return false;
- }
- return cmIsInternallyOn(*val);
+ return val.IsInternallyOn();
}
/** Check for non-empty Property/Variable value. */
diff --git a/Source/cmValue.cxx b/Source/cmValue.cxx
index 59bf201..044db29 100644
--- a/Source/cmValue.cxx
+++ b/Source/cmValue.cxx
@@ -73,11 +73,21 @@ bool cmValue::IsOff(cm::string_view value) noexcept
return IsNOTFOUND(value);
}
+
bool cmValue::IsNOTFOUND(cm::string_view value) noexcept
{
return (value == "NOTFOUND"_s) || cmHasSuffix(value, "-NOTFOUND"_s);
}
+bool cmValue::IsInternallyOn(cm::string_view value) noexcept
+{
+ return (value.size() == 4) && //
+ (value[0] == 'I' || value[0] == 'i') && //
+ (value[1] == '_') && //
+ (value[2] == 'O' || value[2] == 'o') && //
+ (value[3] == 'N' || value[3] == 'n');
+}
+
int cmValue::Compare(cmValue value) const noexcept
{
if (this->Value == nullptr && !value) {
diff --git a/Source/cmValue.h b/Source/cmValue.h
index 43a5e0d..c79b997 100644
--- a/Source/cmValue.h
+++ b/Source/cmValue.h
@@ -85,6 +85,17 @@ public:
return this->Value == nullptr || this->Value->empty();
}
+ /**
+ * 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 IsInternallyOn() const noexcept
+ {
+ return this->Value != nullptr &&
+ cmValue::IsInternallyOn(cm::string_view(*this->Value));
+ }
+
bool IsSet() const noexcept
{
return !this->IsEmpty() && !this->IsNOTFOUND();
@@ -131,6 +142,17 @@ public:
}
static bool IsEmpty(cm::string_view value) noexcept { return value.empty(); }
+ /**
+ * 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".
+ */
+ static bool IsInternallyOn(const char* value) noexcept
+ {
+ return value != nullptr && IsInternallyOn(cm::string_view(value));
+ }
+ static bool IsInternallyOn(cm::string_view) noexcept;
+
private:
static std::string Empty;
const std::string* Value = nullptr;