cmSourceGroup: Fix typos and improve methods const correctness

This commit is contained in:
Cristiano Carvalheiro
2025-11-11 14:08:51 +00:00
parent 0ff69e0da2
commit 1dcebce19f
2 changed files with 11 additions and 10 deletions

View File

@@ -96,9 +96,10 @@ std::string const& cmSourceGroup::GetFullName() const
return this->FullName;
}
bool cmSourceGroup::MatchesRegex(std::string const& name)
bool cmSourceGroup::MatchesRegex(std::string const& name) const
{
return this->GroupRegex.find(name);
cmsys::RegularExpressionMatch match;
return this->GroupRegex.find(name.c_str(), match);
}
bool cmSourceGroup::MatchesFiles(std::string const& name) const
@@ -121,12 +122,12 @@ void cmSourceGroup::AddChild(cmSourceGroup const& child)
this->Internal->GroupChildren.push_back(child);
}
cmSourceGroup* cmSourceGroup::LookupChild(std::string const& name)
cmSourceGroup* cmSourceGroup::LookupChild(std::string const& name) const
{
for (cmSourceGroup& group : this->Internal->GroupChildren) {
// look if descenened is the one were looking for
// look if descendant is the one we're looking for
if (group.GetName() == name) {
return (&group); // if it so return it
return (&group); // if so return it
}
}
@@ -163,7 +164,7 @@ cmSourceGroup const* cmSourceGroup::MatchChildrenFiles(
return nullptr;
}
cmSourceGroup* cmSourceGroup::MatchChildrenRegex(std::string const& name)
cmSourceGroup* cmSourceGroup::MatchChildrenRegex(std::string const& name) const
{
for (cmSourceGroup& group : this->Internal->GroupChildren) {
cmSourceGroup* result = group.MatchChildrenRegex(name);
@@ -172,7 +173,7 @@ cmSourceGroup* cmSourceGroup::MatchChildrenRegex(std::string const& name)
}
}
if (this->MatchesRegex(name)) {
return this;
return const_cast<cmSourceGroup*>(this);
}
return nullptr;

View File

@@ -57,7 +57,7 @@ public:
/**
* Looks up child and returns it
*/
cmSourceGroup* LookupChild(std::string const& name);
cmSourceGroup* LookupChild(std::string const& name) const;
/**
* Get the name of this group.
@@ -72,7 +72,7 @@ public:
/**
* Check if the given name matches this group's regex.
*/
bool MatchesRegex(std::string const& name);
bool MatchesRegex(std::string const& name) const;
/**
* Check if the given name matches this group's explicit file list.
@@ -94,7 +94,7 @@ public:
/**
* Check if the given name matches this group's regex in children.
*/
cmSourceGroup* MatchChildrenRegex(std::string const& name);
cmSourceGroup* MatchChildrenRegex(std::string const& name) const;
/**
* Assign the given source file to this group. Used only by