@cond Doxygen_Suppress
| 4334 | |
| 4335 | //! @cond Doxygen_Suppress |
| 4336 | std::vector<std::string> |
| 4337 | GDALAlgorithm::OpenOptionCompleteFunction(const std::string ¤tValue) const |
| 4338 | { |
| 4339 | std::vector<std::string> oRet; |
| 4340 | |
| 4341 | int datasetType = GDAL_OF_RASTER | GDAL_OF_VECTOR | GDAL_OF_MULTIDIM_RASTER; |
| 4342 | auto inputArg = GetArg(GDAL_ARG_NAME_INPUT); |
| 4343 | if (inputArg && (inputArg->GetType() == GAAT_DATASET || |
| 4344 | inputArg->GetType() == GAAT_DATASET_LIST)) |
| 4345 | { |
| 4346 | datasetType = inputArg->GetDatasetType(); |
| 4347 | } |
| 4348 | |
| 4349 | auto inputFormat = GetArg(GDAL_ARG_NAME_INPUT_FORMAT); |
| 4350 | if (inputFormat && inputFormat->GetType() == GAAT_STRING_LIST && |
| 4351 | inputFormat->IsExplicitlySet()) |
| 4352 | { |
| 4353 | const auto &aosAllowedDrivers = |
| 4354 | inputFormat->Get<std::vector<std::string>>(); |
| 4355 | if (aosAllowedDrivers.size() == 1) |
| 4356 | { |
| 4357 | auto poDriver = GetGDALDriverManager()->GetDriverByName( |
| 4358 | aosAllowedDrivers[0].c_str()); |
| 4359 | if (poDriver) |
| 4360 | { |
| 4361 | AddOptionsSuggestions( |
| 4362 | poDriver->GetMetadataItem(GDAL_DMD_OPENOPTIONLIST), |
| 4363 | datasetType, currentValue, oRet); |
| 4364 | } |
| 4365 | return oRet; |
| 4366 | } |
| 4367 | } |
| 4368 | |
| 4369 | const auto AddSuggestions = [datasetType, ¤tValue, |
| 4370 | &oRet](const GDALArgDatasetValue &datasetValue) |
| 4371 | { |
| 4372 | auto poDM = GetGDALDriverManager(); |
| 4373 | |
| 4374 | const auto &osDSName = datasetValue.GetName(); |
| 4375 | const std::string osExt = CPLGetExtensionSafe(osDSName.c_str()); |
| 4376 | if (!osExt.empty()) |
| 4377 | { |
| 4378 | std::set<std::string> oVisitedExtensions; |
| 4379 | for (int i = 0; i < poDM->GetDriverCount(); ++i) |
| 4380 | { |
| 4381 | auto poDriver = poDM->GetDriver(i); |
| 4382 | if (((datasetType & GDAL_OF_RASTER) != 0 && |
| 4383 | poDriver->GetMetadataItem(GDAL_DCAP_RASTER)) || |
| 4384 | ((datasetType & GDAL_OF_VECTOR) != 0 && |
| 4385 | poDriver->GetMetadataItem(GDAL_DCAP_VECTOR)) || |
| 4386 | ((datasetType & GDAL_OF_MULTIDIM_RASTER) != 0 && |
| 4387 | poDriver->GetMetadataItem(GDAL_DCAP_MULTIDIM_RASTER))) |
| 4388 | { |
| 4389 | const char *pszExtensions = |
| 4390 | poDriver->GetMetadataItem(GDAL_DMD_EXTENSIONS); |
| 4391 | if (pszExtensions) |
| 4392 | { |
| 4393 | const CPLStringList aosExts( |
nothing calls this directly
no test coverage detected