summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-10-04 19:12:47 (GMT)
committerBrad King <brad.king@kitware.com>2023-10-04 22:44:44 (GMT)
commitc1f1aedcee3e24f96ec129105ae0119f3201d1cc (patch)
treee63d591534005c2f8f3103df61475704a34bc9b8
parent23b57462aa5865d1e526c40dfd0f04f6a4af9e25 (diff)
downloadCMake-c1f1aedcee3e24f96ec129105ae0119f3201d1cc.zip
CMake-c1f1aedcee3e24f96ec129105ae0119f3201d1cc.tar.gz
CMake-c1f1aedcee3e24f96ec129105ae0119f3201d1cc.tar.bz2
cmStandardLevelResolver: Add method to look up standard level by name
-rw-r--r--Source/cmStandardLevelResolver.cxx23
-rw-r--r--Source/cmStandardLevelResolver.h3
2 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx
index 4a149e0..e814690 100644
--- a/Source/cmStandardLevelResolver.cxx
+++ b/Source/cmStandardLevelResolver.cxx
@@ -457,6 +457,19 @@ struct StandardLevelComputer
return maxLevel;
}
+ cm::optional<cmStandardLevel> LanguageStandardLevel(
+ std::string const& standardStr) const
+ {
+ cm::optional<cmStandardLevel> langLevel;
+ auto const& stds = this->Levels;
+ auto stdIt =
+ std::find(cm::cbegin(stds), cm::cend(stds), ParseStd(standardStr));
+ if (stdIt != cm::cend(stds)) {
+ langLevel = cmStandardLevel(std::distance(cm::cbegin(stds), stdIt));
+ }
+ return langLevel;
+ }
+
bool IsLaterStandard(int lhs, int rhs) const
{
auto rhsIt =
@@ -661,6 +674,16 @@ cmStandardLevelResolver::CompileFeatureStandardLevel(
return mapping->second.CompileFeatureStandardLevel(this->Makefile, feature);
}
+cm::optional<cmStandardLevel> cmStandardLevelResolver::LanguageStandardLevel(
+ std::string const& lang, std::string const& standardStr) const
+{
+ auto mapping = StandardComputerMapping.find(lang);
+ if (mapping == cm::cend(StandardComputerMapping)) {
+ return cm::nullopt;
+ }
+ return mapping->second.LanguageStandardLevel(standardStr);
+}
+
cmValue cmStandardLevelResolver::CompileFeaturesAvailable(
const std::string& lang, std::string* error) const
{
diff --git a/Source/cmStandardLevelResolver.h b/Source/cmStandardLevelResolver.h
index 09989ba..29cab55 100644
--- a/Source/cmStandardLevelResolver.h
+++ b/Source/cmStandardLevelResolver.h
@@ -39,6 +39,9 @@ public:
cm::optional<cmStandardLevel> CompileFeatureStandardLevel(
std::string const& lang, std::string const& feature) const;
+ cm::optional<cmStandardLevel> LanguageStandardLevel(
+ std::string const& lang, std::string const& standardStr) const;
+
cmValue CompileFeaturesAvailable(const std::string& lang,
std::string* error) const;