App: apply std::ranges

This commit is contained in:
bofdahof
2025-03-12 17:46:30 +10:00
committed by Chris Hennes
parent 25c71dd99d
commit 4a16ea41a7
9 changed files with 25 additions and 27 deletions

View File

@@ -92,7 +92,7 @@ Branding::XmlConfig Branding::getUserDefines() const
while (!child.isNull()) {
std::string name = child.localName().toLatin1().constData();
std::string value = child.text().toUtf8().constData();
if (std::find(filter.begin(), filter.end(), name) != filter.end()) {
if (std::ranges::find(filter, name) != filter.end()) {
cfg[name] = value;
}
child = child.nextSiblingElement();

View File

@@ -208,7 +208,7 @@ App::Point* LocalCoordinateSystem::getPoint(const char* role) const
bool LocalCoordinateSystem::hasObject(const DocumentObject* obj) const
{
const auto& features = OriginFeatures.getValues();
return std::find(features.begin(), features.end(), obj) != features.end();
return std::ranges::find(features, obj) != features.end();
}
short LocalCoordinateSystem::mustExecute() const
@@ -302,12 +302,12 @@ void LocalCoordinateSystem::unsetupObject()
{
const auto& objsLnk = OriginFeatures.getValues();
// Copy to set to assert we won't call method more then one time for each object
std::set<App::DocumentObject*> objs(objsLnk.begin(), objsLnk.end());
const std::set<App::DocumentObject*> objs(objsLnk.begin(), objsLnk.end());
// Remove all controlled objects
for (auto obj : objs) {
// Check that previous deletes didn't indirectly remove one of our objects
const auto& objsLnk = OriginFeatures.getValues();
if (std::find(objsLnk.begin(), objsLnk.end(), obj) != objsLnk.end()) {
const auto& objsLnk2 = OriginFeatures.getValues();
if (std::ranges::find(objsLnk2, obj) != objsLnk2.end()) {
if (!obj->isRemoving()) {
obj->getDocument()->removeObject(obj->getNameInDocument());
}
@@ -331,7 +331,7 @@ void LocalCoordinateSystem::migrateOriginPoint()
return obj->isDerivedFrom<App::DatumElement>() &&
strcmp(static_cast<App::DatumElement*>(obj)->Role.getValue(), PointRoles[0]) == 0;
};
if (std::none_of(features.begin(), features.end(), isOrigin)) {
if (std::ranges::none_of(features, isOrigin)) {
auto data = getData(PointRoles[0]);
auto* origin = createDatum(data);
origin->purgeTouched();

View File

@@ -4304,7 +4304,7 @@ void DocumentP::findAllPathsAt(const std::vector<Node>& all_nodes,
std::vector<Path>& all_paths,
Path tmp)
{
if (std::find(tmp.begin(), tmp.end(), id) != tmp.end()) {
if (std::ranges::find(tmp, id) != tmp.end()) {
Path tmp2(tmp);
tmp2.push_back(id);
all_paths.push_back(tmp2);
@@ -4352,10 +4352,10 @@ Document::getPathsByOutList(const App::DocumentObject* from, const App::Document
DocumentP::findAllPathsAt(all_nodes, index_from, all_paths, tmp);
for (const Path& it : all_paths) {
Path::const_iterator jt = std::find(it.begin(), it.end(), index_to);
auto jt = std::ranges::find(it, index_to);
if (jt != it.end()) {
std::list<App::DocumentObject*> path;
for (Path::const_iterator kt = it.begin(); kt != jt; ++kt) {
std::list<DocumentObject*> path;
for (auto kt = it.begin(); kt != jt; ++kt) {
path.push_back(d->objectArray[*kt]);
}

View File

@@ -590,7 +590,7 @@ bool DocumentObject::isInInListRecursive(DocumentObject* linkTo) const
bool DocumentObject::isInInList(DocumentObject* linkTo) const
{
if (std::find(_inList.begin(), _inList.end(), linkTo) != _inList.end()) {
if (std::ranges::find(_inList, linkTo) != _inList.end()) {
return true;
}
else {
@@ -1253,7 +1253,7 @@ void App::DocumentObject::_removeBackLink(DocumentObject* rmvObj)
{
// do not use erase-remove idom, as this erases ALL entries that match. we only want to remove a
// single one.
auto it = std::find(_inList.begin(), _inList.end(), rmvObj);
auto it = std::ranges::find(_inList, rmvObj);
if (it != _inList.end()) {
_inList.erase(it);
}

View File

@@ -338,7 +338,7 @@ void GeoFeatureGroupExtension::getCSInList(const DocumentObject* obj,
// check if the link is real Local scope one or if it is a expression one (could also be
// both, so it is not enough to check the expressions)
auto res = getScopedObjectsFromLinks(parent, LinkScope::Local);
if (std::find(res.begin(), res.end(), obj) != res.end()) {
if (std::ranges::find(res, obj) != res.end()) {
vec.push_back(parent);
}
}
@@ -382,7 +382,7 @@ void GeoFeatureGroupExtension::recursiveCSRelevantLinks(const DocumentObject* ob
// go on traversing the graph in all directions!
for (auto o : links) {
if (!o || o == obj || std::find(vec.begin(), vec.end(), o) != vec.end()) {
if (!o || o == obj || std::ranges::find(vec, o) != vec.end()) {
continue;
}

View File

@@ -290,7 +290,7 @@ void Document::exportGraphviz(std::ostream& out) const
{
// don't add objects twice
if (std::find(objects.begin(), objects.end(), docObj) != objects.end()) {
if (std::ranges::find(objects, docObj) != objects.end()) {
return;
}

View File

@@ -268,7 +268,7 @@ bool GroupExtension::recursiveHasObject(const DocumentObject* obj,
auto ext = child->getExtensionByType<GroupExtension>();
if (std::find(history.begin(), history.end(), ext) != history.end()) {
if (std::ranges::find(history, ext) != history.end()) {
throw Base::RuntimeError(
"Cyclic dependencies detected: Search cannot be performed");
}

View File

@@ -74,7 +74,7 @@ std::pair<std::string, std::string> customSyntax(std::string_view strIn)
"title",
"visual"};
if (std::find(knowns.begin(), knowns.end(), rest) != knowns.end()) {
if (std::ranges::find(knowns, rest) != knowns.end()) {
return {rest, "null"};
}
return {};

View File

@@ -1232,17 +1232,15 @@ void PropertyExpressionEngine::getLinksTo(std::vector<App::ObjectIdentifier>& id
identifiers.push_back(expressionId);
break;
}
if (std::any_of(paths.begin(),
paths.end(),
[subname, obj, sobj, &subElement](const auto& path) {
if (path.getSubObjectName() == subname) {
return true;
}
if (std::ranges::any_of(paths, [subname, obj, sobj, &subElement](const auto& path) {
if (path.getSubObjectName() == subname) {
return true;
}
App::SubObjectT sobjT(obj, path.getSubObjectName().c_str());
return (sobjT.getSubObject() == sobj
&& sobjT.getOldElementName() == subElement);
})) {
App::SubObjectT sobjT(obj, path.getSubObjectName().c_str());
return (sobjT.getSubObject() == sobj
&& sobjT.getOldElementName() == subElement);
})) {
identifiers.push_back(expressionId);
}
}