Changeset 93287 in vbox for trunk/src/VBox/Frontends/VBoxManage
- Timestamp:
- Jan 17, 2022 10:08:11 PM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 149355
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/src/VBox/Frontends/VBoxManage/VBoxManageNATNetwork.cpp ¶
r93286 r93287 50 50 #include <VBox/log.h> 51 51 52 #include <algorithm> 52 53 #include <vector> 53 54 #include <iprt/sanitized/string> … … 635 636 HRESULT rc; 636 637 637 RT_NOREF(fSorted); 638 639 com::SafeIfaceArray<INATNetwork> nets; 640 CHECK_ERROR(pVirtualBox, COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(nets))); 641 for (size_t i = 0; i < nets.size(); ++i) 642 { 643 printNATNetwork(nets[i], fLong); 638 com::SafeIfaceArray<INATNetwork> aNets; 639 CHECK_ERROR_RET(pVirtualBox, 640 COMGETTER(NATNetworks)(ComSafeArrayAsOutParam(aNets)), 641 RTEXITCODE_FAILURE); 642 643 const size_t cNets = aNets.size(); 644 if (cNets == 0) 645 return RTEXITCODE_SUCCESS; 646 647 /* 648 * Sort the list if necessary. The sort is indirect via an 649 * intermediate array of indexes. 650 */ 651 std::vector<size_t> vIndexes(cNets); 652 for (size_t i = 0; i < cNets; ++i) 653 vIndexes[i] = i; 654 655 if (fSorted) 656 { 657 std::vector<com::Bstr> vBstrNames(cNets); 658 for (size_t i = 0; i < cNets; ++i) 659 { 660 CHECK_ERROR_RET(aNets[i], 661 COMGETTER(NetworkName)(vBstrNames[i].asOutParam()), 662 RTEXITCODE_FAILURE); 663 } 664 665 struct SortBy { 666 const std::vector<com::Bstr> &ks; 667 SortBy(const std::vector<com::Bstr> &aKeys) : ks(aKeys) {} 668 bool operator() (size_t l, size_t r) { return ks[l] < ks[r]; } 669 }; 670 671 std::sort(vIndexes.begin(), vIndexes.end(), 672 SortBy(vBstrNames)); 673 } 674 675 for (size_t i = 0; i < cNets; ++i) 676 { 677 printNATNetwork(aNets[vIndexes[i]], fLong); 644 678 } 645 679
Note:
See TracChangeset
for help on using the changeset viewer.