summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmMakefile.cxx9
-rw-r--r--Source/cmSourceGroup.cxx49
-rw-r--r--Source/cmSourceGroup.h12
3 files changed, 24 insertions, 46 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index d069a5c..1a728c2 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1961,7 +1961,7 @@ cmSourceGroup* cmMakefile::GetSourceGroup(
if (sg != nullptr) {
// iterate through its children to find match source group
for (unsigned int i = 1; i < name.size(); ++i) {
- sg = sg->LookupChild(name[i].c_str());
+ sg = sg->LookupChild(name[i]);
if (sg == nullptr) {
break;
}
@@ -2005,7 +2005,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
if (i == -1) {
// group does not exist nor belong to any existing group
// add its first component
- this->SourceGroups.push_back(cmSourceGroup(name[0].c_str(), regex));
+ this->SourceGroups.push_back(cmSourceGroup(name[0], regex));
sg = this->GetSourceGroup(currentName);
i = 0; // last component found
}
@@ -2015,9 +2015,8 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
}
// build the whole source group path
for (++i; i <= lastElement; ++i) {
- sg->AddChild(
- cmSourceGroup(name[i].c_str(), nullptr, sg->GetFullName().c_str()));
- sg = sg->LookupChild(name[i].c_str());
+ sg->AddChild(cmSourceGroup(name[i], nullptr, sg->GetFullName().c_str()));
+ sg = sg->LookupChild(name[i]);
}
sg->SetGroupRegex(regex);
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index 18bcb49..12ef62b 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -8,7 +8,7 @@ public:
std::vector<cmSourceGroup> GroupChildren;
};
-cmSourceGroup::cmSourceGroup(const char* name, const char* regex,
+cmSourceGroup::cmSourceGroup(const std::string& name, const char* regex,
const char* parentName)
: Name(name)
{
@@ -70,14 +70,14 @@ std::string const& cmSourceGroup::GetFullName() const
return this->FullName;
}
-bool cmSourceGroup::MatchesRegex(const char* name)
+bool cmSourceGroup::MatchesRegex(const std::string& name)
{
return this->GroupRegex.find(name);
}
-bool cmSourceGroup::MatchesFiles(const char* name)
+bool cmSourceGroup::MatchesFiles(const std::string& name) const
{
- return this->GroupFiles.find(name) != this->GroupFiles.end();
+ return this->GroupFiles.find(name) != this->GroupFiles.cend();
}
void cmSourceGroup::AssignSource(const cmSourceFile* sf)
@@ -95,21 +95,12 @@ void cmSourceGroup::AddChild(cmSourceGroup const& child)
this->Internal->GroupChildren.push_back(child);
}
-cmSourceGroup* cmSourceGroup::LookupChild(const char* name) const
+cmSourceGroup* cmSourceGroup::LookupChild(const std::string& name)
{
- // initializing iterators
- std::vector<cmSourceGroup>::const_iterator iter =
- this->Internal->GroupChildren.begin();
- const std::vector<cmSourceGroup>::const_iterator end =
- this->Internal->GroupChildren.end();
-
- // st
- for (; iter != end; ++iter) {
- std::string const& sgName = iter->GetName();
-
+ for (cmSourceGroup& group : this->Internal->GroupChildren) {
// look if descenened is the one were looking for
- if (sgName == name) {
- return const_cast<cmSourceGroup*>(&(*iter)); // if it so return it
+ if (group.GetName() == name) {
+ return (&group); // if it so return it
}
}
@@ -117,19 +108,13 @@ cmSourceGroup* cmSourceGroup::LookupChild(const char* name) const
return nullptr;
}
-cmSourceGroup* cmSourceGroup::MatchChildrenFiles(const char* name)
+cmSourceGroup* cmSourceGroup::MatchChildrenFiles(const std::string& name)
{
- // initializing iterators
- std::vector<cmSourceGroup>::iterator iter =
- this->Internal->GroupChildren.begin();
- std::vector<cmSourceGroup>::iterator end =
- this->Internal->GroupChildren.end();
-
if (this->MatchesFiles(name)) {
return this;
}
- for (; iter != end; ++iter) {
- cmSourceGroup* result = iter->MatchChildrenFiles(name);
+ for (cmSourceGroup& group : this->Internal->GroupChildren) {
+ cmSourceGroup* result = group.MatchChildrenFiles(name);
if (result) {
return result;
}
@@ -137,16 +122,10 @@ cmSourceGroup* cmSourceGroup::MatchChildrenFiles(const char* name)
return nullptr;
}
-cmSourceGroup* cmSourceGroup::MatchChildrenRegex(const char* name)
+cmSourceGroup* cmSourceGroup::MatchChildrenRegex(const std::string& name)
{
- // initializing iterators
- std::vector<cmSourceGroup>::iterator iter =
- this->Internal->GroupChildren.begin();
- std::vector<cmSourceGroup>::iterator end =
- this->Internal->GroupChildren.end();
-
- for (; iter != end; ++iter) {
- cmSourceGroup* result = iter->MatchChildrenRegex(name);
+ for (cmSourceGroup& group : this->Internal->GroupChildren) {
+ cmSourceGroup* result = group.MatchChildrenRegex(name);
if (result) {
return result;
}
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index 7c7c35f..b39f8dd 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -26,7 +26,7 @@ class cmSourceGroupInternals;
class cmSourceGroup
{
public:
- cmSourceGroup(const char* name, const char* regex,
+ cmSourceGroup(const std::string& name, const char* regex,
const char* parentName = nullptr);
cmSourceGroup(cmSourceGroup const& r);
~cmSourceGroup();
@@ -50,7 +50,7 @@ public:
/**
* Looks up child and returns it
*/
- cmSourceGroup* LookupChild(const char* name) const;
+ cmSourceGroup* LookupChild(const std::string& name);
/**
* Get the name of this group.
@@ -65,23 +65,23 @@ public:
/**
* Check if the given name matches this group's regex.
*/
- bool MatchesRegex(const char* name);
+ bool MatchesRegex(const std::string& name);
/**
* Check if the given name matches this group's explicit file list.
*/
- bool MatchesFiles(const char* name);
+ bool MatchesFiles(const std::string& name) const;
/**
* Check if the given name matches this group's explicit file list
* in children.
*/
- cmSourceGroup* MatchChildrenFiles(const char* name);
+ cmSourceGroup* MatchChildrenFiles(const std::string& name);
/**
* Check if the given name matches this group's regex in children.
*/
- cmSourceGroup* MatchChildrenRegex(const char* name);
+ cmSourceGroup* MatchChildrenRegex(const std::string& name);
/**
* Assign the given source file to this group. Used only by