mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
cmValue: introduce constants cmValue::True and cmValue::False
This commit is contained in:
@@ -49,8 +49,6 @@ std::string const& cmSourceFile::GetExtension() const
|
||||
return this->Extension;
|
||||
}
|
||||
|
||||
std::string const propTRUE = "1";
|
||||
std::string const propFALSE = "0";
|
||||
std::string const cmSourceFile::propLANGUAGE = "LANGUAGE";
|
||||
std::string const cmSourceFile::propLOCATION = "LOCATION";
|
||||
std::string const cmSourceFile::propGENERATED = "GENERATED";
|
||||
@@ -387,9 +385,9 @@ cmValue cmSourceFile::GetPropertyForUser(std::string const& prop)
|
||||
(cmp0118 != cmPolicies::OLD && cmp0118 != cmPolicies::WARN);
|
||||
if (this->GetIsGenerated((!cmp0118new) ? CheckScope::GlobalAndLocal
|
||||
: CheckScope::Global)) {
|
||||
return cmValue(propTRUE);
|
||||
return cmValue::True;
|
||||
}
|
||||
return cmValue(propFALSE);
|
||||
return cmValue::False;
|
||||
}
|
||||
|
||||
// Perform the normal property lookup.
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
#include "cmSystemTools.h"
|
||||
#include "cmValue.h"
|
||||
|
||||
static bool GetSourceFilePropertyGENERATED(std::string const& name,
|
||||
cmMakefile& mf,
|
||||
cmValue& propertyValue)
|
||||
namespace {
|
||||
bool GetSourceFilePropertyGENERATED(std::string const& name, cmMakefile& mf,
|
||||
cmValue& propertyValue)
|
||||
{
|
||||
// Globally set as generated?
|
||||
// Note: If the given "name" only contains a filename or a relative path
|
||||
@@ -26,13 +26,11 @@ static bool GetSourceFilePropertyGENERATED(std::string const& name,
|
||||
// generated in the build-directory. Therefore, we first check for
|
||||
// a generated file in the build-directory before we check for a
|
||||
// generated file in the source-directory.
|
||||
static std::string const sOne = "1";
|
||||
static std::string const sZero = "0";
|
||||
{
|
||||
auto file =
|
||||
cmSystemTools::CollapseFullPath(name, mf.GetCurrentBinaryDirectory());
|
||||
if (mf.GetGlobalGenerator()->IsGeneratedFile(file)) {
|
||||
propertyValue = cmValue(sOne);
|
||||
propertyValue = cmValue::True;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -40,13 +38,14 @@ static bool GetSourceFilePropertyGENERATED(std::string const& name,
|
||||
auto file =
|
||||
cmSystemTools::CollapseFullPath(name, mf.GetCurrentSourceDirectory());
|
||||
if (mf.GetGlobalGenerator()->IsGeneratedFile(file)) {
|
||||
propertyValue = cmValue(sOne);
|
||||
propertyValue = cmValue::True;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
propertyValue = cmValue(sZero);
|
||||
propertyValue = cmValue::False;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
cmGetSourceFilePropertyResult cmGetSourceFileProperty(
|
||||
std::string const& sourceName, std::string const& propertyName,
|
||||
|
||||
@@ -8,6 +8,14 @@
|
||||
|
||||
#include "cmStringAlgorithms.h"
|
||||
|
||||
namespace {
|
||||
std::string True{ "1" };
|
||||
std::string False{ "0" };
|
||||
}
|
||||
|
||||
cmValue cmValue::True{ ::True };
|
||||
cmValue cmValue::False{ ::False };
|
||||
|
||||
std::string cmValue::Empty;
|
||||
|
||||
bool cmValue::IsOn(cm::string_view value) noexcept
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
class cmValue
|
||||
{
|
||||
public:
|
||||
static cmValue True;
|
||||
static cmValue False;
|
||||
|
||||
cmValue() noexcept = default;
|
||||
cmValue(std::nullptr_t) noexcept {}
|
||||
explicit cmValue(std::string const* value) noexcept
|
||||
|
||||
Reference in New Issue
Block a user