static */
| 4672 | |
| 4673 | /* static */ |
| 4674 | std::vector<std::string> GDALAlgorithm::FormatAutoCompleteFunction( |
| 4675 | const GDALAlgorithmArg &arg, bool /* bStreamAllowed */, bool bGDALGAllowed) |
| 4676 | { |
| 4677 | std::vector<std::string> res; |
| 4678 | auto poDM = GetGDALDriverManager(); |
| 4679 | const auto vrtCompatible = arg.GetMetadataItem(GAAMDI_VRT_COMPATIBLE); |
| 4680 | const auto allowedFormats = arg.GetMetadataItem(GAAMDI_ALLOWED_FORMATS); |
| 4681 | const auto excludedFormats = arg.GetMetadataItem(GAAMDI_EXCLUDED_FORMATS); |
| 4682 | const auto caps = arg.GetMetadataItem(GAAMDI_REQUIRED_CAPABILITIES); |
| 4683 | if (auto extraFormats = arg.GetMetadataItem(GAAMDI_EXTRA_FORMATS)) |
| 4684 | res = std::move(*extraFormats); |
| 4685 | for (int i = 0; i < poDM->GetDriverCount(); ++i) |
| 4686 | { |
| 4687 | auto poDriver = poDM->GetDriver(i); |
| 4688 | |
| 4689 | if (vrtCompatible && !vrtCompatible->empty() && |
| 4690 | vrtCompatible->front() == "false" && |
| 4691 | EQUAL(poDriver->GetDescription(), "VRT")) |
| 4692 | { |
| 4693 | // do nothing |
| 4694 | } |
| 4695 | else if (allowedFormats && !allowedFormats->empty() && |
| 4696 | std::find(allowedFormats->begin(), allowedFormats->end(), |
| 4697 | poDriver->GetDescription()) != allowedFormats->end()) |
| 4698 | { |
| 4699 | res.push_back(poDriver->GetDescription()); |
| 4700 | } |
| 4701 | else if (excludedFormats && !excludedFormats->empty() && |
| 4702 | std::find(excludedFormats->begin(), excludedFormats->end(), |
| 4703 | poDriver->GetDescription()) != |
| 4704 | excludedFormats->end()) |
| 4705 | { |
| 4706 | continue; |
| 4707 | } |
| 4708 | else if (caps) |
| 4709 | { |
| 4710 | bool ok = true; |
| 4711 | for (const std::string &cap : *caps) |
| 4712 | { |
| 4713 | if (cap == GDAL_ALG_DCAP_RASTER_OR_MULTIDIM_RASTER) |
| 4714 | { |
| 4715 | if (!poDriver->GetMetadataItem(GDAL_DCAP_RASTER) && |
| 4716 | !poDriver->GetMetadataItem(GDAL_DCAP_MULTIDIM_RASTER)) |
| 4717 | { |
| 4718 | ok = false; |
| 4719 | break; |
| 4720 | } |
| 4721 | } |
| 4722 | else if (const char *pszVal = |
| 4723 | poDriver->GetMetadataItem(cap.c_str()); |
| 4724 | pszVal && pszVal[0]) |
| 4725 | { |
| 4726 | } |
| 4727 | else if (cap == GDAL_DCAP_CREATECOPY && |
| 4728 | (std::find(caps->begin(), caps->end(), |
| 4729 | GDAL_DCAP_RASTER) != caps->end() && |
| 4730 | poDriver->GetMetadataItem(GDAL_DCAP_RASTER)) && |
| 4731 | poDriver->GetMetadataItem(GDAL_DCAP_CREATE)) |
nothing calls this directly
no test coverage detected