+
+DBus::ValueOrError<std::vector<Accessible*> > BridgeCollection::GetMatchesInMatches(MatchRule firstRule, MatchRule secondRule, uint32_t sortBy, int32_t firstCount, int32_t secondCount, bool traverse)
+{
+ std::vector<Accessible*> res;
+ std::vector<Accessible*> firstRes;
+ std::vector<Accessible*> secondRes;
+ auto self = BridgeBase::FindCurrentObject();
+ auto firstMatcher = Comparer{&firstRule};
+ auto secondMatcher = Comparer{&secondRule};
+ VisitNodes(self, firstRes, firstMatcher, firstCount);
+
+ for (auto &obj : firstRes)
+ {
+ VisitNodes(obj, secondRes, secondMatcher, secondCount);
+
+ res.insert(res.end(), secondRes.begin(), secondRes.end());
+ secondRes.clear();
+ }
+
+ switch(static_cast<SortOrder>(sortBy))
+ {
+ case SortOrder::CANONICAL:
+ {
+ break;
+ }
+
+ case SortOrder::REVERSE_CANONICAL:
+ {
+ std::reverse(res.begin(), res.end());
+ break;
+ }
+
+ default:
+ {
+ throw std::domain_error{"unsupported sorting order"};
+ }
+ //TODO: other cases
+ }
+
+ return res;
+}