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

Method OpenOptionCompleteFunction

gcore/gdalalgorithm.cpp:4336–4430  ·  view source on GitHub ↗

@cond Doxygen_Suppress

Source from the content-addressed store, hash-verified

4334
4335//! @cond Doxygen_Suppress
4336std::vector<std::string>
4337GDALAlgorithm::OpenOptionCompleteFunction(const std::string &currentValue) 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, &currentValue,
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(

Callers

nothing calls this directly

Calls 15

GetArgFunction · 0.85
GetGDALDriverManagerFunction · 0.85
CPLGetExtensionSafeFunction · 0.85
CSLTokenizeString2Function · 0.85
IterateFunction · 0.85
containsFunction · 0.85
EQUALFunction · 0.50
GetTypeMethod · 0.45
sizeMethod · 0.45
GetDriverByNameMethod · 0.45
c_strMethod · 0.45
GetMetadataItemMethod · 0.45

Tested by

no test coverage detected