Skip to content

Commit

Permalink
Add GDALAlgorithm::AddStrictLaxArg()
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Feb 4, 2025
1 parent 8d8fb57 commit 1ba0066
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
18 changes: 18 additions & 0 deletions gcore/gdalalgorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2770,6 +2770,24 @@ GDALInConstructionAlgorithmArg &GDALAlgorithm::AddProgressArg()
.SetCategory(GAAC_COMMON);
}

/************************************************************************/
/* GDALAlgorithm::AddStrictLaxArg() */
/************************************************************************/

void GDALAlgorithm::AddStrictLaxArg()
{
AddArg("strict", 0, _("Strict mode"), &m_strictMode)
.SetMutualExclusionGroup("strict-lax")
.AddAction([this]() { m_laxMode = false; })
.SetDefault(true)
.SetCategory(GAAC_COMMON);
AddArg("lax", 0, _("Relaxed mode"), &m_laxMode)
.SetMutualExclusionGroup("strict-lax")
.AddAction([this]() { m_strictMode = false; })
.SetDefault(false)
.SetCategory(GAAC_COMMON);
}

/************************************************************************/
/* GDALAlgorithm::Run() */
/************************************************************************/
Expand Down
9 changes: 9 additions & 0 deletions gcore/gdalalgorithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,9 @@ class CPL_DLL GDALAlgorithmRegistry
/** Whether a progress bar is requested (value of --progress argument) */
bool m_progressBarRequested = false;

/** Whether strict mode is requested (value of --strict) */
bool m_strictMode = true;

friend class GDALVectorPipelineAlgorithm;
/** Whether ValidateArguments() should be skipped during ParseCommandLineArguments() */
bool m_skipValidationInParseCommandLine = false;
Expand Down Expand Up @@ -2174,6 +2177,9 @@ class CPL_DLL GDALAlgorithmRegistry
/** Add --progress argument. */
GDALInConstructionAlgorithmArg &AddProgressArg();

/** Add --strict / --lax argument */
void AddStrictLaxArg();

/** Validation function to use for key=value type of arguments. */
bool ValidateKeyValue(const GDALAlgorithmArg &arg) const;

Expand Down Expand Up @@ -2221,6 +2227,9 @@ class CPL_DLL GDALAlgorithmRegistry
std::function<std::vector<std::string>(const std::vector<std::string> &)>
m_autoCompleteFunction{};

/** Whether relaxed mode is requested (value of --lax) */
bool m_laxMode = false;

GDALInConstructionAlgorithmArg &
AddArg(std::unique_ptr<GDALInConstructionAlgorithmArg> arg);
bool ParseArgument(
Expand Down

0 comments on commit 1ba0066

Please sign in to comment.