MCPcopy Create free account
hub / github.com/FoundationDB/fdb-document-layer / hasOperatorFieldnames

Function hasOperatorFieldnames

src/ExtUtil.actor.cpp:525–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523}
524
525int 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
552template <class T>
553bool isin(std::list<T> coll, T item) {

Calls 1

beginMethod · 0.80

Tested by

no test coverage detected