Skip to content

Commit 06950bb

Browse files
committed
Code formatting
1 parent 0b93e82 commit 06950bb

File tree

3 files changed

+61
-63
lines changed

3 files changed

+61
-63
lines changed

modules/yup_data_model/tree/yup_DataTree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -999,10 +999,10 @@ bool DataTree::isAChildOf (const DataTree& possibleParent) const noexcept
999999
while (parent.isValid())
10001000
{
10011001
const void* parentPtr = parent.object.get();
1002-
if (visited.find(parentPtr) != visited.end())
1002+
if (visited.find (parentPtr) != visited.end())
10031003
return false;
10041004

1005-
visited.insert(parentPtr);
1005+
visited.insert (parentPtr);
10061006

10071007
if (parent == possibleParent)
10081008
return true;

modules/yup_data_model/tree/yup_DataTreeQuery.cpp

Lines changed: 58 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ struct DataTreeQuery::XPathParser
8484
{
8585
enum Type
8686
{
87-
HasProperty, // [@prop]
88-
PropertyEquals, // [@prop='value']
89-
PropertyNotEquals, // [@prop!='value']
90-
PropertyGreater, // [@prop > value]
91-
PropertyLess, // [@prop < value]
87+
HasProperty, // [@prop]
88+
PropertyEquals, // [@prop='value']
89+
PropertyNotEquals, // [@prop!='value']
90+
PropertyGreater, // [@prop > value]
91+
PropertyLess, // [@prop < value]
9292
PropertyGreaterEqual, // [@prop >= value]
93-
PropertyLessEqual, // [@prop <= value]
94-
Position, // [1], [2], etc.
95-
First, // [first()]
96-
Last, // [last()]
97-
And, // predicate1 and predicate2
98-
Or, // predicate1 or predicate2
99-
Not // not(predicate)
93+
PropertyLessEqual, // [@prop <= value]
94+
Position, // [1], [2], etc.
95+
First, // [first()]
96+
Last, // [last()]
97+
And, // predicate1 and predicate2
98+
Or, // predicate1 or predicate2
99+
Not // not(predicate)
100100
};
101101

102102
Type type;
@@ -248,7 +248,7 @@ struct DataTreeQuery::XPathParser
248248
else
249249
{
250250
// Error: @ not followed by identifier
251-
parseResult = Result::fail("Expected property name after '@' in node test");
251+
parseResult = Result::fail ("Expected property name after '@' in node test");
252252
return;
253253
}
254254

@@ -258,22 +258,22 @@ struct DataTreeQuery::XPathParser
258258
{
259259
// text() function - select text property
260260
++currentToken;
261-
261+
262262
// Skip parentheses for text()
263263
if (currentToken < static_cast<int> (tokens.size()) && tokens[currentToken].type == Token::Type::OpenParen)
264264
{
265265
++currentToken;
266266
if (currentToken < static_cast<int> (tokens.size()) && tokens[currentToken].type == Token::Type::CloseParen)
267267
++currentToken;
268268
}
269-
269+
270270
operations.emplace_back (QueryOperation::Property, "text");
271271
return; // text() selection terminates node traversal
272272
}
273273
else if (token.type == Token::Type::OpenBracket)
274274
{
275275
// Unexpected bracket without node test
276-
parseResult = Result::fail("Unexpected '[' without preceding node selector");
276+
parseResult = Result::fail ("Unexpected '[' without preceding node selector");
277277
return;
278278
}
279279

@@ -297,7 +297,7 @@ struct DataTreeQuery::XPathParser
297297
else
298298
{
299299
// Error parsing predicate expression
300-
parseResult = Result::fail("Invalid predicate expression inside brackets");
300+
parseResult = Result::fail ("Invalid predicate expression inside brackets");
301301
return;
302302
}
303303

@@ -307,7 +307,7 @@ struct DataTreeQuery::XPathParser
307307
else
308308
{
309309
// Error: missing closing bracket
310-
parseResult = Result::fail("Missing closing bracket ']' in predicate");
310+
parseResult = Result::fail ("Missing closing bracket ']' in predicate");
311311
return;
312312
}
313313
}
@@ -430,9 +430,9 @@ struct DataTreeQuery::XPathParser
430430
{
431431
++currentToken;
432432
auto value = parseValue();
433-
if (!isValidValue(value))
433+
if (! isValidValue (value))
434434
{
435-
parseResult = Result::fail("Expected value after comparison operator");
435+
parseResult = Result::fail ("Expected value after comparison operator");
436436
return nullptr;
437437
}
438438
return std::make_unique<Predicate> (Predicate::PropertyEquals, propertyName, value);
@@ -441,9 +441,9 @@ struct DataTreeQuery::XPathParser
441441
{
442442
++currentToken;
443443
auto value = parseValue();
444-
if (!isValidValue(value))
444+
if (! isValidValue (value))
445445
{
446-
parseResult = Result::fail("Expected value after comparison operator");
446+
parseResult = Result::fail ("Expected value after comparison operator");
447447
return nullptr;
448448
}
449449
return std::make_unique<Predicate> (Predicate::PropertyNotEquals, propertyName, value);
@@ -452,9 +452,9 @@ struct DataTreeQuery::XPathParser
452452
{
453453
++currentToken;
454454
auto value = parseValue();
455-
if (!isValidValue(value))
455+
if (! isValidValue (value))
456456
{
457-
parseResult = Result::fail("Expected value after comparison operator");
457+
parseResult = Result::fail ("Expected value after comparison operator");
458458
return nullptr;
459459
}
460460
return std::make_unique<Predicate> (Predicate::PropertyGreater, propertyName, value);
@@ -463,9 +463,9 @@ struct DataTreeQuery::XPathParser
463463
{
464464
++currentToken;
465465
auto value = parseValue();
466-
if (!isValidValue(value))
466+
if (! isValidValue (value))
467467
{
468-
parseResult = Result::fail("Expected value after comparison operator");
468+
parseResult = Result::fail ("Expected value after comparison operator");
469469
return nullptr;
470470
}
471471
return std::make_unique<Predicate> (Predicate::PropertyLess, propertyName, value);
@@ -474,9 +474,9 @@ struct DataTreeQuery::XPathParser
474474
{
475475
++currentToken;
476476
auto value = parseValue();
477-
if (!isValidValue(value))
477+
if (! isValidValue (value))
478478
{
479-
parseResult = Result::fail("Expected value after comparison operator");
479+
parseResult = Result::fail ("Expected value after comparison operator");
480480
return nullptr;
481481
}
482482
return std::make_unique<Predicate> (Predicate::PropertyGreaterEqual, propertyName, value);
@@ -485,9 +485,9 @@ struct DataTreeQuery::XPathParser
485485
{
486486
++currentToken;
487487
auto value = parseValue();
488-
if (!isValidValue(value))
488+
if (! isValidValue (value))
489489
{
490-
parseResult = Result::fail("Expected value after comparison operator");
490+
parseResult = Result::fail ("Expected value after comparison operator");
491491
return nullptr;
492492
}
493493
return std::make_unique<Predicate> (Predicate::PropertyLessEqual, propertyName, value);
@@ -500,7 +500,7 @@ struct DataTreeQuery::XPathParser
500500
else
501501
{
502502
// Error: @ not followed by identifier in predicate
503-
parseResult = Result::fail("Expected property name after '@' in predicate");
503+
parseResult = Result::fail ("Expected property name after '@' in predicate");
504504
return nullptr;
505505
}
506506
}
@@ -542,13 +542,13 @@ struct DataTreeQuery::XPathParser
542542

543543
return {};
544544
}
545-
546-
bool isValidValue(const var& value) const
545+
546+
bool isValidValue (const var& value) const
547547
{
548548
// Check if the value is valid (not empty/null in meaningful way)
549549
// For XPath parsing, any parsed value should be valid
550550
// But if parseValue() was called and no value was found, it returns empty var
551-
return !value.isVoid();
551+
return ! value.isVoid();
552552
}
553553

554554
void addPredicateOperation (std::vector<DataTreeQuery::QueryOperation>& operations,
@@ -557,14 +557,13 @@ struct DataTreeQuery::XPathParser
557557
QueryOperation op (QueryOperation::Where);
558558

559559
auto predicatePtr = std::shared_ptr<Predicate> (std::move (predicate));
560-
560+
561561
// Store the predicate for position-aware evaluation
562562
op.xpathPredicate = predicatePtr;
563-
563+
564564
operations.push_back (std::move (op));
565565
}
566566

567-
568567
public:
569568
static bool evaluatePredicate (const Predicate& predicate, const DataTree& node, int position, int totalCount)
570569
{
@@ -580,22 +579,22 @@ struct DataTreeQuery::XPathParser
580579
return ! node.hasProperty (predicate.property) || node.getProperty (predicate.property) != predicate.value;
581580

582581
case Predicate::PropertyGreater:
583-
if (!node.hasProperty (predicate.property))
582+
if (! node.hasProperty (predicate.property))
584583
return false;
585584
return node.getProperty (predicate.property) > predicate.value;
586585

587586
case Predicate::PropertyLess:
588-
if (!node.hasProperty (predicate.property))
587+
if (! node.hasProperty (predicate.property))
589588
return false;
590589
return node.getProperty (predicate.property) < predicate.value;
591590

592591
case Predicate::PropertyGreaterEqual:
593-
if (!node.hasProperty (predicate.property))
592+
if (! node.hasProperty (predicate.property))
594593
return false;
595594
return node.getProperty (predicate.property) >= predicate.value;
596595

597596
case Predicate::PropertyLessEqual:
598-
if (!node.hasProperty (predicate.property))
597+
if (! node.hasProperty (predicate.property))
599598
return false;
600599
return node.getProperty (predicate.property) <= predicate.value;
601600

@@ -768,7 +767,7 @@ struct DataTreeQuery::XPathParser
768767
else
769768
{
770769
// Error: Unmatched quote
771-
parseResult = Result::fail("Unmatched quote in string literal");
770+
parseResult = Result::fail ("Unmatched quote in string literal");
772771
}
773772
}
774773

@@ -942,7 +941,7 @@ DataTreeQuery& DataTreeQuery::xpath (const String& query)
942941
rootNode = DataTree();
943942
return *this;
944943
}
945-
944+
946945
for (auto& op : xpathOps)
947946
operations.push_back (std::move (op));
948947

@@ -1113,7 +1112,6 @@ std::vector<DataTree> DataTreeQuery::executeOperations() const
11131112
return result;
11141113
}
11151114

1116-
11171115
std::vector<DataTree> DataTreeQuery::applyOperation (const QueryOperation& op, const std::vector<DataTree>& input, const DataTree& rootNode)
11181116
{
11191117
std::vector<DataTree> result;
@@ -1157,21 +1155,21 @@ std::vector<DataTree> DataTreeQuery::applyOperation (const QueryOperation& op, c
11571155
{
11581156
for (const auto& node : input)
11591157
{
1160-
std::function<void(const DataTree&)> traverse = [&](const DataTree& current)
1158+
std::function<void (const DataTree&)> traverse = [&] (const DataTree& current)
11611159
{
11621160
const int numChildren = current.getNumChildren();
11631161
for (int i = 0; i < numChildren; ++i)
11641162
{
1165-
auto child = current.getChild(i);
1163+
auto child = current.getChild (i);
11661164
if (child.isValid())
11671165
{
1168-
result.push_back(child);
1169-
traverse(child); // Recursively process child
1166+
result.push_back (child);
1167+
traverse (child); // Recursively process child
11701168
}
11711169
}
11721170
};
11731171

1174-
traverse(node);
1172+
traverse (node);
11751173
}
11761174

11771175
break;
@@ -1180,25 +1178,25 @@ std::vector<DataTree> DataTreeQuery::applyOperation (const QueryOperation& op, c
11801178
case QueryOperation::DescendantsOfType:
11811179
{
11821180
Identifier type (op.parameter1.toString());
1183-
1181+
11841182
for (const auto& node : input)
11851183
{
1186-
std::function<void(const DataTree&)> traverse = [&](const DataTree& current)
1184+
std::function<void (const DataTree&)> traverse = [&] (const DataTree& current)
11871185
{
11881186
const int numChildren = current.getNumChildren();
11891187
for (int i = 0; i < numChildren; ++i)
11901188
{
1191-
auto child = current.getChild(i);
1189+
auto child = current.getChild (i);
11921190
if (child.isValid())
11931191
{
11941192
if (child.getType() == type)
1195-
result.push_back(child);
1196-
traverse(child); // Recursively process child
1193+
result.push_back (child);
1194+
traverse (child); // Recursively process child
11971195
}
11981196
}
11991197
};
12001198

1201-
traverse(node);
1199+
traverse (node);
12021200
}
12031201

12041202
break;
@@ -1223,7 +1221,7 @@ std::vector<DataTree> DataTreeQuery::applyOperation (const QueryOperation& op, c
12231221
auto parent = node.getParent();
12241222
while (parent.isValid())
12251223
{
1226-
result.push_back(parent);
1224+
result.push_back (parent);
12271225
parent = parent.getParent();
12281226
}
12291227
}
@@ -1255,12 +1253,12 @@ std::vector<DataTree> DataTreeQuery::applyOperation (const QueryOperation& op, c
12551253
if (op.xpathPredicate)
12561254
{
12571255
// XPath predicate with position information
1258-
auto predicate = std::static_pointer_cast<XPathParser::Predicate>(op.xpathPredicate);
1259-
int totalCount = static_cast<int>(input.size());
1260-
for (int i = 0; i < static_cast<int>(input.size()); ++i)
1256+
auto predicate = std::static_pointer_cast<XPathParser::Predicate> (op.xpathPredicate);
1257+
int totalCount = static_cast<int> (input.size());
1258+
for (int i = 0; i < static_cast<int> (input.size()); ++i)
12611259
{
12621260
const auto& node = input[i];
1263-
if (XPathParser::evaluatePredicate(*predicate, node, i, totalCount))
1261+
if (XPathParser::evaluatePredicate (*predicate, node, i, totalCount))
12641262
result.push_back (node);
12651263
}
12661264
}

modules/yup_data_model/tree/yup_DataTreeQuery.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,7 @@ class YUP_API DataTreeQuery
10121012
var parameter2;
10131013
std::function<bool (const DataTree&)> predicate;
10141014
std::function<var (const DataTree&)> transformer;
1015-
1015+
10161016
// For XPath predicates that need position information
10171017
std::shared_ptr<void> xpathPredicate;
10181018

0 commit comments

Comments
 (0)