| 279 | } |
| 280 | |
| 281 | std::vector<int> BuildOpenOrder(const std::vector<CameraCandidate>& candidates, const std::string& requestedName) |
| 282 | { |
| 283 | std::vector<int> order; |
| 284 | order.reserve(candidates.size()); |
| 285 | |
| 286 | auto addUnique = [&](int idx) |
| 287 | { |
| 288 | if (idx < 0 || idx >= static_cast<int>(candidates.size())) |
| 289 | return; |
| 290 | if (std::find(order.begin(), order.end(), idx) == order.end()) |
| 291 | order.push_back(idx); |
| 292 | }; |
| 293 | |
| 294 | const std::string trimmedRequest = OtherTools::TrimAscii(requestedName); |
| 295 | const std::string lowerRequest = OtherTools::ToLowerAscii(trimmedRequest); |
| 296 | const bool autoSelect = trimmedRequest.empty() || lowerRequest == "none" || lowerRequest == "auto"; |
| 297 | |
| 298 | if (!autoSelect) |
| 299 | { |
| 300 | int exact = FindExactNameMatch(candidates, trimmedRequest); |
| 301 | if (exact >= 0) |
| 302 | addUnique(exact); |
| 303 | else |
| 304 | { |
| 305 | int partial = FindPartialNameMatch(candidates, trimmedRequest); |
| 306 | if (partial >= 0) |
| 307 | addUnique(partial); |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | int bestAutoIdx = -1; |
| 312 | int bestScore = -1; |
| 313 | for (int i = 0; i < static_cast<int>(candidates.size()); ++i) |
| 314 | { |
| 315 | const int score = ScoreAutoCameraChoice(candidates[i]); |
| 316 | if (score > bestScore) |
| 317 | { |
| 318 | bestScore = score; |
| 319 | bestAutoIdx = i; |
| 320 | } |
| 321 | } |
| 322 | addUnique(bestAutoIdx); |
| 323 | |
| 324 | for (int i = 0; i < static_cast<int>(candidates.size()); ++i) |
| 325 | addUnique(i); |
| 326 | |
| 327 | return order; |
| 328 | } |
| 329 | |
| 330 | bool TryOpenCandidate( |
| 331 | const CameraCandidate& candidate, |
no test coverage detected