| 523 | } |
| 524 | |
| 525 | int hasOperatorFieldnames(bson::BSONObj obj, |
| 526 | int maxDepth, |
| 527 | int ensureEveryFieldnameBeyondThisDepthIsAnOperator, |
| 528 | int currentDepth) { |
| 529 | int index = 0; |
| 530 | for (auto i = obj.begin(); i.more(); index++) { |
| 531 | auto next = i.next(); |
| 532 | if (next.fieldName()[0] == '$') { |
| 533 | if (currentDepth > ensureEveryFieldnameBeyondThisDepthIsAnOperator) { |
| 534 | if (index > 0) |
| 535 | throw mixed_operator_literal_update(); |
| 536 | else |
| 537 | while (i.more()) |
| 538 | if (i.next().fieldName()[0] != '$') |
| 539 | throw mixed_operator_literal_update(); |
| 540 | } |
| 541 | return ++currentDepth; |
| 542 | } |
| 543 | int depth; |
| 544 | if ((maxDepth > currentDepth || maxDepth < 0) && next.type() == bson::BSONType::Object && |
| 545 | (depth = hasOperatorFieldnames(next.Obj(), maxDepth, ensureEveryFieldnameBeyondThisDepthIsAnOperator, |
| 546 | ++currentDepth))) |
| 547 | return depth; |
| 548 | } |
| 549 | return 0; |
| 550 | } |
| 551 | |
| 552 | template <class T> |
| 553 | bool isin(std::list<T> coll, T item) { |
no test coverage detected