| 595 | } |
| 596 | |
| 597 | bson::BSONObj convertCompoundStringToObj(bson::BSONObj obj) { |
| 598 | bson::BSONObjBuilder builder1; |
| 599 | |
| 600 | for (auto entries = obj.begin(); entries.more();) { |
| 601 | auto next = entries.next(); |
| 602 | |
| 603 | if (strchr(next.fieldName(), '.')) { |
| 604 | bson::BSONObjBuilder builder2; |
| 605 | bson::BSONObj child; |
| 606 | std::string fieldName(next.fieldName()); |
| 607 | std::string::size_type pos = fieldName.find('.'); |
| 608 | std::string childName(fieldName.substr(pos + 1)); |
| 609 | fieldName = fieldName.substr(0, pos); |
| 610 | |
| 611 | builder2.appendAs(next, bson::StringData(childName)); |
| 612 | |
| 613 | if (childName.find('.')) |
| 614 | child = convertCompoundStringToObj(builder2.obj()); |
| 615 | else |
| 616 | child = builder2.obj(); |
| 617 | |
| 618 | builder1.append(bson::StringData(fieldName), child); |
| 619 | } else |
| 620 | builder1.append(next); |
| 621 | } |
| 622 | return builder1.obj(); |
| 623 | } |
| 624 | |
| 625 | // bson::BSONObj deepConvertCompoundStringToObj(bson::BSONObj obj) |
| 626 | //{ |
no test coverage detected