MCPcopy Create free account
hub / github.com/OSGeo/gdal / FormatAutoCompleteFunction

Method FormatAutoCompleteFunction

gcore/gdalalgorithm.cpp:4674–4750  ·  view source on GitHub ↗

static */

Source from the content-addressed store, hash-verified

4672
4673/* static */
4674std::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))

Callers

nothing calls this directly

Calls 13

GetGDALDriverManagerFunction · 0.85
moveFunction · 0.85
frontMethod · 0.80
EQUALFunction · 0.50
GetMetadataItemMethod · 0.45
GetDriverCountMethod · 0.45
GetDriverMethod · 0.45
emptyMethod · 0.45
GetDescriptionMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected