App: modernize C++: use range-based for loop
This commit is contained in:
@@ -115,11 +115,11 @@ Property *PropertyExpressionEngine::Copy() const
|
||||
{
|
||||
PropertyExpressionEngine * engine = new PropertyExpressionEngine();
|
||||
|
||||
for (ExpressionMap::const_iterator it = expressions.begin(); it != expressions.end(); ++it) {
|
||||
for (const auto & it : expressions) {
|
||||
ExpressionInfo info;
|
||||
if (it->second.expression)
|
||||
info.expression = std::shared_ptr<Expression>(it->second.expression->copy());
|
||||
engine->expressions[it->first] = info;
|
||||
if (it.second.expression)
|
||||
info.expression = std::shared_ptr<Expression>(it.second.expression->copy());
|
||||
engine->expressions[it.first] = info;
|
||||
}
|
||||
|
||||
engine->validator = validator;
|
||||
@@ -274,15 +274,15 @@ void PropertyExpressionEngine::Save(Base::Writer &writer) const
|
||||
writer.incInd();
|
||||
PropertyExpressionContainer::Save(writer);
|
||||
}
|
||||
for (ExpressionMap::const_iterator it = expressions.begin(); it != expressions.end(); ++it) {
|
||||
for (const auto & it : expressions) {
|
||||
std::string expression, comment;
|
||||
if (it->second.expression) {
|
||||
expression = it->second.expression->toString(true);
|
||||
comment = it->second.expression->comment;
|
||||
if (it.second.expression) {
|
||||
expression = it.second.expression->toString(true);
|
||||
comment = it.second.expression->comment;
|
||||
}
|
||||
|
||||
writer.Stream() << writer.ind() << "<Expression path=\""
|
||||
<< Property::encodeAttribute(it->first.toString()) <<"\" expression=\""
|
||||
<< Property::encodeAttribute(it.first.toString()) <<"\" expression=\""
|
||||
<< Property::encodeAttribute(expression) << "\"";
|
||||
if (!comment.empty())
|
||||
writer.Stream() << " comment=\""
|
||||
@@ -535,9 +535,9 @@ void PropertyExpressionEngine::buildGraph(const ExpressionMap & exprs,
|
||||
std::vector<Edge> edges;
|
||||
|
||||
// Build data structure for graph
|
||||
for (ExpressionMap::const_iterator it = exprs.begin(); it != exprs.end(); ++it) {
|
||||
for (const auto & expr : exprs) {
|
||||
if(option!=ExecuteAll) {
|
||||
auto prop = it->first.getProperty();
|
||||
auto prop = expr.first.getProperty();
|
||||
if(!prop)
|
||||
throw Base::RuntimeError("Path does not resolve to a property.");
|
||||
bool is_output = prop->testStatus(App::Property::Output)||(prop->getType()&App::Prop_Output);
|
||||
@@ -549,15 +549,15 @@ void PropertyExpressionEngine::buildGraph(const ExpressionMap & exprs,
|
||||
&& !prop->testStatus(Property::EvalOnRestore))
|
||||
continue;
|
||||
}
|
||||
buildGraphStructures(it->first, it->second.expression, nodes, revNodes, edges);
|
||||
buildGraphStructures(expr.first, expr.second.expression, nodes, revNodes, edges);
|
||||
}
|
||||
|
||||
// Create graph
|
||||
g = DiGraph(nodes.size());
|
||||
|
||||
// Add edges to graph
|
||||
for (std::vector<Edge>::const_iterator i = edges.begin(); i != edges.end(); ++i)
|
||||
add_edge(i->first, i->second, g);
|
||||
for (const auto & edge : edges)
|
||||
add_edge(edge.first, edge.second, g);
|
||||
|
||||
// Check for cycles
|
||||
bool has_cycle = false;
|
||||
@@ -590,11 +590,11 @@ std::vector<App::ObjectIdentifier> PropertyExpressionEngine::computeEvaluationOr
|
||||
std::vector<int> c;
|
||||
topological_sort(g, std::back_inserter(c));
|
||||
|
||||
for (std::vector<int>::iterator i = c.begin(); i != c.end(); ++i) {
|
||||
for (int i : c) {
|
||||
// we return the evaluation order for our properties, not the dependencies
|
||||
// the topo sort will contain node ids for both our props and their deps
|
||||
if (revNodes.find(*i) != revNodes.end())
|
||||
evaluationOrder.push_back(revNodes[*i]);
|
||||
if (revNodes.find(i) != revNodes.end())
|
||||
evaluationOrder.push_back(revNodes[i]);
|
||||
}
|
||||
|
||||
return evaluationOrder;
|
||||
@@ -825,8 +825,8 @@ void PropertyExpressionEngine::renameExpressions(const std::map<ObjectIdentifier
|
||||
std::map<ObjectIdentifier, ObjectIdentifier> canonicalPaths;
|
||||
|
||||
/* ensure input map uses canonical paths */
|
||||
for (std::map<ObjectIdentifier, ObjectIdentifier>::const_iterator i = paths.begin(); i != paths.end(); ++i)
|
||||
canonicalPaths[canonicalPath(i->first)] = i->second;
|
||||
for (const auto & path : paths)
|
||||
canonicalPaths[canonicalPath(path.first)] = path.second;
|
||||
|
||||
for (ExpressionMap::const_iterator i = expressions.begin(); i != expressions.end(); ++i) {
|
||||
std::map<ObjectIdentifier, ObjectIdentifier>::const_iterator j = canonicalPaths.find(i->first);
|
||||
@@ -853,19 +853,19 @@ void PropertyExpressionEngine::renameExpressions(const std::map<ObjectIdentifier
|
||||
|
||||
void PropertyExpressionEngine::renameObjectIdentifiers(const std::map<ObjectIdentifier, ObjectIdentifier> &paths)
|
||||
{
|
||||
for (ExpressionMap::iterator it = expressions.begin(); it != expressions.end(); ++it) {
|
||||
RenameObjectIdentifierExpressionVisitor<PropertyExpressionEngine> v(*this, paths, it->first);
|
||||
it->second.expression->visit(v);
|
||||
for (const auto & it : expressions) {
|
||||
RenameObjectIdentifierExpressionVisitor<PropertyExpressionEngine> v(*this, paths, it.first);
|
||||
it.second.expression->visit(v);
|
||||
}
|
||||
}
|
||||
|
||||
PyObject *PropertyExpressionEngine::getPyObject()
|
||||
{
|
||||
Py::List list;
|
||||
for (ExpressionMap::const_iterator it = expressions.begin(); it != expressions.end(); ++it) {
|
||||
for (const auto & it : expressions) {
|
||||
Py::Tuple tuple(2);
|
||||
tuple.setItem(0, Py::String(it->first.toString()));
|
||||
auto expr = it->second.expression;
|
||||
tuple.setItem(0, Py::String(it.first.toString()));
|
||||
auto expr = it.second.expression;
|
||||
tuple.setItem(1, expr ? Py::String(expr->toString()) : Py::None());
|
||||
list.append(tuple);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user