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

Method ProcessDatasetArg

gcore/gdalalgorithm.cpp:2729–3124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2727/************************************************************************/
2728
2729bool GDALAlgorithm::ProcessDatasetArg(GDALAlgorithmArg *arg,
2730 GDALAlgorithm *algForOutput)
2731{
2732 bool ret = true;
2733
2734 const auto updateArg = algForOutput->GetArg(GDAL_ARG_NAME_UPDATE);
2735 const bool hasUpdateArg = updateArg && updateArg->GetType() == GAAT_BOOLEAN;
2736 const bool update = hasUpdateArg && updateArg->Get<bool>();
2737
2738 const auto appendArg = algForOutput->GetArg(GDAL_ARG_NAME_APPEND);
2739 const bool hasAppendArg = appendArg && appendArg->GetType() == GAAT_BOOLEAN;
2740 const bool append = hasAppendArg && appendArg->Get<bool>();
2741
2742 const auto overwriteArg = algForOutput->GetArg(GDAL_ARG_NAME_OVERWRITE);
2743 const bool overwrite =
2744 (arg->IsOutput() && overwriteArg &&
2745 overwriteArg->GetType() == GAAT_BOOLEAN && overwriteArg->Get<bool>());
2746
2747 auto outputArg = algForOutput->GetArg(GDAL_ARG_NAME_OUTPUT);
2748 auto &val = [arg]() -> GDALArgDatasetValue &
2749 {
2750 if (arg->GetType() == GAAT_DATASET_LIST)
2751 return arg->Get<std::vector<GDALArgDatasetValue>>()[0];
2752 else
2753 return arg->Get<GDALArgDatasetValue>();
2754 }();
2755 const bool onlyInputSpecifiedInUpdateAndOutputNotRequired =
2756 arg->GetName() == GDAL_ARG_NAME_INPUT && outputArg &&
2757 !outputArg->IsExplicitlySet() && !outputArg->IsRequired() && update &&
2758 !overwrite;
2759
2760 // Used for nested pipelines
2761 const auto oIterDatasetNameToDataset =
2762 val.IsNameSet() ? m_oMapDatasetNameToDataset.find(val.GetName())
2763 : m_oMapDatasetNameToDataset.end();
2764
2765 if (!val.GetDatasetRef() && !val.IsNameSet())
2766 {
2767 ReportError(CE_Failure, CPLE_AppDefined,
2768 "Argument '%s' has no dataset object or dataset name.",
2769 arg->GetName().c_str());
2770 ret = false;
2771 }
2772 else if (val.GetDatasetRef() && !CheckCanSetDatasetObject(arg))
2773 {
2774 return false;
2775 }
2776 else if (m_inputDatasetCanBeOmitted &&
2777 val.GetName() == GDAL_DATASET_PIPELINE_PLACEHOLDER_VALUE &&
2778 !arg->IsOutput())
2779 {
2780 return true;
2781 }
2782 else if (!val.GetDatasetRef() &&
2783 (arg->AutoOpenDataset() ||
2784 oIterDatasetNameToDataset != m_oMapDatasetNameToDataset.end()) &&
2785 (!arg->IsOutput() || (arg == outputArg && update && !overwrite) ||
2786 onlyInputSpecifiedInUpdateAndOutputNotRequired))

Callers 1

Calls 15

CheckCanSetDatasetObjectFunction · 0.85
GetArgFunction · 0.85
GetGDALDriverManagerFunction · 0.85
VSIUnlinkFunction · 0.85
VSIStrerrorFunction · 0.85
VSIStatLFunction · 0.85
GetArgMethod · 0.80
FetchNameValueMethod · 0.80
SetNameValueMethod · 0.80
ListMethod · 0.80
eraseMethod · 0.80

Tested by

no test coverage detected