| 2771 | } |
| 2772 | |
| 2773 | static std::set<int> GetNestedSaveIDs(const Bson &j) |
| 2774 | { |
| 2775 | std::set<int> saveIDs; |
| 2776 | for (auto &[ key, member ] : j.As<Bson::Object>()) |
| 2777 | { |
| 2778 | if (member.Is<int32_t>()) |
| 2779 | { |
| 2780 | saveIDs.insert(member.As<int32_t>()); |
| 2781 | } |
| 2782 | else if (member.Is<Bson::Array>()) |
| 2783 | { |
| 2784 | for (auto &link : member.As<Bson::Array>()) |
| 2785 | { |
| 2786 | // only supports objects and ints here because that is all we need |
| 2787 | if (link.Is<int32_t>()) |
| 2788 | { |
| 2789 | saveIDs.insert(link.As<int32_t>()); |
| 2790 | continue; |
| 2791 | } |
| 2792 | if (!link.Is<Bson::Object>()) |
| 2793 | { |
| 2794 | continue; |
| 2795 | } |
| 2796 | auto nestedSaveIDs = GetNestedSaveIDs(link); |
| 2797 | saveIDs.insert(nestedSaveIDs.begin(), nestedSaveIDs.end()); |
| 2798 | } |
| 2799 | } |
| 2800 | } |
| 2801 | return saveIDs; |
| 2802 | } |
| 2803 | |
| 2804 | // converts a json object to bson |
| 2805 | static void TrimAuthorsOut(Bson &b, int depth) |
no test coverage detected