| 723 | } |
| 724 | |
| 725 | bson::BSONObj sortBsonObj(bson::BSONObj obj) { |
| 726 | std::vector<bson::BSONElement> fields; |
| 727 | std::vector<bson::BSONObj> holder; |
| 728 | |
| 729 | for (auto i = obj.begin(); i.more();) { |
| 730 | auto e = i.next(); |
| 731 | if (e.type() != bson::BSONType::Object) { |
| 732 | fields.push_back(e); |
| 733 | } else { |
| 734 | bson::BSONObj newObj = BSON(e.fieldName() << sortBsonObj(e.Obj())).getOwned(); |
| 735 | holder.push_back(newObj); |
| 736 | fields.push_back(newObj.firstElement()); |
| 737 | } |
| 738 | } |
| 739 | std::sort(fields.begin(), fields.end(), [](bson::BSONElement left, bson::BSONElement right) { |
| 740 | return strcmp(left.fieldName(), right.fieldName()) < 0; |
| 741 | }); |
| 742 | bson::BSONObjBuilder b(obj.objsize()); |
| 743 | for (auto e : fields) { |
| 744 | b.append(e); |
| 745 | } |
| 746 | return b.obj(); |
| 747 | } |
| 748 | |
| 749 | Optional<IdInfo> extractEncodedIds(bson::BSONObj obj) { |
| 750 | bson::BSONElement el; |
no test coverage detected